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 11KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479
  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 && parseFloat(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 && parseFloat(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 && parseFloat(amountData.actualPayment) !== 0'>
  34. <text>待付款</text>
  35. <text class="amount">¥{{handleAmount(amountData.actualPayment)}}</text>
  36. </view>
  37. <view class="over-txt">
  38. <button type="success" class="btn-txt btn" :class='{disabledBtn:!qdOrderVal.h5ReturnQdUrl}'
  39. :disabled="!qdOrderVal.h5ReturnQdUrl"
  40. @click="toNav">用户车辆信息上传完成</button>
  41. <!-- <wx-open-launch-weapp id="launch-btn" appid="wxbd70e25d388d9f46" path="pages/index/index" env-version="trial"
  42. @error="handleErrorFn" @launch="handleLaunchFn" v-else>
  43. <div v-is="'script'" type='text/wxtag-template' style="display: block;">
  44. <div class="btn">跳转小程序</div>
  45. </div>
  46. </wx-open-launch-weapp> -->
  47. </view>
  48. <!-- <Hetong v-model="checked" :link='linkObj.url' v-if='linkObj.url' :name='linkObj.name' /> -->
  49. <!-- <button type="success" class="btn-txt btn" @click="submit">确认办理</button> -->
  50. </view>
  51. <u-toast ref="uToastRef" />
  52. </view>
  53. </view>
  54. </template>
  55. <script setup lang='ts'>
  56. import {
  57. unifyTemplate
  58. } from '@/hooks/unifyTemplate'
  59. import {
  60. reactive,
  61. ref
  62. } from 'vue'
  63. import {
  64. onLoad
  65. } from '@dcloudio/uni-app'
  66. import Hetong from '@/components/Hetong/Hetong.vue'
  67. import {
  68. request,
  69. requestNew,
  70. myJsonp,
  71. toWeixin
  72. } from '@/utils/network/request'
  73. import {
  74. payType,
  75. payMentStatus
  76. } from './common.js'
  77. import {
  78. setToken,
  79. getToken,
  80. setItem,
  81. StorageKeys
  82. } from '@/utils/storage'
  83. import handleAmount from '@/utils/handleAmount.js';
  84. import {
  85. handleToTypes,
  86. isWeb,
  87. handleToZhifubao,
  88. handleTonei,
  89. isWxDuan
  90. } from '@/utils/utils';
  91. const {
  92. CustomHeader, //头部组件
  93. initData, //初始化数据
  94. isShow, //是否展示formBuilderVue组件
  95. qdOrderVal //qdOrder中数据 ref
  96. } = unifyTemplate() //初始化数据
  97. // import {
  98. // request
  99. // } from '../../static/js/network/request'
  100. function handleErrorFn(e) {
  101. console.log('fail', e.detail);
  102. }
  103. function handleLaunchFn(e) {
  104. console.log('success');
  105. }
  106. let orderObj = {}
  107. let formData = reactive < any > ([{
  108. label: '产品名',
  109. value: '',
  110. key: "product",
  111. key1: 'promoteName',
  112. }, {
  113. label: '订单步骤',
  114. value: '',
  115. key: "orderStepName",
  116. }, {
  117. label: '车牌号',
  118. key: "vehiclePlate",
  119. value: '贵'
  120. }, {
  121. label: '车主姓名',
  122. key: "ownerName",
  123. value: ''
  124. }, {
  125. label: '邮寄地址',
  126. key: "orderInfoExt",
  127. key1: 'region,address',
  128. default: "不邮寄",
  129. isHide: false,
  130. value: ''
  131. }])
  132. const amountList = ref < any > ([])
  133. const checked = ref(false)
  134. // 实付款
  135. const amountData = ref({
  136. totalFee: '',
  137. actualPayment: 0
  138. })
  139. let config = ref < any > ({
  140. submitName: '提交',
  141. titleWidth: 160
  142. })
  143. onLoad((opin) => {
  144. // 初始化数据
  145. initData(opin, 4).then(async data => {
  146. console.log(data, 'data');
  147. orderObj = data.order
  148. amountData.value.totalFee = handleAmount(data.order.amount)
  149. await login(data)
  150. // getLink(data.order.orderNo)
  151. getOrderInfo(data.order.orderNo)
  152. delete data.config.tableConfig
  153. config.value = Object.assign(data.config, config.value)
  154. })
  155. })
  156. const linkObj = reactive({
  157. url: "",
  158. name: ""
  159. })
  160. // 获取协议链接
  161. async function getLink(orderId) {
  162. await requestNew('/iaw/issue/order/agreementInSertOrder', {
  163. data: {
  164. orderId
  165. }
  166. }).then((res) => {
  167. if (res.code === 0) {
  168. let data = res.data.data[0]
  169. console.log(data, '协议');
  170. linkObj.url = data.address[0].url
  171. linkObj.name = data.name
  172. }
  173. // contractTesting(qdOrderVal.value.qdOrderNo, jumpPage)
  174. })
  175. }
  176. // 无感登录,如果没有登录调用登录
  177. async function login(orderData) {
  178. let data = {
  179. userType: '',
  180. accountNumber: '',
  181. loginSource: '431bfdc8b9c645e0b293b85d6ce1948n',
  182. }
  183. if (orderData.order.userType === "PERSONAL_USER") {
  184. // 个人办理
  185. data.userType = 'PERSONAL'
  186. data.accountNumber = orderData.order.customerTel
  187. } else {
  188. // 单位办理
  189. console.log('单位办理');
  190. data.userType = 'ENTERPRISE'
  191. data.accountNumber = orderData.order.customerIdNum
  192. }
  193. console.log('login请求参数', data);
  194. await requestNew('/iaw/portal/loginByNoPassword', {
  195. data,
  196. }).then((res) => {
  197. if (res.code === 0) {
  198. let data = res.data
  199. // 保存token
  200. setToken(data.accessToken)
  201. setItem(StorageKeys.OpenId, data.openId)
  202. console.log(data, '登录获取的数据')
  203. }
  204. // contractTesting(qdOrderVal.value.qdOrderNo, jumpPage)
  205. })
  206. }
  207. const stepOptions = [{
  208. value: 1,
  209. label: "完成填写基本信息"
  210. },
  211. {
  212. value: 2,
  213. label: "完成个人/单位信息上传"
  214. },
  215. {
  216. value: 3,
  217. label: "已支付,待签约"
  218. },
  219. {
  220. value: 4,
  221. label: "完成车辆信息上传,待支付"
  222. },
  223. {
  224. value: 5,
  225. label: "完成签约"
  226. },
  227. {
  228. value: 6,
  229. label: "待审核"
  230. },
  231. {
  232. value: 7,
  233. label: "审核不通过"
  234. },
  235. {
  236. value: 8,
  237. label: "待发货"
  238. },
  239. {
  240. value: 9,
  241. label: "待收货"
  242. },
  243. {
  244. value: 10,
  245. label: "待激活"
  246. },
  247. {
  248. value: 11,
  249. label: "已完成"
  250. },
  251. {
  252. value: 12,
  253. label: "已申请-换货"
  254. },
  255. {
  256. value: 13,
  257. label: "已申请-退货"
  258. },
  259. {
  260. value: 14,
  261. label: "已结束"
  262. },
  263. {
  264. value: 15,
  265. label: "退款中"
  266. },
  267. {
  268. value: 16,
  269. label: "退款成功"
  270. },
  271. {
  272. value: 17,
  273. label: "退货成功"
  274. },
  275. ]
  276. function getOrderInfo(orderId) {
  277. let options = {
  278. type: 2,
  279. data: {
  280. orderId
  281. },
  282. method: 'POST',
  283. showLoading: true
  284. }
  285. requestNew('/iaw/issue/order/orderDetailQuery', options).then((res) => {
  286. if (res.code === 0) {
  287. let data = res.data.data
  288. console.log(data, '订单数据');
  289. data.orderStepName = stepOptions.find(item => item.value === data.orderStep)?.label || data.orderStep
  290. formData.forEach(item => {
  291. let itemData = data[item.key]
  292. if (typeof itemData === 'object' && itemData) {
  293. console.log(itemData, item.key1);
  294. if (item.key1 && item.key1.includes(',')) {
  295. let str = ''
  296. item.key1.split(',').forEach(listItem => {
  297. str += itemData[listItem] || ''
  298. })
  299. itemData = str
  300. } else {
  301. console.log(itemData, 'item.key1');
  302. itemData = itemData[item.key1]
  303. }
  304. }
  305. if (item.format) {
  306. itemData = item.format(itemData)
  307. }
  308. if (!itemData && itemData !== 0 && item.isHide === false) {
  309. item.isHide = true
  310. }
  311. item.value = itemData || item.default
  312. })
  313. amountData.value.actualPayment = 0
  314. amountList.value = data.feeList?.map(item => {
  315. if (item.payStatus === 'UNPAY') {
  316. amountData.value.actualPayment += parseInt(item.fee)
  317. }
  318. return {
  319. status: item.payStatus,
  320. statusName: payMentStatus[item.payStatus],
  321. label: payType[item.payType],
  322. value: handleAmount(item.fee)
  323. }
  324. }) || []
  325. console.log(amountList.value, 'amountList.value');
  326. isShow.value = true;
  327. }
  328. console.log(res, '请求订单获取的数据');
  329. })
  330. }
  331. // 数据处理
  332. // function getOrderInfo(orderId) {
  333. // request('8', {
  334. // data: {
  335. // orderId
  336. // }
  337. // }).then((res) => {
  338. // let data = JSON.parse(res.bizContent)
  339. // console.log(data, '订单数据');
  340. // formData.forEach(item => {
  341. // let itemData = data[item.key]
  342. // if (typeof itemData === 'object') {
  343. // if (item.key1.includes(',')) {
  344. // let str = ''
  345. // item.key1.split(',').forEach(listItem => {
  346. // str += itemData[listItem] || ''
  347. // })
  348. // itemData = str
  349. // } else {
  350. // itemData = itemData[item.key1]
  351. // }
  352. // }
  353. // if (item.format) {
  354. // itemData = item.format(itemData)
  355. // }
  356. // if (!itemData && itemData !== 0 && item.isHide === false) {
  357. // item.isHide = true
  358. // }
  359. // item.value = itemData || item.default
  360. // })
  361. // amountData.value.totalFee = handleAmount(data.sumFee)
  362. // amountData.value.actualPayment = 0
  363. // amountList.value = [] || data.datas.map(item => {
  364. // if (item.payStatus === 'UNPAY') {
  365. // amountData.value.actualPayment += parseInt(item.fee)
  366. // }
  367. // return {
  368. // status: item.payStatus,
  369. // statusName: payMentStatus[item.payStatus],
  370. // label: payType[item.payType],
  371. // value: handleAmount(item.fee)
  372. // }
  373. // })
  374. // isShow.value = true;
  375. // })
  376. // }
  377. const uToastRef = ref(null)
  378. //确认办理
  379. function submit() {
  380. if (checked.value || !linkObj.url) {
  381. uni.navigateTo({
  382. url: '/pages/payment/orderPayment',
  383. animationType: 'pop-in',
  384. animationDuration: 500
  385. })
  386. } else {
  387. uToastRef.value.show({
  388. title: '请先勾选协议',
  389. type: 'warning',
  390. })
  391. }
  392. }
  393. const toNav = () => {
  394. handleFinish()
  395. }
  396. const handleOther = (returnUrl) => {
  397. const type = handleToTypes();
  398. if (type === 'alipaymini') {
  399. handleToZhifubao(returnUrl);
  400. } else if (type === 'wechatmini') {
  401. let returnUrls = returnUrl.split('?')
  402. if (returnUrls.length === 1) {
  403. returnUrls = returnUrl +
  404. `?orderId=${orderObj.orderNo}&ownerName=${orderObj.ownerName}&productName=${orderObj.productName}&tel=${orderObj.customerTel || orderObj.agentTel}&vehicleId=${orderObj.vehicleId}&qdOrderNo=${orderObj.orderNo}`
  405. } else {
  406. returnUrls = returnUrl
  407. }
  408. console.log('returnUrls', returnUrls);
  409. handleTonei(returnUrls);
  410. }
  411. };
  412. const handleFinish = () => {
  413. console.log(qdOrderVal.value, '获取的qdorder');
  414. const h5ReturnQdUrl = qdOrderVal.value.h5ReturnQdUrl || '';
  415. if (!h5ReturnQdUrl) {
  416. return;
  417. }
  418. if (isWeb(h5ReturnQdUrl) || isWxDuan(h5ReturnQdUrl)) {
  419. window.open(h5ReturnQdUrl, '_self');
  420. } else {
  421. handleOther(h5ReturnQdUrl);
  422. }
  423. };
  424. </script>
  425. <style lang='scss' scoped>
  426. .title {
  427. font-size: 30rpx;
  428. margin-left: 30rpx;
  429. }
  430. .container {
  431. padding: 10px;
  432. font-size: 14px;
  433. .detail-item {
  434. display: flex;
  435. align-items: center;
  436. justify-content: space-between;
  437. padding: 5px;
  438. margin-bottom: 8px;
  439. border-bottom: 1px solid #ccc;
  440. }
  441. }
  442. .payment-total {
  443. text-align: right;
  444. padding: 0 10px 20px;
  445. }
  446. text {
  447. margin-left: 10px;
  448. }
  449. .status {
  450. margin: 0;
  451. }
  452. .amount {
  453. color: #1AAC1B;
  454. max-width: 450rpx;
  455. }
  456. .over-txt {
  457. text-align: center;
  458. font-size: 32rpx;
  459. padding-top: 30rpx;
  460. }
  461. .over-txt .disabledBtn {
  462. background-color: #ccc !important;
  463. color: #666;
  464. }
  465. </style>