john 2 سال پیش
والد
کامیت
48029ce891

+ 1 - 1
src/App.vue

@@ -84,7 +84,7 @@ export default {
         if (carList) {
           uni.setStorageSync('carList', JSON.parse(carList));
         }
-        this.$store.commit('SET_IS_INIT', false);
+        this.$store.commit('SET_IS_INIT', true);
         window.token = `${window.location.href}`.replace(/.*wx\/(.*)\/.*/g, '$1');
         try {
           const options = await wssInit();

+ 12 - 2
src/api/mockData/checkout.pd2.response.json

@@ -21,6 +21,14 @@
         "discountFee": 10
       }
     ],
+    "consume": [
+      {
+        "defaultSelected": true,
+        "maxDiscountTime": 10,
+        "defaultDiscountTime": 3,
+        "redeemSalesAmount": 1000
+      }
+    ],
     "points": [
       {
         "available": 10000,
@@ -43,10 +51,12 @@
     "enableCoupon": false,
     "maxOneDayCoupons": 5,
     "remainCoupons": 5,
+    "oneDayLimitation": true,
+    "oneTimeLimitation": true,
     "enablePaperCoupons": true,
     "paperCouponsDescription": "纸质优惠券不限制会员使用。",
-    "enableConsume": false,
-    "enableConsumeSplit": false,
+    "enableConsume": true,
+    "enableConsumeSplit": true,
     "maxConsumeTime": 0,
     "remainConsumeTime": 0,
     "hourPrice": 10

+ 62 - 0
src/api/mockData/checkout.pd4.response.json

@@ -0,0 +1,62 @@
+{
+  "parkingRecord": {
+    "vehicleNo": "沪D00020",
+    "enterTime": "2023-04-25 08:46:00",
+    "serviceMin": 1975,
+    "totalFee": 3300,
+    "actualPayFee": 23,
+    "thirdParkOrderNo": "4970693",
+    "createdByQrCode": false,
+    "totalFeeInYuan": 33
+  },
+  "discountInfo": {
+    "usingTotalDiscount": 10,
+    "memberLevelDiscount": true,
+    "memberGrade": [
+      {
+        "defaultSelected": true,
+        "memberGrade": "01",
+        "memberGradeText": "嘉友卡",
+        "discountTime": 1,
+        "discountFee": 10
+      }
+    ],
+    "points": [
+      {
+        "available": 10000,
+        "pointsPerUnit": 1200,
+        "unitAmount": 0,
+        "newMember": false,
+        "label": "10000积分可减免"
+      }
+    ],
+    "paperCoupons": [
+      {
+        "description": "纸质优惠券不限制会员使用。"
+      }
+    ]
+  },
+  "parkingRule": {
+    "maxOneTimeDiscountTime": 10,
+    "enableNewMemberPoints": false,
+    "enablePoints": true,
+    "enableCoupon": false,
+    "maxOneDayCoupons": 5,
+    "remainCoupons": 5,
+    "enablePaperCoupons": true,
+    "paperCouponsDescription": "纸质优惠券不限制会员使用。",
+    "enableConsume": false,
+    "enableConsumeSplit": false,
+    "maxConsumeTime": 0,
+    "remainConsumeTime": 0,
+    "hourPrice": 10,
+    "oneDayLimitation": false,
+    "oneTimeLimitation": true
+  },
+  "parkInfo": {
+    "parkName": "浦东嘉里停车场",
+    "description": "12元/小时。8-24小时封顶96元。纸质优惠券不限制使用数量。每次最多优惠2小时。积分兑换停车费用1200积分=1小时。积分商城售卖停车电子券的使用类型。单日累计消费满300元赠送1张消费600元赠2张1小时的停车券,不重复发券,消费跨天不累计,优惠有效期7天",
+    "parkMallCode": 6,
+    "buildingId": "PKC-P1"
+  }
+}

+ 62 - 0
src/api/mockData/checkout.pd5.response.json

@@ -0,0 +1,62 @@
+{
+  "parkingRecord": {
+    "vehicleNo": "沪K10000",
+    "enterTime": "2023-04-27 12:57:00",
+    "serviceMin": 103,
+    "totalFee": 200,
+    "actualPayFee": 0.0,
+    "thirdParkOrderNo": "4970704",
+    "createdByQrCode": false,
+    "totalFeeInYuan": 2.00
+  },
+  "discountInfo": {
+    "usingTotalDiscount": 10,
+    "memberLevelDiscount": true,
+    "memberGrade": [
+      {
+        "defaultSelected": true,
+        "memberGrade": "01",
+        "memberGradeText": "嘉友卡",
+        "discountTime": 1,
+        "discountFee": 10
+      }
+    ],
+    "points": [
+      {
+        "available": 10000,
+        "pointsPerUnit": 1200,
+        "unitAmount": 0,
+        "newMember": false,
+        "label": "10000积分可减免"
+      }
+    ],
+    "paperCoupons": [
+      {
+        "description": "纸质优惠券不限制会员使用。"
+      }
+    ]
+  },
+  "parkingRule": {
+    "maxOneTimeDiscountTime": 10,
+    "enableNewMemberPoints": false,
+    "enablePoints": true,
+    "enableCoupon": false,
+    "maxOneDayCoupons": 5,
+    "remainCoupons": 5,
+    "enablePaperCoupons": true,
+    "paperCouponsDescription": "纸质优惠券不限制会员使用。",
+    "enableConsume": false,
+    "enableConsumeSplit": false,
+    "maxConsumeTime": 0,
+    "remainConsumeTime": 0,
+    "hourPrice": 10,
+    "oneTimeLimitation": true,
+    "oneDayLimitation": false
+  },
+  "parkInfo": {
+    "parkName": "浦东嘉里停车场",
+    "description": "12元/小时。8-24小时封顶96元。纸质优惠券不限制使用数量。每次最多优惠2小时。积分兑换停车费用1200积分=1小时。积分商城售卖停车电子券的使用类型。单日累计消费满300元赠送1张消费600元赠2张1小时的停车券,不重复发券,消费跨天不累计,优惠有效期7天",
+    "parkMallCode": 1,
+    "buildingId": "PKC-P1"
+  }
+}

+ 4 - 0
src/components/uni-number-box/uni-number-box.vue

@@ -88,14 +88,17 @@ export default {
       if (this.disabled) {
         return;
       }
+      console.log(type, 91)
       const scale = this._getDecimalScale();
       let value = this.inputValue * scale;
       let step = this.step * scale;
       if (type === 'minus') {
         value -= step;
+        console.log(97, value , this.min * scale)
         if (value < this.min * scale) {
           return;
         }
+        console.log(101, value, this.max, scale)
         if (value > this.max * scale) {
           value = this.max * scale;
         }
@@ -108,6 +111,7 @@ export default {
           value = this.min * scale;
         }
       }
+      console.log(113, value, scale)
 
       this.inputValue = String(value / scale);
     },

+ 1 - 1
src/main.js

@@ -6,7 +6,7 @@ import VConsole from 'vconsole';
 // 或者使用配置参数来初始化,详情见文档
 // 开发环境和qa环境 打开debug
 const debug = /dev-t?-?|qa-t?-?|sl-t?-?/.test(window.location.href) || window.location.href.indexOf('8080') > -1;
-if (debug) {
+if (debug && false) {
   window.vConsole = new VConsole(
     // { theme: 'dark' }
   );

+ 14 - 3
src/pages/parkingFee/mixins/parkingFeeCoupon.js

@@ -270,7 +270,7 @@ export default {
     // 超限提示
     crossMessage() {
       const { parkMallCode } = this.orderDetail.parkInfo;
-      const { maxOneDayCoupons, maxonedaydiscountFee, remainConsumeTime, hourPrice, availableDiscountFee } = this.orderDetail.parkingRule;
+      const { maxOneDayCoupons, maxonedaydiscountFee, remainConsumeTime, hourPrice, availableDiscountFee, maxOneTimeDiscountTime } = this.orderDetail.parkingRule;
       const {
         usingTotalDiscount, // 使用总抵扣
         coupons,
@@ -281,9 +281,12 @@ export default {
       } = this.orderDetail.parkingRecord;
       // 剩余可使用的优惠金额,支持动态计算; 优惠时长,不可能全部使用,不能超过车费减去优惠的金额;不能超过单次的应付金额
       let remainPrice = remainConsumeTime * hourPrice;
-      if (remainPrice > actualPayFee) {
-        remainPrice = actualPayFee;
+      if (parkMallCode === 5) {
+        if (remainPrice > actualPayFee) {
+          remainPrice = actualPayFee;
+        }  
       }
+      
       // let totalFee = this.parkDiscountTotal.feeCopy;
       // totalFee += this.totalFee;
       // 电子券优惠金额总计
@@ -324,6 +327,14 @@ export default {
           icon: 'none',
         });
       }
+      // TODO: 浦东,单次上限提示, 后续 usingTotalDiscount 再减去 纸质优惠券的金额
+      if (parkMallCode === 1 && usingTotalDiscount >= maxOneTimeDiscountTime) {
+        return Toast({
+          message: `超出抵扣上限,每次最高可抵扣${maxOneTimeDiscountTime}小时`,
+          icon: 'none',
+        });
+      }
+      return false
     },
     // 确认
     confirm() {

+ 18 - 3
src/pages/parkingFee/mixins/parkingFeeDetail.js

@@ -62,6 +62,7 @@ export default {
       usePoints: (state) => state.order.usePoints,
       usePointsTime: (state) => state.order.usePointsTime,
       enableConsume: (state) => state.order.enableConsume,
+      memberLevelDiscount: (state) => state.order.memberLevelDiscount,
       unitAmount: (state) => state.order.unitAmount,
       unlicensedInfo: state => state.unlicensedInfo,
       endlessLoop: (state) => state.endlessLoop,
@@ -108,7 +109,7 @@ export default {
     // 前往支付
     async toPay() {
       const { parkingRecord, discountInfo = {}, parkingRule = {}} = this.orderDetail;
-      const { coupons, points } = discountInfo
+      const { coupons, points, memberGrade = [] } = discountInfo
       const { hourPrice } = parkingRule
       try {
         const params = {
@@ -127,6 +128,16 @@ export default {
             actualUsedDiscount: discountInfo?.usingTotalDiscount || 0, //实际优惠金额
           },
         };
+        // 会员等级减免
+        if ( memberGrade?.length && memberGrade[0].discountFee > 0 && memberGrade[0].hasOwnProperty('selected')? memberGrade[0].selected : memberGrade[0].defaultSelected) {
+          const {discountFee, discountTime} = memberGrade[0]
+          params.discountInfo.memberLevel = {
+            "discountTime": discountTime,
+            "discountFee": discountFee,
+            "memberGrade": memberGrade[0].memberGrade
+          }
+        }
+        
         // 积分
         if (points?.length && points[0].discountFee > 0) {
           // 15 兑换 5元
@@ -386,7 +397,7 @@ export default {
     },
     // 停车优惠
     discounts() {
-      if (!this.enableConsume && orderDetail.parkInfo.parkMallCode !== 2) {
+      if (!this.enableConsume && !this.memberLevelDiscount && this.orderDetail.parkInfo.parkMallCode !== 2) {
         return Toast({
           message: '暂无可用优惠',
         });
@@ -434,7 +445,11 @@ export default {
         path: 'parkingFeeCoupon',
       });
     },
-    paperCoupon() { },
+    paperCoupon() {
+      this.$router.push({
+        path: 'parkingFeePaperCoupon',
+      });
+    },
     duration() { },
     couponCount() { },
     // 重置倒计时

+ 116 - 22
src/pages/parkingFee/mixins/parkingFeeDiscounts.js

@@ -1,9 +1,10 @@
 import { mapState } from 'vuex';
 import uniNumberBox from '@/components/uni-number-box/uni-number-box.vue';
+import {cloneDeep} from 'lodash'
 import uni from '@/utils/uniHooks';
 // const app = getApp()
 export default {
-  components: { uniNumberBox },
+  components: {uniNumberBox},
   created() {
     // 超限提示
     this.crossMessage();
@@ -17,61 +18,154 @@ export default {
   data() {
     return {
       checkedList: [], // 已选优惠列表
-      memberLevelReduce:[],
+      oldCheckedList: [], // 已选优惠列表备份
+      isMember: true, // member
+      isReduces: true, // reduces
+      memberLevelReduce: [],
       memberGrade: {},
       consume: {},
       todayReduceDiscountMessage: '',
       isMemberDiscountDisabled: false,
+      maxDiscountTime: 0,
+      enableConsumeSplit: false,
+      maxReduceDiscount: 0,
+      reduceHours: 0,
     };
   },
   computed: {
     ...mapState({
       orderDetail: state => state.order.orderDetail,
-      custTypeId: (state) => state.custTypeId,
-      groupId: (state) => state.groupId,
+      custTypeId: ( state ) => state.custTypeId,
+      groupId: ( state ) => state.groupId,
       enableConsume: state => state.order.enableConsume,
       actualPayFee: state => state.order.actualPayFee,
       usingTotalDiscount: state => state.order.usingTotalDiscount,
       memberLevelDiscount: state => state.order.memberLevelDiscount,
+      checkedTotal: state => state.order.checkedTotal,
+      parkMallCode: state => state.order.parkMallCode,
     }),
   },
   mounted() {
-    this.pageInit();
+    try {
+      this.isCheck(
+        () => this.pageInit()
+      ); // 验证是否可选  
+    } catch ( err ) {
+      console.log(err)
+      this.$router.back();
+    }
   },
   methods: {
     pageInit() {
-      this.checkedList = []
-      const {memberGrade, consume, memberLevelDiscount} = this.orderDetail.discountInfo;
-      if (!memberLevelDiscount) {
-
+      if ( this.orderDetail?.parkingRule?.enableConsumeSplit ) {
+        this.enableConsumeSplit = this.orderDetail.parkingRule.enableConsumeSplit
       }
+     
+
+      this.checkedList = []
+      const {memberGrade = [],consume = [],memberLevelDiscount} = this.orderDetail.discountInfo;
       this.memberGrade = {...memberGrade[0]}
       this.consume = {...consume[0]}
-      if (memberGrade.length && memberGrade[0].defaultSelected) {
+      if ( JSON.stringify(this.memberGrade) !== '{}' && this.memberGrade.hasOwnProperty('selected') ? this.memberGrade.selected : this.memberGrade.defaultSelected && !this.isMember ) {
         this.checkedList.push('member')
       }
-      if (memberGrade.length && consume[0].defaultSelected) {
-
-        this.checkedList.push('reduces')
+      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
       }
-      console.log(44444, this.checkedList);
+      if ( this?.consume?.maxDiscountTime ) {
+        this.maxReduceDiscount = this.consume.maxDiscountTime
+      }
+      this.oldCheckedList = [...this.checkedList]
     },
     setIsMemberDiscountDisabled() {
       this.todayReduceDiscountMessage = '当日'
     },
-    actualFee() {},
-    discountFee() {},
-    confirm() {},
-    crossMessage() {},
+    confirm() {
+      let orderDetail = cloneDeep(this.orderDetail)
+      // 如果初次进来操作的跟原来的不一样则重新计算优惠
+      if ( this.checkedList.length !==  this.checkedTotal) {
+        ['member', 'reduces'].forEach(key => {
+          if ( key === 'member' ) {
+            this.memberGrade = {
+              ...this.memberGrade,
+              selected: this.checkedList.indexOf(key) > -1
+            }
+            orderDetail.discountInfo.memberGrade = [this.memberGrade]
+          }
+          if ( key === 'reduces' ) {
+            this.consume = {
+              ...this.consume,
+              discountTime: this.reduceHours,
+              selected: this.checkedList.indexOf(key) > -1
+            }
+            if ( this.consume.selected ) {
+              this.consume.discountFee = this.reduceHours * this.orderDetail.parkingRule.hourPrice
+            }
+            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
+        }
+        this.$store.dispatch('order/saveDiscounts', {orderDetail,  callback: () => this.$router.back()})
+      } else {
+        this.$router.back();
+      }
+    },
     checkboxChange() {},
-    parkInfoEntity() {},
-    isShowReduceDiscount() {},
     // todayReduceDiscountMessage() {},
     // 验证当前的选项是否可选择
-    isCheck(type) {
-
+    isCheck( callback ) {
+      const {parkInfo,parkingRule,discountInfo} = this.orderDetail
+      const {maxOneTimeDiscountTime,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)
+        this.isMember = !(this.usingTotalDiscount + remainConsumeTimeFee < maxOneTimeDiscountFee && this.memberLevelDiscount)
+        this.isReduces = !(this.usingTotalDiscount + remainConsumeTimeFee < maxOneTimeDiscountFee && this.enableConsume)
+      }
+      // if ( this.checkedTotal === 2 ) {
+      //   if ( this.checkedList.indexOf(type) > -1 ) {
+      //
+      //   } else {
+      //     // 未选中
+      //
+      //   }
+      // }
+      if ( callback ) callback()
+    },
+    reducesChange(value) {
+      console.log(value)
     },
+    crossMessage() {
 
+    }
   },
 
 };

+ 1 - 46
src/pages/parkingFee/mixins/parkingFeePaperCoupon.js

@@ -12,52 +12,7 @@ export default {
     fuiToast,
   },
   created() {
-    this.servicefee = uni.getStorageSync('servicefee'); // 应缴金额
-    this.parkDiscountTotal = uni.getStorageSync('parkingTotal'); // 总停车优惠
-
-    if (uni.getStorageSync('parkFee')) {
-      this.parkFee = JSON.parse(uni.getStorageSync('parkFee')); // discount接口返回的数据
-      this.parkMallCode = this.parkFee.parkInfoEntity.parkMallCode;
-      // 上限金额
-      this.maxonetimediscountFee =
-        this.parkFee.parkInfoEntity.maxonetimediscount *
-        this.parkFee.parkInfoEntity.needmoney;
-      this.maxonedaydiscountFee =
-        (this.parkFee.parkInfoEntity.maxOneDayHour -
-          this.parkFee.parkInfoEntity.ticketandMemeberGradeAndConsumeUseHour) *
-          this.parkFee.parkInfoEntity.needmoney || 0;
-      if (this.maxonedaydiscountFee < 0) {
-        this.maxonedaydiscountFee = 0;
-      }
-
-      // 纸质优惠券说明
-      if (
-        this.parkFee.parkPaperCouponsEntities &&
-        this.parkFee.parkPaperCouponsEntities[0]
-      ) {
-        this.parkPaperCouponRemark =
-          this.parkFee.parkPaperCouponsEntities[0].remark;
-      }
-    } else {
-      this.$router.replace({path: 'home'})
-      return
-    }
-
-    // 本页面数据缓存
-    this.paperCouponInfo = uni.getStorageSync('paperCouponInfo');
-    if (this.paperCouponInfo && this.paperCouponInfo.paperCouponList) {
-      // this.paperCouponList = this.paperCouponInfo.paperCouponList;
-
-      this.paperDiscountFee = this.paperCouponInfo.paperDiscountFee;
-      this.paperDiscountTime = this.paperCouponInfo.paperDiscountTime;
-      this.parkDiscountTotal.feeCopy -= this.paperCouponInfo.paperDiscountFee;
-    }
-    // this.paperCouponList = [
-    //   {
-    //     discountCode: '123456',
-    //     discountValueMoney: 10
-    //   }
-    // ];
+    
   },
   data() {
     return {

+ 8 - 5
src/pages/parkingFee/parkingFeeDetail.vue

@@ -29,7 +29,7 @@
         </div>
       </div>
       <div class="info-box mb--30">
-        <div class="info-item-box" v-if="enableConsume">
+        <div class="info-item-box" v-if="enableConsume || memberLevelDiscount">
           <div class="label">停车优惠</div>
           <div @click="discounts" :class="['value',discountDesc === '暂无可用优惠' ?  '' : 'text-red']">{{ discountDesc }}
             <van-icon name="arrow"/>
@@ -49,7 +49,7 @@
         </div>
         <div class="info-item-box" v-if="enablePaperCoupons">
           <div class="label">纸质优惠劵</div>
-          <div :class="['value', 'text-red']">扫描纸质优惠劵二维码
+          <div :class="['value', 'text-red']" @click="paperCoupon">扫描纸质优惠劵二维码
             <van-icon name="arrow"/>
           </div>
         </div>
@@ -58,7 +58,7 @@
           <div :class="['value']">-{{ usingTotalDiscount | currency }}</div>
         </div>
         <div class="van-hairline--bottom hr"></div>
-        <div class="info-item-box">
+        <div class="info-item-box npb">
           <div class="label pb--27">应付金额</div>
           <div class="value bold-fz">
             {{ actualPayFee | currency }}
@@ -229,10 +229,13 @@ export default {
   .info-item-box {
     display: flex;
     justify-content: space-between;
-
+    padding-bottom: 39px;
+    &.npb{
+      padding-bottom: 0;
+    }
     .label {
       padding-left: 36px;
-      padding-bottom: 39px;
+      //padding-bottom: 39px;
       text-align: left;
 
       font-family: 'PingFang SC';

+ 110 - 48
src/pages/parkingFee/parkingFeeDiscounts.vue

@@ -1,13 +1,13 @@
 <template>
-  <div>
-    <div scroll-y="true" :class="['scroll-Y', theme]">
+  <div :class="theme">
+    <div scroll-y="true" :class="['scroll-Y']">
       <van-checkbox-group v-model="checkedList" @change="checkboxChange" checked-color="#064C8A">
         <div class="container" v-if="memberLevelDiscount">
           <div class="item">
             <div class="title">会员等级减免</div>
             <div class="content">{{ memberGrade.memberGradeText || '' }}减免{{ memberGrade.discountTime || 0 }}小时。可优惠{{ memberGrade.discountFee || 0 }}元</div>
           </div>
-          <van-checkbox color="#fff" name="member" :disabled="isCheck('member')" />
+          <van-checkbox color="#fff" name="member" checked-color="var(--k-color-primary)" :disabled="isMember" />
           <!-- :checked="isCheck('member')" -->
           <div class="member-discount-info" v-if="isMemberDiscountDisabled">当日已使用</div>
         </div>
@@ -19,26 +19,42 @@
               {{ todayReduceDiscountMessage }}
             </div>
             <uni-number-box
-              v-if="parkInfoEntity.isSplit === 0 && maxReduceDiscount > 0"
+              v-if="enableConsumeSplit"
               :min="1"
               :max="maxReduceDiscount"
               v-model="reduceHours"
               @input="reducesChange"
             ></uni-number-box>
           </div>
-          <van-checkbox name="reduces" color="#fff" :disabled="isCheck('reduces')" />
-          <!-- :checked="isCheck('reduces')" -->
+          <van-checkbox name="reduces" color="#fff" checked-color="var(--k-color-primary)" :disabled="isReduces" />
         </div>
       </van-checkbox-group>
     </div>
     <div class="flewx">
-      <div class="flewx-content">
-        合计<span style="color: #333; font-weight: 600; font-size: 36px; padding-left: 0px">{{ actualPayFee | currency }}</span>
-        元
-        <span style="color: #999; padding-left: 0px; font-size: 28px">已优惠{{ usingTotalDiscount | currency }}元</span>
+      <div class="control-box">
+        <div class="flewx-content">
+          <div class="fee-box">
+            <div>合计:</div>
+            <div class="actualPayFee">{{
+                actualPayFee | currency
+              }}
+            </div>
+            <div :class="['van-hairline--surround','usingTotalDiscount', usingTotalDiscount > 0 && 'usingTotalDiscount-red']"
+            >已优惠{{ usingTotalDiscount | currency }}元
+            </div
+            >
+            <!-- <van-count-down :time="3 * 60 * 1000" /> -->
+          </div>
+        </div>
+        <div class="btn-box">
+          <k-button style="width: 100%;max-width: 240px" title="确定" disabledColor="#D1D2D9" @click="confirm"/>
+        </div>
+
       </div>
-      <div class="flewx_index3" @click="confirm">确定</div>
+      <!-- 开启底部安全区适配 -->
+      <van-number-keyboard safe-area-inset-bottom />
     </div>
+    
   </div>
 </template>
 
@@ -110,46 +126,92 @@ export default {
   }
 }
 
+/*页面底部操作区*/
 .flewx {
-  width: 100%;
-  height: 130px;
-  background-color: #fff;
   position: fixed;
   bottom: 0;
-  font-size: 30px;
-  display: flex;
-  align-items: center;
-  justify-content: space-around;
-  // padding-bottom: constant(safe-area-inset-bottom);
-  // padding-bottom: env(safe-area-inset-bottom);
-  padding-bottom: 20px;
-
-  .flewx-content {
-    position: absolute;
-    left: 16px;
-  }
-
-  .flewx_index3 {
-    width: 150px;
-    height: 70px;
-    border-radius: 45px;
-    text-align: center;
-    font-size: 30px;
-    line-height: 70px;
-    color: #fff;
-    // background-image: linear-gradient(to right, #7e4fa1, #433c7f);
-    background: #064c8a;
-    box-shadow: 2px 3px 5px #888888;
-    position: absolute;
-    right: 16px;
-  }
-
-  .blue_flewx_index3 {
-    .color-background-color('blue');
-  }
-
-  .green_flewx_index3 {
-    .color-background-color('green');
+  right: 0;
+  left: 0;
+  background-color: #fff;
+  .control-box {
+    width: 100%;
+    box-sizing: border-box;
+
+    display: flex;
+    align-content: flex-start;
+    align-items: center;
+    //padding-bottom: constant(safe-area-inset-bottom);
+    //padding-bottom: env(safe-area-inset-bottom);
+    padding: 30px 24px 30px 30px;
+    justify-content: space-between;
+    .flewx-content {
+      font-size: 28px;
+      .fee-box {
+        display: flex;
+        align-items: center;
+        justify-content: flex-start;
+      }
+
+      .actualPayFee {
+        color: #333;
+        font-size: 40px;
+      }
+
+      .usingTotalDiscount {
+        font-family: 'PingFang SC';
+        font-style: normal;
+        font-weight: 400;
+        font-size: 22px;
+        //height: 22px;
+        //line-height: 22px;
+        margin-left: 7px;
+        //border: 1px solid var(--k-color-red-01);
+        background-color: #F4F7FF;
+        border-radius: 2px;
+        &::after {
+          border-color: #999999;
+        }
+
+        color: #999999;
+        padding: 1px 3px;
+
+        &.usingTotalDiscount-red {
+          color: var(--k-color-red-01);
+          background-color: var(--k-color-red-06);
+          &::after {
+            border-color: var(--k-color-red-01);
+          }
+        }
+      }
+
+      .count-down-box {
+        display: flex;
+        font-weight: 400;
+        align-items: center;
+        color: var(--k-color-red-01);
+        font-family: 'PingFang SC';
+        font-style: normal;
+        font-weight: 400;
+        font-size: 26px;
+        margin-top: 5px;
+        .van-count-down {
+          font-size: 30px;
+          color: var(--k-color-red-01);
+        }
+
+        .desc {
+          font-size: 30px;
+
+        }
+      }
+    }
+    .btn-box {
+      display: flex;
+      justify-content: flex-end;
+      margin-left: 35px;
+      flex: 1;
+      max-width: 240px;
+    }
   }
 }
 

+ 1 - 1
src/store/index.js

@@ -5,7 +5,7 @@ import { crmQueryMemberInfo } from '@/utils/api-crm-member';
 import uni from '@/utils/uniHooks';
 import { kipAllCities,kipGetUserDetail,getVIPIntegral } from '@/utils/api-kip';
 import cachedViews from './cachedViews';
-import order from './order';
+import order from './order/index';
 import invoice from './invoice';
 import { lbsDictionary } from '@/common/js/BaseDictionary';
 import { getGroupIdAndMallIdByLsbId } from '@/utils';

+ 0 - 631
src/store/order.js

@@ -1,631 +0,0 @@
-import { checkOut, calculateDiscount, ordersAndPrepay, currentUnlicensedPlate, unlicensedCarCheckIn, unlicensedCarCheckout } from '@/api/parking';
-
-// import checkOutQHResponse from '@/api/mockData/checkout.qh3.response.json'
-// import checkOutQHResponse from '@/api/mockData/checkout.hz.response.json';
-import checkOutQHResponse from '@/api/mockData/checkout.pd1.response.json'
-// import unlicensedCarCheckInResponse from '@/api/mockData/unlicensedCarCheckIn.qh.response.json';
-
-/* 
-([a-z]*):(.*),
-state.$1 =$2;
- */
-// 大于等于停车费
-// 微服务接口字段
-const state = {
-  // 微服务接口字段
-  orderDetail: {}, // 订单原始数据
-  isShowDiscounts: false, // 是否展示会员登记优惠
-  discountDesc: '', // 停车优惠(首停、会员减免、消费减免)
-  checkedTotal: 0, // 选中count数
-  enableNewMemberPoints: false, // 是否开启新会员积分
-  enablePoints: false, // 是否开启积分减免
-  usePoints: 0, // 用户已选择的积分
-  isFirst: 0, // 判断用户是否首次进入
-  integralDesc: '', // 积分减免说明文案
-  pointsPerHour: 0, // 每小时兑换积分
-  enableCoupon: false, // 电子优惠券是否启用
-  maxOneDayCoupons: 0, // 单日可选优惠券上限
-  coupons: [], // 可选优惠券数量
-  couponCount: 0, // 已选择优惠券
-  couponDesc: '', // 优惠券说明文案
-  enablePaperCoupons: false, // 启动纸质优惠券
-  usingTotalDiscount: 0, // 优惠金额
-  actualPayFee: 0, // 应付金额
-  availableDiscountFee: 0, // 当日剩余可使用优惠金额
-  // 积分相关
-  available: 0, // 用户可用积分
-  maxPointsTime: '', // 积分最大兑换时长
-  pointsTime: '', // 已兑换的积分时间
-  unitAmount: 0,
-  // 停车优惠:会员等级和消费减免
-  memberLevelDiscount: false, // 是否开启会员等级
-  enableConsume: false, // 是否开启消费减免
-  pointsPerUnit: 0, //
-  // unlicensed: false // true: 临时车牌;false:普通车牌
-  // 无牌车逻辑
-  unlicensedCar: '',
-};
-
-const mutations = {
-  setOrderDetail(state, payload) {
-    state.orderDetail = payload;
-  },
-  setIsShowDiscounts(state, payload) {
-    state.isShowDiscounts = payload;
-  },
-  setCheckedTotal(state, payload) {
-    state.checkedTotal = payload;
-  },
-  setDiscountDesc(state, payload) {
-    state.discountDesc = payload;
-  },
-  setEnableNewMemberPoints(state, payload) {
-    state.enableNewMemberPoints = payload;
-  },
-  setEnablePoints(state, payload) {
-    state.enablePoints = payload;
-  },
-  setIsFirst(state, payload) {
-    state.isFirst = payload;
-  },
-  setIntegralDesc(state, payload) {
-    state.integralDesc = payload;
-  },
-  setUsePoints(state, payload) {
-    state.usePoints = payload;
-  },
-  setEnableCoupon(state, payload) {
-    state.enableCoupon = payload;
-  },
-  setMaxOneDayCoupons(state, payload) {
-    state.maxOneDayCoupons = payload;
-  },
-  setCoupons(state, payload) {
-    state.coupons = payload;
-  },
-  setCouponCount(state, payload) {
-    state.couponCount = payload;
-  },
-  setCouponDesc(state, payload) {
-    state.couponDesc = payload;
-  },
-  setEnablePaperCoupons(state, payload) {
-    state.enablePaperCoupons = payload;
-  },
-  setUsingTotalDiscount(state, payload) {
-    state.usingTotalDiscount = payload;
-  },
-  setActualPayFee(state, payload) {
-    state.actualPayFee = payload;
-  },
-  setAvailableDiscountFee(state, payload) {
-    state.availableDiscountFee = payload;
-  },
-  setPointsPerHour(state, payload) {
-    state.pointsPerHour = payload;
-  },
-  setAvailable(state, payload) {
-    state.available = payload;
-  },
-  setMaxPointsTime(state, payload) {
-    state.maxPointsTime = payload;
-  },
-  setPointsTime(state, payload) {
-    state.pointsTime = payload;
-  },
-  setEnableConsume(state, payload) {
-    state.enableConsume = payload;
-  },
-  setMemberLevelDiscount(state, payload) {
-    state.memberLevelDiscount = payload;
-  },
-  setPointsPerUnit(state, payload) {
-    state.pointsPerUnit = payload;
-  },
-  setMaxOneDayDiscountFee(state, payload) {
-    state.maxOneDayDiscountFee = payload;
-  },
-  setUnitAmount(state, payload) {
-    state.unitAmount = payload;
-  },
-  setMaxDiscountFee(state, payload) {
-    state.maxDiscountFee = payload;
-  },
-  setUnlicensedCar(state, payload) {
-    state.unlicensedCar = payload;
-  },
-  // 订单初始化
-  clearOrderInfo(state) {
-    state.orderDetail = {}; // 订单原始数据
-    state.isShowDiscounts = false; // 是否展示会员登记优惠
-    state.discountDesc = ''; // 停车优惠(首停、会员减免、消费减免)
-    state.checkedTotal = 0; // 选中count数
-    state.enableNewMemberPoints = false; // 是否开启新会员积分
-    state.enablePoints = false; // 是否开启积分减免
-    state.usePoints = 0; // 用户已选择的积分
-    state.isFirst = 0; // 判断用户是否首次进入
-    state.integralDesc = ''; // 积分减免说明文案
-    state.pointsPerHour = 0; // 每小时兑换积分
-    state.enableCoupon = false; // 电子优惠券是否启用
-    state.maxOneDayCoupons = 0; // 单日可选优惠券上限
-    state.coupons = []; // 可选优惠券数量
-    state.couponCount = 0; // 已选择优惠券
-    state.couponDesc = ''; // 优惠券说明文案
-    state.enablePaperCoupons = false; // 启动纸质优惠券
-    state.usingTotalDiscount = 0; // 优惠金额
-    state.actualPayFee = 0; // 应付金额
-    state.availableDiscountFee = 0; // 当日剩余可使用优惠金额
-    // 积分相关
-    state.available = 0; // 用户可用积分
-    state.maxPointsTime = ''; // 积分最大兑换时长
-    state.pointsTime = ''; // 已兑换的积分时间
-    state.unitAmount = 0;
-    // 停车优惠:会员等级和消费减免
-    state.memberLevelDiscount = false; // 是否开启会员等级
-    state.enableConsume = false; // 是否开启消费减免
-    state.pointsPerUnit = 0; //
-    // unlicensed: false // true: 临时车牌;false:普通车牌
-    // 无牌车逻辑
-    state.unlicensedCar = '';
-  }
-};
-
-const actions = {
-  /**
-   * 车辆订单的缴费信息初始化
-   * @param {*} param0
-   * @param {*} param1.gateId  车场闸机口ID
-   * @param {*} param1.vehicleNo  车牌号(包含临牌)
-   * @param {*} param1.callback  回调函数,用于接口报错时,展示对应的信息
-   * @param {*} param1.endlessLoop 用于判断当前用户是否扫码进入 
-   */
-  async orderInit({ commit, dispatch, state }, { gateId = '124p3LK1', vehicleNo = '浙A616A1', callback, endlessLoop }) {
-    try {
-      commit('clearOrderInfo');
-      const unlicensed = vehicleNo.indexOf('临') > -1 || !vehicleNo; // true: 临时车牌;false:普通车牌
-      // const res = await checkOut('浙A616A1');
-      // const res = await checkOut('闽AAQ5519', unlicensed);
-      // const res = await checkOut('粤A51113');
-      // const res = await checkOut('沪DCJ986');
-      // console.log('无牌车扫码出场', endlessLoop);
-      // 场内缴费,调 check-out 接口,
-      const method = unlicensed && endlessLoop || !vehicleNo ? unlicensedCarCheckout : checkOut
-      // const res = await method(vehicleNo, unlicensed, gateId);
-      const res = checkOutQHResponse
-      if (res?.parkingRecord?.totalFee <= 0) {
-        callback && callback({
-          unlicensed,
-          endlessLoop,
-          code: endlessLoop,
-          orderDetail: res,
-        }); // 统一处理错误原因
-        return
-      }
-      // console.log(vehicleNo, res);
-      // 所有的优惠时间长转为金额
-      console.log(112, '所有的优惠时间长转为金额');
-      // dispatch('orderInitRule', checkOutQHResponse);
-      dispatch('orderInitRule', res);
-    } catch (error) {
-      console.log('151151151151151', error);
-      /* if (/NOT_FOUND|PARKING_RECORD_NOT_FOUND/.test(error.code)) {
-        callback && callback(error)
-      } */
-      callback && callback(error); // 统一处理错误原因
-    }
-  },
-  orderInitRule({ commit, dispatch, state }, checkOutResponse) {
-    console.log(119, checkOutResponse);
-    // 记录buildingId
-    if (checkOutResponse?.parkInfo?.buildingId) {
-      window.localStorage.setItem('buildingId', checkOutResponse.parkInfo.buildingId);
-    }
-    commit('setOrderDetail', checkOutResponse);
-    const isShowDiscounts = checkOutResponse?.parkingRule?.enableCoupon || false;
-    // 是否展示优惠
-    commit('setIsShowDiscounts', isShowDiscounts);
-    if (checkOutResponse.parkingRule) {
-      // 会员等级减免
-      // 停车优惠(首停、会员减免、消费减免)
-      dispatch('getCheckedTotal', checkOutResponse);
-      // 是否开启新会员积分(hold)
-      commit('setEnableNewMemberPoints', checkOutResponse.parkingRule.enableNewMemberPoints);
-      // 积分减免
-      dispatch('pointsRule', checkOutResponse);
-      // dispatch('getIntegralDesc', checkOutResponse.parkingRule.enablePoints);
-      // 电子优惠券:是否启用
-      // 处理电子优惠券相关逻辑
-      dispatch('couponRule', checkOutResponse);
-      // 纸质优惠券(hold)
-      commit('setEnablePaperCoupons', checkOutResponse?.parkingRule?.enablePaperCoupons || false);
-      // 其他数据收集
-      commit('setUsingTotalDiscount', checkOutResponse?.discountInfo?.usingTotalDiscount || 0);
-      // console.log(191, checkOutResponse?.parkingRecord.hasOwnProperty(actualPayFee));
-    }
-    if (checkOutResponse?.parkingRecord?.hasOwnProperty('actualPayFee')) {
-      commit('setActualPayFee', checkOutResponse.parkingRecord?.actualPayFee);
-    } else {
-      commit('setActualPayFee', checkOutResponse.parkingRecord?.totalFeeInYuan);
-    }
-  },
-  // 停车优惠(首停、会员减免、消费减免)
-  getCheckedTotal({ commit, dispatch }, orderDetail) {
-    let checkedTotal = 0;
-    console.log(orderDetail);
-    if (orderDetail?.discountInfo?.memberLevelDiscount && orderDetail?.discountInfo?.memberGrade.length) {
-      orderDetail.discountInfo.memberGrade.forEach((elm) => {
-        if (elm.defaultSelected) {
-          checkedTotal++;
-        }
-      });
-    }
-    if (orderDetail?.discountInfo?.consume?.length) {
-      orderDetail.discountInfo.consume.forEach((elm) => {
-        if (elm.defaultSelected) {
-          checkedTotal++;
-        }
-      });
-    }
-    commit('setMemberLevelDiscount', orderDetail.discountInfo.memberLevelDiscount);
-    commit('setCheckedTotal', checkedTotal);
-    dispatch('getDiscountDesc', {
-      orderDetail,
-      checkedTotal,
-    });
-  },
-  getDiscountDesc({ commit, dispatch }, { orderDetail, checkedTotal }) {
-    if (orderDetail.parkingRule.enableConsume) {
-      commit('setEnableConsume', orderDetail.parkingRule.enableConsume);
-      if (checkedTotal > 0) {
-        return commit('setDiscountDesc', `已选择${checkedTotal}项优惠`);
-      }
-      return commit('setDiscountDesc', `立即使用`);
-    } else {
-      return commit('setDiscountDesc', `暂无可用优惠`);
-    }
-  },
-  // 积分相关计算(仅计算用户可使用的积分)
-  pointsRule({ commit, dispatch, state }, checkOutResponse) {
-    const { discountInfo, parkingRule, parkInfo } = checkOutResponse
-    const {
-      points,
-      usingTotalDiscount, // 当前车辆的已使用优惠的总上限
-    } = discountInfo;
-    const {
-      parkMallCode
-    } = parkInfo
-    const {
-      maxPointsTime = 0, // 最大积分
-      enablePoints,
-      availableDiscountFee,
-      maxOneDayDiscountFee, // 每日最大优惠金额(深圳车场)
-      remainConsumeTime, // 当前订单剩余可使用的优惠
-    } = parkingRule;
-    if ( !points ) return commit('setIntegralDesc', '暂无可用积分'); // 积分优惠处的描述
-    const [
-      {
-        pointsPerHour,
-        available, // 用户可用的积分(当前车辆在) available是用户选择抵扣N小时后剩余的可用积分
-        maxDiscountFee, // 单次上限(元)
-        unitAmount, // 兑换值(元)
-        pointsPerUnit = 0, // 500积分对应的价值
-        discountFee,
-        label,
-      },
-    ] = points;
-    commit('setAvailableDiscountFee', availableDiscountFee);
-    dispatch('maxPointsTimeMath', checkOutResponse) // 剩余积分可兑换上限
-    commit('setEnablePoints', enablePoints);
-    commit('setAvailable', available);
-    commit('setMaxPointsTime', maxPointsTime);
-    commit('setMaxDiscountFee', maxDiscountFee);
-    commit('setPointsTime', discountFee || 0);
-    commit('setPointsPerUnit', pointsPerUnit);
-    commit('setMaxOneDayDiscountFee', maxOneDayDiscountFee);
-    commit('setPointsPerHour', pointsPerUnit);
-    commit('setUnitAmount', unitAmount);
-    commit('setIntegralDesc', discountFee ? `已选择兑换${discountFee}元` : available > pointsPerUnit ? `${available}积分可减免` : `${pointsPerUnit}积分可停车1小时`); // 积分优惠处的描述
-  },
-  // 当前最大可选优惠时间
-  /*
-   * 当前最大可选优惠时间
-   * 1、不能超过积分上限
-   * 2、
-   * */
-  maxPointsTimeMath({ commit, dispatch, state }, checkOutResponse) {
-    const { discountInfo, parkingRule, parkInfo } = checkOutResponse
-    const { points: [{
-      available, // 用户可用的积分(当前车辆在) available是用户选择抵扣N小时后剩余的可用积分
-      unitAmount, // 兑换值(元)
-      pointsPerUnit = 0, // 500 积分对应的价值
-      discountFee,
-      maxDiscountFee,
-    }] } = discountInfo
-    const {
-      parkMallCode
-    } = parkInfo
-    // 总积分
-    const max = available / pointsPerUnit * unitAmount;
-    const timeNum = maxDiscountFee / unitAmount;
-    console.log(';999988888;', timeNum);
-
-    /**
-     * maxDiscountFee 单次最大可使用金额 
-     * availableDiscountFee 当日剩余可使用优惠金额
-     * available 当前用户的剩余积分,也可以说是可以抵扣的积分,如果有积分抵扣自动勾选,那么这个值=这个值-已勾选积分
-     *
-     */
-
-    // if ( !state.maxPointsTime ) {
-    //   commit('setMaxPointsTime', discountFee || max)
-    // }
-    // if (
-    //   parkInfo.parkMallCode === 3 &&
-    //   enablePoints && !maxPointsTime
-    // ) {
-    //   return commit('setIntegralDesc', `今日已达上限`);
-    // }
-    // return commit('setIntegralDesc', `${available}积分可减免`);
-  },
-
-  // 积分减免
-  pointsMath({ commit, dispatch, state }, { type, callback }) {
-    const {parkInfo, parkingRule} = state.orderDetail
-    const {maxOneTimeDiscountTime} = parkingRule
-    const {parkMallCode} = parkInfo
-    console.log(376, maxOneTimeDiscountTime, state.availableDiscountFee)
-    /**
-     * maxDiscountFee 单次最大可使用金额 
-     * availableDiscountFee 当日剩余可使用优惠金额
-     * available 当前用户的剩余积分,也可以说是可以抵扣的积分,如果有积分抵扣自动勾选,那么这个值=这个值-已勾选积分
-     */
-    // 计算用户当前的最大可使用积分的总数(单位:元)
-    let maxPointsTime = state.available / (state.pointsPerUnit / state.unitAmount) + state.pointsTime;
-    if (maxPointsTime > state.maxDiscountFee) {
-      maxPointsTime = state.maxDiscountFee
-    }
-    let msg = ''
-    // 验证最大积分的总数(单位:元)
-    if (maxPointsTime > state.availableDiscountFee) {
-      maxPointsTime = state.availableDiscountFee
-    }
-    console.log(392, state.pointsTime, maxPointsTime);
-    if ( parkMallCode === 5 ) {
-    if (type === 'add' && state.pointsTime >= maxPointsTime) {
-      
-        // 以下是深圳积分上限规则
-        // 超出抵扣上限,每日最高可抵扣${this.parkFee.parkInfoEntity.maxOneDayHour}元 '优惠金额' >= '每日最高可抵扣'
-        if (state.usingTotalDiscount >= state.maxOneDayDiscountFee && !msg) {
-          msg = `超出抵扣上限,每日最高可抵扣${state.maxOneDayDiscountFee}元`
-        }
-        // 超出抵扣上限,每次最高可抵扣${this.integralMaxMoney}元 '积分兑换时长' >= '深圳前海停车积分上限'q
-        if (state.pointsTime >= maxPointsTime && !msg) {
-          msg = `超出抵扣上限,每次最高可抵扣${state.maxDiscountFee}元`
-        }
-      }
-   
-      callback({
-        message: msg
-      });
-      return
-    }
-    if (type === 'add' && state.pointsTime < maxPointsTime) {
-      const pointsTime = state.pointsTime + state.unitAmount;
-      const available = state.available - state.pointsPerUnit;
-      const usingTotalDiscount = state.usingTotalDiscount + state.unitAmount; // 重新计算已经使用的优惠逻辑
-      if (available > -1) {
-        // 如果是深圳车场
-        commit('setAvailable', available);
-        commit('setPointsTime', pointsTime);
-        commit('setUsingTotalDiscount', usingTotalDiscount);
-      }
-    }
-    if (type === 'minus' && state.pointsTime > 0) {
-      const pointsTime = state.pointsTime - state.unitAmount;
-      // 如果是深圳车场
-      commit('setAvailable', state.available + state.pointsPerUnit);
-      commit('setPointsTime', pointsTime);
-    }
-  },
-  cancelPointsMath({ commit, dispatch, state }, callback) {
-    const {
-      discountInfo: { points },
-      parkingRule,
-    } = state.orderDetail;
-    if(!points) {
-      callback && callback();
-      return
-    }
-    const [{ pointsPerHour, available, discountFee }] = points;
-    const { maxPointsTime, enablePoints } = parkingRule;
-    commit('setAvailable', available);
-    commit('setPointsTime', discountFee || 0);
-    callback && callback();
-  },
-  async savePointsMath({ commit, dispatch, state }, callback) {
-    try {
-      const orderDetail = { ...state.orderDetail };
-      // 如果是重复提交,则不做重新计算
-      if (orderDetail.discountInfo.points[0].available === state.available) {
-        callback && callback();
-        return
-      }
-      // 计算积分修改之后的金额,返回给后端
-      // orderDetail.discountInfo.points[0].discountFee = state.pointsTime * orderDetail.discountInfo.points[0].unitAmount;
-      orderDetail.discountInfo.points[0].discountFee = state.pointsTime;
-      orderDetail.discountInfo.points[0].available = state.available;
-      orderDetail.discountInfo.points[0].selected = true;
-      /* 其他优惠统计 */
-      // 优惠券: 如果没有添加 selected 字段,则增加 selected; 默认取 defaultSelected;
-      if (orderDetail?.discountInfo?.hasOwnProperty('coupons') && !orderDetail?.discountInfo?.coupons[0]?.hasOwnProperty('selected')) {
-        orderDetail.discountInfo.coupons = orderDetail.discountInfo.coupons.map(elm => {
-          elm.selected = elm.defaultSelected || false;
-          return elm;
-        })
-      }
-      const res = await calculateDiscount({
-        ...orderDetail,
-      });
-      console.log('积分修改失败', { res });
-      dispatch('orderInitRule', res);
-      callback && callback();
-    } catch (err) {
-      console.log('积分修改失败!', err);
-      callback && callback();
-    }
-    //
-  },
-  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;
-    }
-    try {
-      const res = await calculateDiscount({
-        ...orderDetail,
-      });
-      dispatch('orderInitRule', res);
-      callback && callback();
-    } catch (err) {
-      console.log('积分修改失败!', err);
-      callback && callback();
-    }
-    // commit('setCoupons', checkOutResponse.discountInfo.coupons);
-  },
-  getIntegralDesc() {
-    // 自动勾选积分优惠
-    // 深圳是最大抵扣金额
-    // available
-    /*
-    if (this.duration > 0) {
-        // 深圳特殊处理(单位:金额)
-        if (this.parkMallCode === 5) {
-          return `已选择兑换${this.duration}元`;
-        }
-        return `已选择兑换${this.duration}小时`;
-      }
-      if (this.bonusCopy < this.integral) {
-        return `${this.integral}积分可停车1小时`;
-      }
-      if (
-        this.parkMallCode === 3 &&
-        this.member?.currnentintegral >= this.integral &&
-        !this.bonus
-      ) {
-        return `今日已达上限`;
-      }
-      return `${this.bonus}积分可减免`;
-    */
-  },
-  // 电子优惠券
-  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) => {
-        let aTime = new Date(`${a.expirationDate}`.replace(/-/g, '/'));
-        let bTime = new Date(`${b.expirationDate}`.replace(/-/g, '/'));
-        let aN = aTime.getTime(aTime) // 方法1
-        let bN = bTime.getTime(bTime) // 方法2
-        return aN - bN;
-      }
-      const coupons = checkOutResponse.discountInfo.coupons.sort(couponSort)
-      commit('setCoupons', coupons);
-      // 统计已选择优惠券
-      let couponCount = 0;
-      checkOutResponse.discountInfo.coupons.forEach((elm) => {
-        const selected = elm.hasOwnProperty('selected') ? elm.selected : elm.defaultSelected;
-        if (selected) {
-          couponCount++;
-        }
-      });
-      commit('setCouponCount', couponCount);
-      console.log(479, couponCount);
-      if (couponCount > 0) {
-        return commit('setCouponDesc', `已选择${couponCount}张优惠劵`);
-      } else {
-        if (checkOutResponse.discountInfo.coupons.length) {
-          return commit('setCouponDesc', `您有${checkOutResponse.discountInfo.coupons.length}张可用优惠劵`);
-        }
-        return commit('setCouponDesc', `暂无可用优惠券`);
-      }
-    } else {
-      commit('setCouponDesc', `暂无可用优惠券`);
-    }
-  },
-
-  // 无牌车逻辑
-  async unlicensedRule({ commit, dispatch, state }, callback) {
-    try {
-      // const res = await currentUnlicensedPlate(); // 无牌车查询
-      // const res = await unlicensedCarCheckIn({gateId: 1}); // 无牌车入场
-      /**
-       * CAR_NOT_FOUND 车场扫描道闸入口,发现无车
-       * CAR_HAS_PLATE 车场扫描道闸入口,发现有牌车
-       */
-      // const res = unlicensedCarCheckInResponse;
-      const res = await currentUnlicensedPlate();
-      console.log('无牌车的查询记录', res);
-      commit('setUnlicensedCar', res.vehicleNo);
-      // 如果是扫码进入的用户,在出场时需要重新扫码,这时会在此处传入的一个回调函数,在获取到临牌时,返回给 qrCodesRule 函数
-      if (res.vehicleNo && callback) {
-        callback(res.vehicleNo);
-      } else {
-        callback('error');
-      }
-    } catch (err) {
-      console.log(err);
-    }
-  },
-
-  // 是否展示优惠
-  // getIsShowDiscounts({commit, dispatch}, orderDetail) {
-  //   params?.parkingRule?.enableCoupon
-  // }
-  // calculateDiscount
-
-  /*
-   如果积分发生变化
-   */
-
-};
-
-export default {
-  //开启命名模块
-  namespaced: true,
-  state: state,
-  mutations,
-  actions,
-};

+ 3 - 0
src/store/order/consume.js

@@ -0,0 +1,3 @@
+export default {
+  
+}

+ 88 - 0
src/store/order/coupon.js

@@ -0,0 +1,88 @@
+import { checkOut,calculateDiscount,ordersAndPrepay,currentUnlicensedPlate,unlicensedCarCheckIn,unlicensedCarCheckout } from '@/api/parking';
+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 ) => {
+        let aTime = new Date(`${ a.expirationDate }`.replace(/-/g,'/'));
+        let bTime = new Date(`${ b.expirationDate }`.replace(/-/g,'/'));
+        let aN = aTime.getTime(aTime) // 方法1
+        let bN = bTime.getTime(bTime) // 方法2
+        return aN - bN;
+      }
+      const coupons = checkOutResponse.discountInfo.coupons.sort(couponSort)
+      commit('setCoupons',coupons);
+      // 统计已选择优惠券
+      let couponCount = 0;
+      checkOutResponse.discountInfo.coupons.forEach(( elm ) => {
+        const selected = elm.hasOwnProperty('selected') ? elm.selected : elm.defaultSelected;
+        if ( selected ) {
+          couponCount++;
+        }
+      });
+      commit('setCouponCount',couponCount);
+      console.log(479,couponCount);
+      if ( couponCount > 0 ) {
+        return commit('setCouponDesc',`已选择${ couponCount }张优惠劵`);
+      } else {
+        if ( checkOutResponse.discountInfo.coupons.length ) {
+          return commit('setCouponDesc',`您有${ checkOutResponse.discountInfo.coupons.length }张可用优惠劵`);
+        }
+        return commit('setCouponDesc',`暂无可用优惠券`);
+      }
+    } else {
+      commit('setCouponDesc',`暂无可用优惠券`);
+    }
+  },
+  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;
+    }
+    try {
+      const res = await calculateDiscount({
+        ...orderDetail,
+      });
+      dispatch('orderInitRule',res);
+      callback && callback();
+    } catch ( err ) {
+      console.log('积分修改失败!',err);
+      callback && callback();
+    }
+    // commit('setCoupons', checkOutResponse.discountInfo.coupons);
+  },
+}

+ 110 - 0
src/store/order/index.js

@@ -0,0 +1,110 @@
+import checkOutQHResponse from "@/api/mockData/checkout.pd5.response.json";
+import { checkOut,calculateDiscount,ordersAndPrepay,currentUnlicensedPlate,unlicensedCarCheckIn,unlicensedCarCheckout } from '@/api/parking';
+import state from "@/store/order/state";
+import mutations from "@/store/order/mutations";
+import memberLevel from "@/store/order/memberLevel";
+import points from "@/store/order/points";
+import coupon from "@/store/order/coupon";
+import consume from "@/store/order/consume";
+import unlicensed from "@/store/order/unlicensed";
+
+export default {
+  //开启命名模块
+  namespaced: true,
+  state: state,
+  mutations,
+  actions: {
+    /**
+     * 车辆订单的缴费信息初始化
+     * @param commit
+     * @param dispatch
+     * @param state
+     * @param gateId      车场闸机口ID
+     * @param vehicleNo   车牌号(包含临牌)
+     * @param callback    回调函数,用于接口报错时,展示对应的信息
+     * @param endlessLoop 用于判断当前用户是否扫码进入
+     */
+    async orderInit( {commit,dispatch,state},{gateId = '124p3LK1',vehicleNo = '浙A616A1',callback,endlessLoop} ) {
+      try {
+        commit('clearOrderInfo');
+        const unlicensed = vehicleNo.indexOf('临') > -1 || !vehicleNo; // true: 临时车牌;false:普通车牌
+        // const res = await checkOut('浙A616A1');
+        // const res = await checkOut('闽AAQ5519', unlicensed);
+        // const res = await checkOut('粤A51113');
+        // const res = await checkOut('沪DCJ986');
+        // console.log('无牌车扫码出场', endlessLoop);
+        // 场内缴费,调 check-out 接口,
+        const method = unlicensed && endlessLoop || !vehicleNo ? unlicensedCarCheckout : checkOut
+        const res = await method(vehicleNo, unlicensed, gateId);
+        // const res = checkOutQHResponse
+        if ( res?.parkingRecord?.totalFee <= 0 ) {
+          callback && callback({
+            unlicensed,
+            endlessLoop,
+            code: endlessLoop,
+            orderDetail: res,
+          }); // 统一处理错误原因
+          return
+        }
+        // console.log(vehicleNo, res);
+        // 所有的优惠时间长转为金额
+        console.log(112,'所有的优惠时间长转为金额');
+        // dispatch('orderInitRule', checkOutQHResponse);
+        dispatch('orderInitRule',res);
+      } catch ( error ) {
+        console.log('151151151151151',error);
+        /* if (/NOT_FOUND|PARKING_RECORD_NOT_FOUND/.test(error.code)) {
+         callback && callback(error)
+         } */
+        callback && callback(error); // 统一处理错误原因
+      }
+    },
+    orderInitRule( {commit,dispatch,state},checkOutResponse ) {
+      console.log(119,checkOutResponse);
+      // 记录buildingId
+      if ( checkOutResponse?.parkInfo?.buildingId ) {
+        window.localStorage.setItem('buildingId',checkOutResponse.parkInfo.buildingId);
+      }
+      commit('setParkMallCode', checkOutResponse.parkInfo.parkMallCode)
+      commit('setOrderDetail',checkOutResponse);
+      const isShowDiscounts = checkOutResponse?.parkingRule?.enableCoupon || false;
+      // 是否展示优惠
+      commit('setIsShowDiscounts',isShowDiscounts);
+      if ( checkOutResponse.parkingRule ) {
+        // 会员等级减免
+        // 停车优惠(首停、会员减免、消费减免)
+        dispatch('getCheckedTotal',checkOutResponse);
+        // 是否开启新会员积分(hold)
+        commit('setEnableNewMemberPoints',checkOutResponse.parkingRule.enableNewMemberPoints);
+        // 积分减免
+        dispatch('pointsRule',checkOutResponse);
+        // dispatch('getIntegralDesc', checkOutResponse.parkingRule.enablePoints);
+        // 电子优惠券:是否启用
+        // 处理电子优惠券相关逻辑
+        dispatch('couponRule',checkOutResponse);
+        // 纸质优惠券(hold)
+        commit('setEnablePaperCoupons',checkOutResponse?.parkingRule?.enablePaperCoupons || false);
+        // 其他数据收集
+        commit('setUsingTotalDiscount',checkOutResponse?.discountInfo?.usingTotalDiscount || 0);
+        // console.log(191, checkOutResponse?.parkingRecord.hasOwnProperty(actualPayFee));
+      }
+      if ( checkOutResponse?.parkingRecord?.hasOwnProperty('actualPayFee') ) {
+        commit('setActualPayFee',checkOutResponse.parkingRecord?.actualPayFee);
+      } else {
+        commit('setActualPayFee',checkOutResponse.parkingRecord?.totalFeeInYuan);
+      }
+    },
+    // 会员等级
+    ...memberLevel,
+    // 消费减免
+    ...consume,
+    // 积分
+    ...points,
+    // 电子券
+    ...coupon,
+    // 无牌车
+    ...unlicensed,
+    // 纸质优惠券
+
+  },
+};

+ 56 - 0
src/store/order/memberLevel.js

@@ -0,0 +1,56 @@
+import { checkOut,calculateDiscount,ordersAndPrepay,currentUnlicensedPlate,unlicensedCarCheckIn,unlicensedCarCheckout } from '@/api/parking';
+export default {
+  // 停车优惠(首停、会员减免、消费减免)
+  getCheckedTotal( {commit,dispatch},orderDetail ) {
+    let checkedTotal = 0;
+    console.log(254, orderDetail);
+    if ( orderDetail?.discountInfo?.memberLevelDiscount && orderDetail?.discountInfo?.memberGrade.length ) {
+
+      orderDetail.discountInfo.memberGrade.forEach(( elm ) => {
+        if ( elm.hasOwnProperty('selected') ? elm.selected : elm.defaultSelected ) {
+          checkedTotal++;
+        }
+      });
+    }
+    if ( orderDetail?.discountInfo?.consume?.length ) {
+      orderDetail.discountInfo.consume.forEach(( elm ) => {
+        if ( elm.hasOwnProperty('selected') ? elm.selected : elm.defaultSelected ) {
+          checkedTotal++;
+        }
+      });
+    }
+    console.log(22, checkedTotal)
+    commit('setMemberLevelDiscount',orderDetail.discountInfo.memberLevelDiscount);
+    commit('setCheckedTotal',checkedTotal);
+    dispatch('getDiscountDesc',{
+      orderDetail,
+      checkedTotal,
+    });
+  },
+  getDiscountDesc( {commit,dispatch},{orderDetail,checkedTotal} ) {
+    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 }项优惠`);
+      }
+      return commit('setDiscountDesc',`立即使用`);
+    } else {
+      return commit('setDiscountDesc',`暂无可用优惠`);
+    }
+  },
+  async saveDiscounts({commit,dispatch},{orderDetail,callback}) {
+    try {
+      const res = await calculateDiscount({
+        ...orderDetail,
+      });
+      console.log(48, res)
+      dispatch('orderInitRule',res);
+      callback && callback();
+    } catch ( err ) {
+      console.log('优惠修改失败!',err);
+      callback && callback();
+    }
+  }
+}

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

@@ -0,0 +1,128 @@
+export default {
+  setOrderDetail( state,payload ) {
+    state.orderDetail = payload;
+  },
+  setIsShowDiscounts( state,payload ) {
+    state.isShowDiscounts = payload;
+  },
+  setCheckedTotal( state,payload ) {
+    state.checkedTotal = payload;
+  },
+  setDiscountDesc( state,payload ) {
+    state.discountDesc = payload;
+  },
+  setEnableNewMemberPoints( state,payload ) {
+    state.enableNewMemberPoints = payload;
+  },
+  setEnablePoints( state,payload ) {
+    state.enablePoints = payload;
+  },
+  setIsFirst( state,payload ) {
+    state.isFirst = payload;
+  },
+  setIntegralDesc( state,payload ) {
+    state.integralDesc = payload;
+  },
+  setUsePoints( state,payload ) {
+    state.usePoints = payload;
+  },
+  setEnableCoupon( state,payload ) {
+    state.enableCoupon = payload;
+  },
+  setMaxOneDayCoupons( state,payload ) {
+    state.maxOneDayCoupons = payload;
+  },
+  setCoupons( state,payload ) {
+    state.coupons = payload;
+  },
+  setCouponCount( state,payload ) {
+    state.couponCount = payload;
+  },
+  setCouponDesc( state,payload ) {
+    state.couponDesc = payload;
+  },
+  setEnablePaperCoupons( state,payload ) {
+    state.enablePaperCoupons = payload;
+  },
+  setUsingTotalDiscount( state,payload ) {
+    state.usingTotalDiscount = payload;
+  },
+  setActualPayFee( state,payload ) {
+    state.actualPayFee = payload;
+  },
+  setAvailableDiscountFee( state,payload ) {
+    state.availableDiscountFee = payload;
+  },
+  setPointsPerHour( state,payload ) {
+    state.pointsPerHour = payload;
+  },
+  setAvailable( state,payload ) {
+    state.available = payload;
+  },
+  setMaxPointsTime( state,payload ) {
+    state.maxPointsTime = payload;
+  },
+  setPointsTime( state,payload ) {
+    state.pointsTime = payload;
+  },
+  setEnableConsume( state,payload ) {
+    state.enableConsume = payload;
+  },
+  setMemberLevelDiscount( state,payload ) {
+    state.memberLevelDiscount = payload;
+  },
+  setPointsPerUnit( state,payload ) {
+    state.pointsPerUnit = payload;
+  },
+  setMaxOneDayDiscountFee( state,payload ) {
+    state.maxOneDayDiscountFee = payload;
+  },
+  setUnitAmount( state,payload ) {
+    state.unitAmount = payload || 1;
+  },
+  setMaxDiscountFee( state,payload ) {
+    state.maxDiscountFee = payload;
+  },
+  setUnlicensedCar( state,payload ) {
+    state.unlicensedCar = payload;
+  },
+  setParkMallCode( state,payload ) {
+    state.parkMallCode = payload;
+  },
+  // 订单初始化
+  clearOrderInfo( state ) {
+    state.orderDetail = {}; // 订单原始数据
+    state.isShowDiscounts = false; // 是否展示会员登记优惠
+    state.discountDesc = ''; // 停车优惠(首停、会员减免、消费减免)
+    state.checkedTotal = 0; // 选中count数
+    state.enableNewMemberPoints = false; // 是否开启新会员积分
+    state.enablePoints = false; // 是否开启积分减免
+    state.usePoints = 0; // 用户已选择的积分
+    state.isFirst = 0; // 判断用户是否首次进入
+    state.integralDesc = ''; // 积分减免说明文案
+    state.pointsPerHour = 0; // 每小时兑换积分
+    state.enableCoupon = false; // 电子优惠券是否启用
+    state.maxOneDayCoupons = 0; // 单日可选优惠券上限
+    state.coupons = []; // 可选优惠券数量
+    state.couponCount = 0; // 已选择优惠券
+    state.couponDesc = ''; // 优惠券说明文案
+    state.enablePaperCoupons = false; // 启动纸质优惠券
+    state.usingTotalDiscount = 0; // 优惠金额
+    state.actualPayFee = 0; // 应付金额
+    state.availableDiscountFee = 0; // 当日剩余可使用优惠金额
+    // 积分相关
+    state.available = 0; // 用户可用积分
+    state.maxPointsTime = ''; // 积分最大兑换时长
+    state.pointsTime = ''; // 已兑换的积分时间
+    state.unitAmount = 1;
+    // 停车优惠:会员等级和消费减免
+    state.memberLevelDiscount = false; // 是否开启会员等级
+    state.enableConsume = false; // 是否开启消费减免
+    state.pointsPerUnit = 0; //
+    // unlicensed: false // true: 临时车牌;false:普通车牌
+    // 无牌车逻辑
+    state.unlicensedCar = '';
+    // 车场相关
+    state.parkMallCode = '' // 车场唯一编号
+  }
+};

+ 280 - 0
src/store/order/points.js

@@ -0,0 +1,280 @@
+import { checkOut,calculateDiscount,ordersAndPrepay,currentUnlicensedPlate,unlicensedCarCheckIn,unlicensedCarCheckout } from '@/api/parking';
+
+export default {
+
+  // 积分相关计算(仅计算用户可使用的积分)
+  pointsRule( {commit,dispatch,state},checkOutResponse ) {
+    const {discountInfo,parkingRule,parkInfo} = checkOutResponse
+    const {
+      points,
+      usingTotalDiscount, // 当前车辆的已使用优惠的总上限
+    } = discountInfo;
+    const {
+      parkMallCode
+    } = parkInfo
+    const {
+      maxPointsTime = 0, // 最大积分
+      enablePoints,
+      availableDiscountFee,
+      maxOneDayDiscountFee, // 每日最大优惠金额(深圳车场)
+      remainConsumeTime, // 当前订单剩余可使用的优惠
+    } = parkingRule;
+    if ( !points ) return commit('setIntegralDesc','暂无可用积分'); // 积分优惠处的描述
+    const [
+      {
+        pointsPerHour,
+        available, // 用户可用的积分(当前车辆在) available是用户选择抵扣N小时后剩余的可用积分
+        maxDiscountFee, // 单次上限(元)
+        unitAmount, // 兑换值(元)
+        pointsPerUnit = 0, // 500积分对应的价值
+        discountFee,
+        label,
+      },
+    ] = points;
+    commit('setAvailableDiscountFee',availableDiscountFee);
+    dispatch('maxPointsTimeMath',checkOutResponse) // 剩余积分可兑换上限
+    commit('setEnablePoints',enablePoints);
+    commit('setAvailable',available);
+    commit('setMaxPointsTime',maxPointsTime);
+    commit('setMaxDiscountFee',maxDiscountFee);
+    commit('setPointsTime',discountFee || 0);
+    commit('setPointsPerUnit',pointsPerUnit);
+    commit('setMaxOneDayDiscountFee',maxOneDayDiscountFee);
+    commit('setPointsPerHour',pointsPerUnit);
+    commit('setUnitAmount',unitAmount);
+    commit('setIntegralDesc',discountFee ? `已选择兑换${ discountFee }元` : available > pointsPerUnit ? `${ available }积分可减免` : `${ pointsPerUnit }积分可停车1小时`); // 积分优惠处的描述
+  },
+  // 当前最大可选优惠时间
+  /*
+   * 当前最大可选优惠时间
+   * 1、不能超过积分上限
+   * 2、
+   * */
+  maxPointsTimeMath( {commit,dispatch,state},checkOutResponse ) {
+    const {discountInfo,parkingRule,parkInfo} = checkOutResponse
+    const {
+      points: [{
+        available, // 用户可用的积分(当前车辆在) available是用户选择抵扣N小时后剩余的可用积分
+        unitAmount, // 兑换值(元)
+        pointsPerUnit = 0, // 500 积分对应的价值
+        discountFee,
+        maxDiscountFee,
+      }]
+    } = discountInfo
+    const {
+      parkMallCode
+    } = parkInfo
+    // 总积分
+    const max = available / pointsPerUnit * unitAmount;
+    const timeNum = maxDiscountFee / unitAmount;
+    console.log(';999988888;',timeNum);
+
+    /**
+     * maxDiscountFee 单次最大可使用金额
+     * availableDiscountFee 当日剩余可使用优惠金额
+     * available 当前用户的剩余积分,也可以说是可以抵扣的积分,如果有积分抵扣自动勾选,那么这个值=这个值-已勾选积分
+     *
+     */
+
+    // if ( !state.maxPointsTime ) {
+    //   commit('setMaxPointsTime', discountFee || max)
+    // }
+    // if (
+    //   parkInfo.parkMallCode === 3 &&
+    //   enablePoints && !maxPointsTime
+    // ) {
+    //   return commit('setIntegralDesc', `今日已达上限`);
+    // }
+    // return commit('setIntegralDesc', `${available}积分可减免`);
+  },
+  // 积分减免
+  pointsMath( {commit,dispatch,state},{type,callback} ) {
+    const {parkInfo,parkingRule} = state.orderDetail
+    const {maxOneTimeDiscountTime,oneTimeLimitation,oneDayLimitation,hourPrice,remainConsumeTime} = parkingRule
+    const {parkMallCode} = parkInfo
+    console.log(376,maxOneTimeDiscountTime,state.availableDiscountFee)
+    /**
+     * maxDiscountFee 单次最大可使用金额
+     * availableDiscountFee 当日剩余可使用优惠金额
+     * available 当前用户的剩余积分,也可以说是可以抵扣的积分,如果有积分抵扣自动勾选,那么这个值=这个值-已勾选积分
+     */
+      // 计算用户当前的最大可使用积分的总数(单位:元)
+    let maxPointsTime = state.available / ( state.pointsPerUnit / state.unitAmount ) + state.pointsTime;
+    if ( maxPointsTime > state.maxDiscountFee ) {
+      maxPointsTime = state.maxDiscountFee
+    }
+    let msg = ''
+    // 验证最大积分的总数(单位:元)
+    if ( maxPointsTime > state.availableDiscountFee ) {
+      maxPointsTime = state.availableDiscountFee
+    }
+    console.log(392,state.pointsTime,maxPointsTime,parkMallCode);
+    if ( parkMallCode === 5 ) {
+      if ( type === 'add' && state.pointsTime >= maxPointsTime ) {
+        // 以下是深圳积分上限规则
+        // 超出抵扣上限,每日最高可抵扣${this.parkFee.parkInfoEntity.maxOneDayHour}元 '优惠金额' >= '每日最高可抵扣'
+        if ( state.usingTotalDiscount >= state.maxOneDayDiscountFee && !msg ) {
+          msg = `超出抵扣上限,每日最高可抵扣${ state.maxOneDayDiscountFee }元`
+        }
+        // 超出抵扣上限,每次最高可抵扣${this.integralMaxMoney}元 '积分兑换时长' >= '深圳前海停车积分上限'q
+        if ( state.pointsTime >= maxPointsTime && !msg ) {
+          msg = `超出抵扣上限,每次最高可抵扣${ state.maxDiscountFee }元`
+        }
+      }
+    }
+    // 单日上限限制
+    if ( oneDayLimitation && !msg ) {
+      const maxOneTimeDiscountFee = maxOneTimeDiscountTime * hourPrice
+      const remainConsumeTimeFee = remainConsumeTime * hourPrice
+      // 计算单日剩余 remainConsumeTime
+      // 当前使用优惠 state.usingTotalDiscount
+      // 判断符合上限 
+
+      // 浦东积分上限判断
+      if ( parkMallCode === 1 && type === 'add' && state.usingTotalDiscount + remainConsumeTimeFee <= maxOneTimeDiscountFee ) {
+        msg = `超出抵扣上限,每次最高可抵扣${ maxOneTimeDiscountTime }小时`
+      }
+    }
+    // 单次上限限制
+    if ( oneTimeLimitation && !msg ) {
+      const maxOneTimeDiscountFee = maxOneTimeDiscountTime * hourPrice
+      const remainConsumeTimeFee = remainConsumeTime * hourPrice
+      // 计算单日剩余 remainConsumeTime
+      // 当前使用优惠 state.usingTotalDiscount
+      // 判断符合上限 
+
+      // 浦东积分上限判断
+      if ( parkMallCode === 1 && type === 'add' && state.usingTotalDiscount + remainConsumeTimeFee <= maxOneTimeDiscountFee ) {
+        msg = `超出抵扣上限,每次最高可抵扣${ maxOneTimeDiscountTime }小时`
+      }
+    }
+    console.log(434,msg)
+    if ( msg && false ) {
+      callback({
+        message: msg
+      });
+      return
+    }
+    console.log(158,state.pointsTime,remainConsumeTime);
+    // 计算浦东的上限
+    // if ( type === 'add' && state.pointsTime < remainConsumeTime ) {
+    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);
+        commit('setPointsTime',pointsTime);
+        commit('setUsingTotalDiscount',usingTotalDiscount);
+      }
+    }
+    if ( type === 'minus' && state.pointsTime > 0 ) {
+      const pointsTime = state.pointsTime - state.unitAmount;
+      // 如果是深圳车场
+      commit('setAvailable',state.available + state.pointsPerUnit);
+      commit('setPointsTime',pointsTime);
+    }
+  },
+  cancelPointsMath( {commit,dispatch,state},callback ) {
+    const {
+      discountInfo: {points},
+      parkingRule,
+    } = state.orderDetail;
+    if ( !points ) {
+      callback && callback();
+      return
+    }
+    const [{pointsPerHour,available,discountFee}] = points;
+    const {maxPointsTime,enablePoints} = parkingRule;
+    commit('setAvailable',available);
+    commit('setPointsTime',discountFee || 0);
+    callback && callback();
+  },
+  async savePointsMath( {commit,dispatch,state},callback ) {
+    try {
+      let orderDetail = {...state.orderDetail};
+      // 如果是重复提交,则不做重新计算
+      if ( orderDetail.discountInfo.points[0].available === state.available ) {
+        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
+        }]
+      }
+      // 计算积分修改之后的金额,返回给后端
+      // orderDetail.discountInfo.points[0].discountFee = state.pointsTime * orderDetail.discountInfo.points[0].unitAmount;
+      orderDetail.discountInfo.points[0].discountFee = state.pointsTime;
+      orderDetail.discountInfo.points[0].available = state.available;
+      orderDetail.discountInfo.points[0].selected = true;
+      /* 其他优惠统计 */
+      // 优惠券: 如果没有添加 selected 字段,则增加 selected; 默认取 defaultSelected;
+      if ( orderDetail?.discountInfo?.hasOwnProperty('coupons') && !orderDetail?.discountInfo?.coupons[0]?.hasOwnProperty('selected') ) {
+        orderDetail.discountInfo.coupons = orderDetail.discountInfo.coupons.map(elm => {
+          elm.selected = elm.defaultSelected || false;
+          return elm;
+        })
+      }
+      const res = await calculateDiscount({
+        ...orderDetail,
+      });
+      console.log('积分修改失败',{res});
+      dispatch('orderInitRule',res);
+      callback && callback();
+    } catch ( err ) {
+      console.log('积分修改失败!',err);
+      callback && callback();
+    }
+    //
+  },
+
+  getIntegralDesc() {
+    // 自动勾选积分优惠
+    // 深圳是最大抵扣金额
+    // available
+    /*
+     if (this.duration > 0) {
+     // 深圳特殊处理(单位:金额)
+     if (this.parkMallCode === 5) {
+     return `已选择兑换${this.duration}元`;
+     }
+     return `已选择兑换${this.duration}小时`;
+     }
+     if (this.bonusCopy < this.integral) {
+     return `${this.integral}积分可停车1小时`;
+     }
+     if (
+     this.parkMallCode === 3 &&
+     this.member?.currnentintegral >= this.integral &&
+     !this.bonus
+     ) {
+     return `今日已达上限`;
+     }
+     return `${this.bonus}积分可减免`;
+     */
+  },
+}

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

@@ -0,0 +1,36 @@
+export default  {
+  // 微服务接口字段
+  orderDetail: {}, // 订单原始数据
+  isShowDiscounts: false, // 是否展示会员登记优惠
+  discountDesc: '', // 停车优惠(首停、会员减免、消费减免)
+  checkedTotal: 0, // 选中count数
+  enableNewMemberPoints: false, // 是否开启新会员积分
+  enablePoints: false, // 是否开启积分减免
+  usePoints: 0, // 用户已选择的积分
+  isFirst: 0, // 判断用户是否首次进入
+  integralDesc: '', // 积分减免说明文案
+  pointsPerHour: 0, // 每小时兑换积分
+  enableCoupon: false, // 电子优惠券是否启用
+  maxOneDayCoupons: 0, // 单日可选优惠券上限
+  coupons: [], // 可选优惠券数量
+  couponCount: 0, // 已选择优惠券
+  couponDesc: '', // 优惠券说明文案
+  enablePaperCoupons: false, // 启动纸质优惠券
+  usingTotalDiscount: 0, // 优惠金额
+  actualPayFee: 0, // 应付金额
+  availableDiscountFee: 0, // 当日剩余可使用优惠金额
+  // 积分相关
+  available: 0, // 用户可用积分
+  maxPointsTime: '', // 积分最大兑换时长
+  pointsTime: '', // 已兑换的积分时间
+  unitAmount: 1,
+  // 停车优惠:会员等级和消费减免
+  memberLevelDiscount: false, // 是否开启会员等级
+  enableConsume: false, // 是否开启消费减免
+  pointsPerUnit: 0, //
+  // unlicensed: false // true: 临时车牌;false:普通车牌
+  // 无牌车逻辑
+  unlicensedCar: '',
+  // 车场相关
+  parkMallCode: '' // 车场唯一编号
+}

+ 27 - 0
src/store/order/unlicensed.js

@@ -0,0 +1,27 @@
+import { checkOut,calculateDiscount,ordersAndPrepay,currentUnlicensedPlate,unlicensedCarCheckIn,unlicensedCarCheckout } from '@/api/parking';
+
+export default {
+  // 无牌车逻辑
+  async unlicensedRule( {commit,dispatch,state},callback ) {
+    try {
+      // const res = await currentUnlicensedPlate(); // 无牌车查询
+      // const res = await unlicensedCarCheckIn({gateId: 1}); // 无牌车入场
+      /**
+       * CAR_NOT_FOUND 车场扫描道闸入口,发现无车
+       * CAR_HAS_PLATE 车场扫描道闸入口,发现有牌车
+       */
+        // const res = unlicensedCarCheckInResponse;
+      const res = await currentUnlicensedPlate();
+      console.log('无牌车的查询记录',res);
+      commit('setUnlicensedCar',res.vehicleNo);
+      // 如果是扫码进入的用户,在出场时需要重新扫码,这时会在此处传入的一个回调函数,在获取到临牌时,返回给 qrCodesRule 函数
+      if ( res.vehicleNo && callback ) {
+        callback(res.vehicleNo);
+      } else {
+        callback('error');
+      }
+    } catch ( err ) {
+      console.log(err);
+    }
+  },
+}

+ 1 - 1
vue.config.js

@@ -123,7 +123,7 @@ module.exports = {
       },
       '/msApi': {
         // target: 'http://172.21.201.251:8080',
-        target: 'http://172.20.51.111:8080',
+        target: 'http://172.21.203.156: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