ソースを参照

修改微信登录回调信息缺失和修改微信支付使用优惠券

zaijin 2 年 前
コミット
1dc4736dfe

+ 3 - 1
common/apiurl.js

@@ -132,7 +132,9 @@ const apiurl = {
   // 兑换优惠券
   exchangeCouponUrl: '/client/couponInfo/couponExchange',
 	// 根据订单号刷新优惠券状态(用于取消支付情况)
-	updateCouponStatusUrl: '/client/couponInfo/backCoupon'
+	updateCouponStatusUrl: '/client/couponInfo/backCoupon',
+  // 根据订单id获取符合要求的优惠券
+  getCouponByOrderIdUrl: '/client/couponInfo/memberCoupon'
 };
 
 export { apiurl };

+ 3 - 1
common/http.api.js

@@ -119,6 +119,7 @@ const install = (Vue, vm) => {
 	let couponListApi = (params = {}) => vm.$u.get(apiurl.couponListUrl, params);
   let exchangeCouponApi = (params = {}) => vm.$u.put(apiurl.exchangeCouponUrl, params);
 	let updateCouponStatusApi = (params = {}) => vm.$u.post(apiurl.updateCouponStatusUrl, params);
+  let getCouponByOrderIdApi = (params = {}) => vm.$u.get(apiurl.getCouponByOrderIdUrl, params);
   // 将各个定义的接口名称,统一放进对象挂载到vm.$u.api(因为vm就是this,也即this.$u.api)下
   vm.$u.api = {
     feedbackAdd,
@@ -183,7 +184,8 @@ const install = (Vue, vm) => {
 		monthlyRuleDetailsApi,
 		couponListApi,
     exchangeCouponApi,
-		updateCouponStatusApi
+		updateCouponStatusApi,
+    getCouponByOrderIdApi
   };
 };
 

+ 17 - 1
pages/center/order/orderDetails/orderDetails.vue

@@ -174,15 +174,24 @@
         </view>
       </view>
     </u-mask>
+    <!-- <ChoosePayment
+      ref="choosePayment"
+      :exportFlag="exportFlag"
+      :curOrderList="orderList"
+      :jumpUrl="jumpUrl"
+      @closePaymentMethod="closePaymentMethod"
+    /> -->
     <u-toast ref="uToast" />
   </view>
 </template>
 
 <script>
 import PaymentMethod from '@/pages/paymentMethod/paymentMethod.vue';
+import ChoosePayment from '@/pages/choosePayment/choosePayment.vue';
 export default {
   components: {
-    PaymentMethod
+    PaymentMethod,
+    ChoosePayment
   },
   data() {
     return {
@@ -311,6 +320,13 @@ export default {
       }
       if (this.orderList.length > 0) {
         this.payWayPop = true;
+        // this.$nextTick(() => {
+        //   this.$refs['choosePayment'].openPopup(
+        //     { id: this.orderId, totalAmount: this.orderInfo.totalAmount },
+        //     'single',
+        //     this.orderType === 'road' ? 'road' : 'parking'
+        //   );
+        // });
       } else {
         this.$refs.uToast.show({
           title: '当前订单编号不存在,请重新进入当前页面!',

+ 7 - 4
pages/center/phoneLogin/phoneLogin.vue

@@ -57,6 +57,13 @@
 					})
 				}
 			}
+			const pages = getCurrentPages();
+			if (pages.length >= 2) {
+				uni.setStorageSync('last_page', pages[pages.length - 2].route);
+				if (pages[pages.length - 2].options) {
+					uni.setStorageSync('last_page_options', pages[pages.length - 2].options);
+				}
+			}
 		},
 		computed: {
 			inputStyle() {
@@ -136,10 +143,6 @@
 					this.showToast();
 				});
 			},
-			// 微信登录
-			wechatLogin() {
-				this.jumpIndex()
-			},
 			// 微信已登录则跳转到首页
 			jumpIndex() {
 				let ret = localStorage.getItem('backUrl');

+ 81 - 0
pages/choosePayment/choosePayment.scss

@@ -22,4 +22,85 @@
       }
     }
   }
