Authored by xuqi

Merge branch 'develop' of http://git.dev.yoho.cn/web/yohobuy into develop

@@ -5,7 +5,7 @@ @@ -5,7 +5,7 @@
5 */ 5 */
6 6
7 var $ = require('jquery'), 7 var $ = require('jquery'),
8 - Hammer = require('hammer'); 8 + Hammer = require('hammer'),
9 Swiper = require('yoho.iswiper'), 9 Swiper = require('yoho.iswiper'),
10 lazyLoad = require('yoho.lazyload'); 10 lazyLoad = require('yoho.lazyload');
11 11
@@ -22,7 +22,7 @@ var requestFrame, @@ -22,7 +22,7 @@ var requestFrame,
22 $logotrans = $('.home-header .logo'), 22 $logotrans = $('.home-header .logo'),
23 isen = true; 23 isen = true;
24 24
25 -var navHammer, mobileWrapHammer, sideNavHammer; 25 +var navHammer, mobileWrapHammer;
26 26
27 require('./maybe-like'); 27 require('./maybe-like');
28 28
@@ -5,7 +5,6 @@ @@ -5,7 +5,6 @@
5 */ 5 */
6 6
7 var $ = require('jquery'), 7 var $ = require('jquery'),
8 - Hammer = require('hammer'),  
9 tip = require('../plugin/tip'), 8 tip = require('../plugin/tip'),
10 lazyLoad = require('yoho.lazyload'); 9 lazyLoad = require('yoho.lazyload');
11 10
@@ -11,7 +11,7 @@ var $searchBox = $('.search-box'), @@ -11,7 +11,7 @@ var $searchBox = $('.search-box'),
11 $indexSearch = $('.index-search'), 11 $indexSearch = $('.index-search'),
12 $indexLogo = $('.index-logo'); 12 $indexLogo = $('.index-logo');
13 13
14 -var floatLayerCloseHammer, floatLayerBtnHammer, clearTextHammer, searchIconHammer; 14 +var floatLayerCloseHammer, floatLayerBtnHammer;
15 15
16 function downLoadApp() { 16 function downLoadApp() {
17 var appUrl = 'http://a.app.qq.com/o/simple.jsp?pkgname=com.yoho&g_f=995445'; 17 var appUrl = 'http://a.app.qq.com/o/simple.jsp?pkgname=com.yoho&g_f=995445';
@@ -6,6 +6,7 @@ @@ -6,6 +6,7 @@
6 6
7 var $ = require('jquery'), 7 var $ = require('jquery'),
8 Swiper = require('yoho.iswiper'), 8 Swiper = require('yoho.iswiper'),
  9 + Hammer = require('hammer'),
9 lazyLoad = require('yoho.lazyload'); 10 lazyLoad = require('yoho.lazyload');
10 11
11 var swiper; 12 var swiper;
@@ -14,9 +15,10 @@ var filter = require('../../plugin/filter'); @@ -14,9 +15,10 @@ var filter = require('../../plugin/filter');
14 var loading = require('../../plugin/loading'); 15 var loading = require('../../plugin/loading');
15 16
16 var $goodsContainer = $('#goods-container'), 17 var $goodsContainer = $('#goods-container'),
17 - $ngc = $($goodsContainer.children().get(0)),  
18 - $pgc = $($goodsContainer.children().get(1)),  
19 - $dgc = $($goodsContainer.children().get(2)); 18 + $goodsChildren = $goodsContainer.children(),
  19 + $ngc = $($goodsChildren.get(0)),
  20 + $pgc = $($goodsChildren.get(1)),
  21 + $dgc = $($goodsChildren.get(2));
20 22
21 var winH = $(window).height(), 23 var winH = $(window).height(),
22 noResult = '<p class="no-result">未找到相关搜索结果</p>'; 24 noResult = '<p class="no-result">未找到相关搜索结果</p>';
@@ -56,6 +58,7 @@ var $listNav = $('#list-nav'), @@ -56,6 +58,7 @@ var $listNav = $('#list-nav'),
56 } 58 }
57 }, 59 },
58 $pre = $listNav.find('.active'), //纪录进入筛选前的active项,初始为选中项 60 $pre = $listNav.find('.active'), //纪录进入筛选前的active项,初始为选中项
  61 + navHammer,
