瀏覽代碼

从未登录状态切换登录时,更新本地用户信息

john.hong 2 年之前
父節點
當前提交
aeb1e16b25
共有 1 個文件被更改,包括 20 次插入2 次删除
  1. 20 2
      src/pages/parkingFee/mixins/parkingFee.js

+ 20 - 2
src/pages/parkingFee/mixins/parkingFee.js

@@ -122,7 +122,7 @@ export default {
     // 如果用户未登录的话,返回之后,重新获取数据用户的基础数据
     if (!member && !uni.getStorageSync('isLogin') && window?.toWXSendMsg) {
       wxToLoginCallback('parkingFee', (options) => {
-        if(!this.openid) {
+        /*if(!this.openid) {
           this.$store.commit('SET_IS_INIT', false);
           // 请求 projectId
           window.toWXSendMsg({
@@ -144,7 +144,25 @@ export default {
         } else {
           requestInit();
           this.getParkInfo();
-        }
+        }*/
+        this.$store.commit('SET_IS_INIT', false);
+        // 请求 projectId
+        window.toWXSendMsg({
+          type: 'getProjectId',
+          options: {},
+        });
+        window.subscribe('projectId', (newOptions) => {
+          this.$store.dispatch('baseInit', {
+            options: newOptions,
+            callback: () => {
+              this.$nextTick(( ) => {
+                requestInit();
+                this.getParkInfo();
+                this.$store.commit('SET_IS_INIT', true);
+              })
+            },
+          });
+        });
       });
       // return
     }