Authored by xuqi

homeupdate

@@ -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,34 +43,16 @@ navHammer.on('tap', function(event) { @@ -60,34 +43,16 @@ navHammer.on('tap', function(event) {
60 width: '100%', 43 width: '100%',
61 overflow: 'hidden' 44 overflow: 'hidden'
62 }); 45 });
63 - }  
64 - event.stopPropagation(); 46 + event.srcEvent.stopPropagation();
65 }); 47 });
66 48
67 -//点击页面主体,收起侧栏导航及二级导航  
68 -// $('.mobile-wrap').on('tap', function () {  
69 -// if ($(this).hasClass('menu-open')) {  
70 -// $('.mobile-wrap').removeClass('menu-open');  
71 -// $('.overlay').css('opacity', 0);  
72 -// $('.sub-nav').removeClass('show');  
73 -// $('.side-nav').removeClass('on');  
74 -// $('body').css({  
75 -// height: 'auto',  
76 -// overflow: 'auto'  
77 -// });  
78 -// setTimeout(function() {  
79 -// $('.overlay').hide();  
80 -// }, 300);  
81 -// }  
82 -// });  
83 -  
84 mobileWrapHammer = new Hammer($('.mobile-wrap')[0]); 49 mobileWrapHammer = new Hammer($('.mobile-wrap')[0]);
85 -mobileWrapHammer.on('tap', function(event) {  
86 - if ($(this).hasClass('menu-open')) {  
87 - $('.mobile-wrap').removeClass('menu-open');  
88 - $('.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);
89 $('.sub-nav').removeClass('show'); 54 $('.sub-nav').removeClass('show');
90 - $('.side-nav').removeClass('on'); 55 + $sideNav.removeClass('on');
91 $('body').css({ 56 $('body').css({
92 height: 'auto', 57 height: 'auto',
93 overflow: 'auto' 58 overflow: 'auto'
@@ -95,11 +60,12 @@ mobileWrapHammer.on('tap', function(event) { @@ -95,11 +60,12 @@ mobileWrapHammer.on('tap', function(event) {
95 setTimeout(function() { 60 setTimeout(function() {
96 $('.overlay').hide(); 61 $('.overlay').hide();
97 }, 300); 62 }, 300);
  63 + e.srcEvent.stopPropagation();
98 } 64 }
99 }); 65 });
100 66
101 //点击一级导航,弹出二级导航 67 //点击一级导航,弹出二级导航
102 -$('.side-nav').on('touchstart', 'li', function () { 68 +$sideNav.on('touchstart', 'li', function () {
103 if ($(this).find('.sub-nav').size() > 0) { 69 if ($(this).find('.sub-nav').size() > 0) {
104 $('.sub-nav').removeClass('show'); 70 $('.sub-nav').removeClass('show');
105 $(this).find('.sub-nav').addClass('show'); 71 $(this).find('.sub-nav').addClass('show');
@@ -114,13 +80,6 @@ $('.sub-nav').each(function () { @@ -114,13 +80,6 @@ $('.sub-nav').each(function () {
114 }); 80 });
115 }); 81 });
116 82
117 -//二级导航样式控制  
118 -$('.sub-nav').on('mouseenter', 'li', function () {  
119 - if ($(this).index() !== 0) {  
120 - $(this).addClass('current').siblings().removeClass('current');  
121 - }  
122 -});  
123 -  
124 //头部banner轮播 83 //头部banner轮播
125 if ($('.banner-swiper').find('li').size() > 1) { 84 if ($('.banner-swiper').find('li').size() > 1) {
126 bannerSwiper = new Swiper('.banner-swiper', { 85 bannerSwiper = new Swiper('.banner-swiper', {
@@ -39,10 +39,11 @@ @@ -39,10 +39,11 @@
39 39
40 .nav-btn { 40 .nav-btn {
41 position: absolute; 41 position: absolute;
42 - left: 32rem / $pxConvertRem; 42 + left: 0;
43 top: 0; 43 top: 0;
44 bottom: 0; 44 bottom: 0;
45 z-index: 2; 45 z-index: 2;
  46 + padding: 0 32rem / $pxConvertRem;
46 } 47 }
47 48
48 .logo { 49 .logo {