john 2 éve
szülő
commit
2202a82e60

+ 102 - 0
src/api/mockData/checkout.qh8.response.json

@@ -0,0 +1,102 @@
+{
+  "parkingRecord": {
+    "vehicleNo": "赣A45678",
+    "enterTime": "2023-04-17 18:14:19",
+    "serviceMin": 24268,
+    "totalFee": 12000,
+    "actualPayFee": 80,
+    "thirdPartyId": "6a61bf47dc324ccd9d9ae8e3c0b914ab",
+    "thirdParkOrderNo": "Mh1p3CphEE7GbGv7Wzehs",
+    "createdByQrCode": false,
+    "totalFeeInYuan": 120
+  },
+  "discountInfo": {
+    "usingTotalDiscount": 40,
+    "memberLevelDiscount": false,
+    "points": [
+      {
+        "available": 4060,
+        "maxDiscountFee": 20,
+        "pointsPerUnit": 50,
+        "unitAmount": 5,
+        "newMember": false,
+        "label": "已选择兑换20元",
+        "discountFee": 20
+      }
+    ],
+    "coupons": [
+      {
+        "code": "sggsxqg614f_t",
+        "name": "首2小时停车券(测试)",
+        "expirationDate": "2023-05-31 23:59:59",
+        "discountFee": 20,
+        "defaultSelected": true,
+        "superposition": "2",
+        "limitCountPerOrder": 1
+      },
+      {
+        "code": "jvfmu4ept17_t",
+        "name": "5元停车券(周末及法定节假日)",
+        "expirationDate": "2023-05-31 23:59:59",
+        "discountFee": 5,
+        "defaultSelected": false,
+        "superposition": "2",
+        "limitCountPerOrder": 1000
+      },
+      {
+        "code": "r43iz9fgt5i_t",
+        "name": "5元停车券(周末及法定节假日)",
+        "expirationDate": "2023-05-31 23:59:59",
+        "discountFee": 5,
+        "defaultSelected": false,
+        "superposition": "2",
+        "limitCountPerOrder": 1000
+      },
+      {
+        "code": "h4rosxr74om_t",
+        "name": "周末首2小时满赠停车券--001--001",
+        "expirationDate": "2023-05-31 23:59:59",
+        "discountFee": 20,
+        "defaultSelected": false,
+        "superposition": "2",
+        "limitCountPerOrder": 1
+      },
+      {
+        "code": "0wtk9cbu9g2_t",
+        "name": "首2小时免费停车优惠券",
+        "expirationDate": "2023-05-31 23:59:59",
+        "discountFee": 20,
+        "defaultSelected": false,
+        "superposition": "1",
+        "limitCountPerOrder": 1
+      },
+      {
+        "code": "g2viqqia3hs_t",
+        "name": "停车电子券(金额券)",
+        "expirationDate": "2023-05-31 23:59:59",
+        "discountFee": 5,
+        "defaultSelected": false,
+        "superposition": "2",
+        "limitCountPerOrder": 0
+      }
+    ]
+  },
+  "parkingRule": {
+    "maxOneDayDiscountFee": 60,
+    "enableNewMemberPoints": false,
+    "enablePoints": true,
+    "enableCoupon": true,
+    "enablePaperCoupons": false,
+    "maxPointsTime": 101,
+    "enableConsume": false,
+    "enableConsumeSplit": false,
+    "availableDiscountFee": 60,
+    "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"
+  }
+}

+ 6 - 0
src/api/parking/index.js

@@ -163,3 +163,9 @@ export function qrCodes(codeId) {
 }
 
 
+// 1.3 纸质优惠劵金额接口
+export function paperCoupon(couponCode) {
+  return window.requestms.get(`parking-lots/paper-coupon?couponCode=${couponCode}`, { loading: true });
+}
+
+

+ 1 - 1
src/api/request.js

@@ -99,7 +99,7 @@ function XUser(config) {
     lbsId: store.state?.lbsId || '',
   };
   // params = {"userId": "8aaa809d835ba76d018378bc57180006","sourceType": "WECHAT","phoneNumber": "18521563898","projectId": "paroject1","buildingId": "QHKC-P1","brandId":"8a84853b7c91ac5b017c962dab55030e","cid": "oIUfO5XAVleJ88z13i1_08DCKIhQ","vipCode":"KERRY100200040","lbsId":"8aaa81cb7c836c6b017c83e46b110001"}
-  if (/orders-and-prepay|calculate-discount|unlicensed-car-check-in|unlicensed-car-checkout/g.test(config.url)) {
+  if (/orders-and-prepay|calculate-discount|unlicensed-car-check-in|unlicensed-car-checkout|paper-coupon/g.test(config.url)) {
     params.buildingId = window.localStorage.getItem('buildingId');
   }
   const newParams = {}

+ 1 - 1
src/pages/parkingFee/components/base/parkingFeeCoupon.vue

@@ -34,7 +34,7 @@
       <div class="flewx-content">
         应付<span style="color: red; font-size: 32px; padding-left: 20px">{{ actualPayFee | currency }}</span>
-        <span style="color: #8d8d8d; padding-left: 30px; font-size: 28px">已优惠{{ usingTotalDiscount | currency }}元</span>
+        <span style="color: #8d8d8d; padding-left: 30px; font-size: 28px">已优惠{{ remainPrice | currency }}元</span>
       </div>
       <div
         :class="{

+ 16 - 15
src/pages/parkingFee/mixins/parkingFeeCoupon.js

@@ -30,6 +30,7 @@ export default {
       maxOneDayDiscountFee: (state) => state.order.maxOneDayDiscountFee, // 深圳单日单次使用上限
       usingTotalDiscount: (state) => state.order.usingTotalDiscount, // 当前已使用优惠
       availableDiscountFee: (state) => state.order.availableDiscountFee, // 当前已使用优惠
+      paperDiscountFee: (state) => state.order.paperDiscountFee, // 当前已使用优惠
       lbsId: (state) => state.lbsId, // 楼栋ID
       groupId: (state) => state.groupId, // 楼盘ID
     }),
