Authored by zhangxiaoru

品牌品类

@@ -222,7 +222,8 @@ const category = (req, res) => { @@ -222,7 +222,8 @@ const category = (req, res) => {
222 }), 222 }),
223 goodList: params, 223 goodList: params,
224 showDownloadApp: true, 224 showDownloadApp: true,
225 - pageFooter: true 225 + pageFooter: true,
  226 + category: true
226 }); 227 });
227 }; 228 };
228 229
@@ -182,11 +182,16 @@ const search = (req, res, next) => { @@ -182,11 +182,16 @@ const search = (req, res, next) => {
182 182
183 params.isApp = req.yoho.isApp; 183 params.isApp = req.yoho.isApp;
184 searchModel.getSearchData(params).then((result) => { 184 searchModel.getSearchData(params).then((result) => {
  185 + if(result.list.length > 0) {
185 res.render('search/page', { 186 res.render('search/page', {
186 layout: false, 187 layout: false,
187 new: result.list, 188 new: result.list,
188 total: result.total 189 total: result.total
189 }); 190 });
  191 + } else {
  192 + res.json(result);
  193 + }
  194 +
190 }).catch(next); 195 }).catch(next);
191 }; 196 };
192 197
@@ -147,12 +147,15 @@ const getSearchData = (params) => { @@ -147,12 +147,15 @@ const getSearchData = (params) => {
147 if (result && result.code === 200) { 147 if (result && result.code === 200) {
148 let newList = {}; 148 let newList = {};
149 149
150 - newList.total = result.data.total;  
151 -  
152 newList.list = productProcess.processProductList(result.data.product_list || [], { 150 newList.list = productProcess.processProductList(result.data.product_list || [], {
153 isApp: params.isApp || (params.appVersion && params.appVersion !== 'false'), 151 isApp: params.isApp || (params.appVersion && params.appVersion !== 'false'),
154 gender: _coverChannel[params.coverChannel] 152 gender: _coverChannel[params.coverChannel]
155 }); 153 });
  154 +
  155 + if(parseInt(params.page) === 1) {
  156 + newList.total = result.data.total;
  157 + }
  158 +
156 return newList; 159 return newList;
157 } else { 160 } else {
158 logger.error('get product search api return code is not 200'); 161 logger.error('get product search api return code is not 200');
1 <div class="good-list-page yoho-page"> 1 <div class="good-list-page yoho-page">
2 {{> search/list}} 2 {{> search/list}}
  3 + {{#if category}}
  4 + <input type="text" id="category-point" style="display:none" value="{{category}}">
  5 + {{/if}}
3 </div> 6 </div>
@@ -2,4 +2,3 @@ @@ -2,4 +2,3 @@
2 {{# new}} 2 {{# new}}
3 {{> common/goods}} 3 {{> common/goods}}
4 {{/ new}} 4 {{/ new}}
5 -  
@@ -201,6 +201,13 @@ function search(opt) { @@ -201,6 +201,13 @@ function search(opt) {
201 searching = true; 201 searching = true;
202 loading.showLoadingMask(); 202 loading.showLoadingMask();
203 203
  204 + if (window._yas && window._yas.sendCustomInfo) {
  205 + window._yas.sendCustomInfo({
  206 + op: optype,
  207 + param: JSON.stringify(yasparm)
  208 + }, true);
  209 + }
  210 +
204 $.ajax({ 211 $.ajax({
205 type: 'GET', 212 type: 'GET',
206 url: '/product/new/selectNewSale', 213 url: '/product/new/selectNewSale',
@@ -67,7 +67,9 @@ var $listNav = $('#list-nav'), @@ -67,7 +67,9 @@ var $listNav = $('#list-nav'),
67 introHammer, 67 introHammer,
68 brandColHammer; 68 brandColHammer;
69 69
70 -var getChannel, C_ID, RES_QTY, qwert; 70 +var getChannel, C_ID, RES_QTY, argument, optype;
  71 +
  72 +var category = $('#category-point').val();
71 73
72 require('../../common'); 74 require('../../common');
73 75
@@ -373,7 +375,7 @@ function search(opt) { @@ -373,7 +375,7 @@ function search(opt) {
373 searching = true; 375 searching = true;
374 loading.showLoadingMask(); 376 loading.showLoadingMask();
375 377
376 - qwert = setting; 378 + argument = setting;
377 379
378 $.ajax({ 380 $.ajax({
379 type: 'GET', 381 type: 'GET',
@@ -384,7 +386,8 @@ function search(opt) { @@ -384,7 +386,8 @@ function search(opt) {
384 num, 386 num,
385 $container, 387 $container,
386 goodIds = [], 388 goodIds = [],
387 - FILTER_VALUE; 389 + FILTER_VALUE,
  390 + yasparm;
388 391
389 switch (navType) { 392 switch (navType) {
390 case 'newest': 393 case 'newest':
@@ -399,14 +402,40 @@ function search(opt) { @@ -399,14 +402,40 @@ function search(opt) {
399 default: 402 default:
400 break; 403 break;
401 } 404 }
  405 + //console.log(data)
402 406
403 - if (data === '') { 407 + if (data === '' || data.list) {
404 nav.end = true; 408 nav.end = true;
405 409
406 if (nav.reload) { 410 if (nav.reload) {
407 $container.html(noResult); 411 $container.html(noResult);
408 } 412 }
409 } else { 413 } else {
  414 +
  415 + yasparm = {
  416 + C_ID: C_ID,
  417 + PAGE_NUM: setting.page,
  418 + FILTER_VALUE: FILTER_VALUE,
  419 + SORT_TYPE: setting.type
  420 + }
  421 +
  422 + if(category) {
  423 + optype = 'YB_CATEGORY_GOODS_LIST_L',
  424 + yasparm = Object.assign(yasparm, {
  425 + CATEGORY_ID: window.queryString.title || '',
  426 + })
  427 + } else if ($brandHeader.length > 0) {
  428 + optype = 'YB_BRAND_GOODS_LIST_L',
  429 + yasparm = Object.assign(yasparm, {
  430 + BRAND_ID: $brandHeader.data('id')
  431 + })
  432 + } else {
  433 + optype = 'YB_KEYWORD_GOOS_LIST_L',
  434 + yasparm = Object.assign(yasparm, {
  435 + KEYWORD: setting.query || ''
  436 + })
  437 + }
  438 +
410 if (nav.reload) { 439 if (nav.reload) {
411 $container.html(data); 440 $container.html(data);
412 lazyLoad($container.find('.lazy')); 441 lazyLoad($container.find('.lazy'));
@@ -422,28 +451,29 @@ function search(opt) { @@ -422,28 +451,29 @@ function search(opt) {
422 } 451 }
423 }); 452 });
424 453
425 - if (window._yas && window._yas.sendCustomInfo) {  
426 - window._yas.sendCustomInfo({  
427 - op: 'YB_KEYWORD_GOOS_LIST_L',  
428 - param: JSON.stringify({  
429 - C_ID: C_ID,  
430 - KEYWORD: setting.query || '',  
431 - RES_QTY: RES_QTY, 454 + yasparm = Object.assign(yasparm, {
432 PRD_LIST: goodIds, 455 PRD_LIST: goodIds,
433 - PAGE_NUM: setting.page,  
434 - FILTER_VALUE: FILTER_VALUE,  
435 - SORT_TYPE: setting.type 456 + RES_QTY: RES_QTY,
  457 + FILTER_VALUE: FILTER_VALUE
436 }) 458 })
  459 +
  460 + if (window._yas && window._yas.sendCustomInfo) {
  461 + window._yas.sendCustomInfo({
  462 + op: optype,
  463 + param: JSON.stringify(yasparm)
437 }, true); 464 }, true);
438 } 465 }
439 } else { 466 } else {
440 num = $container.find('.good-info').length; 467 num = $container.find('.good-info').length;
441 $container.append(data); 468 $container.append(data);
442 469
443 - if ($container.find('.total')) { 470 + if ($container.find('.total')[1]) {
444 $container.find('.total')[1].remove(); 471 $container.find('.total')[1].remove();
445 } 472 }
446 473
  474 + RES_QTY = $container.find('.total').data('id');
  475 + FILTER_VALUE = JSON.stringify(setting).replace(/\{|\}|\"/g, '');
  476 +
447 $container.find('.good-info:gt(' + (num - 1) + ')').each(function() { 477 $container.find('.good-info:gt(' + (num - 1) + ')').each(function() {
448 var goodid = $(this).data('good-id'); 478 var goodid = $(this).data('good-id');
449 479
@@ -452,18 +482,16 @@ function search(opt) { @@ -452,18 +482,16 @@ function search(opt) {
452 } 482 }
453 }); 483 });
454 484
455 - if (window._yas && window._yas.sendCustomInfo) {  
456 - window._yas.sendCustomInfo({  
457 - op: 'YB_KEYWORD_GOOS_LIST_L',  
458 - param: JSON.stringify({  
459 - C_ID: C_ID,  
460 - KEYWORD: setting.query || '',  
461 - RES_QTY: RES_QTY, 485 + yasparm = Object.assign(yasparm, {
462 PRD_LIST: goodIds, 486 PRD_LIST: goodIds,
463 - PAGE_NUM: setting.page,  
464 - FILTER_VALUE: FILTER_VALUE,  
465 - SORT_TYPE: setting.type 487 + RES_QTY: RES_QTY,
  488 + FILTER_VALUE: FILTER_VALUE
466 }) 489 })
  490 +
  491 + if (window._yas && window._yas.sendCustomInfo) {
  492 + window._yas.sendCustomInfo({
  493 + op: optype,
  494 + param: JSON.stringify(yasparm)
467 }, true); 495 }, true);
468 } 496 }
469 497
@@ -745,24 +773,44 @@ $listNav.on('touchstart', 'li', function() { @@ -745,24 +773,44 @@ $listNav.on('touchstart', 'li', function() {
745 773
746 $('#goods-container').on('click', '.good-info', function(event) { 774 $('#goods-container').on('click', '.good-info', function(event) {
747 var PRD_ID = $(this).data('good-id'), 775 var PRD_ID = $(this).data('good-id'),
748 - PRD_NUM = $(this).index() + 1,  
749 - FILTER_VALUE = JSON.stringify(qwert).replace(/\{|\}|\"/g, ''); 776 + PRD_NUM = $(this).index(),
  777 + FILTER_VALUE = JSON.stringify(argument).replace(/\{|\}|\"/g, ''),
  778 + yasparms;
750 779
751 - event.preventDefault();  
752 - if (window._yas && window._yas.sendCustomInfo) {  
753 - window._yas.sendCustomInfo({  
754 - op: 'YB_KEYWORD_GOODS_LIST_C',  
755 - param: JSON.stringify({ 780 + //event.preventDefault();
  781 +
  782 + yasparms = {
756 C_ID: C_ID, 783 C_ID: C_ID,
757 - KEYWORD: qwert.query || '',  
758 PRD_ID: PRD_ID, 784 PRD_ID: PRD_ID,
759 PRD_NUM: PRD_NUM, 785 PRD_NUM: PRD_NUM,
760 - PAGE_NUM: qwert.page, 786 + PAGE_NUM: argument.page,
761 FILTER_VALUE: FILTER_VALUE, 787 FILTER_VALUE: FILTER_VALUE,
762 - SORT_TYPE: qwert.type 788 + SORT_TYPE: argument.type
  789 + }
  790 +
  791 + if(category) {
  792 + optype = 'YB_CATEGORY_GOODS_LIST_C',
  793 + yasparms = Object.assign(yasparms, {
  794 + CATEGORY_ID: window.queryString.title || '',
  795 + })
  796 + } else if ($brandHeader.length > 0) {
  797 + optype = 'YB_BRAND_GOODS_LIST_C',
  798 + yasparms = Object.assign(yasparms, {
  799 + BRAND_ID: $brandHeader.data('id')
763 }) 800 })
  801 + } else {
  802 + optype = 'YB_KEYWORD_GOOS_LIST_C',
  803 + yasparms = Object.assign(yasparms, {
  804 + KEYWORD: argument.query || ''
  805 + })
  806 + }
  807 +
  808 + if (window._yas && window._yas.sendCustomInfo) {
  809 + window._yas.sendCustomInfo({
  810 + op: optype,
  811 + param: JSON.stringify(yasparms)
764 }, true); 812 }, true);
765 } 813 }
766 814
767 - return false; 815 + //return false;
768 }); 816 });