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

order_payment.vue 16KB

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