<template>
|
<view class="comment-item">
|
<view class="comment-item-header">
|
<view class="comment-item-header-left">
|
<view class="avatar">
|
<up-avatar :src="avatar" size="40rpx" shape="circle" />
|
</view>
|
<view class="comment-content">
|
<view class="author">
|
<text class="nickname">{{ nickname }}</text>
|
<view v-if="isAuthor" class="author-flag">作者</view>
|
</view>
|
<view class="comment-content-text">
|
<text>{{ content }}</text>
|
<up-album :urls="images" multipleSize="180rpx" singleSize="500rpx" />
|
<text class="date">{{ date }}</text>
|
<text class="address">{{ address }}</text>
|
<text class="reply" @click="onReply">回复</text>
|
</view>
|
</view>
|
<view class="comment-opeartor">
|
<up-icon
|
name="heart"
|
size="30rpx"
|
:color="isLiked ? '#FF0000' : '#B9B9B9'"
|
@click="() => handleLike(props.id)"
|
/>
|
<view class="comment-opeartor-heart-number">{{ likes }}</view>
|
</view>
|
</view>
|
</view>
|
</view>
|
</template>
|
|
<script setup lang="ts">
|
import { CommentDTO } from '@/types/index'
|
const props = defineProps<{
|
avatar: string
|
nickname: string
|
isAuthor: boolean
|
content: string
|
images: string[]
|
date: string
|
address: string
|
likes: number
|
filmInfo: CommentDTO
|
isLiked: boolean
|
id: number
|
}>()
|
|
const emit = defineEmits<{
|
(e: 'reply', id: number): void
|
(e: 'like', id: number): void
|
}>()
|
|
const onReply = () => {
|
console.log("onReply",props)
|
emit('reply', props.id)
|
}
|
|
const handleLike = (id: number) => { // 添加参数
|
console.log("handleLike", id)
|
emit('like', id)
|
}
|
</script>
|
|
<style lang="scss" scoped>
|
.comment-item {
|
.comment-item-header {
|
display: flex;
|
align-items: center;
|
|
.comment-item-header-left {
|
display: flex;
|
width: 100%;
|
|
.avatar {
|
margin-right: 10rpx;
|
}
|
|
.comment-content {
|
width: 92%;
|
display: flex;
|
flex-direction: column;
|
padding-left: 10rpx;
|
|
.author {
|
display: flex;
|
align-items: center;
|
|
.nickname {
|
font-size: 30rpx;
|
color: #858585;
|
}
|
|
.author-flag {
|
font-size: 18rpx;
|
color: #ff4d4f;
|
font-weight: bold;
|
border-radius: 50rpx;
|
padding: 5rpx 10rpx;
|
background-color: rgba(219, 19, 22, 0.219);
|
width: 40rpx;
|
margin-left: 10rpx;
|
height: 25rpx;
|
}
|
}
|
|
.comment-content-text {
|
margin-top: 10rpx;
|
font-size: 26rpx;
|
letter-spacing: 1rpx;
|
line-height: 1.5;
|
|
.date,
|
.address {
|
font-size: 20rpx;
|
padding: 10rpx;
|
color: #858585;
|
}
|
|
.reply {
|
font-size: 24rpx;
|
padding: 10rpx;
|
color: #2979ff;
|
}
|
}
|
}
|
|
.comment-opeartor {
|
display: flex;
|
flex-direction: column;
|
align-items: flex-start;
|
|
.comment-opeartor-heart-number {
|
width: 100%;
|
text-align: center;
|
font-size: 20rpx;
|
}
|
}
|
}
|
}
|
}
|
</style>
|