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.

order_payment.vue 17KB

1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697
  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="imageUrl"></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 {
  52. PAYDETECTION,
  53. PAYMENTORDERAPPLY,
  54. wechatAppID,
  55. wechatSecret,
  56. CardBillQuery,
  57. CardBillPlaceOrder,
  58. CardBillPayStatus,
  59. wechatPayConfigId,
  60. aliPayConfigIdTwo,
  61. obtainUserId,
  62. getOpenidApi,
  63. orderDetail
  64. } from "@/utils/network/api.js";
  65. import { request } from "@/utils/network/request.js";
  66. import { stringToJson } from "@/utils/network/encryption";
  67. import { fileURL } from "@/datas/fileURL.js";
  68. import navBgCar from "./components/nav-bg-car5";
  69. import navBar from "@/components/nav-bar/nav-bar2.vue";
  70. import { getItem, StorageKeys, setItem } from "@/utils/storage.ts";
  71. import { msg } from "@/utils/utils";
  72. const imgURL = `${fileURL}image/`;
  73. let imageUrl = ""
  74. // import { setItem } from "@/utils/storage";
  75. let logo
  76. const scrollTop = ref(0); //滚动距离
  77. // 单选默认数据
  78. // let flag = ref(true)
  79. // 单选
  80. const radioChange = (n) => {
  81. console.log('radioChange', n);
  82. if (n == '记账卡') {
  83. state.isValueCard = 2
  84. } else if (n == '储值卡') {
  85. state.isValueCard = 1
  86. } else {
  87. state.isValueCard = 3
  88. }
  89. uni.redirectTo({
  90. url: `/subpackage/orders/essential-information?promoteId=${getItem("promoteId")}&userType=${state.userType}&type=${state.type}&isSign=${state.isSign}&isValueCard=${state.isValueCard}`,
  91. });
  92. }
  93. const savaHandle = (val) => {
  94. if (val.payStatus === 'UNPAY') {
  95. // #ifdef MP-ALIPAY
  96. my.getAuthCode({
  97. scopes: 'auth_base',
  98. success: res => {
  99. const optionsUser = {
  100. type: 2,
  101. data: {
  102. payConfigId: aliPayConfigIdTwo,
  103. code: res.authCode
  104. },
  105. method: "POST",
  106. showLoading: true,
  107. };
  108. console.log('支付宝用户编号请求:', optionsUser)
  109. request(obtainUserId, optionsUser).then((res) => {
  110. console.log('支付宝用户编号返回:', res)
  111. const data = stringToJson(res.bizContent);
  112. const optionsali = {
  113. type: 2,
  114. data: {
  115. orderId: state.orderId,
  116. wxOpenid: data.openId,
  117. payType: val.payType
  118. },
  119. method: "POST",
  120. showLoading: true,
  121. };
  122. console.log('支付下单请求:', optionsali)
  123. request(PAYMENTORDERAPPLY, optionsali).then((res) => {
  124. const data = stringToJson(res.bizContent);
  125. console.log('支付下单返回:', data)
  126. return;
  127. my.tradePay({
  128. // 调用统一收单交易创建接口(alipay.trade.create),获得返回字段支付宝交易号 trade_no
  129. tradeNO: data.tranPackage,
  130. success: res => {
  131. console.log("支付成功", res);
  132. refresh();
  133. },
  134. fail: res => {
  135. console.log("支付失败", res);
  136. },
  137. });
  138. });
  139. });
  140. },
  141. fail: err => {
  142. console.log('my.getAuthCode 调用失败', err)
  143. }
  144. });
  145. // #endif
  146. // #ifdef MP-WEIXIN
  147. // if (!state.openid) {
  148. // getOpenID();
  149. // }
  150. uni.login({
  151. provider: "weixin",
  152. success: function (e) {
  153. // uni.request({
  154. // url: `https://api.weixin.qq.com/sns/jscode2session?appid=${wechatAppID}&secret=${wechatSecret}&js_code=${e.code}&grant_type=authorization_code`,
  155. // success: (res : any) => {
  156. const options1 = {
  157. type: 2,
  158. data: {
  159. "jsCode": e.code
  160. },
  161. method: "POST",
  162. showLoading: true,
  163. };
  164. request(getOpenidApi, options1).then((res) => {
  165. const result = stringToJson(res.bizContent);
  166. const openidData = stringToJson(result.data);
  167. console.log("获取openId", openidData)
  168. const options = {
  169. type: 2,
  170. data: {
  171. orderId: state.orderId,
  172. wxOpenid: openidData.openid,
  173. payType: val.payType
  174. },
  175. method: "POST",
  176. showLoading: true,
  177. };
  178. request(PAYMENTORDERAPPLY, options).then((res) => {
  179. const data = stringToJson(res.bizContent);
  180. uni.requestPayment({
  181. provider: "wxpay",
  182. orderInfo: "",
  183. timeStamp: data.timestamp,
  184. nonceStr: data.noncestr,
  185. package: data.wxPackage ? data.wxPackage : "",
  186. signType: data.signType,
  187. paySign: data.sign,
  188. success: function (e) {
  189. console.log("支付成功", res);
  190. refresh();
  191. },
  192. fail: function (err) {
  193. confirm(err, () => { }, "支付失败", false);
  194. },
  195. });
  196. });
  197. });
  198. // },
  199. // });
  200. },
  201. });
  202. // #endif
  203. }
  204. };
  205. const getOpenID = () => {
  206. uni.login({
  207. provider: "weixin",
  208. success: function (e) {
  209. getOpenid(e.code);
  210. // uni.request({
  211. // url: `https://api.weixin.qq.com/sns/jscode2session?appid=${wechatAppID}&secret=${wechatSecret}&js_code=${e.code}&grant_type=authorization_code`,
  212. // success: (res: any) => {
  213. // state.openid = res.data.openid;
  214. // },
  215. // });
  216. },
  217. });
  218. };
  219. const getOpenid = (code) => {
  220. const options = {
  221. type: 2,
  222. data: {
  223. "jsCode": code
  224. },
  225. method: "POST",
  226. showLoading: true,
  227. };
  228. // #ifdef MP-WEIXIN
  229. request(getOpenidApi, options).then((res) => {
  230. const result = stringToJson(res.bizContent);
  231. console.log("获取微信小程序openid", result);
  232. const openidData = stringToJson(result.data);
  233. state.openid = openidData.openid;
  234. });
  235. // #endif
  236. }
  237. const refresh = () => {
  238. let source = ""
  239. // #ifdef MP-ALIPAY
  240. source = "ALI"
  241. // #endif
  242. // #ifdef MP-WEIXIN
  243. source = "WECHAT"
  244. // getOpenID();
  245. // #endif
  246. var data = {
  247. orderId: state.orderId,
  248. source: source //请求方来源
  249. };
  250. const options = {
  251. type: 2,
  252. data: data,
  253. method: "POST",
  254. showLoading: true,
  255. };
  256. console.log("输出内容", options);
  257. request(PAYDETECTION, options).then((res) => {
  258. // console.log(res.bizContent);
  259. const data = stringToJson(res.bizContent);
  260. console.log(data);
  261. // console.log(typeof(data));
  262. if (data.paymentStatus == 'ALLSUCCESS') {
  263. gotoEditUserOrUnitInfo()
  264. }
  265. state.dataArray = data.datas;
  266. // HANDLE("办理费",1){},
  267. // MARGIN("保证金",2){},
  268. // PRESTORE("预存金",3){},
  269. // EQUITY("权益费",4){},
  270. for (let i = 0; i < state.dataArray.length; i++) {
  271. if (state.dataArray[i].payType === 'HANDLE') {
  272. state.dataArray[i].payName = '办理费'
  273. } else if (state.dataArray[i].payType === 'MARGIN') {
  274. state.dataArray[i].payName = '保证金'
  275. } else if (state.dataArray[i].payType === 'PRESTORE') {
  276. state.dataArray[i].payName = '预存金'
  277. } else if (state.dataArray[i].payType === 'EQUITY') {
  278. state.dataArray[i].payName = '权益费'
  279. } else {
  280. state.dataArray[i].payName = '未知费'
  281. }
  282. // SUCCESS("支付成功",1){},
  283. // PAYING("支付中",2){},
  284. // FAILED("支付失败",3){},
  285. // UNPAY("未支付",4){},
  286. // CLOSED("已关闭",5){},
  287. // CANCELED("已撤销",6){},
  288. // REFUND("转入退费",7){},
  289. if (state.dataArray[i].payStatus === 'SUCCESS') {
  290. state.dataArray[i].payStatusName = '已支付'
  291. } else if (state.dataArray[i].payStatus === 'PAYING') {
  292. state.dataArray[i].payStatusName = '支付中'
  293. } else if (state.dataArray[i].payStatus === 'FAILED') {
  294. state.dataArray[i].payStatusName = '支付失败'
  295. } else if (state.dataArray[i].payStatus === 'UNPAY') {
  296. state.dataArray[i].payStatusName = '未支付'
  297. } else if (state.dataArray[i].payStatus === 'CLOSED') {
  298. state.dataArray[i].payStatusName = '已关闭'
  299. } else if (state.dataArray[i].payStatus === 'CANCELED') {
  300. state.dataArray[i].payStatusName = '已撤销'
  301. } else if (state.dataArray[i].payStatus === 'REFUND') {
  302. state.dataArray[i].payStatusName = '转入退费'
  303. } else {
  304. state.dataArray[i].payStatusName = '未知'
  305. }
  306. }
  307. console.log("state.dataArray", state.dataArray)
  308. });
  309. }
  310. onLoad((option : any) => {
  311. console.log("传递过来的", option)
  312. state.orderId = option.orderId;
  313. state.isValueCard = option.isValueCard;
  314. let source = ""
  315. // #ifdef MP-ALIPAY
  316. imageUrl = imgURL + "applyCard/alibaba.png";
  317. source = "ALI"
  318. // #endif
  319. // #ifdef MP-WEIXIN
  320. imageUrl = imgURL + "applyCard/wechat.png";
  321. source = "WECHAT"
  322. // #endif
  323. // state.userType = option.userType;
  324. // state.vehiclePlateColor = option.vehiclePlateColor;
  325. // state.userType = option.userType;
  326. // state.type = option.type;
  327. // option.orderId;
  328. var data = {
  329. orderId: state.orderId,
  330. source: source //请求方来源
  331. };
  332. const options = {
  333. type: 2,
  334. data: data,
  335. method: "POST",
  336. showLoading: true,
  337. };
  338. console.log("输出内容", options);
  339. request(PAYDETECTION, options).then((res) => {
  340. // console.log(res.bizContent);
  341. const data = stringToJson(res.bizContent);
  342. console.log(data);
  343. // console.log(typeof(data));
  344. if (data.paymentStatus == 'ALLSUCCESS') {
  345. // gotoEditUserOrUnitInfo()
  346. // uni.redirectTo({
  347. // url: `/subpackage/orders/sign-up-ali?orderId=${state.orderId}`,
  348. // });
  349. if (state.isValueCard != 1) {
  350. uni.redirectTo({
  351. url: `/subpackage/orders/release-products?orderId=${state.orderId}`,
  352. });
  353. } else {
  354. uni.switchTab({
  355. url: "/pages/order/order"
  356. })
  357. }
  358. }
  359. state.dataArray = data.datas;
  360. // HANDLE("办理费",1){},
  361. // MARGIN("保证金",2){},
  362. // PRESTORE("预存金",3){},
  363. // EQUITY("权益费",4){},
  364. for (let i = 0; i < state.dataArray.length; i++) {
  365. if (state.dataArray[i].payType === 'HANDLE') {
  366. state.dataArray[i].payName = '办理费'
  367. } else if (state.dataArray[i].payType === 'MARGIN') {
  368. state.dataArray[i].payName = '保证金'
  369. } else if (state.dataArray[i].payType === 'PRESTORE') {
  370. state.dataArray[i].payName = '预存金'
  371. } else if (state.dataArray[i].payType === 'EQUITY') {
  372. state.dataArray[i].payName = '权益费'
  373. } else {
  374. state.dataArray[i].payName = '未知费'
  375. }
  376. // SUCCESS("支付成功",1){},
  377. // PAYING("支付中",2){},
  378. // FAILED("支付失败",3){},
  379. // UNPAY("未支付",4){},
  380. // CLOSED("已关闭",5){},
  381. // CANCELED("已撤销",6){},
  382. // REFUND("转入退费",7){},
  383. if (state.dataArray[i].payStatus === 'SUCCESS') {
  384. state.dataArray[i].payStatusName = '已支付'
  385. } else if (state.dataArray[i].payStatus === 'PAYING') {
  386. state.dataArray[i].payStatusName = '支付中'
  387. } else if (state.dataArray[i].payStatus === 'FAILED') {
  388. state.dataArray[i].payStatusName = '支付失败'
  389. } else if (state.dataArray[i].payStatus === 'UNPAY') {
  390. state.dataArray[i].payStatusName = '未支付'
  391. } else if (state.dataArray[i].payStatus === 'CLOSED') {
  392. state.dataArray[i].payStatusName = '已关闭'
  393. } else if (state.dataArray[i].payStatus === 'CANCELED') {
  394. state.dataArray[i].payStatusName = '已撤销'
  395. } else if (state.dataArray[i].payStatus === 'REFUND') {
  396. state.dataArray[i].payStatusName = '转入退费'
  397. } else {
  398. state.dataArray[i].payStatusName = '未知'
  399. }
  400. }
  401. console.log("state.dataArray", state.dataArray)
  402. });
  403. });
  404. //解析URL获取参数
  405. const getRequest = (urlStr) => {
  406. if (typeof urlStr == "undefined") {
  407. // 获取url中"?"符后的字符串
  408. var url = decodeURI(location.search);
  409. } else {
  410. var url = "?" + urlStr.split("?")[1];
  411. }
  412. var theRequest = new Object();
  413. if (url.indexOf("?") != -1) {
  414. var str = url.substr(1);
  415. var strs = str.split("&");
  416. for (var i = 0; i < strs.length; i++) {
  417. theRequest[strs[i].split("=")[0]] = decodeURI(strs[i].split("=")[1]);
  418. }
  419. }
  420. return theRequest;
  421. };
  422. //监听页面滚动
  423. onPageScroll((e) => {
  424. scrollTop.value = e.scrollTop;
  425. });
  426. const productReCodeAction = (id) => {
  427. var data = {
  428. productId: id,
  429. orderId: state.orderId,
  430. };
  431. const options = {
  432. type: 2,
  433. data: data,
  434. method: "POST",
  435. showLoading: true,
  436. };
  437. return new Promise(async (resolve, reject) => {
  438. const res = await request(productReCode, options);
  439. const data = stringToJson(res.bizContent);
  440. resolve(data);
  441. }).catch((error) => {
  442. reject(error);
  443. });
  444. };
  445. const gotoEditUserOrUnitInfo = () => {
  446. if (state.isValueCard != 1) {
  447. uni.redirectTo({
  448. url: `/subpackage/orders/release-products?orderId=${state.orderId}`,
  449. });
  450. } else {
  451. uni.switchTab({
  452. url: "/pages/order/order"
  453. })
  454. }
  455. }
  456. const state = reactive({
  457. isValueCard: 1, //卡的类型
  458. radiolist1: [], //选择卡的数据列表
  459. choiceCardShow: false, //选择卡的弹出框
  460. isSign: '',
  461. id: "",
  462. orderId: "",
  463. userType: 1, //1 个人 2单位
  464. type: 0, //0 客车 1货车
  465. vehiclePlateColor: "",
  466. data: {
  467. show: false,
  468. src: imgURL + "applyCard/edit.png",
  469. },
  470. dataArray: [],
  471. list: [
  472. {
  473. bg: imgURL + "applyCard/product-bg.png",
  474. icon: imgURL + "applyCard/wechat.png",
  475. title: "【货车】微信车主服务",
  476. tip: "绑定微信支付,无需绑定银行卡",
  477. },
  478. ],
  479. openid: ""
  480. });
  481. </script>
  482. <style lang="scss" scoped>
  483. ::v-deep .u-radio {
  484. display: flex !important;
  485. align-items: center !important;
  486. float: none !important;
  487. }
  488. ::v-deep .u-icon__icon {
  489. top: -4px !important;
  490. }
  491. .bottomTip {
  492. margin-top: 100rpx;
  493. text-align: center;
  494. font-size: 28rpx;
  495. font-family: Microsoft YaHei;
  496. font-weight: 400;
  497. color: #b3b3b3;
  498. }
  499. .content-value {
  500. position: relative;
  501. // margin-top: -50rpx;
  502. padding: 0rpx 30rpx;
  503. position: relative;
  504. .img-pos {
  505. position: absolute;
  506. left: 500rpx;
  507. top: -38rpx;
  508. right: 50rpx;
  509. .img-flex {
  510. display: flex;
  511. justify-content: space-between;
  512. align-items: center;
  513. .car-img {
  514. width: 86rpx;
  515. height: 42rpx;
  516. }
  517. .flag-img {
  518. width: 30rpx;
  519. height: 35rpx;
  520. }
  521. }
  522. }
  523. }
  524. .flex {
  525. display: flex;
  526. align-items: center;
  527. }
  528. .action {
  529. margin-top: 30rpx;
  530. padding-left: 20rpx;
  531. padding-right: 20rpx;
  532. padding-bottom: 30rpx;
  533. .button {
  534. height: 80rpx;
  535. background: linear-gradient(-90deg, #43a1e0 0%, #13e7c1 100%);
  536. border-radius: 40rpx;
  537. font-size: 32rpx;
  538. font-weight: 400;
  539. color: #ffffff;
  540. line-height: 80rpx;
  541. }
  542. }
  543. .action-btn {
  544. margin-left: 45rpx;
  545. width: 121rpx;
  546. height: 61rpx;
  547. border: 1px solid rgba(255, 255, 255, 1);
  548. border-radius: 30rpx;
  549. background: rgba(255, 255, 255, 0.2);
  550. text-align: center;
  551. font-size: 30rpx;
  552. font-family: Microsoft YaHei;
  553. font-weight: 400;
  554. color: #ffffff;
  555. line-height: 61rpx;
  556. }
  557. .tag1 {
  558. padding: 5rpx;
  559. background: rgba(0, 179, 139, 0.5);
  560. border-radius: 6rpx;
  561. font-size: 22rpx;
  562. font-family: Microsoft YaHei;
  563. font-weight: 400;
  564. color: #ffffff;
  565. }
  566. .tag3 {
  567. padding: 5rpx;
  568. background: rgba(139, 112, 228, 0.5);
  569. border-radius: 6rpx;
  570. font-size: 22rpx;
  571. font-family: Microsoft YaHei;
  572. font-weight: 400;
  573. color: #ffffff;
  574. }
  575. .tag2 {
  576. padding: 5rpx;
  577. background: rgba(249, 97, 60, 0.5);
  578. border-radius: 6rpx;
  579. font-size: 22rpx;
  580. font-family: Microsoft YaHei;
  581. font-weight: 400;
  582. color: #ffffff;
  583. }
  584. .ul-item {
  585. padding: 5px 20rpx;
  586. display: flex;
  587. align-items: center;
  588. .item-value {
  589. padding: 20rpx;
  590. position: absolute;
  591. display: flex;
  592. align-items: center;
  593. // justify-content: space-around;
  594. width: 80%;
  595. .content {
  596. width: 51%;
  597. .title {
  598. font-size: 32rpx;
  599. font-family: Microsoft YaHei;
  600. font-weight: 400;
  601. color: #ffffff;
  602. }
  603. .tip {
  604. font-size: 24rpx;
  605. font-family: Microsoft YaHei;
  606. font-weight: 400;
  607. color: #ffffff;
  608. }
  609. }
  610. }
  611. .icon-tip {
  612. width: 100rpx;
  613. height: 100rpx;
  614. }
  615. .content {
  616. margin-left: 40rpx;
  617. }
  618. }
  619. .money {
  620. color: white;
  621. // float: right;
  622. }
  623. ::v-deep .u-mode-center-box {
  624. border-radius: 10rpx;
  625. }
  626. .squire {
  627. padding: 30rpx 30rpx 50rpx 50rpx;
  628. }
  629. .mask-close {
  630. text-align: right;
  631. }
  632. .icon-closed {
  633. width: 48rpx;
  634. height: 48rpx;
  635. }
  636. .mask-title {
  637. text-align: center;
  638. font-size: 32rpx;
  639. color: $uni-text-color-black;
  640. margin-bottom: 50rpx;
  641. }
  642. </style>