|
|
@@ -197,7 +197,7 @@ import { useRouter } from "vue-router";
|
|
|
import { ElMessage } from "element-plus";
|
|
|
import { User, Plus } from "@element-plus/icons-vue";
|
|
|
import type { FormInstance, FormRules, UploadUserFile } from "element-plus";
|
|
|
-import { getList, addAppealNew, saveComment, uploadImg } from "@/api/modules/newLoginApi";
|
|
|
+import { getList, addAppealNew, saveComment, uploadImg, getRatingCount } from "@/api/modules/newLoginApi";
|
|
|
import { localGet } from "@/utils";
|
|
|
import { useUserStore } from "@/stores/modules/user";
|
|
|
|
|
|
@@ -292,32 +292,16 @@ const handleTimeFilterChange = () => {
|
|
|
// 加载统计数据(只在初始化时调用一次)
|
|
|
const loadStatistics = async () => {
|
|
|
try {
|
|
|
- const baseParams = {
|
|
|
- pageNum: 1,
|
|
|
- pageSize: 1,
|
|
|
- phoneId: `store_${localGet("geeker-user").userInfo.phone}`,
|
|
|
- businessType: 5,
|
|
|
- days: timeFilter.value,
|
|
|
- replyStatus: 0,
|
|
|
- storeId: localGet("createdId"),
|
|
|
- userType: 0
|
|
|
- };
|
|
|
-
|
|
|
- // 并行请求各个评论等级的数量
|
|
|
- const [allRes, goodRes, neutralRes, badRes, pendingRes]: any[] = await Promise.all([
|
|
|
- getList({ ...baseParams, commentLevel: 0 }), // 全部
|
|
|
- getList({ ...baseParams, commentLevel: 1 }), // 好评
|
|
|
- getList({ ...baseParams, commentLevel: 2 }), // 中评
|
|
|
- getList({ ...baseParams, commentLevel: 3 }), // 差评
|
|
|
- getList({ ...baseParams, commentLevel: 3, replyStatus: 2 }) // 待回复差评
|
|
|
- ]);
|
|
|
-
|
|
|
- // 更新标签页计数
|
|
|
- tabCounts.all = allRes?.code === 200 ? allRes.data?.total || 0 : 0;
|
|
|
- tabCounts.good = goodRes?.code === 200 ? goodRes.data?.total || 0 : 0;
|
|
|
- tabCounts.neutral = neutralRes?.code === 200 ? neutralRes.data?.total || 0 : 0;
|
|
|
- tabCounts.bad = badRes?.code === 200 ? badRes.data?.total || 0 : 0;
|
|
|
- tabCounts.pending = pendingRes?.code === 200 ? pendingRes.data?.total || 0 : 0;
|
|
|
+ // 从 getRatingCount 获取各评论等级数量
|
|
|
+ const ratingCountRes = await getRatingCount({ businessId: localGet("createdId"), businessType: 1 });
|
|
|
+ const ratingCount = Number(ratingCountRes?.code) === 200 ? ratingCountRes.data : null;
|
|
|
+ // 从 getRatingCount 返回的 data 取值(totalCount / goodCount / midCount / badCount / pending)
|
|
|
+ const rc = ratingCount as Record<string, number | undefined> | null;
|
|
|
+ tabCounts.all = rc?.totalCount ?? 0;
|
|
|
+ tabCounts.good = rc?.goodCount ?? 0;
|
|
|
+ tabCounts.neutral = rc?.midCount ?? 0;
|
|
|
+ tabCounts.bad = rc?.badCount ?? 0;
|
|
|
+ tabCounts.pending = rc?.pending ?? 0;
|
|
|
|
|
|
// 更新统计数据
|
|
|
statistics.totalReviews = tabCounts.all;
|
|
|
@@ -353,18 +337,30 @@ const loadReviewList = async (commentLevel?: string | number, resetPage = false)
|
|
|
// 判断是否是待回复差评
|
|
|
const isPending = level === "pending";
|
|
|
|
|
|
- const params: any = {
|
|
|
+ // 构建请求参数
|
|
|
+ const params: Record<string, any> = {
|
|
|
pageNum: pageNum.value,
|
|
|
pageSize: pageSize.value,
|
|
|
- phoneId: `store_${localGet("geeker-user").userInfo.phone}`,
|
|
|
- businessType: 5, //业务类型(1:订单评论, 2:动态社区评论, 3:活动评论, 4:店铺打卡评论, 5:订单评价, 6:订单评论的评论)
|
|
|
- commentLevel: isPending ? 3 : level, // 待回复差评传3,其他按原值
|
|
|
- days: timeFilter.value, // 评论时间筛选
|
|
|
- replyStatus: isPending ? 2 : 0, // 待回复差评传2,其他传0
|
|
|
- storeId: localGet("createdId"),
|
|
|
- userType: 0
|
|
|
+ businessType: 1, // 1-店铺评价
|
|
|
+ businessId: localGet("createdId"),
|
|
|
+ userId: userStore.userInfo?.userId || userStore.userInfo?.id || ""
|
|
|
};
|
|
|
|
|
|
+ // 评分筛选:0-全部 1-好评(≥4.5) 2-中评(3.0-4.0) 3-差评(0.5-2.5)
|
|
|
+ const levelNum = isPending ? 3 : Number(level);
|
|
|
+ if (levelNum !== 0) {
|
|
|
+ params.searchScore = levelNum;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (timeFilter.value) {
|
|
|
+ params.days = timeFilter.value;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 待回复差评:回复状态 2-未回复
|
|
|
+ if (isPending) {
|
|
|
+ params.replyStatus = 2;
|
|
|
+ }
|
|
|
+
|
|
|
const res: any = await getList(params);
|
|
|
|
|
|
if (res.code === 200) {
|