From 500078714411487af00161e01bd7e0b5efdc3414 Mon Sep 17 00:00:00 2001
From: cloudroam <cloudroam>
Date: 星期四, 07 八月 2025 13:32:32 +0800
Subject: [PATCH] add:热门景点
---
components/comment/comment-item.vue | 34 ++++++++++++++++++++++++++--------
1 files changed, 26 insertions(+), 8 deletions(-)
diff --git a/components/comment/comment-item.vue b/components/comment/comment-item.vue
index 5278054..5d18656 100644
--- a/components/comment/comment-item.vue
+++ b/components/comment/comment-item.vue
@@ -19,7 +19,12 @@
</view>
</view>
<view class="comment-opeartor">
- <up-icon name="heart" size="30rpx" />
+ <up-icon
+ name="heart"
+ size="30rpx"
+ :color="isLiked ? '#FF0000' : '#B9B9B9'"
+ @click="handleLike(props.id)"
+ />
<view class="comment-opeartor-heart-number">{{ likes }}</view>
</view>
</view>
@@ -29,6 +34,7 @@
<view class="sub-comment">
<comment-sub-item
v-for="(item, index) in child"
+ :key="index"
:avatar="item.picture"
:nickname="item.commentUserName"
:isAuthor="item.createBy === filmInfo.createBy"
@@ -36,10 +42,13 @@
:images="getImageList(item)"
:date="item.createTime"
address="湖北"
- :likes="item.likeCount"
- @reply="emitReply"
+ :likes="item.likeCount"
+ :isLiked="item.isLike"
+ :id="item.id"
+ @reply="handleSubReply"
+ @like="handleLike"
:filmInfo="filmInfo"
- />
+ />
</view>
</view>
</template>
@@ -58,12 +67,15 @@
likes: number
child: CommentDTO[]
filmInfo: CommentDTO
+ isLiked: boolean
+ id: number
}
const props = defineProps<Props>()
const emit = defineEmits<{
- (e: 'reply'): void
+ (e: 'reply', id?: number): void
+ (e: 'like', id: number): void
}>()
@@ -83,11 +95,17 @@
const onReply = () => {
- emit('reply')
+ emit('reply', props.id) // ✅ 传递父评论ID
}
-const emitReply = () => {
- emit('reply')
+const handleSubReply = (commentId: number) => {
+ console.log("commentId",commentId)
+ emit('reply', commentId)
+}
+
+const handleLike = (commentId: number) => {
+ console.log('handleLike', commentId)
+ emit('like', commentId)
}
</script>
--
Gitblit v1.9.3