...
|
...
|
@@ -23,34 +23,12 @@ const brandFolderSeries = '经典系列'; |
|
|
const folderTitle = '经典款型';
|
|
|
const seriesTitle = '经典系列';
|
|
|
|
|
|
// 经典店铺list url
|
|
|
const shopListUrl = '/product/shoplist';
|
|
|
|
|
|
// 搜索分类信息需要的参数
|
|
|
const positionId = 10;
|
|
|
|
|
|
// 获取分类左侧广告id
|
|
|
const sortAdsId = 79;
|
|
|
|
|
|
|
|
|
const _getGender = (channel) => {
|
|
|
let gender;
|
|
|
|
|
|
switch (channel) {
|
|
|
case 'boys':
|
|
|
gender = '1,3';
|
|
|
break;
|
|
|
case 'girls':
|
|
|
gender = '2,3';
|
|
|
break;
|
|
|
default:
|
|
|
gender = '1,2,3';
|
|
|
break;
|
|
|
}
|
|
|
|
|
|
return gender;
|
|
|
};
|
|
|
|
|
|
/**
|
|
|
* 获取商品分类列表数据
|
|
|
*/
|
...
|
...
|
@@ -566,124 +544,6 @@ const getShopInfo = (shopId, uid) => { |
|
|
});
|
|
|
};
|
|
|
|
|
|
const getShopListData = (channel, params, uid) => {
|
|
|
let gender = _getGender(channel),
|
|
|
shopId = params.shopId,
|
|
|
navBar = params.navBar || 1;
|
|
|
let apiArr = [
|
|
|
headerModel.requestHeaderData(channel), // 头部数据
|
|
|
searchApi.getShopDecorator(shopId), // 店铺装修数据
|
|
|
searchApi.getShopInfo(shopId, uid), // 店铺介绍
|
|
|
searchApi.getProductList(Object.assign({shop_id: shopId}, params,
|
|
|
{limit: (params.limit || 60) - 1}), 'shop'), // 搜索店铺商品
|
|
|
searchApi.getSortList({shop_id: shopId}) // 店铺分类
|
|
|
];
|
|
|
|
|
|
if (_.has(params, 'query')) {
|
|
|
// 如果有店内搜索,则并行查询店铺所有商品,搜索不到商品则显示所有商品
|
|
|
apiArr.push(searchApi.getProductList(Object.assign({shop_id: shopId},
|
|
|
params, {query: ''}), 'shop')); // 搜索店铺所有商品
|
|
|
}
|
|
|
|
|
|
|
|
|
return Promise.all(apiArr).then(result => {
|
|
|
let finalResult = {
|
|
|
headerData: Object.assign(result[0].headerData, {header: true})
|
|
|
};
|
|
|
|
|
|
// 面包屑导航
|
|
|
Object.assign(finalResult, searchHandler.handlePathNavData({}, params, 'shop', channel));
|
|
|
|
|
|
// 店铺装修
|
|
|
if (result[1].code === 200) {
|
|
|
Object.assign(finalResult, shopHandler.getShopDecorator(result[1].data, params, shopId));
|
|
|
|
|
|
// 设置shop nav选中状态
|
|
|
_.set(finalResult, `navigationBar[${navBar}].current`, true);
|
|
|
|
|
|
if (result[2].code === 200) {
|
|
|
let data = _.get(result[2], 'data', {});
|
|
|
|
|
|
_.set(finalResult, 'shopTopBanner.brandIntro', {
|
|
|
shopId: shopId,
|
|
|
brandName: data.shop_name || '',
|
|
|
isFavorite: data.is_favorite === 'Y',
|
|
|
brandCont: data.shop_intro || ''
|
|
|
});
|
|
|
|
|
|
// 店铺SEO
|
|
|
Object.assign(finalResult, searchHandler.getBrandShopSeo(channel, {
|
|
|
shopName: data.shop_name
|
|
|
}, params));
|
|
|
}
|
|
|
} else {
|
|
|
return Promise.reject('No ShopDecorator data');
|
|
|
}
|
|
|
|
|
|
// 获取商品数据和顶部筛选条件
|
|
|
if (result[3].code === 200) {
|
|
|
let info = result[3];
|
|
|
let goodsList = _.get(info, 'data.product_list', []);
|
|
|
|
|
|
if (goodsList.length) {
|
|
|
let totalPage = _.get(info, 'data.total', 1);
|
|
|
|
|
|
Object.assign(finalResult, {
|
|
|
filters: searchHandler.handleFilterDataAll(info.data, params),
|
|
|
opts: searchHandler.handleOptsData(params, totalPage),
|
|
|
goods: productProcess.processProductList(goodsList, {
|
|
|
newCoverSort: true,
|
|
|
showDiscount: false,
|
|
|
gender: _getGender(channel),
|
|
|
query: params.query
|
|
|
}),
|
|
|
hasNextPage: searchHandler.handleNextPage(params, totalPage),
|
|
|
footPager: searchHandler.handlePagerData(totalPage, params)
|
|
|
});
|
|
|
|
|
|
_.set(finalResult, 'filters.checkedConditions.clearUrl',
|
|
|
`?navBar=${params.navBar}&shopId=${params.shopId}`);
|
|
|
} else {
|
|
|
finalResult.searchEmpty = true;
|
|
|
|
|
|
if (result[5] && result[5].code === 200) {
|
|
|
let allGoods = {
|
|
|
name: '全部商品 ALL',
|
|
|
sort: searchHandler.handleOptsData(params, _.get(result[5], 'data.total', 0)),
|
|
|
list: productProcess.processProductList(_.get(result[5], 'data.product_list', []), {
|
|
|
newCoverSort: true,
|
|
|
showDiscount: false,
|
|
|
gender: gender
|
|
|
})
|
|
|
};
|
|
|
|
|
|
_.set(allGoods, 'sort.newPage', true); // 启用新的分页导航
|
|
|
|
|
|
finalResult.allGoods = allGoods;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
if (result[4].code === 200) {
|
|
|
|
|
|
let groupSort = _.get(result[4], 'data', []),
|
|
|
noPageQs = Object.assign({}, params, {page: 1});
|
|
|
|
|
|
finalResult.leftContent = searchHandler.handleSortData(groupSort, noPageQs, params);
|
|
|
|
|
|
_.set(finalResult, 'brandShopAd', {baseUrl: shopListUrl});
|
|
|
|
|
|
if (finalResult.allGoods) {
|
|
|
Object.assign(finalResult.allGoods, searchHandler.setShopSort(groupSort, noPageQs));
|
|
|
}
|
|
|
}
|
|
|
|
|
|
finalResult.criteo = {skn: searchHandler.getCriteo(_.get(finalResult, 'goods'))};
|
|
|
|
|
|
return finalResult;
|
|
|
});
|
|
|
};
|
|
|
|
|
|
const getUserCoupunStatus = (id, uid, type) => {
|
|
|
if (type === 'shop') {
|
|
|
return shopApi.shopCouponListAsync(id, uid).then(result => {
|
...
|
...
|
@@ -726,6 +586,5 @@ module.exports = { |
|
|
getNodeContentData,
|
|
|
getAdnav,
|
|
|
getShopInfo,
|
|
|
getShopListData,
|
|
|
getUserCoupunStatus
|
|
|
}; |
...
|
...
|
|