fix: rating

This commit is contained in:
zzc
2026-05-26 09:52:58 +08:00
parent d9e14b09c6
commit 02bfefa58c
3 changed files with 186 additions and 125 deletions

View File

@@ -87,28 +87,11 @@
</view>
<view class="comment-list">
<view class="comment-item" v-for="comment in comments" :key="comment.id">
<image class="c-avatar" :src="comment.avatar" mode="aspectFill" />
<view class="c-content-wrap">
<view class="c-header">
<view class="c-user-info">
<text class="c-name">{{ comment.name }}</text>
<!-- 用户态度徽章 -->
<ActionBadge v-if="comment.userAction" :action="comment.userAction" />
<view class="c-badge" v-if="comment.badge">
<text class="b-icon">{{ comment.badgeIcon }}</text>
<text class="b-text">{{ comment.badge }}</text>
</view>
</view>
<view class="c-like">
<text class="like-icon"></text>
<text class="like-count">{{ comment.likes }}</text>
</view>
</view>
<text class="c-time">{{ comment.time }}</text>
<text class="c-text">{{ comment.content }}</text>
</view>
</view>
<CommentItem
v-for="(comment, index) in comments"
:key="comment.id"
:comment="comment"
/>
</view>
<!-- 加载更多 -->
@@ -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;

View File

@@ -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}`
});
};