fix: rating

This commit is contained in:
zzc
2026-05-25 00:01:32 +08:00
parent 8dfe94453b
commit f5534632ff
3 changed files with 211 additions and 13 deletions

View File

@@ -115,6 +115,9 @@
</view>
</view>
</view>
<!-- 评分成功特效弹窗 -->
<SuccessPopup ref="successPopupRef" />
</view>
</template>
@@ -123,6 +126,7 @@ import { ref } from 'vue';
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";
@@ -131,6 +135,7 @@ const statusBarHeight = ref(getStatusBarHeight() || 44);
const loading = ref(false);
const hasMore = ref(true);
const currentAction = ref('');
const successPopupRef = ref(null);
const goBack = () => {
uni.navigateBack();
@@ -151,10 +156,12 @@ const itemId = ref('');
const handleActionChange = async (action) => {
const originAction = detailData.value.userAction;
const originScore = detailData.value.score;
try {
detailData.value.userAction = detailData.value.userAction === action.label ? '' : action.label;
currentAction.value = action.label;
const originScore = detailData.value.score;
const isCancel = detailData.value.userAction === action.label;
try {
detailData.value.userAction = isCancel ? '' : action.label;
currentAction.value = detailData.value.userAction;
const res = await topicItemScore({
topicId: detailData.value.topicId,
@@ -162,11 +169,12 @@ const handleActionChange = async (action) => {
scoreType: action.scoreType
});
detailData.value.score = res?.scoreAvg || originScore;
// 如果是成功评分(非取消),展示特效弹窗
if (!isCancel && successPopupRef.value) {
successPopupRef.value.show(action);
}
} catch (error) {
uni.showToast({
title: '评分失败',
icon: 'none'
});
detailData.value.userAction = originAction;
detailData.value.score = originScore;
currentAction.value = originAction;

View File

@@ -148,6 +148,8 @@
</view>
</view>
<!-- 评分成功特效弹窗 -->
<SuccessPopup ref="successPopupRef" />
</view>
</template>
@@ -158,6 +160,7 @@ import { onPullDownRefresh, onReachBottom, onLoad } from "@dcloudio/uni-app";
import { fetchTopicDetail, fetchTopicRatingItems } from "@/api/topic";
import { FILE_BASE_URL } from "@/utils/constants";
import RatingCard from "@/components/RatingCard/RatingCard.vue";
import SuccessPopup from "@/components/SuccessPopup/SuccessPopup.vue";
import { topicItemScore } from "@/api/topicItem";
// 状态栏高度处理
const statusBarHeight = ref(getStatusBarHeight() || 44);
@@ -166,6 +169,7 @@ const loading = ref(false);
const hasMore = ref(true);
const currentPage = ref(1);
const currentTopicId = ref(null);
const successPopupRef = ref(null);
const goBack = () => {
uni.navigateBack({
@@ -287,19 +291,22 @@ const comments = ref([...mockComments]);
const handleAction = async (item, action) => {
const originAction = item.userAction;
const originScore = item.scoreAvg;
const isCancel = item.userAction === action.label;
try {
item.userAction = item.userAction === action.label ? '' : action.label;
item.userAction = isCancel ? '' : action.label;
const res = await topicItemScore({
topicId: currentTopicId.value,
itemId: item.id,
scoreType: action.scoreType
});
item.scoreAvg = res?.scoreAvg || originScore;
// 如果是成功评分(非取消),展示特效弹窗
if (!isCancel && successPopupRef.value) {
successPopupRef.value.show(action);
}
} catch (error) {
uni.showToast({
title: '评分失败',
icon: 'none'
});
item.userAction = originAction;
item.scoreAvg = originScore;
}