diff --git a/components/CommentItem/CommentItem.vue b/components/CommentItem/CommentItem.vue new file mode 100644 index 0000000..6221b53 --- /dev/null +++ b/components/CommentItem/CommentItem.vue @@ -0,0 +1,173 @@ + + + + + \ No newline at end of file diff --git a/pages/rating/detail.vue b/pages/rating/detail.vue index 3cefc66..158b726 100644 --- a/pages/rating/detail.vue +++ b/pages/rating/detail.vue @@ -87,28 +87,11 @@ - - - - - - - - {{ comment.time }} - {{ comment.content }} - - + @@ -130,6 +113,7 @@ import { onLoad, onPullDownRefresh, onReachBottom } from "@dcloudio/uni-app"; import AttitudePanel from "@/components/AttitudePanel/AttitudePanel.vue"; import SuccessPopup from "@/components/SuccessPopup/SuccessPopup.vue"; import ActionBadge from "@/components/ActionBadge/ActionBadge.vue"; +import CommentItem from "@/components/CommentItem/CommentItem.vue"; import { FILE_BASE_URL } from "@/utils/constants"; import { fetchTopicRatingItems, topicItemScore, topicItemComment, topicItemCommentList } from "@/api/topicItem"; import { formatDate } from "@/utils/date"; @@ -227,7 +211,7 @@ const getCommentsData = async () => { try { loading.value = true; const res = await topicItemCommentList(detailData.value.topicId, itemId.value, currentPage.value); - const list = res?.list || []; + const list = res?.list || []; const formattedList = list.map(item => ({ id: item.id, @@ -248,7 +232,7 @@ const getCommentsData = async () => { } // 假设每页10条,如果返回的少于10条则没有更多了 - hasMore.value = list.length >= 10; + hasMore.value = list.length >= 6; } catch (error) { console.error('获取评论列表失败:', error); } finally { @@ -270,7 +254,7 @@ const getDetailData = async () => { avatar: data.avatarUrl ? `${FILE_BASE_URL}${data.avatarUrl}` : '', aiSummary: data.description || '暂无总结', hotScore: data.hotScore || '0.00', - topicId: data.topicId || '', + topicId: data.topicId || detailData.value.topicId || '', ratingCount: data.scoreCount || 0, userAction: data.userAction || "" }; @@ -303,6 +287,9 @@ const getDetailData = async () => { }; onLoad((options) => { + if (options.topicId) { + detailData.value.topicId = options.topicId; + } if (options.itemId) { itemId.value = options.itemId; getDetailData(); @@ -648,105 +635,6 @@ onReachBottom(() => { flex-direction: column; } -.comment-item { - display: flex; - padding: 32rpx 0; - position: relative; -} - -.comment-item::after { - content: ''; - position: absolute; - bottom: 0; - left: 104rpx; /* 头像宽度(80) + 间距(24) */ - right: 0; - height: 2rpx; - background-color: #f0f2f7; -} - -.comment-item:last-child::after { - display: none; -} - -.c-avatar { - width: 80rpx; - height: 80rpx; - border-radius: 50%; - margin-right: 24rpx; - background-color: #f5f6fa; - flex-shrink: 0; - border: 2rpx solid #f0f2f7; -} - -.c-content-wrap { - flex: 1; -} - -.c-header { - display: flex; - justify-content: space-between; - align-items: flex-start; - margin-bottom: 8rpx; -} - -.c-user-info { - display: flex; - align-items: center; - flex-wrap: wrap; -} - -.c-name { - font-size: 30rpx; - font-weight: 800; - color: #111; - margin-right: 16rpx; -} - -.c-badge { - display: flex; - align-items: center; - background: linear-gradient(90deg, #f5f6fa, #f0f2f7); - padding: 4rpx 16rpx; - border-radius: 100rpx; -} - -.b-icon { font-size: 20rpx; margin-right: 6rpx; } -.b-text { font-size: 20rpx; color: #666; font-weight: bold; } - -.c-like { - display: flex; - align-items: center; - color: #999; - font-size: 24rpx; - font-weight: 600; -} - -.like-icon { - width: 32rpx; - height: 32rpx; - background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23999' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M14 9V5a3 3 0 0 0-3-3l-4 9v11h11.28a2 2 0 0 0 2-1.7l1.38-9a2 2 0 0 0-2-2.3zM7 22H4a2 2 0 0 1-2-2v-7a2 2 0 0 1 2-2h3'%3E%3C/path%3E%3C/svg%3E"); - background-size: cover; - margin-right: 8rpx; - transition: transform 0.2s; -} - -.c-like:active .like-icon { - transform: scale(1.1); -} - -.c-time { - font-size: 24rpx; - color: #a1a1a1; - display: block; - margin-bottom: 16rpx; -} - -.c-text { - font-size: 32rpx; - color: #222; - line-height: 1.6; -} - .load-more { text-align: center; padding: 40rpx 0 0; diff --git a/pages/rating/index.vue b/pages/rating/index.vue index 23903d8..0fec746 100644 --- a/pages/rating/index.vue +++ b/pages/rating/index.vue @@ -314,7 +314,7 @@ const handleAction = async (item, action) => { const goToDetail = (itemId) => { uni.navigateTo({ - url: `/pages/rating/detail?itemId=${itemId}` + url: `/pages/rating/detail?itemId=${itemId}&topicId=${currentTopicId.value}` }); };