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

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