Authored by 梁志锋

Merge remote-tracking branch 'remotes/origin/develop/wap' into beta/wap

@@ -13,6 +13,8 @@ var $ = require('jquery'), @@ -13,6 +13,8 @@ var $ = require('jquery'),
13 tip = require('../plugin/tip'), 13 tip = require('../plugin/tip'),
14 loading = require('../plugin/loading'); 14 loading = require('../plugin/loading');
15 15
  16 +var innerScroll = require('../plugin/inner-scroll');
  17 +
16 var $chosePanel = $('#chose-panel'), 18 var $chosePanel = $('#chose-panel'),
17 $num, 19 $num,
18 $chosed, 20 $chosed,
@@ -31,6 +33,7 @@ var $chosePanel = $('#chose-panel'), @@ -31,6 +33,7 @@ var $chosePanel = $('#chose-panel'),
31 cbFn, 33 cbFn,
32 $allChoseItems, 34 $allChoseItems,
33 queryString, 35 queryString,
  36 + $choseArea,
34 $soonSoldOut = $('.soonSoldOut-tag'), 37 $soonSoldOut = $('.soonSoldOut-tag'),
35 $yohoPage = $('.yoho-page'); 38 $yohoPage = $('.yoho-page');
36 39
@@ -46,6 +49,7 @@ function init() { @@ -46,6 +49,7 @@ function init() {
46 $curSizeBlock = null; 49 $curSizeBlock = null;
47 queryString = $.queryString(); 50 queryString = $.queryString();
48 $imgsThumb = $('.chose-panel').find('.thumb'); 51 $imgsThumb = $('.chose-panel').find('.thumb');
  52 + $choseArea = $('.chose-panel .main .chose-items');
49 $allChoseItems = $('.chose-items'); 53 $allChoseItems = $('.chose-items');
50 $sizeRowList = $('.size-list ul'); 54 $sizeRowList = $('.size-list ul');
51 $colorRowList = $('.color-list ul'); 55 $colorRowList = $('.color-list ul');
@@ -71,101 +75,6 @@ function setEditModeWithSknId(sknId, isThisGoodSelected) { @@ -71,101 +75,6 @@ function setEditModeWithSknId(sknId, isThisGoodSelected) {
71 isSelected = isThisGoodSelected; 75 isSelected = isThisGoodSelected;
72 } 76 }
73 77
74 -function preventDefault(e) {  
75 - e = e || window.event;  
76 - e.preventDefault && e.preventDefault();  
77 - e.returnValue = false;  
78 -}  
79 -  
80 -function stopPropagation(e) {  
81 - e = e || window.event;  
82 - e.stopPropagation && e.stopPropagation();  
83 - e.cancelBubble = false;  
84 -}  
85 -  
86 -function innerScroll(e) {  
87 - var delta = e.wheelDelta || e.originalEvent.wheelDelta || e.detail || 0,  
88 - box = $(this).get(0);  
89 -  
90 - // 阻止冒泡到document  
91 - // document上已经preventDefault  
92 - stopPropagation(e);  
93 -  
94 -  
95 - if ($(box).height() + box.scrollTop >= box.scrollHeight) {  
96 - if (delta < 0) {  
97 - preventDefault(e);  
98 - return false;  
99 - }  
100 - }  
101 - if (box.scrollTop === 0) {  
102 - if (delta > 0) {  
103 - preventDefault(e);  
104 - return false;  
105 - }  
106 - }  
107 -}  
108 -  
109 -function disableScroll() {  
110 - var startX, startY;  
111 -  
112 - var $choseArea = $('.chose-panel .main .chose-items');  
113 -  
114 - // 内部可滚  
115 - $choseArea.on('mousewheel', innerScroll);  
116 -  
117 - // 移动端touch重写  
118 - $choseArea.on('touchstart', function(e) {  
119 - startX = e.originalEvent.changedTouches[0].pageX;  
120 - startY = e.originalEvent.changedTouches[0].pageY;  
121 - });  
122 -  
123 - // 仿innerScroll方法  
124 - $choseArea.on('touchmove', function(e) {  
125 - var deltaX = e.originalEvent.changedTouches[0].pageX - startX,  
126 - deltaY = e.originalEvent.changedTouches[0].pageY - startY;  
127 -  
128 - var box = $(this).get(0);  
129 -  
130 - e.stopPropagation();  
131 -  
132 -  
133 - // 只能纵向滚  
134 - if (Math.abs(deltaY) < Math.abs(deltaX)) {  
135 - e.preventDefault();  
136 - return false;  
137 - }  
138 -  
139 -  
140 - if ($(box).height() + box.scrollTop >= box.scrollHeight) {  
141 - if (deltaY < 0) {  
142 - e.preventDefault();  
143 - return false;  
144 - }  
145 - }  
146 - if (box.scrollTop === 0) {  
147 - if (deltaY > 0) {  
148 - e.preventDefault();  
149 - return false;  
150 - }  
151 - }  
152 - });  
153 -  
154 - $(document).on('mousewheel', preventDefault);  
155 - $(document).on('touchmove', preventDefault);  
156 -}  
157 -  
158 -function enableScroll() {  
159 - var $choseArea = $('.chose-panel .main .chose-items');  
160 -  
161 - $choseArea.off('touchstart');  
162 - $choseArea.off('touchmove');  
163 - $choseArea.off('mousewheel');  
164 -  
165 - $(document).off('mousewheel', preventDefault);  
166 - $(document).off('touchmove', preventDefault);  
167 -}  
168 -  
169 //删除面板 78 //删除面板
170 function removePannel() { 79 function removePannel() {
171 var $pannel = $('.chose-panel'), 80 var $pannel = $('.chose-panel'),
@@ -220,13 +129,13 @@ function show(html, cb) { @@ -220,13 +129,13 @@ function show(html, cb) {
220 cbFn = cb; 129 cbFn = cb;
221 130
222 131
223 - disableScroll(); 132 + innerScroll.disableScroll($choseArea);
224 } 133 }
225 134
226 //隐藏当前Panel 135 //隐藏当前Panel
227 function hide() { 136 function hide() {
228 $('.chose-panel').hide(); 137 $('.chose-panel').hide();
229 - enableScroll(); 138 + innerScroll.enableScroll($choseArea);
230 } 139 }
231 140
232 //修改加入购物车的文字和背景 141 //修改加入购物车的文字和背景
@@ -19,9 +19,12 @@ var $ = require('jquery'), @@ -19,9 +19,12 @@ var $ = require('jquery'),
19 var start = 0, 19 var start = 0,
20 swiperClass, 20 swiperClass,
21 $logotrans = $('.home-header .logo'), 21 $logotrans = $('.home-header .logo'),
  22 + $choseArea = $('.side-nav .first'),
22 openSideNav = false, 23 openSideNav = false,
23 isen = true; 24 isen = true;
24 25
  26 +var innerScroll = require('../plugin/inner-scroll');
  27 +
25 lazyLoad($('img.lazy')); 28 lazyLoad($('img.lazy'));
26 29
27 $('.nav-btn').on('touchstart', function(event) { 30 $('.nav-btn').on('touchstart', function(event) {
@@ -35,6 +38,8 @@ $('.nav-btn').on('touchstart', function(event) { @@ -35,6 +38,8 @@ $('.nav-btn').on('touchstart', function(event) {
35 $sideNav.css('pointer-events', 'auto'); 38 $sideNav.css('pointer-events', 'auto');
36 }, 400); 39 }, 400);
37 40
  41 + innerScroll.disableScroll($choseArea);
  42 +
38 return false; 43 return false;
39 }); 44 });
40 45
@@ -49,16 +54,13 @@ function hideSideBar() { @@ -49,16 +54,13 @@ function hideSideBar() {
49 } 54 }
50 55
51 $('.overlay').on('touchstart', function(e) { 56 $('.overlay').on('touchstart', function(e) {
  57 + innerScroll.enableScroll($choseArea);
52 hideSideBar(); 58 hideSideBar();
53 return false; 59 return false;
54 }); 60 });
55 61
56 -$sideNav.on('touchmove', function(e) {  
57 - return false;  
58 -});  
59 -  
60 -//点击一级导航,弹出二级导航  
61 -$sideNav.on('touchstart', 'li', function(e) { 62 +// 点击一级导航,弹出二级导航
  63 +$sideNav.on('touchend', 'li', function(e) {
62 if ($(this).find('.sub-nav').size() > 0) { 64 if ($(this).find('.sub-nav').size() > 0) {
63 $('.sub-nav').removeClass('show'); 65 $('.sub-nav').removeClass('show');
64 $(this).find('.sub-nav').addClass('show'); 66 $(this).find('.sub-nav').addClass('show');
@@ -70,7 +72,7 @@ $sideNav.on('touchstart', 'li', function(e) { @@ -70,7 +72,7 @@ $sideNav.on('touchstart', 'li', function(e) {
70 } 72 }
71 }); 73 });
72 74
73 -//返回一级导航,收起二级导航 75 +// 返回一级导航,收起二级导航
74 $subNav.each(function() { 76 $subNav.each(function() {
75 $(this).find('li').eq(0).on('touchend', function() { 77 $(this).find('li').eq(0).on('touchend', function() {
76 $sideNav.css('pointer-events', 'none'); 78 $sideNav.css('pointer-events', 'none');
@@ -99,7 +101,7 @@ highlight($sideNav); @@ -99,7 +101,7 @@ highlight($sideNav);
99 highlight($subNav); 101 highlight($subNav);
100 102
101 103
102 -//头部banner轮播 104 +// 头部banner轮播
103 if ($('.banner-swiper').find('li').size() > 1) { 105 if ($('.banner-swiper').find('li').size() > 1) {
104 bannerSwiper = new Swiper('.banner-swiper', { 106 bannerSwiper = new Swiper('.banner-swiper', {
105 lazyLoading: true, 107 lazyLoading: true,
@@ -113,7 +115,7 @@ if ($('.banner-swiper').find('li').size() > 1) { @@ -113,7 +115,7 @@ if ($('.banner-swiper').find('li').size() > 1) {
113 }); 115 });
114 } 116 }
115 117
116 -//热门品牌滑动 118 +// 热门品牌滑动
117 hotBrandsSwiper = new Swiper('.brands-swiper', { 119 hotBrandsSwiper = new Swiper('.brands-swiper', {
118 grabCursor: true, 120 grabCursor: true,
119 slidesPerView: 'auto', 121 slidesPerView: 'auto',
@@ -121,7 +123,7 @@ hotBrandsSwiper = new Swiper('.brands-swiper', { @@ -121,7 +123,7 @@ hotBrandsSwiper = new Swiper('.brands-swiper', {
121 slideElement: 'li' 123 slideElement: 'li'
122 }); 124 });
123 125
124 -//推荐搭配滑动 126 +// 推荐搭配滑动
125 recommendSwiper = new Swiper('.recommend-swiper', { 127 recommendSwiper = new Swiper('.recommend-swiper', {
126 grabCursor: true, 128 grabCursor: true,
127 slidesPerView: 'auto', 129 slidesPerView: 'auto',
@@ -129,7 +131,7 @@ recommendSwiper = new Swiper('.recommend-swiper', { @@ -129,7 +131,7 @@ recommendSwiper = new Swiper('.recommend-swiper', {
129 slideElement: 'li' 131 slideElement: 'li'
130 }); 132 });
131 133
132 -//潮品话题轮播 134 +// 潮品话题轮播
133 if ($('.trend-topic-swiper').find('li').size() > 1) { 135 if ($('.trend-topic-swiper').find('li').size() > 1) {
134 trendTopicSwiper = new Swiper('.trend-topic-swiper', { 136 trendTopicSwiper = new Swiper('.trend-topic-swiper', {
135 loop: true, 137 loop: true,
@@ -141,7 +143,7 @@ if ($('.trend-topic-swiper').find('li').size() > 1) { @@ -141,7 +143,7 @@ if ($('.trend-topic-swiper').find('li').size() > 1) {
141 }); 143 });
142 } 144 }
143 145
144 -//潮流上装/经典裤装等轮播 146 +// 潮流上装/经典裤装等轮播
145 $('.category-swiper').each(function(i, index) { 147 $('.category-swiper').each(function(i, index) {
146 swiperClass = 'category-swiper' + i; 148 swiperClass = 'category-swiper' + i;
147 $(this).addClass(swiperClass); 149 $(this).addClass(swiperClass);
@@ -157,7 +159,7 @@ $('.category-swiper').each(function(i, index) { @@ -157,7 +159,7 @@ $('.category-swiper').each(function(i, index) {
157 } 159 }
158 }); 160 });
159 161
160 -//logo动画 162 +// logo动画
161 function tsAnimate() { 163 function tsAnimate() {
162 start = start + 10; 164 start = start + 10;
163 $logotrans.css({ 165 $logotrans.css({
@@ -196,7 +198,7 @@ $('.home-header .iconfont').on('touchstart', function() { @@ -196,7 +198,7 @@ $('.home-header .iconfont').on('touchstart', function() {
196 // 底部留出tab 的高度 198 // 底部留出tab 的高度
197 window.reMarginFooter('.footer-tab'); 199 window.reMarginFooter('.footer-tab');
198 200
199 -//set cookie 201 +// set cookie
200 exports.set = function(c) { 202 exports.set = function(c) {
201 window.setCookie('_Channel', c, { 203 window.setCookie('_Channel', c, {
202 expires: 365, 204 expires: 365,
  1 +/**
  2 + * 弹出层可以滚动,遮盖层禁止滚动插件
  3 + *
  4 + * @author liangzhifeng<zhifeng.liang@yoho.cn>
  5 + * @date: 2016/02/22
  6 + */
  7 +
  8 +var $ = require('jquery');
  9 +
  10 +function preventDefault(e) {
  11 + e = e || window.event;
  12 + e.preventDefault && e.preventDefault();
  13 + e.returnValue = false;
  14 +}
  15 +
  16 +function stopPropagation(e) {
  17 + e = e || window.event;
  18 + e.stopPropagation && e.stopPropagation();
  19 + e.cancelBubble = false;
  20 +}
  21 +
  22 +function innerScroll(e) {
  23 + var delta = e.wheelDelta || e.originalEvent.wheelDelta || e.detail || 0,
  24 + box = $(this).get(0);
  25 +
  26 + // 阻止冒泡到document
  27 + // document上已经preventDefault
  28 + stopPropagation(e);
  29 +
  30 +
  31 + if ($(box).height() + box.scrollTop >= box.scrollHeight) {
  32 + if (delta < 0) {
  33 + preventDefault(e);
  34 + return false;
  35 + }
  36 + }
  37 + if (box.scrollTop === 0) {
  38 + if (delta > 0) {
  39 + preventDefault(e);
  40 + return false;
  41 + }
  42 + }
  43 +}
  44 +
  45 +function disableScroll($choseArea) {
  46 + var startX, startY;
  47 +
  48 + // 内部可滚
  49 + $choseArea.on('mousewheel', innerScroll);
  50 +
  51 + // 移动端touch重写
  52 + $choseArea.on('touchstart', function(e) {
  53 + startX = e.originalEvent.changedTouches[0].pageX;
  54 + startY = e.originalEvent.changedTouches[0].pageY;
  55 + });
  56 +
  57 + // 仿innerScroll方法
  58 + $choseArea.on('touchmove', function(e) {
  59 + var deltaX = e.originalEvent.changedTouches[0].pageX - startX,
  60 + deltaY = e.originalEvent.changedTouches[0].pageY - startY;
  61 +
  62 + var box = $(this).get(0);
  63 +
  64 + e.stopPropagation();
  65 +
  66 +
  67 + // 只能纵向滚
  68 + if (Math.abs(deltaY) < Math.abs(deltaX)) {
  69 + e.preventDefault();
  70 + return false;
  71 + }
  72 +
  73 +
  74 + if ($(box).height() + box.scrollTop >= box.scrollHeight) {
  75 + if (deltaY < 0) {
  76 + e.preventDefault();
  77 + return false;
  78 + }
  79 + }
  80 + if (box.scrollTop === 0) {
  81 + if (deltaY > 0) {
  82 + e.preventDefault();
  83 + return false;
  84 + }
  85 + }
  86 + });
  87 +
  88 + $(document).on('mousewheel', preventDefault);
  89 + $(document).on('touchmove', preventDefault);
  90 +}
  91 +
  92 +function enableScroll($choseArea) {
  93 +
  94 + $choseArea.off('touchstart');
  95 + $choseArea.off('touchmove');
  96 + $choseArea.off('mousewheel');
  97 +
  98 + $(document).off('mousewheel', preventDefault);
  99 + $(document).off('touchmove', preventDefault);
  100 +}
  101 +
  102 +exports.enableScroll = enableScroll;
  103 +exports.disableScroll = disableScroll;
@@ -14,7 +14,7 @@ @@ -14,7 +14,7 @@
14 @include transition(all .3s); 14 @include transition(all .3s);
15 15
16 > ul { 16 > ul {
17 - margin-bottom: 16rem / $pxConvertRem; 17 + margin-bottom: 20rem / $pxConvertRem;
18 background: #fff; 18 background: #fff;
19 border-top: 1px solid #e0e0e0; 19 border-top: 1px solid #e0e0e0;
20 border-bottom: 1px solid #e0e0e0; 20 border-bottom: 1px solid #e0e0e0;
@@ -22,8 +22,8 @@ @@ -22,8 +22,8 @@
22 22
23 li { 23 li {
24 position: relative; 24 position: relative;
25 - height: 64rem / $pxConvertRem;  
26 - line-height: 64rem / $pxConvertRem; 25 + height: 80rem / $pxConvertRem;
  26 + line-height: 80rem / $pxConvertRem;
27 background: #fff; 27 background: #fff;
28 28
29 &:after { 29 &:after {
@@ -45,27 +45,21 @@ @@ -45,27 +45,21 @@
45 a { 45 a {
46 display: block; 46 display: block;
47 height: 100%; 47 height: 100%;
48 - padding-left: 92rem / $pxConvertRem; 48 + padding-left: 110rem / $pxConvertRem;
49 color: #444; 49 color: #444;
50 } 50 }
51 51
52 em { 52 em {
53 font-weight: bold; 53 font-weight: bold;
54 - font-size: 24rem / $pxConvertRem; 54 + font-size: 26rem / $pxConvertRem;
55 } 55 }
56 56
57 .title { 57 .title {
58 display: inline-block; 58 display: inline-block;
59 font-size: 36rem / $pxConvertRem; 59 font-size: 36rem / $pxConvertRem;
60 vertical-align: bottom; 60 vertical-align: bottom;
61 - padding-left: 20rem / $pxConvertRem;  
62 // 此处字体小于 12px, 先扩大,再scale缩小 61 // 此处字体小于 12px, 先扩大,再scale缩小
63 @include transform(scale(0.5)); 62 @include transform(scale(0.5));
64 -  
65 - -webkit-transform-origin: 0 50% 0;  
66 - -moz-transform-origin: 0 50% 0;  
67 - -ms-transform-origin: 0 50% 0;  
68 - transform-origin: 0 50% 0;  
69 } 63 }
70 64
71 .nav-icon, .nav-img { 65 .nav-icon, .nav-img {
@@ -98,8 +92,8 @@ @@ -98,8 +92,8 @@
98 .first { 92 .first {
99 93
100 li { 94 li {
101 - height: 80rem / $pxConvertRem;  
102 - line-height: 80rem / $pxConvertRem; 95 + height: 100rem / $pxConvertRem;
  96 + line-height: 100rem / $pxConvertRem;
103 border-bottom: 1px solid #e0e0e0; 97 border-bottom: 1px solid #e0e0e0;
104 98
105 &:last-child { 99 &:last-child {
@@ -111,7 +105,7 @@ @@ -111,7 +105,7 @@
111 } 105 }
112 106
113 em { 107 em {
114 - font-size: 32rem / $pxConvertRem; 108 + font-size: 36rem / $pxConvertRem;
115 } 109 }
116 110
117 .nav-img, .nav-icon { 111 .nav-img, .nav-icon {