fix:商品不存在时,不展示 empty 的情况
parent
49dbce22d1
commit
c7d101cd05
|
|
@ -258,14 +258,25 @@
|
|||
// 非法参数
|
||||
if (!options.id) {
|
||||
state.goodsInfo = null;
|
||||
state.skeletonLoading = false;
|
||||
return;
|
||||
}
|
||||
state.grouponId = options.id;
|
||||
// 加载活动信息
|
||||
const { code, data: activity } = await CombinationApi.getCombinationActivity(state.grouponId);
|
||||
if (code !== 0) {
|
||||
state.goodsInfo = null;
|
||||
state.skeletonLoading = false;
|
||||
return;
|
||||
}
|
||||
state.activity = activity;
|
||||
// 加载商品信息
|
||||
const { data: spu } = await SpuApi.getSpuDetail(activity.spuId);
|
||||
if (code !== 0) {
|
||||
state.goodsInfo = null;
|
||||
state.skeletonLoading = false;
|
||||
return;
|
||||
}
|
||||
state.goodsId = spu.id;
|
||||
|
||||
// 默认显示最低价
|
||||
|
|
|
|||
|
|
@ -387,19 +387,22 @@
|
|||
// 非法参数
|
||||
if (!options.id) {
|
||||
state.goodsInfo = null;
|
||||
state.skeletonLoading = false;
|
||||
return;
|
||||
}
|
||||
state.goodsId = options.id;
|
||||
// 1. 加载商品信息
|
||||
SpuApi.getSpuDetail(state.goodsId).then((res) => {
|
||||
// 未找到商品
|
||||
if (res.code !== 0 || !res.data) {
|
||||
state.goodsInfo = null;
|
||||
state.skeletonLoading = false;
|
||||
return;
|
||||
}
|
||||
// 加载到商品
|
||||
state.skeletonLoading = false;
|
||||
state.goodsInfo = res.data;
|
||||
// 获取结算信息
|
||||
getSettlementByIds(state.goodsId);
|
||||
// 加载是否收藏
|
||||
if (isLogin.value) {
|
||||
FavoriteApi.isFavoriteExists(state.goodsId, 'goods').then((res) => {
|
||||
|
|
@ -421,8 +424,6 @@
|
|||
}
|
||||
state.activityList = res.data;
|
||||
});
|
||||
//获取结算信息
|
||||
getSettlementByIds(state.goodsId);
|
||||
});
|
||||
</script>
|
||||
|
||||
|
|
|
|||
|
|
@ -210,18 +210,14 @@
|
|||
};
|
||||
});
|
||||
|
||||
const getShowPriceText = computed(() => {
|
||||
let priceText = `¥${fen2yuan(state.goodsInfo.price)}`;
|
||||
if (!isEmpty(state.selectedSku)) {
|
||||
const sku = state.selectedSku;
|
||||
priceText = `${sku.point}${!sku.pointPrice ? '' : `+¥${fen2yuan(sku.pointPrice)}`}`;
|
||||
}
|
||||
return priceText;
|
||||
});
|
||||
|
||||
// 查询活动
|
||||
const getActivity = async (id) => {
|
||||
const { data } = await PointApi.getPointActivity(id);
|
||||
if (!data) {
|
||||
state.goodsInfo = null;
|
||||
state.skeletonLoading = false;
|
||||
return;
|
||||
}
|
||||
activity.value = data;
|
||||
// 查询商品
|
||||
await getSpu(data.spuId);
|
||||
|
|
@ -230,6 +226,11 @@
|
|||
// 查询商品
|
||||
const getSpu = async (id) => {
|
||||
const { data } = await SpuApi.getSpuDetail(id);
|
||||
if (!data) {
|
||||
state.goodsInfo = null;
|
||||
state.skeletonLoading = false;
|
||||
return;
|
||||
}
|
||||
data.activity_type = PromotionActivityTypeEnum.POINT.type;
|
||||
state.goodsInfo = data;
|
||||
state.goodsInfo.stock = Math.min(data.stock, activity.value.stock);
|
||||
|
|
@ -258,6 +259,7 @@
|
|||
// 非法参数
|
||||
if (!options.id) {
|
||||
state.goodsInfo = null;
|
||||
state.skeletonLoading = false;
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -226,6 +226,11 @@
|
|||
// 查询活动
|
||||
const getActivity = async (id) => {
|
||||
const { data } = await SeckillApi.getSeckillActivity(id);
|
||||
if (!data) {
|
||||
state.goodsInfo = null;
|
||||
state.skeletonLoading = false;
|
||||
return;
|
||||
}
|
||||
activity.value = data;
|
||||
timeStatusEnum.value = getTimeStatusEnum(activity.value.startTime, activity.value.endTime);
|
||||
state.percent = 100 - (data.stock / data.totalStock) * 100;
|
||||
|
|
@ -236,6 +241,11 @@
|
|||
// 查询商品
|
||||
const getSpu = async (id) => {
|
||||
const { data } = await SpuApi.getSpuDetail(id);
|
||||
if (!data) {
|
||||
state.goodsInfo = null;
|
||||
state.skeletonLoading = false;
|
||||
return;
|
||||
}
|
||||
data.activity_type = 'seckill';
|
||||
state.goodsInfo = data;
|
||||
// 处理轮播图
|
||||
|
|
@ -274,6 +284,7 @@
|
|||
// 非法参数
|
||||
if (!options.id) {
|
||||
state.goodsInfo = null;
|
||||
state.skeletonLoading = false;
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue