diff --git a/components/SuccessPopup/SuccessPopup.vue b/components/SuccessPopup/SuccessPopup.vue new file mode 100644 index 0000000..c02225b --- /dev/null +++ b/components/SuccessPopup/SuccessPopup.vue @@ -0,0 +1,183 @@ + + + + + \ No newline at end of file diff --git a/pages/rating/detail.vue b/pages/rating/detail.vue index 7c04cd2..c8f4e47 100644 --- a/pages/rating/detail.vue +++ b/pages/rating/detail.vue @@ -115,6 +115,9 @@ + + + @@ -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; diff --git a/pages/rating/index.vue b/pages/rating/index.vue index 227f2dd..23903d8 100644 --- a/pages/rating/index.vue +++ b/pages/rating/index.vue @@ -148,6 +148,8 @@ + + @@ -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; }