Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

order_payment.vue 16KB

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