Browse Source

个人中心bug

lr 2 years ago
parent
commit
fc1dffb972
1 changed files with 50 additions and 45 deletions
  1. 50 45
      src/views/middle.vue

+ 50 - 45
src/views/middle.vue

@@ -246,54 +246,58 @@ export default {
   },
   methods: {
     getUser(token) {
-      ssoGetUser(token).then((res) => {
-        if (!sessionStorage.getItem('dmUser')) {
-          console.log(111)
-          sessionStorage.setItem('dmUser', JSON.stringify(res.data.data))
+      if (!localStorage.getItem('dmUser')) {
+        ssoGetUser(token).then((res) => {
+          // console.log(111)
+          localStorage.setItem('dmUser', JSON.stringify(res.data.data))
           this.dmUser = res.data.data
-        } else {
-          console.log(222)
-          this.dmUser = JSON.parse(sessionStorage.getItem('dmUser'))
-        }
-        console.log(this.dmUser)
-        const user = {
-          username: this.dmUser.user.username,
-          password: this.dmUser.user.ossPassword
-        }
-        this.$store.dispatch('Sso', user).then(() => {
-          crudDmSystem.queryByUserId(this.dmUser.user.id, 0).then((res) => {
-            this.systemList = res
-          })
-          crudDmSystem.queryByUserId(this.dmUser.user.id, 1).then((res) => {
-            this.systemListOne = res
-          })
+          this.allDate()
+        })
+      } else {
+        // console.log(222)
+        this.dmUser = JSON.parse(localStorage.getItem('dmUser'))
+        this.allDate()
+      }
+    },
+    allDate() {
+      // console.log(this.dmUser)
+      const user = {
+        username: this.dmUser.user.username,
+        password: this.dmUser.user.ossPassword
+      }
+      this.$store.dispatch('Sso', user).then(() => {
+        crudDmSystem.queryByUserId(this.dmUser.user.id, 0).then((res) => {
+          this.systemList = res
+        })
+        crudDmSystem.queryByUserId(this.dmUser.user.id, 1).then((res) => {
+          this.systemListOne = res
         })
-        this.getBalance(this.dmUser.user.dmUser.cardid)
-        this.getPlate(
-          this.dmUser.token,
-          this.dmUser.nonce,
-          this.dmUser.timestamp,
-          this.dmUser.user.id
-        )
-        this.getAccessTraffic(
-          this.dmUser.token,
-          this.dmUser.nonce,
-          this.dmUser.timestamp,
-          this.dmUser.user.id
-        )
-        this.orderRecord(
-          this.dmUser.token,
-          this.dmUser.nonce,
-          this.dmUser.timestamp,
-          this.dmUser.user.dmUser.cardid
-        )
-        this.getVisitors(
-          this.dmUser.token,
-          this.dmUser.nonce,
-          this.dmUser.timestamp,
-          this.dmUser.user.id
-        )
       })
+      this.getBalance(this.dmUser.user.dmUser.cardid)
+      this.getPlate(
+        this.dmUser.token,
+        this.dmUser.nonce,
+        this.dmUser.timestamp,
+        this.dmUser.user.id
+      )
+      this.getAccessTraffic(
+        this.dmUser.token,
+        this.dmUser.nonce,
+        this.dmUser.timestamp,
+        this.dmUser.user.id
+      )
+      this.orderRecord(
+        this.dmUser.token,
+        this.dmUser.nonce,
+        this.dmUser.timestamp,
+        this.dmUser.user.dmUser.cardid
+      )
+      this.getVisitors(
+        this.dmUser.token,
+        this.dmUser.nonce,
+        this.dmUser.timestamp,
+        this.dmUser.user.id
+      )
     },
     getBalance(card) {
       axios
@@ -405,6 +409,7 @@ export default {
         type: 'warning'
       }).then(() => {
         this.logout()
+        localStorage.clear()
       })
     },
     logout() {