fix: rating
This commit is contained in:
@@ -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({
|
||||
|
||||
@@ -12,8 +12,9 @@
|
||||
<view class="sparkle s-2">✨</view>
|
||||
<view class="sparkle s-3">✨</view>
|
||||
</view>
|
||||
<text class="title">评分成功</text>
|
||||
<text class="subtitle">你已将TA评价为「{{ actionData?.label || '...' }}」</text>
|
||||
<text class="title">{{ type === 'comment' ? '评论成功' : '评分成功' }}</text>
|
||||
<text class="subtitle" v-if="type === 'comment'">{{ actionData?.label || '你的锐评已发布' }}</text>
|
||||
<text class="subtitle" v-else>你已将TA评价为「{{ actionData?.label || '...' }}」</text>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
@@ -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渲染,然后添加动画类
|
||||
|
||||
@@ -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 () => {
|
||||
|
||||
Reference in New Issue
Block a user