From a55c8356c8115167e3e96eb9f44fa061eeadab4e Mon Sep 17 00:00:00 2001 From: "pikachu1995@126.com" Date: Wed, 28 Oct 2026 15:09:28 +0800 Subject: [PATCH] =?UTF-8?q?fix(buyer):=20=E4=BF=AE=E5=A4=8D=E5=95=86?= =?UTF-8?q?=E5=93=81=E8=AF=A6=E6=83=85=E9=A1=B5=E6=9C=AA=E7=99=BB=E5=BD=95?= =?UTF-8?q?=E6=97=B6=E8=B0=83=E7=94=A8=E8=AF=84=E4=BB=B7=E6=8E=A5=E5=8F=A3?= =?UTF-8?q?=E5=AF=BC=E8=87=B4=E7=9A=84=E7=99=BB=E5=BD=95=E5=BC=B9=E7=AA=97?= =?UTF-8?q?=E4=B8=8E=E6=9C=AA=E6=8D=95=E8=8E=B7=E6=8A=A5=E9=94=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - goodsComment/goodsCommentNum 改为 needToken,未登录时不再发起请求 - 评价/收藏状态等后台查询增加 skipAuthHandler+skipMessage,token 失效时静默失败 - ShowGoodsDetail 评价接口调用补充 catch 并增加登录守卫 --- buyer/src/api/member.js | 24 ++++++++++++------- .../goodsDetail/ShowGoodsDetail.vue | 9 ++++++- 2 files changed, 24 insertions(+), 9 deletions(-) diff --git a/buyer/src/api/member.js b/buyer/src/api/member.js index bbe177de8..f71a8c58b 100644 --- a/buyer/src/api/member.js +++ b/buyer/src/api/member.js @@ -95,21 +95,25 @@ export function cancelStoreCollect (type, id) { }); } -// 查看是否收藏商品 +// 查看是否收藏商品(后台查询,token 失效时静默失败,不弹全局登录框) export function isCollection (type, goodsId) { return request({ url: `/buyer/member/collection/isCollection/${type}/${goodsId}`, method: Method.GET, - needToken: true + needToken: true, + skipAuthHandler: true, + skipMessage: true }); } -// 查看是否收藏店铺 +// 查看是否收藏店铺(后台查询,token 失效时静默失败,不弹全局登录框) export function isStoreCollection (type, goodsId) { return request({ url: `/buyer/member/storeCollection/isCollection/${type}/${goodsId}`, method: Method.GET, - needToken: true + needToken: true, + skipAuthHandler: true, + skipMessage: true }); } @@ -133,22 +137,26 @@ export function storeCollectList (params) { }); } -// 单个商品评价 +// 单个商品评价(需登录;token 失效时静默失败,不弹全局登录框) export function goodsComment (params) { return request({ url: `/buyer/member/evaluation/${params.goodsId}/goodsEvaluation`, method: Method.GET, - needToken: false, + needToken: true, + skipAuthHandler: true, + skipMessage: true, params }); } -// 商品各评价类别数量 +// 商品各评价类别数量(需登录;token 失效时静默失败,不弹全局登录框) export function goodsCommentNum (goodsId) { return request({ url: `/buyer/member/evaluation/${goodsId}/evaluationNumber`, method: Method.GET, - needToken: false + needToken: true, + skipAuthHandler: true, + skipMessage: true }); } diff --git a/buyer/src/components/goodsDetail/ShowGoodsDetail.vue b/buyer/src/components/goodsDetail/ShowGoodsDetail.vue index 4960a2e21..9261a90ed 100644 --- a/buyer/src/components/goodsDetail/ShowGoodsDetail.vue +++ b/buyer/src/components/goodsDetail/ShowGoodsDetail.vue @@ -100,7 +100,7 @@ v-model:current-page="commentParams.pageNumber" v-model:page-size="commentParams.pageSize" :total="commentTotal" - small + size="small" @current-change="changePageNum" @size-change="changePageSize" layout="prev, pager, next" @@ -136,6 +136,7 @@ import { computed, onMounted, onBeforeUnmount, reactive, ref } from 'vue'; import { Refresh } from '@element-plus/icons-vue'; import { goodsComment, goodsCommentNum } from '@/api/member.js'; +import storage from '@/plugins/storage.js'; import StoreSide from './StoreSide.vue'; defineOptions({ name: 'ShowGoodsDetail' }); @@ -246,17 +247,23 @@ function changePageSize (val) { getList(); } function getList () { + // 评价接口需要登录,未登录时不发起请求 + if (!storage.getItem('accessToken') || !storage.getItem('userInfo')) return; commentParams.goodsId = skuDetail.value.goodsId; goodsComment(commentParams).then(res => { if (res.success) { commentList.value = res.result.records; commentTotal.value = res.result.total; } + }).catch(() => { + // 评价为可选数据,加载失败时静默 }); goodsCommentNum(skuDetail.value.goodsId).then(res => { if (res.success) { commentTypeNum.value = res.result; } + }).catch(() => { + // 评价统计为可选数据,加载失败时静默 }); } function viewByGrade (grade) {