Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

payment.vue 6.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308
  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. }).finally(() => {
  158. uni.hideLoading()
  159. })
  160. // request('fdfbdddba6ec49f8b451cf2e299b4feb', {
  161. // data,
  162. // }).then((res) => {
  163. // if (res.statusCode === 0) {
  164. // console.log(res);
  165. // }
  166. })
  167. }
  168. })
  169. }
  170. // 签约检测
  171. function contractTesting(qdOrderNo, jumpPage) {
  172. const data = {
  173. qdOrderNo,
  174. }
  175. request('fdfbdddba6ec49f8b451cf2e299b4feb', {
  176. data,
  177. }).then((res) => {
  178. if (res.statusCode === 0) {
  179. const data = JSON.parse(res.bizContent)
  180. if (data.status !== 0) {
  181. // 后台调用它方接口报错
  182. uni.showModal({
  183. title: '警告',
  184. content: data.msg,
  185. success: function(res) {}
  186. });
  187. return
  188. }
  189. if (data.signStatus === 1 && data.accountStatus === 1 && data.bindStatus === 1) {
  190. // 上面三值都为1才进行下一步,否则进行签约初始化
  191. if (!jumpPage) return
  192. uni.navigateTo({
  193. url: '/' + jumpPage,
  194. animationType: 'pop-in',
  195. animationDuration: 500
  196. })
  197. /* 自定义返回 */
  198. } else {
  199. // 进行签约初始化
  200. signingInitialization(qdOrderNo)
  201. }
  202. // qdOrderStore.orderInfo.value.orderId = JSON.parse(res.bizContent).orderId
  203. // 通过检测
  204. }
  205. })
  206. }
  207. // 签约初始化
  208. function signingInitialization(qdOrderNo) {
  209. const data = {
  210. qdOrderNo
  211. }
  212. request('94569071cf814517908cd35693f1f2e1', {
  213. data,
  214. }).then((res) => {
  215. if (res.statusCode === 0) {
  216. const data = JSON.parse(res.bizContent)
  217. if (data.status !== 0) {
  218. // 后台调用它方接口报错
  219. uni.showModal({
  220. title: '警告',
  221. content: data.msg,
  222. success: function(res) {}
  223. });
  224. return
  225. }
  226. if (data.returnType === 0) {
  227. // 0-无需跳转,关闭H5即可 1-需跳转至返回url
  228. // const opened = window.open('about:blank', '_self');
  229. // opened.opener = null;
  230. // opened.close();
  231. closeWin()
  232. } else {
  233. window.open(data.signUrl, '_self')
  234. }
  235. }
  236. })
  237. }
  238. // 关闭当前页面方法
  239. function closeWin() {
  240. // @ts-ignore
  241. var jWeixin = import('jweixin-module')
  242. // @ts-ignore
  243. jWeixin.miniProgram.getEnv(function(res) {
  244. if (res.miniprogram) {
  245. // @ts-ignore
  246. jWeixin.miniProgram.navigateTo({
  247. url: '/path/to/page'
  248. })
  249. } else {
  250. const opened = window.open('about:blank', '_self');
  251. opened.opener = null;
  252. opened.close()
  253. }
  254. })
  255. }
  256. </script>
  257. <style lang='scss' scoped>
  258. .title {
  259. font-size: 30rpx;
  260. margin-left: 30rpx;
  261. }
  262. .container {
  263. padding: 10px;
  264. font-size: 14px;
  265. .detail-item {
  266. display: flex;
  267. align-items: center;
  268. justify-content: space-between;
  269. padding: 5px;
  270. margin-bottom: 8px;
  271. border-bottom: 1px solid #ccc;
  272. }
  273. }
  274. .payment-total {
  275. text-align: right;
  276. padding: 0 10px 20px;
  277. }
  278. text {
  279. margin-left: 10px;
  280. }
  281. .amount {
  282. color: #1AAC1B;
  283. max-width: 450rpx;
  284. }
  285. .btn {
  286. height: 80rpx;
  287. opacity: 1;
  288. border-radius: 100rpx;
  289. margin: 20rpx 20rpx 20rpx 20rpx;
  290. }
  291. .btn-txt {
  292. background: #1AAC1B;
  293. margin: 10px;
  294. color: #FFFFFF;
  295. font-size: 28rpx;
  296. }
  297. </style>