Authored by 王水玲

sale

... ... @@ -18,6 +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']
};
/**
* sale 首页
... ... @@ -173,3 +179,24 @@ exports.vip = (req, res) => {
saleLogger(err, 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];
}
saleModel.getSearchData(setting).then((result) => {
result.goods = {};
result.layout = false;
res.render('product', result);
});
};
... ...
... ... @@ -47,6 +47,37 @@ const processSpecial = (list) => {
return formatData;
};
/**
* 商品搜索数据处理
*/
const processSearch = (list) => {
// const formartData = [];
// let goods = {};
list = list || [];
// _.forEach(camelCase(list.data.product_list), (data) => {
// });
};
/**
* 获取商品数据
*/
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 [];
}
});
};
exports.getSaleResources = () => {
return serviceAPI.get('operations/api/v5/resource/get', sign.apiSign({
content_code: '7c2b77093421efa8ae9302c91460db73'
... ... @@ -61,18 +92,6 @@ exports.getSaleResources = () => {
};
/**
* 获取首页数据
* @param {[object]} params
* @return {[object]}
*/
exports.getSaleData = (params) => {
return api.get('', sign.apiSign(Object.assign({
method: 'app.search.sales'
}, params)));
};
/**
* 获取折扣专场专题列表数据
* @param {[object]} params
* @return {[object]}
... ...
... ... @@ -27,6 +27,8 @@ router.get('/specialDetail', sale.specialDetail);
router.get('/breakCode', sale.breakCode);
router.get('/vip', sale.vip);
router.get('/sale/search', sale.search);
// router.get('/outlet', sale.outlet);
module.exports = router;
... ...
{{# goods}}
{{> common/goods}}
{{/ goods}}
\ No newline at end of file
... ...
<div class="banner">
<img src="{{image src 640 200}}"/>
{{# activityTime}}
<p class="activity-time" data-time-ms = '{{msTime}}'><i class="iconfont time-ico">&#xe603;</i><span>剩1天2小时38分4秒</span></p>
{{/ activityTime}}
</div>
<ul id="list-nav" class="list-nav clearfix">
<li class="new active">
... ...
{{#if .}} {{!-- 剔除值为false的项 --}}
<div class="good-info" data-id="{{id}}" data-bp-id="guang_goodList_{{name}}_false">
<div class="good-info" data-id="{{goodsId}}" data-bp-id="guang_goodList_{{name}}_false">
<div class="tag-container clearfix">
{{# tags}}
{{# isNew}}
... ...
... ... @@ -51,6 +51,7 @@ var $listNav = $('#list-nav'),
searching;
require('./suspend-cart'); // 悬浮购物车
require('../common');
ellipsis.init();
... ... @@ -151,7 +152,6 @@ function search(opt) {
}
nav = navInfo[navType];
page = nav.page + 1;
if (nav.reload) {
page = 1;
... ... @@ -172,12 +172,14 @@ function search(opt) {
$.ajax({
type: 'GET',
url: '/product/newsale/selectNewSale',
url: '/product/sale/search',
data: setting,
success: function(data) {
var $container,
num;
console.log(data);
switch (navType) {
case 'newest':
$container = $ngc;
... ...