Du kannst nicht mehr als 25 Themen auswählen Themen müssen mit entweder einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

order_payment.vue 15KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579
  1. <template>
  2. <navBar title="订单支付" :scrollTop="scrollTop"></navBar>
  3. <navBgCar></navBgCar>
  4. <view class="content-value">
  5. <view @click="savaHandle(item)" class="ul-item" v-for="(item, index) in state.dataArray" :key="index">
  6. <image style="width: 100%; height: 170rpx; border-radius: 20rpx"
  7. :src="`${$imgUrl}applyCard/product-bg.png`"></image>
  8. <view class="item-value">
  9. <image class="icon-tip" :src="`${$imgUrl}applyCard/wechat.png`"></image>
  10. <view class="content">
  11. <view class="title">
  12. {{ item.payName }}
  13. </view>
  14. <!-- 1记账卡2储值卡3记存卡 -->
  15. <!-- <view style="margin-top: 15rpx" class="tip" v-if="item.cardType=='1'">
  16. 记账卡
  17. </view> -->
  18. <view style="margin-top: 15rpx" class="tip">
  19. {{ item.payStatusName }}
  20. </view>
  21. </view>
  22. <view class="money">
  23. ¥:{{ item.fee * 0.01 }}
  24. </view>
  25. </view>
  26. </view>
  27. <!-- <view class="bottomTip"> 到底啦!敬请期待其他产品! </view> -->
  28. </view>
  29. <!-- <u-popup mode="center" v-model="state.choiceCardShow" closeable>
  30. <view class="squire">
  31. <view class="mask-title" :style="{ '--color': color }">选择办理卡类型</view>
  32. <view class="as-layout-horizontal">
  33. <view v-for="(item, index) in state.radiolist1" :key="index" :label="item.disabled" :name="item.name"
  34. @click="radioChange(item.name)"
  35. style="width: 100%;display: flex;align-items: center;margin-bottom: 30rpx;">
  36. <view class="as-layout-vertical as-gravity-center">
  37. <image style="width: 140rpx; height: 100rpx; border-radius: 20rpx;margin-right: 20rpx;"
  38. :src="`${$imgUrl}card2.png`" mode="aspectFill"></image>
  39. <view style="margin-top: 20rpx;">
  40. {{item.name}}
  41. </view>
  42. </view>
  43. </view>
  44. </view>
  45. </view>
  46. </u-popup> -->
  47. </template>
  48. <script setup lang="ts">
  49. import { onLoad, onPageScroll } from "@dcloudio/uni-app";
  50. import { reactive, ref } from "vue";
  51. import { PAYDETECTION,
  52. PAYMENTORDERAPPLY,
  53. wechatAppID,
  54. wechatSecret,
  55. CardBillQuery,
  56. CardBillPlaceOrder,
  57. CardBillPayStatus,
  58. wechatPayConfigId,
  59. aliPayConfigId,
  60. obtainUserId } from "@/utils/network/api.js";
  61. import { request } from "@/utils/network/request.js";
  62. import { stringToJson } from "@/utils/network/encryption";
  63. import { fileURL } from "@/datas/fileURL.js";
  64. import navBgCar from "./components/nav-bg-car1";
  65. import navBar from "@/components/nav-bar/nav-bar2.vue";
  66. import { getItem, StorageKeys, setItem } from "@/utils/storage.ts";
  67. import { msg } from "@/utils/utils";
  68. const imgURL = `${fileURL}image/`;
  69. // import { setItem } from "@/utils/storage";
  70. let logo
  71. const scrollTop = ref(0); //滚动距离
  72. // 单选默认数据
  73. // let flag = ref(true)
  74. // 单选
  75. const radioChange = (n) => {
  76. console.log('radioChange', n);
  77. if (n == '记账卡') {
  78. state.isValueCard = 2
  79. } else if (n == '储值卡') {
  80. state.isValueCard = 1
  81. } else {
  82. state.isValueCard = 3
  83. }
  84. uni.redirectTo({
  85. url: `/subpackage/orders/essential-information?promoteId=${getItem("promoteId")}&userType=${state.userType}&type=${state.type}&isSign=${state.isSign}&isValueCard=${state.isValueCard}`,
  86. });
  87. }
  88. const savaHandle = (val) => {
  89. // console.log("vAL", val)
  90. // setItem("clientFee", val.clientFee);
  91. // setItem("promoteId", val.promoteId);
  92. // setItem("isValueCard", val.isValueCard);
  93. // state.isSign = val.isSign;
  94. // // 判断是几张卡
  95. // console.log("val.cardTypeArr.split(", ")", val.cardTypeArr.split(","))
  96. // // if (val.promoteName.indexOf('选装') != -1) {
  97. // // if (val.cardTypeArr.split(",")[0] == "记账卡") {
  98. // // state.isValueCard = 2
  99. // // } else if (val.cardTypeArr.split(",")[0] == '储值卡') {
  100. // // state.isValueCard = 1
  101. // // } else {
  102. // // state.isValueCard = 3
  103. // // }
  104. // // uni.redirectTo({
  105. // // url: `/subpackage/orders/verify/verify-phone/verify-phone?promoteId=${getItem("promoteId")}&userType=${state.userType}&type=${state.type}&isValueCard=${state.isValueCard}`,
  106. // // });
  107. // // return
  108. // // }
  109. // if (val.cardTypeArr.split(",").length == 1) {
  110. // if (val.cardTypeArr.split(",")[0] == "记账卡") {
  111. // state.isValueCard = 2
  112. // } else if (val.cardTypeArr.split(",")[0] == '储值卡') {
  113. // state.isValueCard = 1
  114. // } else {
  115. // state.isValueCard = 3
  116. // }
  117. // uni.redirectTo({
  118. // url: `/subpackage/orders/essential-information?promoteId=${getItem("promoteId")}&userType=${state.userType}&type=${state.type}&isValueCard=${state.isValueCard}`,
  119. // });
  120. // } else {
  121. // state.radiolist1 = [];
  122. // // 处理卡的数据
  123. // for (var i = 0; i < val.cardTypeArr.split(",").length; i++) {
  124. // const obj = {};
  125. // obj["name"] = val.cardTypeArr.split(",")[i];
  126. // obj["disabled"] = false;
  127. // state.radiolist1.push(obj)
  128. // }
  129. // state.choiceCardShow = true;
  130. // console.log("state.radiolist1", state.radiolist1)
  131. // }
  132. if (val.payStatus === 'UNPAY') {
  133. // #ifdef MP-ALIPAY
  134. my.getAuthCode({
  135. scopes: 'auth_base',
  136. success: res => {
  137. const optionsUser = {
  138. type: 2,
  139. data: {
  140. payConfigId: aliPayConfigId,
  141. code: res.authCode
  142. },
  143. method: "POST",
  144. showLoading: true,
  145. };
  146. console.log('支付宝用户编号请求:',optionsUser)
  147. request(obtainUserId, optionsUser).then((res) => {
  148. console.log('支付宝用户编号返回:',res)
  149. const data = stringToJson(res.bizContent);
  150. const optionsali = {
  151. type: 2,
  152. data: {
  153. orderId:state.orderId,
  154. wxOpenid: data.openId,
  155. payType:val.payType
  156. },
  157. method: "POST",
  158. showLoading: true,
  159. };
  160. console.log('支付下单请求:',optionsali)
  161. request(PAYMENTORDERAPPLY, optionsali).then((res) => {
  162. console.log('支付下单返回:',res)
  163. const data = stringToJson(res.bizContent);
  164. my.tradePay ({
  165. // 调用统一收单交易创建接口(alipay.trade.create),获得返回字段支付宝交易号 trade_no
  166. tradeNO: data.tranPackage,
  167. success: res => {
  168. console.log("支付成功", res);
  169. refresh();
  170. },
  171. fail: res => {
  172. console.log("支付失败", res);
  173. },
  174. });
  175. });
  176. });
  177. },
  178. fail: err => {
  179. console.log('my.getAuthCode 调用失败', err)
  180. }
  181. });
  182. // #endif
  183. }
  184. };
  185. const refresh = () =>{
  186. var data = {
  187. orderId: state.orderId,
  188. source: 'ALI' //请求方来源
  189. };
  190. const options = {
  191. type: 2,
  192. data: data,
  193. method: "POST",
  194. showLoading: true,
  195. };
  196. console.log("输出内容", options);
  197. request(PAYDETECTION, options).then((res) => {
  198. // console.log(res.bizContent);
  199. const data = stringToJson(res.bizContent);
  200. console.log(data);
  201. // console.log(typeof(data));
  202. if(data.paymentStatus == 'ALLSUCCESS'){
  203. uni.redirectTo({
  204. url: `/subpackage/orders/sign-up-ali?orderId=${state.orderId}`,
  205. });
  206. }
  207. state.dataArray = data.datas;
  208. // HANDLE("办理费",1){},
  209. // MARGIN("保证金",2){},
  210. // PRESTORE("预存金",3){},
  211. // EQUITY("权益费",4){},
  212. for(let i = 0;i < state.dataArray.length;i++){
  213. if(state.dataArray[i].payType === 'HANDLE'){
  214. state.dataArray[i].payName = '办理费'
  215. }else if(state.dataArray[i].payType === 'MARGIN'){
  216. state.dataArray[i].payName = '保证金'
  217. }else if(state.dataArray[i].payType === 'PRESTORE'){
  218. state.dataArray[i].payName = '预存金'
  219. }else if(state.dataArray[i].payType === 'EQUITY'){
  220. state.dataArray[i].payName = '权益费'
  221. }else {
  222. state.dataArray[i].payName = '未知费'
  223. }
  224. // SUCCESS("支付成功",1){},
  225. // PAYING("支付中",2){},
  226. // FAILED("支付失败",3){},
  227. // UNPAY("未支付",4){},
  228. // CLOSED("已关闭",5){},
  229. // CANCELED("已撤销",6){},
  230. // REFUND("转入退费",7){},
  231. if(state.dataArray[i].payStatus === 'SUCCESS'){
  232. state.dataArray[i].payStatusName = '已支付'
  233. }else if(state.dataArray[i].payStatus === 'PAYING'){
  234. state.dataArray[i].payStatusName = '支付中'
  235. }else if(state.dataArray[i].payStatus === 'FAILED'){
  236. state.dataArray[i].payStatusName = '支付失败'
  237. }else if(state.dataArray[i].payStatus === 'UNPAY'){
  238. state.dataArray[i].payStatusName = '未支付'
  239. }else if(state.dataArray[i].payStatus === 'CLOSED'){
  240. state.dataArray[i].payStatusName = '已关闭'
  241. }else if(state.dataArray[i].payStatus === 'CANCELED'){
  242. state.dataArray[i].payStatusName = '已撤销'
  243. }else if(state.dataArray[i].payStatus === 'REFUND'){
  244. state.dataArray[i].payStatusName = '转入退费'
  245. }else{
  246. state.dataArray[i].payStatusName = '未知'
  247. }
  248. }
  249. console.log("state.dataArray", state.dataArray)
  250. });
  251. }
  252. onLoad((option : any) => {
  253. state.orderId = option.orderId;
  254. // state.userType = option.userType;
  255. // state.vehiclePlateColor = option.vehiclePlateColor;
  256. // state.userType = option.userType;
  257. // state.type = option.type;
  258. // option.orderId;
  259. var data = {
  260. orderId: state.orderId,
  261. source: 'ALI' //请求方来源
  262. };
  263. const options = {
  264. type: 2,
  265. data: data,
  266. method: "POST",
  267. showLoading: true,
  268. };
  269. console.log("输出内容", options);
  270. request(PAYDETECTION, options).then((res) => {
  271. // console.log(res.bizContent);
  272. const data = stringToJson(res.bizContent);
  273. console.log(data);
  274. // console.log(typeof(data));
  275. if(data.paymentStatus == 'ALLSUCCESS'){
  276. uni.redirectTo({
  277. url: `/subpackage/orders/sign-up-ali?orderId=${state.orderId}`,
  278. });
  279. }
  280. state.dataArray = data.datas;
  281. // HANDLE("办理费",1){},
  282. // MARGIN("保证金",2){},
  283. // PRESTORE("预存金",3){},
  284. // EQUITY("权益费",4){},
  285. for(let i = 0;i < state.dataArray.length;i++){
  286. if(state.dataArray[i].payType === 'HANDLE'){
  287. state.dataArray[i].payName = '办理费'
  288. }else if(state.dataArray[i].payType === 'MARGIN'){
  289. state.dataArray[i].payName = '保证金'
  290. }else if(state.dataArray[i].payType === 'PRESTORE'){
  291. state.dataArray[i].payName = '预存金'
  292. }else if(state.dataArray[i].payType === 'EQUITY'){
  293. state.dataArray[i].payName = '权益费'
  294. }else {
  295. state.dataArray[i].payName = '未知费'
  296. }
  297. // SUCCESS("支付成功",1){},
  298. // PAYING("支付中",2){},
  299. // FAILED("支付失败",3){},
  300. // UNPAY("未支付",4){},
  301. // CLOSED("已关闭",5){},
  302. // CANCELED("已撤销",6){},
  303. // REFUND("转入退费",7){},
  304. if(state.dataArray[i].payStatus === 'SUCCESS'){
  305. state.dataArray[i].payStatusName = '办理费'
  306. }else if(state.dataArray[i].payStatus === 'PAYING'){
  307. state.dataArray[i].payStatusName = '支付中'
  308. }else if(state.dataArray[i].payStatus === 'FAILED'){
  309. state.dataArray[i].payStatusName = '支付失败'
  310. }else if(state.dataArray[i].payStatus === 'UNPAY'){
  311. state.dataArray[i].payStatusName = '未支付'
  312. }else if(state.dataArray[i].payStatus === 'CLOSED'){
  313. state.dataArray[i].payStatusName = '已关闭'
  314. }else if(state.dataArray[i].payStatus === 'CANCELED'){
  315. state.dataArray[i].payStatusName = '已撤销'
  316. }else if(state.dataArray[i].payStatus === 'REFUND'){
  317. state.dataArray[i].payStatusName = '转入退费'
  318. }else{
  319. state.dataArray[i].payStatusName = '未知'
  320. }
  321. }
  322. console.log("state.dataArray", state.dataArray)
  323. });
  324. });
  325. //监听页面滚动
  326. onPageScroll((e) => {
  327. scrollTop.value = e.scrollTop;
  328. });
  329. const productReCodeAction = (id) => {
  330. var data = {
  331. productId: id,
  332. orderId: state.orderId,
  333. };
  334. const options = {
  335. type: 2,
  336. data: data,
  337. method: "POST",
  338. showLoading: true,
  339. };
  340. return new Promise(async (resolve, reject) => {
  341. const res = await request(productReCode, options);
  342. const data = stringToJson(res.bizContent);
  343. resolve(data);
  344. }).catch((error) => {
  345. reject(error);
  346. });
  347. };
  348. const state = reactive({
  349. isValueCard: 1, //卡的类型
  350. radiolist1: [], //选择卡的数据列表
  351. choiceCardShow: false, //选择卡的弹出框
  352. isSign: '',
  353. orderId: "",
  354. userType: 1, //1 个人 2单位
  355. type: 0, //0 客车 1货车
  356. vehiclePlateColor: "",
  357. data: {
  358. show: false,
  359. src: imgURL + "applyCard/edit.png",
  360. },
  361. dataArray: [],
  362. list: [
  363. {
  364. bg: imgURL + "applyCard/product-bg.png",
  365. icon: imgURL + "applyCard/wechat.png",
  366. title: "【货车】微信车主服务",
  367. tip: "绑定微信支付,无需绑定银行卡",
  368. },
  369. ],
  370. });
  371. </script>
  372. <style lang="scss" scoped>
  373. ::v-deep .u-radio {
  374. display: flex !important;
  375. align-items: center !important;
  376. float: none !important;
  377. }
  378. ::v-deep .u-icon__icon {
  379. top: -4px !important;
  380. }
  381. .bottomTip {
  382. margin-top: 100rpx;
  383. text-align: center;
  384. font-size: 28rpx;
  385. font-family: Microsoft YaHei;
  386. font-weight: 400;
  387. color: #b3b3b3;
  388. }
  389. .content-value {
  390. position: relative;
  391. // margin-top: -50rpx;
  392. padding: 0rpx 30rpx;
  393. position: relative;
  394. .img-pos {
  395. position: absolute;
  396. left: 500rpx;
  397. top: -38rpx;
  398. right: 50rpx;
  399. .img-flex {
  400. display: flex;
  401. justify-content: space-between;
  402. align-items: center;
  403. .car-img {
  404. width: 86rpx;
  405. height: 42rpx;
  406. }
  407. .flag-img {
  408. width: 30rpx;
  409. height: 35rpx;
  410. }
  411. }
  412. }
  413. }
  414. .flex {
  415. display: flex;
  416. align-items: center;
  417. }
  418. .action {
  419. margin-top: 30rpx;
  420. padding-left: 20rpx;
  421. padding-right: 20rpx;
  422. padding-bottom: 30rpx;
  423. .button {
  424. height: 80rpx;
  425. background: linear-gradient(-90deg, #43a1e0 0%, #13e7c1 100%);
  426. border-radius: 40rpx;
  427. font-size: 32rpx;
  428. font-weight: 400;
  429. color: #ffffff;
  430. line-height: 80rpx;
  431. }
  432. }
  433. .action-btn {
  434. margin-left: 45rpx;
  435. width: 121rpx;
  436. height: 61rpx;
  437. border: 1px solid rgba(255, 255, 255, 1);
  438. border-radius: 30rpx;
  439. background: rgba(255, 255, 255, 0.2);
  440. text-align: center;
  441. font-size: 30rpx;
  442. font-family: Microsoft YaHei;
  443. font-weight: 400;
  444. color: #ffffff;
  445. line-height: 61rpx;
  446. }
  447. .tag1 {
  448. padding: 5rpx;
  449. background: rgba(0, 179, 139, 0.5);
  450. border-radius: 6rpx;
  451. font-size: 22rpx;
  452. font-family: Microsoft YaHei;
  453. font-weight: 400;
  454. color: #ffffff;
  455. }
  456. .tag3 {
  457. padding: 5rpx;
  458. background: rgba(139, 112, 228, 0.5);
  459. border-radius: 6rpx;
  460. font-size: 22rpx;
  461. font-family: Microsoft YaHei;
  462. font-weight: 400;
  463. color: #ffffff;
  464. }
  465. .tag2 {
  466. padding: 5rpx;
  467. background: rgba(249, 97, 60, 0.5);
  468. border-radius: 6rpx;
  469. font-size: 22rpx;
  470. font-family: Microsoft YaHei;
  471. font-weight: 400;
  472. color: #ffffff;
  473. }
  474. .ul-item {
  475. padding: 5px 20rpx;
  476. display: flex;
  477. align-items: center;
  478. .item-value {
  479. padding: 20rpx;
  480. position: absolute;
  481. display: flex;
  482. align-items: center;
  483. // justify-content: space-around;
  484. width: 80%;
  485. .content {
  486. width: 51%;
  487. .title {
  488. font-size: 32rpx;
  489. font-family: Microsoft YaHei;
  490. font-weight: 400;
  491. color: #ffffff;
  492. }
  493. .tip {
  494. font-size: 24rpx;
  495. font-family: Microsoft YaHei;
  496. font-weight: 400;
  497. color: #ffffff;
  498. }
  499. }
  500. }
  501. .icon-tip {
  502. width: 100rpx;
  503. height: 100rpx;
  504. }
  505. .content {
  506. margin-left: 40rpx;
  507. }
  508. }
  509. .money {
  510. color: white;
  511. // float: right;
  512. }
  513. ::v-deep .u-mode-center-box {
  514. border-radius: 10rpx;
  515. }
  516. .squire {
  517. padding: 30rpx 30rpx 50rpx 50rpx;
  518. }
  519. .mask-close {
  520. text-align: right;
  521. }
  522. .icon-closed {
  523. width: 48rpx;
  524. height: 48rpx;
  525. }
  526. .mask-title {
  527. text-align: center;
  528. font-size: 32rpx;
  529. color: $uni-text-color-black;
  530. margin-bottom: 50rpx;
  531. }
  532. </style>