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

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