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