Prechádzať zdrojové kódy

fix(wealth): isLoggedIn computed → data property to fix login state reactivity

Xiaogang Liao 2 mesiacov pred
rodič
commit
3cc032eb55
1 zmenil súbory, kde vykonal 5 pridanie a 4 odobranie
  1. 5 4
      cfc-frontend/pages/wealth/index.vue

+ 5 - 4
cfc-frontend/pages/wealth/index.vue

@@ -202,6 +202,7 @@ export default {
   data() {
     return {
       showTabTransition: true,
+      isLoggedIn: false,
       role: 'parent',
       isSwitchedChild: false,
       nickname: '',
@@ -234,9 +235,6 @@ export default {
     }
   },
   computed: {
-    isLoggedIn() {
-      return !!uni.getStorageSync('token')
-    },
     activeChildId() {
       if (this.role === 'child') {
         return uni.getStorageSync('currentChildId')
@@ -247,10 +245,13 @@ export default {
   onShow() {
     this.showTabTransition = true
 
-    if (!uni.getStorageSync('token')) {
+    var token = uni.getStorageSync('token')
+    if (!token) {
+      this.isLoggedIn = false
       this._watchPageReady()
       return
     }
+    this.isLoggedIn = true
 
     var currentRole = uni.getStorageSync('currentRole') || uni.getStorageSync('role') || 'parent'
     if (currentRole === 'teacher') {