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.5KB

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