|
|
|
|
|
|
|
|
const _ = require('lodash');
|
|
|
const headerModel = require('../../../doraemon/models/header');
|
|
|
|
|
|
const SearchApi = require('./search-api');
|
|
|
|
|
|
const searchHandler = require('./search-handler');
|
|
|
const utils = '../../../utils';
|
|
|
const productProcess = require(`${utils}/product-process-simple`);
|
|
|
|
|
|
const _setHotKeywordData = (result, params, channel) => {
|
|
|
let changeQuery = Object.assign({}, params);
|
|
|
let finalResult = {
|
|
|
headerData: Object.assign(result[0].headerData, {
|
|
|
header: true
|
|
|
})
|
|
|
};
|
|
|
|
|
|
_.unset(changeQuery, 'query');
|
|
|
|
|
|
// 获取商品数据和顶部筛选条件
|
|
|
if (result[1].code === 200) {
|
|
|
let data = result[1].data;
|
|
|
|
|
|
Object.assign(finalResult,
|
|
|
searchHandler.handlePathNavData({total: data.total}, params, 'search', channel),
|
|
|
{
|
|
|
product: {
|
|
|
opts: searchHandler.handleOptsData(changeQuery, data.total),
|
|
|
totalCount: data.total,
|
|
|
footPager: searchHandler.handlePagerData(data.total, changeQuery),
|
|
|
goods: productProcess.processProductList(data.product_list,
|
|
|
Object.assign({showDiscount: false, from: {type: 'search', params: params}}, params)),
|
|
|
latestWalk: 6,
|
|
|
hasNextPage: searchHandler.handleNextPage(changeQuery, data.total)
|
|
|
}
|
|
|
}
|
|
|
);
|
|
|
|
|
|
finalResult.hotBrands = _.get(data, 'filter.brand', []);
|
|
|
|
|
|
finalResult.hotBrands.forEach((val) => {
|
|
|
val.href = '#'; // TODO
|
|
|
return val;
|
|
|
});
|
|
|
|
|
|
console.log(_.get(data, 'filter.brand', []));
|
|
|
|
|
|
// finalResult.criteo = {skn: searchHandler.getCriteo(_.get(finalResult.search, 'goods'))};
|
|
|
}
|
|
|
|
|
|
// console.log(finalResult);
|
|
|
|
|
|
return finalResult;
|
|
|
};
|
|
|
|
|
|
module.exports = class extends global.yoho.BaseModel {
|
|
|
constructor(ctx) {
|
|
|
super(ctx);
|
|
|
|
|
|
this.searchApi = new SearchApi(ctx);
|
|
|
}
|
|
|
|
|
|
getHotKeywordDate(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;
|
|
|
}
|
|
|
|
|
|
searchParams.need_filter = 'yes';
|
|
|
searchParams.query = '夹克';
|
|
|
return Promise.all([
|
|
|
headerModel.requestHeaderData(channel),
|
|
|
this.searchApi.getSeoProductList(searchParams, 'fuzzySearch')
|
|
|
]).then(result => {
|
|
|
return _setHotKeywordData(result, params, channel);
|
|
|
});
|
|
|
}
|
|
|
}; |
...
|
...
|
|