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

order_payment.vue 16KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650
  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. PAYMENTORDERAPPLY,
  32. aliPayConfigIdTwo,
  33. obtainUserId,
  34. getOpenId, 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-car1";
  40. import navBar from "@/components/nav-bar/nav-bar2.vue";
  41. const imgURL = `${fileURL}image/`;
  42. import { confirm,navTo} 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,state.isclick)
  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. requestNew(obtainUserId, optionsUser).then((res) => {
  83. console.log('支付宝用户编号返回:', res)
  84. const data = res;
  85. const optionsali = {
  86. type: 2,
  87. data: {
  88. orderId: state.orderId,
  89. wxOpenid: data.openId ? data.openId : data.alipayUserId,
  90. payType: val.payType
  91. },
  92. method: "POST",
  93. showLoading: true,
  94. };
  95. console.log('支付下单请求:', optionsali)
  96. requestNew(PAYMENTORDERAPPLY, optionsali).then((res) => {
  97. const data = res;
  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. (err)=>{
  112. state.isclick = true
  113. console.log("err")
  114. }
  115. );
  116. });
  117. },
  118. fail: err => {
  119. console.log('my.getAuthCode 调用失败', err)
  120. state.isclick = true
  121. }
  122. });
  123. // #endif
  124. // #ifdef MP-WEIXIN
  125. uni.login({
  126. provider: "weixin",
  127. success: function (e) {
  128. const options1 = {
  129. type: 2,
  130. data: {
  131. "jsCode": e.code
  132. },
  133. method: "POST",
  134. showLoading: true,
  135. };
  136. requestNew(getOpenId, options1).then((res) => {
  137. const result = res;
  138. const openidData = stringToJson(result.data);
  139. console.log("获取openId", openidData)
  140. const options = {
  141. type: 2,
  142. data: {
  143. orderId: state.orderId,
  144. wxOpenId: openidData.openid,
  145. payType: val.payType,
  146. longitude:state.longitude, //经度
  147. latitude:state.latitude //纬度
  148. },
  149. method: "POST",
  150. showLoading: true,
  151. };
  152. requestNew(payApply, options).then((res) => {
  153. const data = res;
  154. console.log("data======111", data)
  155. if (data) {
  156. console.log("进来了")
  157. uni.requestPayment({
  158. provider: "wxpay",
  159. orderInfo: "",
  160. timeStamp: data.timestamp,
  161. nonceStr: data.noncestr,
  162. package: data.wxPackage ? data.wxPackage : "",
  163. signType: data.signType,
  164. paySign: data.sign,
  165. success: function (e) {
  166. console.log("支付成功", res);
  167. refresh();
  168. },
  169. fail: function (err) {
  170. state.isclick = true
  171. confirm(err, () => { }, "支付失败", false);
  172. },
  173. });
  174. } else {
  175. state.isclick = true
  176. console.log("state.isclick", state.isclick)
  177. }
  178. },
  179. (err)=>{
  180. state.isclick = true
  181. console.log("err")
  182. }
  183. );
  184. });
  185. },
  186. });
  187. // #endif
  188. }
  189. // })
  190. }
  191. };
  192. const refresh = () => {
  193. state.isclick = true
  194. let source = ""
  195. // #ifdef MP-ALIPAY
  196. source = "ALI"
  197. // #endif
  198. // #ifdef MP-WEIXIN
  199. source = "WECHAT"
  200. // #endif
  201. var data = {
  202. orderId: state.orderId,
  203. };
  204. const options = {
  205. type: 2,
  206. data: data,
  207. method: "POST",
  208. showLoading: true,
  209. };
  210. console.log("输出内容", options);
  211. requestNew(payQuery, options).then((res) => {
  212. console.log("res====", res)
  213. const data = res;
  214. console.log(data);
  215. if (data.paymentStatus == 'ALLSUCCESS') {
  216. gotoEditUserOrUnitInfo()
  217. }
  218. state.dataArray = data.datas;
  219. for (let i = 0; i < state.dataArray.length; i++) {
  220. if (state.dataArray[i].payType === 'HANDLE') {
  221. state.dataArray[i].payName = '权益金'
  222. } else if (state.dataArray[i].payType === 'MARGIN') {
  223. state.dataArray[i].payName = '保证金'
  224. } else if (state.dataArray[i].payType === 'PRESTORE') {
  225. state.dataArray[i].payName = '预存金'
  226. } else if (state.dataArray[i].payType === 'EQUITY') {
  227. state.dataArray[i].payName = '权益费'
  228. } else if (state.dataArray[i].payType === 'REPAIROBU') {
  229. state.dataArray[i].payName = '增补obu'
  230. } else if (state.dataArray[i].payType === 'CHANGECARD') {
  231. state.dataArray[i].payName = '更换卡'
  232. } else if (state.dataArray[i].payType === 'CHANGEOBU') {
  233. state.dataArray[i].payName = '更换签'
  234. } else if (state.dataArray[i].payType === 'CHANGEALL') {
  235. state.dataArray[i].payName = '更换卡签'
  236. } else {
  237. state.dataArray[i].payName = '未知费'
  238. }
  239. if (state.dataArray[i].payStatus === 'SUCCESS') {
  240. state.dataArray[i].payStatusName = '已支付'
  241. } else if (state.dataArray[i].payStatus === 'PAYING') {
  242. state.dataArray[i].payStatusName = '支付中'
  243. } else if (state.dataArray[i].payStatus === 'FAILED') {
  244. state.dataArray[i].payStatusName = '支付失败'
  245. } else if (state.dataArray[i].payStatus === 'UNPAY') {
  246. state.dataArray[i].payStatusName = '未支付'
  247. } else if (state.dataArray[i].payStatus === 'CLOSED') {
  248. state.dataArray[i].payStatusName = '已关闭'
  249. } else if (state.dataArray[i].payStatus === 'CANCELED') {
  250. state.dataArray[i].payStatusName = '已撤销'
  251. } else if (state.dataArray[i].payStatus === 'REFUND') {
  252. state.dataArray[i].payStatusName = '转入退费'
  253. } else {
  254. state.dataArray[i].payStatusName = '未知'
  255. }
  256. }
  257. console.log("state.dataArray", state.dataArray)
  258. });
  259. }
  260. onLoad((option : any) => {
  261. console.log("传递过来的到支付页面", option)
  262. state.orderId = option.orderId;
  263. state.isValueCard = option.isValueCard;
  264. state.vehicleId = option.vehicleId;
  265. state.orderQuery = option.orderQuery;
  266. let source = ""
  267. // #ifdef MP-ALIPAY
  268. imageUrl = imgURL + "applyCard/alibaba.png";
  269. source = "ALI"
  270. // #endif
  271. // #ifdef MP-WEIXIN
  272. imageUrl = imgURL + "applyCard/wechat.png";
  273. source = "WECHAT"
  274. // #endif
  275. var data = {
  276. orderId: state.orderId,
  277. };
  278. const options = {
  279. type: 2,
  280. data: data,
  281. method: "POST",
  282. showLoading: true,
  283. };
  284. console.log("输出内容", options);
  285. requestNew(payQuery, options).then((res) => {
  286. const data = res;
  287. console.log(data);
  288. if (data.paymentStatus == 'ALLSUCCESS') {
  289. // isValueCard 1 储值卡 2 记账卡
  290. if (state.isValueCard == 1) {
  291. if(state.orderQuery == '1'){
  292. uni.navigateBack()
  293. }else{
  294. uni.switchTab({
  295. url: "/pages/order/order"
  296. })
  297. }
  298. } else {
  299. navTo(
  300. `/subpackage/orders/release-products?orderId=${state.orderId}&orderQuery=${state.orderQuery}`,
  301. );
  302. }
  303. }
  304. state.dataArray = data.datas;
  305. for (let i = 0; i < state.dataArray.length; i++) {
  306. if (state.dataArray[i].payType === 'HANDLE') {
  307. state.dataArray[i].payName = '权益金'
  308. } else if (state.dataArray[i].payType === 'MARGIN') {
  309. state.dataArray[i].payName = '保证金'
  310. } else if (state.dataArray[i].payType === 'PRESTORE') {
  311. state.dataArray[i].payName = '预存金'
  312. } else if (state.dataArray[i].payType === 'EQUITY') {
  313. state.dataArray[i].payName = '权益费'
  314. } else if (state.dataArray[i].payType === 'REPAIROBU') {
  315. state.dataArray[i].payName = '增补obu'
  316. } else if (state.dataArray[i].payType === 'CHANGECARD') {
  317. state.dataArray[i].payName = '更换卡'
  318. } else if (state.dataArray[i].payType === 'CHANGEOBU') {
  319. state.dataArray[i].payName = '更换签'
  320. } else if (state.dataArray[i].payType === 'CHANGEALL') {
  321. state.dataArray[i].payName = '更换卡签'
  322. } else {
  323. state.dataArray[i].payName = '未知费'
  324. }
  325. if (state.dataArray[i].payStatus === 'SUCCESS') {
  326. state.dataArray[i].payStatusName = '已支付'
  327. } else if (state.dataArray[i].payStatus === 'PAYING') {
  328. state.dataArray[i].payStatusName = '支付中'
  329. } else if (state.dataArray[i].payStatus === 'FAILED') {
  330. state.dataArray[i].payStatusName = '支付失败'
  331. } else if (state.dataArray[i].payStatus === 'UNPAY') {
  332. state.dataArray[i].payStatusName = '未支付'
  333. } else if (state.dataArray[i].payStatus === 'CLOSED') {
  334. state.dataArray[i].payStatusName = '已关闭'
  335. } else if (state.dataArray[i].payStatus === 'CANCELED') {
  336. state.dataArray[i].payStatusName = '已撤销'
  337. } else if (state.dataArray[i].payStatus === 'REFUND') {
  338. state.dataArray[i].payStatusName = '转入退费'
  339. } else {
  340. state.dataArray[i].payStatusName = '未知'
  341. }
  342. }
  343. console.log("state.dataArray", state.dataArray)
  344. });
  345. uni.getLocation({
  346. type: 'gcj02',
  347. success: function (res) {
  348. console.log("经纬福",res)
  349. state.longitude = res.longitude;
  350. state.latitude = res.latitude;
  351. },
  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. if(state.orderQuery == '1'){
  380. uni.navigateBack()
  381. }else{
  382. uni.switchTab({
  383. url: "/pages/order/order"
  384. })
  385. }
  386. } else {
  387. navTo(
  388. `/subpackage/orders/release-products?orderId=${state.orderId}&orderQuery=${state.orderQuery}`,
  389. );
  390. }
  391. }
  392. const state = reactive({
  393. isValueCard: 1, //卡的类型
  394. radiolist1: [], //选择卡的数据列表
  395. choiceCardShow: false, //选择卡的弹出框
  396. isSign: '',
  397. id: "",
  398. orderId: "",
  399. userType: 1, //1 个人 2单位
  400. type: 0, //0 客车 1货车
  401. vehiclePlateColor: "",
  402. data: {
  403. show: false,
  404. src: imgURL + "applyCard/edit.png",
  405. },
  406. dataArray: [],
  407. list: [
  408. {
  409. bg: imgURL + "applyCard/product-bg.png",
  410. icon: imgURL + "applyCard/wechat.png",
  411. title: "【货车】微信车主服务",
  412. tip: "绑定微信支付,无需绑定银行卡",
  413. },
  414. ],
  415. openid: "",
  416. isclick: true,//防止重复点击
  417. vehicleId: "",
  418. orderQuery:"0",
  419. longitude:"",
  420. latitude:""
  421. });
  422. </script>
  423. <style lang="scss" scoped>
  424. ::v-deep .u-radio {
  425. display: flex !important;
  426. align-items: center !important;
  427. float: none !important;
  428. }
  429. ::v-deep .u-icon__icon {
  430. top: -4px !important;
  431. }
  432. .bottomTip {
  433. margin-top: 100rpx;
  434. text-align: center;
  435. font-size: 28rpx;
  436. font-family: Microsoft YaHei;
  437. font-weight: 400;
  438. color: #b3b3b3;
  439. }
  440. .content-value {
  441. position: absolute;
  442. top: 370rpx;
  443. width: 100%;
  444. min-height: calc(100% - 370rpx);
  445. box-sizing: border-box;
  446. padding: 0 30rpx 210rpx;
  447. .t-card {
  448. background-color: #fff;
  449. padding: 40rpx 30rpx;
  450. border-radius: 12rpx;
  451. }
  452. .img-pos {
  453. position: absolute;
  454. left: 500rpx;
  455. top: -38rpx;
  456. right: 50rpx;
  457. .img-flex {
  458. display: flex;
  459. justify-content: space-between;
  460. align-items: center;
  461. .car-img {
  462. width: 86rpx;
  463. height: 42rpx;
  464. }
  465. .flag-img {
  466. width: 30rpx;
  467. height: 35rpx;
  468. }
  469. }
  470. }
  471. }
  472. .flex {
  473. display: flex;
  474. align-items: center;
  475. }
  476. .action {
  477. margin-top: 30rpx;
  478. padding-left: 20rpx;
  479. padding-right: 20rpx;
  480. padding-bottom: 30rpx;
  481. .button {
  482. height: 80rpx;
  483. background: linear-gradient(-90deg, #43a1e0 0%, #13e7c1 100%);
  484. border-radius: 40rpx;
  485. font-size: 32rpx;
  486. font-weight: 400;
  487. color: #ffffff;
  488. line-height: 80rpx;
  489. }
  490. }
  491. .action-btn {
  492. margin-left: 45rpx;
  493. width: 121rpx;
  494. height: 61rpx;
  495. border: 1px solid rgba(255, 255, 255, 1);
  496. border-radius: 30rpx;
  497. background: rgba(255, 255, 255, 0.2);
  498. text-align: center;
  499. font-size: 30rpx;
  500. font-family: Microsoft YaHei;
  501. font-weight: 400;
  502. color: #ffffff;
  503. line-height: 61rpx;
  504. }
  505. .tag1 {
  506. padding: 5rpx;
  507. background: rgba(0, 179, 139, 0.5);
  508. border-radius: 6rpx;
  509. font-size: 22rpx;
  510. font-family: Microsoft YaHei;
  511. font-weight: 400;
  512. color: #ffffff;
  513. }
  514. .tag3 {
  515. padding: 5rpx;
  516. background: rgba(139, 112, 228, 0.5);
  517. border-radius: 6rpx;
  518. font-size: 22rpx;
  519. font-family: Microsoft YaHei;
  520. font-weight: 400;
  521. color: #ffffff;
  522. }
  523. .tag2 {
  524. padding: 5rpx;
  525. background: rgba(249, 97, 60, 0.5);
  526. border-radius: 6rpx;
  527. font-size: 22rpx;
  528. font-family: Microsoft YaHei;
  529. font-weight: 400;
  530. color: #ffffff;
  531. }
  532. .ul-item {
  533. display: flex;
  534. align-items: center;
  535. &:nth-child(n+2) {
  536. margin-top: 30rpx;
  537. }
  538. .item-value {
  539. padding: 20rpx;
  540. position: absolute;
  541. display: flex;
  542. align-items: center;
  543. width: 100%;
  544. box-sizing: border-box;
  545. height: 146rpx;
  546. .money {
  547. color: #fff;
  548. font-size: 46rpx;
  549. font-family: SourceHanSansCN, SourceHanSansCN;
  550. font-weight: 400;
  551. margin-right: 43rpx;
  552. .unit {
  553. font-size: 29rpx;
  554. margin-right: 2rpx;
  555. }
  556. }
  557. .content {
  558. margin-left: 33rpx;
  559. .title {
  560. font-weight: 400;
  561. font-family: SourceHanSansCN, SourceHanSansCN;
  562. font-size: 36rpx;
  563. color: #2C3246;
  564. }
  565. }
  566. .r-btn {
  567. margin-left: 137rpx;
  568. width: 139rpx;
  569. height: 65rpx;
  570. background: radial-gradient(at 0% 0%, #C6B077 0%, #DFCC96 100%);
  571. border-radius: 33rpx;
  572. font-family: SourceHanSansCN, SourceHanSansCN;
  573. font-weight: 400;
  574. font-size: 26rpx;
  575. color: #FFFFFF;
  576. line-height: 65rpx;
  577. text-align: center;
  578. }
  579. }
  580. .icon-tip {
  581. width: 100rpx;
  582. height: 100rpx;
  583. }
  584. }
  585. ::v-deep .u-mode-center-box {
  586. border-radius: 10rpx;
  587. }
  588. .squire {
  589. padding: 30rpx 30rpx 50rpx 50rpx;
  590. }
  591. .mask-close {
  592. text-align: right;
  593. }
  594. .icon-closed {
  595. width: 48rpx;
  596. height: 48rpx;
  597. }
  598. .mask-title {
  599. text-align: center;
  600. font-size: 32rpx;
  601. color: $uni-text-color-black;
  602. margin-bottom: 50rpx;
  603. }
  604. </style>