Ver código fonte

Merge pull request #270 from John-Hong/John/release-2.18.0/KIP-10673

feat(KIP-10673): C端 | HKC 临时停车交互优化
John-Hong 1 ano atrás
pai
commit
c8f7fbbca4

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

@@ -294,4 +294,12 @@ curl --location --request DELETE 'https://dev-kip-service-internal.kerryonvip.co
 export function delVehicle(vehicleId, params) {
   return window.requestms.delete(`vehicles/${vehicleId}`, params, { loading: false });
   // return window.requestms.delete(`https://dev-kip-service-internal.kerryonvip.com/temporary-parking-service/vehicles/${vehicleId}`, params, { loading: false });
+}
+
+// 获取用户在场车牌
+// parking-record?userId=userId&lbsId
+// userId    lbsId
+export function parkingRecord(vehicleId, params) {
+  return window.requestms.get('parking-record/', params, { loading: false });
+  // return window.requestms.delete(`https://dev-kip-service-internal.kerryonvip.com/temporary-parking-service/vehicles/${vehicleId}`, params, { loading: false });
 }

+ 3 - 3
src/constants.js

@@ -43,9 +43,9 @@ const USER_LIST_ITEM_EDIT_OBJ = {
 const LOGO_KO_DEFAULT = `https://cnsh-kerry-crm-prod.oss-cn-shanghai.aliyuncs.com/images/logo-default1.png`;
 
 const LICENSE_PLATE_TYPE_ARR = [
-  { value: 'ORDINARY_CAR_NO', label: '燃油车辆' },
-  { value: 'NEW_ENERGY_CAR_NO', label: '新能源' },
-  { value: 'SPECIAL_CAR_NO', label: '特殊车辆' },
+  { value: 'ORDINARY_CAR_NO', label: '燃油车辆', name: '燃油车牌' },
+  { value: 'NEW_ENERGY_CAR_NO', label: '新能源', name: '新能源' },
+  { value: 'SPECIAL_CAR_NO', label: '特殊车辆', name: '特殊车牌' },
 ];
 
 // 注册来源

+ 138 - 90
src/pages/parkingFeeV2/mixins/parkingFee.js

@@ -1,24 +1,18 @@
 import plateNumber from '@/components/plate-number/plateNumber.vue';
-import { REG_SOURCE } from '@/constants';
+import {LICENSE_PLATE_TYPE_ARR, REG_SOURCE} from '@/constants';
 import LoginDom from '@/components/Login/Login.vue';
-import { mapState } from 'vuex';
-import { initWxJsSdkConfig } from '@/utils/login';
-import { getPlatform,requestInit } from '@/utils/index';
-import { wxToLoginCallback, getUrlParams, theCommunicationBetweenWechatAndH5IsNormal } from '@/utils';
-import {getAccessH5} from '@/utils/api-crm-member'
+import {mapState} from 'vuex';
+import {initWxJsSdkConfig} from '@/utils/login';
+import {getUrlParams, isHZ} from '@/utils';
 import wxPointsAuth from '@/components/wx-points-auth/wx-points-auth.vue'
+
 const app = {
   globalData: {
     regSource: '',
   },
 };
 import uni from '@/utils/uniHooks';
-// import blueCom from '../components/blue/home.vue';
-// import greenCom from '../components/green/home.vue';
-// import officeBlueCom from '../components/officeBlue/home.vue';
-// import purpleCom from '../components/purple/home.vue';
-import { parkingLots, qrCodes, unlicensedCarCheckIn, getConfValueOfKey } from '@/api/parking';
-import { reject } from 'lodash';
+import {parkingLots, qrCodes, unlicensedCarCheckIn, getConfValueOfKey, getVehicles, parkingRecord} from '@/api/parking';
 
 export default {
   components: {
@@ -89,20 +83,22 @@ export default {
     // console.log('二次加载', this.$route.query.fromPage && !this.$store.state.pageHistory[this.$route.query.fromPage]);
     const fromPage = localStorage.getItem(`${this.$route.query.fromPage}`)
     // console.log(9191, this.$route.query?.fromPage);
-    if(this.$route.query?.fromPage !== 'undefined' && !this.$store.state.pageHistory[this.$route.query.fromPage] && !fromPage) {
+    if (this.$route.query?.fromPage !== 'undefined' && !this.$store.state.pageHistory[this.$route.query.fromPage] && !fromPage) {
       // console.log(93939);
       this.$store.commit('setPageHistory', {
         [this.$route.query.fromPage]: 1
       })
       localStorage.setItem(`${this.$route.query.fromPage}`, this.$route.query.fromPage)
-      this.$router.push({ path: this.$route.query.fromPage, query: {
-        ...this.$route.query,
-        loginCount: 1
-      }});
+      this.$router.push({
+        path: this.$route.query.fromPage, query: {
+          ...this.$route.query,
+          loginCount: 1
+        }
+      });
     }
-    const {type= '', code = ''} = this.$route.query
+    const {type = '', code = ''} = this.$route.query
     // 无牌车流程
-    if(/unlicensedOut|unlicensedIn/.test(type) && code && !this.$store.state.pageHistory?.unlicensed && !this.endlessLoop) {
+    if (/unlicensedOut|unlicensedIn/.test(type) && code && !this.$store.state.pageHistory?.unlicensed && !this.endlessLoop) {
       this.$store.commit('setPageHistory', {
         unlicensed: 1
       })
@@ -111,7 +107,7 @@ export default {
       });
       this.$store.commit('SET_ENDLESS_LOOP', type);
       this.$nextTick(() => {
-          this.qrCodesRule(code);
+        this.qrCodesRule(code);
       })
     }
   },
@@ -149,8 +145,8 @@ export default {
     //   await initWxJsSdkConfig(['checkJsApi', 'scanQRCode']);
     // }
     this.getVehiclesINTMP()
-    const openid= uni.getStorageSync('openid');
-      
+    const openid = uni.getStorageSync('openid');
+
     // 如果用户未登录的话,返回之后,重新获取数据用户的基础数据
     if (openid) {
       this.getParkInfo();
@@ -168,7 +164,7 @@ export default {
     }
     try {
       const href = window.location.href;
-      if(!isAlipayClient && !/808[0-9]/.test(href)) {
+      if (!isAlipayClient && !/808[0-9]/.test(href)) {
         setTimeout(async () => {
           await initWxJsSdkConfig(['checkJsApi', 'scanQRCode']);
         }, 1500)
@@ -232,7 +228,7 @@ export default {
     },
     // 唤起键盘
     clickShowKeyboard(index) {
-      if ( this.carType !== 1 && index === 7) return
+      if (this.carType !== 1 && index === 7) return
       this.ind = index;
       this.active = index;
       if (index === 0) {
@@ -281,8 +277,8 @@ export default {
       this.$store.commit('SET_REGRESH_PAGE_KEY')
       this.$nextTick(() => {
         const query = {
-            ...this.$route.query,
-            vehicleNo: this.vehicleNumber,
+          ...this.$route.query,
+          vehicleNo: this.vehicleNumber,
         }
         // fromPage && format && unlicensed
         query.fromPage = ''
@@ -302,15 +298,15 @@ export default {
       });
       this.$store.commit('SET_REGRESH_PAGE_KEY')
       this.$nextTick(() => {
-          const query = {
-              ...this.$route.query,
-              vehicleNo: vehicleNo,
-          }
-          // fromPage && format && unlicensed
-          query.fromPage = ''
-          query.format = ''
-          query.unlicensed = ''
-          
+        const query = {
+          ...this.$route.query,
+          vehicleNo: vehicleNo,
+        }
+        // fromPage && format && unlicensed
+        query.fromPage = ''
+        query.format = ''
+        query.unlicensed = ''
+
         this.$router.push({
           path: 'parkingFeeDetail',
           query,
@@ -365,14 +361,14 @@ export default {
             this.parkingFeeDetailInit();
             uni.setStorageSync('isReload', '3');
             // this.$destroy();
-              const query = {
-                  ...this.$route.query,
-                  vehicleNo: carno,
-              }
-              // fromPage && format && unlicensed
-              query.fromPage = ''
-              query.format = ''
-              query.unlicensed = ''
+            const query = {
+              ...this.$route.query,
+              vehicleNo: carno,
+            }
+            // fromPage && format && unlicensed
+            query.fromPage = ''
+            query.format = ''
+            query.unlicensed = ''
             this.$router.push({
               path: 'parkingFeeDetail',
               query,
@@ -452,7 +448,7 @@ export default {
       const query = {
         ...this.$route.query,
         // vehicleNo: vehicleNo,
-    }
+      }
       // fromPage && format && unlicensed
       query.fromPage = ''
       query.format = ''
@@ -463,7 +459,7 @@ export default {
       //   return;
       // }
       this.$store.commit('SET_REGRESH_PAGE_KEY')
-      this.$router.push({ path: 'parkingFeeList', query });
+      this.$router.push({path: 'parkingFeeList', query});
     },
     // 车牌管理
     doRouter2: function () {
@@ -485,13 +481,13 @@ export default {
       const query = {
         ...this.$route.query,
         // vehicleNo: vehicleNo,
-    }
+      }
       // fromPage && format && unlicensed
       query.fromPage = ''
       query.format = ''
       query.loginCount = ''
       uni.removeStorageSync('passLogin');
-      this.$router.push({ path: 'vehicleManagement', query });
+      this.$router.push({path: 'vehicleManagement', query});
     },
     async jumpToPreJudgmentOfParkingInvoice() {
       return new Promise(async (resolve) => {
@@ -501,7 +497,7 @@ export default {
           // const res = await getAccessH5(`${this.mallId}-invoice`);
           const res = await getConfValueOfKey('HEJIInvoiceSwitch')
           const lbsId = uni.getStorageSync('lbsId')
-          if(res?.switch && res.lbsId.length && res.lbsId.indexOf(lbsId) > -1) {
+          if (res?.switch && res.lbsId.length && res.lbsId.indexOf(lbsId) > -1) {
             uni.hideLoading();
             // console.log(474, this.Dialog);
             this.$dialog({
@@ -527,7 +523,7 @@ export default {
     //停车发票
     doRouter1: async function () {
       const isJump = await this.jumpToPreJudgmentOfParkingInvoice();
-      if(isJump) return
+      if (isJump) return
       uni.hideLoading()
       uni.removeStorageSync('invoiceindex');
       this.$store.dispatch('clearUnlicensed');
@@ -543,7 +539,7 @@ export default {
       const query = {
         ...this.$route.query,
         // vehicleNo: vehicleNo,
-    }
+      }
       // fromPage && format && unlicensed
       query.fromPage = ''
       query.format = ''
@@ -564,7 +560,7 @@ export default {
         return
       }
       */
-      this.$router.push({ path: 'parkingReceipt', query });
+      this.$router.push({path: 'parkingReceipt', query});
     },
     //停车券兑换
     doRouter3: function () {
@@ -587,7 +583,7 @@ export default {
       // });
 
       wx.miniProgram.navigateTo({
-          "url": "/pages/pointsMall/pointsMall?exchangeTypes=2" // 去 login 页面 1 去登录
+        "url": "/pages/pointsMall/pointsMall?exchangeTypes=2" // 去 login 页面 1 去登录
       })
     },
     blueComChange(value) {
@@ -619,7 +615,7 @@ export default {
             const url = res.result;
             const {path} = getUrlParams(res.result)
             let params = null
-            if(path) {
+            if (path) {
               params = getUrlParams(decodeURIComponent(path))
             }
             /*
@@ -639,7 +635,7 @@ export default {
             针对微信的小程序码进行的兼容改造
             微信扫码结束之后的返回参数 {"errMsg": "scanCode:ok", "scanType": "WX_CODE", "charSet": "ISO8859-1", "rawData": "bGsoP3gyT1Aud3QpbW1JeHRfVHJsUjg4JnR5cGU9dW5saWNlbnNlZElu", "path": "pages/automatic/automaticIndex?scene=code%3D9988%26type%3DunlicensedIn"}
             */
-          if(res.scanType && res.scanType === 'WX_CODE' && res.path) {
+          if (res.scanType && res.scanType === 'WX_CODE' && res.path) {
             const params = getUrlParams(`?${decodeURIComponent(res.path.replace(/.*scene=/g, ''))}`)
             this.$store.commit('SET_UNLICENSED_INFO', params);
             this.$nextTick(() => {
@@ -647,12 +643,12 @@ export default {
             })
           }
           // 兜底逻辑,如果是其他小程序扫描,则提取rawData,进行解析提取入参
-          if(res.scanType && res.scanType === 'WX_CODE' && !res?.path){
+          if (res.scanType && res.scanType === 'WX_CODE' && !res?.path) {
             let path = atob(res.rawData)
             path = path.replace(/.*([a-z0-9]{6}&type)/g, '8b$1')
             const regex = /(\w+)&type=(\w+)/;
             const match = path.match(regex);
-            const obj = { code: match[1], type: match[2] };
+            const obj = {code: match[1], type: match[2]};
             this.$store.commit('SET_UNLICENSED_INFO', obj);
             this.$nextTick(() => {
               this.qrCodesRule(obj.code, 'scan');
@@ -691,7 +687,7 @@ export default {
               console.log(614, path);
               const regex = /(\w+)&type=(\w+)/;
               const match = path.match(regex);
-              const obj = { code: match[1], type: match[2] };
+              const obj = {code: match[1], type: match[2]};
               console.log(618, obj);
               console.log(696, this.qrCodesRule);
               this.$store.commit('SET_UNLICENSED_INFO', obj);
@@ -716,11 +712,11 @@ export default {
     async qrCodesRule(code, source = '') {
       console.log(717, code, source);
       // source 是为了避免重复刷新
-      if(this.$store.state.pageHistory.parkingFeeMsg && !source) {
+      if (this.$store.state.pageHistory.parkingFeeMsg && !source) {
         return
       }
       try {
-        if ( this.qrCodeHistory && this.qrCodeHistory === code ) {
+        if (this.qrCodeHistory && this.qrCodeHistory === code) {
           return
         }
         this.qrCodeHistory = code
@@ -735,17 +731,17 @@ export default {
         console.log(735);
         // return
         if (this.unlicensedInfo?.type === 'unlicensedOut') {
-            const query = {
-                ...this.$route.query,
-                gateId: qrCodesres.gateId,
-                vehicleNo: '',
-                type: this.unlicensedInfo.type
-            }
-            // fromPage && format && unlicensed
-            query.fromPage = ''
-            query.format = ''
-            query.unlicensed = ''
-            query.code = ''
+          const query = {
+            ...this.$route.query,
+            gateId: qrCodesres.gateId,
+            vehicleNo: '',
+            type: this.unlicensedInfo.type
+          }
+          // fromPage && format && unlicensed
+          query.fromPage = ''
+          query.format = ''
+          query.unlicensed = ''
+          query.code = ''
           this.$router.push({
             path: 'parkingFeeDetail',
             query
@@ -757,16 +753,16 @@ export default {
           gateId: qrCodesres.gateId
         });
 
-          const query = {
-              ...this.$route.query,
-              type: 'success',
-              vehicleNo: unlicensedCarCheckInres.vehicleNo
-          }
-          // fromPage && format && unlicensed
-          query.fromPage = ''
-          query.format = ''
-          query.unlicensed = ''
-          query.code = ''
+        const query = {
+          ...this.$route.query,
+          type: 'success',
+          vehicleNo: unlicensedCarCheckInres.vehicleNo
+        }
+        // fromPage && format && unlicensed
+        query.fromPage = ''
+        query.format = ''
+        query.unlicensed = ''
+        query.code = ''
         this.$store.commit('setPageHistory', {
           parkingFeeMsg: 1
         })
@@ -781,15 +777,15 @@ export default {
           return
         }
         if (/CAR_NOT_FOUND|INOUT_FAILED|UNLICENSED_PLATE_ACQUISITION_FAILED/.test(err.code)) {
-            const query = {
-                ...this.$route.query,
-                type: 'fail'
-            }
-            // fromPage && format && unlicensed
-            query.fromPage = ''
-            query.format = ''
-            query.unlicensed = ''
-            query.code = ''
+          const query = {
+            ...this.$route.query,
+            type: 'fail'
+          }
+          // fromPage && format && unlicensed
+          query.fromPage = ''
+          query.format = ''
+          query.unlicensed = ''
+          query.code = ''
           this.$store.commit('setPageHistory', {
             parkingFeeMsg: 1
           })
@@ -806,6 +802,58 @@ export default {
       // 无牌车这边去支付的时候,属于场内缴费,需要调用场内缴费的接口 /parking/check-out
       this.$store.commit('SET_ENDLESS_LOOP', '');
       this.toHandleSearch(this.unlicensedCar);
-    }
+    },
+    // 获取会员绑定的车牌列表
+    async getVehiclesINTMP() {
+      /*杭州*/
+      if (!isHZ(this.mallId)) return
+      try {
+        let vehicles = []
+        // 获取用户车场在停车辆数据集
+        vehicles = await parkingRecord({
+          userId: this.kipUserId,
+          lbsId: this.mallId
+        })
+        // 获取用户的所有车牌
+        const userVehicles = await getVehicles(this.kipUserId)
+        if (!vehicles.length) {
+          vehicles = userVehicles.content
+        }
+        if (vehicles.length) {
+          const vehicleNo = vehicles[0].vehicleNo
+          // 设置车牌类型
+          this.setVehicleNoType(vehicleNo, userVehicles.content)
+          // 赋值
+          this.numArr = vehicles[0].vehicleNo.split('');
+          this.vehicleNumber = vehicles[0].vehicleNo;
+        } else {
+          throw new Error('202')
+        }
+      } catch (e) {
+        // 设置默认参数
+        this.numArr  = '浙,A,,,,,'.split(',')
+      }
+    },
+    setVehicleNoType(vehicleNo, vehicles) {
+      if(vehicleNo.indexOf('临') === 0) {
+        this.tabbarActive = '无牌缴费'
+        return
+      }
+      const item = vehicles.filter(e => e.vehicleNo === vehicleNo)
+      if(item.length) {
+        let label = LICENSE_PLATE_TYPE_ARR.filter(e => e.value == item[0].licensePlateType)
+        const index = ['燃油车牌', '新能源', '特殊车牌'].indexOf(label[0].name)
+        this.$refs['k-tab'].changeTab(index)
+        return true
+      }
+      return false
+    },
+    setLicensePlateList(arr) {
+      var array = []
+      arr.forEach(element => {
+        array.push(element.vehicleNo)
+      });
+      return array
+    },
   },
 };

+ 16 - 8
src/pages/parkingFeeV2/mixins/parkingFeeDetail.js

@@ -1,20 +1,13 @@
-import moment from 'moment';
 import { mapState } from 'vuex';
-import log from '@/utils/log.js';
-import { compare } from '@/utils/location.js';
 import uni from '@/utils/uniHooks';
-import { initWxJsSdkConfig } from '@/utils/login';
 import {
   backLbsHome,
   getPlatform,
-  getsTheCurrentTopic,
   isAlipay,
-  theCommunicationBetweenWechatAndH5IsNormal
 } from '@/utils';
 import {debounce, } from 'lodash'
 import { Dialog, Toast } from 'vant';
 import { ordersAndPrepay } from '@/api/parking';
-// import checkOutResponse from '@/api/mockData/checkout.hz.response'
 
 export default {
   name: 'parkingFeeDetail',
@@ -385,7 +378,22 @@ export default {
           }, 2900)
         } else {
           // 如果接口返回异常,重置当前页面数据
-          this.reCreateParkOrder()
+          console.log('err::::', err)
+          if (err.code !=='NO_FEE_NEED_TO_PAY') {
+            this.reCreateParkOrder()
+          } else {
+            Dialog.alert({
+              title: '提示',
+              message: '当前无需缴费',
+              confirmButtonColor: '#333',
+            }).then(() => {
+              this.$router.replace({
+                // path: 'parkingFeeSuccess?carno=' + this.parkInfo.carno,
+                path: 'home',
+              }); 
+              // this.createParkOrder();
+            });
+          }
           this.btnLoading = false
           this.isPay = false
         }

+ 2 - 23
src/pages/parkingFeeV2/mixins/vehicleAddOrEdit.js

@@ -1,10 +1,8 @@
 import uniPop from '@/components/uni-popup/uni-popup.vue';
 import plateNumber from '@/components/plate-number/plateNumber.vue';
-// const app = getApp()
 import uni from '@/utils/uniHooks';
-import { Dialog, Toast } from 'vant';
+import { Toast } from 'vant';
 
-const app = {};
 import { LICENSE_PLATE_TYPE_ARR } from '@/constants.js';
 import {
   kipAddMemberVehicles,
@@ -36,21 +34,6 @@ export default {
     uni.setStorageSync('previousUrl', '/pages/parkingFee/vehicleAddOrEdit.vue');
   },
   mounted() {
-    setTimeout(() => {
-      uni.setNavigationBarTitle({
-        title: '绑定车牌号',
-      });
-    }, 300);
-    setTimeout(() => {
-      window?.toWXSendMsg({
-        type: 'uni_func',
-        funcName: 'setNavigationBarColor',
-        options: {
-          frontColor: '#000000',
-          backgroundColor: '#FBFCFF',
-        },
-      });
-    }, 500)
     const params = this.$route.query;
     console.log(55555, params);
     if (params.carType) {
@@ -58,17 +41,13 @@ export default {
         ...params,
       };
       this.carType = Number.parseInt(this.carInfo.carType);
+      this.$refs['k-tab'].changeTab(this.carType)
       this.numArr = this.carInfo.carno.split('');
       this.vehicleNumber = this.carInfo.carno;
     }
   },
   computed: {
     disabledBtn() {
-      // console.log(
-      //   190,
-      //   this.numArr,
-      //   this.numArr.findIndex((val) => !val)
-      // );
       return this.numArr.findIndex((val) => !val) !== -1;
     },
     ...mapState({

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

@@ -44,7 +44,7 @@
               <div class="parkingFee-search">
                 <div class="search_tip_1" :style="{paddingTop: supportUnlicensed? '0': '32px'}">
                   <div class="title">车辆类型</div>
-                  <k-tab type="fill" @change="toggleType" :tabs="['燃油车牌', '新能源', '特殊车牌']" />
+                  <k-tab ref="k-tab" type="fill" @change="toggleType" :tabs="['燃油车牌', '新能源', '特殊车牌']" />
                 </div>
                 <!-- <div class="search_tip">
                   <div class="title">车辆类型</div>

+ 1 - 1
src/pages/parkingFeeV2/vehicleAddOrEdit.vue

@@ -4,7 +4,7 @@
     <div>
       <div class="search_tip_1">
         <div class="title">车辆类型</div>
-        <k-tab type="fill" @change="toggleType" :tabs="['燃油车牌', '新能源', '特殊车牌']" />
+        <k-tab type="fill" ref="k-tab" @change="toggleType" :tabs="['燃油车牌', '新能源', '特殊车牌']" />
       </div>
       <div class="input-box">
         <!-- <div v-for="i in carType === 1 ? 8 : 7" class="li" :key="`numArr${i}`" @click="clickShowKeyboard(i)" :class="[active === i ? 'active' : '']">

+ 5 - 0
src/utils/common/lbsIdCommon.js

@@ -0,0 +1,5 @@
+// 如果是杭州的 site
+export function isHZ(lbsId) {
+  const hzLbsIds =['8a8883557cca9463017ccb002b360001','8a84853b7c91ac5b017c961a9b2a030d', '8aaa80b47c784020017c78b00d060022'] 
+  return hzLbsIds.indexOf(lbsId) > -1
+}

+ 1 - 0
src/utils/index.js

@@ -417,4 +417,5 @@ export function toLogin() {
 export * from './common/websocket.js'
 export * from './common/localStorage.js'
 export * from './common/function.js'
+export * from './common/lbsIdCommon.js'
 export * from './alipayClient/index.js'