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

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

View File

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