Pārlūkot izejas kodu

feat(KIP-10665): C端 | HKC车辆管理功能调整

john 1 gadu atpakaļ
vecāks
revīzija
fba76b9564

+ 36 - 33
src/pages/parkingFee/mixins/vehicleAddOrEdit.js

@@ -82,7 +82,6 @@ export default {
       this.ind = 0;
       this.active = 0;
       this.carType = index;
-
       if (this.carType == '1') {
         this.numArr = [
           this.numArr[0],
@@ -105,6 +104,7 @@ export default {
           this.numArr[6],
         ];
       }
+      this.vehicleNumber = this.numArr.toString().replace(/,/g, '')
     },
     // 唤起键盘
     clickShowKeyboard(index) {
@@ -167,15 +167,36 @@ export default {
         licensePlateType: this.licensePlateTypeArr[this.carType].value,
         vehicleNo: this.vehicleNumber,
       };
-      if(this.carInfo?.id) {
-        // 修改
-        const res = await editVehicles(this.carInfo?.id, {
-          id: this.carInfo?.id,
-          ...params
-        })
-        if(res.id) {
+      try {
+        if (this.carInfo?.id) {
+          // 修改
+          const res = await editVehicles(this.carInfo?.id, {
+            id: this.carInfo?.id,
+            ...params
+          })
+          if (res.id) {
+            Toast({
+              message: '修改车牌成功',
+              position: 'top',
+              onClose: () => {
+                setTimeout(() => {
+                  this.$router.go(-1)
+                }, 300)
+              }
+            });
+          } else {
+            const message = res.langMessage || '修改车牌失败';
+            Toast({
+              message: message,
+            });
+          }
+          return
+        }
+        // 添加
+        const res = await addVehicles(this.kipUserId, params)
+        if (res?.id) {
           Toast({
-            message: '修改车牌成功',
+            message: '绑定车牌成功',
             position: 'top',
             onClose: () => {
               // this.$router.replace({
@@ -187,34 +208,16 @@ export default {
             }
           });
         } else {
-          const message = res.langMessage || '修改车牌失败';
+          const message = res.langMessage || '绑定车牌失败';
           Toast({
             message: message,
+            position: 'top',
           });
         }
-        return
-      } 
-      // 添加
-      const res= await addVehicles( this.kipUserId, params )
-      if(res?.id) {
-        Toast({
-          message: '绑定车牌成功',
-          position: 'top',
-          onClose: () => {
-            // this.$router.replace({
-            //   path: `vehicleManagement`,
-            // });
-            setTimeout(() => {
-              this.$router.go(-1)
-            }, 300)
-          }
-        });
-      } else {
-        const message = res.langMessage || '绑定车牌失败';
-        Toast({
-          message: message,
-          position: 'top',
-        });
+      } catch (err) {
+        if(err.code === 'FOUND_DUPLICATE') {
+          Toast('当前车牌已经存在,请勿重复绑定');
+        }
       }
     },
     handleAddLicensePlateByKipMember() {

+ 17 - 0
src/pages/parkingFee/mixins/vehicleManagement.js

@@ -294,6 +294,23 @@ export default {
       //   });
       // this.deleteDialogSwitch = true;
     },
+    // 编辑
+    toEditBefore(item) {
+      // TODO 不是杭州的车牌 或者 是非优惠的车牌
+      if(!this.isHZ || !item.eligible){
+        this.toEdit(item)
+        return
+      }
+      this.$refs['checkCarPopup'].open({
+        redirectTo: 'edit',
+        vehicleNo: this.vehicleNumber,
+        topBtnName: '继续修改',
+        topBtnFn: async () => {
+          this.toEdit(item)
+        },
+        bottomBtnName: '取消'
+      })
+    },
     doDelete() {
       this.delVehicleInTMP();
       return

+ 0 - 1
src/pages/parkingFeeV2/mixins/parkingFee.js

@@ -85,7 +85,6 @@ export default {
     // console.log('二次加载this.$route.query.fromPage', this.$route.query.fromPage, this.$store.state.pageHistory);
     // 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) {
       // console.log(93939);
       this.$store.commit('setPageHistory', {

+ 56 - 50
src/pages/parkingFeeV2/mixins/vehicleAddOrEdit.js

@@ -1,15 +1,15 @@
 import uniPop from '@/components/uni-popup/uni-popup.vue';
 import plateNumber from '@/components/plate-number/plateNumber.vue';
 import uni from '@/utils/uniHooks';
-import { Toast } from 'vant';
+import {Toast} from 'vant';
 
-import { LICENSE_PLATE_TYPE_ARR } from '@/constants.js';
+import {LICENSE_PLATE_TYPE_ARR} from '@/constants.js';
 import {
   kipAddMemberVehicles,
   kipModifyMemberVehicles,
 } from '@/utils/api-kip.js';
-import { mapState } from 'vuex';
-import { addVehicles, editVehicles } from '@/api/parking/index'
+import {mapState} from 'vuex';
+import {addVehicles, editVehicles} from '@/api/parking/index'
 
 export default {
   components: {
@@ -61,7 +61,6 @@ export default {
       this.ind = 0;
       this.active = 0;
       this.carType = index;
-
       if (this.carType == '1') {
         this.numArr = [
           this.numArr[0],
@@ -84,10 +83,11 @@ export default {
           this.numArr[6],
         ];
       }
+      this.vehicleNumber = this.numArr.toString().replace(/,/g, '')
     },
     // 唤起键盘
     clickShowKeyboard(index) {
-      if ( this.carType !== 1 && index === 7) return
+      if (this.carType !== 1 && index === 7) return
       this.ind = index;
       this.active = index;
       // console.log('唤起键盘', this.ind, this.active);
@@ -146,15 +146,39 @@ export default {
         licensePlateType: this.licensePlateTypeArr[this.carType].value,
         vehicleNo: this.vehicleNumber,
       };
-      if(this.carInfo?.id) {
-        // 修改
-        const res = await editVehicles(this.carInfo?.id, {
-          id: this.carInfo?.id,
-          ...params
-        })
-        if(res.id) {
+      try {
+        if (this.carInfo?.id) {
+          // 修改
+          const res = await editVehicles(this.carInfo?.id, {
+            id: this.carInfo?.id,
+            ...params
+          })
+          if (res.id) {
+            Toast({
+              message: '修改车牌成功',
+              position: 'top',
+              onClose: () => {
+                // this.$router.replace({
+                //   path: `vehicleManagement`,
+                // });
+                setTimeout(() => {
+                  this.$router.go(-1)
+                }, 300)
+              }
+            });
+          } else {
+            const message = res.langMessage || '修改车牌失败';
+            Toast({
+              message: message,
+            });
+          }
+          return
+        }
+        // 添加
+        const res = await addVehicles(this.kipUserId, params)
+        if (res?.id) {
           Toast({
-            message: '修改车牌成功',
+            message: '绑定车牌成功',
             position: 'top',
             onClose: () => {
               // this.$router.replace({
@@ -166,34 +190,16 @@ export default {
             }
           });
         } else {
-          const message = res.langMessage || '修改车牌失败';
+          const message = res.langMessage || '绑定车牌失败';
           Toast({
             message: message,
+            position: 'top',
           });
         }
-        return
-      } 
-      // 添加
-      const res= await addVehicles( this.kipUserId, params )
-      if(res?.id) {
-        Toast({
-          message: '绑定车牌成功',
-          position: 'top',
-          onClose: () => {
-            // this.$router.replace({
-            //   path: `vehicleManagement`,
-            // });
-            setTimeout(() => {
-              this.$router.go(-1)
-            }, 300)
-          }
-        });
-      } else {
-        const message = res.langMessage || '绑定车牌失败';
-        Toast({
-          message: message,
-          position: 'top',
-        });
+      } catch (err) {
+        if (err.code === 'FOUND_DUPLICATE') {
+          Toast('当前车牌已经存在,请勿重复绑定');
+        }
       }
     },
     handleAddLicensePlateByKipMember() {
@@ -225,7 +231,7 @@ export default {
                   onClose: () => {
                     this.$router.replace({
                       path: `vehicleManagement`,
-                      query:{
+                      query: {
                         ...this.$route.query,
                       }
                     });
@@ -262,22 +268,22 @@ export default {
                   onClose: () => {
                     this.$router.replace({
                       path: `vehicleManagement`,
-                      query:{
+                      query: {
                         ...this.$route.query,
                       }
                     });
                   }
                 });
-               /* Dialog.alert({
-                  message: '绑定车牌成功',
-                  confirmButtonColor: '#333',
-                }).then(() => {
-                  // on confirm
-                  this.$router.replace({
-                    path: `vehicleManagement`,
-                  });
-                  // this.$router.back();
-                });*/
+                /* Dialog.alert({
+                   message: '绑定车牌成功',
+                   confirmButtonColor: '#333',
+                 }).then(() => {
+                   // on confirm
+                   this.$router.replace({
+                     path: `vehicleManagement`,
+                   });
+                   // this.$router.back();
+                 });*/
                 // setTimeout(() => {
                 //   // this.$router.back();
                 //   this.$router.replace({

+ 17 - 0
src/pages/parkingFeeV2/mixins/vehicleManagement.js

@@ -161,6 +161,23 @@ export default {
         bottomBtnName: '放弃缴费 '
       })
     },
+    // 编辑
+    toEditBefore(item) {
+      // 不是杭州的车牌 或者 是非优惠的车牌
+      if(!this.isHZ || !item.eligible){
+        this.toEdit(item)
+        return
+      }
+      this.$refs['checkCarPopup'].open({
+        redirectTo: 'edit',
+        vehicleNo: this.vehicleNumber,
+        topBtnName: '继续修改',
+        topBtnFn: async () => {
+          this.toEdit(item)
+        },
+        bottomBtnName: '取消'
+      })
+    },
     toPay(carno) {
       console.log(145, this.isNoLogin, this.isLogin);
       if (this.isNoLogin) return

+ 5 - 0
src/store/index.js

@@ -351,6 +351,11 @@ const store = new Vuex.Store({
         }
         if(isLogin) {
           commit('SET_IS_LOGIN', isLogin);
+          dispatch('memberInit', {
+            openid: openId,
+            unionId,
+            isError: true
+          });
         }
         callback && callback();
         return