Authored by zhangxiaoru

new

... ... @@ -45,10 +45,15 @@ const selectNewSale = (req, res, next) => {
let params = _.assign({}, req.query);
newModel.getSearchData(params).then((result) => {
res.render('search/page', {
layout: false,
new: result
});
if (result.list.length > 0) {
res.render('search/page', {
layout: false,
new: result.list,
total: result.total
});
} else {
res.json(result);
}
}).catch(next);
};
... ...
... ... @@ -71,7 +71,15 @@ const getNewFocus = (channel) => {
const getSearchData = (params) => {
return _searchGoods(params).then((result) => {
if (result && result.code === 200) {
return productProcess.processProductList(result.data.product_list || [], {showTags: false});
let newList = {};
newList.list = productProcess.processProductList(result.data.product_list || [], {showTags: false});
if (parseInt(params.page) === 1) {
newList.total = result.data.total;
}
return newList;
} else {
logger.error('get product search api return code is not 200');
return [];
... ...
... ... @@ -33,6 +33,8 @@ var now = new Date(),
month = now.getMonth() + 1,
date = now.getDate();
var getChannel, C_ID, argument;
require('../../common/footer');
var $listNav = $('#list-nav'),
... ... @@ -77,6 +79,19 @@ if ($('.swiper-container .swiper-slide').length > 1) {
});
}
getChannel = function functionName() {
var name = window.cookie('_Channel');
return {
boys: 1,
girls: 2,
kids: 3,
lifestyle: 4
}[name] || 1;
};
C_ID = getChannel();
/**
* 筛选注册的回调,筛选子项点击后逻辑
* 需要执行search的场景:1.点选筛选项;2.relaod为true时切换导航;3.下拉加载
... ... @@ -201,12 +216,7 @@ function search(opt) {
searching = true;
loading.showLoadingMask();
if (window._yas && window._yas.sendCustomInfo) {
window._yas.sendCustomInfo({
op: optype,
param: JSON.stringify(yasparm)
}, true);
}
argument = setting;
$.ajax({
type: 'GET',
... ... @@ -214,7 +224,10 @@ function search(opt) {
data: setting,
success: function(data) {
var $container,
num;
num,
yasparm,
goodid,
goodIds = [];
switch (navType) {
case 'today':
... ... @@ -230,21 +243,68 @@ function search(opt) {
break;
}
if (data === ' ' || data === '') {
if (data === ' ' || data === '' || data.list) {
nav.end = true;
if (nav.reload) {
$container.html(noResult);
}
} else {
yasparm = {
C_ID: C_ID,
PAGE_NUM: setting.page,
FILTER_VALUE: JSON.stringify(setting).replace(/\{|\}|\"/g, ''),
SORT_TYPE: setting.dayLimit
};
if (nav.reload) {
$container.html(data);
lazyLoad($container.find('.lazy'));
$container.find('.good-info').each(function() {
goodid = $(this).data('good-id');
if (goodid) {
goodIds.push(goodid);
}
});
if (window._yas && window._yas.sendCustomInfo) {
window._yas.sendCustomInfo({
op: 'YB_NEW_GOODS_LIST_L',
param: JSON.stringify(Object.assign(yasparm, {
RES_QTY: $container.find('.total').data('id'),
PRD_LIST: goodIds
}))
}, true);
}
} else {
num = $container.find('.good-info').length;
$container.append(data);
if ($container.find('.total')[1]) {
$container.find('.total')[1].remove();
}
// lazy good-infos who append in
lazyLoad($container.find('.good-info:gt(' + (num - 1) + ') .lazy'));
$container.find('.good-info:gt(' + (num - 1) + ')').each(function() {
goodid = $(this).data('good-id');
if (goodid) {
goodIds.push(goodid);
}
});
if (window._yas && window._yas.sendCustomInfo) {
window._yas.sendCustomInfo({
op: 'YB_NEW_GOODS_LIST_L',
param: JSON.stringify(Object.assign(yasparm, {
RES_QTY: $container.find('.total').data('id'),
PRD_LIST: goodIds
}))
}, true);
}
}
}
... ... @@ -411,3 +471,27 @@ $listNav.on('touchstart', 'li', function() {
}).on('touchend touchcancel', function() {
$listNav.find('li').removeClass('bytouch');
});
$('#goods-container').on('click', '.good-info', function() {
var PRD_ID = $(this).data('good-id'),
PRD_NUM = $(this).index(),
FILTER_VALUE = JSON.stringify(argument).replace(/\{|\}|\"/g, '');
// event.preventDefault();
if (window._yas && window._yas.sendCustomInfo) {
window._yas.sendCustomInfo({
op: 'YB_NEW_GOODS_LIST_C',
param: JSON.stringify({
C_ID: C_ID,
PRD_ID: PRD_ID,
PRD_NUM: PRD_NUM,
PAGE_NUM: argument.page,
FILTER_VALUE: FILTER_VALUE || '',
SORT_TYPE: argument.dayLimit
})
}, true);
}
// return false;
});
... ...