You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

payment.vue 6.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269
  1. <template>
  2. <view class="content">
  3. <image class='bg-image' mode="widthFix"
  4. src="https://qtzl.etcjz.cn/default-bucket/20240324/3eba2095f5204798a1f8101b_beijing.jpg"></image>
  5. <view class="content-re">
  6. <custom-header title="订单详情" :back="config.hasReturn === 'true'"></custom-header>
  7. <view style="padding: 20rpx" v-if='isShow'>
  8. <view class="title">
  9. 订单详情
  10. </view>
  11. <view class="container">
  12. <template v-for='(item,index) in formData'>
  13. <view class="detail-item" :key='index' v-if='item.value !== "" && item.value !== undefined && !item.isHide'>
  14. <text>{{item.label}}</text>
  15. <text class="amount">{{item.key === 'amount'? '¥'+ item.value:item.value}}</text>
  16. </view>
  17. </template>
  18. <template v-for='(item,index) in amountList'>
  19. <view class="detail-item" :key='index' v-if='item.value !== "" && item.value !== undefined '>
  20. <text>{{item.label}}</text>
  21. <view>
  22. <text class="amount">{{'¥'+ item.value}} </text>
  23. <text class="status" :class="{amount:item.status==='SUCCESS'}">({{item.statusName}}) </text>
  24. </view>
  25. </view>
  26. </template>
  27. <view class="detail-item">
  28. <text>合计金额</text>
  29. <text class="amount">¥{{amountData.totalFee}} </text>
  30. </view>
  31. </view>
  32. <view class="payment-total">
  33. <text>待付款</text>
  34. <text class="amount">¥{{handleAmount(amountData.actualPayment)}}</text>
  35. </view>
  36. <Hetong v-model="checked" :link='link' v-if='link' />
  37. <button type="success" class="btn-txt btn" @click="submit">确认办理</button>
  38. </view>
  39. <u-toast ref="uToastRef" />
  40. </view>
  41. </view>
  42. </template>
  43. <script setup lang='ts'>
  44. import {
  45. unifyTemplate
  46. } from '@/hooks/unifyTemplate'
  47. import {
  48. reactive,
  49. ref
  50. } from 'vue'
  51. import {
  52. onLoad
  53. } from '@dcloudio/uni-app'
  54. import Hetong from '@/components/Hetong/Hetong.vue'
  55. import {
  56. request,
  57. myJsonp,
  58. toWeixin
  59. } from '@/utils/network/request'
  60. import {
  61. payType,
  62. payMentStatus
  63. } from './common.js'
  64. import {
  65. setToken,
  66. getToken
  67. } from '@/utils/storage'
  68. import handleAmount from '@/utils/handleAmount.js';
  69. const {
  70. CustomHeader, //头部组件
  71. initData, //初始化数据
  72. isShow, //是否展示formBuilderVue组件
  73. qdOrderVal //qdOrder中数据 ref
  74. } = unifyTemplate() //初始化数据
  75. // import {
  76. // request
  77. // } from '../../static/js/network/request'
  78. let formData = reactive < any > ([{
  79. label: '产品名',
  80. value: '',
  81. key: "product",
  82. key1: 'promoteName',
  83. }, {
  84. label: '车牌号',
  85. key: "vehiclePlate",
  86. value: '贵'
  87. }, {
  88. label: '车主姓名',
  89. key: "ownerName",
  90. value: ''
  91. }, {
  92. label: '邮寄地址',
  93. key: "orderInfoExt",
  94. key1: 'region,address',
  95. default: "不邮寄",
  96. isHide: false,
  97. value: ''
  98. }])
  99. const amountList = ref < any > ([])
  100. const checked = ref(false)
  101. // 实付款
  102. const amountData = ref({
  103. totalFee: '',
  104. actualPayment: 0
  105. })
  106. let config = ref < any > ({
  107. submitName: '提交',
  108. titleWidth: 160
  109. })
  110. onLoad((opin) => {
  111. // 初始化数据
  112. initData(opin, 4).then(async data => {
  113. await login(data)
  114. getLink(data.order.orderId)
  115. getOrderInfo(data.qdOrder.qtOrderNo)
  116. delete data.config.tableConfig
  117. config.value = Object.assign(data.config, config.value)
  118. })
  119. })
  120. const link = ref('')
  121. // 获取协议链接
  122. async function getLink(orderId) {
  123. await request('32a9d99a781a4bf2af29a46d903702bd', {
  124. data: {
  125. orderId
  126. }
  127. }).then((res) => {
  128. if (res.statusCode === 0) {
  129. let bizContent = JSON.parse(res.bizContent)
  130. console.log(bizContent);
  131. link.value = bizContent.supAgree
  132. }
  133. // contractTesting(qdOrderVal.value.qdOrderNo, jumpPage)
  134. })
  135. }
  136. // 无感登录,如果没有登录调用登录
  137. async function login(orderData) {
  138. let data = {
  139. userType: '',
  140. account: ''
  141. }
  142. if (orderData.order.userType === "PERSONAL_USER") {
  143. // 个人办理
  144. data.userType = 'PERSONAL'
  145. data.account = orderData.order.customerTel
  146. } else {
  147. // 单位办理
  148. data.userType = 'ENTERPRISE'
  149. data.account = orderData.order.customerIdnum
  150. }
  151. console.log('请求参数', data);
  152. await request('abaf0013caa24dafad12b0f571e8ee40', {
  153. data,
  154. }).then((res) => {
  155. if (res.statusCode === 0) {
  156. let bizContent = JSON.parse(res.bizContent)
  157. // 保存token
  158. setToken(bizContent.accessToken)
  159. }
  160. // contractTesting(qdOrderVal.value.qdOrderNo, jumpPage)
  161. })
  162. }
  163. // 数据处理
  164. function getOrderInfo(orderId) {
  165. request('8', {
  166. data: {
  167. orderId
  168. }
  169. }).then((res) => {
  170. let data = JSON.parse(res.bizContent)
  171. console.log(data);
  172. formData.forEach(item => {
  173. let itemData = data[item.key]
  174. if (typeof itemData === 'object') {
  175. if (item.key1.includes(',')) {
  176. let str = ''
  177. item.key1.split(',').forEach(listItem => {
  178. str += itemData[listItem] || ''
  179. })
  180. itemData = str
  181. } else {
  182. itemData = itemData[item.key1]
  183. }
  184. }
  185. if (item.format) {
  186. itemData = item.format(itemData)
  187. }
  188. if (!itemData && itemData !== 0 && item.isHide === false) {
  189. item.isHide = true
  190. }
  191. item.value = itemData || item.default
  192. })
  193. amountData.value.totalFee = handleAmount(data.sumFee)
  194. amountData.value.actualPayment = 0
  195. amountList.value = data.datas.map(item => {
  196. if (item.payStatus === 'UNPAY') {
  197. amountData.value.actualPayment += parseInt(item.fee)
  198. }
  199. return {
  200. status: item.payStatus,
  201. statusName: payMentStatus[item.payStatus],
  202. label: payType[item.payType],
  203. value: handleAmount(item.fee)
  204. }
  205. })
  206. isShow.value = true;
  207. })
  208. }
  209. const uToastRef = ref(null)
  210. //确认办理
  211. function submit() {
  212. if (checked.value || !link.value) {
  213. uni.navigateTo({
  214. url: '/pages/payment/orderPayment',
  215. animationType: 'pop-in',
  216. animationDuration: 500
  217. })
  218. } else {
  219. uToastRef.value.show({
  220. title: '请先勾选协议',
  221. type: 'warning',
  222. })
  223. }
  224. }
  225. </script>
  226. <style lang='scss' scoped>
  227. .title {
  228. font-size: 30rpx;
  229. margin-left: 30rpx;
  230. }
  231. .container {
  232. padding: 10px;
  233. font-size: 14px;
  234. .detail-item {
  235. display: flex;
  236. align-items: center;
  237. justify-content: space-between;
  238. padding: 5px;
  239. margin-bottom: 8px;
  240. border-bottom: 1px solid #ccc;
  241. }
  242. }
  243. .payment-total {
  244. text-align: right;
  245. padding: 0 10px 20px;
  246. }
  247. text {
  248. margin-left: 10px;
  249. }
  250. .status {
  251. margin: 0;
  252. }
  253. .amount {
  254. color: #1AAC1B;
  255. max-width: 450rpx;
  256. }
  257. </style>