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 16KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639
  1. <template>
  2. <navBar title="订单支付" :scrollTop="scrollTop" :orderId="state.orderId" navbgClass="nav-bgXin" fontColor='#fff'></navBar>
  3. <navBgCar :activeNum='5'></navBgCar>
  4. <view class="content-value">
  5. <view class="t-card">
  6. <view @click="savaHandle(item)" class="ul-item" v-for="(item, index) in state.dataArray" :key="index">
  7. <image style="width: 100%; height: 146rpx;" :src="`${$imgUrl}issuance/equity-bg.png`" mode='scaleToFill'>
  8. </image>
  9. <view class="item-value">
  10. <view class="money">
  11. <text class='unit'>¥</text>
  12. <text>{{ item.fee * 0.01 }}</text>
  13. </view>
  14. <view class="content">
  15. <view class="title">
  16. {{ item.payName }}
  17. </view>
  18. </view>
  19. <view class="r-btn">
  20. {{ item.payStatusName }}
  21. </view>
  22. </view>
  23. </view>
  24. </view>
  25. </view>
  26. </template>
  27. <script setup lang="ts">
  28. import { onLoad, onPageScroll } from "@dcloudio/uni-app";
  29. import { reactive, ref } from "vue";
  30. import {
  31. // PAYDETECTION,
  32. PAYMENTORDERAPPLY,
  33. aliPayConfigIdTwo,
  34. obtainUserId,
  35. getOpenId,
  36. etcVehiclePlateVer, payApply, payQuery
  37. } from "@/utils/network/api.js";
  38. import { request, requestNew } from "@/utils/network/request.js";
  39. import { stringToJson } from "@/utils/network/encryption";
  40. import { fileURL } from "@/datas/fileURL.js";
  41. import navBgCar from "./components/nav-bg-car1";
  42. import navBar from "@/components/nav-bar/nav-bar2.vue";
  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 ? data.openId : data.alipayUserId,
  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. requestNew(getOpenId, options1).then((res) => {
  135. const result = res;
  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. requestNew(payApply, options).then((res) => {
  149. const data = res;
  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 refresh = () => {
  184. state.isclick = true
  185. let source = ""
  186. // #ifdef MP-ALIPAY
  187. source = "ALI"
  188. // #endif
  189. // #ifdef MP-WEIXIN
  190. source = "WECHAT"
  191. // #endif
  192. var data = {
  193. orderId: state.orderId,
  194. };
  195. const options = {
  196. type: 2,
  197. data: data,
  198. method: "POST",
  199. showLoading: true,
  200. };
  201. console.log("输出内容", options);
  202. requestNew(payQuery, options).then((res) => {
  203. console.log("res====", res)
  204. const data = res;
  205. console.log(data);
  206. if (data.paymentStatus == 'ALLSUCCESS') {
  207. gotoEditUserOrUnitInfo()
  208. }
  209. state.dataArray = data.datas;
  210. for (let i = 0; i < state.dataArray.length; i++) {
  211. if (state.dataArray[i].payType === 'HANDLE') {
  212. state.dataArray[i].payName = '权益金'
  213. } else if (state.dataArray[i].payType === 'MARGIN') {
  214. state.dataArray[i].payName = '保证金'
  215. } else if (state.dataArray[i].payType === 'PRESTORE') {
  216. state.dataArray[i].payName = '预存金'
  217. } else if (state.dataArray[i].payType === 'EQUITY') {
  218. state.dataArray[i].payName = '权益费'
  219. } else if (state.dataArray[i].payType === 'REPAIROBU') {
  220. state.dataArray[i].payName = '增补obu'
  221. } else if (state.dataArray[i].payType === 'CHANGECARD') {
  222. state.dataArray[i].payName = '更换卡'
  223. } else if (state.dataArray[i].payType === 'CHANGEOBU') {
  224. state.dataArray[i].payName = '更换签'
  225. } else if (state.dataArray[i].payType === 'CHANGEALL') {
  226. state.dataArray[i].payName = '更换卡签'
  227. } else {
  228. state.dataArray[i].payName = '未知费'
  229. }
  230. if (state.dataArray[i].payStatus === 'SUCCESS') {
  231. state.dataArray[i].payStatusName = '已支付'
  232. } else if (state.dataArray[i].payStatus === 'PAYING') {
  233. state.dataArray[i].payStatusName = '支付中'
  234. } else if (state.dataArray[i].payStatus === 'FAILED') {
  235. state.dataArray[i].payStatusName = '支付失败'
  236. } else if (state.dataArray[i].payStatus === 'UNPAY') {
  237. state.dataArray[i].payStatusName = '未支付'
  238. } else if (state.dataArray[i].payStatus === 'CLOSED') {
  239. state.dataArray[i].payStatusName = '已关闭'
  240. } else if (state.dataArray[i].payStatus === 'CANCELED') {
  241. state.dataArray[i].payStatusName = '已撤销'
  242. } else if (state.dataArray[i].payStatus === 'REFUND') {
  243. state.dataArray[i].payStatusName = '转入退费'
  244. } else {
  245. state.dataArray[i].payStatusName = '未知'
  246. }
  247. }
  248. console.log("state.dataArray", state.dataArray)
  249. });
  250. }
  251. onLoad((option : any) => {
  252. console.log("传递过来的到支付页面", option)
  253. state.orderId = option.orderId;
  254. state.isValueCard = option.isValueCard;
  255. state.vehicleId = option.vehicleId;
  256. let source = ""
  257. // #ifdef MP-ALIPAY
  258. imageUrl = imgURL + "applyCard/alibaba.png";
  259. source = "ALI"
  260. // #endif
  261. // #ifdef MP-WEIXIN
  262. imageUrl = imgURL + "applyCard/wechat.png";
  263. source = "WECHAT"
  264. // #endif
  265. var data = {
  266. orderId: state.orderId,
  267. };
  268. const options = {
  269. type: 2,
  270. data: data,
  271. method: "POST",
  272. showLoading: true,
  273. };
  274. console.log("输出内容", options);
  275. requestNew(payQuery, options).then((res) => {
  276. const data = res;
  277. console.log(data);
  278. if (data.paymentStatus == 'ALLSUCCESS') {
  279. // isValueCard 1 储值卡 2 记账卡
  280. if (state.isValueCard == 1) {
  281. uni.switchTab({
  282. url: "/pages/order/order"
  283. })
  284. } else {
  285. uni.navigateTo({
  286. url: `/subpackage/orders/release-products?orderId=${state.orderId}`,
  287. });
  288. }
  289. }
  290. state.dataArray = data.datas;
  291. for (let i = 0; i < state.dataArray.length; i++) {
  292. if (state.dataArray[i].payType === 'HANDLE') {
  293. state.dataArray[i].payName = '权益金'
  294. } else if (state.dataArray[i].payType === 'MARGIN') {
  295. state.dataArray[i].payName = '保证金'
  296. } else if (state.dataArray[i].payType === 'PRESTORE') {
  297. state.dataArray[i].payName = '预存金'
  298. } else if (state.dataArray[i].payType === 'EQUITY') {
  299. state.dataArray[i].payName = '权益费'
  300. } else if (state.dataArray[i].payType === 'REPAIROBU') {
  301. state.dataArray[i].payName = '增补obu'
  302. } else if (state.dataArray[i].payType === 'CHANGECARD') {
  303. state.dataArray[i].payName = '更换卡'
  304. } else if (state.dataArray[i].payType === 'CHANGEOBU') {
  305. state.dataArray[i].payName = '更换签'
  306. } else if (state.dataArray[i].payType === 'CHANGEALL') {
  307. state.dataArray[i].payName = '更换卡签'
  308. } else {
  309. state.dataArray[i].payName = '未知费'
  310. }
  311. if (state.dataArray[i].payStatus === 'SUCCESS') {
  312. state.dataArray[i].payStatusName = '已支付'
  313. } else if (state.dataArray[i].payStatus === 'PAYING') {
  314. state.dataArray[i].payStatusName = '支付中'
  315. } else if (state.dataArray[i].payStatus === 'FAILED') {
  316. state.dataArray[i].payStatusName = '支付失败'
  317. } else if (state.dataArray[i].payStatus === 'UNPAY') {
  318. state.dataArray[i].payStatusName = '未支付'
  319. } else if (state.dataArray[i].payStatus === 'CLOSED') {
  320. state.dataArray[i].payStatusName = '已关闭'
  321. } else if (state.dataArray[i].payStatus === 'CANCELED') {
  322. state.dataArray[i].payStatusName = '已撤销'
  323. } else if (state.dataArray[i].payStatus === 'REFUND') {
  324. state.dataArray[i].payStatusName = '转入退费'
  325. } else {
  326. state.dataArray[i].payStatusName = '未知'
  327. }
  328. }
  329. console.log("state.dataArray", state.dataArray)
  330. });
  331. });
  332. //解析URL获取参数
  333. const getRequest = (urlStr) => {
  334. if (typeof urlStr == "undefined") {
  335. // 获取url中"?"符后的字符串
  336. var url = decodeURI(location.search);
  337. } else {
  338. var url = "?" + urlStr.split("?")[1];
  339. }
  340. var theRequest = new Object();
  341. if (url.indexOf("?") != -1) {
  342. var str = url.substr(1);
  343. var strs = str.split("&");
  344. for (var i = 0; i < strs.length; i++) {
  345. theRequest[strs[i].split("=")[0]] = decodeURI(strs[i].split("=")[1]);
  346. }
  347. }
  348. return theRequest;
  349. };
  350. //监听页面滚动
  351. onPageScroll((e) => {
  352. scrollTop.value = e.scrollTop;
  353. });
  354. // isValueCard 1 储值卡 2 记账卡
  355. const gotoEditUserOrUnitInfo = () => {
  356. if (state.isValueCard == 1) {
  357. uni.switchTab({
  358. url: "/pages/order/order"
  359. })
  360. } else {
  361. uni.navigateTo({
  362. url: `/subpackage/orders/release-products?orderId=${state.orderId}`,
  363. });
  364. }
  365. }
  366. const state = reactive({
  367. isValueCard: 1, //卡的类型
  368. radiolist1: [], //选择卡的数据列表
  369. choiceCardShow: false, //选择卡的弹出框
  370. isSign: '',
  371. id: "",
  372. orderId: "",
  373. userType: 1, //1 个人 2单位
  374. type: 0, //0 客车 1货车
  375. vehiclePlateColor: "",
  376. data: {
  377. show: false,
  378. src: imgURL + "applyCard/edit.png",
  379. },
  380. dataArray: [],
  381. list: [
  382. {
  383. bg: imgURL + "applyCard/product-bg.png",
  384. icon: imgURL + "applyCard/wechat.png",
  385. title: "【货车】微信车主服务",
  386. tip: "绑定微信支付,无需绑定银行卡",
  387. },
  388. ],
  389. openid: "",
  390. isclick: true,//防止重复点击
  391. vehicleId: ""
  392. });
  393. // 车牌校验
  394. const etcVehiclePlateVerRequest = () => {
  395. let data = {
  396. vehiclePlate: state.vehicleId.split('_')[0],
  397. vehiclePlateColor: state.vehicleId.split('_')[1],
  398. }
  399. const options = {
  400. type: 2,
  401. data: data,
  402. method: "POST",
  403. showLoading: true,
  404. };
  405. return new Promise(async (resolve, reject) => {
  406. const res = await request(etcVehiclePlateVer, options);
  407. const data = stringToJson(res.bizContent);
  408. resolve(data);
  409. }).catch((error) => {
  410. reject(error);
  411. });
  412. }
  413. </script>
  414. <style lang="scss" scoped>
  415. ::v-deep .u-radio {
  416. display: flex !important;
  417. align-items: center !important;
  418. float: none !important;
  419. }
  420. ::v-deep .u-icon__icon {
  421. top: -4px !important;
  422. }
  423. .bottomTip {
  424. margin-top: 100rpx;
  425. text-align: center;
  426. font-size: 28rpx;
  427. font-family: Microsoft YaHei;
  428. font-weight: 400;
  429. color: #b3b3b3;
  430. }
  431. .content-value {
  432. position: absolute;
  433. top: 370rpx;
  434. width: 100%;
  435. min-height: calc(100% - 370rpx);
  436. box-sizing: border-box;
  437. padding: 0 30rpx 210rpx;
  438. .t-card {
  439. background-color: #fff;
  440. padding: 40rpx 30rpx;
  441. border-radius: 12rpx;
  442. }
  443. .img-pos {
  444. position: absolute;
  445. left: 500rpx;
  446. top: -38rpx;
  447. right: 50rpx;
  448. .img-flex {
  449. display: flex;
  450. justify-content: space-between;
  451. align-items: center;
  452. .car-img {
  453. width: 86rpx;
  454. height: 42rpx;
  455. }
  456. .flag-img {
  457. width: 30rpx;
  458. height: 35rpx;
  459. }
  460. }
  461. }
  462. }
  463. .flex {
  464. display: flex;
  465. align-items: center;
  466. }
  467. .action {
  468. margin-top: 30rpx;
  469. padding-left: 20rpx;
  470. padding-right: 20rpx;
  471. padding-bottom: 30rpx;
  472. .button {
  473. height: 80rpx;
  474. background: linear-gradient(-90deg, #43a1e0 0%, #13e7c1 100%);
  475. border-radius: 40rpx;
  476. font-size: 32rpx;
  477. font-weight: 400;
  478. color: #ffffff;
  479. line-height: 80rpx;
  480. }
  481. }
  482. .action-btn {
  483. margin-left: 45rpx;
  484. width: 121rpx;
  485. height: 61rpx;
  486. border: 1px solid rgba(255, 255, 255, 1);
  487. border-radius: 30rpx;
  488. background: rgba(255, 255, 255, 0.2);
  489. text-align: center;
  490. font-size: 30rpx;
  491. font-family: Microsoft YaHei;
  492. font-weight: 400;
  493. color: #ffffff;
  494. line-height: 61rpx;
  495. }
  496. .tag1 {
  497. padding: 5rpx;
  498. background: rgba(0, 179, 139, 0.5);
  499. border-radius: 6rpx;
  500. font-size: 22rpx;
  501. font-family: Microsoft YaHei;
  502. font-weight: 400;
  503. color: #ffffff;
  504. }
  505. .tag3 {
  506. padding: 5rpx;
  507. background: rgba(139, 112, 228, 0.5);
  508. border-radius: 6rpx;
  509. font-size: 22rpx;
  510. font-family: Microsoft YaHei;
  511. font-weight: 400;
  512. color: #ffffff;
  513. }
  514. .tag2 {
  515. padding: 5rpx;
  516. background: rgba(249, 97, 60, 0.5);
  517. border-radius: 6rpx;
  518. font-size: 22rpx;
  519. font-family: Microsoft YaHei;
  520. font-weight: 400;
  521. color: #ffffff;
  522. }
  523. .ul-item {
  524. display: flex;
  525. align-items: center;
  526. &:nth-child(n+2) {
  527. margin-top: 30rpx;
  528. }
  529. .item-value {
  530. padding: 20rpx;
  531. position: absolute;
  532. display: flex;
  533. align-items: center;
  534. width: 100%;
  535. box-sizing: border-box;
  536. height: 146rpx;
  537. .money {
  538. color: #fff;
  539. font-size: 46rpx;
  540. font-family: SourceHanSansCN, SourceHanSansCN;
  541. font-weight: 400;
  542. margin-right: 43rpx;
  543. .unit {
  544. font-size: 29rpx;
  545. margin-right: 2rpx;
  546. }
  547. }
  548. .content {
  549. margin-left: 33rpx;
  550. .title {
  551. font-weight: 400;
  552. font-family: SourceHanSansCN, SourceHanSansCN;
  553. font-size: 36rpx;
  554. color: #2C3246;
  555. }
  556. }
  557. .r-btn {
  558. margin-left: 137rpx;
  559. width: 139rpx;
  560. height: 65rpx;
  561. background: radial-gradient(at 0% 0%, #C6B077 0%, #DFCC96 100%);
  562. border-radius: 33rpx;
  563. font-family: SourceHanSansCN, SourceHanSansCN;
  564. font-weight: 400;
  565. font-size: 26rpx;
  566. color: #FFFFFF;
  567. line-height: 65rpx;
  568. text-align: center;
  569. }
  570. }
  571. .icon-tip {
  572. width: 100rpx;
  573. height: 100rpx;
  574. }
  575. }
  576. ::v-deep .u-mode-center-box {
  577. border-radius: 10rpx;
  578. }
  579. .squire {
  580. padding: 30rpx 30rpx 50rpx 50rpx;
  581. }
  582. .mask-close {
  583. text-align: right;
  584. }
  585. .icon-closed {
  586. width: 48rpx;
  587. height: 48rpx;
  588. }
  589. .mask-title {
  590. text-align: center;
  591. font-size: 32rpx;
  592. color: $uni-text-color-black;
  593. margin-bottom: 50rpx;
  594. }
  595. </style>