From 7ef0e46cc8770b4fbee6faf3f0721a09e74348b5 Mon Sep 17 00:00:00 2001 From: zzc <1761997216@qq.com> Date: Tue, 26 May 2026 07:29:52 +0800 Subject: [PATCH] fix: rating --- api/topicItem.js | 8 +++++ components/SuccessPopup/SuccessPopup.vue | 9 ++++-- pages/rating/detail.vue | 39 ++++++++++++++++++------ 3 files changed, 44 insertions(+), 12 deletions(-) diff --git a/api/topicItem.js b/api/topicItem.js index cb6580c..6455182 100644 --- a/api/topicItem.js +++ b/api/topicItem.js @@ -18,6 +18,14 @@ export const topicItemComment = async (data) => { }); }; +// 获取评论列表 +export const topicItemCommentList = async (topicId, itemId, page = 1) => { + return request({ + url: `/api/rating/topic/comment/item/list?topicId=${topicId}&itemId=${itemId}&page=${page}`, + method: "GET", + }); +}; + // 获取评分项详情 export const fetchTopicRatingItems = async (itemId) => { return request({ diff --git a/components/SuccessPopup/SuccessPopup.vue b/components/SuccessPopup/SuccessPopup.vue index c02225b..e76bc9d 100644 --- a/components/SuccessPopup/SuccessPopup.vue +++ b/components/SuccessPopup/SuccessPopup.vue @@ -12,8 +12,9 @@ - 评分成功 - 你已将TA评价为「{{ actionData?.label || '...' }}」 + {{ type === 'comment' ? '评论成功' : '评分成功' }} + {{ actionData?.label || '你的锐评已发布' }} + 你已将TA评价为「{{ actionData?.label || '...' }}」 @@ -24,10 +25,12 @@ import { ref } from 'vue'; const visible = ref(false); const showAnim = ref(false); const actionData = ref(null); +const type = ref('rating'); let timer = null; -const show = (action) => { +const show = (action, popupType = 'rating') => { actionData.value = action; + type.value = popupType; visible.value = true; // 留一点时间让DOM渲染,然后添加动画类 diff --git a/pages/rating/detail.vue b/pages/rating/detail.vue index c8f4e47..c74c770 100644 --- a/pages/rating/detail.vue +++ b/pages/rating/detail.vue @@ -127,9 +127,8 @@ import { getStatusBarHeight } from "@/utils/system"; import { onLoad, onPullDownRefresh, onReachBottom } from "@dcloudio/uni-app"; import AttitudePanel from "@/components/AttitudePanel/AttitudePanel.vue"; import SuccessPopup from "@/components/SuccessPopup/SuccessPopup.vue"; -import { fetchTopicRatingItems } from "@/api/topicItem"; import { FILE_BASE_URL } from "@/utils/constants"; -import { topicItemScore } from "@/api/topicItem"; +import { fetchTopicRatingItems, topicItemScore, topicItemComment } from "@/api/topicItem"; const statusBarHeight = ref(getStatusBarHeight() || 44); const loading = ref(false); @@ -181,13 +180,35 @@ const handleActionChange = async (action) => { } }; -const handleSendComment = (payload) => { - console.log('发送评论:', payload); - uni.showToast({ - title: '发送成功', - icon: 'success' - }); - // TODO: 调用接口发送评论,然后更新评论列表 +const handleSendComment = async (payload) => { + if (!detailData.value.topicId || !itemId.value) return; + + try { + uni.showLoading({ title: '发送中...' }); + await topicItemComment({ + topicId: detailData.value.topicId, + itemId: itemId.value, + content: payload.content + }); + uni.hideLoading(); + + // 弹出成功弹窗 + if (successPopupRef.value) { + successPopupRef.value.show({ + emoji: '💬', + label: '你的锐评已发布' + }, 'comment'); + } + + // 刷新页面数据以获取最新评论 + getDetailData(); + } catch (error) { + uni.hideLoading(); + uni.showToast({ + title: '发送失败', + icon: 'none' + }); + } }; const getDetailData = async () => {