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.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678
  1. <template>
  2. <navBar title="订单支付" :scrollTop="scrollTop"></navBar>
  3. <navBgCar></navBgCar>
  4. <view class="content-value">
  5. <view @click="savaHandle(item)" class="ul-item" v-for="(item, index) in state.dataArray" :key="index">
  6. <image style="width: 100%; height: 170rpx; border-radius: 20rpx"
  7. :src="`${$imgUrl}applyCard/product-bg.png`"></image>
  8. <view class="item-value">
  9. <image class="icon-tip" :src="imageUrl"></image>
  10. <view class="content">
  11. <view class="title">
  12. {{ item.payName }}
  13. </view>
  14. <!-- 1记账卡2储值卡3记存卡 -->
  15. <!-- <view style="margin-top: 15rpx" class="tip" v-if="item.cardType=='1'">
  16. 记账卡
  17. </view> -->
  18. <view style="margin-top: 15rpx" class="tip">
  19. {{ item.payStatusName }}
  20. </view>
  21. </view>
  22. <view class="money">
  23. ¥:{{ item.fee * 0.01 }}
  24. </view>
  25. </view>
  26. </view>
  27. <!-- <view class="bottomTip"> 到底啦!敬请期待其他产品! </view> -->
  28. </view>
  29. <!-- <u-popup mode="center" v-model="state.choiceCardShow" closeable>
  30. <view class="squire">
  31. <view class="mask-title" :style="{ '--color': color }">选择办理卡类型</view>
  32. <view class="as-layout-horizontal">
  33. <view v-for="(item, index) in state.radiolist1" :key="index" :label="item.disabled" :name="item.name"
  34. @click="radioChange(item.name)"
  35. style="width: 100%;display: flex;align-items: center;margin-bottom: 30rpx;">
  36. <view class="as-layout-vertical as-gravity-center">
  37. <image style="width: 140rpx; height: 100rpx; border-radius: 20rpx;margin-right: 20rpx;"
  38. :src="`${$imgUrl}card2.png`" mode="aspectFill"></image>
  39. <view style="margin-top: 20rpx;">
  40. {{item.name}}
  41. </view>
  42. </view>
  43. </view>
  44. </view>
  45. </view>
  46. </u-popup> -->
  47. </template>
  48. <script setup lang="ts">
  49. import { onLoad, onPageScroll } from "@dcloudio/uni-app";
  50. import { reactive, ref } from "vue";
  51. import {
  52. PAYDETECTION,
  53. PAYMENTORDERAPPLY,
  54. wechatAppID,
  55. wechatSecret,
  56. CardBillQuery,
  57. CardBillPlaceOrder,
  58. CardBillPayStatus,
  59. wechatPayConfigId,
  60. aliPayConfigIdTwo,
  61. obtainUserId,
  62. getOpenidApi,
  63. orderDetail
  64. } from "@/utils/network/api.js";
  65. import { request } from "@/utils/network/request.js";
  66. import { stringToJson } from "@/utils/network/encryption";
  67. import { fileURL } from "@/datas/fileURL.js";
  68. import navBgCar from "./components/nav-bg-car5";
  69. import navBar from "@/components/nav-bar/nav-bar2.vue";
  70. import { getItem, StorageKeys, setItem } from "@/utils/storage.ts";
  71. import { msg } from "@/utils/utils";
  72. const imgURL = `${fileURL}image/`;
  73. let imageUrl = ""
  74. // import { setItem } from "@/utils/storage";
  75. let logo
  76. const scrollTop = ref(0); //滚动距离
  77. // 单选默认数据
  78. // let flag = ref(true)
  79. // 单选
  80. const radioChange = (n) => {
  81. console.log('radioChange', n);
  82. if (n == '记账卡') {
  83. state.isValueCard = 2
  84. } else if (n == '储值卡') {
  85. state.isValueCard = 1
  86. } else {
  87. state.isValueCard = 3
  88. }
  89. uni.redirectTo({
  90. url: `/subpackage/orders/essential-information?promoteId=${getItem("promoteId")}&userType=${state.userType}&type=${state.type}&isSign=${state.isSign}&isValueCard=${state.isValueCard}`,
  91. });
  92. }
  93. const savaHandle = (val) => {
  94. if (val.payStatus === 'UNPAY') {
  95. // #ifdef MP-ALIPAY
  96. my.getAuthCode({
  97. scopes: 'auth_base',
  98. success: res => {
  99. const optionsUser = {
  100. type: 2,
  101. data: {
  102. payConfigId: aliPayConfigIdTwo,
  103. code: res.authCode
  104. },
  105. method: "POST",
  106. showLoading: true,
  107. };
  108. console.log('支付宝用户编号请求:', optionsUser)
  109. request(obtainUserId, optionsUser).then((res) => {
  110. console.log('支付宝用户编号返回:', res)
  111. const data = stringToJson(res.bizContent);
  112. const optionsali = {
  113. type: 2,
  114. data: {
  115. orderId: state.orderId,
  116. wxOpenid: data.openId,
  117. payType: val.payType
  118. },
  119. method: "POST",
  120. showLoading: true,
  121. };
  122. console.log('支付下单请求:', optionsali)
  123. request(PAYMENTORDERAPPLY, optionsali).then((res) => {
  124. console.log('支付下单返回:', res)
  125. const data = stringToJson(res.bizContent);
  126. my.tradePay({
  127. // 调用统一收单交易创建接口(alipay.trade.create),获得返回字段支付宝交易号 trade_no
  128. tradeNO: data.tranPackage,
  129. success: res => {
  130. console.log("支付成功", res);
  131. refresh();
  132. },
  133. fail: res => {
  134. console.log("支付失败", res);
  135. },
  136. });
  137. });
  138. });
  139. },
  140. fail: err => {
  141. console.log('my.getAuthCode 调用失败', err)
  142. }
  143. });
  144. // #endif
  145. // #ifdef MP-WEIXIN
  146. // if (!state.openid) {
  147. // getOpenID();
  148. // }
  149. uni.login({
  150. provider: "weixin",
  151. success: function (e) {
  152. // uni.request({
  153. // url: `https://api.weixin.qq.com/sns/jscode2session?appid=${wechatAppID}&secret=${wechatSecret}&js_code=${e.code}&grant_type=authorization_code`,
  154. // success: (res : any) => {
  155. const options1 = {
  156. type: 2,
  157. data: {
  158. "jsCode": e.code
  159. },
  160. method: "POST",
  161. showLoading: true,
  162. };
  163. request(getOpenidApi, options1).then((res) => {
  164. const result = stringToJson(res.bizContent);
  165. const openidData = stringToJson(result.data);
  166. console.log("获取openId", openidData)
  167. const options = {
  168. type: 2,
  169. data: {
  170. orderId: state.orderId,
  171. wxOpenid: openidData.openid,
  172. payType: val.payType
  173. },
  174. method: "POST",
  175. showLoading: true,
  176. };
  177. request(PAYMENTORDERAPPLY, options).then((res) => {
  178. const data = stringToJson(res.bizContent);
  179. uni.requestPayment({
  180. provider: "wxpay",
  181. orderInfo: "",
  182. timeStamp: data.timestamp,
  183. nonceStr: data.noncestr,
  184. package: data.wxPackage ? data.wxPackage : "",
  185. signType: data.signType,
  186. paySign: data.sign,
  187. success: function (e) {
  188. console.log("支付成功", res);
  189. refresh();
  190. },
  191. fail: function (err) {
  192. confirm(err, () => { }, "支付失败", false);
  193. },
  194. });
  195. });
  196. });
  197. // },
  198. // });
  199. },
  200. });
  201. // #endif
  202. }
  203. };
  204. const getOpenID = () => {
  205. uni.login({
  206. provider: "weixin",
  207. success: function (e) {
  208. getOpenid(e.code);
  209. // uni.request({
  210. // url: `https://api.weixin.qq.com/sns/jscode2session?appid=${wechatAppID}&secret=${wechatSecret}&js_code=${e.code}&grant_type=authorization_code`,
  211. // success: (res: any) => {
  212. // state.openid = res.data.openid;
  213. // },
  214. // });
  215. },
  216. });
  217. };
  218. const getOpenid = (code) => {
  219. const options = {
  220. type: 2,
  221. data: {
  222. "jsCode": code
  223. },
  224. method: "POST",
  225. showLoading: true,
  226. };
  227. // #ifdef MP-WEIXIN
  228. request(getOpenidApi, options).then((res) => {
  229. const result = stringToJson(res.bizContent);
  230. console.log("获取微信小程序openid", result);
  231. const openidData = stringToJson(result.data);
  232. state.openid = openidData.openid;
  233. });
  234. // #endif
  235. }
  236. const refresh = () => {
  237. let source = ""
  238. // #ifdef MP-ALIPAY
  239. source = "ALI"
  240. // #endif
  241. // #ifdef MP-WEIXIN
  242. source = "WECHAT"
  243. // getOpenID();
  244. // #endif
  245. var data = {
  246. orderId: state.orderId,
  247. source: source //请求方来源
  248. };
  249. const options = {
  250. type: 2,
  251. data: data,
  252. method: "POST",
  253. showLoading: true,
  254. };
  255. console.log("输出内容", options);
  256. request(PAYDETECTION, options).then((res) => {
  257. // console.log(res.bizContent);
  258. const data = stringToJson(res.bizContent);
  259. console.log(data);
  260. // console.log(typeof(data));
  261. if (data.paymentStatus == 'ALLSUCCESS') {
  262. gotoEditUserOrUnitInfo()
  263. }
  264. state.dataArray = data.datas;
  265. // HANDLE("办理费",1){},
  266. // MARGIN("保证金",2){},
  267. // PRESTORE("预存金",3){},
  268. // EQUITY("权益费",4){},
  269. for (let i = 0; i < state.dataArray.length; i++) {
  270. if (state.dataArray[i].payType === 'HANDLE') {
  271. state.dataArray[i].payName = '办理费'
  272. } else if (state.dataArray[i].payType === 'MARGIN') {
  273. state.dataArray[i].payName = '保证金'
  274. } else if (state.dataArray[i].payType === 'PRESTORE') {
  275. state.dataArray[i].payName = '预存金'
  276. } else if (state.dataArray[i].payType === 'EQUITY') {
  277. state.dataArray[i].payName = '权益费'
  278. } else {
  279. state.dataArray[i].payName = '未知费'
  280. }
  281. // SUCCESS("支付成功",1){},
  282. // PAYING("支付中",2){},
  283. // FAILED("支付失败",3){},
  284. // UNPAY("未支付",4){},
  285. // CLOSED("已关闭",5){},
  286. // CANCELED("已撤销",6){},
  287. // REFUND("转入退费",7){},
  288. if (state.dataArray[i].payStatus === 'SUCCESS') {
  289. state.dataArray[i].payStatusName = '已支付'
  290. } else if (state.dataArray[i].payStatus === 'PAYING') {
  291. state.dataArray[i].payStatusName = '支付中'
  292. } else if (state.dataArray[i].payStatus === 'FAILED') {
  293. state.dataArray[i].payStatusName = '支付失败'
  294. } else if (state.dataArray[i].payStatus === 'UNPAY') {
  295. state.dataArray[i].payStatusName = '未支付'
  296. } else if (state.dataArray[i].payStatus === 'CLOSED') {
  297. state.dataArray[i].payStatusName = '已关闭'
  298. } else if (state.dataArray[i].payStatus === 'CANCELED') {
  299. state.dataArray[i].payStatusName = '已撤销'
  300. } else if (state.dataArray[i].payStatus === 'REFUND') {
  301. state.dataArray[i].payStatusName = '转入退费'
  302. } else {
  303. state.dataArray[i].payStatusName = '未知'
  304. }
  305. }
  306. console.log("state.dataArray", state.dataArray)
  307. });
  308. }
  309. onLoad((option : any) => {
  310. state.orderId = option.orderId;
  311. state.isValueCard = option.isValueCard;
  312. let source = ""
  313. // #ifdef MP-ALIPAY
  314. imageUrl = imgURL + "applyCard/alibaba.png";
  315. source = "ALI"
  316. // #endif
  317. // #ifdef MP-WEIXIN
  318. imageUrl = imgURL + "applyCard/wechat.png";
  319. source = "WECHAT"
  320. // #endif
  321. // state.userType = option.userType;
  322. // state.vehiclePlateColor = option.vehiclePlateColor;
  323. // state.userType = option.userType;
  324. // state.type = option.type;
  325. // option.orderId;
  326. var data = {
  327. orderId: state.orderId,
  328. source: source //请求方来源
  329. };
  330. const options = {
  331. type: 2,
  332. data: data,
  333. method: "POST",
  334. showLoading: true,
  335. };
  336. console.log("输出内容", options);
  337. request(PAYDETECTION, options).then((res) => {
  338. // console.log(res.bizContent);
  339. const data = stringToJson(res.bizContent);
  340. console.log(data);
  341. // console.log(typeof(data));
  342. if (data.paymentStatus == 'ALLSUCCESS') {
  343. // gotoEditUserOrUnitInfo()
  344. // uni.redirectTo({
  345. // url: `/subpackage/orders/sign-up-ali?orderId=${state.orderId}`,
  346. // });
  347. if (state.isValueCard != 1) {
  348. uni.redirectTo({
  349. url: `/subpackage/orders/release-products?orderId=${state.orderId}`,
  350. });
  351. } else {
  352. uni.switchTab({
  353. url: "/pages/order/order"
  354. })
  355. }
  356. }
  357. state.dataArray = data.datas;
  358. // HANDLE("办理费",1){},
  359. // MARGIN("保证金",2){},
  360. // PRESTORE("预存金",3){},
  361. // EQUITY("权益费",4){},
  362. for (let i = 0; i < state.dataArray.length; i++) {
  363. if (state.dataArray[i].payType === 'HANDLE') {
  364. state.dataArray[i].payName = '办理费'
  365. } else if (state.dataArray[i].payType === 'MARGIN') {
  366. state.dataArray[i].payName = '保证金'
  367. } else if (state.dataArray[i].payType === 'PRESTORE') {
  368. state.dataArray[i].payName = '预存金'
  369. } else if (state.dataArray[i].payType === 'EQUITY') {
  370. state.dataArray[i].payName = '权益费'
  371. } else {
  372. state.dataArray[i].payName = '未知费'
  373. }
  374. // SUCCESS("支付成功",1){},
  375. // PAYING("支付中",2){},
  376. // FAILED("支付失败",3){},
  377. // UNPAY("未支付",4){},
  378. // CLOSED("已关闭",5){},
  379. // CANCELED("已撤销",6){},
  380. // REFUND("转入退费",7){},
  381. if (state.dataArray[i].payStatus === 'SUCCESS') {
  382. state.dataArray[i].payStatusName = '已支付'
  383. } else if (state.dataArray[i].payStatus === 'PAYING') {
  384. state.dataArray[i].payStatusName = '支付中'
  385. } else if (state.dataArray[i].payStatus === 'FAILED') {
  386. state.dataArray[i].payStatusName = '支付失败'
  387. } else if (state.dataArray[i].payStatus === 'UNPAY') {
  388. state.dataArray[i].payStatusName = '未支付'
  389. } else if (state.dataArray[i].payStatus === 'CLOSED') {
  390. state.dataArray[i].payStatusName = '已关闭'
  391. } else if (state.dataArray[i].payStatus === 'CANCELED') {
  392. state.dataArray[i].payStatusName = '已撤销'
  393. } else if (state.dataArray[i].payStatus === 'REFUND') {
  394. state.dataArray[i].payStatusName = '转入退费'
  395. } else {
  396. state.dataArray[i].payStatusName = '未知'
  397. }
  398. }
  399. console.log("state.dataArray", state.dataArray)
  400. });
  401. });
  402. //监听页面滚动
  403. onPageScroll((e) => {
  404. scrollTop.value = e.scrollTop;
  405. });
  406. const productReCodeAction = (id) => {
  407. var data = {
  408. productId: id,
  409. orderId: state.orderId,
  410. };
  411. const options = {
  412. type: 2,
  413. data: data,
  414. method: "POST",
  415. showLoading: true,
  416. };
  417. return new Promise(async (resolve, reject) => {
  418. const res = await request(productReCode, options);
  419. const data = stringToJson(res.bizContent);
  420. resolve(data);
  421. }).catch((error) => {
  422. reject(error);
  423. });
  424. };
  425. const gotoEditUserOrUnitInfo = () => {
  426. if (state.isValueCard != 1) {
  427. uni.redirectTo({
  428. url: `/subpackage/orders/release-products?orderId=${state.orderId}`,
  429. });
  430. } else {
  431. uni.switchTab({
  432. url: "/pages/order/order"
  433. })
  434. }
  435. }
  436. const state = reactive({
  437. isValueCard: 1, //卡的类型
  438. radiolist1: [], //选择卡的数据列表
  439. choiceCardShow: false, //选择卡的弹出框
  440. isSign: '',
  441. id: "",
  442. orderId: "",
  443. userType: 1, //1 个人 2单位
  444. type: 0, //0 客车 1货车
  445. vehiclePlateColor: "",
  446. data: {
  447. show: false,
  448. src: imgURL + "applyCard/edit.png",
  449. },
  450. dataArray: [],
  451. list: [
  452. {
  453. bg: imgURL + "applyCard/product-bg.png",
  454. icon: imgURL + "applyCard/wechat.png",
  455. title: "【货车】微信车主服务",
  456. tip: "绑定微信支付,无需绑定银行卡",
  457. },
  458. ],
  459. openid: ""
  460. });
  461. </script>
  462. <style lang="scss" scoped>
  463. ::v-deep .u-radio {
  464. display: flex !important;
  465. align-items: center !important;
  466. float: none !important;
  467. }
  468. ::v-deep .u-icon__icon {
  469. top: -4px !important;
  470. }
  471. .bottomTip {
  472. margin-top: 100rpx;
  473. text-align: center;
  474. font-size: 28rpx;
  475. font-family: Microsoft YaHei;
  476. font-weight: 400;
  477. color: #b3b3b3;
  478. }
  479. .content-value {
  480. position: relative;
  481. // margin-top: -50rpx;
  482. padding: 0rpx 30rpx;
  483. position: relative;
  484. .img-pos {
  485. position: absolute;
  486. left: 500rpx;
  487. top: -38rpx;
  488. right: 50rpx;
  489. .img-flex {
  490. display: flex;
  491. justify-content: space-between;
  492. align-items: center;
  493. .car-img {
  494. width: 86rpx;
  495. height: 42rpx;
  496. }
  497. .flag-img {
  498. width: 30rpx;
  499. height: 35rpx;
  500. }
  501. }
  502. }
  503. }
  504. .flex {
  505. display: flex;
  506. align-items: center;
  507. }
  508. .action {
  509. margin-top: 30rpx;
  510. padding-left: 20rpx;
  511. padding-right: 20rpx;
  512. padding-bottom: 30rpx;
  513. .button {
  514. height: 80rpx;
  515. background: linear-gradient(-90deg, #43a1e0 0%, #13e7c1 100%);
  516. border-radius: 40rpx;
  517. font-size: 32rpx;
  518. font-weight: 400;
  519. color: #ffffff;
  520. line-height: 80rpx;
  521. }
  522. }
  523. .action-btn {
  524. margin-left: 45rpx;
  525. width: 121rpx;
  526. height: 61rpx;
  527. border: 1px solid rgba(255, 255, 255, 1);
  528. border-radius: 30rpx;
  529. background: rgba(255, 255, 255, 0.2);
  530. text-align: center;
  531. font-size: 30rpx;
  532. font-family: Microsoft YaHei;
  533. font-weight: 400;
  534. color: #ffffff;
  535. line-height: 61rpx;
  536. }
  537. .tag1 {
  538. padding: 5rpx;
  539. background: rgba(0, 179, 139, 0.5);
  540. border-radius: 6rpx;
  541. font-size: 22rpx;
  542. font-family: Microsoft YaHei;
  543. font-weight: 400;
  544. color: #ffffff;
  545. }
  546. .tag3 {
  547. padding: 5rpx;
  548. background: rgba(139, 112, 228, 0.5);
  549. border-radius: 6rpx;
  550. font-size: 22rpx;
  551. font-family: Microsoft YaHei;
  552. font-weight: 400;
  553. color: #ffffff;
  554. }
  555. .tag2 {
  556. padding: 5rpx;
  557. background: rgba(249, 97, 60, 0.5);
  558. border-radius: 6rpx;
  559. font-size: 22rpx;
  560. font-family: Microsoft YaHei;
  561. font-weight: 400;
  562. color: #ffffff;
  563. }
  564. .ul-item {
  565. padding: 5px 20rpx;
  566. display: flex;
  567. align-items: center;
  568. .item-value {
  569. padding: 20rpx;
  570. position: absolute;
  571. display: flex;
  572. align-items: center;
  573. // justify-content: space-around;
  574. width: 80%;
  575. .content {
  576. width: 51%;
  577. .title {
  578. font-size: 32rpx;
  579. font-family: Microsoft YaHei;
  580. font-weight: 400;
  581. color: #ffffff;
  582. }
  583. .tip {
  584. font-size: 24rpx;
  585. font-family: Microsoft YaHei;
  586. font-weight: 400;
  587. color: #ffffff;
  588. }
  589. }
  590. }
  591. .icon-tip {
  592. width: 100rpx;
  593. height: 100rpx;
  594. }
  595. .content {
  596. margin-left: 40rpx;
  597. }
  598. }
  599. .money {
  600. color: white;
  601. // float: right;
  602. }
  603. ::v-deep .u-mode-center-box {
  604. border-radius: 10rpx;
  605. }
  606. .squire {
  607. padding: 30rpx 30rpx 50rpx 50rpx;
  608. }
  609. .mask-close {
  610. text-align: right;
  611. }
  612. .icon-closed {
  613. width: 48rpx;
  614. height: 48rpx;
  615. }
  616. .mask-title {
  617. text-align: center;
  618. font-size: 32rpx;
  619. color: $uni-text-color-black;
  620. margin-bottom: 50rpx;
  621. }
  622. </style>