瀏覽代碼

Merge pull request #219 from John-Hong/John/release-2.14.0/KIP-11250

John/release 2.14.0/kip 11250
Jackie-BL-Shi 2 年之前
父節點
當前提交
1584ec014e

+ 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);

+ 2 - 1
src/api/request.js

@@ -99,7 +99,8 @@ function XUser(config) {
     lbsId: store.state?.lbsId || '',
     // https://kerryprops.atlassian.net/browse/KIP-10831
     sourceId: store.state?.sourceId || '', // 微信:unionId; 支付宝:userId
-    isLogin: store.state?.member?.vipcode ? true : false
+    // isLogin: store.state?.member?.vipcode ? true : false
+    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;
       }

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

@@ -4,7 +4,7 @@ import log from '@/utils/log.js';
 import { compare } from '@/utils/location.js';
 import uni from '@/utils/uniHooks';
 import { initWxJsSdkConfig } from '@/utils/login';
-import { getPlatform, isAlipay, theCommunicationBetweenWechatAndH5IsNormal } from '@/utils';
+import {getPlatform, getsTheCurrentTopic, isAlipay, theCommunicationBetweenWechatAndH5IsNormal} from '@/utils';
 import { Dialog, Toast } from 'vant';
 import { ordersAndPrepay } from '@/api/parking';
 // import checkOutResponse from '@/api/mockData/checkout.hz.response'
@@ -35,6 +35,7 @@ export default {
     next();
   },
   created() {
+    // 如果本地不存在
     setTimeout(() => {
       uni.setNavigationBarTitle({
         title: '停车支付',
@@ -50,8 +51,42 @@ export default {
         },
       });
     }, 500)
-    setTimeout(() => {
-      this.pageInit();
+    setTimeout(async () => {
+      // 如果从小程序来的用户已经登录。但是本地的 member 数据是空的,则从后端重新获取,如果获取失败则提示用户
+      if(this.isLogin === 'haveLoggedIn' && this.isNoLogin) {
+        const res = await this.$store.dispatch('memberInit',{
+          unionId: this.$store.state.sourceId,
+          openid:  this.$store.state.openid,
+          isError: true
+        })
+        if(res) {
+          const { theme } = getsTheCurrentTopic();
+          const dialog = this.$dialog.alert({
+            title: '温馨提示',
+            message: '当前网络异常,请返回首页重试',
+            confirmButtonColor: this.$theme[theme].primaryColor,
+            beforeClose: async (action, done) => {
+              try {
+                if(window?.__wxjs_environment === 'miniprogram') {
+                  wx?.miniProgram?.reLaunch({
+                    url: '/pages/automatic/automaticIndex'
+                  })
+                }
+                if (isAlipayClient) {
+                  my?.reLaunch({
+                    url: '/pages/automatic/automaticIndex'
+                  })
+                }
+              } catch (e) {
+                console.log('90909090', e)
+              }
+              done()
+            }
+          });
+          return;
+        }
+      }
+     await this.pageInit();
     }, 300)
   },
   mounted() {
@@ -87,6 +122,7 @@ export default {
       appId: state => state.appId,
       source: state => state.source,
       parkMallCode: (state) => state.order.parkMallCode,
+      isLogin: (state) => state.isLogin,
     }),
     isNoLogin() {
       return JSON.stringify(this.member) === '{}' || !this.member

+ 2 - 2
src/pages/parkingFee/mixins/parkingReceipt/parkingApplication.js

@@ -236,9 +236,9 @@ export default {
         try {
           const res = await submitInvoice(params);
           if (res) {
-            Toast({
+            /*Toast({
               message: '开票成功',
-            });
+            });*/
             uni.setStorageSync('invoiceindex', 2)
             // vue.router router.replace点两次返回问题及解决方案: https://blog.csdn.net/william_jzy/article/details/85760660
             this.$router.replace({

+ 32 - 28
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,30 +268,13 @@ const store = new Vuex.Store({
           commit('SET_ACCESS_TOKEN', accessToken);
           commit('SET_KIP_USER_ID', kipUserId);
           commit('SET_MOBILE', mobile);
+          commit('SET_IS_LOGIN', 'haveLoggedIn');
           dispatch('getUserDetail');
-          const memberRes = await getVIPIntegral()
-          console.log(271, memberRes);
-          dispatch('updateUnionIdActive', {
-            unionId: unionId,
-            openId: openid || uni.getStorageSync('openid'),
-            vipCode: memberRes.vipcode
-          })
-          // const memberRes = await crmQueryMemberInfo({
-          //   groupId,
-          //   kipUserId,
-          //   mallId,
-          // });
-          // 请求 projectId
-          /* window.toWXSendMsg({
-            type: 'getProjectId',
-            options: {},
-          }); */
-          // const marketListRes = await kipAllCities();
-          if ( memberRes) {
-            // dispatch('getUserDetail');
-            commit('SET_MEMBER',memberRes);
-          }
-          // console.log(929292, marketListRes);
+          dispatch('memberInit',{
+            openid,
+            unionId,
+            isError: true
+          });
         } else {
           dispatch('updateUnionIdActive', {
             unionId: unionId,
@@ -305,10 +288,31 @@ const store = new Vuex.Store({
       }
     },
     async getUserDetail({ commit }) {
-      const res = await kipGetUserDetail();
-      console.log(296, res);
-      commit('SET_USER_INFO', res.data);
-      // console.log('user_info', res);
+      try {
+        const res = await kipGetUserDetail();
+        // console.log(296, res);
+        commit('SET_USER_INFO', res.data);
+        // console.log('user_info', res);
+      } catch (err) {
+        console.log(err, err);
+      }
+    },
+    async memberInit({ commit, dispatch },{unionId, openid, isError = true}) {
+      try {
+        const memberRes = await getVIPIntegral()
+        if (memberRes && isError) {
+          await dispatch('updateUnionIdActive', {
+            unionId: unionId,
+            openId: openid || uni.getStorageSync('openid'),
+            vipCode: memberRes.vipcode
+          })
+          commit('SET_MEMBER', memberRes);
+        }
+      } catch (err) {
+        console.log(err);
+      }
+      const member = uni.getStorageSync('member')
+      return JSON.stringify(member) === '{}'
     },
     // updateUnionId
     async updateUnionIdActive({ commit }, { openId, unionId, vipCode = null }) {