Authored by 王水玲

outlet bug 修改

@@ -29,10 +29,10 @@ const typeCont = { @@ -29,10 +29,10 @@ const typeCont = {
29 sale: ['s_n_desc', 's_n_asc'], 29 sale: ['s_n_desc', 's_n_asc'],
30 30
31 // newest: ['s_t_desc,s_s_desc', 's_t_asc,s_s_asc'], 31 // newest: ['s_t_desc,s_s_desc', 's_t_asc,s_s_asc'],
32 -  
33 newest: ['s_t_desc', 's_t_asc'], 32 newest: ['s_t_desc', 's_t_asc'],
34 stock: ['s_s_desc', 's_s_asc'], 33 stock: ['s_s_desc', 's_s_asc'],
35 - all: ['d_s_desc', 'd_s_asc'] 34 + all: ['d_s_desc', 'd_s_asc'],
  35 + category: ['s_t_desc', 's_t_asc']
36 }; 36 };
37 37
38 const channelType = { 38 const channelType = {
@@ -9,11 +9,31 @@ var $categoryNavItem = $('.outlet-category-nav a'); @@ -9,11 +9,31 @@ var $categoryNavItem = $('.outlet-category-nav a');
9 var search = require('./sale/search'); 9 var search = require('./sale/search');
10 var iscroll = require('./outlet/nav'); 10 var iscroll = require('./outlet/nav');
11 11
12 -require('./sale/search');  
13 -  
14 lazyLoad($('img.lazy')); 12 lazyLoad($('img.lazy'));
15 13
16 14
  15 +// 搜索条件初始化
  16 +function searchInitParam(dom) {
  17 + var href = dom.attr('href'),
  18 + querys = href.split('?')[1].split('&');
  19 +
  20 + var query = {};
  21 +
  22 + querys.forEach(function(value) {
  23 + var queryPairs = value.split('='),
  24 + key = queryPairs[0],
  25 + val = queryPairs[1];
  26 +
  27 + if (key === 'actiontype') {
  28 + return;
  29 + }
  30 +
  31 + query[key] = val;
  32 + });
  33 +
  34 + return query;
  35 +}
  36 +
17 if ($el.length > 0) { 37 if ($el.length > 0) {
18 $el.each(function() { 38 $el.each(function() {
19 new Countdown.Countdown({ 39 new Countdown.Countdown({
@@ -34,26 +54,14 @@ if ($('.swiper-container .swiper-slide').length > 1) { @@ -34,26 +54,14 @@ if ($('.swiper-container .swiper-slide').length > 1) {
34 }); 54 });
35 } 55 }
36 56
37 -  
38 $categoryNavItem.on('click', function(e) { 57 $categoryNavItem.on('click', function(e) {
39 - var href = $(this).attr('href'),  
40 - querys = href.split('?')[1].split('&');  
41 -  
42 - var query = {}; 58 + var query = searchInitParam($(this));
43 59
44 $('.category a').removeClass('active'); 60 $('.category a').removeClass('active');
45 $(this).addClass('active'); 61 $(this).addClass('active');
46 62
47 e.preventDefault(); 63 e.preventDefault();
48 64
49 - querys.forEach(function(value) {  
50 - var queryPairs = value.split('='),  
51 - key = queryPairs[0],  
52 - val = queryPairs[1];  
53 -  
54 - query[key] = val;  
55 - });  
56 -  
57 search.start({ 65 search.start({
58 type: 'category' 66 type: 'category'
59 }, query); 67 }, query);
@@ -61,7 +69,11 @@ $categoryNavItem.on('click', function(e) { @@ -61,7 +69,11 @@ $categoryNavItem.on('click', function(e) {
61 69
62 // 触发第一个search 70 // 触发第一个search
63 if ($categoryNavItem.length > 0) { 71 if ($categoryNavItem.length > 0) {
64 - $categoryNavItem.eq(0).trigger('click'); 72 + // $categoryNavItem.eq(0).trigger('click');
  73 +
  74 + search.start({
  75 + type: 'category'
  76 + }, searchInitParam($categoryNavItem.eq(0)));
65 } 77 }
66 78
67 // 导航滚动 79 // 导航滚动
@@ -77,7 +89,7 @@ if ($('.outlet-category-nav').length > 0) { @@ -77,7 +89,7 @@ if ($('.outlet-category-nav').length > 0) {
77 }).goto(0); 89 }).goto(0);
78 } 90 }
79 91
80 -//更多活动按钮 92 +// 更多活动按钮
81 if ($('.back-ground-white').length > 10) { 93 if ($('.back-ground-white').length > 10) {
82 $('.more-activity').show(); 94 $('.more-activity').show();
83 $('.back-ground-white').each(function(index, e) { 95 $('.back-ground-white').each(function(index, e) {
@@ -323,26 +323,33 @@ function search(opt, params) { @@ -323,26 +323,33 @@ function search(opt, params) {
323 323
324 } 324 }
325 325
326 -$.ajax({  
327 - type: 'GET',  
328 - url: '/product/sale/filter',  
329 - data: defaultOpt,  
330 - success: function(data) {  
331 - $goodsContainer.append(data);  
332 -  
333 - // 初始化filter&注册filter回调  
334 - filter.initFilter({  
335 - fCbFn: search,  
336 - hCbFn: function() {  
337 -  
338 - // 切换active状态到$pre上  
339 - $pre.addClass('active');  
340 - $pre.siblings('.filter').removeClass('active');  
341 - },  
342 - missStatus: true  
343 - });  
344 - }  
345 -}); 326 +function filterInit() {
  327 + $.ajax({
  328 + type: 'GET',
  329 + url: '/product/sale/filter',
  330 + data: defaultOpt,
  331 + success: function(data) {
  332 + $goodsContainer.append(data);
  333 +
  334 + // 初始化filter&注册filter回调
  335 + filter.initFilter({
  336 + fCbFn: search,
  337 + hCbFn: function() {
  338 +
  339 + // 切换active状态到$pre上
  340 + $pre.addClass('active');
  341 + $pre.siblings('.filter').removeClass('active');
  342 + },
  343 + missStatus: true
  344 + });
  345 + }
  346 + });
  347 +}
  348 +
  349 +if ($('.outlet-index-page').length === 0) {
  350 + filterInit();
  351 +}
  352 +
346 lazyLoad($('.lazy')); 353 lazyLoad($('.lazy'));
347 354
348 // 导航栏点击逻辑说明: 355 // 导航栏点击逻辑说明:
@@ -479,7 +486,9 @@ function scrollHandler() { @@ -479,7 +486,9 @@ function scrollHandler() {
479 486
480 // srcoll to load more 487 // srcoll to load more
481 $(window).scroll(function() { 488 $(window).scroll(function() {
482 - window.requestAnimationFrame(scrollHandler); 489 + if ($('.outlet-index-page').length === 0) {
  490 + window.requestAnimationFrame(scrollHandler);
  491 + }
483 }); 492 });
484 493
485 494