165 lines
3.5 KiB
Vue
165 lines
3.5 KiB
Vue
<template>
|
|
<div style="width: 100%">
|
|
<div style="position: relative">
|
|
<img
|
|
:src="BorderImgUrl"
|
|
alt=""
|
|
width="100%"
|
|
style="display: block; position: relative; z-index: 2"
|
|
/>
|
|
<!-- 头像 -->
|
|
<div
|
|
style="
|
|
position: absolute;
|
|
top: 0;
|
|
left: 0;
|
|
right: 0;
|
|
z-index: 1;
|
|
display: flex;
|
|
justify-content: center;
|
|
align-items: center;
|
|
"
|
|
:style="{ height: isTopOne ? '55%' : '60%' }"
|
|
>
|
|
<div style="width: 75%">
|
|
<img
|
|
:src="avatarUrl || ''"
|
|
alt=""
|
|
width="100%"
|
|
style="aspect-ratio: 1/1; object-fit: cover"
|
|
:style="{ borderRadius: isRoom ? '0' : '50%' }"
|
|
@error="defaultAvatarUrl"
|
|
/>
|
|
</div>
|
|
</div>
|
|
<!-- 用户名和贡献值 -->
|
|
<div
|
|
style="
|
|
position: absolute;
|
|
bottom: 0;
|
|
left: 0;
|
|
right: 0;
|
|
height: 40%;
|
|
z-index: 3;
|
|
|
|
display: flex;
|
|
flex-direction: column;
|
|
align-items: center;
|
|
"
|
|
>
|
|
<div
|
|
style="
|
|
height: 28%;
|
|
width: 60%;
|
|
display: flex;
|
|
justify-content: center;
|
|
align-items: center;
|
|
"
|
|
>
|
|
<div style="font-weight: 860" class="showText" :class="isTopOne ? 'top1Text' : 'text'">
|
|
{{ name }}
|
|
</div>
|
|
</div>
|
|
<div style="width: 60%; position: relative">
|
|
<img
|
|
src="/src/assets/images/Ranking/coinNumBg.png"
|
|
alt=""
|
|
width="100%"
|
|
style="display: block"
|
|
/>
|
|
<div
|
|
style="position: absolute; inset: 0; display: flex; align-items: center; padding: 3% 5%"
|
|
>
|
|
<img src="/src/assets/icon/coin.png" alt="" width="25%" style="display: block" />
|
|
<div
|
|
style="
|
|
font-weight: 700;
|
|
background: linear-gradient(180deg, #ffe656 0%, #fff 100%);
|
|
background-clip: text;
|
|
-webkit-background-clip: text;
|
|
-webkit-text-fill-color: transparent;
|
|
"
|
|
class="showText"
|
|
:class="isTopOne ? 'top1Text' : 'text'"
|
|
>
|
|
{{ distributionValue }}
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</template>
|
|
|
|
<script setup>
|
|
import { watch } from 'vue'
|
|
|
|
const props = defineProps({
|
|
isRoom: {
|
|
type: Boolean,
|
|
default: false,
|
|
},
|
|
|
|
isTopOne: {
|
|
type: Boolean,
|
|
default: false,
|
|
},
|
|
|
|
avatarUrl: {
|
|
type: String,
|
|
default: '/src/assets/images/WeeklyStar/defaultAvatar.png',
|
|
},
|
|
|
|
BorderImgUrl: {
|
|
type: String,
|
|
required: true,
|
|
},
|
|
|
|
name: {
|
|
type: String,
|
|
default: '',
|
|
},
|
|
|
|
distributionValue: {
|
|
type: String,
|
|
default: '',
|
|
},
|
|
})
|
|
|
|
watch(
|
|
() => props.isRoom,
|
|
(newVal, oldVal) => {
|
|
console.log('isRoom 变化 =>', '新值:', newVal, '旧值:', oldVal)
|
|
}
|
|
)
|
|
|
|
const defaultAvatarUrl = (e) => {
|
|
console.log('头像资源出错')
|
|
e.target.onerror = null //防止循环
|
|
e.target.src = new URL('/src/assets/images/WeeklyStar/defaultAvatar.png', import.meta.url).href
|
|
}
|
|
</script>
|
|
|
|
<style lang="scss" scoped>
|
|
* {
|
|
font-family: 'SF Pro';
|
|
color: black;
|
|
}
|
|
|
|
.showText {
|
|
color: #fff;
|
|
text-align: center;
|
|
overflow: hidden;
|
|
white-space: nowrap;
|
|
text-overflow: ellipsis;
|
|
}
|
|
|
|
.top1Text {
|
|
font-size: 1em;
|
|
}
|
|
|
|
.text {
|
|
font-size: 0.9em;
|
|
}
|
|
</style>
|