From e04d6a8904fd0c93b931551d8feea0943bae8eac Mon Sep 17 00:00:00 2001 From: cloudroam <cloudroam> Date: 星期四, 12 六月 2025 18:11:06 +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