rollback outlet.page.js
Showing
1 changed file
with
34 additions
and
44 deletions
1 | var $ = require('yoho-jquery'), | 1 | var $ = require('yoho-jquery'), |
2 | - iscroll = require('./outlet/nav'), | ||
3 | - lazyLoad = require('yoho-jquery-lazyload'); | ||
4 | - | ||
5 | - | ||
6 | -var Swiper, | ||
7 | - Countdown; | 2 | + Swiper = require('yoho-swiper'), |
3 | + lazyLoad = require('yoho-jquery-lazyload'), | ||
4 | + Countdown = require('./outlet/countdown'); | ||
8 | 5 | ||
9 | var $el = $('.cd-lite'); | 6 | var $el = $('.cd-lite'); |
10 | var $categoryNavItem = $('.outlet-category-nav a'); | 7 | var $categoryNavItem = $('.outlet-category-nav a'); |
11 | -var $moreBtn = $('.more-activity'); | ||
12 | -var $categoryNav = $('.outlet-category-nav'); | ||
13 | -var $slider = $('.swiper-container .swiper-slide'); | ||
14 | -var $topNav = $('#index_nav'); | ||
15 | 8 | ||
16 | var search = require('./sale/search'); | 9 | var search = require('./sale/search'); |
10 | +var iscroll = require('./outlet/nav'); | ||
17 | 11 | ||
18 | require('./outlet/fix-nav'); | 12 | require('./outlet/fix-nav'); |
19 | 13 | ||
@@ -41,27 +35,17 @@ function searchInitParam(dom) { | @@ -41,27 +35,17 @@ function searchInitParam(dom) { | ||
41 | return query; | 35 | return query; |
42 | } | 36 | } |
43 | 37 | ||
44 | -if ($el && $el.length > 0) { | ||
45 | - Countdown = require('./outlet/countdown'); | ||
46 | - | 38 | +if ($el.length > 0) { |
47 | $el.each(function() { | 39 | $el.each(function() { |
48 | new Countdown.Countdown({ | 40 | new Countdown.Countdown({ |
49 | el: $(this) | 41 | el: $(this) |
50 | }); | 42 | }); |
51 | }); | 43 | }); |
52 | } | 44 | } |
53 | -$('.outlet-category-nav').fixNav(); | ||
54 | -if ($categoryNav && $categoryNav.length > 0) { | ||
55 | - // $categoryNav.fixNav(); | ||
56 | 45 | ||
57 | - iscroll({ | ||
58 | - el: '.outlet-category-nav' | ||
59 | - }).goto(0); | ||
60 | -} | ||
61 | - | ||
62 | -if ($slider && $slider.length > 1) { | ||
63 | - Swiper = require('yoho-swiper'); | 46 | +$('.outlet-category-nav').fixNav(); |
64 | 47 | ||
48 | +if ($('.swiper-container .swiper-slide').length > 1) { | ||
65 | new Swiper('.swiper-container', { | 49 | new Swiper('.swiper-container', { |
66 | lazyLoading: true, | 50 | lazyLoading: true, |
67 | lazyLoadingInPrevNext: true, | 51 | lazyLoadingInPrevNext: true, |
@@ -81,33 +65,41 @@ $('.nav-back').on('click', function(e) { | @@ -81,33 +65,41 @@ $('.nav-back').on('click', function(e) { | ||
81 | location.href = '//m.yohobuy.com/' + channel; | 65 | location.href = '//m.yohobuy.com/' + channel; |
82 | }); | 66 | }); |
83 | 67 | ||
84 | -if ($categoryNavItem && $categoryNavItem.length > 0) { | ||
85 | - $categoryNavItem.on('click', function(e) { | ||
86 | - var query = searchInitParam($(this)); | 68 | +$categoryNavItem.on('click', function(e) { |
69 | + var query = searchInitParam($(this)); | ||
87 | 70 | ||
88 | - $('.category a').removeClass('active'); | ||
89 | - $(this).addClass('active'); | 71 | + $('.category a').removeClass('active'); |
72 | + $(this).addClass('active'); | ||
90 | 73 | ||
91 | - e.preventDefault(); | 74 | + e.preventDefault(); |
92 | 75 | ||
93 | - search.start({ | ||
94 | - type: 'category' | ||
95 | - }, query); | ||
96 | - }); | 76 | + search.start({ |
77 | + type: 'category' | ||
78 | + }, query); | ||
79 | +}); | ||
80 | + | ||
81 | +// 触发第一个search | ||
82 | +if ($categoryNavItem.length > 0) { | ||
83 | + // $categoryNavItem.eq(0).trigger('click'); | ||
97 | 84 | ||
98 | - // 触发第一个search | ||
99 | search.start({ | 85 | search.start({ |
100 | type: 'category' | 86 | type: 'category' |
101 | }, searchInitParam($categoryNavItem.eq(0))); | 87 | }, searchInitParam($categoryNavItem.eq(0))); |
102 | } | 88 | } |
103 | 89 | ||
104 | // 导航滚动 | 90 | // 导航滚动 |
105 | -if ($topNav && $topNav.length > 0) { | 91 | +if ($('#index_nav').length > 0) { |
106 | iscroll({ | 92 | iscroll({ |
107 | el: '#index_nav' | 93 | el: '#index_nav' |
108 | }).goto($('#index_nav').find('.active').index()); | 94 | }).goto($('#index_nav').find('.active').index()); |
109 | } | 95 | } |
110 | 96 | ||
97 | +if ($('.outlet-category-nav').length > 0) { | ||
98 | + iscroll({ | ||
99 | + el: '.outlet-category-nav' | ||
100 | + }).goto(0); | ||
101 | +} | ||
102 | + | ||
111 | // 更多活动按钮 | 103 | // 更多活动按钮 |
112 | if ($('.back-ground-white').length > 10) { | 104 | if ($('.back-ground-white').length > 10) { |
113 | $('.more-activity').show(); | 105 | $('.more-activity').show(); |
@@ -118,13 +110,11 @@ if ($('.back-ground-white').length > 10) { | @@ -118,13 +110,11 @@ if ($('.back-ground-white').length > 10) { | ||
118 | }); | 110 | }); |
119 | } | 111 | } |
120 | 112 | ||
121 | -if ($moreBtn && $moreBtn.length > 0) { | ||
122 | - $moreBtn.click(function() { | ||
123 | - $('.more-activity').hide(); | ||
124 | - $('.back-ground-white').each(function(index, e) { | ||
125 | - if (index > 9) { | ||
126 | - $(e).show(); | ||
127 | - } | ||
128 | - }); | 113 | +$('.more-activity').click(function() { |
114 | + $('.more-activity').hide(); | ||
115 | + $('.back-ground-white').each(function(index, e) { | ||
116 | + if (index > 9) { | ||
117 | + $(e).show(); | ||
118 | + } | ||
129 | }); | 119 | }); |
130 | -} | 120 | +}); |
-
Please register or login to post a comment