|
@@ -30,19 +30,21 @@ const actions = {
|
|
|
//wx登陆,openid存在,user中是openid和qrcode;正常登陆,user中是mobile和passwd
|
|
|
if (isWx) res = await this.$axios.$post(`${api.wxLogin}`, user);
|
|
|
else res = await this.$axios.$post(`${api.interface}`, user);
|
|
|
- const setUser = (token, commit) => {
|
|
|
+ const setUser = async (token, commit) => {
|
|
|
localStorage.setItem('token', token);
|
|
|
- dispatch('toGetUser');
|
|
|
+ let userInfo = await dispatch('toGetUser');
|
|
|
+ return userInfo;
|
|
|
};
|
|
|
+ let userInfo = {};
|
|
|
if (res.errcode == '0') {
|
|
|
- setUser(res.data.key, commit);
|
|
|
+ userInfo = await setUser(res.data.key, commit);
|
|
|
Notification({
|
|
|
title: '登录成功',
|
|
|
// message: `欢迎,${user.user_name}`,
|
|
|
type: 'success',
|
|
|
duration: 2000,
|
|
|
});
|
|
|
- return res;
|
|
|
+ return userInfo;
|
|
|
} else {
|
|
|
if (needReturn) return res;
|
|
|
else {
|
|
@@ -71,13 +73,15 @@ const actions = {
|
|
|
}
|
|
|
console.log('用户');
|
|
|
let res = await axios.post(api.getUser, { key: key });
|
|
|
+ let user = {};
|
|
|
if (res.data.errcode == '0') {
|
|
|
let token = _.get(res, `data.data.token`);
|
|
|
if (token) {
|
|
|
- let user = jwt.decode(token);
|
|
|
+ user = jwt.decode(token);
|
|
|
commit('setUser', user, { root: true });
|
|
|
}
|
|
|
}
|
|
|
+ return user;
|
|
|
},
|
|
|
async toGetMenu({ commit }, payload) {
|
|
|
const res = await this.$axios.$get(api.getMenu, payload);
|