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

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