2023-12-14 23:29:36 +08:00
|
|
|
|
<template>
|
|
|
|
|
|
<div class="avatar">
|
|
|
|
|
|
<div class="avatar-left">
|
2023-12-21 12:56:06 +08:00
|
|
|
|
<div v-if="props.isSelf" class="avatar-center">
|
2024-01-07 20:51:20 +08:00
|
|
|
|
<el-avatar :size="props.size" :src="iconUrl" />
|
2023-12-14 23:29:36 +08:00
|
|
|
|
<div class="nick">{{ userInfo.nick }}</div>
|
|
|
|
|
|
</div>
|
2024-01-07 20:51:20 +08:00
|
|
|
|
<div v-if="!props.isSelf" class="avatar-card">
|
|
|
|
|
|
<!-- 悬浮卡片 -->
|
|
|
|
|
|
<userInfo-card :userInfo="userInfo" :iconUrl="iconUrl" />
|
|
|
|
|
|
<div class="content">
|
|
|
|
|
|
<div class="nick" :class="{ mt_1: props.time != 'undefined' }">
|
|
|
|
|
|
<div class="text">{{ userInfo.nick }}</div>
|
|
|
|
|
|
<div class="level">
|
|
|
|
|
|
<el-tag round effect="light" type="success" v-if="userInfo.level"
|
2024-01-29 11:20:40 +08:00
|
|
|
|
>{{ userInfo.level }}-{{userInfo.levelName}} 等级</el-tag
|
2024-01-07 20:51:20 +08:00
|
|
|
|
>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
<div class="status" v-if="userInfo.userLimit">
|
2024-01-27 10:55:12 +08:00
|
|
|
|
|
|
|
|
|
|
<UserLimitTag :userLimit="userInfo.userLimit"/>
|
|
|
|
|
|
|
2024-01-07 20:51:20 +08:00
|
|
|
|
</div>
|
2023-12-23 15:02:49 +08:00
|
|
|
|
</div>
|
2024-01-07 20:51:20 +08:00
|
|
|
|
<div class="remarks" v-if="props.time">{{ props.time }}</div>
|
|
|
|
|
|
<div class="remarks">
|
|
|
|
|
|
<slot name="bottom" />
|
2023-12-23 15:02:49 +08:00
|
|
|
|
</div>
|
2023-12-14 10:15:23 +08:00
|
|
|
|
</div>
|
2023-12-14 23:29:36 +08:00
|
|
|
|
</div>
|
|
|
|
|
|
<div class="info" v-if="!props.isSelf">
|
|
|
|
|
|
<el-tag class="ml-2" type="warning">V8</el-tag>
|
2024-01-17 16:31:01 +08:00
|
|
|
|
<el-tag class="ml-2" type="danger">核心</el-tag>
|
2023-12-14 23:29:36 +08:00
|
|
|
|
</div>
|
2023-12-21 12:56:06 +08:00
|
|
|
|
<el-button
|
|
|
|
|
|
v-if="props.showWatching"
|
|
|
|
|
|
type="primary"
|
|
|
|
|
|
size="small"
|
|
|
|
|
|
icon="Plus"
|
|
|
|
|
|
>关注</el-button
|
|
|
|
|
|
>
|
2023-12-14 10:15:23 +08:00
|
|
|
|
</div>
|
2023-12-14 23:29:36 +08:00
|
|
|
|
</div>
|
2023-12-14 10:15:23 +08:00
|
|
|
|
</template>
|
|
|
|
|
|
<script setup>
|
2023-12-14 23:29:36 +08:00
|
|
|
|
import useUserStore from "@/stores/user";
|
|
|
|
|
|
import { reactive, watch, onMounted, computed, ref } from "vue";
|
2023-12-24 21:26:04 +08:00
|
|
|
|
import { upload } from "@/apis/fileApi";
|
2024-01-07 20:51:20 +08:00
|
|
|
|
import useAuths from "@/hooks/useAuths";
|
|
|
|
|
|
import UserInfoCard from "./UserInfoCard/index.vue";
|
2024-01-27 10:55:12 +08:00
|
|
|
|
import UserLimitTag from "./UserLimitTag.vue";
|
|
|
|
|
|
|
2024-01-07 20:51:20 +08:00
|
|
|
|
|
|
|
|
|
|
const { getToken } = useAuths();
|
|
|
|
|
|
const isHasToken = getToken();
|
2023-12-24 21:26:04 +08:00
|
|
|
|
|
2023-12-14 10:15:23 +08:00
|
|
|
|
//userInfo
|
|
|
|
|
|
//{icon,name,role,id},根据判断userInfo是否等于未定义,来觉得是当前登录用户信息,还是其他人信息
|
2023-12-14 23:29:36 +08:00
|
|
|
|
const props = defineProps([
|
|
|
|
|
|
"size",
|
|
|
|
|
|
"showWatching",
|
|
|
|
|
|
"time",
|
|
|
|
|
|
"userInfo",
|
|
|
|
|
|
"isSelf",
|
|
|
|
|
|
]);
|
2023-12-14 10:15:23 +08:00
|
|
|
|
const userStore = useUserStore();
|
|
|
|
|
|
const userInfo = reactive({
|
2023-12-14 23:29:36 +08:00
|
|
|
|
icon: "",
|
|
|
|
|
|
nick: "",
|
|
|
|
|
|
role: [],
|
|
|
|
|
|
id: "",
|
2023-12-23 18:47:28 +08:00
|
|
|
|
level: "",
|
|
|
|
|
|
userLimit: "",
|
2024-01-17 16:31:01 +08:00
|
|
|
|
userName:""
|
2023-12-14 10:15:23 +08:00
|
|
|
|
});
|
2024-01-03 10:48:28 +08:00
|
|
|
|
const iconUrl = ref("/acquiesce.png");
|
2023-12-24 21:26:04 +08:00
|
|
|
|
const iconUrlHandler = (icon) => {
|
2023-12-14 23:29:36 +08:00
|
|
|
|
if (
|
|
|
|
|
|
userInfo.icon == null ||
|
|
|
|
|
|
userInfo.icon == undefined ||
|
|
|
|
|
|
userInfo.icon == ""
|
|
|
|
|
|
) {
|
2024-01-03 10:48:28 +08:00
|
|
|
|
return "/acquiesce.png";
|
2023-12-24 21:26:04 +08:00
|
|
|
|
} else {
|
|
|
|
|
|
return import.meta.env.VITE_APP_BASEAPI + "/file/" + icon;
|
2023-12-14 23:29:36 +08:00
|
|
|
|
}
|
|
|
|
|
|
};
|
2023-12-14 10:15:23 +08:00
|
|
|
|
|
|
|
|
|
|
watch(userStore, (n) => {
|
2023-12-24 21:51:28 +08:00
|
|
|
|
Init();
|
2023-12-14 23:29:36 +08:00
|
|
|
|
});
|
2023-12-14 10:15:23 +08:00
|
|
|
|
|
2023-12-14 23:29:36 +08:00
|
|
|
|
watch(
|
|
|
|
|
|
() => props,
|
|
|
|
|
|
(n) => {
|
2023-12-14 10:15:23 +08:00
|
|
|
|
Init();
|
2023-12-14 23:29:36 +08:00
|
|
|
|
},
|
|
|
|
|
|
{ deep: true }
|
|
|
|
|
|
);
|
2023-12-14 10:15:23 +08:00
|
|
|
|
|
|
|
|
|
|
onMounted(() => {
|
2023-12-14 23:29:36 +08:00
|
|
|
|
Init();
|
|
|
|
|
|
});
|
2023-12-14 10:15:23 +08:00
|
|
|
|
|
|
|
|
|
|
const Init = () => {
|
2023-12-14 23:29:36 +08:00
|
|
|
|
//使用传入值
|
|
|
|
|
|
if (props.userInfo != undefined) {
|
|
|
|
|
|
userInfo.icon = props.userInfo.icon;
|
|
|
|
|
|
userInfo.nick = props.userInfo.nick;
|
|
|
|
|
|
userInfo.role = props.userInfo.role;
|
|
|
|
|
|
userInfo.id = props.userInfo.id;
|
2024-01-15 15:44:55 +08:00
|
|
|
|
userInfo.money=props.userInfo.money;
|
2024-01-07 20:51:20 +08:00
|
|
|
|
userInfo.level = props.userInfo.level;
|
2024-01-07 21:19:54 +08:00
|
|
|
|
userInfo.userLimit = props.userInfo.userLimit;
|
2024-01-17 16:31:01 +08:00
|
|
|
|
userInfo.userName= props.userInfo.userName;
|
2024-01-29 11:20:40 +08:00
|
|
|
|
userInfo.levelName= props.userInfo.levelName;
|
2023-12-14 23:29:36 +08:00
|
|
|
|
iconUrl.value = iconUrlHandler(userInfo.icon);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//使用当前登录用户
|
|
|
|
|
|
else {
|
|
|
|
|
|
userInfo.icon = userStore.icon;
|
|
|
|
|
|
userInfo.nick = userStore.name;
|
|
|
|
|
|
userInfo.role = userStore.role;
|
|
|
|
|
|
userInfo.id = userStore.id;
|
2023-12-16 10:03:29 +08:00
|
|
|
|
iconUrl.value = userInfo.icon;
|
2023-12-14 23:29:36 +08:00
|
|
|
|
}
|
|
|
|
|
|
};
|
2023-12-23 15:02:49 +08:00
|
|
|
|
|
|
|
|
|
|
|
2024-01-27 10:55:12 +08:00
|
|
|
|
|
2023-12-14 10:15:23 +08:00
|
|
|
|
</script>
|
2024-01-07 20:51:20 +08:00
|
|
|
|
|
|
|
|
|
|
<style lang="scss" scoped>
|
2023-12-14 10:15:23 +08:00
|
|
|
|
.mt_1 {
|
2023-12-14 23:29:36 +08:00
|
|
|
|
margin-top: 0.5rem;
|
2023-12-14 10:15:23 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.info {
|
2023-12-21 12:56:06 +08:00
|
|
|
|
flex: 1;
|
2023-12-14 23:29:36 +08:00
|
|
|
|
margin-left: 1rem;
|
2023-12-14 10:15:23 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.info .el-tag {
|
2023-12-14 23:29:36 +08:00
|
|
|
|
margin-right: 1rem;
|
2023-12-14 10:15:23 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.el-icon {
|
2023-12-14 23:29:36 +08:00
|
|
|
|
color: white;
|
2023-12-14 10:15:23 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.avatar {
|
2023-12-21 12:56:06 +08:00
|
|
|
|
flex: 1;
|
2023-12-14 23:29:36 +08:00
|
|
|
|
display: flex;
|
|
|
|
|
|
justify-content: space-between;
|
2024-01-07 22:31:52 +08:00
|
|
|
|
align-items: center;
|
2023-12-14 10:15:23 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2024-01-07 20:51:20 +08:00
|
|
|
|
.avatar-left,
|
|
|
|
|
|
.avatar-card {
|
2023-12-14 23:29:36 +08:00
|
|
|
|
display: flex;
|
2023-12-21 12:56:06 +08:00
|
|
|
|
justify-content: space-between;
|
2023-12-14 23:29:36 +08:00
|
|
|
|
align-items: center;
|
2024-01-07 20:51:20 +08:00
|
|
|
|
.content {
|
|
|
|
|
|
margin-left: 10px;
|
|
|
|
|
|
}
|
|
|
|
|
|
.nick {
|
|
|
|
|
|
display: flex;
|
|
|
|
|
|
align-items: center;
|
|
|
|
|
|
justify-content: space-between;
|
|
|
|
|
|
font-weight: bold;
|
|
|
|
|
|
> div {
|
|
|
|
|
|
margin-right: 10px;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2023-12-14 10:15:23 +08:00
|
|
|
|
}
|
2024-01-07 20:51:20 +08:00
|
|
|
|
|
2023-12-21 12:56:06 +08:00
|
|
|
|
.avatar-center {
|
2024-01-07 20:51:20 +08:00
|
|
|
|
display: flex;
|
2023-12-21 12:56:06 +08:00
|
|
|
|
flex: 2;
|
|
|
|
|
|
}
|
2023-12-14 10:15:23 +08:00
|
|
|
|
.el-avatar {
|
2023-12-16 10:03:29 +08:00
|
|
|
|
margin-right: 1rem;
|
|
|
|
|
|
--el-avatar-bg-color: none;
|
2023-12-14 10:15:23 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.remarks {
|
2023-12-14 23:29:36 +08:00
|
|
|
|
padding-top: 0.5rem;
|
|
|
|
|
|
color: #8c8c8c;
|
2023-12-14 10:15:23 +08:00
|
|
|
|
}
|
2023-12-14 23:29:36 +08:00
|
|
|
|
</style>
|