Files
Yi.Admin/Yi.Bbs.Vue3/src/views/profile/Index.vue

390 lines
9.7 KiB
Vue
Raw Normal View History

2023-12-14 10:15:23 +08:00
<template>
2023-12-24 16:16:56 +08:00
<div class="app-container" style="width: 1300px">
2024-01-16 15:48:15 +08:00
<!-- 老版用户信息页面 -->
2024-01-16 18:49:30 +08:00
<!-- <el-row :gutter="20">
2023-12-24 16:16:56 +08:00
<el-col :span="6" :xs="24">
<el-card class="box-card">
<template v-slot:header>
<div class="clearfix">
<span>个人信息</span>
</div>
</template>
<div>
<div class="text-center">
<userAvatar :user="state.user" />
</div>
<ul class="list-group list-group-striped">
<li class="list-group-item">
2024-01-16 15:48:15 +08:00
<el-icon><User /></el-icon> 账号
2023-12-24 16:16:56 +08:00
<div class="pull-right">{{ state.user.userName }}</div>
</li>
<li class="list-group-item">
<el-icon><Phone /></el-icon> 手机号码
<div class="pull-right">{{ state.user.phone }}</div>
</li>
<li class="list-group-item">
<el-icon><Message /></el-icon> 用户邮箱
<div class="pull-right">{{ state.user.email }}</div>
</li>
<li class="list-group-item">
<el-icon><Avatar /></el-icon> 所属角色
<div class="pull-right">
<span v-for="role in state.roles" :key="role.id"
>{{ role.roleName }} /</span
>
</div>
</li>
<li class="list-group-item">
2024-01-16 15:48:15 +08:00
<el-icon><Stopwatch /></el-icon> 注册日期
2023-12-24 16:16:56 +08:00
<div class="pull-right">{{ state.user.creationTime }}</div>
</li>
</ul>
</div>
</el-card>
</el-col>
<el-col :span="18" :xs="24">
<el-card>
<template v-slot:header>
<div class="clearfix">
<span>基本资料</span>
</div>
</template>
<el-tabs v-model="activeTab">
<el-tab-pane label="基本资料" name="userinfo">
<userInfo :user="state.user" />
</el-tab-pane>
<el-tab-pane label="修改密码" name="resetPwd">
<resetPwd />
</el-tab-pane>
2024-01-15 15:44:55 +08:00
<el-tab-pane label="第三方快捷登录" name="accountSetting">
<accountSet />
</el-tab-pane>
2023-12-24 16:16:56 +08:00
</el-tabs>
</el-card>
</el-col>
2024-01-16 18:49:30 +08:00
</el-row> -->
2024-01-16 15:48:15 +08:00
<!-- 新版用户信息页面 -->
2024-01-16 18:49:30 +08:00
<el-row>
2024-01-16 15:48:15 +08:00
<el-col :span="24">
<div class="div-top">
2024-01-16 18:49:30 +08:00
<div class="div-top-user">
2024-01-17 11:47:36 +08:00
<div class="user-icon text-center">
2024-01-17 16:31:01 +08:00
<userAvatar :user="state.user" :isDisable="!iSCurrentUserLogin"/>
2024-01-17 11:47:36 +08:00
</div>
2024-01-16 15:48:15 +08:00
<div class="user-info">
<div class="user-nick">
<div class="user-nick-left">{{ state.user.nick }}
<el-tag effect="light" type="success"
2024-01-29 11:20:40 +08:00
>{{state.user.level }}-{{state.user.levelName}} 等级</el-tag
>
2024-01-27 10:55:12 +08:00
<UserLimitTag :userLimit="state.user.userLimit"/>
<el-tag effect="light" type="success"
>{{state.user.money }} 钱钱</el-tag
>
</div>
2024-01-17 11:47:36 +08:00
<div class="user-nick-right">
其他
</div>
2024-01-16 15:48:15 +08:00
</div>
<div class="user-remark">
2024-01-27 17:45:04 +08:00
<span>{{ state.user.agreeNumber }}</span> 点赞 | <span>{{ state.user.discussNumber }}</span> 主题 | <span>{{ state.user.commentNumber }}</span> 评论
2024-01-17 11:47:36 +08:00
2024-01-16 15:48:15 +08:00
</div>
2024-01-17 11:47:36 +08:00
<el-divider />
2024-01-16 18:49:30 +08:00
<div>
2024-01-17 11:47:36 +08:00
<p>账号{{ state.user.userName }}</p>
<p>手机号码{{ state.user.phone }}</p>
<p>注册时间{{state.user.creationTime}}</p>
<p>个人简介你好世界~</p>
2024-01-16 18:49:30 +08:00
</div>
2024-01-16 15:48:15 +08:00
</div>
</div>
<div class="user-edit">
<div class="user-info-bottom">
2024-01-16 18:49:30 +08:00
<el-tabs v-model="activeTab" class="user-edit-tab">
<el-tab-pane label="基本资料" name="userinfo">
2024-01-17 16:31:01 +08:00
<userInfo :user="state.user" :isDisable="!iSCurrentUserLogin" />
2024-01-16 18:49:30 +08:00
</el-tab-pane>
2024-01-17 16:31:01 +08:00
<el-tab-pane v-if="iSCurrentUserLogin" label="修改密码" name="resetPwd">
2024-01-16 18:49:30 +08:00
<resetPwd />
</el-tab-pane>
2024-01-17 16:31:01 +08:00
<el-tab-pane v-if="iSCurrentUserLogin" label="第三方快捷登录" name="accountSetting">
2024-01-16 18:49:30 +08:00
<accountSet />
</el-tab-pane>
</el-tabs>
2024-01-16 15:48:15 +08:00
</div>
</div>
</div>
</el-col>
</el-row>
<el-row class="div-bottom">
2024-01-17 11:47:36 +08:00
<el-col :span="5" class="div-bottom-left">
<el-menu
default-active="1"
class="el-menu-left"
>
<el-menu-item index="1">
<el-icon><ChatLineRound /></el-icon>
<span>主题</span>
</el-menu-item>
<el-menu-item index="2">
<el-icon><Discount /></el-icon>
<span>收藏</span>
</el-menu-item>
<el-menu-item index="3">
<el-icon><ChatDotRound /></el-icon>
<span>评论</span>
</el-menu-item>
<el-menu-item index="4">
<el-icon><View /></el-icon>
<span>关注</span>
</el-menu-item>
</el-menu>
</el-col>
2024-01-16 15:48:15 +08:00
<el-col :span="19" class="div-bottom-right">
2024-01-17 11:47:36 +08:00
<div class="div-bottom-right-content">
2024-01-30 15:08:41 +08:00
<div v-for="item in discussList" :key="item.id">
2024-01-17 11:47:36 +08:00
<DisscussCard :discuss="item" />
</div>
2024-01-17 16:31:01 +08:00
</div>
<el-empty v-if="discussList.length == 0" description="空空如也" />
<div v-else class="pagination">
2024-01-17 11:47:36 +08:00
<el-pagination
v-model:current-page="query.skipCount"
v-model:page-size="query.maxResultCount"
:page-sizes="[10, 20, 30, 50]"
:background="true"
layout="total, sizes, prev, pager, next, jumper"
:total="discussTotal"
@size-change="
async (val) => {
await getDiscuss();
}
"
@current-change="
async (val) => {
await getDiscuss();
}
"
/>
</div>
2024-01-16 15:48:15 +08:00
</el-col>
2024-01-16 18:49:30 +08:00
</el-row>
2023-12-24 16:16:56 +08:00
</div>
2023-12-14 10:15:23 +08:00
</template>
<script setup name="Profile">
import userAvatar from "./UserAvatar.vue";
import userInfo from "./UserInfo.vue";
import resetPwd from "./ResetPwd.vue";
import accountSet from "./AccountSetting.vue";
2024-01-17 16:31:01 +08:00
import { getBbsUserProfile } from "@/apis/userApi.js";
2023-12-24 16:16:56 +08:00
import { onMounted, ref, reactive } from "vue";
2024-01-17 11:47:36 +08:00
import { getList } from "@/apis/discussApi.js";
import { useRoute } from "vue-router";
2024-01-17 16:31:01 +08:00
import useAuths from "@/hooks/useAuths";
const { isLogin } = useAuths();
import useUserStore from "@/stores/user";
2024-01-27 10:55:12 +08:00
import UserLimitTag from "@/components/UserLimitTag.vue";
2024-01-17 11:47:36 +08:00
const route = useRoute();
2024-01-17 16:31:01 +08:00
const userStore=useUserStore();
2023-12-14 10:15:23 +08:00
const activeTab = ref("userinfo");
const state = reactive({
user: {},
dept: {},
roles: [],
roleGroup: {},
2023-12-24 16:16:56 +08:00
postGroup: {},
2024-01-17 11:47:36 +08:00
});
2024-01-17 16:31:01 +08:00
const iSCurrentUserLogin=ref(false);
const discussList= ref([]);
2024-01-17 11:47:36 +08:00
const discussTotal=ref(0);
const query = reactive({
skipCount: 1,
maxResultCount: 10,
2024-01-17 16:31:01 +08:00
userName:route.params.userName
2023-12-14 10:15:23 +08:00
});
function getUser() {
2024-01-17 16:31:01 +08:00
getBbsUserProfile(query.userName).then((response) => {
2023-12-24 16:16:56 +08:00
const res = response.data;
2024-01-17 16:31:01 +08:00
state.user = res;
2023-12-14 10:15:23 +08:00
});
2023-12-24 16:16:56 +08:00
}
2024-01-17 11:47:36 +08:00
const getDiscuss=async ()=>
{
const {data:{items,totalCount}}= await getList(query);
discussList.value=items;
discussTotal.value=totalCount;
}
2023-12-24 16:16:56 +08:00
onMounted(() => {
2024-01-17 16:31:01 +08:00
//效验是否登录用户等于当前的userInfo
if(userStore.userName ==query.userName&&isLogin)
{
iSCurrentUserLogin.value=true;
}
2023-12-24 16:16:56 +08:00
getUser();
2024-01-17 11:47:36 +08:00
getDiscuss();
2023-12-24 16:16:56 +08:00
});
2023-12-14 10:15:23 +08:00
</script>
2024-01-16 18:49:30 +08:00
<style scoped lang="scss">
2023-12-14 10:15:23 +08:00
.pull-right {
2023-12-24 16:16:56 +08:00
float: right !important;
2023-12-14 10:15:23 +08:00
}
.list-group-striped > .list-group-item {
2023-12-24 16:16:56 +08:00
border-left: 0;
border-right: 0;
border-radius: 0;
padding-left: 0;
padding-right: 0;
2023-12-14 10:15:23 +08:00
}
.list-group {
2023-12-24 16:16:56 +08:00
padding-left: 0px;
list-style: none;
2023-12-14 10:15:23 +08:00
}
.list-group-item {
2023-12-24 16:16:56 +08:00
border-bottom: 1px solid #e7eaec;
border-top: 1px solid #e7eaec;
margin-bottom: -1px;
padding: 11px 0px;
font-size: 13px;
2023-12-14 10:15:23 +08:00
}
.app-container {
padding: 20px;
}
2024-01-02 21:09:07 +08:00
.text-center {
display: flex;
justify-content: center;
margin-bottom: 10px;
}
2024-01-16 18:49:30 +08:00
2024-01-17 11:47:36 +08:00
$topHeight: 620px;
$userHeight: 220px;
$remarkHeight: $topHeight - $userHeight;
2024-01-16 15:48:15 +08:00
.div-top {
2024-01-17 11:47:36 +08:00
padding-top: 10px;
2024-01-16 15:48:15 +08:00
background-color: #ffffff;
2024-01-16 18:49:30 +08:00
min-height: $topHeight;
2024-01-16 15:48:15 +08:00
margin-top: 30px;
font-size: 14px;
color: #555666;
2024-01-16 18:49:30 +08:00
&-user {
display: flex;
width: 100%;
height: $userHeight;
.user-icon {
flex: 1;
height: $userHeight;
2024-01-17 11:47:36 +08:00
padding: 10px;
2024-01-16 18:49:30 +08:00
}
.user-info {
2024-01-17 11:47:36 +08:00
padding-left: 10px;
2024-01-16 18:49:30 +08:00
flex: 9;
height: $userHeight;
.user-nick {
display: flex;
justify-content: space-between;
padding-top: 5px;
padding-bottom: 5px;
&-left {
2024-01-17 11:47:36 +08:00
color:#222226;
font-size: 23px;
font-weight: 800;
.el-tag{
margin-right: 10px;
}
2024-01-17 11:47:36 +08:00
}
&-right{
margin-right: 30px;
2024-01-16 18:49:30 +08:00
}
}
2024-01-16 15:48:15 +08:00
2024-01-16 18:49:30 +08:00
.user-remark span {
font-size: larger;
font-weight: bold;
color: black;
}
2024-01-16 15:48:15 +08:00
2024-01-17 11:47:36 +08:00
p {
margin-bottom: 10px;
2024-01-16 18:49:30 +08:00
}
}
}
.user-edit {
height: $remarkHeight;
flex: 1 0 auto;
2024-01-17 11:47:36 +08:00
margin-left: 10%;
padding-left: 20px;
2024-01-16 15:48:15 +08:00
2024-01-16 18:49:30 +08:00
}
2024-01-16 15:48:15 +08:00
}
2024-01-17 11:47:36 +08:00
.el-divider--horizontal
{
margin-bottom: 10px;
}
2024-01-16 18:49:30 +08:00
.user-edit-tab
{
width: 80%;
2024-01-16 15:48:15 +08:00
}
2024-01-17 11:47:36 +08:00
.pagination
{
display: flex;
justify-content: center;
padding: 20px 0;
}
2024-01-16 15:48:15 +08:00
.div-bottom {
margin-top: 20px;
2024-01-16 18:49:30 +08:00
&-left {
2024-01-17 11:47:36 +08:00
padding-top: 30px;
height: 280px;
background-color: #FFFFFF;
2024-01-16 18:49:30 +08:00
}
&-right {
background-color: #f0f2f5;
padding-left: 20px;
&-content {
width: 100%;
2024-01-17 11:47:36 +08:00
background-color: #FFFFFF;
2024-01-16 18:49:30 +08:00
}
}
2024-01-17 11:47:36 +08:00
.el-menu
{
height: 100%;
}
.el-menu-item
{
justify-content: center;
}
2024-01-16 15:48:15 +08:00
}
2023-12-24 16:16:56 +08:00
</style>