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

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