59 searching; 62 searching;
60 63
61 if ($('.swiper-container .swiper-slide').length > 1) { 64 if ($('.swiper-container .swiper-slide').length > 1) {
@@ -82,6 +85,10 @@ function search(opt) { @@ -82,6 +85,10 @@ function search(opt) {
82 nav, navType, 85 nav, navType,
83 page; 86 page;
84 87
  88 + if (searching) {
  89 + return;
  90 + }
  91 +
85 if (opt) { 92 if (opt) {
86 93
87 //筛选项变更则重置reload为true 94 //筛选项变更则重置reload为true
@@ -136,9 +143,6 @@ function search(opt) { @@ -136,9 +143,6 @@ function search(opt) {
136 $.extend(defaultOpt, ext); //扩展筛选项 143 $.extend(defaultOpt, ext); //扩展筛选项
137 } 144 }
138 145
139 - if (searching) {  
140 - return;  
141 - }  
142 146
143 //导航类别 147 //导航类别
144 if ($pre.hasClass('new')) { 148 if ($pre.hasClass('new')) {
@@ -174,7 +178,8 @@ function search(opt) { @@ -174,7 +178,8 @@ function search(opt) {
174 url: '/product/newsale/selectNewSale', 178 url: '/product/newsale/selectNewSale',
175 data: setting, 179 data: setting,
176 success: function(data) { 180 success: function(data) {
177 - var $container; 181 + var $container,
  182 + num;
178 183
179 switch (navType) { 184 switch (navType) {
180 case 'newest': 185 case 'newest':
@@ -197,11 +202,15 @@ function search(opt) { @@ -197,11 +202,15 @@ function search(opt) {
197 } else { 202 } else {
198 if (nav.reload) { 203 if (nav.reload) {
199 $container.html(data); 204 $container.html(data);
  205 + lazyLoad($container.find('.lazy'));
200 } else { 206 } else {
  207 + num = $container.find('.good-info').length;
201 $container.append(data); 208 $container.append(data);
  209 +
  210 + //lazy good-infos who append in
  211 + lazyLoad($container.find('.good-info:gt(' + (num - 1) + ') .lazy'));
202 } 212 }
203 213
204 - lazyLoad($container.find('.lazy'));  
205 } 214 }
206 215
207 nav.reload = false; 216 nav.reload = false;
@@ -214,19 +223,37 @@ function search(opt) { @@ -214,19 +223,37 @@ function search(opt) {
214 223
215 } 224 }
216 225
217 -lazyLoad($('.lazy')); 226 +$.ajax({
  227 + type: 'GET',
  228 + url: '/newArrival/filter',
  229 + data: defaultOpt,
  230 + success: function(data) {
  231 + $goodsContainer.append(data);
218 232
219 -filter.registerCbFn(search); 233 + //初始化filter&注册filter回调
  234 + filter.initFilter({
  235 + fCbFn: search,
  236 + hCbFn: function() {
  237 +
  238 + //切换active状态到$pre上
  239 + $pre.addClass('active');
  240 + $pre.siblings('.filter').removeClass('active');
  241 + },
  242 + missStatus: true
  243 + });
  244 + }
  245 +});
  246 +lazyLoad($('.lazy'));
220 247
221 -// loading.initLoadingMask();  
222 //导航栏点击逻辑说明: 248 //导航栏点击逻辑说明:
223 //1.点击非active项时切换active状态 249 //1.点击非active项时切换active状态
224 //2.价格和折扣active状态时继续点击切换排序 250 //2.价格和折扣active状态时继续点击切换排序
225 //3.筛选无active时点击展开筛选面板 251 //3.筛选无active时点击展开筛选面板
226 //4.筛选有active时点击隐藏筛选面板并恢复点击筛选前active项的active状态 252 //4.筛选有active时点击隐藏筛选面板并恢复点击筛选前active项的active状态
227 //5.当前active为筛选并且点击其他项时,隐藏筛选面板 253 //5.当前active为筛选并且点击其他项时,隐藏筛选面板
228 -$listNav.delegate('li', 'touchstart', function() {  
229 - var $this = $(this), 254 +navHammer = new Hammer($listNav[0]);
  255 +navHammer.on('tap', function(e) {
  256 + var $this = $(e.target).closest('li'),
230 nav, 257 nav,
231 navType, 258 navType,
232 $active; 259 $active;
@@ -6,17 +6,22 @@ @@ -6,17 +6,22 @@
6 6
7 var $ = require('jquery'), 7 var $ = require('jquery'),
8 Swiper = require('yoho.iswiper'), 8 Swiper = require('yoho.iswiper'),
  9 + Hammer = require('hammer'),
9 lazyLoad = require('yoho.lazyload'); 10 lazyLoad = require('yoho.lazyload');
10 11
11 -var swiper; 12 +var swiper,
  13 + $ngc,
  14 + $pgc,
  15 + $dgc;
12 16
13 var filter = require('../../plugin/filter'); 17 var filter = require('../../plugin/filter');
14 var loading = require('../../plugin/loading'); 18 var loading = require('../../plugin/loading');
15 19
16 var $goodsContainer = $('#goods-container'), 20 var $goodsContainer = $('#goods-container'),
17 - $ngc = $($goodsContainer.children().get(0)),  
18 - $pgc = $($goodsContainer.children().get(1)),  
19 - $dgc = $($goodsContainer.children().get(2)); 21 + $goodsChildren = $goodsContainer.children(),
  22 + $ngc = $($goodsChildren.get(0)),
  23 + $pgc = $($goodsChildren.get(1)).addClass('hide'),
  24 + $dgc = $($goodsChildren.get(2)).addClass('hide');
20 25
21 var winH = $(window).height(), 26 var winH = $(window).height(),
22 noResult = '<p class="no-result">未找到相关搜索结果</p>'; 27 noResult = '<p class="no-result">未找到相关搜索结果</p>';
@@ -60,11 +65,9 @@ var $listNav = $('#list-nav'), @@ -60,11 +65,9 @@ var $listNav = $('#list-nav'),
60 } 65 }
61 }, 66 },
62 $pre = $listNav.find('.active'), //纪录进入筛选前的active项,初始为选中项 67 $pre = $listNav.find('.active'), //纪录进入筛选前的active项,初始为选中项
  68 + navHammer,
63 searching; 69 searching;
64 70
65 -$pgc.addClass('hide');  
66 -$dgc.addClass('hide');  
67 -  
68 $('#today a').text(month + '月' + date + '号'); 71 $('#today a').text(month + '月' + date + '号');
69 72
70 if ($('.swiper-container .swiper-slide').length > 1) { 73 if ($('.swiper-container .swiper-slide').length > 1) {
@@ -92,6 +95,10 @@ function search(opt) { @@ -92,6 +95,10 @@ function search(opt) {
92 dayLimit, 95 dayLimit,
93 page; 96 page;
94 97
  98 + if (searching) {
  99 + return;
  100 + }
  101 +
95 if (opt) { 102 if (opt) {
96 103
97 //筛选项变更则重置reload为true 104 //筛选项变更则重置reload为true
@@ -161,10 +168,6 @@ function search(opt) { @@ -161,10 +168,6 @@ function search(opt) {
161 $.extend(defaultOpt, ext); //扩展筛选项 168 $.extend(defaultOpt, ext); //扩展筛选项
162 } 169 }
163 170
164 - if (searching) {  
165 - return;  
166 - }  
167 -  
168 //导航类别 171 //导航类别
169 if ($pre.hasClass('today')) { 172 if ($pre.hasClass('today')) {
170 navType = 'today'; 173 navType = 'today';
@@ -201,7 +204,8 @@ function search(opt) { @@ -201,7 +204,8 @@ function search(opt) {
201 url: '/product/newsale/selectNewSale', 204 url: '/product/newsale/selectNewSale',
202 data: setting, 205 data: setting,
203 success: function(data) { 206 success: function(data) {
204 - var $container; 207 + var $container,
  208 + num;
205 209
206 switch (navType) { 210 switch (navType) {
207 case 'today': 211 case 'today':
@@ -224,11 +228,15 @@ function search(opt) { @@ -224,11 +228,15 @@ function search(opt) {
224 } else { 228 } else {
225 if (nav.reload) { 229 if (nav.reload) {
226 $container.html(data); 230 $container.html(data);
  231 + lazyLoad($container.find('.lazy'));
227 } else { 232 } else {
  233 + num = $container.find('.good-info').length;
228 $container.append(data); 234 $container.append(data);
  235 +
  236 + //lazy good-infos who append in
  237 + lazyLoad($container.find('.good-info:gt(' + (num - 1) + ') .lazy'));
229 } 238 }
230 239
231 - lazyLoad($container.find('.lazy'));  
232 } 240 }
233 241
234 nav.reload = false; 242 nav.reload = false;
@@ -241,9 +249,27 @@ function search(opt) { @@ -241,9 +249,27 @@ function search(opt) {
241 249
242 } 250 }
243 251
244 -lazyLoad($('.lazy')); 252 +$.ajax({
  253 + type: 'GET',
  254 + url: '/product/newsale/filter',
  255 + data: defaultOpt,
  256 + success: function(data) {
  257 + $goodsContainer.append(data);
245 258
246 -filter.registerCbFn(search); 259 + //初始化filter&注册filter回调
  260 + filter.initFilter({
  261 + fCbFn: search,
  262 + hCbFn: function() {
  263 +
  264 + //切换active状态到$pre上
  265 + $pre.addClass('active');
  266 + $pre.siblings('.filter').removeClass('active');
  267 + },
  268 + missStatus: true
  269 + });
  270 + }
  271 +});
  272 +lazyLoad($('.lazy'));
247 273
248 //导航栏点击逻辑说明: 274 //导航栏点击逻辑说明:
249 //1.点击非active项时切换active状态 275 //1.点击非active项时切换active状态
@@ -251,9 +277,9 @@ filter.registerCbFn(search); @@ -251,9 +277,9 @@ filter.registerCbFn(search);
251 //3.筛选无active时点击展开筛选面板 277 //3.筛选无active时点击展开筛选面板
252 //4.筛选有active时点击隐藏筛选面板并恢复点击筛选前active项的active状态 278 //4.筛选有active时点击隐藏筛选面板并恢复点击筛选前active项的active状态
253 //5.当前active为筛选并且点击其他项时,隐藏筛选面板 279 //5.当前active为筛选并且点击其他项时,隐藏筛选面板
254 -  
255 -$listNav.delegate('li', 'touchstart', function() {  
256 - var $this = $(this), 280 +navHammer = new Hammer($listNav[0]);
  281 +navHammer.on('tap', function(e) {
  282 + var $this = $(e.target).closest('li'),
257 nav, 283 nav,
258 navType, 284 navType,
259 $active; 285 $active;