Commit b90ea7f3 authored by 周远喜's avatar 周远喜

用户信息查看

parent 813aeee0
...@@ -33,6 +33,7 @@ export default { ...@@ -33,6 +33,7 @@ export default {
}, },
mounted() { mounted() {
this.getMenu(); this.getMenu();
this.initUserInfo();
}, },
watch: { watch: {
// 监听路由 控制侧边栏显示 标记当前顶栏菜单(如需要) // 监听路由 控制侧边栏显示 标记当前顶栏菜单(如需要)
...@@ -77,19 +78,11 @@ export default { ...@@ -77,19 +78,11 @@ export default {
res.result.avatarUrl != "" && res.result.avatarUrl != "" &&
res.result.avatarUrl != null res.result.avatarUrl != null
) { ) {
this.userInfo.avatarUrl = res.result.avatarUrl; res.result.avatarUrl = fileUrlDown + res.result.avatarUrl;
this.$store.commit(
"setUserAvatar",
fileUrlDown + res.result.avatarUrl
);
} else {
this.userInfo.avatarUrl = "";
this.$store.commit("setUserAvatar", avatar);
} }
this.userName = res.result.userName; this.$store.commit("admin/user/setUserAvatar", res.result);
localStorage.setItem("userName", this.userName);
} else { } else {
this.$Message.error("查询失败!"); this.$Message.error("用户信息查询失败!");
} }
}); });
}, },
......
...@@ -67,6 +67,7 @@ export default { ...@@ -67,6 +67,7 @@ export default {
let that = this; let that = this;
mgr.getUser().then(function(user) { mgr.getUser().then(function(user) {
if (user) { if (user) {
console.info("user",user)
that.msg = "该用户已经登录"; that.msg = "该用户已经登录";
const userInfos = { const userInfos = {
token: user.access_token, token: user.access_token,
......
...@@ -7,6 +7,12 @@ export const mutations={ ...@@ -7,6 +7,12 @@ export const mutations={
}, },
setUser(state,info){ setUser(state,info){
state.info=info; state.info=info;
},
setUserAvatar(state,user){
let info=state.info;
info.name=user.name;
info.avatar=user.avatarUrl;
state.info=info;
} }
} }
export const actions={ export const actions={
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment