選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

order_payment.vue 15KB

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