您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

payment.vue 7.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320
  1. <template>
  2. <div class="content">
  3. <custom-header title="订单详情" :back="config.hasReturn === 'true'"></custom-header>
  4. <div style="padding: 20rpx" v-if='isShow'>
  5. <view class="title">
  6. 订单详情
  7. </view>
  8. <view class="container">
  9. <template v-for='(item,index) in formData'>
  10. <view class="detail-item" :key='index' v-if='item.value !== "" && item.value !== undefined'>
  11. <text>{{item.label}}</text>
  12. <text class="amount">{{item.key === 'amount'? '¥'+ item.value:item.value}}</text>
  13. </view>
  14. </template>
  15. </view>
  16. <view class="payment-total">
  17. <text>实付款</text>
  18. <text class="amount">¥{{amount}}</text>
  19. </view>
  20. <button type="success" class="btn-txt btn" @click="submit">确认办理</button>
  21. </div>
  22. </div>
  23. </template>
  24. <script setup lang='ts'>
  25. import {
  26. unifyTemplate
  27. } from '@/hooks/unifyTemplate'
  28. import {
  29. reactive,
  30. ref
  31. } from 'vue'
  32. import {
  33. onLoad
  34. } from '@dcloudio/uni-app'
  35. import {
  36. request,
  37. OrdinaryRequest,
  38. myJsonp,
  39. toWeixin
  40. } from '@/utils/network/request'
  41. const {
  42. CustomHeader, //头部组件
  43. initData, //初始化数据
  44. isShow, //是否展示formBuilderVue组件
  45. qdOrderVal //qdOrder中数据 ref
  46. } = unifyTemplate() //初始化数据
  47. // import {
  48. // request
  49. // } from '../../static/js/network/request'
  50. let formData = reactive < any > ([{
  51. label: '产品名',
  52. value: '',
  53. key: "product",
  54. key1: 'promoteName',
  55. }, {
  56. label: '车牌号',
  57. key: "vehiclePlate",
  58. value: '贵'
  59. }, {
  60. label: '车主姓名',
  61. key: "ownerName",
  62. value: ''
  63. }, {
  64. label: '邮寄地址',
  65. key: "orderInfoExt",
  66. key1: 'region,address',
  67. default: "不邮寄",
  68. value: ''
  69. }, {
  70. label: '产品金额',
  71. key: "amount",
  72. format: (val) => {
  73. return val * 0.01
  74. },
  75. value: '0'
  76. }, ])
  77. // 实付款
  78. const amount = ref < any > ('')
  79. let config = ref < any > ({
  80. submitName: '提交',
  81. titleWidth: 160
  82. })
  83. onLoad((opin) => {
  84. // 初始化数据
  85. initData(opin, 4).then(data => {
  86. getOrderInfo(data.qdOrder.qtOrderNo)
  87. delete data.config.tableConfig
  88. config.value = Object.assign(data.config, config.value)
  89. })
  90. })
  91. // 数据处理
  92. function getOrderInfo(orderId) {
  93. request('8', {
  94. data: {
  95. orderId
  96. }
  97. }).then((res) => {
  98. let data = JSON.parse(res.bizContent)
  99. amount.value = data.amount * 0.01
  100. formData.forEach(item => {
  101. let itemData = data[item.key]
  102. if (typeof itemData === 'object') {
  103. if (item.key1.includes(',')) {
  104. let str = ''
  105. item.key1.split(',').forEach(listItem => {
  106. str += itemData[listItem] || ''
  107. })
  108. itemData = str
  109. } else {
  110. itemData = itemData[item.key1]
  111. }
  112. }
  113. if (item.format) {
  114. itemData = item.format(itemData)
  115. }
  116. item.value = itemData || item.default
  117. })
  118. isShow.value = true;
  119. })
  120. }
  121. //提交
  122. function submit() {
  123. // console.log('提交内容', item)
  124. uni.showLoading({
  125. title: '正在支付...',
  126. mask: true
  127. })
  128. let {
  129. jumpPage
  130. } = config.value
  131. setTimeout(() => {
  132. uni.hideLoading()
  133. contractTesting(qdOrderVal.value.qdOrderNo, jumpPage)
  134. // uni.navigateTo({
  135. // url: '/' + jumpPage,
  136. // animationType: 'pop-in',
  137. // animationDuration: 500
  138. // })
  139. }, 1000)
  140. // 根据公网ip获取支付地址
  141. myJsonp({
  142. url: 'https://www.taobao.com/help/getip.php',
  143. success(res) {
  144. console.log(res)
  145. const data = {
  146. fee: 1,
  147. spbillCreateIp: res.ip,
  148. }
  149. OrdinaryRequest({
  150. data,
  151. }).then(res => {
  152. if (res.code === 200) {
  153. console.log(res.data)
  154. // window.location.href = res.data.h5Url
  155. window.open(res.data.h5Url, '_blank')
  156. // 在当前窗口中打开一个新窗口
  157. // const newWindow = window.open('', '_self'); // 给 URL 添加自定义请求头信息
  158. // const url = res.data.h5Url;
  159. // const headers = {
  160. // 'Referer': 'www.aaa.com'
  161. // };
  162. // const params = new URLSearchParams(headers).toString();
  163. // const urlWithHeader = `${url}?${params}`; // 设置新窗口的 URL
  164. // newWindow.location.href = urlWithHeader;
  165. // const h5Url = res.data.h5Url.substring(21)
  166. // toWeixin(h5Url)
  167. }
  168. })
  169. }
  170. })
  171. // const data = {
  172. // fee: 1,
  173. // spbillCreateIp: '',
  174. // }
  175. // OrdinaryRequest({
  176. // data,
  177. // })
  178. }
  179. // 签约检测
  180. function contractTesting(qdOrderNo, jumpPage) {
  181. const data = {
  182. qdOrderNo,
  183. }
  184. request('fdfbdddba6ec49f8b451cf2e299b4feb', {
  185. data,
  186. }).then((res) => {
  187. if (res.statusCode === 0) {
  188. const data = JSON.parse(res.bizContent)
  189. if (data.status !== 0) {
  190. // 后台调用它方接口报错
  191. uni.showModal({
  192. title: '警告',
  193. content: data.msg,
  194. success: function(res) {}
  195. });
  196. return
  197. }
  198. if (data.signStatus === 1 && data.accountStatus === 1 && data.bindStatus === 1) {
  199. // 上面三值都为1才进行下一步,否则进行签约初始化
  200. if (!jumpPage) return
  201. uni.navigateTo({
  202. url: '/' + jumpPage,
  203. animationType: 'pop-in',
  204. animationDuration: 500
  205. })
  206. /* 自定义返回 */
  207. } else {
  208. // 进行签约初始化
  209. signingInitialization(qdOrderNo)
  210. }
  211. // qdOrderStore.orderInfo.value.orderId = JSON.parse(res.bizContent).orderId
  212. // 通过检测
  213. }
  214. })
  215. }
  216. // 签约初始化
  217. function signingInitialization(qdOrderNo) {
  218. const data = {
  219. qdOrderNo
  220. }
  221. request('94569071cf814517908cd35693f1f2e1', {
  222. data,
  223. }).then((res) => {
  224. if (res.statusCode === 0) {
  225. const data = JSON.parse(res.bizContent)
  226. if (data.status !== 0) {
  227. // 后台调用它方接口报错
  228. uni.showModal({
  229. title: '警告',
  230. content: data.msg,
  231. success: function(res) {}
  232. });
  233. return
  234. }
  235. if (data.returnType === 0) {
  236. // 0-无需跳转,关闭H5即可 1-需跳转至返回url
  237. // const opened = window.open('about:blank', '_self');
  238. // opened.opener = null;
  239. // opened.close();
  240. closeWin()
  241. } else {
  242. window.open(data.signUrl, '_self')
  243. }
  244. }
  245. })
  246. }
  247. // 关闭当前页面方法
  248. function closeWin() {
  249. // @ts-ignore
  250. var jWeixin = import('jweixin-module')
  251. // @ts-ignore
  252. jWeixin.miniProgram.getEnv(function(res) {
  253. if (res.miniprogram) {
  254. // @ts-ignore
  255. jWeixin.miniProgram.navigateTo({
  256. url: '/path/to/page'
  257. })
  258. } else {
  259. const opened = window.open('about:blank', '_self');
  260. opened.opener = null;
  261. opened.close()
  262. }
  263. })
  264. }
  265. </script>
  266. <style lang='scss' scoped>
  267. .title {
  268. font-size: 30rpx;
  269. margin-left: 30rpx;
  270. }
  271. .container {
  272. padding: 10px;
  273. font-size: 14px;
  274. .detail-item {
  275. display: flex;
  276. align-items: center;
  277. justify-content: space-between;
  278. padding: 5px;
  279. margin-bottom: 8px;
  280. border-bottom: 1px solid #ccc;
  281. }
  282. }
  283. .payment-total {
  284. text-align: right;
  285. padding: 0 10px 20px;
  286. }
  287. text {
  288. margin-left: 10px;
  289. }
  290. .amount {
  291. color: #1AAC1B;
  292. max-width: 450rpx;
  293. }
  294. .btn {
  295. height: 80rpx;
  296. opacity: 1;
  297. border-radius: 100rpx;
  298. margin: 20rpx 20rpx 20rpx 20rpx;
  299. }
  300. .btn-txt {
  301. background: #1AAC1B;
  302. margin: 10px;
  303. color: #FFFFFF;
  304. font-size: 28rpx;
  305. }
  306. </style>