@@ -57,7 +58,7 @@ export default {
        * 2、superposition  叠加使用规则 (1不可叠加,2仅同类型可叠加,3可叠加);
        * */
       this.couponList = [...this.coupons];
-      this.remainPrice = this.availableDiscountFee * 1;
+      this.remainPrice = this.usingTotalDiscount;
       if (this.couponList.length) {
         this.couponList = this.couponList.map((elm, index) => {
           elm.disabled = true;
@@ -108,7 +109,7 @@ export default {
       }
     },
     // 对不同类型的优惠券进行汇总统计
-    groupedCouponData() {
+    /*groupedCouponData() {
       const groupedData = {}; // 所有的电子券按照批次分组;
       let couponList = [...this.couponList]; // 获取目前用户的电子券
       couponList.forEach((elm, index) => {
@@ -143,21 +144,21 @@ export default {
               if (item?.superposition === '1') {
                 if (selectedList.length) {// 如果存在已选择项,设置未选中的为不可选择
                   item.disabled = this.checkedCouponList.indexOf(elmName) < 0;
-                  /* 
+                  /!* 
                   TODO: 如果不可叠加电子券的选择规则改变为,选中某一项不可叠加券,其他券不可选择,则打开此处注释
                   if (item.superposition === '2') {
                     item.disabled = selectedList.length > 0
-                  } */
+                  } *!/
                 } else {
                   item.disabled = this.checkedCouponList.length > 0;
                 }
               }
-              /* 
+              /!* 
               // TODO: 如果不可叠加电子券的选择规则改变为,选中某一项不可叠加券,其他券不可选择,则打开此处注释
               // 如果存在已选的电子优惠券,将其他类型的优惠券设置为不可选中
               if ( item.superposition === '2' && selectedList.length) {
                 item.disabled = true
-              } */
+              } *!/
               return item
             })
             break
@@ -178,7 +179,7 @@ export default {
         }
       })
       this.couponList = [...couponList];