+  .pay-money {
+    text-align: center;
+    font-size: 34rpx;
+    color: #008CFF;
+    margin-top: 20rpx;
+  }
+  .pay-btn {
+    margin-top: 34rpx;
+  }
+}
+.coupon-popup {
+  position: relative;
+  min-height: 100vh;
+  overflow-y: auto;
+  background-color: #F9F9F9;
+  &-list {
+    padding: 30rpx;
+    &-item {
+      background-color: #fff;
+      border-radius: 17rpx;
+      margin-bottom: 20rpx;
+      &-top {
+        padding: 30rpx;
+        display: flex;
+        justify-content: space-between;
+        align-items: baseline;
+        border-bottom: 1px solid #EEEEEE;
+        &-left {
+          display: flex;
+          align-items: baseline;
+          .cplitl-left {
+            color: #FF6D6D;
+            font-size: 20rpx;
+            margin-right: 34rpx;
+            text:last-child {
+              font-size: 60rpx;
+              font-weight: bold;
+            }
+            &-bottom {
+              color: #333333;
+              font-size: 24rpx;
+            }
+          }
+          .cplitl-right {
+            view {
+              &:first-child {
+                font-size: 32rpx;
+                color: #333333;
+                font-weight: 700;
+                margin-bottom: 8rpx;
+              }
+              &:last-child {
+                font-size: 20rpx;
+                color: #666;
+              }
+            }
+          }
+        }
+      }
+      &-bottom {
+        color: #999999;
+        padding: 10rpx 30rpx;
+        font-size: 20rpx;
+        .cplib-point {
+          margin-top: 10rpx;
+          &-content {
+            padding-top: 10rpx;
+            font-size: 24rpx;
+            color: #999999;
+          }
+        }
+      }
+    }
+  }
+  &-btn {
+    width: 100%;
+    padding: 80rpx 30rpx;
+    position: absolute;
+    bottom: 0;
+    left: 0;
+  }
 }

+ 311 - 13
pages/choosePayment/choosePayment.vue

@@ -2,31 +2,35 @@
   <view>
     <u-modal
       v-model="payWayPop"
-      :title-style="{ color: '#404040' }"
+      :title-style="{ color: '#1E1E1E', fontSize: '34rpx' }"
       title="选择支付方式"
       width="550rpx"
       :show-confirm-button="false"
       :show-cancel-button="false"
+      :mask-close-able="true"
+      @input="modalClose"
     >
       <view class="pay-content">
         <view class="pay-list">
-          <radio-group>
-            <view class="pay-list-item">
+          <radio-group @change="payRadioChange">
+            <!-- #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>
               </view>
               <view class="radioBox">
-                <radio color="#2DCF8C" value="1" :checked="1 === radioCurrent" />
+                <radio color="#2DCF8C" value="weixin" :checked="'weixin' === radioCurrent" />
               </view>
             </view>
+            <!-- #endif -->
             <view class="pay-list-item">
               <view class="pay-list-item-image">
                 <image class="image" src="/static/img/gy-icon-new.png" mode="aspectFit" />
                 <view>贵州银行</view>
               </view>
               <view class="radioBox">
-                <radio color="#2DCF8C" value="2" :checked="2 === radioCurrent" />
+                <radio color="#2DCF8C" value="gzyh" :checked="'gzyh' === radioCurrent" />
               </view>
             </view>
             <view class="pay-list-item">
@@ -35,13 +39,88 @@
                 <view>聚合支付</view>
               </view>
               <view class="radioBox">
-                <radio color="#2DCF8C" value="3" :checked="3 === radioCurrent" />
+                <radio color="#2DCF8C" value="juhe" :checked="'juhe' === radioCurrent" />
               </view>
             </view>
           </radio-group>
         </view>
+        <view class="pay-coupon" v-if="radioCurrent === 'weixin' && isShowCoupon">
+          <u-cell-group :border="false">
+            <u-cell-item icon="" title="优惠券" :value="couponName || '暂无优惠券'" :border-bottom="false" @click="chooseCoupon"></u-cell-item>
+          </u-cell-group>
+        </view>
+        <view class="pay-money"> 金额¥{{ orderMoney }} </view>
+        <view class="pay-btn">
+          <u-button type="primary" shape="circle" @click="immediatePayment">立即支付</u-button>
+        </view>
       </view>
     </u-modal>
