85 lines
1.6 KiB
Plaintext
85 lines
1.6 KiB
Plaintext
<template>
|
|
<view class="avatar-container">
|
|
<image class="avatar" :src="user.avatar" mode="aspectFill"></image>
|
|
<view v-if="user.online" class="online-badge"></view>
|
|
<text v-if="user.vip" class="vip-badge">VIP</text>
|
|
<text v-if="badge !== null && badge > 0" class="message-badge">
|
|
{{ badge !== null && badge > 99 ? '99+' : badge }}
|
|
</text>
|
|
</view>
|
|
</template>
|
|
|
|
<script setup lang="uts">
|
|
import { ISender } from '@/types/chatType.uts'
|
|
type TUser = {
|
|
id : number
|
|
nickname : string
|
|
avatar : string
|
|
online : boolean
|
|
vip : boolean
|
|
}
|
|
const props = defineProps({
|
|
badge: {
|
|
type: Number,
|
|
required: true
|
|
},
|
|
user: {
|
|
type: Object as PropType<ISender>,
|
|
required: true
|
|
}
|
|
})
|
|
const { badge, user } = props
|
|
</script>
|
|
|
|
<style>
|
|
.avatar-container {
|
|
position: relative;
|
|
width: 100rpx;
|
|
height: 100rpx;
|
|
margin-right: 30rpx;
|
|
}
|
|
|
|
.avatar {
|
|
width: 100%;
|
|
height: 100%;
|
|
border-radius: 20rpx;
|
|
background-color: #f0f0f0;
|
|
}
|
|
|
|
.online-badge {
|
|
position: absolute;
|
|
right: 0;
|
|
bottom: 0;
|
|
width: 24rpx;
|
|
height: 24rpx;
|
|
background-color: #4CD964;
|
|
border-radius: 50%;
|
|
border: 4rpx solid #fff;
|
|
}
|
|
|
|
.vip-badge {
|
|
position: absolute;
|
|
left: 0;
|
|
top: 0;
|
|
padding: 4rpx 10rpx;
|
|
background: linear-gradient(to right, #FFD700, #FFA500);
|
|
color: #fff;
|
|
font-size: 20rpx;
|
|
border-radius: 0 0 20rpx 0;
|
|
}
|
|
|
|
.message-badge {
|
|
position: absolute;
|
|
top: -10rpx;
|
|
right: -10rpx;
|
|
min-width: 36rpx;
|
|
height: 36rpx;
|
|
line-height: 36rpx;
|
|
text-align: center;
|
|
background-color: #FF3B30;
|
|
color: #fff;
|
|
font-size: 24rpx;
|
|
border-radius: 18rpx;
|
|
padding: 0 8rpx;
|
|
}
|
|
</style> |