mirror of
https://gitee.com/beijing_hongye_huicheng/lilishop-ui.git
synced 2026-11-06 17:09:08 +08:00
fix(buyer): 修复商品详情页未登录时调用评价接口导致的登录弹窗与未捕获报错
- goodsComment/goodsCommentNum 改为 needToken,未登录时不再发起请求 - 评价/收藏状态等后台查询增加 skipAuthHandler+skipMessage,token 失效时静默失败 - ShowGoodsDetail 评价接口调用补充 catch 并增加登录守卫
This commit is contained in:
@@ -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
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user