瀏覽代碼

调整室内支付

zaijin 2 年之前
父節點
當前提交
f439c06ed7

+ 0 - 1
common/http.api.js

@@ -1,7 +1,6 @@
 import { apiurl } from './apiurl.js';
 
 // 此处第二个参数vm,就是我们在页面使用的this,你可以通过vm获取vuex等操作,更多内容详见uView对拦截器的介绍部分:
-// https://uviewui.com/js/http.html#%E4%BD%95%E8%B0%93%E8%AF%B7%E6%B1%82%E6%8B%A6%E6%88%AA%EF%BC%9F
 const install = (Vue, vm) => {
   // 反馈提交
   let feedbackAdd = (params = {}) => vm.$u.post(apiurl.feedbackAddUrl, params);

+ 30 - 16
pages/OnsitePayment/OnsitePayment.vue

@@ -12,7 +12,7 @@
           </view>
         </view>
         <view class="parking-lock-pay-btn">
-          <button type="default" @click="payMoney">立即支付</button>
+          <button type="default" @click="payMoney" :disabled="!orderInfo.id">立即支付</button>
         </view>
         <view class="parking-lock-pay-attention">
           <text>温馨提示:支付完成请尽快离场,超过免费时长将会重新计费</text>
@@ -38,7 +38,7 @@ export default {
       // 订单信息
       orderInfo: {},
       // 回调地址
-      jumpUrl: location.href + '&isBack=1',
+      jumpUrl: '',
       // 显示的字段集合
       fieldList: [
         { key: 'vehicleNo', label: '车牌号' },
@@ -57,17 +57,29 @@ export default {
       },
       timer: null,
       polyOrderId: undefined, // 预支付订单id
-      isBack: 0
+      isBack: 0,
+      needPay: ''
     };
   },
-  onLoad(page) {
-    const { vehicleNo, parkNo, isBack, polyOrderId } = page;
+  onLoad(options) {
+    console.log('options', options);
+    const { vehicleNo, parkNo, isBack, polyOrderId, needPay } = options;
     if (vehicleNo && parkNo) {
       this.paramsObj.vehicleNo = vehicleNo;
       this.paramsObj.parkNo = parkNo;
       this.isBack = isBack ?? 0;
       this.polyOrderId = polyOrderId;
-      this.getOrderDetails(vehicleNo, parkNo);
+      this.needPay = needPay;
+      console.log('isBack', Number(this.isBack) !== 1);
+      if (needPay && needPay === 'not') {
+        this.$u.route({
+          url: '/pages/center/order/order',
+          type: 'redirectTo'
+        });
+      } else if (Number(this.isBack) !== 1) {
+        this.getOrderDetails(vehicleNo, parkNo);
+      }
+      this.jumpUrl = `${location.origin}/#/pages/OnsitePayment/OnsitePayment?vehicleNo=${vehicleNo}&parkNo=${parkNo}&isBack=1`;
     } else {
       this.$nextTick(() => {
         this.showToast('参数丢失!', 'error');
@@ -75,8 +87,9 @@ export default {
     }
   },
   onShow() {
-    const { isBack } = this;
-    if (Number(isBack) === 1 && this.polyOrderId) {
+    const { isBack, polyOrderId, needPay } = this;
+    console.log('this', this);
+    if (Number(isBack) === 1 && polyOrderId && needPay !== 'not') {
       uni.showLoading({
         title: '支付查询中...',
         mask: true
@@ -136,20 +149,21 @@ export default {
         if (code === 200) {
           if (data?.payStatus === 1 || data?.payStatus === 3) {
             clearInterval(this.timer);
-            this.getOrderDetails(this.paramsObj.vehicleNo, this.paramsObj.parkNo);
-            uni.hideLoading();
+            this.$refs.uToast.show({
+              title: '该订单已支付成功!',
+              type: 'success',
+              url: '/pages/common/paymentSuccess/paymentSuccess',
+              callback: () => {
+                uni.hideLoading();
+              }
+            });
           }
         }
       } catch (error) {
+        clearInterval(this.timer);
         uni.hideLoading();
       }
     },
-    // 返回首页
-    cancel() {
-      uni.switchTab({
-        url: '/pages/index/index'
-      });
-    },
     /**
      * @description: 显示提示信息
      * @param {*} title

+ 1 - 1
pages/center/index.vue

@@ -8,7 +8,7 @@
       back-icon-color="#CCE8FF"
       :background="{ background: '#008CFF' }"
       title="我的"
-    ></u-navbar>
+    />
 
     <!-- ===================================== 头像 ===================================== -->
     <view class="u-flex user-box u-p-l-30 u-p-r-20 u-p-b-30 u-p-t-30">

+ 11 - 8
pages/choosePayment/choosePayment.vue

@@ -13,7 +13,8 @@
       <view class="pay-content">
         <view class="pay-list">
           <radio-group @change="payRadioChange">
-            <view class="pay-list-item">
+            <!-- #ifdef H5 || MP-WEIXIN -->
+            <view class="pay-list-item" v-if="wxEnv">
               <view class="pay-list-item-image">
                 <image class="image" src="/static/img/wechat-icon-new.png" mode="aspectFit" />
                 <view>微信支付</view>
@@ -22,6 +23,7 @@
                 <radio color="#2DCF8C" value="weixin" :checked="'weixin' === radioCurrent" />
               </view>
             </view>
+            <!-- #endif -->
             <template v-if="alipayEnv">
               <view class="pay-list-item">
                 <view class="pay-list-item-image">
@@ -75,7 +77,7 @@
           >
         </view>
         <view class="pay-btn">
-          <u-button type="primary" shape="circle" :disabled="!radioCurrent" @click="immediatePayment">立即支付</u-button>
+          <u-button type="primary" shape="circle" :disabled="!radioCurrent" @tap="$u.debounce(immediatePayment, 1500, true)">立即支付</u-button>
         </view>
       </view>
     </u-modal>
@@ -258,10 +260,14 @@ export default {
      * @returns {any}
      */
     openPopup(details, numType = 'single', orderType = 'road') {
+      // 获取环境信息
       this.wxEnv = getEnvIsWx();
       this.alipayEnv = getEnvIsAlipay();
+      // 打开弹出层
       this.payWayPop = true;
+      // 计算订单金额
       this.orderMoney = details.payAmount.toFixed(2);
+      // 如果是单个停车订单,且是路边停车,且不是月卡支付,则显示优惠券
       if (numType === 'single' && orderType === 'parking' && !this.isMonthPay) {
         this.isShowCoupon = true;
         this.isCancelCoupon = true;
@@ -405,7 +411,6 @@ export default {
                     this.cancelCoupon(messageMap[r.code]);
                   } else {
                     this.showToast(messageMap[r.code], 'info');
-                    location.reload();
                   }
                   break;
                 case 2: // 支付失败
@@ -416,8 +421,7 @@ export default {
           } else {
             this.showToast('无需支付', 'info');
             setTimeout(() => {
-              uni.hideLoading();
-              location.reload();
+              this.jumpUrl ? (location.href = `${this.jumpUrl}`) : location.reload();
             }, 1000);
           }
         }
@@ -616,7 +620,7 @@ export default {
                 switch (Number(r.code)) {
                   case 0: // 成功
                     //#ifdef H5
-                    location.reload();
+                    this.jumpUrl ? (location.href = `${this.jumpUrl}&polyOrderId=${data.polyOrderId}`) : location.reload();
                     //#endif
                     break;
                   case 1: // 取消
@@ -624,7 +628,6 @@ export default {
                       this.cancelCoupon(messageMap[r.code]);
                     } else {
                       this.showToast(messageMap[r.code], 'info');
-                      location.reload();
                     }
                     break;
                   case 2: // 支付失败
@@ -644,7 +647,7 @@ export default {
         } else {
           this.showToast('无需支付', 'info');
           setTimeout(() => {
-            location.href = this.jumpUrl;
+            this.jumpUrl ? (location.href = `${this.jumpUrl}&polyOrderId=${data.polyOrderId}`) : location.reload();
           }, 1000);
         }
       }

+ 1 - 10
pages/handleMonthly/handleMonthly.vue

@@ -140,12 +140,7 @@ export default {
     if (page.roadNo) {
       this.monthlyRuleDetails();
     }
-    // if (page.parkNo) {
-    //   this.monthlyRuleDetails();
-    // }
-    const baseUrl = window.location.href.split('#')[0];
-    let jumpUrl = baseUrl + '#/pages/center/monthly/monthly?type=' + this.type;
-    this.jumpUrl = jumpUrl;
+    this.jumpUrl = location.origin + '/#/pages/center/monthly/monthly?type=' + this.type;
   },
   methods: {
     /**
@@ -336,10 +331,6 @@ export default {
           this.loading = false;
         })
         .catch((err) => {
-          this.$refs.uToast.show({
-            title: '程序错误!',
-            type: 'error'
-          });
           this.loading = false;
         });
     },

+ 0 - 2
pages/wechatLogin/wechatLogin.vue

@@ -15,14 +15,12 @@ export default {
     };
   },
   onLoad(page) {
-    console.log('page', page);
     let local = window.location.href;
     let locationLocaturl = window.location.search;
     // 微信返回的回调地址
     let backUrl = getUrlParams(local, 'backUrl');
     if (backUrl) {
       this.backUrl = decodeURIComponent(backUrl);
-      
     }
     console.log('backUrl', decodeURIComponent(backUrl));
     let loginType = getUrlParams(local, 'loginType');

+ 20 - 35
utils/wxPay.js

@@ -1,58 +1,43 @@
 const wx = require('weixin-js-sdk');
 export default {
   weixinPay(data, jumpUrl) {
-    return new Promise((r) => {
-      wx.config({
-        debug: false,
-        appId: data.appId,
-        timestamp: data.timeStamp,
-        nonceStr: data.nonceStr,
-        signature: data.paySign,
-        jsApiList: ['chooseWXPay']
-      });
+    wx.config({
+      debug: false,
+      appId: data.appId,
+      timestamp: data.timeStamp,
+      nonceStr: data.nonceStr,
+      signature: data.paySign,
+      jsApiList: ['chooseWXPay']
+    });
+    return new Promise((resolve, reject) => {
       wx.ready(() => {
         wx.chooseWXPay({
-          timestamp: data.timeStamp, //这个字段是为字符串后端返回时需检查
+          timestamp: data.timeStamp,
           nonceStr: data.nonceStr,
           package: data.packageValue,
           signType: data.signType,
           paySign: data.paySign,
           success(res) {
-            r({
-              code: 0,
-              msg: '成功'
-            });
+            resolve({ code: 0, msg: '成功' });
+            if (e.errMsg === 'chooseWXPay:ok' && jumpUrl) {
+              window.location.href = jumpUrl;
+            }
           },
           cancel() {
-            r({
-              code: 1,
-              msg: '取消'
-            });
+            resolve({ code: 1, msg: '取消' });
           },
           fail(err) {
-            r({
-              code: 2,
-              msg: err.errMsg.split(':')[1] || '支付失败!'
-            });
+            reject({ code: 2, msg: err.errMsg.split(':')[1] || '支付失败!' });
           },
-          // 无论失败成功都会执行
           complete(e) {
-            // e.errMsg三种状态 1.chooseWXPay:ok 支付成功 2: chooseWXPay:cancel 支付取消 3:chooseWXPay:fail 支付失败
-            if (e.errMsg === 'chooseWXPay:ok') {
-              if (jumpUrl) {
-                window.location.href = jumpUrl;
-              } else {
-                window.location.reload();
-              }
+            if (e.errMsg !== 'chooseWXPay:ok') {
+              reject({ code: 2, msg: '支付失败!' });
             }
           }
         });
       });
-      wx.error(function (err) {
-        r({
-          code: 2,
-          msg: '支付失败!'
-        });
+      wx.error((err) => {
+        reject({ code: 2, msg: '支付失败!' });
       });
     });
   }