فهرست منبع

fix(KIP-13985): 阻断 memberGrade、consume不存在时,优惠逻辑的执行

john 1 سال پیش
والد
کامیت
7196952a9e
3فایلهای تغییر یافته به همراه43 افزوده شده و 12 حذف شده
  1. 2 2
      src/api/request.js
  2. 30 7
      src/pages/parkingFee/mixins/parkingFeeDiscounts.js
  3. 11 3
      src/pages/parkingFeeV2/Discounts/index.js

+ 2 - 2
src/api/request.js

@@ -110,7 +110,7 @@ function XUser(config) {
     delete params.userId
     delete params.phoneNumber
   }
-  if (params.isLogin && (!params.vipCode || !params.userId) && config.url.indexOf('/parking-lots/') < -1 || !params.sourceId) {
+  if (params.isLogin && (!params.vipCode || !params.userId || params.userId == 'undefined') && config.url.indexOf('/parking-lots/') < -1 || !params.sourceId) {
     throw {
       response: {
         data: {
@@ -121,7 +121,7 @@ function XUser(config) {
   }
   // 如果 token 存在, 但是没有 vipCode 或者 userId
   const kipAccessToken =uni.getStorageSync('kipAccessToken')
-  if (kipAccessToken && (!params.vipCode || !params.userId) && config.url.indexOf('/parking-lots/') < -1) {
+  if (kipAccessToken && (!params.vipCode || !params.userId || params.userId == 'undefined') && config.url.indexOf('/parking-lots/') < -1) {
     throw {
       response: {
         data: {

+ 30 - 7
src/pages/parkingFee/mixins/parkingFeeDiscounts.js

@@ -233,7 +233,7 @@ export default {
       const { memberGrade = [{}], consume = [], memberLevelDiscount, points = [{}] } = this.orderDetail.discountInfo;
       const { maxConsumeTime, remainConsumeTime, hourPrice } = this.orderDetail.parkingRule;
       // 如果积分存在的话,则移除积分的优惠
-      if (JSON.stringify(points) !== {}) {
+      if (points.length && JSON.stringify(points[0]) !== "{}") {
         this.remainPrice = this.parkMallCode !== 1 ? this.usingTotalDiscount - points[0].discountFee : this.usingTotalDiscount;
       }
       this.memberGrade = { ...memberGrade[0] };
@@ -371,8 +371,17 @@ export default {
         return;
       }
     },
-    memberClick() {
-      // debugger
+    async memberClick() {
+      await waitByTime(200)
+      // 没有优惠时不做多余的事情
+      if(JSON.stringify(this.memberGrade) === '{}') {
+        return;
+      }
+      if(!this.actualPayFee) {
+        Toast('当前无需追加优惠')
+        this.checkedList = this.checkedList.filter(elm => elm !== 'member')
+        return;
+      }
       const { maxConsumeTime, remainConsumeTime, availableDiscountFee, hourPrice } = this.orderDetail.parkingRule;
       if (this.checkedList.indexOf('member') > -1) {
         /* 浦东 */
@@ -402,7 +411,7 @@ export default {
         }
         this.remainPrice = this.remainPrice - this.memberGrade.discountFee;
         // 如果不是沈阳,重新计算优惠
-        if (this.parkMallCode !== 4 && this.parkMallCode !== 6) {
+        if (this.parkMallCode !== 4 && this.parkMallCode !== 6 && JSON.stringify(this.consume) !== '{}') {
           this.maxReduceDiscount = remainConsumeTime;
         }
         // 如果不是沈阳,重新计算优惠
@@ -420,7 +429,21 @@ export default {
         }
       }
     },
-    reducesClick() {
+    async reducesClick() {
+    await waitByTime(200)
+      if(!this.actualPayFee) {
+        Toast('当前无需追加优惠')
+        this.checkedList = this.checkedList.filter(elm => elm !== 'reduces')
+        return;
+      }
+      // 没有优惠时不做多余的事情
+      if(JSON.stringify(this.consume) === '{}') {
+        return;
+      }
+      // 浦东
+      if((this.parkMallCode === 1 || this.parkMallCode === 0) && (this.isReduces || !this.maxReduceDiscount) ) {
+        return;
+      }
       const { maxOneTimeDiscountTime, hourPrice, oneTimeLimitation, maxConsumeTime, remainConsumeTime, oneDayLimitation, maxOneDayDiscountFee, availableDiscountFee } = this.orderDetail.parkingRule;
       const maxOneTimeDiscountFee = maxOneTimeDiscountTime * hourPrice;
       if (this.checkedList.indexOf('reduces') > -1) {
@@ -504,14 +527,14 @@ export default {
       // 如果初次进来操作的跟原来的不一样则重新计算优惠
       if (this.checkedList.length !== this.checkedTotal || true) {
         ['member', 'reduces'].forEach((key) => {
-          if (key === 'member') {
+          if (key === 'member' && JSON.stringify(this.memberGrade) !== '{}') {
             this.memberGrade = {
               ...this.memberGrade,
               selected: this.checkedList.indexOf(key) > -1,
             };
             orderDetail.discountInfo.memberGrade = [this.memberGrade];
           }
-          if (key === 'reduces') {
+          if (key === 'reduces' && JSON.stringify(this.consume) !== '{}') {
             this.consume = {
               ...this.consume,
               discountTime: this.reduceHours,

+ 11 - 3
src/pages/parkingFeeV2/Discounts/index.js

@@ -411,6 +411,10 @@ export default {
     },
     async memberClick() {
       await waitByTime(200)
+      // 没有优惠时不做多余的事情
+      if(JSON.stringify(this.memberGrade) === '{}') {
+        return;
+      }
       if(!this.actualPayFee) {
         Toast('当前无需追加优惠')
         this.checkedList = this.checkedList.filter(elm => elm !== 'member')
@@ -445,7 +449,7 @@ export default {
         }
         this.remainPrice = this.remainPrice - this.memberGrade.discountFee;
         // 如果不是沈阳,重新计算优惠
-        if (this.parkMallCode !== 4 && this.parkMallCode !== 6) {
+        if (this.parkMallCode !== 4 && this.parkMallCode !== 6 && JSON.stringify(this.consume) !== '{}') {
           this.maxReduceDiscount = remainConsumeTime;
         }
         // 如果不是沈阳,重新计算优惠
@@ -470,6 +474,10 @@ export default {
         this.checkedList = this.checkedList.filter(elm => elm !== 'reduces')
         return;
       }
+      // 没有优惠时不做多余的事情
+      if(JSON.stringify(this.consume) === '{}') {
+        return;
+      }
       // 浦东
       if((this.parkMallCode === 1 || this.parkMallCode === 0) && (this.isReduces || !this.maxReduceDiscount) ) {
         return;
@@ -574,14 +582,14 @@ export default {
       // 如果初次进来操作的跟原来的不一样则重新计算优惠
       if (this.checkedList.length !== this.checkedTotal || true) {
         ['member', 'reduces'].forEach((key) => {
-          if (key === 'member') {
+          if (key === 'member' && JSON.stringify(this.memberGrade) !== '{}') {
             this.memberGrade = {
               ...this.memberGrade,
               selected: this.checkedList.indexOf(key) > -1,
             };
             orderDetail.discountInfo.memberGrade = [this.memberGrade];
           }
-          if (key === 'reduces') {
+          if (key === 'reduces' && JSON.stringify(this.consume) !== '{}') {
             this.consume = {
               ...this.consume,
               discountTime: this.reduceHours,