您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

order_payment.vue 16KB

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