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

payment.vue 6.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298
  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. }, 1000)
  135. // 根据公网ip获取支付地址
  136. // myJsonp({
  137. // url: 'https://www.taobao.com/help/getip.php',
  138. // success(res) {
  139. // console.log(res)
  140. // const data = {
  141. // fee: 1,
  142. // spbillCreateIp: res.ip,
  143. // }
  144. // OrdinaryRequest({
  145. // data,
  146. // }).then(res => {
  147. // if (res.code === 200) {
  148. // console.log(res.data)
  149. // window.location.href = res.data.h5Url
  150. // window.open(res.data.h5Url, '_blank')
  151. // 在当前窗口中打开一个新窗口
  152. // const newWindow = window.open('', '_self'); // 给 URL 添加自定义请求头信息
  153. // const url = res.data.h5Url;
  154. // const headers = {
  155. // 'Referer': 'www.aaa.com'
  156. // };
  157. // const params = new URLSearchParams(headers).toString();
  158. // const urlWithHeader = `${url}?${params}`; // 设置新窗口的 URL
  159. // newWindow.location.href = urlWithHeader;
  160. // const h5Url = res.data.h5Url.substring(21)
  161. // toWeixin(h5Url)
  162. // }
  163. // })
  164. // }
  165. // })
  166. // const data = {
  167. // fee: 1,
  168. // spbillCreateIp: '',
  169. // }
  170. // OrdinaryRequest({
  171. // data,
  172. // })
  173. }
  174. // 签约检测
  175. function contractTesting(qdOrderNo, jumpPage) {
  176. const data = {
  177. qdOrderNo,
  178. }
  179. request('fdfbdddba6ec49f8b451cf2e299b4feb', {
  180. data,
  181. }).then((res) => {
  182. if (res.statusCode === 0) {
  183. const data = JSON.parse(res.bizContent)
  184. if (data.signStatus === 1 && data.accountStatus === 1 && data.bindStatus === 1) {
  185. // 上面三值都为1才进行下一步,否则进行签约初始化
  186. if (!jumpPage) return
  187. uni.navigateTo({
  188. url: '/' + jumpPage,
  189. animationType: 'pop-in',
  190. animationDuration: 500
  191. })
  192. /* 自定义返回 */
  193. } else {
  194. // 进行签约初始化
  195. signingInitialization(qdOrderNo)
  196. }
  197. // qdOrderStore.orderInfo.value.orderId = JSON.parse(res.bizContent).orderId
  198. // 通过检测
  199. }
  200. })
  201. }
  202. // 签约初始化
  203. function signingInitialization(qdOrderNo) {
  204. const data = {
  205. qdOrderNo
  206. }
  207. request('94569071cf814517908cd35693f1f2e1', {
  208. data,
  209. }).then((res) => {
  210. if (res.statusCode === 0) {
  211. const data = JSON.parse(res.bizContent)
  212. if (data.returnType === 0) {
  213. // 0-无需跳转,关闭H5即可 1-需跳转至返回url
  214. // const opened = window.open('about:blank', '_self');
  215. // opened.opener = null;
  216. // opened.close();
  217. closeWin()
  218. } else {
  219. window.open(data.signUrl, '_self')
  220. }
  221. }
  222. })
  223. }
  224. // 关闭当前页面方法
  225. function closeWin() {
  226. // @ts-ignore
  227. var jWeixin = import('jweixin-module')
  228. // @ts-ignore
  229. jWeixin.miniProgram.getEnv(function(res) {
  230. if (res.miniprogram) {
  231. // @ts-ignore
  232. jWeixin.miniProgram.navigateTo({
  233. url: '/path/to/page'
  234. })
  235. } else {
  236. const opened = window.open('about:blank', '_self');
  237. opened.opener = null;
  238. opened.close()
  239. }
  240. })
  241. }
  242. </script>
  243. <style lang='scss' scoped>
  244. .title {
  245. font-size: 30rpx;
  246. margin-left: 30rpx;
  247. }
  248. .container {
  249. padding: 10px;
  250. font-size: 14px;
  251. .detail-item {
  252. display: flex;
  253. align-items: center;
  254. justify-content: space-between;
  255. padding: 5px;
  256. margin-bottom: 8px;
  257. border-bottom: 1px solid #ccc;
  258. }
  259. }
  260. .payment-total {
  261. text-align: right;
  262. padding: 0 10px 20px;
  263. }
  264. text {
  265. margin-left: 10px;
  266. }
  267. .amount {
  268. color: #1AAC1B;
  269. max-width: 450rpx;
  270. }
  271. .btn {
  272. height: 80rpx;
  273. opacity: 1;
  274. border-radius: 100rpx;
  275. margin: 20rpx 20rpx 20rpx 20rpx;
  276. }
  277. .btn-txt {
  278. background: #1AAC1B;
  279. margin: 10px;
  280. color: #FFFFFF;
  281. font-size: 28rpx;
  282. }
  283. </style>