username password

This commit is contained in:
pixelqm
2019-09-13 16:58:36 +08:00
parent ccefb35790
commit 6738d0eb1a
10 changed files with 77 additions and 66 deletions
+17 -6
View File
@@ -1,9 +1,13 @@
import { login } from '@/api/user'
export const user = {
namespaced: true,
state: {
userInfo: {
uuid: "",
nickName: ""
nickName: "",
headerImg: "",
authority: "",
},
token: ""
},
@@ -18,13 +22,20 @@ export const user = {
}
},
actions: {
// AsyncSetUserInfo({ commit }, loginInfo) {
// }
LoginIn({ commit }, loginInfo) {
login(loginInfo).then(res => {
commit('setUserInfo', res.data.user)
commit('setToken', res.data.token)
return res
}).catch(err => {
console.error(err)
return Promise.reject(err)
})
}
},
getters: {
userName(state) {
return state.userName
userInfo(state) {
return state.userInfo
}
}
}