+    <!-- 选择优惠券弹框 -->
+    <u-popup v-model="couponPopup.show" mode="top" length="100%">
+      <view class="coupon-popup">
+        <u-navbar
+          back-text=""
+          title="我的优惠券"
+          :background="couponPopup.background"
+          title-color="#fff"
+          back-icon-color="#fff"
+          :custom-back="customBack"
+        />
+        <view class="coupon-popup-list">
+          <template v-if="couponPopup.couponList.length">
+            <radio-group @change="couponRadioChange">
+              <view class="coupon-popup-list-item" v-for="(item, index) in couponPopup.couponList" :key="index">
+                <view class="coupon-popup-list-item-top">
+                  <view class="coupon-popup-list-item-top-left">
+                    <view class="cplitl-left">
+                      <view>
+                        <text>¥</text>
+                        <text>{{ item.couponContent }}</text>
+                      </view>
+                      <view class="cplitl-left-bottom">{{ Number(item.threshold) > 0 ? `停车时长满${item.threshold}分钟` : '无门槛' }}</view>
+                    </view>
+                    <view class="cplitl-right">
+                      <view>{{ item.couponName }}</view>
+                      <view>有限期:剩余{{ calcValidity(item.startTime, item.endTime) }}</view>
+                    </view>
+                  </view>
+                  <view class="coupon-popup-list-item-top-right">
+                    <radio color="#FF6D6D" :value="item.id" :checked="item.id === couponPopup.radioCurrent" />
+                  </view>
+                </view>
+                <view class="coupon-popup-list-item-bottom">
+                  适用停车点:
+                  <template v-if="item.parkList">
+                    <template v-if="item.parkList.length > 1"> 适用多个停车点 </template>
+                    <template v-else> 仅限{{ item.parkList.map((item) => item.parkName).join('、') }} </template>
+                    <template v-if="item.parkList && item.parkList.length > 1">
+                      <view class="cplib-point">
+                        <u-read-more
+                          text-indent="0"
+                          show-height="0"
+                          :toggle="true"
+                          :shadow-style="{ backgroundImage: 'none' }"
+                          fontSize="20rpx"
+                          close-text="展开所有停车点"
+                        >
+                          <view class="cplib-point-content">{{ item.parkList.map((item) => item.parkName).join('、') }}</view>
+                        </u-read-more>
+                      </view>
+                    </template>
+                  </template>
+                </view>
+              </view>
+            </radio-group>
+          </template>
+          <template v-else>
+            <u-empty text="没有适合的优惠券" mode="coupon" margin-top="300"></u-empty>
+          </template>
+        </view>
+        <view class="coupon-popup-btn">
+          <u-button type="primary" shape="circle" :disabled="!couponPopup.radioCurrent" @click="confimCoupon">确 定</u-button>
+        </view>
+      </view>
+    </u-popup>
     <u-toast ref="uToast" />
   </view>
 </template>
