Browse Source

使用语义化的枚举值,替换数值来描述用户的登录状态;
notLoggedIn: 未登录;haveLoggedIn:已登录;loginDenied:拒绝登录

john 2 năm trước cách đây
mục cha
commit
0b784dd554

+ 1 - 1
src/App.vue

@@ -196,7 +196,7 @@ export default {
         if (openid && openid !== 'undefined') {
           this.$store.commit('SET_OPENID', openid);
           // 用户选择不登录
-          if (this.isLogin !== '3') {
+          if (this.isLogin !== 'loginDenied') {
             this.$store.commit('SET_IS_INIT', false);
             setTimeout(() => {
               this.$store.commit('SET_IS_INIT', true);

+ 1 - 1
src/api/request.js

@@ -100,7 +100,7 @@ function XUser(config) {
     // https://kerryprops.atlassian.net/browse/KIP-10831
     sourceId: store.state?.sourceId || '', // 微信:unionId; 支付宝:userId
     // isLogin: store.state?.member?.vipcode ? true : false
-    isLogin: store.state?.isLogin === '2'
+    isLogin: store.state?.isLogin === 'haveLoggedIn'
   };
   // params = {"userId": "8aaa809d835ba76d018378bc57180006","sourceType": "WECHAT","phoneNumber": "18521563898","projectId": "paroject1","buildingId": "QHKC-P1","brandId":"8a84853b7c91ac5b017c962dab55030e","cid": "oIUfO5XAVleJ88z13i1_08DCKIhQ","vipCode":"KERRY100200040","lbsId":"8aaa81cb7c836c6b017c83e46b110001"}
   if (/orders-and-prepay|calculate-discount|unlicensed-car-check-in|unlicensed-car-checkout|paper-coupon/g.test(config.url)) {

+ 1 - 1
src/pages/login/login.vue

@@ -229,7 +229,7 @@ export default {
       return false;
     },
     passLogin() {
-      this.$store.commit('SET_IS_LOGIN', '3');
+      this.$store.commit('SET_IS_LOGIN', 'loginDenied');
       this.$router.replace({ path: 'home' });
     },
     // 获取验证码

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

@@ -448,7 +448,7 @@ export default {
         },
       });
       uni.setStorageSync('loadData', '');
-      if (this.$store.state.isLogin === '3') {
+      if (this.$store.state.isLogin === 'loginDenied') {
         this.$router.push({ path: 'login' });
         return;
       }
@@ -466,7 +466,7 @@ export default {
         },
       });
       uni.setStorageSync('loadData', '');
-      if (this.$store.state.isLogin === '3') {
+      if (this.$store.state.isLogin === 'loginDenied') {
         this.$router.push({ path: 'login' });
         return;
       }
@@ -520,7 +520,7 @@ export default {
         },
       });
       uni.setStorageSync('loadData', '');
-      if (this.$store.state.isLogin === '3') {
+      if (this.$store.state.isLogin === 'loginDenied') {
         this.$router.push({ path: 'login' });
         return;
       }

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

@@ -53,7 +53,7 @@ export default {
     }, 500)
     setTimeout(async () => {
       // 如果从小程序来的用户已经登录。但是本地的 member 数据是空的,则从后端重新获取,如果获取失败则提示用户
-      if(this.isLogin === '2' && this.isNoLogin) {
+      if(this.isLogin === 'haveLoggedIn' && this.isNoLogin) {
         const res = await this.$store.dispatch('memberInit',{
           unionId: this.$store.state.sourceId,
           openid:  this.$store.state.openid,

+ 2 - 2
src/store/index.js

@@ -44,7 +44,7 @@ const store = new Vuex.Store({
     parkFee: {},
     marketList: [],
     projectId: '',
-    isLogin: '1', // 1: 未登录,2:已登录,3:拒绝登录
+    isLogin: 'notLoggedIn', // notLoggedIn: 未登录,haveLoggedIn:已登录,loginDenied:拒绝登录
     accessToken: '', // 用户的token
     tempParkingOrder: {},
     tempParkingMoney: '',
@@ -268,7 +268,7 @@ const store = new Vuex.Store({
           commit('SET_ACCESS_TOKEN', accessToken);
           commit('SET_KIP_USER_ID', kipUserId);
           commit('SET_MOBILE', mobile);
-          commit('SET_IS_LOGIN', '2');
+          commit('SET_IS_LOGIN', 'haveLoggedIn');
           dispatch('getUserDetail');
           dispatch('memberInit',{
             openid,