ソースを参照

feat(KIP-9697): KIP | Temporary Parking H5 |静安嘉里和浦东嘉里有牌车临停功能联调

john 2 年 前
コミット
0d33c57b3a

+ 2 - 2
src/api/parking/index.js

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

+ 17 - 1
src/pages/parkingFee/mixins/parkingFeeDetail.js

@@ -109,7 +109,7 @@ export default {
     // 前往支付
     async toPay() {
       const { parkingRecord, discountInfo = {}, parkingRule = {}} = this.orderDetail;
-      const { coupons, points, memberGrade = [] } = discountInfo
+      const { coupons, points, memberGrade = [], paperCoupons = [] } = discountInfo
       const { hourPrice } = parkingRule
       try {
         const params = {
@@ -161,6 +161,19 @@ export default {
             params.discountInfo.coupons = selectedCoupons
           }
         }
+        // 纸质优惠券
+        if ( paperCoupons?.length ) {
+            params.discountInfo.paperCoupons = paperCoupons.filter(elm => {
+              if ( !elm.discountCode ) {
+                return false
+              }
+              return {
+                ...elm,
+                "discountFee": elm.discountFee,
+                discountTime: elm.discountFee / hourPrice * 60
+              }
+            })
+         }
         console.log('下单时的参数', params);
         const res = await ordersAndPrepay(params);
         // console.log('orderDetail', res);
@@ -448,6 +461,9 @@ export default {
     paperCoupon() {
       this.$router.push({
         path: 'parkingFeePaperCoupon',
+        query:{
+          vehicleNo: this.$route.query.vehicleNo
+        }
       });
     },
     duration() { },

+ 14 - 5
src/pages/parkingFee/mixins/parkingFeePaperCoupon.js

@@ -126,14 +126,14 @@ export default {
       uni.showLoading({
         title: '加载中',
       });
-      // const res = await paperCoupon(couponCode);
-      const res = {
+      const res = await paperCoupon(couponCode, this.$route.query.vehicleNo);
+      /*const res = {
         "status": "1",
         "discountCode": "91354260",
         "discountFee": 1,
         "used": "0",
         "content": "嘉里卡券测试"
-      }
+      }*/
       if ( /0/.test(res.status)) {
         return Toast({
           message: '该纸质优惠券未激活',
@@ -154,17 +154,25 @@ export default {
           message: '该纸质优惠券已核销',
         });
       }
+      console.log(157, res)
+      console.log(158, this.paperCoupons)
+      console.log(158, this.paperCoupons.findIndex(item => {
+        console.log(160, item.discountCode, couponCode)
+        return item.discountCode === couponCode
+      }))
       // 如果纸质优惠券不存在的话,则往 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',[
+        const paperCoupons =  [
           ...this.paperCoupons,
           {
             ...res,
             discountTime: res.discountFee / hourPrice
           }
-        ])
+        ]
+        this.paperCouponList = paperCoupons
+        this.$store.commit('order/setPaperCoupons',paperCoupons)
         // 金额
         this.$store.commit('order/setPaperDiscountFee',this.paperDiscountFee + Number(res.discountFee))
         // 时间
@@ -187,6 +195,7 @@ export default {
     // 确认
     confirm() {
       console.log(310,this.orderDetail);
+      
       this.$store.dispatch('order/savePaperCoupon', {
         couponList: this.paperCoupons,
         callback: () => {

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

@@ -51,7 +51,7 @@
         <div class="flewx-content">
           已选<span class="num">{{ paperCouponList.length }}张</span>
           <span class="discountFee"
-          >优惠券可优惠{{ discountFee | currency }}</span
+          >优惠券可优惠{{ paperDiscountFee | currency }}</span
           >
         </div>
         <div class="btn-box">

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

@@ -60,7 +60,7 @@ export default {
     // font-size: 17px;
     // background-image: linear-gradient(to right, #7e4fa1, #433c7f);
 
-    background-color: var(--k-color-primary-01);
+    background-color: var(--k-color-primary);
     border-radius: 45px;
     font-size: 34px;
     font-weight: 400;

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

@@ -80,6 +80,9 @@ export default {
   setUnitAmount( state,payload ) {
     state.unitAmount = payload || 1;
   },
+  setUnitHour( state,payload ) {
+    state.unitHour = payload || 1;
+  },
   setMaxDiscountFee( state,payload ) {
     state.maxDiscountFee = payload;
   },
@@ -131,6 +134,7 @@ export default {
     state.maxPointsTime = ''; // 积分最大兑换时长
     state.pointsTime = ''; // 已兑换的积分时间
     state.unitAmount = 1;
+    state.unitHour = 1;
     // 停车优惠:会员等级和消费减免
     state.memberLevelDiscount = false; // 是否开启会员等级
     state.enableConsume = false; // 是否开启消费减免

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

@@ -22,7 +22,13 @@ export default {
   async savePaperCoupon( {commit,dispatch,state},{paperCoupons,callback} ) {
     try {
       const orderDetail = {...state.orderDetail};
-      setSelected(['paperCoupons', 'coupons','consume','points','memberGrade'], orderDetail)
+      setSelected(['coupons','consume','points','memberGrade'], orderDetail)
+      orderDetail.discountInfo.paperCoupons = state.paperCoupons.map(elm => {
+        return {
+          ...elm,
+          selected: true,
+        }
+      })
       const res = await calculateDiscount({
         ...orderDetail,
       });

+ 4 - 2
src/store/order/points.js

@@ -27,6 +27,7 @@ export default {
         available, // 用户可用的积分(当前车辆在) available是用户选择抵扣N小时后剩余的可用积分
         maxDiscountFee, // 单次上限(元)
         unitAmount, // 兑换值(元)
+        unitHour, // 兑换值(小时)
         pointsPerUnit = 0, // 500积分对应的价值
         discountFee,
         label,
@@ -43,6 +44,7 @@ export default {
     commit('setMaxOneDayDiscountFee',maxOneDayDiscountFee);
     commit('setPointsPerHour',pointsPerUnit);
     commit('setUnitAmount',unitAmount);
+    commit('setUnitHour', unitHour);
     commit('setIntegralDesc',discountFee ? `已选择兑换${ discountFee }元` : available > pointsPerUnit ? `${ available }积分可减免` : `${ pointsPerUnit }积分可停车1小时`); // 积分优惠处的描述
   },
   // 当前最大可选优惠时间
@@ -160,7 +162,7 @@ export default {
     }
     if ( type === 'add' ) {
       let pointsTime = 0;
-      pointsTime = state.pointsTime + state.unitAmount;
+      pointsTime = state.pointsTime + (parkMallCode === 1 ? state.unitAmount : state.unitHour);
       const available = state.available - state.pointsPerUnit;
       const usingTotalDiscount = state.usingTotalDiscount + state.unitAmount; // 重新计算已经使用的优惠逻辑
       if ( available > -1 ) {
@@ -171,7 +173,7 @@ export default {
       }
     }
     if ( type === 'minus' && state.pointsTime > 0 ) {
-      const pointsTime = state.pointsTime - state.unitAmount;
+      const pointsTime = state.pointsTime - (parkMallCode === 1 ? state.unitAmount : state.unitHour);
       // 如果是深圳车场
       commit('setAvailable',state.available + state.pointsPerUnit);
       commit('setPointsTime',pointsTime);

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

@@ -23,7 +23,8 @@ export default  {
   available: 0, // 用户可用积分
   maxPointsTime: '', // 积分最大兑换时长
   pointsTime: '', // 已兑换的积分时间
-  unitAmount: 1,
+  unitAmount: 1, // 金额
+  unitHour: 1,  // 小时
   // 停车优惠:会员等级和消费减免
   memberLevelDiscount: false, // 是否开启会员等级
   enableConsume: false, // 是否开启消费减免

+ 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.50.207:8080',
+        target: 'http://172.21.202.63: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