@@ -51,11 +130,6 @@ import { getEnvIsWx } from '@/utils/judgEnvironment.js';
 import $wxPay from '@/utils/wxPay.js';
 export default {
   props: {
-    // 弹框显示
-    payWayPop: {
-      type: Boolean,
-      default: true
-    },
     // 订单数组
     curOrderList: {
       type: Array,
@@ -104,14 +178,155 @@ export default {
   },
   data() {
     return {
+      payWayPop: false,
       wxEnv: true,
-      radioCurrent: 1
+      radioCurrent: '',
+      couponName: '',
+      orderMoney: '',
+      isShowCoupon: false,
+      couponPopup: {
+        show: false,
+        couponList: [
+          {
+            id: '770098293625933824',
+            createTime: '2023-01-03 11:42:31',
+            updateTime: '2023-01-02 21:57:18',
+            merchantName: '',
+            couponId: '770098213246291968',
+            couponName: '路段10元券',
+            exchangeId: '770098224449277952',
+            exchangeCode: 'h3zi1nek',
+            memberId: '550854924816437248',
+            memberName: '15085256944',
+            startTime: '2023-01-02 11:42:31',
+            endTime: '2023-04-13 11:42:31',
+            vehicleNo: '贵A22223',
+            status: 0,
+            source: 1,
+            threshold: 0.0,
+            couponContent: 10.0,
+            parkList: [
+              {
+                id: '770098213267263488',
+                createBy: 'admin',
+                createTime: '2023-01-03 11:42:12',
+                delFlag: 0,
+                couponId: '770098213246291968',
+                couponName: '路段10元券',
+                parkType: 1,
+                parkId: '1395602533837180929',
+                parkName: '本杰路',
+                parkNo: 'RN000000038'
+              },
+              {
+                id: '770098213279846400',
+                createBy: 'admin',
+                createTime: '2023-01-03 11:42:12',
+                delFlag: 0,
+                couponId: '770098213246291968',
+                couponName: '路段10元券',
+                parkType: 1,
+                parkId: '1395602161655615489',
+                parkName: '党固路',
+                parkNo: 'RN000000031'
+              }
+            ]
+          },
+          {
+            id: '770097376860131328',
+            createTime: '2023-01-03 11:38:53',
+            updateTime: '2023-02-17 09:57:38',
+            merchantName: '',
+            couponId: '770097278759555072',
+            couponName: '优惠券10元',
+            exchangeId: '770097291925475328',
+            exchangeCode: 'TTqBGghf',
+            memberId: '550854924816437248',
+            memberName: '15085256944',
+            startTime: '2023-01-02 11:38:53',
+            endTime: '2023-04-13 11:38:53',
+            vehicleNo: '贵A22223',
+            status: 0,
+            source: 1,
+            threshold: 0.0,
+            couponContent: 10.0,
+            parkList: [
+              {
+                id: '770097278818275328',
+                createBy: 'admin',
+                createTime: '2023-01-03 11:38:29',
+                delFlag: 0,
+                couponId: '770097278759555072',
+                couponName: '优惠券10元',
+                parkType: 0,
+                parkId: '657028028294320128',
+                parkName: '工信局停车场',
+                parkNo: 'ecd4650febc94ad4a2e8fcedfbec266a'
+              }
+            ]
+          }
+        ],
+        radioCurrent: '',
+        background: {
+          backgroundColor: '#008CFF'
+        },
+        currentCoupon: {}
+      }
     };
   },
   created() {
     this.wxEnv = getEnvIsWx();
   },
   methods: {
+    /**
+     * 打开弹框触发
+     * @date 2023-02-17
+     * @param {any} details
+     * @param {any} numType   single 单笔订单  multiple 多比订单  用于区分多笔订单不能使用优惠券
+     * @param {any} orderType   road 路段订单  parking 停车场订单  用于区分路段订单不使用优惠券
+     * @returns {any}
+     */
+    openPopup(details, numType = 'single', orderType = 'road') {
+      this.payWayPop = true;
+      this.orderMoney = details.totalAmount.toFixed(2);
+      if (numType === 'single' && orderType === 'parking') {
+        this.isShowCoupon = true;
+        this.getCouponList(details.id);
+      }
+    },
+    /**
+     * 描述
+     * @date 2023-02-17
+     * @param {any} orderId
+     * @returns {any}
+     */
+    getCouponList(orderId) {
+      this.$u.api.getCouponByOrderIdApi({ orderId }).then((res) => {
+        this.couponPopup.couponList = res?.data ?? [];
+        if (this.couponPopup.couponList.length) {
+          this.couponPopup.currentCoupon = this.couponPopup.couponList[0];
+          this.couponPopup.radioCurrent = this.couponPopup.couponList[0].id;
+          this.couponName = this.couponPopup.couponList[0].couponName;
+        }
+      });
+    },
+    /**
+     * 选中支付类型
+     * @date 2023-02-17
+     * @param {any} {detail}
+     * @returns {any}
+     */
+    payRadioChange({ detail }) {
+      this.radioCurrent = detail.value;
+    },
+    /**
+     * 选中优惠券
+     * @date 2023-02-17
+     * @returns {any}
+     */
+    chooseCoupon() {
+      this.couponPopup.show = true;
+    },
     /**
      * 贵阳银行支付
      * @param {Array} orderList 需要支付的订单号组成的数组
@@ -355,6 +570,89 @@ export default {
      * */
     closePaymentMethod() {
       this.$emit('closePaymentMethod');
+    },
+    /**
+     * 支付弹框支付触发
+     * @date 2023-02-17
+     * @returns {any}
+     */
+    modalClose() {
+      this.wxEnv = true,
+      this.radioCurrent = 'weixin',
+      this.couponName = '',
+      this.orderMoney = '',
+      this.isShowCoupon = false,
+      this.couponPopup = {
+        show: false,
+        couponList: [],
+        radioCurrent: '',
+        background: {
+          backgroundColor: '#008CFF'
+        },
+        currentCoupon: {}
+      }
+    },
+    /**
+     * 关闭优惠券弹框
+     * @date 2023-02-17
+     * @returns {any}
+     */
+    customBack() {
+      this.couponPopup.show = false;
+    },
+    /**
+     * 优惠券单选触发
+     * @date 2023-02-17
+     * @param {any} val
+     * @returns {any}
+     */
+    couponRadioChange(val) {
+      this.couponPopup.radioCurrent = val.detail.value;
+    },
+    /**
+     * 优惠券确认
+     * @date 2023-02-17
+     * @returns {any}
+     */
+    confimCoupon() {
+      this.couponPopup.currentCoupon = this.couponPopup.couponList.find((item) => item.id === this.couponPopup.radioCurrent);
+      this.couponName = this.couponPopup.currentCoupon.couponName;
+      this.couponPopup.show = false;
+    },
+    /**
+     * 立即支付
+     * @date 2023-02-17
+     * @returns {any}
+     */
+    immediatePayment() {
+      switch (this.radioCurrent) {
+        case 'weixin': // 微信支付
+          this.wechatPay();
+          break;
+        case 'gzyh':
+          this.gyBankPay();
+          break;
+        case 'juhe':
+          this.juhePay();
+          break;
+      }
+    },
+    /**
+     * 计算剩余时间
+     * @date 2022-02-17
+     * @param {any} datetime
+     * @returns {any}
+     */
+    calcValidity(startTime, endTime) {
+      let endTimeStr = new Date(endTime).valueOf(),
+        nowTimeStr = new Date(startTime).valueOf() < Date.now() ? Date.now() : new Date(startTime).valueOf(),
+        remainTimeStr = endTimeStr - nowTimeStr,
+        day = Math.floor(remainTimeStr / (1000 * 3600 * 24)),
+        dayOver = remainTimeStr % (1000 * 3600 * 24),
+        hours = Math.floor(dayOver / (3600 * 1000)),
+        hourOver = dayOver % (3600 * 1000),
+        minutes = Math.floor(hourOver / (60 * 1000));
+      return `${day}天${hours}小时${minutes}分`;
     }
   }
 };
@@ -362,4 +660,4 @@ export default {
 
 <style lang="scss" scoped>
 @import './choosePayment.scss';
-</style>
+</style>

+ 27 - 15
pages/index/index.vue

@@ -394,10 +394,10 @@ export default {
         this.jumpMsgModal = false;
       }, 3000);
     }
+		this.getLocation();
   },
   onShow() {
     this.handleGetIndexData();
-    this.getLocation();
     const locationLocaturl = window.location.search;
     this.code = getUrlParams(locationLocaturl, 'code');
     if (this.code && !this.$store.state.vuex_wxinfo.openId) {
@@ -513,20 +513,32 @@ export default {
           },
           function (err) {
             // 错误处理
-            switch (err.code) {
-              case 1:
-                alert('位置服务被拒绝。');
-                break;
-              case 2:
-                alert('暂时获取不到位置信息。');
-                break;
-              case 3:
-                alert('获取信息超时。');
-                break;
-              default:
-                alert('未知错误。');
-                break;
-            }
+            // switch (err.code) {
+            //   case 1:
+            //     alert('位置服务被拒绝。');
+            //     break;
+            //   case 2:
+            //     alert('暂时获取不到位置信息。');
+            //     break;
+            //   case 3:
+            //     alert('获取信息超时。');
+            //     break;
+            //   default:
+            //     alert('未知错误。');
+            //     break;
+            // }
+						uni.getLocation({
+							type: 'gcj02',
+							success: function (res) {
+								that.latLongItude = {
+								  latitude: res.latitude,
+								  longitude: res.longitude
+								};
+								that.latitude = res.latitude;
+								that.longitude = res.longitude;
+								that.getCityNameByLonLat(that.latLongItude);
+							}
+						});
           }
         );
       } else {

+ 26 - 7
pages/payLists/payLists.vue

@@ -37,7 +37,9 @@
                       <view class="pay-center-item" v-if="payItem.orderStatus == 1 && payItem.outTime"> 结束计费:{{ `未出场` }}</view>
                       <view class="pay-center-item" v-if="payItem.orderStatus !== 1"> 结束计费:{{ payItem.outTime || 0 }}</view>
                     </template>
-                    <view class="pay-center-item" v-if="payItem.orderStatus !== 1"> 免费时长:{{ payItem.freeDuration || `0天0时${free_time}分0秒` }} </view>
+                    <view class="pay-center-item" v-if="payItem.orderStatus !== 1">
+                      免费时长:{{ payItem.freeDuration || `0天0时${free_time}分0秒` }}
+                    </view>
                     <!-- 计费时长=停车时长-免费时长 -->
                     <view class="pay-center-item" v-if="payItem.orderStatus !== 1"> 计费时长:{{ payItem.calcDuration || 0 }} </view>
                     <view class="pay-center-item" v-if="payItem.orderStatus !== 1"> 累计停车时长:{{ payItem.duration || 0 }} </view>
@@ -57,7 +59,7 @@
                     <view class="pay-center-item" v-if="payItem.deviceType && payItem.deviceType != 1"> 车位锁设备号:{{ payItem.deviceNo }} </view>
                   </view>
                   <view class="pay-bottom">
-                    <u-cell-item title="去支付" @click="choosePayWay(payItem.orderId)" style="color: #008cff"> </u-cell-item>
+                    <u-cell-item title="去支付" @click="choosePayWay(payItem.orderId, payItem)" style="color: #008cff"> </u-cell-item>
                   </view>
                 </view>
                 <view v-if="item.index == 1">
@@ -74,7 +76,9 @@
                     <view class="pay-center-item">入场时间:{{ payItem.inTime || 0 }}</view>
                     <view class="pay-center-item">出场通道:{{ payItem.outEntranceName }}</view>
                     <view class="pay-center-item" v-if="payItem.orderStatus !== 1"> 出场时间:{{ payItem.outTime || 0 }} </view>
-                    <view class="pay-center-item" v-if="payItem.orderStatus !== 1"> 免费时长:{{ payItem.freeDuration || `0天0时${free_time}分0秒` }} </view>
+                    <view class="pay-center-item" v-if="payItem.orderStatus !== 1">
+                      免费时长:{{ payItem.freeDuration || `0天0时${free_time}分0秒` }}
+                    </view>
                     <!-- 计费时长=停车时长-免费时长 -->
                     <view class="pay-center-item" v-if="payItem.orderStatus !== 1"> 计费时长:{{ payItem.calcDuration || 0 }} </view>
                     <view class="pay-center-item" v-if="payItem.orderStatus !== 1"> 累计停车时长:{{ payItem.duration || 0 }} </view>
@@ -84,7 +88,7 @@
                     <view class="pay-center-item" v-if="payItem.deviceType && payItem.deviceType != 1"> 车位锁设备号:{{ payItem.deviceNo }} </view>
                   </view>
                   <view class="pay-bottom">
-                    <u-cell-item title="去支付" @click="choosePayWay(payItem.orderId)" style="color: #008cff"> </u-cell-item>
+                    <u-cell-item title="去支付" @click="choosePayWay(payItem.orderId, payItem)" style="color: #008cff"> </u-cell-item>
                   </view>
                 </view>
               </view>
@@ -135,15 +139,24 @@
       :jumpUrl="jumpUrl"
       @closePaymentMethod="closePaymentMethod"
     ></PaymentMethod>
+    <!-- <ChoosePayment
+      ref="choosePayment"
+      :exportFlag="exportFlag"
+      :curOrderList="currentItem"
+      :jumpUrl="jumpUrl"
+      @closePaymentMethod="closePaymentMethod"
+    /> -->
     <u-toast ref="uToast" />
   </view>
 </template>
 
 <script>
 import PaymentMethod from '@/pages/paymentMethod/paymentMethod.vue';
+import ChoosePayment from '@/pages/choosePayment/choosePayment.vue';
 export default {
   components: {
-    PaymentMethod
+    PaymentMethod,
+    ChoosePayment
   },
   data() {
     return {
@@ -329,10 +342,13 @@ export default {
         });
     },
     // 去支付,选择支付方式
-    choosePayWay(item) {
+    choosePayWay(orderId, item) {
       this.currentItem = [];
-      this.currentItem.push(item);
+      this.currentItem.push(orderId);
       this.payWayPop = true;
+      // this.$nextTick(() => {
+      //   this.$refs['choosePayment'].openPopup(item, 'single', this.current === 0 ? 'road' : 'parking');
+      // });
     },
     // 全部缴费确认
     confirmPrice() {
@@ -360,6 +376,9 @@ export default {
     // 缴费提示弹框确认
     payTipsPopConfirm() {
       this.payWayPop = true;
+      // this.$nextTick(() => {
+      //   this.$refs['choosePayment'].openPopup({ totalAmount: Number(this.payTipsItem.price) }, 'multiple', this.current === 0 ? 'road' : 'parking');
+      // });
     },
     handleGetOrderinfo(orderId) {
       this.$u.api

+ 115 - 117
pages/wechatLogin/wechatLogin.vue

@@ -1,123 +1,121 @@
 <template>
-  <view>
-    <u-toast ref="uToast" />
-  </view>
+	<view>
+		<u-toast ref="uToast" />
+	</view>
 </template>
 
 <script>
-import getUrlParams from '@/utils/getUrlParams.js';
-export default {
-  data() {
-    return {
-      backUrl: '',
-      code: ''
-    };
-  },
-  onLoad(page) {
-    console.log('page:', page);
-    const locationLocaturl = location.search;
-    // 微信返回的回调地址
-    const backUrl = page?.backUrl;
-    if (backUrl) {
-      this.backUrl = backUrl;
-    }
-    console.log('backUrl', backUrl);
-    let code = getUrlParams(locationLocaturl, 'code');
-    console.log('code', code);
-    if (code) {
-      this.code = code;
-      // 判断重复回调问题
-      let wechatLoginKey = localStorage.getItem('wechatLoginKey');
-      if (wechatLoginKey) {
-        wechatLoginKey = JSON.parse(wechatLoginKey);
-        if (code === wechatLoginKey.code) {
-          this.getToken(wechatLoginKey.openId);
-        } else {
-          this.handleGetWXInfo(this.code);
-        }
-      } else {
-        this.handleGetWXInfo(this.code);
-      }
-    } else {
-      const local = location.href;
-      location.href = `https://open.weixin.qq.com/connect/oauth2/authorize?
-				appid=${this.config.wxAppid}&
-				redirect_uri=${encodeURIComponent(local)}&
-				response_type=code&
-				scope=snsapi_userinfo&
-				state=STATE#wechat_redirect`;
-    }
-  },
-  methods: {
-    // 通过code获取 openId等用户信息
-    handleGetWXInfo(code) {
-      uni.showLoading({
-        title: '加载中'
-      });
-      this.$u.api
-        .getWXInfo(code)
-        .then((res) => {
-          if (res.code === 200) {
-            this.$u.vuex('vuex_wxinfo', res.data);
-            localStorage.setItem(
-              'wechatLoginKey',
-              JSON.stringify({
-                code,
-                openId: res.data.openId
-              })
-            );
-            this.getToken(res.data.openId);
-          } else {
-            this.$refs.uToast.show({
-              title: res.msg || '获取用户信息失败!',
-              type: 'error'
-            });
-            uni.hideLoading();
-          }
-        })
-        .catch((err) => {
-          uni.hideLoading();
-        });
-    },
-    /**
-     * 通过openId获取token
-     * @param {Object} openId
-     */
-    getToken(openId) {
-      this.$u.api.codeV2Api
-        .sendSmsCodeV2api({
-          openId
-        })
-        .then((res) => {
-          if (res.code === 200) {
-            this.$u.vuex('vuex_token', res.data.accessToken);
-            this.$u.vuex('vuex_hasLogin', true);
-            if (res.data.needVerify) {
-              localStorage.setItem('backUrl', this.backUrl);
-              this.$u.route({
-                url: 'pages/center/phoneLogin/phoneLogin',
-								type: 'reLaunch'
-              });
-            } else {
-              this.$u.vuex('vuex_user', res.data);
-              if (this.backUrl.indexOf('wechatLogin') > -1) {
-                location.href = '/';
-              } else {
-                location.href = this.backUrl;
-              }
-            }
-            uni.hideLoading();
-          } else {
-            this.$refs.uToast.show({
-              title: res.msg || '获取用户信息失败!',
-              type: 'error'
-            });
-            uni.hideLoading();
-          }
-        });
-    }
-  }
-};
+	import getUrlParams from '@/utils/getUrlParams.js';
+	export default {
+		data() {
+			return {
+				backUrl: '',
+				code: ''
+			};
+		},
+		onLoad(page) {
+			let local = window.location.href;
+			let locationLocaturl = window.location.search;
+			// 微信返回的回调地址
+			let backUrl = local.split('backUrl=')[1];
+			if (backUrl) {
+				this.backUrl = decodeURIComponent(backUrl);
+			}
+			console.log('backUrl', decodeURIComponent(backUrl));
+			let code = getUrlParams(locationLocaturl, 'code');
+			console.log('code', code);
+			if (code) {
+				this.code = code;
+				// 判断重复回调问题
+				let wechatLoginKey = localStorage.getItem('wechatLoginKey');
+				if (wechatLoginKey) {
+					wechatLoginKey = JSON.parse(wechatLoginKey);
+					if (code === wechatLoginKey.code) {
+						this.getToken(wechatLoginKey.openId);
+					} else {
+						this.handleGetWXInfo(this.code);
+					}
+				} else {
+					this.handleGetWXInfo(this.code);
+				}
+			} else {
+				location.href = `https://open.weixin.qq.com/connect/oauth2/authorize?
+					appid=${this.config.wxAppid}&
+					redirect_uri=${encodeURIComponent(local)}&
+					response_type=code&
+					scope=snsapi_userinfo&
+					state=STATE#wechat_redirect`;
+			}
+		},
+		methods: {
+			// 通过code获取 openId等用户信息
+			handleGetWXInfo(code) {
+				uni.showLoading({
+					title: '加载中'
+				});
+				this.$u.api
+					.getWXInfo(code)
+					.then((res) => {
+						if (res.code === 200) {
+							this.$u.vuex('vuex_wxinfo', res.data);
+							localStorage.setItem(
+								'wechatLoginKey',
+								JSON.stringify({
+									code,
+									openId: res.data.openId
+								})
+							);
+							this.getToken(res.data.openId);
+						} else {
+							this.$refs.uToast.show({
+								title: res.msg || '获取用户信息失败!',
+								type: 'error'
+							});
+							uni.hideLoading();
+						}
+					})
+					.catch((err) => {
+						uni.hideLoading();
+					});
+			},
+			/**
+			 * 通过openId获取token
+			 * @param {Object} openId
+			 */
+			getToken(openId) {
+				this.$u.api.codeV2Api
+					.sendSmsCodeV2api({
+						openId
+					})
+					.then((res) => {
+						if (res.code === 200) {
+							this.$u.vuex('vuex_token', res.data.accessToken);
+							this.$u.vuex('vuex_hasLogin', true);
+							if (res.data.needVerify) {
+								localStorage.setItem('backUrl', this.backUrl);
+								this.$u.route({
+									url: 'pages/center/phoneLogin/phoneLogin',
+									type: 'reLaunch'
+								});
+							} else {
+								this.$u.vuex('vuex_user', res.data);
+								if (this.backUrl.indexOf('wechatLogin') > -1) {
+									location.href = '/';
+								} else {
+									location.href = this.backUrl;
+								}
+							}
+							uni.hideLoading();
+						} else {
+							this.$refs.uToast.show({
+								title: res.msg || '获取用户信息失败!',
+								type: 'error'
+							});
+							uni.hideLoading();
+						}
+					});
+			}
+		}
+	};
 </script>
 
-<style></style>