【代码优化】拼团活动逻辑优化

pull/91/head
卢越 2024-09-05 11:32:30 +08:00
parent 85441704cb
commit b6dd2ae1eb
2 changed files with 28 additions and 11 deletions

View File

@ -37,7 +37,7 @@ const CombinationApi = {
url: '/promotion/combination-activity/detail-list',
method: 'GET',
params: {
ids,
ids
},
});
},
@ -58,9 +58,9 @@ const CombinationApi = {
// 获得我的拼团记录分页
getCombinationRecordPage: (params) => {
return request({
url: '/promotion/combination-record/page',
url: "/promotion/combination-record/page",
method: 'GET',
params,
params
});
},

View File

@ -144,6 +144,7 @@
import sheep from '@/sheep';
import CombinationApi from '@/sheep/api/promotion/combination';
import SpuApi from '@/sheep/api/product/spu';
import spu from '@/sheep/api/product/spu';
//
const LayoutTypeEnum = {
@ -241,21 +242,35 @@
* @param ids 商品编号列表
* @return {Promise<undefined>} 商品列表
*/
async function getSpuDetail(spuId) {
const { data: spu } = await SpuApi.getSpuDetail(spuId)
async function getSpuDetail(ids) {
const { data: spu } = await SpuApi.getSpuDetail(ids);
return spu;
}
//
onMounted(async () => {
//
//
const activityList = await getCombinationActivityDetailList(activityIds.join(','));
// SPU Promise
const spuPromises = activityList.map(activity => getSpuDetail(activity.spuId));
// SPU
// spuList
state.spuList = await Promise.all(spuPromises);
// SPUspuList
for (const activity of activityList) {
state.spuList.push(await getSpuDetail(activity.spuId));
}
//
activityList.forEach(activity => {
//
activity.products.forEach(product => {
const combinationPrice = product.combinationPrice || Infinity;
// spu
const spu = state.spuList.find(spu => activity.spuId === spu.id);
if (spu) {
spu.price = Math.min(combinationPrice, spu.price || Infinity);
}
});
});
//
if (layoutType === LayoutTypeEnum.TWO_COL) {
@ -273,11 +288,13 @@
.goods-list-box {
width: 50%;
box-sizing: border-box;
.left-list {
&:nth-last-child(1) {
margin-bottom: 0 !important;
}
}
.right-list {
&:nth-last-child(1) {
margin-bottom: 0 !important;