cloudroam
2025-06-13 a4892378960434c17bb20f19e537df54be598142
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>