Authored by zhangxiaoru

new

@@ -45,10 +45,15 @@ const selectNewSale = (req, res, next) => { @@ -45,10 +45,15 @@ const selectNewSale = (req, res, next) => {
45 let params = _.assign({}, req.query); 45 let params = _.assign({}, req.query);
46 46
47 newModel.getSearchData(params).then((result) => { 47 newModel.getSearchData(params).then((result) => {
48 - res.render('search/page', {  
49 - layout: false,  
50 - new: result  
51 - }); 48 + if (result.list.length > 0) {
  49 + res.render('search/page', {
  50 + layout: false,
  51 + new: result.list,
  52 + total: result.total
  53 + });
  54 + } else {
  55 + res.json(result);
  56 + }
52 }).catch(next); 57 }).catch(next);
53 }; 58 };
54 59
@@ -71,7 +71,15 @@ const getNewFocus = (channel) => { @@ -71,7 +71,15 @@ const getNewFocus = (channel) => {
71 const getSearchData = (params) => { 71 const getSearchData = (params) => {
72 return _searchGoods(params).then((result) => { 72 return _searchGoods(params).then((result) => {
73 if (result && result.code === 200) { 73 if (result && result.code === 200) {
74 - return productProcess.processProductList(result.data.product_list || [], {showTags: false}); 74 + let newList = {};
  75 +
  76 + newList.list = productProcess.processProductList(result.data.product_list || [], {showTags: false});
  77 +
  78 + if (parseInt(params.page) === 1) {
  79 + newList.total = result.data.total;
  80 + }
  81 +
  82 + return newList;
75 } else { 83 } else {
76 logger.error('get product search api return code is not 200'); 84 logger.error('get product search api return code is not 200');
77 return []; 85 return [];
@@ -33,6 +33,8 @@ var now = new Date(), @@ -33,6 +33,8 @@ var now = new Date(),
33 month = now.getMonth() + 1, 33 month = now.getMonth() + 1,
34 date = now.getDate(); 34 date = now.getDate();
35 35
  36 +var getChannel, C_ID, argument;
  37 +
36 require('../../common/footer'); 38 require('../../common/footer');
37 39
38 var $listNav = $('#list-nav'), 40 var $listNav = $('#list-nav'),
@@ -77,6 +79,19 @@ if ($('.swiper-container .swiper-slide').length > 1) { @@ -77,6 +79,19 @@ if ($('.swiper-container .swiper-slide').length > 1) {
77 }); 79 });
78 } 80 }
79 81
  82 +getChannel = function functionName() {
  83 + var name = window.cookie('_Channel');
  84 +
  85 + return {
  86 + boys: 1,
  87 + girls: 2,
  88 + kids: 3,
  89 + lifestyle: 4
  90 + }[name] || 1;
  91 +};
  92 +
  93 +C_ID = getChannel();
  94 +
80 /** 95 /**
81 * 筛选注册的回调,筛选子项点击后逻辑 96 * 筛选注册的回调,筛选子项点击后逻辑
82 * 需要执行search的场景:1.点选筛选项;2.relaod为true时切换导航;3.下拉加载 97 * 需要执行search的场景:1.点选筛选项;2.relaod为true时切换导航;3.下拉加载
@@ -201,12 +216,7 @@ function search(opt) { @@ -201,12 +216,7 @@ function search(opt) {
201 searching = true; 216 searching = true;
202 loading.showLoadingMask(); 217 loading.showLoadingMask();
203 218
204 - if (window._yas && window._yas.sendCustomInfo) {  
205 - window._yas.sendCustomInfo({  
206 - op: optype,  
207 - param: JSON.stringify(yasparm)  
208 - }, true);  
209 - } 219 + argument = setting;
210 220
211 $.ajax({ 221 $.ajax({
212 type: 'GET', 222 type: 'GET',
@@ -214,7 +224,10 @@ function search(opt) { @@ -214,7 +224,10 @@ function search(opt) {
214 data: setting, 224 data: setting,
215 success: function(data) { 225 success: function(data) {
216 var $container, 226 var $container,
217 - num; 227 + num,
  228 + yasparm,
  229 + goodid,
  230 + goodIds = [];
218 231
219 switch (navType) { 232 switch (navType) {
220 case 'today': 233 case 'today':
@@ -230,21 +243,68 @@ function search(opt) { @@ -230,21 +243,68 @@ function search(opt) {
230 break; 243 break;
231 } 244 }
232 245
233 - if (data === ' ' || data === '') { 246 + if (data === ' ' || data === '' || data.list) {
234 nav.end = true; 247 nav.end = true;
235 if (nav.reload) { 248 if (nav.reload) {
236 $container.html(noResult); 249 $container.html(noResult);
237 } 250 }
238 } else { 251 } else {
  252 + yasparm = {
  253 + C_ID: C_ID,
  254 + PAGE_NUM: setting.page,
  255 + FILTER_VALUE: JSON.stringify(setting).replace(/\{|\}|\"/g, ''),
  256 + SORT_TYPE: setting.dayLimit
  257 + };
  258 +
239 if (nav.reload) { 259 if (nav.reload) {
240 $container.html(data); 260 $container.html(data);
241 lazyLoad($container.find('.lazy')); 261 lazyLoad($container.find('.lazy'));
  262 +
  263 + $container.find('.good-info').each(function() {
  264 + goodid = $(this).data('good-id');
  265 +
  266 + if (goodid) {
  267 + goodIds.push(goodid);
  268 + }
  269 + });
  270 +
  271 + if (window._yas && window._yas.sendCustomInfo) {
  272 + window._yas.sendCustomInfo({
  273 + op: 'YB_NEW_GOODS_LIST_L',
  274 + param: JSON.stringify(Object.assign(yasparm, {
  275 + RES_QTY: $container.find('.total').data('id'),
  276 + PRD_LIST: goodIds
  277 + }))
  278 + }, true);
  279 + }
242 } else { 280 } else {
243 num = $container.find('.good-info').length; 281 num = $container.find('.good-info').length;
244 $container.append(data); 282 $container.append(data);
245 283
  284 + if ($container.find('.total')[1]) {
  285 + $container.find('.total')[1].remove();
  286 + }
  287 +
246 // lazy good-infos who append in 288 // lazy good-infos who append in
247 lazyLoad($container.find('.good-info:gt(' + (num - 1) + ') .lazy')); 289 lazyLoad($container.find('.good-info:gt(' + (num - 1) + ') .lazy'));
  290 +
  291 + $container.find('.good-info:gt(' + (num - 1) + ')').each(function() {
  292 + goodid = $(this).data('good-id');
  293 +
  294 + if (goodid) {
  295 + goodIds.push(goodid);
  296 + }
  297 + });
  298 +
  299 + if (window._yas && window._yas.sendCustomInfo) {
  300 + window._yas.sendCustomInfo({
  301 + op: 'YB_NEW_GOODS_LIST_L',
  302 + param: JSON.stringify(Object.assign(yasparm, {
  303 + RES_QTY: $container.find('.total').data('id'),
  304 + PRD_LIST: goodIds
  305 + }))
  306 + }, true);
  307 + }
248 } 308 }
249 309
250 } 310 }
@@ -411,3 +471,27 @@ $listNav.on('touchstart', 'li', function() { @@ -411,3 +471,27 @@ $listNav.on('touchstart', 'li', function() {
411 }).on('touchend touchcancel', function() { 471 }).on('touchend touchcancel', function() {
412 $listNav.find('li').removeClass('bytouch'); 472 $listNav.find('li').removeClass('bytouch');
413 }); 473 });
  474 +
  475 +$('#goods-container').on('click', '.good-info', function() {
  476 + var PRD_ID = $(this).data('good-id'),
  477 + PRD_NUM = $(this).index(),
  478 + FILTER_VALUE = JSON.stringify(argument).replace(/\{|\}|\"/g, '');
  479 +
  480 + // event.preventDefault();
  481 +
  482 + if (window._yas && window._yas.sendCustomInfo) {
  483 + window._yas.sendCustomInfo({
  484 + op: 'YB_NEW_GOODS_LIST_C',
  485 + param: JSON.stringify({
  486 + C_ID: C_ID,
  487 + PRD_ID: PRD_ID,
  488 + PRD_NUM: PRD_NUM,
  489 + PAGE_NUM: argument.page,
  490 + FILTER_VALUE: FILTER_VALUE || '',
  491 + SORT_TYPE: argument.dayLimit
  492 + })
  493 + }, true);
  494 + }
  495 +
  496 + // return false;
  497 +});