Authored by 王水玲

Merge branch 'feature/sale' of http://git.dev.yoho.cn/web/yohobuywap-node into feature/sale

... ... @@ -18,12 +18,12 @@ const saleLogger = (err, res) => {
res.send('error');
};
const typeCont = {
price: ['s_p_desc', 's_p_asc'],
discount: ['p_d_desc', 'p_d_asc'],
sales: ['s_n_desc', 's_n_asc'],
newest: ['s_t_desc', 's_t_asc']
};
// const typeCont = {
// price: ['s_p_desc', 's_p_asc'],
// discount: ['p_d_desc', 'p_d_asc'],
// sales: ['s_n_desc', 's_n_asc'],
// newest: ['s_t_desc', 's_t_asc']
// };
/**
* sale 首页
... ... @@ -162,22 +162,12 @@ exports.vip = (req, res) => {
};
exports.search = (req, res) => {
let setting = {
limit: '5',
page: req.query.page,
yh_channel: '1',
productSize: '384x511'
};
let type = req.query.type;
let order = req.query.order;
if (typeCont[type]) {
setting.order = typeCont[type][order];
}
let params = Object.assign({}, req.query);
saleModel.getSearchData(setting).then((result) => {
result.goods = {};
saleModel.getSearchData(params).then((result) => {
result.layout = false;
res.render('product', result);
res.render('product', Object.assign({
params: params
}, result));
});
};
... ...
... ... @@ -72,7 +72,9 @@ const processBreakingSort = (list) => {
/**
* 商品搜索数据处理
*/
const processSearch = () => {
const processSearch = (data) => {
return camelCase(data);
// const goods = [];
// list = list || [];
... ... @@ -112,22 +114,6 @@ const processSearch = () => {
// });
};
/**
* 获取商品数据
*/
exports.getSearchData = (params) => {
return api.get('', sign.apiSign(Object.assign({
method: 'app.search.sales'
}, params))).then((result) => {
if (result && result.code === 200) {
return processSearch(result);
} else {
logger.error('SALE 商品搜索返回 code 不是 200');
return [];
}
});
};
const getResources = (page) => {
const contentCode = {
sale: '7c2b77093421efa8ae9302c91460db73',
... ... @@ -161,6 +147,23 @@ const getBreakingSort = (yhChannel) => {
};
/**
* 获取商品数据
*/
exports.getSearchData = (params) => {
params = params || {};
return api.get('', sign.apiSign(Object.assign({
method: 'app.search.sales'
}, params))).then((result) => {
if (result && result.code === 200) {
return processSearch(result.data);
} else {
logger.error('SALE 商品搜索返回 code 不是 200');
return {};
}
});
};
/**
* 获取sale首页数据
* @param {[object]} params
* @return {[object]}
... ... @@ -199,10 +202,10 @@ exports.getSpecialData = (params) => {
}, params))).then((result) => {
if (result && result.code === 200) {
specialData.data = processSpecial(result.data);
return specialData;
} else {
return Promise.reject('error');
logger.error('SALE 专题活动列表接口返回 code 不是 200');
}
return specialData;
});
};
... ...