|
@@ -15,6 +15,7 @@ const state = {
|
|
btns: [],
|
|
btns: [],
|
|
orgGroup:'',
|
|
orgGroup:'',
|
|
orgName:'',
|
|
orgName:'',
|
|
|
|
+ userId: ''
|
|
};
|
|
};
|
|
|
|
|
|
const mutations = {
|
|
const mutations = {
|
|
@@ -45,18 +46,22 @@ const mutations = {
|
|
SET_LOGINNAME:(state,loginName)=>{
|
|
SET_LOGINNAME:(state,loginName)=>{
|
|
state.loginName = loginName;
|
|
state.loginName = loginName;
|
|
}
|
|
}
|
|
|
|
+ ,
|
|
|
|
+ SET_USERID:(state,userId)=>{
|
|
|
|
+ state.userId = userId;
|
|
|
|
+ }
|
|
};
|
|
};
|
|
|
|
|
|
const actions = {
|
|
const actions = {
|
|
// user login
|
|
// user login
|
|
login({commit}, userInfo) {
|
|
login({commit}, userInfo) {
|
|
const {username,password} = userInfo ;
|
|
const {username,password} = userInfo ;
|
|
|
|
+ commit('SET_LOGINNAME',username);
|
|
return new Promise((resolve, reject) => {
|
|
return new Promise((resolve, reject) => {
|
|
login({username: username.trim(),password: password}).then(
|
|
login({username: username.trim(),password: password}).then(
|
|
response => {
|
|
response => {
|
|
const {data} = response;
|
|
const {data} = response;
|
|
commit('SET_TOKEN', data.token);
|
|
commit('SET_TOKEN', data.token);
|
|
-
|
|
|
|
setToken(data.token);
|
|
setToken(data.token);
|
|
resolve();
|
|
resolve();
|
|
}).catch(error => {
|
|
}).catch(error => {
|
|
@@ -86,13 +91,16 @@ const actions = {
|
|
//头像
|
|
//头像
|
|
commit('SET_AVATAR', data.avatar);
|
|
commit('SET_AVATAR', data.avatar);
|
|
//用户名
|
|
//用户名
|
|
- commit('SET_LOGINNAME',response.userName);
|
|
|
|
|
|
+ if(response.userName){
|
|
|
|
+ commit('SET_LOGINNAME',response.userName);
|
|
|
|
+ }
|
|
//组织名称
|
|
//组织名称
|
|
commit('SET_ORGNAME', orgName);
|
|
commit('SET_ORGNAME', orgName);
|
|
//组织角色
|
|
//组织角色
|
|
if (orgGroup !== null && orgGroup !== '') {
|
|
if (orgGroup !== null && orgGroup !== '') {
|
|
commit('SET_ORG_GROUP', orgGroup.orgGroupCode);
|
|
commit('SET_ORG_GROUP', orgGroup.orgGroupCode);
|
|
}
|
|
}
|
|
|
|
+ commit('SET_USERID', data.userId);
|
|
resolve(response);
|
|
resolve(response);
|
|
}).catch(error => {
|
|
}).catch(error => {
|
|
reject(error);
|
|
reject(error);
|