|
@@ -1,5 +1,6 @@
|
|
// import { login, logout, getInfo } from '@/api/user'
|
|
// import { login, logout, getInfo } from '@/api/user'
|
|
import { login, getInfo } from '@/api/user'
|
|
import { login, getInfo } from '@/api/user'
|
|
|
|
+import { getOrganizeInfo } from '@/api/other'
|
|
import { getToken, setToken, removeToken } from '@/utils/auth'
|
|
import { getToken, setToken, removeToken } from '@/utils/auth'
|
|
import router, { resetRouter } from '@/router'
|
|
import router, { resetRouter } from '@/router'
|
|
// import store from '@/store'
|
|
// import store from '@/store'
|
|
@@ -8,7 +9,8 @@ const state = {
|
|
token: getToken(),
|
|
token: getToken(),
|
|
name: '',
|
|
name: '',
|
|
avatar: '',
|
|
avatar: '',
|
|
- introduction: '',
|
|
|
|
|
|
+ systemName: '',
|
|
|
|
+ systemImage: '',
|
|
roles: []
|
|
roles: []
|
|
}
|
|
}
|
|
|
|
|
|
@@ -16,8 +18,11 @@ const mutations = {
|
|
SET_TOKEN: (state, token) => {
|
|
SET_TOKEN: (state, token) => {
|
|
state.token = token
|
|
state.token = token
|
|
},
|
|
},
|
|
- SET_INTRODUCTION: (state, introduction) => {
|
|
|
|
- state.introduction = introduction
|
|
|
|
|
|
+ SET_SYSTEM_NAME: (state, systemName) => {
|
|
|
|
+ state.systemName = systemName
|
|
|
|
+ },
|
|
|
|
+ SET_SYSTEM_IMAGE: (state, systemImage) => {
|
|
|
|
+ state.systemImage = systemImage
|
|
},
|
|
},
|
|
SET_NAME: (state, name) => {
|
|
SET_NAME: (state, name) => {
|
|
state.name = name
|
|
state.name = name
|
|
@@ -31,6 +36,22 @@ const mutations = {
|
|
}
|
|
}
|
|
|
|
|
|
const actions = {
|
|
const actions = {
|
|
|
|
+ getSysInfo: function({ commit, state }, organizeID) {
|
|
|
|
+ return new Promise((resolve, reject) => {
|
|
|
|
+ getOrganizeInfo({ id: organizeID }).then(response => {
|
|
|
|
+ const { data } = response
|
|
|
|
+ if (data) {
|
|
|
|
+ const { systemName, systemImage } = data
|
|
|
|
+ commit('SET_SYSTEM_NAME', systemName)
|
|
|
|
+ commit('SET_SYSTEM_IMAGE', systemImage)
|
|
|
|
+ }
|
|
|
|
+ resolve(data)
|
|
|
|
+ }).catch(error => {
|
|
|
|
+ reject(error)
|
|
|
|
+ })
|
|
|
|
+ })
|
|
|
|
+ },
|
|
|
|
+
|
|
// user login
|
|
// user login
|
|
login: function({ commit }, userInfo) {
|
|
login: function({ commit }, userInfo) {
|
|
const { account, password, organizeID } = userInfo
|
|
const { account, password, organizeID } = userInfo
|
|
@@ -60,12 +81,11 @@ const actions = {
|
|
reject('getInfo: roles must be a non-null array!')
|
|
reject('getInfo: roles must be a non-null array!')
|
|
} */
|
|
} */
|
|
data.roles = ['admin']
|
|
data.roles = ['admin']
|
|
- data.introduction = 'I am a super administrator'
|
|
|
|
- const { roles, account, avatar, introduction } = data
|
|
|
|
|
|
+ const { roles, accountName, avatar } = data
|
|
commit('SET_ROLES', roles)
|
|
commit('SET_ROLES', roles)
|
|
- commit('SET_NAME', account)
|
|
|
|
|
|
+ commit('SET_NAME', accountName)
|
|
commit('SET_AVATAR', avatar)
|
|
commit('SET_AVATAR', avatar)
|
|
- commit('SET_INTRODUCTION', introduction)
|
|
|
|
|
|
+ // commit('SET_SYSTEM_NAME', introduction)
|
|
resolve(data)
|
|
resolve(data)
|
|
}).catch(error => {
|
|
}).catch(error => {
|
|
reject(error)
|
|
reject(error)
|