...
|
...
|
@@ -15,12 +15,15 @@ const helpers = global.yoho.helpers; |
|
|
const crypto = global.yoho.crypto;
|
|
|
const _ = require('lodash');
|
|
|
|
|
|
const limitNum = 60; // 商品每页显示数目
|
|
|
// const limitNum = 60; // 商品每页显示数目
|
|
|
const needParams = ['query', 'msort', 'misort', 'gender', 'shelveTime'];
|
|
|
|
|
|
// 品牌页folder名称
|
|
|
const brandFolderSeries = '经典系列';
|
|
|
|
|
|
// 经典店铺list url
|
|
|
const shopListUrl = '/product/shoplist';
|
|
|
|
|
|
// 搜索分类信息需要的参数
|
|
|
const positionId = 10;
|
|
|
|
...
|
...
|
@@ -276,16 +279,16 @@ const getBrandData = (params, extra, channel) => { |
|
|
} else {
|
|
|
// 品牌以品牌ID查询商品
|
|
|
queryBase.brand = extra.brandId;
|
|
|
}
|
|
|
|
|
|
// 设置品牌默认排序方式
|
|
|
let order = params.order || 'b_w_desc';
|
|
|
// 设置品牌默认排序方式
|
|
|
searchParams.order = searchParams.order || 'b_w_desc';
|
|
|
}
|
|
|
|
|
|
// 调用接口
|
|
|
let apiMethod = [
|
|
|
headerModel.requestHeaderData(channel),
|
|
|
searchApi.getSortList(queryBase),
|
|
|
searchApi.getProductList(Object.assign(searchParams, {order: order}, queryBase))
|
|
|
searchApi.getProductList(Object.assign(searchParams, queryBase))
|
|
|
];
|
|
|
|
|
|
if (queryBase.brand) {
|
...
|
...
|
@@ -301,6 +304,7 @@ const getBrandData = (params, extra, channel) => { |
|
|
brandBanner: searchHandler.handleBrandBanner(extra),
|
|
|
leftContent: {},
|
|
|
node: extra.node || '',
|
|
|
brandShopAd: true,
|
|
|
brandId: extra.brandId
|
|
|
}
|
|
|
};
|
...
|
...
|
@@ -496,7 +500,7 @@ const getNodeContentData = (params) => { |
|
|
*/
|
|
|
const getAdnav = (params) => {
|
|
|
|
|
|
return Promise.all([searchApi.getBrandFolder(params), searchApi.getBrandSeries(params)]).then(result => {
|
|
|
return Promise.all([searchApi.getBrandShopFolder(params), searchApi.getBrandShopSeries(params)]).then(result => {
|
|
|
|
|
|
let dest = {
|
|
|
picTitle: '',
|
...
|
...
|
@@ -615,8 +619,7 @@ const getShopData = (shopId, channel, params, shopInfo) => { |
|
|
sknList.push(value.productSkn);
|
|
|
});
|
|
|
|
|
|
let shopBrandIds = [], // 店铺的所有品牌id
|
|
|
articleApiMethod = [], // 通过品牌获取相关文章接口
|
|
|
let articleApiMethod = [], // 通过品牌获取相关文章接口
|
|
|
apiMethod = [
|
|
|
searchApi.getProductList({
|
|
|
viewNum: sknList.length,
|
...
|
...
|
@@ -626,7 +629,6 @@ const getShopData = (shopId, channel, params, shopInfo) => { |
|
|
|
|
|
if (result[3].code === 200 && result[3].data) {
|
|
|
_.forEach(result[3].data, value => {
|
|
|
shopBrandIds.push(value.brand_id);
|
|
|
articleApiMethod.push(
|
|
|
searchApi.getArticleByBrand(value.brand_id, 'udid') // 品牌推荐文章
|
|
|
);
|
...
|
...
|
@@ -637,8 +639,8 @@ const getShopData = (shopId, channel, params, shopInfo) => { |
|
|
finalResult.coupon = searchHandler.handleBrandShopCoupons(result[4].data, {shopId: shopId});
|
|
|
}
|
|
|
|
|
|
// 根据品牌获取分类 (腾讯云测试没有该接口,暂时不调用分类)
|
|
|
apiMethod.push(searchApi.getSortList({brand: shopBrandIds}));
|
|
|
// 根据店铺id获取分类
|
|
|
apiMethod.push(searchApi.getSortList({shop_id: shopId}));
|
|
|
apiMethod = _.concat(apiMethod, articleApiMethod);
|
|
|
|
|
|
return Promise.all(apiMethod).then(subRes => {
|
...
|
...
|
@@ -654,8 +656,7 @@ const getShopData = (shopId, channel, params, shopInfo) => { |
|
|
|
|
|
_.forEach(prodList, value => {
|
|
|
list[value.product_skn] = {
|
|
|
img: helpers.getForceSourceUrl(value.default_images) +
|
|
|
'?imageView2/1/w/{width}/h/{height}',
|
|
|
img: value.default_images,
|
|
|
title: value.product_name,
|
|
|
price: `¥${value.sales_price}`
|
|
|
};
|
...
|
...
|
@@ -681,11 +682,13 @@ const getShopData = (shopId, channel, params, shopInfo) => { |
|
|
if (subRes[1].code === 200) {
|
|
|
let groupSort = _.get(subRes[1], 'data.sort', []);
|
|
|
|
|
|
finalResult.leftContent = searchHandler.handleSortData(groupSort, params);
|
|
|
finalResult.leftContent = searchHandler.handleSortData(groupSort, params, params, '/product/shoplist');
|
|
|
|
|
|
_.set(finalResult, 'brandShopAd', {baseUrl: shopListUrl});
|
|
|
|
|
|
if (finalResult.allGoods) {
|
|
|
Object.assign(finalResult.allGoods, searchHandler.setShopSort(groupSort, Object.assign({},
|
|
|
params, {page: 1})));
|
|
|
params, {page: 1})), searchHandler.setGenderFilter(params));
|
|
|
}
|
|
|
}
|
|
|
|
...
|
...
|
@@ -732,7 +735,7 @@ const getShopGoodsData = (shopId, channel, params) => { |
|
|
searchApi.getProductList(Object.assign({
|
|
|
shop_id: shopId
|
|
|
}, params)), // 搜索店铺商品
|
|
|
searchApi.getShopBrands(shopId) // 店铺品牌数据
|
|
|
searchApi.getSortList({shop_id: shopId}) // 根据店铺id获取分类
|
|
|
]).then(result => {
|
|
|
// 获取商品数据和顶部筛选条件
|
|
|
if (result[0].code === 200) {
|
...
|
...
|
@@ -747,25 +750,14 @@ const getShopGoodsData = (shopId, channel, params) => { |
|
|
_.set(resData, 'sort.newPage', true); // 启用新的分页导航
|
|
|
}
|
|
|
|
|
|
let shopBrandIds = []; // 店铺的所有品牌id
|
|
|
if (result[1].code === 200) {
|
|
|
let groupSort = _.get(result[1], 'data.sort', []);
|
|
|
|
|
|
if (result[1].code === 200 && result[1].data) {
|
|
|
_.forEach(result[1].data, value => {
|
|
|
shopBrandIds.push(value.brand_id);
|
|
|
});
|
|
|
Object.assign(resData, searchHandler.setShopSort(groupSort, Object.assign({}, params,
|
|
|
{page: 1})), searchHandler.setGenderFilter(params));
|
|
|
}
|
|
|
|
|
|
// 根据品牌获取分类 (腾讯云测试没有该接口,暂时不调用分类)
|
|
|
return searchApi.getSortList({brand: shopBrandIds}).then(subRes => {
|
|
|
if (subRes.code === 200) {
|
|
|
let groupSort = _.get(subRes, 'data.sort', []);
|
|
|
|
|
|
Object.assign(resData, searchHandler.setShopSort(groupSort, Object.assign(params,
|
|
|
{page: 1})));
|
|
|
}
|
|
|
|
|
|
return resData;
|
|
|
});
|
|
|
return resData;
|
|
|
});
|
|
|
};
|
|
|
|
...
|
...
|
@@ -778,10 +770,11 @@ const getShopListData = (channel, params, uid) => { |
|
|
searchApi.getShopDecorator(shopId), // 店铺装修数据
|
|
|
searchApi.getShopInfo(shopId, uid), // 店铺介绍
|
|
|
searchApi.getProductList(Object.assign({shop_id: shopId}, params)), // 搜索店铺商品
|
|
|
searchApi.getShopBrands(shopId) // 店铺品牌数据
|
|
|
searchApi.getSortList({shop_id: shopId}) // 店铺分类
|
|
|
];
|
|
|
|
|
|
if (_.has(params, 'query')) {
|
|
|
// 如果有店内搜索,则并行查询店铺所有商品,搜索不到商品则显示所有商品
|
|
|
apiArr.push(searchApi.getProductList(Object.assign({shop_id: shopId},
|
|
|
params, {query: ''}))); // 搜索店铺所有商品
|
|
|
}
|
...
|
...
|
@@ -827,26 +820,18 @@ const getShopListData = (channel, params, uid) => { |
|
|
let goodsList = _.get(info, 'data.product_list', []);
|
|
|
|
|
|
if (goodsList.length) {
|
|
|
let tip = {
|
|
|
start: (_.get(info, 'data.page', 1) - 1) * limitNum + 1,
|
|
|
total: _.get(info, 'data.total', 0)
|
|
|
};
|
|
|
|
|
|
tip.end = tip.start + limitNum - 1;
|
|
|
if (tip.end > tip.total) {
|
|
|
tip.end = tip.total;
|
|
|
}
|
|
|
let totalPage = _.get(info, 'data.total', 1);
|
|
|
|
|
|
Object.assign(finalResult, {
|
|
|
filters: searchHandler.handleFilterDataAll(info.data, params),
|
|
|
opts: searchHandler.handleOptsData(params, tip.total),
|
|
|
opts: searchHandler.handleOptsData(params, totalPage),
|
|
|
goods: productProcess.processProductList(goodsList, {
|
|
|
newCoverSort: true,
|
|
|
showDiscount: false,
|
|
|
gender: _getGender(channel),
|
|
|
query: params.query
|
|
|
}),
|
|
|
footPager: {tip: tip}
|
|
|
footPager: searchHandler.handlePagerData(totalPage, params)
|
|
|
});
|
|
|
|
|
|
_.set(finalResult, 'filters.checkedConditions.clearUrl',
|
...
|
...
|
@@ -873,27 +858,15 @@ const getShopListData = (channel, params, uid) => { |
|
|
}
|
|
|
|
|
|
if (result[4].code === 200) {
|
|
|
let shopBrandIds = []; // 店铺下的所有品牌id数组
|
|
|
|
|
|
_.forEach(_.get(result[4], 'data', []), value => {
|
|
|
shopBrandIds.push(value.brand_id);
|
|
|
});
|
|
|
|
|
|
return searchApi.getSortList({brand: shopBrandIds}).then(subRes => {
|
|
|
if (subRes.code === 200) {
|
|
|
let groupSort = _.get(subRes, 'data.sort', []),
|
|
|
noPageQs = Object.assign({}, params, {page: 1});
|
|
|
|
|
|
finalResult.leftContent = searchHandler.handleSortData(groupSort, noPageQs);
|
|
|
let groupSort = _.get(result[4], 'data.sort', []),
|
|
|
noPageQs = Object.assign({}, params, {page: 1});
|
|
|
|
|
|
if (finalResult.allGoods) {
|
|
|
Object.assign(finalResult.allGoods, searchHandler.setShopSort(groupSort, noPageQs));
|
|
|
}
|
|
|
}
|
|
|
|
|
|
return finalResult;
|
|
|
});
|
|
|
finalResult.leftContent = searchHandler.handleSortData(groupSort, noPageQs);
|
|
|
|
|
|
if (finalResult.allGoods) {
|
|
|
Object.assign(finalResult.allGoods, searchHandler.setShopSort(groupSort, noPageQs));
|
|
|
}
|
|
|
}
|
|
|
|
|
|
finalResult.criteo = {skn: searchHandler.getCriteo(_.get(finalResult, 'goods'))};
|
...
|
...
|
@@ -908,6 +881,7 @@ const getShopListData = (channel, params, uid) => { |
|
|
const getBaseShopData = (params, extra, channel, shopId) => {
|
|
|
let resData = {};
|
|
|
|
|
|
params.shopId = shopId;
|
|
|
return Promise.all([
|
|
|
getBrandData(params, extra, channel),
|
|
|
searchApi.getShopDecorator(shopId), // 店铺装修数据
|
...
|
...
|
|