添加前端用户信息展示

This commit is contained in:
橙子
2022-04-30 22:04:47 +08:00
parent d6b0c56c35
commit 2f69e0b96c
3 changed files with 21 additions and 19 deletions

View File

@@ -41,6 +41,13 @@ export default {
method: 'put',
data: { user, newPassword }
})
},
getUserAllInfo()
{
return myaxios({
url: `/Account/getUserAllInfo`,
method: 'get'
})
}
}

View File

@@ -16,7 +16,7 @@
<v-list :tile="false" flat nav>
<app-bar-item to="/"
><v-list-item-title v-text="'用户名:'+$store.state.user.user.username"
><v-list-item-title v-text="'用户名:'+$store.state.user.user.userName"
/></app-bar-item>
<app-bar-item to="/"
><v-list-item-title v-text="'称号:'+$store.state.user.user.nick"
@@ -27,7 +27,7 @@
<template v-for="(p, i) in profile">
<v-divider v-if="p.divider" :key="`divider-${i}`" class="mb-2 mt-2" />
<app-bar-item v-else :key="`item-${i}`" to="/">
<app-bar-item v-else :key="`item-${i}`" :to="p.router">
<v-list-item-title v-text="p.title" />
</app-bar-item>
</template>
@@ -40,10 +40,10 @@ export default {
name: "DefaultAccount",
data: () => ({
profile: [
{ title: "用户信息" },
{ title: "用户信息",router:"/userInfo" },
{ title: "设置" },
{ divider: true },
{ title: "登出" },
{ title: "登出",router:"/login" },
],
}),
};

View File

@@ -7,7 +7,7 @@
<v-card-text class="text-center">
<h6 class="text-h6 mb-2 text--secondary">
{{ userInfo.username }}
{{ userInfo.userName }}
</h6>
<h4 class="text-h4 mb-3 text--primary">{{ userInfo.nick }}</h4>
@@ -61,7 +61,7 @@
<v-text-field
color="purple"
label="用户名"
v-model="editInfo.username"
v-model="editInfo.userName"
disabled
/>
</v-col>
@@ -154,12 +154,12 @@
<v-list-item-subtitle>
<v-row>
<v-col
v-for="item in editInfo.roles"
v-for="item in roleInfo"
:key="item.id"
cols="6"
sm="3"
md="1"
>{{ item.role_name }}</v-col
>{{ item.roleName }}</v-col
>
</v-row>
</v-list-item-subtitle>
@@ -178,7 +178,7 @@
cols="6"
sm="3"
md="1"
>{{ item.menu_name }}</v-col
>{{ item.menuName }}</v-col
>
</v-row>
</v-list-item-subtitle>
@@ -264,7 +264,6 @@
<script>
import fileApi from "../api/fileApi";
import userApi from "../api/userApi";
import menuApi from "../api/menuApi";
import accountApi from "../api/accountApi";
export default {
name: "UserProfileView",
@@ -274,6 +273,7 @@ export default {
editInfo: {},
newPassword: "",
dis_newPassword: true,
roleInfo:[],
menuInfo: [],
}),
created() {
@@ -313,19 +313,14 @@ export default {
},
init() {
this.newPassword = "";
userApi.GetUserInRolesByHttpUser().then((resp) => {
this.userInfo = resp.data;
accountApi.getUserAllInfo().then((resp) => {
this.userInfo = resp.data.user;
this.userInfo.password = "";
this.editInfo = Object.assign({}, this.userInfo);
this.roleInfo=resp.data.roles;
this.menuInfo = resp.data.menus;
this.$store.commit('SET_USER',this.userInfo)
});
menuApi.GetTopMenusByHttpUser().then((resp) => {
this.menuInfo = resp.data;
});
},
choiceImg() {
this.$refs.imgFile.dispatchEvent(new MouseEvent("click"));