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) {
|
export function isCollection (type, goodsId) {
|
||||||
return request({
|
return request({
|
||||||
url: `/buyer/member/collection/isCollection/${type}/${goodsId}`,
|
url: `/buyer/member/collection/isCollection/${type}/${goodsId}`,
|
||||||
method: Method.GET,
|
method: Method.GET,
|
||||||
needToken: true
|
needToken: true,
|
||||||
|
skipAuthHandler: true,
|
||||||
|
skipMessage: true
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// 查看是否收藏店铺
|
// 查看是否收藏店铺(后台查询,token 失效时静默失败,不弹全局登录框)
|
||||||
export function isStoreCollection (type, goodsId) {
|
export function isStoreCollection (type, goodsId) {
|
||||||
return request({
|
return request({
|
||||||
url: `/buyer/member/storeCollection/isCollection/${type}/${goodsId}`,
|
url: `/buyer/member/storeCollection/isCollection/${type}/${goodsId}`,
|
||||||
method: Method.GET,
|
method: Method.GET,
|
||||||
needToken: true
|
needToken: true,
|
||||||
|
skipAuthHandler: true,
|
||||||
|
skipMessage: true
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -133,22 +137,26 @@ export function storeCollectList (params) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// 单个商品评价
|
// 单个商品评价(需登录;token 失效时静默失败,不弹全局登录框)
|
||||||
export function goodsComment (params) {
|
export function goodsComment (params) {
|
||||||
return request({
|
return request({
|
||||||
url: `/buyer/member/evaluation/${params.goodsId}/goodsEvaluation`,
|
url: `/buyer/member/evaluation/${params.goodsId}/goodsEvaluation`,
|
||||||
method: Method.GET,
|
method: Method.GET,
|
||||||
needToken: false,
|
needToken: true,
|
||||||
|
skipAuthHandler: true,
|
||||||
|
skipMessage: true,
|
||||||
params
|
params
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// 商品各评价类别数量
|
// 商品各评价类别数量(需登录;token 失效时静默失败,不弹全局登录框)
|
||||||
export function goodsCommentNum (goodsId) {
|
export function goodsCommentNum (goodsId) {
|
||||||
return request({
|
return request({
|
||||||
url: `/buyer/member/evaluation/${goodsId}/evaluationNumber`,
|
url: `/buyer/member/evaluation/${goodsId}/evaluationNumber`,
|
||||||
method: Method.GET,
|
method: Method.GET,
|
||||||
needToken: false
|
needToken: true,
|
||||||
|
skipAuthHandler: true,
|
||||||
|
skipMessage: true
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -100,7 +100,7 @@
|
|||||||
v-model:current-page="commentParams.pageNumber"
|
v-model:current-page="commentParams.pageNumber"
|
||||||
v-model:page-size="commentParams.pageSize"
|
v-model:page-size="commentParams.pageSize"
|
||||||
:total="commentTotal"
|
:total="commentTotal"
|
||||||
small
|
size="small"
|
||||||
@current-change="changePageNum"
|
@current-change="changePageNum"
|
||||||
@size-change="changePageSize"
|
@size-change="changePageSize"
|
||||||
layout="prev, pager, next"
|
layout="prev, pager, next"
|
||||||
@@ -136,6 +136,7 @@
|
|||||||
import { computed, onMounted, onBeforeUnmount, reactive, ref } from 'vue';
|
import { computed, onMounted, onBeforeUnmount, reactive, ref } from 'vue';
|
||||||
import { Refresh } from '@element-plus/icons-vue';
|
import { Refresh } from '@element-plus/icons-vue';
|
||||||
import { goodsComment, goodsCommentNum } from '@/api/member.js';
|
import { goodsComment, goodsCommentNum } from '@/api/member.js';
|
||||||
|
import storage from '@/plugins/storage.js';
|
||||||
import StoreSide from './StoreSide.vue';
|
import StoreSide from './StoreSide.vue';
|
||||||
|
|
||||||
defineOptions({ name: 'ShowGoodsDetail' });
|
defineOptions({ name: 'ShowGoodsDetail' });
|
||||||
@@ -246,17 +247,23 @@ function changePageSize (val) {
|
|||||||
getList();
|
getList();
|
||||||
}
|
}
|
||||||
function getList () {
|
function getList () {
|
||||||
|
// 评价接口需要登录,未登录时不发起请求
|
||||||
|
if (!storage.getItem('accessToken') || !storage.getItem('userInfo')) return;
|
||||||
commentParams.goodsId = skuDetail.value.goodsId;
|
commentParams.goodsId = skuDetail.value.goodsId;
|
||||||
goodsComment(commentParams).then(res => {
|
goodsComment(commentParams).then(res => {
|
||||||
if (res.success) {
|
if (res.success) {
|
||||||
commentList.value = res.result.records;
|
commentList.value = res.result.records;
|
||||||
commentTotal.value = res.result.total;
|
commentTotal.value = res.result.total;
|
||||||
}
|
}
|
||||||
|
}).catch(() => {
|
||||||
|
// 评价为可选数据,加载失败时静默
|
||||||
});
|
});
|
||||||
goodsCommentNum(skuDetail.value.goodsId).then(res => {
|
goodsCommentNum(skuDetail.value.goodsId).then(res => {
|
||||||
if (res.success) {
|
if (res.success) {
|
||||||
commentTypeNum.value = res.result;
|
commentTypeNum.value = res.result;
|
||||||
}
|
}
|
||||||
|
}).catch(() => {
|
||||||
|
// 评价统计为可选数据,加载失败时静默
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
function viewByGrade (grade) {
|
function viewByGrade (grade) {
|
||||||
|
|||||||
Reference in New Issue
Block a user