Authored by 周少峰

list new

... ... @@ -32,7 +32,7 @@ exports.index = (req, res, next) => {
exports.new = (req, res, next) => {
let resData = {};
list.getListData(req.query).then(result => {
list.getListNewData(req.query).then(result => {
Object.assign(resData, result);
res.render('list/index', resData);
}).catch(next);
... ...
... ... @@ -82,3 +82,54 @@ exports.getListData = (params) => {
return finalResult;
});
};
/**
* 获取新品到着数据
*/
exports.getListNewData = (params) => {
// 调用接口
let apiMethod = [
headerModel.requestHeaderData(),
searchApi.getSortList(),
searchApi.getProductList(params),
searchApi.getWeekNew(params)
];
return api.all(apiMethod).then(result => {
let finalResult = {
headerData: Object.assign(result[0].headerData, {
header: true
}),
list: {
leftContent: {}
}
};
// 获取左侧类目数据
if (result[1].code === 200) {
finalResult.list = {
leftContent: searchHandler.handleSortData(result[1].data.sort, params),
pathNav: searchHandler.handlePathNavData(result[1].data.sort, params, 'new')
};
}
// 获取商品数据和顶部筛选条件
if (result[2].code === 200) {
Object.assign(finalResult.list, {
filters: searchHandler.handleFilterData(result[2].data.filter, params),
opts: searchHandler.handleOptsData(params, result[2].data.total, result[2].data.filter),
totalCount: result[2].data.total,
footPager: searchHandler.handlePagerData(result[2].data.total, params),
goods: productProcess.processProductList(result[2].data.product_list,
Object.assign({showDiscount: false}, params))
});
}
// 新品上架
if (result[3] && result[3].code === 200) {
Object.assign(finalResult.list.leftContent, searchHandler.handleWeekNew(result[3].data, params));
}
return finalResult;
});
};
... ...
... ... @@ -81,7 +81,13 @@ const getBrandFolder = (params) => {
* @return
*/
const getWeekNew = (params) => {
return yohoApi.get('', params);
let finalParams = {
method: 'web.regular.recent'
};
Object.assign(finalParams, params);
return yohoApi.get('', finalParams);
};
/**
... ...
... ... @@ -51,13 +51,14 @@ const handleCheckedData = (params, origin, param) => {
if (!_.isEmpty(origin)) {
_.forEach(origin, value => {
if (value.checked) {
let tempPatam = {};
let tempPatam = _.cloneDeep(params);
tempPatam[param] = '';
// 删除选中
delete tempPatam[param];
dest.push({
name: value.name,
href: handleFilterUrl(params, tempPatam)
href: handleFilterUrl(tempPatam)
});
}
});
... ... @@ -842,6 +843,28 @@ exports.handleSortAds = (data) => {
};
/**
* 处理一周新品上架
* @type {[type]}
*/
exports.handleWeekNew = (data, params) => {
let dest = {
newSales: {
name: '',
list: []
}
};
_.forEach(data.recent, function(value, key) {
dest.newSales.list.push({
name: key,
href: handleFilterUrl(params, {shelveTime: key}),
active: key === params.shelveTime
});
});
return dest;
};
/**
* 筛选类链接处理的对外接口
* @type {[type]}
*/
... ...