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

order_payment.vue 15KB

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