Explorar o código

feat: 刷新数量

linwenxin hai 1 ano
pai
achega
696d32ace5
Modificáronse 2 ficheiros con 8 adicións e 3 borrados
  1. 7 3
      src/App.vue
  2. 1 0
      src/pages/login/indexs.vue

+ 7 - 3
src/App.vue

@@ -35,7 +35,10 @@
         this.updateUserInfo();
       });
 
-      this.updateUserInfo();
+      if (this.$store.state.user.token) {
+        this.updateUserInfo();
+      }
+
       // #endif
 
       uni.getSystemInfo({
@@ -72,8 +75,9 @@
           if (getUserValTimeId) {
             clearTimeout(getUserValTimeId)
           }
-          getUserInfo()
-          getUserValTimeId = setTimeout(getUserVal, 2000)
+          getUserInfo().then(res => {
+            getUserValTimeId = setTimeout(getUserVal, 2000)
+          })
         })()
       },
       // #endif

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

@@ -112,6 +112,7 @@
               this.$store.commit("user/set_name", res.data.name)
               this.$store.commit("user/set_avatar", res.data.avatar)
               this.$store.commit("user/set_userId", res.data.baseUserId)
+              uni.$emit("updateUserInfo")
               this.$navToPage({
                 url: "/pages/index/index"
               }, "switchTab")