...
|
...
|
@@ -24,6 +24,78 @@ exports.getKeyActivity = (query) => { |
|
|
});
|
|
|
};
|
|
|
|
|
|
const setSearchData = (result, params, channel) => {
|
|
|
let changeQuery = Object.assign({}, params);
|
|
|
let finalResult = {
|
|
|
headerData: Object.assign(result[0].headerData, {
|
|
|
header: true
|
|
|
}),
|
|
|
search: {}
|
|
|
};
|
|
|
|
|
|
// 获取左侧类目数据
|
|
|
if (result[1].code === 200) {
|
|
|
let dps = {};
|
|
|
|
|
|
_.forEach(needParams, (value) => {
|
|
|
if (params[value]) {
|
|
|
dps[value] = params[value];
|
|
|
}
|
|
|
});
|
|
|
|
|
|
finalResult.search = {
|
|
|
leftContent: searchHandler.handleSortData(result[1].data.sort, dps, params),
|
|
|
isSearch: true
|
|
|
};
|
|
|
}
|
|
|
|
|
|
// 获取商品数据和顶部筛选条件
|
|
|
if (result[2].code === 200) {
|
|
|
|
|
|
// 搜索推荐词,获取对应的参数值
|
|
|
let termsSuggestion = _.get(result[2], 'data.suggestion.terms_suggestion', []);
|
|
|
|
|
|
// 推荐词 获取无商品,首次搜索,通过isChangedQuery做开关
|
|
|
if (result[2].data.isChangedQuery === 'Y') {
|
|
|
Object.assign(changeQuery, {query: termsSuggestion[0]});
|
|
|
}
|
|
|
|
|
|
let filters = Object.assign(searchHandler.handleFilterDataAll(result[2].data, changeQuery),
|
|
|
finalResult.search.leftContent.sort);
|
|
|
|
|
|
filters.checkedConditions.conditions = _.concat(filters.checkedConditions.conditions,
|
|
|
finalResult.search.leftContent.checked);
|
|
|
|
|
|
Object.assign(finalResult.search,
|
|
|
searchHandler.handlePathNavData({total: result[2].data.total }, params, 'search', channel),
|
|
|
{
|
|
|
filters: filters,
|
|
|
opts: searchHandler.handleOptsData(changeQuery, result[2].data.total, result[2].data.filter),
|
|
|
totalCount: result[2].data.total,
|
|
|
footPager: searchHandler.handlePagerData(result[2].data.total, changeQuery),
|
|
|
goods: productProcess.processProductList(result[2].data.product_list,
|
|
|
Object.assign({showDiscount: false, from: {type: 'search', params: params}}, params)),
|
|
|
latestWalk: 6,
|
|
|
hasNextPage: searchHandler.handleNextPage(changeQuery, result[2].data.total),
|
|
|
shopEntry: result[3],
|
|
|
name: params.query,
|
|
|
suggest: (termsSuggestion.length !== 0) ? termsSuggestion.slice(0, 3) : false,
|
|
|
changedQuery: result[2].data.isChangedQuery === 'Y',
|
|
|
suggestFirst: finalResult.search.suggestFirst,
|
|
|
suggestSecond: finalResult.search.suggestSecond
|
|
|
});
|
|
|
|
|
|
if (finalResult.search.changedQuery) {
|
|
|
|
|
|
finalResult.search.suggestFirst = finalResult.search.suggest[0];
|
|
|
finalResult.search.suggestSecond = _.slice(termsSuggestion, 1, termsSuggestion.length).splice(0, 3);
|
|
|
}
|
|
|
|
|
|
finalResult.criteo = {skn: searchHandler.getCriteo(_.get(finalResult.search, 'goods'))};
|
|
|
}
|
|
|
return finalResult;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 转换价格
|
|
|
*
|
...
|
...
|
@@ -40,9 +112,7 @@ const transPrice = (price) => { |
|
|
* @return {[type]} [description]
|
|
|
*/
|
|
|
exports.getSearchData = (params, channel) => {
|
|
|
|
|
|
let searchParams = searchHandler.getSearchParams(params);
|
|
|
let changeQuery = Object.assign({}, params);
|
|
|
|
|
|
switch (channel) {
|
|
|
case 'boys':
|
...
|
...
|
@@ -70,74 +140,17 @@ exports.getSearchData = (params, channel) => { |
|
|
];
|
|
|
|
|
|
return api.all(apiMethod).then(result => {
|
|
|
let finalResult = {
|
|
|
headerData: Object.assign(result[0].headerData, {
|
|
|
header: true
|
|
|
}),
|
|
|
search: {}
|
|
|
};
|
|
|
|
|
|
// 获取左侧类目数据
|
|
|
if (result[1].code === 200) {
|
|
|
let dps = {};
|
|
|
if (_.get(result, '[2].data.isChangedQuery', '') === 'Y') {
|
|
|
return searchApi.getSortList(Object.assign({}, searchParams, {msort: '',
|
|
|
query: _.get(result, '[2]data.suggestion.terms_suggestion[0]', ''),
|
|
|
misort: '', sort: ''})).then(subRes => {
|
|
|
result[1] = subRes;
|
|
|
|
|
|
_.forEach(needParams, (value) => {
|
|
|
if (params[value]) {
|
|
|
dps[value] = params[value];
|
|
|
}
|
|
|
return setSearchData(result, params, channel);
|
|
|
});
|
|
|
|
|
|
finalResult.search = {
|
|
|
leftContent: searchHandler.handleSortData(result[1].data.sort, dps, params),
|
|
|
isSearch: true
|
|
|
};
|
|
|
}
|
|
|
|
|
|
// 获取商品数据和顶部筛选条件
|
|
|
if (result[2].code === 200) {
|
|
|
|
|
|
// 搜索推荐词,获取对应的参数值
|
|
|
let termsSuggestion = _.get(result[2], 'data.suggestion.terms_suggestion', []);
|
|
|
|
|
|
// 推荐词 获取无商品,首次搜索,通过isChangedQuery做开关
|
|
|
if (result[2].data.isChangedQuery === 'Y') {
|
|
|
Object.assign(changeQuery, {query: termsSuggestion[0]});
|
|
|
}
|
|
|
|
|
|
let filters = Object.assign(searchHandler.handleFilterDataAll(result[2].data, changeQuery),
|
|
|
finalResult.search.leftContent.sort);
|
|
|
|
|
|
filters.checkedConditions.conditions = _.concat(filters.checkedConditions.conditions,
|
|
|
finalResult.search.leftContent.checked);
|
|
|
|
|
|
Object.assign(finalResult.search,
|
|
|
searchHandler.handlePathNavData({total: result[2].data.total }, params, 'search', channel),
|
|
|
{
|
|
|
filters: filters,
|
|
|
opts: searchHandler.handleOptsData(changeQuery, result[2].data.total, result[2].data.filter),
|
|
|
totalCount: result[2].data.total,
|
|
|
footPager: searchHandler.handlePagerData(result[2].data.total, changeQuery),
|
|
|
goods: productProcess.processProductList(result[2].data.product_list,
|
|
|
Object.assign({showDiscount: false, from: {type: 'search', params: params}}, params)),
|
|
|
latestWalk: 6,
|
|
|
hasNextPage: searchHandler.handleNextPage(changeQuery, result[2].data.total),
|
|
|
shopEntry: result[3],
|
|
|
name: params.query,
|
|
|
suggest: (termsSuggestion.length !== 0) ? termsSuggestion.slice(0, 3) : false,
|
|
|
changedQuery: result[2].data.isChangedQuery === 'Y',
|
|
|
suggestFirst: finalResult.search.suggestFirst,
|
|
|
suggestSecond: finalResult.search.suggestSecond
|
|
|
});
|
|
|
|
|
|
if (finalResult.search.changedQuery) {
|
|
|
|
|
|
finalResult.search.suggestFirst = finalResult.search.suggest[0];
|
|
|
finalResult.search.suggestSecond = _.slice(termsSuggestion, 1, termsSuggestion.length).splice(0, 3);
|
|
|
}
|
|
|
|
|
|
finalResult.criteo = {skn: searchHandler.getCriteo(_.get(finalResult.search, 'goods'))};
|
|
|
}
|
|
|
return finalResult;
|
|
|
return setSearchData(result, params, channel);
|
|
|
});
|
|
|
};
|
|
|
|
...
|
...
|
|