...
|
...
|
@@ -24,52 +24,8 @@ exports.getKeyActivity = (query) => { |
|
|
});
|
|
|
};
|
|
|
|
|
|
/**
|
|
|
* 转换价格
|
|
|
*
|
|
|
* @param float|string $price 价格
|
|
|
* @return float|string 转换之后的价格
|
|
|
*/
|
|
|
const transPrice = (price) => {
|
|
|
return price ? (price * 1).toFixed(2) : '0.00';
|
|
|
};
|
|
|
|
|
|
/**
|
|
|
* 获取搜索数据
|
|
|
* @param {[type]} origin [description]
|
|
|
* @return {[type]} [description]
|
|
|
*/
|
|
|
exports.getSearchData = (params, channel) => {
|
|
|
|
|
|
let searchParams = searchHandler.getSearchParams(params);
|
|
|
const setSearchData = (result, params, channel) => {
|
|
|
let changeQuery = Object.assign({}, params);
|
|
|
|
|
|
switch (channel) {
|
|
|
case 'boys':
|
|
|
searchParams.physical_channel = 1;
|
|
|
break;
|
|
|
case 'girls':
|
|
|
searchParams.physical_channel = 2;
|
|
|
break;
|
|
|
case 'kids':
|
|
|
searchParams.physical_channel = 3;
|
|
|
break;
|
|
|
case 'lifestyle':
|
|
|
searchParams.physical_channel = 4;
|
|
|
break;
|
|
|
default:
|
|
|
break;
|
|
|
}
|
|
|
|
|
|
// 调用接口
|
|
|
let apiMethod = [
|
|
|
headerModel.requestHeaderData(channel),
|
|
|
searchApi.getSortList(Object.assign({}, searchParams, {msort: '', misort: '', sort: ''})),
|
|
|
searchApi.getProductList(searchParams),
|
|
|
searchApi.getShopList(params)
|
|
|
];
|
|
|
|
|
|
return api.all(apiMethod).then(result => {
|
|
|
let finalResult = {
|
|
|
headerData: Object.assign(result[0].headerData, {
|
|
|
header: true
|
...
|
...
|
@@ -138,6 +94,63 @@ exports.getSearchData = (params, channel) => { |
|
|
finalResult.criteo = {skn: searchHandler.getCriteo(_.get(finalResult.search, 'goods'))};
|
|
|
}
|
|
|
return finalResult;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 转换价格
|
|
|
*
|
|
|
* @param float|string $price 价格
|
|
|
* @return float|string 转换之后的价格
|
|
|
*/
|
|
|
const transPrice = (price) => {
|
|
|
return price ? (price * 1).toFixed(2) : '0.00';
|
|
|
};
|
|
|
|
|
|
/**
|
|
|
* 获取搜索数据
|
|
|
* @param {[type]} origin [description]
|
|
|
* @return {[type]} [description]
|
|
|
*/
|
|
|
exports.getSearchData = (params, channel) => {
|
|
|
let searchParams = searchHandler.getSearchParams(params);
|
|
|
|
|
|
switch (channel) {
|
|
|
case 'boys':
|
|
|
searchParams.physical_channel = 1;
|
|
|
break;
|
|
|
case 'girls':
|
|
|
searchParams.physical_channel = 2;
|
|
|
break;
|
|
|
case 'kids':
|
|
|
searchParams.physical_channel = 3;
|
|
|
break;
|
|
|
case 'lifestyle':
|
|
|
searchParams.physical_channel = 4;
|
|
|
break;
|
|
|
default:
|
|
|
break;
|
|
|
}
|
|
|
|
|
|
// 调用接口
|
|
|
let apiMethod = [
|
|
|
headerModel.requestHeaderData(channel),
|
|
|
searchApi.getSortList(Object.assign({}, searchParams, {msort: '', misort: '', sort: ''})),
|
|
|
searchApi.getProductList(searchParams),
|
|
|
searchApi.getShopList(params)
|
|
|
];
|
|
|
|
|
|
return api.all(apiMethod).then(result => {
|
|
|
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;
|
|
|
|
|
|
return setSearchData(result, params, channel);
|
|
|
});
|
|
|
}
|
|
|
|
|
|
return setSearchData(result, params, channel);
|
|
|
});
|
|
|
};
|
|
|
|
...
|
...
|
|