Selaa lähdekoodia

Merge pull request #117 from John-Hong/release-2.8.0

feat(SCRM-3602): 功能优化 | 临时停车优惠券选择未生效券展示和提示
Tron 2 vuotta sitten
vanhempi
sitoutus
0f2243a4ff

+ 58 - 0
src/api/mockData/checkout.pd7.response.json

@@ -0,0 +1,58 @@
+{
+  "parkingRecord": {
+    "vehicleNo": "沪K10003",
+    "enterTime": "2023-04-27 12:59:00",
+    "serviceMin": 18910,
+    "totalFee": 12500,
+    "actualPayFee": 0.0,
+    "thirdParkOrderNo": "4970706",
+    "createdByQrCode": false,
+    "totalFeeInYuan": 125.00
+  },
+  "discountInfo": {
+    "usingTotalDiscount": 125,
+    "memberLevelDiscount": false,
+    "points": [
+      {
+        "available": 459,
+        "maxDiscountFee": 20,
+        "pointsPerUnit": 50,
+        "unitAmount": 5,
+        "newMember": false,
+        "label": "已选择兑换21小时",
+        "discountFee": 105,
+        "unlimitUsePoints": "LIMIT"
+      }
+    ],
+    "coupons": [
+      {
+        "code": "w8duiwr20be_t",
+        "couponId": "67a5071cfff34264925b96c578c76184",
+        "name": "首2小时免费停车优惠券",
+        "expirationDate": "2023-05-31 23:59:59",
+        "discountFee": 20,
+        "defaultSelected": true,
+        "superposition": "1",
+        "limitCountPerOrder": 1
+      }
+    ]
+  },
+  "parkingRule": {
+    "maxOneTimeDiscountTime": 0,
+    "enableNewMemberPoints": false,
+    "enablePoints": true,
+    "enableCoupon": true,
+    "enablePaperCoupons": false,
+    "enableConsume": false,
+    "enableConsumeSplit": false,
+    "hourPrice": 5,
+    "oneDayLimitation": false,
+    "oneTimeLimitation": true
+  },
+  "parkInfo": {
+    "parkName": "浦东嘉里停车场",
+    "description": "深圳停车场最新描述涨价到10块一小时",
+    "parkMallCode": 1,
+    "buildingId": "PKC-P1"
+  }
+}

+ 51 - 1
src/api/mockData/checkout.qh10.response.json

@@ -31,9 +31,59 @@
         "name": "首2小时免费停车优惠券",
         "expirationDate": "2023-05-31 23:59:59",
         "discountFee": 20,
+        "defaultSelected": false,
+        "superposition": "1",
+        "status": "unavailable",
+        "availableDays": "...",
+        "limitCountPerOrder": 1
+      },
+      {
+        "code": "e903c24ggng_t2",
+        "couponId": "67a5071cfff34264925b96c578c76184",
+        "name": "首2小时免费停车优惠券",
+        "expirationDate": "2023-05-31 23:59:59",
+        "discountFee": 20,
         "defaultSelected": true,
         "superposition": "1",
+        "status": "available",
+        "availableDays": "...",
         "limitCountPerOrder": 1
+      },
+      {
+        "code": "r43iz9fgt5i_t3",
+        "couponId": "1",
+        "name": "5元停车券(周末及法定节假日)",
+        "expirationDate": "2023-05-31 23:59:59",
+        "discountFee": 5,
+        "defaultSelected": false,
+        "superposition": "2",
+        "status": "available",
+        "availableDays": "...",
+        "limitCountPerOrder": 2
+      },
+      {
+        "code": "r43iz9fgt5i_t4",
+        "couponId": "1",
+        "name": "5元停车券(周末及法定节假日)",
+        "expirationDate": "2023-05-31 23:59:59",
+        "discountFee": 5,
+        "defaultSelected": false,
+        "superposition": "2",
+        "status": "available",
+        "availableDays": "...",
+        "limitCountPerOrder": 2
+      },
+      {
+        "code": "r43iz9fgt5i_t4",
+        "couponId": "1",
+        "name": "5元停车券(周末及法定节假日)",
+        "expirationDate": "2023-05-31 23:59:59",
+        "discountFee": 5,
+        "defaultSelected": false,
+        "superposition": "2",
+        "status": "available",
+        "availableDays": "...",
+        "limitCountPerOrder": 2
       }
     ]
   },
