From 6d42ebb513f0daa953e167520d339d58498aa328 Mon Sep 17 00:00:00 2001 From: zzc <1761997216@qq.com> Date: Tue, 26 May 2026 10:25:33 +0800 Subject: [PATCH] fix: rating --- api/topicItem.js | 4 ++-- pages/rating/detail.vue | 17 ++++++++++++++--- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/api/topicItem.js b/api/topicItem.js index 617f6f6..0aec464 100644 --- a/api/topicItem.js +++ b/api/topicItem.js @@ -29,9 +29,9 @@ export const topicItemCommentLike = async (data) => { }; // 获取评论列表 -export const topicItemCommentList = async (topicId, itemId, page = 1) => { +export const topicItemCommentList = async (topicId, itemId, page = 1, orderBy = 1) => { return request({ - url: `/api/rating/topic/comment/item/list?topicId=${topicId}&itemId=${itemId}&page=${page}`, + url: `/api/rating/topic/comment/item/list?topicId=${topicId}&itemId=${itemId}&page=${page}&orderBy=${orderBy}`, method: "GET", }); }; diff --git a/pages/rating/detail.vue b/pages/rating/detail.vue index dd4b20d..b5b36fc 100644 --- a/pages/rating/detail.vue +++ b/pages/rating/detail.vue @@ -80,8 +80,8 @@ - 最热 - 最新 + 最热 + 最新 @@ -126,6 +126,7 @@ const hasMore = ref(true); const currentPage = ref(1); const currentAction = ref(''); const successPopupRef = ref(null); +const currentTab = ref('hot'); // 'hot' 或 'new' const goBack = () => { uni.navigateBack(); @@ -205,12 +206,22 @@ const handleSendComment = async (payload) => { } }; +const switchTab = (tab) => { + if (currentTab.value === tab) return; + currentTab.value = tab; + currentPage.value = 1; + hasMore.value = true; + comments.value = []; + getCommentsData(); +}; + const getCommentsData = async () => { if (!detailData.value.topicId || !itemId.value || loading.value) return; try { loading.value = true; - const res = await topicItemCommentList(detailData.value.topicId, itemId.value, currentPage.value); + const orderBy = currentTab.value; + const res = await topicItemCommentList(detailData.value.topicId, itemId.value, currentPage.value, orderBy); const list = res?.list || []; const formattedList = list.map(item => ({