tj
2025-06-06 4789476b3fe734b4366ce72079330cea32a4997d
components/comment/comment-item.vue
@@ -28,15 +28,17 @@
      <!-- 子评论区域 -->
      <view class="sub-comment">
        <comment-sub-item
          avatar="https://img.yzcdn.cn/vant/cat.jpeg"
          nickname="图墙精选"
          :isAuthor="true"
          content="如果路线里全是常规景区,没一个特殊的点位..."
          :images="urls2"
          date="2天前"
        v-for="(item, index) in child"
        :avatar="item.picture"
        :nickname="item.commentUserName"
        :isAuthor="item.createBy === filmInfo.createBy"
        :content="item.content"
        :images="getImageList(item)"
        :date="item.createTime"
          address="湖北"
          :likes="30"
         :likes="item.likeCount"
          @reply="emitReply"
        :filmInfo="filmInfo"
        />
      </view>
    </view>
@@ -44,6 +46,7 @@
  
  <script setup lang="ts">
    import { ref, onMounted } from 'vue'
import { CommentDTO } from '@/types/index'
  interface Props {
    avatar: string
    nickname: string
@@ -53,6 +56,8 @@
    date: string
    address: string
    likes: number
  child: CommentDTO[]
  filmInfo: CommentDTO
  }
  
  const props = defineProps<Props>()
@@ -61,13 +66,21 @@
    (e: 'reply'): void
  }>()
  
  const urls2 = ref<string[]>([
    'https://img.yzcdn.cn/vant/cat.jpeg',
    'https://img.yzcdn.cn/vant/cat.jpeg',
    'https://img.yzcdn.cn/vant/cat.jpeg',
    'https://img.yzcdn.cn/vant/cat.jpeg',
    'https://img.yzcdn.cn/vant/cat.jpeg'
  ])
const getImageList = (item: any): string[] => {
  if (!item || !item.filmPictures || typeof item.filmPictures !== 'string') {
    return [];
  }
  try {
    const pictures = JSON.parse(item.filmPictures);
    return Array.isArray(pictures) ? pictures.map((p: any) => p.url) : [];
  } catch (e) {
    console.error('filmPictures JSON parse error:', e, item.filmPictures);
    return [];
  }
};
  
  const onReply = () => {
    emit('reply')
@@ -145,6 +158,7 @@
          align-items: flex-start;
  
          .comment-opeartor-heart-number {
          width: 100%;
            text-align: center;
            font-size: 20rpx;
          }
@@ -158,4 +172,3 @@
    }
  }
  </style>