-    },
+    },*/
     // 对不同类型的优惠券进行汇总统计
     newGroupedCouponData() {
       let couponList = [...this.couponList]; // 获取目前用户的电子券
@@ -204,10 +205,12 @@ export default {
             elm.disabled = false; // 默认可选
             const elmName = `coupon${i}`;
             if (elm.superposition === superposition) {
-              if (limitCountPerOrder) { // 是否存在上限
+              if (elm.limitCountPerOrder > 1) { // 是否存在上限
                 if (this.checkedCouponList.length >= limitCountPerOrder) {
                   elm.disabled = this.checkedCouponList.indexOf(elmName) < 0
                 }
+              } else {
+                elm.disabled = this.checkedCouponList.indexOf(elmName) < 0 // 同类型可选的券,如果可选上限是1,就设为不可选择
               }
             } else {
               elm.disabled = true; // 非同批次的优惠券设置为不可选择
@@ -216,7 +219,7 @@ export default {
           })
           break;
       }
-      console.log(282, couponList);
+      console.log(220, couponList)
       this.couponList = [...couponList];
     },
     // 根据电子券规则判断是否可选
@@ -321,14 +324,14 @@ export default {
        // });
        }*/
       // 深圳超限处理
-      if (parkMallCode === 5 && this.remainPrice  <= actualPayFee) {
+      if (parkMallCode === 5 && this.remainPrice  >= this.actualPayFee) {
         return Toast({
-          message: `每日最高可抵扣${this.remainPrice}元`,
+          message: `每日最高可抵扣${this.actualPayFee}元`,
           icon: 'none',
         });
       }
-      // TODO: 浦东,单次上限提示, 后续 usingTotalDiscount 再减去 纸质优惠券的金额
-      if (parkMallCode === 1 && usingTotalDiscount >= maxOneTimeDiscountTime) {
+      // 浦东,单次上限提示, 后续 usingTotalDiscount 再减去 纸质优惠券的金额
+      if (parkMallCode === 1 && usingTotalDiscount- this.paperDiscountFee >= maxOneTimeDiscountTime) {
         return Toast({
           message: `超出抵扣上限,每次最高可抵扣${maxOneTimeDiscountTime}小时`,
           icon: 'none',
@@ -338,7 +341,6 @@ export default {
     },
     // 确认
     confirm() {
-      console.log(336, this.checkedCouponList);
       // 重新计算兑换券优惠
       const checkedCouponList = this.checkedCouponList.map((i) => this.item2Number(i));
       console.log(checkedCouponList);
@@ -350,7 +352,6 @@ export default {
         }
         return elm;
       });
-      console.log(348, couponList);
       this.$store.dispatch('order/saveCouponMath', {
         couponList: couponList,
         callback: () => {

+ 16 - 45
src/pages/parkingFee/mixins/parkingFeeDiscounts.js

@@ -1,6 +1,6 @@
 import { mapState } from 'vuex';
 import uniNumberBox from '@/components/uni-number-box/uni-number-box.vue';
-import {cloneDeep} from 'lodash'
+import { cloneDeep } from 'lodash'
 import uni from '@/utils/uniHooks';
 // const app = getApp()
 export default {
@@ -43,6 +43,8 @@ export default {
       memberLevelDiscount: state => state.order.memberLevelDiscount,
       checkedTotal: state => state.order.checkedTotal,
       parkMallCode: state => state.order.parkMallCode,
+      paperDiscountTime: state => state.order.paperDiscountTime,
+      paperDiscountFee: state => state.order.paperDiscountTime,
     }),
   },
   mounted() {
@@ -60,7 +62,7 @@ export default {
       if ( this.orderDetail?.parkingRule?.enableConsumeSplit ) {
         this.enableConsumeSplit = this.orderDetail.parkingRule.enableConsumeSplit
       }
-     
+
 
       this.checkedList = []
       const {memberGrade = [],consume = [],memberLevelDiscount} = this.orderDetail.discountInfo;
@@ -69,13 +71,13 @@ export default {
       if ( JSON.stringify(this.memberGrade) !== '{}' && this.memberGrade.hasOwnProperty('selected') ? this.memberGrade.selected : this.memberGrade.defaultSelected && !this.isMember ) {
         this.checkedList.push('member')
       }
-      if ( JSON.stringify(this.consume) !== '{}' && this.consume.hasOwnProperty('selected') ? this.consume.selected : this.consume.defaultSelected && !this.isReduces  ) {
+      if ( JSON.stringify(this.consume) !== '{}' && this.consume.hasOwnProperty('selected') ? this.consume.selected : this.consume.defaultSelected && !this.isReduces ) {
         consume[0].defaultSelected && this.checkedList.push('reduces')
         // 如果存在拆分逻辑的话
         // this.consume.
       }
       if ( this?.consume?.defaultDiscountTime ) {
-        this.reduceHours = this.consume.hasOwnProperty('discountTime')  ? this.consume.discountTime : this.consume.defaultDiscountTime
+        this.reduceHours = this.consume.hasOwnProperty('discountTime') ? this.consume.discountTime : this.consume.defaultDiscountTime
       }
       if ( this?.consume?.maxDiscountTime ) {
         this.maxReduceDiscount = this.consume.maxDiscountTime
@@ -88,8 +90,8 @@ export default {
     confirm() {
       let orderDetail = cloneDeep(this.orderDetail)
       // 如果初次进来操作的跟原来的不一样则重新计算优惠
-      if ( this.checkedList.length !==  this.checkedTotal) {
-        ['member', 'reduces'].forEach(key => {
+      if ( this.checkedList.length !== this.checkedTotal ) {
+        ['member','reduces'].forEach(key => {
           if ( key === 'member' ) {
             this.memberGrade = {
               ...this.memberGrade,
@@ -109,38 +111,7 @@ export default {
             orderDetail.discountInfo.consume = [this.consume]
           }
         })
-        if ( orderDetail.discountInfo.points.length ) {
-          let points = orderDetail.discountInfo.points
-          if ( !points[0].hasOwnProperty('selected') ) {
-            points[0] = {
-              ...points[0],
-              selected: points[0].hasOwnProperty('defaultSelected') || false
-            } 
-          }
-          orderDetail.discountInfo.points = points
-        }
-        if ( orderDetail.discountInfo.paperCoupons.length ) {
-          let paperCoupons = orderDetail.discountInfo.paperCoupons
-          if ( !paperCoupons[0].hasOwnProperty('selected') ) {
-            paperCoupons[0] = {
-              ...paperCoupons[0],
-              selected: paperCoupons[0].hasOwnProperty('defaultSelected') || false
-            }
-          }
-          orderDetail.discountInfo.paperCoupons = paperCoupons
-        }
-        // 电子券:coupons
-        if ( orderDetail.discountInfo.coupons.length ) {
-          let coupons = orderDetail.discountInfo.coupons
-          coupons = coupons.map(item => {
-            return {
-              ...item,
-              selected: item.hasOwnProperty('selected') ? item.selected : item.defaultSelected
-            }
-          })
-          orderDetail.discountInfo.coupons = coupons
-        }
-        this.$store.dispatch('order/saveDiscounts', {orderDetail,  callback: () => this.$router.back()})
+        this.$store.dispatch('order/saveDiscounts',{orderDetail,callback: () => this.$router.back()})
       } else {
         this.$router.back();
       }
@@ -150,17 +121,17 @@ export default {
     // 验证当前的选项是否可选择
     isCheck( callback ) {
       const {parkInfo,parkingRule,discountInfo} = this.orderDetail
-      const {maxOneTimeDiscountTime, maxOneDayDiscountFee, oneTimeLimitation, oneDayLimitation, hourPrice, remainConsumeTime} = parkingRule
-      console.log(129, this.parkMallCode)
+      const {maxOneTimeDiscountTime,maxOneDayDiscountFee,oneTimeLimitation,oneDayLimitation,hourPrice,remainConsumeTime} = parkingRule
+      console.log(129,this.parkMallCode)
       // 浦东
       if ( this.parkMallCode === 1 ) {
         const maxOneTimeDiscountFee = maxOneTimeDiscountTime * hourPrice
         const remainConsumeTimeFee = remainConsumeTime * hourPrice
-        console.log(133, this.usingTotalDiscount, remainConsumeTimeFee, maxOneTimeDiscountFee )
-        console.log('this.isMember', this.usingTotalDiscount, remainConsumeTimeFee, maxOneTimeDiscountFee, this.memberLevelDiscount)
+        console.log(133,this.usingTotalDiscount,remainConsumeTimeFee,maxOneTimeDiscountFee)
+        console.log('this.isMember',this.usingTotalDiscount,remainConsumeTimeFee,maxOneTimeDiscountFee,this.memberLevelDiscount)
         // TODO: 统计纸质优惠券的总金额, usingTotalDiscount - 纸质优惠券的总金额,才是用户当前订单使用的优惠总数 
-        this.isMember = !(this.usingTotalDiscount < (oneTimeLimitation ? maxOneTimeDiscountFee:maxOneDayDiscountFee ) && this.memberLevelDiscount)
-        this.isReduces = !(this.usingTotalDiscount < (oneTimeLimitation ? maxOneTimeDiscountFee:maxOneDayDiscountFee ) && this.enableConsume)
+        this.isMember = !( this.usingTotalDiscount - this.paperDiscountFee < ( oneTimeLimitation ? maxOneTimeDiscountFee : maxOneDayDiscountFee ) && this.memberLevelDiscount )
+        this.isReduces = !( this.usingTotalDiscount - this.paperDiscountFee < ( oneTimeLimitation ? maxOneTimeDiscountFee : maxOneDayDiscountFee ) && this.enableConsume )
       }
       // if ( this.checkedTotal === 2 ) {
       //   if ( this.checkedList.indexOf(type) > -1 ) {
@@ -172,7 +143,7 @@ export default {
       // }
       if ( callback ) callback()
     },
-    reducesChange(value) {
+    reducesChange( value ) {
       console.log(value)
     },
     crossMessage() {

+ 103 - 284
src/pages/parkingFee/mixins/parkingFeePaperCoupon.js

@@ -6,28 +6,29 @@ import { mapState } from 'vuex';
 import fuiToast from '@/components/fui-toast/fui-toast.vue';
 import { initWxJsSdkConfig } from '@/utils/login';
 import { getPlatform } from '@/utils';
+import { paperCoupon } from '@/api/parking'
 
 export default {
   components: {
     fuiToast,
   },
   created() {
-    
+
   },
   data() {
     return {
-      parkFee: {}, // 停车规则相关信息
-      // parkPaperCouponRemark: '', // 纸质优惠券说明
-      servicefee: 0, // 应缴金额
-      paperDiscountFee: 0, // 纸质优惠券减免金额
-      paperDiscountTime: 0, // 纸质优惠券减免时长
-      parkDiscountTotal: {}, // 总停车优惠
+      // parkFee: {}, // 停车规则相关信息
+      // // parkPaperCouponRemark: '', // 纸质优惠券说明
+      // servicefee: 0, // 应缴金额
+      // paperDiscountFee: 0, // 纸质优惠券减免金额
+      // paperDiscountTime: 0, // 纸质优惠券减免时长
+      // parkDiscountTotal: {}, // 总停车优惠
       paperCouponList: [], // 纸质券list
-      paperCouponInfo: {}, // 页面缓存
-      maxonetimediscountFee: 0, // 每次优惠上限金额
-      maxonedaydiscountFee: 0, // 每天优惠上限金额
-      parkMallCode: 1, // 0静安 1浦东 2杭州 3北京 4沈阳 5深圳
-      parkInfo: {},
+      // paperCouponInfo: {}, // 页面缓存
+      // maxonetimediscountFee: 0, // 每次优惠上限金额
+      // maxonedaydiscountFee: 0, // 每天优惠上限金额
+      // parkMallCode: 1, // 0静安 1浦东 2杭州 3北京 4沈阳 5深圳
+      // parkInfo: {},
     };
   },
   async mounted() {
@@ -35,80 +36,58 @@ export default {
       uni.setNavigationBarTitle({
         title: '纸质优惠券减免',
       });
-    }, 300);
+    },300);
     const platform = getPlatform();
-    if (platform === 'micromessenger') {
+    if ( platform === 'micromessenger' ) {
       // this.getTicket();
-      await initWxJsSdkConfig(['checkJsApi', 'scanQRCode']);
+      await initWxJsSdkConfig(['checkJsApi','scanQRCode']);
       // await initWxJsSdkConfig(['checkJsApi', 'scanQRCode']);
       // if (window.wxJsSdkConfigInitPromise) {
       //   await window.wxJsSdkConfigInitPromise;
       // }
     }
+    this.pageInit()
     setTimeout(() => {
       uni.setNavigationBarTitle({
         title: '优惠券',
       });
-    }, 300);
+    },300);
   },
   computed: {
     ...mapState({
-      custTypeId: (state) => state.custTypeId,
-      mallid: (state) => state.mallId,
-      openId: (state) => state.openid,
-      member: (state) => state.member,
-      groupId: (state) => state.groupId,
-      orderDetail: (state) => state.order.orderDetail
+      custTypeId: ( state ) => state.custTypeId,
+      mallid: ( state ) => state.mallId,
+      openId: ( state ) => state.openid,
+      member: ( state ) => state.member,
+      groupId: ( state ) => state.groupId,
+      orderDetail: ( state ) => state.order.orderDetail,
+      paperCoupons: ( state ) => state.order.paperCoupons,
+      paperDiscountFee: ( state ) => state.order.paperDiscountFee,
+      paperDiscountTime: ( state ) => state.order.paperDiscountTime,
     }),
-    // 实际支付金额
-    actualFee() {
-      const fee = this.servicefee - this.discountFee;
-      return fee > 0 ? fee : 0;
-    },
-    // 已优惠金额
-    discountFee() {
-      // 超出上限按上限计算
-      if (this.parkMallCode === 1) {
-        if (this.parkDiscountTotal.feeCopy > this.maxonetimediscountFee) {
-          this.parkDiscountTotal.feeCopy = this.maxonetimediscountFee;
-        }
-      }
-      if (this.parkMallCode === 4) {
-        if (
-          this.parkDiscountTotal.feeCopy - this.parkDiscountTotal.bonusfee >
-          this.maxonedaydiscountFee
-        ) {
-          this.parkDiscountTotal.feeCopy =
-            this.maxonedaydiscountFee + this.parkDiscountTotal.bonusfee;
-        }
-      }
-      return this.parkDiscountTotal.feeCopy + this.paperDiscountFee;
-    },
-  },
-  watch: {
-    orderDetail(){
-      console.log('909090', this.orderDetail)
-    }
   },
   methods: {
-    showToast(text) {
+    pageInit() {
+      this.paperCouponList = [...this.paperCoupons]
+    },
+    showToast( text ) {
       let options = {};
       options.text = text;
       this.$refs.toast.show(options);
     },
     // 扫码
     scanCode() {
-      const runScanFn = (res) => {
-        if (res.scanType == 'QR_CODE' && res.scanType) {
+      const runScanFn = ( res ) => {
+        if ( res.scanType == 'QR_CODE' && res.scanType ) {
           console.log(res.result);
           const url = res.result;
-          if (url.indexOf('auth/') === -1) {
+          if ( url.indexOf('auth/') === -1 ) {
             this.getPaperCouponInfo(res.result);
           } else {
             const start = url.indexOf('auth/');
             const end = url.indexOf('?');
-            const params = url.slice(start, end).split('/');
-            if (params && params.length) {
+            const params = url.slice(start,end).split('/');
+            if ( params && params.length ) {
               const couponCode = params[1];
               this.getPaperCouponInfo(couponCode);
             }
@@ -117,12 +96,12 @@ export default {
       };
       // 微信小程序
       const platform = getPlatform();
-      if (platform === 'miniprogram') {
+      if ( platform === 'miniprogram' ) {
         window.toWXSendMsg({
           type: 'scanQRCode',
         });
-        window.subscribe('scanQRCodeOver', (options) => {
-          console.log('微信扫码结束之后的返回参数', options);
+        window.subscribe('scanQRCodeOver',( options ) => {
+          console.log('微信扫码结束之后的返回参数',options);
           runScanFn(options);
         });
       } else {
@@ -130,250 +109,90 @@ export default {
           desc: 'scanQRCode desc',
           needResult: 1, // 默认为0,扫描结果由微信处理,1则直接返回扫描结果,
           // scanType: ['qrCode', 'barCode'], // 可以指定扫二维码还是一维码,默认二者都有
-          success: (res) => {
-            console.log(237, res);
+          success: ( res ) => {
+            console.log(237,res);
             runScanFn(res);
             // this.formMsg.deviceCode = res.resultStr;
           },
-          error: (res) => {
-            console.log(242, res);
+          error: ( res ) => {
+            console.log(242,res);
           },
         });
       }
-
-      /* uni.scanCode({
-       onlyFromCamera: false,
-       scanType: ['qrCode'],
-       success: (res) => {
-       console.log('扫码', res);
-       if (res.scanType == 'QR_CODE' && res.scanType) {
-       console.log(res.result);
-       const url = res.result;
-       if (url.indexOf('auth/') === -1) {
-       this.getPaperCouponInfo(res.result);
-       } else {
-       const start = url.indexOf('auth/');
-       const end = url.indexOf('?');
-       const params = url.slice(start, end).split('/');
-       if (params && params.length) {
-       const couponCode = params[1];
-       this.getPaperCouponInfo(couponCode);
-       }
-       }
-       }
-       },
-       }); */
     },
 
     // 根据卡券ID查询卡券信息
-    getPaperCouponInfo(couponCode) {
+    async getPaperCouponInfo( couponCode ) {
       uni.showLoading({
         title: '加载中',
       });
-      const params = {
-        groupId: this.groupId,
-        mallid: this.mallid,
-        couponcode: couponCode,
-        orderno: uni.getStorageSync('orderno'),
-      };
-      this.$md(params);
-      uni.request({
-        url: this.$baseURL + 'api/1.0/park/queryTicketCount',
-        data: params,
-        method: 'POST',
-        header: JSON.parse(uni.getStorageSync('handleUser')),
-        success: (res) => {
-          uni.hideLoading();
-          console.log(res);
-          if (res.data.code !== 0) {
-            // return uni.showToast({
-            // 	title: res.data.msg,
-            // 	duration: 2000,
-            // 	icon: 'none'
-            // })
-            return Toast({
-              message: res.data.msg,
-            });
-            // return this.showToast(res.data.msg);
-          }
-          if (res.data.data.type === 2) {
-            if (res.data.data.discountType == '0') {
-              return Toast({
-                message: '该纸质优惠券未激活',
-              });
-              // return uni.showToast({
-              //   title: '该纸质优惠券未激活',
-              //   duration: 2000,
-              //   icon: 'none',
-              // });
-            }
-            if (res.data.data.discountRuleId == '1') {
-              return Toast({
-                message: '该纸质优惠券已领取',
-              });
-              // return uni.showToast({
-              //   title: '该纸质优惠券已领取',
-              //   duration: 2000,
-              //   icon: 'none',
-              // });
-            }
-            if (res.data.data.discountRuleId == '2') {
-              return Toast({
-                message: '该纸质优惠券已使用',
-              });
-              // return uni.showToast({
-              //   title: '该纸质优惠券已使用',
-              //   duration: 2000,
-              //   icon: 'none',
-              // });
-            }
-            if (res.data.data.discountRuleId == '3') {
-              return Toast({
-                message: '该纸质优惠券已核销',
-              });
-              // return uni.showToast({
-              //   title: '该纸质优惠券已核销',
-              //   duration: 2000,
-              //   icon: 'none',
-              // });
-            }
-          }
-          if (this.paperCouponList.length) {
-            const index = this.paperCouponList.findIndex(
-              (e) => e.discountCode === couponCode
-            );
-            if (index === -1) {
-              this.paperCouponList.push(res.data.data);
-              this.paperDiscountFee += Number(res.data.data.discountValueMoney);
-              this.paperDiscountTime =
-                this.paperDiscountFee / this.parkFee.parkInfoEntity.needmoney;
-            }
-          } else {
-            this.paperCouponList.push(res.data.data);
-            this.paperDiscountFee += Number(res.data.data.discountValueMoney);
-            this.paperDiscountTime =
-              this.paperDiscountFee / this.parkFee.parkInfoEntity.needmoney;
+      // const res = await paperCoupon(couponCode);
+      const res = {
+        "status": "1",
+        "discountCode": "91354260",
+        "discountFee": 1,
+        "used": "0",
+        "content": "嘉里卡券测试"
+      }
+      if ( /0/.test(res.status)) {
+        return Toast({
+          message: '该纸质优惠券未激活',
+        });
+      }
+      if (/1/.test(res.used)) {
+        return Toast({
+          message: '该纸质优惠券已领取',
+        });
+      }
+      if (/2/.test(res.used)) {
+        return Toast({
+          message: '该纸质优惠券已使用',
+        });
+      }
+      if (/3/.test(res.used)) {
+        return Toast({
+          message: '该纸质优惠券已核销',
+        });
+      }
+      // 如果纸质优惠券不存在的话,则往 paperCoupons 添加
+      if ( this.paperCoupons.findIndex(item => item.discountCode === couponCode) < 0 ) {
+        const {hourPrice} = this.orderDetail.parkingRule
+        const discountTime = Number(res.discountFee) / hourPrice
+        this.$store.commit('order/setPaperCoupons',[
+          ...this.paperCoupons,
+          {
+            ...res,
+            discountTime: res.discountFee / hourPrice
           }
-
-          // this.crossMessage();
-        },
-        fail: (err) => {
-          uni.hideLoading();
-          console.log(err);
-        },
-      });
+        ])
+        // 金额
+        this.$store.commit('order/setPaperDiscountFee',this.paperDiscountFee + Number(res.discountFee))
+        // 时间
+        this.$store.commit('order/setPaperDiscountTime',this.paperDiscountTime + discountTime)
+      }
     },
-
     // 删除
-    deleteCoupon(i) {
-      this.paperDiscountFee -= Number(
-        this.paperCouponList[i].discountValueMoney
-      );
-      this.paperDiscountTime =
-        this.paperDiscountFee / this.parkFee.parkInfoEntity.needmoney;
-      this.paperCouponList.splice(i, 1);
+    deleteCoupon( i ) {
+      const item = this.paperCoupons[i]
+      const paperCoupons = this.paperCoupons.filter(elm => elm.discountCode !== item.discountCode)
+      const {hourPrice} = this.orderDetail.parkingRule
+      const discountTime = Number(item.discountFee) / hourPrice
+      this.$store.commit('order/setPaperCoupons',paperCoupons)
+      // 金额
+      this.$store.commit('order/setPaperDiscountFee',this.paperDiscountFee - Number(item.discountFee))
+      // 时间
+      this.$store.commit('order/setPaperDiscountTime',this.paperDiscountTime + discountTime)
     },
 
-    /**
-     * 2021-12-24 微信小群确定取消纸质券限制
-     */
-    // 超限提示
-    // crossMessage() {
-    // 	let totalFee = this.parkDiscountTotal.feeCopy;
-    // 	if (this.paperCouponInfo && this.paperCouponInfo.paperDiscountFee !== 0) {
-    // 		totalFee += this.paperDiscountFee - this.paperCouponInfo.paperDiscountFee;
-    // 	} else {
-    // 		totalFee += this.paperDiscountFee;
-    // 	}
-    // 	// 是否受每次最大优惠限制(浦东)
-    // 	if (this.parkFee.parkPaperCouponsEntities[0].isMaxLimit !== 1) {
-    // 		if (totalFee > this.maxonetimediscountFee) {
-    // 			return uni.showToast({
-    // 				title: `超出抵扣上限,每次最高可抵扣${this.parkFee.parkInfoEntity.maxonetimediscount}小时`,
-    // 				icon: 'none'
-    // 			});
-    // 		}
-    // 	}
-    // 	// 浦东总优惠不包含纸质券
-    // 	if (this.parkMallCode !== 1) {
-    // 		if (totalFee > this.maxonedaydiscountFee) {
-    // 			return uni.showToast({
-    // 				title: `超出抵扣上限,每天最高可抵扣${this.parkFee.parkInfoEntity.maxonedaydiscount}小时`,
-    // 				icon: 'none'
-    // 			});
-    // 		}
-    // 	}
-    // },
-
     // 确认
     confirm() {
-      console.log(310, this.orderDetail);
-      return
-      let paperCouponcode = '';
-      this.paperCouponList.forEach((e, i) => {
-        if (i === this.paperCouponList.length - 1) {
-          paperCouponcode += e.discountCode;
-        } else {
-          paperCouponcode += e.discountCode + '#';
-        }
-      });
-      uni.setStorageSync('paperCouponInfo', {
-        paperDiscountFee: this.paperDiscountFee,
-        paperDiscountTime: this.paperDiscountTime,
-        paperCouponcode: paperCouponcode,
-        paperCouponList: this.paperCouponList,
+      console.log(310,this.orderDetail);
+      this.$store.dispatch('order/savePaperCoupon', {
+        couponList: this.paperCoupons,
+        callback: () => {
+          this.$router.back();
+        },
       });
-      this.$router.back();
     },
-    /*
-     // h5获取配置---公众号支付
-     getTicket() {
-     let self = this;
-     var datas = {
-     groupId: this.$store.state.groupId,
-     mallid: this.$store.state.mallid,
-     url: window.location.href.split('#')[0],
-     };
-     self.$md(datas);
-     uni.request({
-     url: self.$baseURL + 'api/1.0/login/getTicket',
-     method: 'POST',
-     data: datas,
-     header: JSON.parse(uni.getStorageSync('handleUser')),
-     success: (res) => {
-     if (res.data.code == 0) {
-     self.$wx.config({
-     debug: false, // 开启调试模式
-     appId: res.data.data.appId, // 必填,公众号的唯一标识
-     timestamp: res.data.data.timestamp, // 必填,生成签名的时间戳
-     nonceStr: res.data.data.nonceStr, // 必填,生成签名的随机串
-     signature: res.data.data.signature, // 必填,签名
-     jsApiList: ['chooseWXPay', 'scanQRCode', 'checkJsApi'], // 必填,需要使用的JS接口列表
-     });
-     self.$wx.ready(function () {
-     self.$wx.checkJsApi({
-     jsApiList: ['chooseWXPay'],
-     success: (res) => {
-     console.log('checked api:', res);
-     },
-     fail: (err) => {
-     console.log('check api fail:', err);
-     },
-     });
-     });
-     self.$wx.error(function (res) {
-     console.log('err', res);
-     });
-     } else {
-     uni.showToast({
-     title: res.data.msg,
-     duration: 2000,
-     icon: 'none',
-     });
-     }
-     },
-     });
-     },
-     */
   },
 };

+ 1 - 1
src/pages/parkingFee/parkingFeePaperCoupon.vue

@@ -25,7 +25,7 @@
           "
         >
           优惠劵金额 :<span style="color: #064c8a">{{
-            item.discountValueMoney | currency
+            item.discountFee | currency
           }}</span>
         </div>
       </div>

+ 3 - 35
src/store/order/coupon.js

@@ -1,37 +1,11 @@
 import { checkOut,calculateDiscount,ordersAndPrepay,currentUnlicensedPlate,unlicensedCarCheckIn,unlicensedCarCheckout } from '@/api/parking';
+import { setSelected } from "@/store/order/utils";
+
 export default {
   // 电子优惠券
   couponRule( {commit,dispatch,state},checkOutResponse ) {
     commit('setEnableCoupon',checkOutResponse.parkingRule.enableCoupon);
     if ( checkOutResponse.parkingRule.enableCoupon ) {
-      // const {maxOneDayCoupons, remainConsumeTime, hourPrice} = checkOutResponse.parkingRule;
-      // const {
-      //   usingTotalDiscount, // 使用总抵扣
-      //   coupons
-      // } = checkOutResponse.discountInfo;
-      // const {
-      //   totalFee, // 应缴
-      //   actualPayFee // 应付金额
-      // } = checkOutResponse.parkingRecord;
-      // // 剩余可使用的优惠金额,支持动态计算; 优惠时长,不可能全部使用,不能超过车费减去优惠的金额;不能超过单次的应付金额
-      // let remainPrice = remainConsumeTime * hourPrice;
-      // if ( remainPrice > actualPayFee ) {
-      //   remainPrice = actualPayFee;
-      // }
-      // let couponPrice = 0
-      // // 确认优惠券是否可选择
-      // let couponsList = coupons.sort((itema,itemb) => itema.discountFee - itemb.discountFee)
-      // couponsList = couponsList.map(elm => {
-      //   if ( !elm.defaultSelected ) {
-      //     if ( elm.discountFee <=  remainPrice && couponPrice <= remainPrice) {
-      //       elm.disabled = false
-      //     } else {
-      //       elm.disabled = true
-      //     }
-      //   }
-      // })
-      // console.log(343, {couponsList});
-      // commit('setCoupons', couponsList);
       commit('setMaxOneDayCoupons',checkOutResponse.parkingRule.maxOneDayCoupons); // 仅在杭州使用
       // 根据时间排序电子兑换券
       const couponSort = ( a,b ) => {
@@ -52,7 +26,6 @@ export default {
         }
       });
       commit('setCouponCount',couponCount);
-      console.log(479,couponCount);
       if ( couponCount > 0 ) {
         return commit('setCouponDesc',`已选择${ couponCount }张优惠劵`);
       } else {
@@ -68,11 +41,7 @@ export default {
   async saveCouponMath( {commit,dispatch,state},{couponList,callback} ) {
     const orderDetail = {...state.orderDetail};
     orderDetail.discountInfo.coupons = couponList;
-    if ( orderDetail?.discountInfo?.points[0]?.discountFee ) {
-      orderDetail.discountInfo.points[0].selected = true;
-    } else {
-      orderDetail.discountInfo.points[0].selected = false;
-    }
+    setSelected(['paperCoupons','consume','points','memberGrade'],orderDetail)
     try {
       const res = await calculateDiscount({
         ...orderDetail,
@@ -83,6 +52,5 @@ export default {
       console.log('积分修改失败!',err);
       callback && callback();
     }
-    // commit('setCoupons', checkOutResponse.discountInfo.coupons);
   },
 }

+ 5 - 4
src/store/order/index.js

@@ -1,4 +1,4 @@
-import checkOutQHResponse from "@/api/mockData/checkout.pd6.response.json";
+import checkOutQHResponse from "@/api/mockData/checkout.qh8.response.json";
 import { checkOut,calculateDiscount,ordersAndPrepay,currentUnlicensedPlate,unlicensedCarCheckIn,unlicensedCarCheckout } from '@/api/parking';
 import state from "@/store/order/state";
 import mutations from "@/store/order/mutations";
@@ -7,6 +7,7 @@ import points from "@/store/order/points";
 import coupon from "@/store/order/coupon";
 import consume from "@/store/order/consume";
 import unlicensed from "@/store/order/unlicensed";
+import paperCoupon from "@/store/order/paperCoupon";
 
 export default {
   //开启命名模块
@@ -35,8 +36,8 @@ export default {
         // console.log('无牌车扫码出场', endlessLoop);
         // 场内缴费,调 check-out 接口,
         const method = unlicensed && endlessLoop || !vehicleNo ? unlicensedCarCheckout : checkOut
-        const res = await method(vehicleNo, unlicensed, gateId);
-        // const res = checkOutQHResponse
+        // const res = await method(vehicleNo, unlicensed, gateId);
+        const res = checkOutQHResponse
         if ( res?.parkingRecord?.totalFee <= 0 ) {
           callback && callback({
             unlicensed,
@@ -105,6 +106,6 @@ export default {
     // 无牌车
     ...unlicensed,
     // 纸质优惠券
-
+    ...paperCoupon
   },
 };

+ 10 - 7
src/store/order/memberLevel.js

@@ -1,9 +1,11 @@
 import { checkOut,calculateDiscount,ordersAndPrepay,currentUnlicensedPlate,unlicensedCarCheckIn,unlicensedCarCheckout } from '@/api/parking';
+import { setSelected } from "@/store/order/utils";
+
 export default {
   // 停车优惠(首停、会员减免、消费减免)
   getCheckedTotal( {commit,dispatch},orderDetail ) {
     let checkedTotal = 0;
-    console.log(254, orderDetail);
+    console.log(254,orderDetail);
     if ( orderDetail?.discountInfo?.memberLevelDiscount && orderDetail?.discountInfo?.memberGrade.length ) {
 
       orderDetail.discountInfo.memberGrade.forEach(( elm ) => {
@@ -19,7 +21,7 @@ export default {
         }
       });
     }
-    console.log(22, checkedTotal)
+    console.log(22,checkedTotal)
     commit('setMemberLevelDiscount',orderDetail.discountInfo.memberLevelDiscount);
     commit('setCheckedTotal',checkedTotal);
     dispatch('getDiscountDesc',{
@@ -28,9 +30,9 @@ export default {
     });
   },
   getDiscountDesc( {commit,dispatch},{orderDetail,checkedTotal} ) {
-    console.log(278, orderDetail.parkingRule.enableConsume)
-    console.log(278, orderDetail.parkingRule.enableConsume)
-    if ( orderDetail.parkingRule.enableConsume || orderDetail.discountInfo.memberLevelDiscount) {
+    console.log(278,orderDetail.parkingRule.enableConsume)
+    console.log(278,orderDetail.parkingRule.enableConsume)
+    if ( orderDetail.parkingRule.enableConsume || orderDetail.discountInfo.memberLevelDiscount ) {
       commit('setEnableConsume',orderDetail.parkingRule.enableConsume);
       if ( checkedTotal > 0 ) {
         return commit('setDiscountDesc',`已选择${ checkedTotal }项优惠`);
@@ -40,12 +42,13 @@ export default {
       return commit('setDiscountDesc',`暂无可用优惠`);
     }
   },
-  async saveDiscounts({commit,dispatch},{orderDetail,callback}) {
+  async saveDiscounts( {commit,dispatch},{orderDetail,callback} ) {
     try {
+      setSelected(['paperCoupons','coupons','points',],orderDetail)
       const res = await calculateDiscount({
         ...orderDetail,
       });
-      console.log(48, res)
+      console.log(48,res)
       dispatch('orderInitRule',res);
       callback && callback();
     } catch ( err ) {

+ 22 - 0
src/store/order/mutations.js

@@ -89,6 +89,22 @@ export default {
   setParkMallCode( state,payload ) {
     state.parkMallCode = payload;
   },
+  /* 纸质优惠券相关 */
+  setPaperCoupons( state,payload ) {
+    state.paperCoupons = payload;
+  },
+  setPaperCouponCount( state,payload ) {
+    state.paperCouponCount = payload;
+  },
+  setPaperCouponDesc( state,payload ) {
+    state.paperCouponDesc = payload;
+  },
+  setPaperDiscountFee( state,payload ) {
+    state.paperDiscountFee = payload;
+  },
+  setPaperDiscountTime( state,payload ) {
+    state.paperDiscountTime = payload;
+  },
   // 订单初始化
   clearOrderInfo( state ) {
     state.orderDetail = {}; // 订单原始数据
@@ -124,5 +140,11 @@ export default {
     state.unlicensedCar = '';
     // 车场相关
     state.parkMallCode = '' // 车场唯一编号
+    /* 纸质优惠券相关 */
+    state.paperCoupons = [] // 可选纸质优惠券数量
+    state.paperCouponCount = 0 // 已选纸质择优惠券
+    state.paperCouponDesc = '' // 纸质优惠券说明文案
+    state.paperDiscountFee = 0 // 纸质优惠券总金额
+    state.paperDiscountTime = 0 // 纸质优惠券总时间
   }
 };

+ 36 - 0
src/store/order/paperCoupon.js

@@ -0,0 +1,36 @@
+import { calculateDiscount } from "@/api/parking";
+import { setSelected } from "@/store/order/utils";
+
+export default {
+  /*
+   *   setPaperCoupons( state,payload ) {
+   state.paperCoupons = payload;
+   },
+   setPaperCouponCount( state,payload ) {
+   state.paperCouponCount = payload;
+   },
+   setPaperCouponDesc( state,payload ) {
+   state.paperCouponDesc = payload;
+   },
+   * 
+   * */
+  paperCouponRule( {commit,dispatch,state},checkOutResponse ) {
+    if ( checkOutResponse.parkingRule.enablePaperCoupons ) {
+
+    }
+  },
+  async savePaperCoupon( {commit,dispatch,state},{paperCoupons,callback} ) {
+    try {
+      const orderDetail = {...state.orderDetail};
+      setSelected(['paperCoupons', 'coupons','consume','points','memberGrade'], orderDetail)
+      const res = await calculateDiscount({
+        ...orderDetail,
+      });
+      dispatch('orderInitRule',res);
+      callback && callback();
+    } catch ( err ) {
+      console.log('积分修改失败!',err);
+      callback && callback();
+    }
+  }
+}

+ 12 - 36
src/store/order/points.js

@@ -1,4 +1,5 @@
 import { checkOut,calculateDiscount,ordersAndPrepay,currentUnlicensedPlate,unlicensedCarCheckIn,unlicensedCarCheckout } from '@/api/parking';
+import { setSelected } from './utils'
 
 export default {
 
@@ -113,11 +114,11 @@ export default {
       if ( type === 'add' && state.pointsTime >= maxPointsTime ) {
         // 以下是深圳积分上限规则
         // 超出抵扣上限,每日最高可抵扣${this.parkFee.parkInfoEntity.maxOneDayHour}元 '优惠金额' >= '每日最高可抵扣'
-        if ( state.usingTotalDiscount >= state.maxOneDayDiscountFee && !msg ) {
+        if ( state.usingTotalDiscount - state.paperDiscountFee >= state.maxOneDayDiscountFee && !msg ) {
           msg = `超出抵扣上限,每日最高可抵扣${ state.maxOneDayDiscountFee }元`
         }
         // 超出抵扣上限,每次最高可抵扣${this.integralMaxMoney}元 '积分兑换时长' >= '深圳前海停车积分上限'q
-        if ( state.pointsTime >= maxPointsTime && !msg ) {
+        if ( state.pointsTime >= state.maxDiscountFee && !msg ) {
           msg = `超出抵扣上限,每次最高可抵扣${ state.maxDiscountFee }元`
         }
       }
@@ -141,30 +142,27 @@ export default {
       const remainConsumeTimeFee = remainConsumeTime * hourPrice
       // 计算单日剩余 remainConsumeTime
       // 当前使用优惠 state.usingTotalDiscount
-      // 判断符合上限 
-
-      // 浦东积分上限判断
-      if ( parkMallCode === 1 && type === 'add' && state.usingTotalDiscount <= maxOneTimeDiscountFee ) {
+      // 判断符合上限
+      // 浦东积分上限判断: 减去纸质优惠券的金额
+      if ( parkMallCode === 1 && type === 'add' && state.usingTotalDiscount - state.paperDiscountFee <= maxOneTimeDiscountFee ) {
         msg = `超出抵扣上限,每次最高可抵扣${ maxOneTimeDiscountTime }小时`
       }
     }
-    console.log(434,msg)
-    if ( msg && false ) {
+    if ( msg ) {
       callback({
         message: msg
       });
       return
     }
-    console.log(158,state.pointsTime,remainConsumeTime);
     // 计算浦东的上限
-    // if ( type === 'add' && state.pointsTime < remainConsumeTime ) {
+    if ( type === 'add' && state.usingTotalDiscount < state.maxOneDayDiscountFee && parkMallCode === 5 ) {
+      return;
+    }
     if ( type === 'add' ) {
       let pointsTime = 0;
-      console.log(111,state.pointsTime,state.unitAmount);
       pointsTime = state.pointsTime + state.unitAmount;
       const available = state.available - state.pointsPerUnit;
       const usingTotalDiscount = state.usingTotalDiscount + state.unitAmount; // 重新计算已经使用的优惠逻辑
-      console.log(164,available,pointsTime,usingTotalDiscount);
       if ( available > -1 ) {
         // 如果是深圳车场
         commit('setAvailable',available);
@@ -202,30 +200,8 @@ export default {
         callback && callback();
         return
       }
-      // 如果是会员等级减免
-      if ( orderDetail.discountInfo?.memberGrade?.length) {
-        const [memberGrade] = orderDetail.discountInfo?.memberGrade;
-        orderDetail.discountInfo.memberGrade = [{
-          ...memberGrade,
-          selected: memberGrade.hasOwnProperty('selected') ? memberGrade.selected : memberGrade?.defaultSelected || false
-        }]
-      }
-      // 如果是消费减免
-      if ( orderDetail.discountInfo?.consume?.length) {
-        const [consume] = orderDetail.discountInfo?.consume;
-        orderDetail.discountInfo.consume = [{
-          ...consume,
-          selected: consume.hasOwnProperty('selected') ? consume.selected : consume?.defaultSelected || false
-        }]
-      }
-      // 如果是纸质优惠券的话
-      if ( orderDetail.discountInfo?.paperCoupons?.length ) {
-        const [paperCoupons] = orderDetail.discountInfo?.paperCoupons;
-        orderDetail.discountInfo.paperCoupons = [{
-          ...paperCoupons,
-          selected: paperCoupons.hasOwnProperty('selected') ? paperCoupons.selected : paperCoupons?.defaultSelected || false
-        }]
-      }
+      // 如果是会员等级减免\如果是消费减免\如果是纸质优惠券\电子券的话
+      setSelected(['memberGrade','consume','paperCoupons','coupons'],orderDetail)
       // 计算积分修改之后的金额,返回给后端
       // orderDetail.discountInfo.points[0].discountFee = state.pointsTime * orderDetail.discountInfo.points[0].unitAmount;
       orderDetail.discountInfo.points[0].discountFee = state.pointsTime;

+ 7 - 1
src/store/order/state.js

@@ -32,5 +32,11 @@ export default  {
   // 无牌车逻辑
   unlicensedCar: '',
   // 车场相关
-  parkMallCode: '' // 车场唯一编号
+  parkMallCode: '', // 车场唯一编号
+  /* 纸质优惠券相关 */
+  paperCoupons: [], // 可选纸质优惠券数量
+  paperCouponCount: 0, // 已选纸质择优惠券
+  paperDiscountFee: 0, // 纸质优惠券的总金额
+  paperDiscountTime: 0, // 纸质优惠券的总时间
+  paperCouponDesc: '', // 纸质优惠券说明文案
 }

+ 68 - 0
src/store/order/utils.js

@@ -0,0 +1,68 @@
+import { isArray } from "lodash";
+
+export function setSelected( types,orderDetail ) {
+  function run( name ) {
+    switch ( name ) {
+      case 'memberGrade':
+        // 如果是会员等级减免
+        if ( orderDetail.discountInfo?.memberGrade?.length ) {
+          const [memberGrade] = orderDetail.discountInfo?.memberGrade;
+          orderDetail.discountInfo.memberGrade = [{
+            ...memberGrade,
+            selected: memberGrade.hasOwnProperty('selected') ? memberGrade.selected : memberGrade?.defaultSelected || false
+          }]
+        }
+        break
+      case 'consume':
+        // 如果是消费减免
+        if ( orderDetail.discountInfo?.consume?.length ) {
+          const [consume] = orderDetail.discountInfo?.consume;
+          orderDetail.discountInfo.consume = [{
+            ...consume,
+            selected: consume.hasOwnProperty('selected') ? consume.selected : consume?.defaultSelected || false
+          }]
+        }
+        break
+      case 'points':
+        // 如果是积分减免
+        if ( orderDetail.discountInfo?.points?.length ) {
+          const [points] = orderDetail.discountInfo?.points;
+          orderDetail.discountInfo.points = [{
+            ...points,
+            selected: points.hasOwnProperty('selected') ? points.selected : points?.defaultSelected || false
+          }]
+        }
+        break
+      case 'paperCoupons':
+        // 如果是纸质优惠券的话
+        if ( orderDetail.discountInfo?.paperCoupons?.length ) {
+          const [paperCoupons] = orderDetail.discountInfo?.paperCoupons;
+          orderDetail.discountInfo.paperCoupons = [{
+            ...paperCoupons,
+            selected: paperCoupons.hasOwnProperty('selected') ? paperCoupons.selected : paperCoupons?.defaultSelected || false
+          }]
+        }
+        break
+      case 'coupons':
+        // 如果是电子优惠券的话
+        if ( orderDetail.discountInfo?.coupons?.length ) {
+          orderDetail.discountInfo.coupons = orderDetail.discountInfo.coupons.map(elm => {
+            return {
+              ...elm,
+              selected: elm.hasOwnProperty('selected') ? elm.selected : elm?.defaultSelected || false
+            }
+          })
+        }
+        break
+    }
+  }
+
+  if ( typeof types === 'string' ) {
+    run(types)
+  }
+  if ( isArray(types) ) {
+    types.forEach(key => {
+      run(key)
+    })
+  }
+}

+ 2 - 2
src/utils/index.js

@@ -205,9 +205,9 @@ export function initEnv() {
 
 export function requestInit() {
   let baseURL = window.profileApi + '/temporary-parking/v1';
-  /*if (window.location.href.indexOf('parking.') < 0) {
+  if (window.location.href.indexOf('parking.') < 0) {
     baseURL = '/msApi';
-  }*/
+  }
   window.requestms = createAxiosByinterceptors({
     // baseURL: `https://dev-kip-service-internal.kerryonvip.com/`,
     // baseURL: `http://tp.hht.test/`,

+ 1 - 1
vue.config.js

@@ -124,7 +124,7 @@ module.exports = {
       '/msApi': {
         // target: 'http://172.21.201.251:8080',
         // target: 'http://172.21.203.156:8080',
-        target: 'http://172.20.51.69:8080',
+        target: 'http://172.21.203.109:8080',
         // target: 'http://172.21.202.133:8080',
         // target: 'https://dev-kip-service-internal.kerryonvip.com/temporary-parking-service', //代理地址,这里设置的地址会代替axios中设置的baseURL
         // target: 'http://172.21.203.140:8080', //代理地址,这里设置的地址会代替axios中设置的baseURL   2023-2-9