|
@@ -10,6 +10,7 @@ var $ = require('jquery'), |
|
@@ -10,6 +10,7 @@ var $ = require('jquery'), |
10
|
$mobileWrap = $('.mobile-wrap'),
|
10
|
$mobileWrap = $('.mobile-wrap'),
|
11
|
$overlay = $('.overlay'),
|
11
|
$overlay = $('.overlay'),
|
12
|
$sideNav = $('.side-nav'),
|
12
|
$sideNav = $('.side-nav'),
|
|
|
13
|
+ $subNav = $('.sub-nav'),
|
13
|
bannerSwiper,
|
14
|
bannerSwiper,
|
14
|
recommendSwiper,
|
15
|
recommendSwiper,
|
15
|
hotBrandsSwiper,
|
16
|
hotBrandsSwiper,
|
|
@@ -48,8 +49,7 @@ navHammer.on('tap', function(event) { |
|
@@ -48,8 +49,7 @@ navHammer.on('tap', function(event) { |
48
|
return false;
|
49
|
return false;
|
49
|
});
|
50
|
});
|
50
|
|
51
|
|
51
|
-mobileWrapHammer = new Hammer($('.mobile-wrap')[0]);
|
|
|
52
|
-mobileWrapHammer.on('tap', function(e) {
|
52
|
+function hideSideBar() {
|
53
|
if ($mobileWrap.hasClass('menu-open')) {
|
53
|
if ($mobileWrap.hasClass('menu-open')) {
|
54
|
$mobileWrap.removeClass('menu-open');
|
54
|
$mobileWrap.removeClass('menu-open');
|
55
|
$overlay.css('opacity', 0);
|
55
|
$overlay.css('opacity', 0);
|
|
@@ -62,28 +62,40 @@ mobileWrapHammer.on('tap', function(e) { |
|
@@ -62,28 +62,40 @@ mobileWrapHammer.on('tap', function(e) { |
62
|
setTimeout(function() {
|
62
|
setTimeout(function() {
|
63
|
$('.overlay').hide();
|
63
|
$('.overlay').hide();
|
64
|
}, 300);
|
64
|
}, 300);
|
65
|
- e.srcEvent.stopPropagation();
|
|
|
66
|
- return false;
|
|
|
67
|
}
|
65
|
}
|
|
|
66
|
+}
|
|
|
67
|
+
|
|
|
68
|
+mobileWrapHammer = new Hammer($('.mobile-wrap')[0]);
|
|
|
69
|
+mobileWrapHammer.on('tap', function(e) {
|
|
|
70
|
+ hideSideBar();
|
|
|
71
|
+ e.srcEvent.stopPropagation();
|
|
|
72
|
+ return false;
|
68
|
});
|
73
|
});
|
69
|
|
74
|
|
70
|
//点击一级导航,弹出二级导航
|
75
|
//点击一级导航,弹出二级导航
|
71
|
-$sideNav.on('touchend', 'li', function () {
|
76
|
+$sideNav.on('touchend', 'li', function (e) {
|
72
|
if ($(this).find('.sub-nav').size() > 0) {
|
77
|
if ($(this).find('.sub-nav').size() > 0) {
|
73
|
$('.sub-nav').removeClass('show');
|
78
|
$('.sub-nav').removeClass('show');
|
74
|
$(this).find('.sub-nav').addClass('show');
|
79
|
$(this).find('.sub-nav').addClass('show');
|
75
|
}
|
80
|
}
|
76
|
- return false;
|
81
|
+ e.stopPropagation();
|
|
|
82
|
+ if (e.target.pathname === location.pathname) {
|
|
|
83
|
+ hideSideBar();
|
|
|
84
|
+ return false;
|
|
|
85
|
+ }
|
77
|
});
|
86
|
});
|
78
|
|
87
|
|
79
|
//返回一级导航,收起二级导航
|
88
|
//返回一级导航,收起二级导航
|
80
|
-$('.sub-nav').each(function () {
|
89
|
+$subNav.each(function () {
|
81
|
$(this).find('li').eq(0).on('touchend', function (e) {
|
90
|
$(this).find('li').eq(0).on('touchend', function (e) {
|
82
|
$('.sub-nav').removeClass('show');
|
91
|
$('.sub-nav').removeClass('show');
|
|
|
92
|
+ e.stopPropagation();
|
83
|
return false;
|
93
|
return false;
|
84
|
});
|
94
|
});
|
85
|
-}).on('touchend', function() {
|
|
|
86
|
- $('.sub-nav').find('li').removeClass('current');
|
95
|
+}).on('touchend', function(e) {
|
|
|
96
|
+ if (e.currentTarget !== e.target) {
|
|
|
97
|
+ $subNav.find('li').removeClass('current');
|
|
|
98
|
+ }
|
87
|
});
|
99
|
});
|
88
|
|
100
|
|
89
|
//头部banner轮播
|
101
|
//头部banner轮播
|