|
@@ -7,6 +7,9 @@ var $ = require('jquery'), |
|
@@ -7,6 +7,9 @@ var $ = require('jquery'), |
7
|
Hammer = require('hammer'),
|
7
|
Hammer = require('hammer'),
|
8
|
Swiper = require('yoho.iswiper'),
|
8
|
Swiper = require('yoho.iswiper'),
|
9
|
lazyLoad = require('yoho.lazyload'),
|
9
|
lazyLoad = require('yoho.lazyload'),
|
|
|
10
|
+ $mobileWrap = $('.mobile-wrap'),
|
|
|
11
|
+ $overlay = $('.overlay'),
|
|
|
12
|
+ $sideNav = $('.side-nav'),
|
10
|
bannerSwiper,
|
13
|
bannerSwiper,
|
11
|
recommendSwiper,
|
14
|
recommendSwiper,
|
12
|
hotBrandsSwiper,
|
15
|
hotBrandsSwiper,
|
|
@@ -28,31 +31,11 @@ require('./maybe-like'); |
|
@@ -28,31 +31,11 @@ require('./maybe-like'); |
28
|
|
31
|
|
29
|
lazyLoad($('img.lazy'));
|
32
|
lazyLoad($('img.lazy'));
|
30
|
|
33
|
|
31
|
-//$('img:in-viewport').trigger('appear');
|
|
|
32
|
-
|
|
|
33
|
-//点击首页汉堡menu图标,滑出侧栏导航
|
|
|
34
|
-// $('.nav-btn').on('tap', function (event) {
|
|
|
35
|
-// if (!$(this).hasClass('menu-open')) {
|
|
|
36
|
-// $('.mobile-wrap').addClass('menu-open');
|
|
|
37
|
-// $('.overlay').show().css('opacity', 0.3);
|
|
|
38
|
-// $('.side-nav').addClass('on');
|
|
|
39
|
-
|
|
|
40
|
-// //设置boy高宽,页面不能上下滑动
|
|
|
41
|
-// $('body').css({
|
|
|
42
|
-// height: $(window).height(),
|
|
|
43
|
-// width: '100%',
|
|
|
44
|
-// overflow: 'hidden'
|
|
|
45
|
-// });
|
|
|
46
|
-// }
|
|
|
47
|
-// event.stopPropagation();
|
|
|
48
|
-// });
|
|
|
49
|
-
|
|
|
50
|
navHammer = new Hammer($('.nav-btn')[0]);
|
34
|
navHammer = new Hammer($('.nav-btn')[0]);
|
51
|
navHammer.on('tap', function(event) {
|
35
|
navHammer.on('tap', function(event) {
|
52
|
- if (!$(this).hasClass('menu-open')) {
|
|
|
53
|
- $('.mobile-wrap').addClass('menu-open');
|
|
|
54
|
- $('.overlay').show().css('opacity', 0.3);
|
|
|
55
|
- $('.side-nav').addClass('on');
|
36
|
+ $mobileWrap.addClass('menu-open');
|
|
|
37
|
+ $overlay.show().css('opacity', 0.3);
|
|
|
38
|
+ $sideNav.addClass('on');
|
56
|
|
39
|
|
57
|
//设置boy高宽,页面不能上下滑动
|
40
|
//设置boy高宽,页面不能上下滑动
|
58
|
$('body').css({
|
41
|
$('body').css({
|
|
@@ -60,35 +43,16 @@ navHammer.on('tap', function(event) { |
|
@@ -60,35 +43,16 @@ navHammer.on('tap', function(event) { |
60
|
width: '100%',
|
43
|
width: '100%',
|
61
|
overflow: 'hidden'
|
44
|
overflow: 'hidden'
|
62
|
});
|
45
|
});
|
63
|
- }
|
|
|
64
|
-
|
|
|
65
|
- // event.stopPropagation();
|
46
|
+ event.srcEvent.stopPropagation();
|
66
|
});
|
47
|
});
|
67
|
|
48
|
|
68
|
-//点击页面主体,收起侧栏导航及二级导航
|
|
|
69
|
-// $('.mobile-wrap').on('tap', function () {
|
|
|
70
|
-// if ($(this).hasClass('menu-open')) {
|
|
|
71
|
-// $('.mobile-wrap').removeClass('menu-open');
|
|
|
72
|
-// $('.overlay').css('opacity', 0);
|
|
|
73
|
-// $('.sub-nav').removeClass('show');
|
|
|
74
|
-// $('.side-nav').removeClass('on');
|
|
|
75
|
-// $('body').css({
|
|
|
76
|
-// height: 'auto',
|
|
|
77
|
-// overflow: 'auto'
|
|
|
78
|
-// });
|
|
|
79
|
-// setTimeout(function() {
|
|
|
80
|
-// $('.overlay').hide();
|
|
|
81
|
-// }, 300);
|
|
|
82
|
-// }
|
|
|
83
|
-// });
|
|
|
84
|
-
|
|
|
85
|
mobileWrapHammer = new Hammer($('.mobile-wrap')[0]);
|
49
|
mobileWrapHammer = new Hammer($('.mobile-wrap')[0]);
|
86
|
-mobileWrapHammer.on('tap', function(event) {
|
|
|
87
|
- if ($(this).hasClass('menu-open')) {
|
|
|
88
|
- $('.mobile-wrap').removeClass('menu-open');
|
|
|
89
|
- $('.overlay').css('opacity', 0);
|
50
|
+mobileWrapHammer.on('tap', function(e) {
|
|
|
51
|
+ if ($mobileWrap.hasClass('menu-open')) {
|
|
|
52
|
+ $mobileWrap.removeClass('menu-open');
|
|
|
53
|
+ $overlay.css('opacity', 0);
|
90
|
$('.sub-nav').removeClass('show');
|
54
|
$('.sub-nav').removeClass('show');
|
91
|
- $('.side-nav').removeClass('on');
|
55
|
+ $sideNav.removeClass('on');
|
92
|
$('body').css({
|
56
|
$('body').css({
|
93
|
height: 'auto',
|
57
|
height: 'auto',
|
94
|
overflow: 'auto'
|
58
|
overflow: 'auto'
|
|
@@ -96,11 +60,12 @@ mobileWrapHammer.on('tap', function(event) { |
|
@@ -96,11 +60,12 @@ mobileWrapHammer.on('tap', function(event) { |
96
|
setTimeout(function() {
|
60
|
setTimeout(function() {
|
97
|
$('.overlay').hide();
|
61
|
$('.overlay').hide();
|
98
|
}, 300);
|
62
|
}, 300);
|
|
|
63
|
+ e.srcEvent.stopPropagation();
|
99
|
}
|
64
|
}
|
100
|
});
|
65
|
});
|
101
|
|
66
|
|
102
|
//点击一级导航,弹出二级导航
|
67
|
//点击一级导航,弹出二级导航
|
103
|
-$('.side-nav').on('touchstart', 'li', function () {
|
68
|
+$sideNav.on('touchstart', 'li', function () {
|
104
|
if ($(this).find('.sub-nav').size() > 0) {
|
69
|
if ($(this).find('.sub-nav').size() > 0) {
|
105
|
$('.sub-nav').removeClass('show');
|
70
|
$('.sub-nav').removeClass('show');
|
106
|
$(this).find('.sub-nav').addClass('show');
|
71
|
$(this).find('.sub-nav').addClass('show');
|
|
@@ -115,13 +80,6 @@ $('.sub-nav').each(function () { |
|
@@ -115,13 +80,6 @@ $('.sub-nav').each(function () { |
115
|
});
|
80
|
});
|
116
|
});
|
81
|
});
|
117
|
|
82
|
|
118
|
-//二级导航样式控制
|
|
|
119
|
-$('.sub-nav').on('mouseenter', 'li', function () {
|
|
|
120
|
- if ($(this).index() !== 0) {
|
|
|
121
|
- $(this).addClass('current').siblings().removeClass('current');
|
|
|
122
|
- }
|
|
|
123
|
-});
|
|
|
124
|
-
|
|
|
125
|
//头部banner轮播
|
83
|
//头部banner轮播
|
126
|
if ($('.banner-swiper').find('li').size() > 1) {
|
84
|
if ($('.banner-swiper').find('li').size() > 1) {
|
127
|
bannerSwiper = new Swiper('.banner-swiper', {
|
85
|
bannerSwiper = new Swiper('.banner-swiper', {
|