@@ -46,7 +96,7 @@
     "maxPointsTime": 10,
     "enableConsume": false,
     "enableConsumeSplit": false,
-    "availableDiscountFee": 20,
+    "availableDiscountFee": 60,
     "hourPrice": 5
   },
   "parkInfo": {

+ 60 - 0
src/api/mockData/checkout.qh11.response.json

@@ -0,0 +1,60 @@
+{
+  "parkingRecord": {
+    "vehicleNo": "云A22223",
+    "enterTime": "2021-12-02 14:45:11",
+    "serviceMin": 756091,
+    "totalFee": 946000,
+    "actualPayFee": 9440,
+    "thirdPartyId": "fBQ8mW9RJQ4vCJ9ck2hUI",
+    "thirdParkOrderNo": "B7uMkA5gJPW6SGycz1AQz7",
+    "createdByQrCode": false,
+    "totalFeeInYuan": 9460
+  },
+  "discountInfo": {
+    "usingTotalDiscount": 20,
+    "memberLevelDiscount": false,
+    "points": [
+      {
+        "available": 509,
+        "maxDiscountFee": 20,
+        "pointsPerUnit": 50,
+        "unitAmount": 5,
+        "totalAvailable": 509,
+        "newMember": false,
+        "label": "509积分可减免"
+      }
+    ],
+    "coupons": [
+      {
+        "code": "e903c24ggng_t",
+        "couponId": "67a5071cfff34264925b96c578c76184",
+        "name": "首2小时免费停车优惠券",
+        "expirationDate": "2023-05-31 23:59:59",
+        "discountFee": 20,
+        "defaultSelected": true,
+        "status": "available", 
+        "availableDays": "...",
+        "superposition": "1",
+        "limitCountPerOrder": 1
+      }
+    ]
+  },
+  "parkingRule": {
+    "maxOneDayDiscountFee": 60,
+    "enableNewMemberPoints": false,
+    "enablePoints": true,
+    "enableCoupon": true,
+    "enablePaperCoupons": false,
+    "maxPointsTime": 10,
+    "enableConsume": false,
+    "enableConsumeSplit": false,
+    "availableDiscountFee": 20,
+    "hourPrice": 5
+  },
+  "parkInfo": {
+    "parkName": "深圳前海湾停车场",
+    "description": "基础计费规则:\n15分钟内免费,首小时15元,其后每小时5元,全天封顶60元。\n嘉湾汇会员停车礼遇:\n银卡:每月可免费领取2张首2小时停车券\n金卡:每月可免费领取5张首2小时停车券\n铂金卡:每月可免费领取10张首2小时停车券\n*数量有限,领完即止\n仅限开具一个月内的停车费电子发票 ",
+    "parkMallCode": 5,
+    "buildingId": "QHKC-P1"
+  }
+}

+ 1 - 1
src/api/request.js

@@ -188,7 +188,7 @@ export const createAxiosByinterceptors = (config) => {
       }
       // 错误信息提示
       const { code, langMessage, message,status } = error.response.data;
-      const codeList = ['INTERNAL_SERVER_ERROR', 'VALIDATION_FAILED', 'CAR_HAS_PLATE', "NOT_FOUND", "LOCAL_PARK_ERROR", "LOCK_OCCUPIED", "REMOTE_CALL_FAIL", 'PLEASE_SCAN_QRCODE', 'SUBIN_CAR_IN_DEVICE_EXCEPTION']; // 默认处理的错误code
+      const codeList = ['INTERNAL_SERVER_ERROR', 'VALIDATION_FAILED', 'CAR_HAS_PLATE', "NOT_FOUND", "LOCAL_PARK_ERROR", "LOCK_OCCUPIED", "REMOTE_CALL_FAIL", 'PLEASE_SCAN_QRCODE', 'SUBIN_CAR_IN_DEVICE_EXCEPTION', 'COUPON_UNAVAILABLE']; // 默认处理的错误code
       if (codeList.indexOf(code) > -1) {
         uni.showToast({ title: langMessage || message, duration: 3000, icon: 'fail' });
       }

+ 18 - 6
src/pages/parkingFee/mixins/parkingFeeCoupon.js

@@ -224,7 +224,7 @@ export default {
       let couponList = [...this.couponList]; // 获取目前用户的电子券
       if (!this.checkedCouponList.length) {
         this.couponList = couponList.map(elm => {
-          elm.disabled = false
+          elm.disabled = elm?.status !== 'available';
           return elm;
         })
         return
@@ -242,13 +242,17 @@ export default {
         case '2': // 同类型可叠加
           // 找到
           couponList = couponList.map((elm, i) => {
-            elm.disabled = false; // 默认可选
+            // 只有 status === 'available' 的才会赋值为 false
+            elm.disabled = elm?.status !== 'available'; // 默认可选
             // 找到所以 superposition === 2 的同类型的券
-            if (elm.superposition === superposition) {
-              const selectCouponIds = couponList.filter((iem, iemi) => iem.couponId === elm.couponId && this.checkedCouponList.indexOf(`coupon${iemi}`) > -1);
+            if ( elm?.status === 'unavailable' ) {
+              // 这里是做一个阻断,就是避免程序往下执行,没有别的意思
+              elm.disabled = true
+            } else if (elm.superposition === superposition) { // 这里是找到一样类型的券
+              const selectCouponIds = couponList.filter((iem, iemi) => iem.couponId === elm.couponId && this.checkedCouponList.indexOf(`coupon${iemi}`) > -1); // 筛选出相同批次(couponId一样)的电子券,并且是已经选中的
               if (elm.limitCountPerOrder > 1) { // 是否存在上限
-                if (selectCouponIds.length >= elm.limitCountPerOrder) {
-                  elm.disabled = selectCouponIds.findIndex(iem => iem.code === elm.code) < 0
+                if (selectCouponIds.length >= elm.limitCountPerOrder) { // 如果这个批次的券已经选了一部分,并且超过了可选上限的话。
+                  elm.disabled = selectCouponIds.findIndex(iem => iem.code === elm.code) < 0 // 置灰剩余没有选中的电子券
                 }
               } else {
                 elm.disabled = selectCouponIds.findIndex(iem => iem.code === elm.code) < 0 && selectCouponIds.length > 0 // 同类型可选的券,如果可选上限是1,就设为不可选择
@@ -265,6 +269,14 @@ export default {
     // 根据电子券规则判断是否可选
     isDisabledByRule(item) {
       const { parkMallCode } = this.orderDetail.parkInfo;
+      // 最高优先级,提示未生效的电子券
+      if (item.status === 'unavailable') {
+        return Toast({
+          className: 'top300',
+          message: `当前电子券暂未生效,不可用`,
+          icon: 'none',
+        });
+      }
       // 杭州电子券使用上限(单位: 张)
       /*if (this.parkMallCode === 2) {
        // 达到上限

+ 4 - 0
src/styles/common.less

@@ -112,14 +112,18 @@ button {
 .van-toast{
   border-radius: 10px;
   padding: 25px 42px;
+  width: 65%;
+  min-height: inherit;
   background-color: @toast-background-color;
   .van-toast__text {
     font-family: 'PingFang SC';
     font-style: normal;
     font-weight: 400;
     font-size: 28px;
+    margin-top: 0;
     color: #FFFFFF;
   }
+  top: 300PX;
   &.top300{
     top: 300PX;
   }