Browse Source

权限修改

renmy 3 years ago
parent
commit
b442bb44f0
2 changed files with 11 additions and 9 deletions
  1. 2 3
      src/store/modules/user.js
  2. 9 6
      src/views/login/index.vue

+ 2 - 3
src/store/modules/user.js

@@ -61,12 +61,11 @@ const actions = {
                 if (!data) {
                     return reject('Verification failed, please Login again.')
                 }
-
+                let userName = localStorage.getItem('userName')
                 const { name, avatar } = data
-
                 commit('SET_NAME', name)
                 commit('SET_AVATAR', avatar)
-                postJson('/api/v1/sys/role/tree', { id: 'admin' }).then(response => {
+                postJson('/api/v1/sys/role/tree', { id: userName }).then(response => {
                     if (response.code === 200) {
                         commit('SET_ROLE', response.data.checked)
                     }

+ 9 - 6
src/views/login/index.vue

@@ -50,7 +50,7 @@
 
 <script>
 import { validUsername } from '@/utils/validate'
-import { postJson, getSort } from '@/api/page'
+import { postJson, postForm } from '@/api/page'
 import { mapGetters, mapState, mapActions } from 'vuex'
 
 export default {
@@ -109,12 +109,15 @@ export default {
         if (valid) {
           this.loading = true
           this.$store.dispatch('user/login', this.loginForm).then(() => {
+            // debugger
+            // postJson('/api/v1/sys/role/tree', { id: this.loginForm.username }).then(response => {
+            //   debugger
+            //   if (response.code === 200) {
+            //     this.setRole(response.data.checked)       
+            //   }
+            // })
+            localStorage.setItem('userName', this.loginForm.username)
             this.$router.push({ path: this.redirect || '/' })
-            postJson('/api/v1/sys/role/tree', { id: this.loginForm.username }).then(response => {
-              if (response.code === 200) {
-                this.setRole(response.data.checked)       
-              }
-            })
             this.loading = false
           }).catch(() => {
             this.loading = false