Merge branch 'release/4.4' of http://git.dev.yoho.cn/web/yohobuywap into release/4.4
Showing
1 changed file
with
77 additions
and
103 deletions
@@ -48,13 +48,13 @@ var $listNav = $('#list-nav'), | @@ -48,13 +48,13 @@ var $listNav = $('#list-nav'), | ||
48 | new: { | 48 | new: { |
49 | order: 1, | 49 | order: 1, |
50 | reload: true, | 50 | reload: true, |
51 | - page: 0, | 51 | + page: 1, |
52 | end: false | 52 | end: false |
53 | }, | 53 | }, |
54 | hot: { | 54 | hot: { |
55 | order: 1, | 55 | order: 1, |
56 | reload: true, | 56 | reload: true, |
57 | - page: 0, | 57 | + page: 1, |
58 | end: false | 58 | end: false |
59 | }, | 59 | }, |
60 | newest: { | 60 | newest: { |
@@ -80,7 +80,7 @@ var $listNav = $('#list-nav'), | @@ -80,7 +80,7 @@ var $listNav = $('#list-nav'), | ||
80 | searching; | 80 | searching; |
81 | 81 | ||
82 | var viewType = 1; // 1-首页,2-上新,3-人气 | 82 | var viewType = 1; // 1-首页,2-上新,3-人气 |
83 | - | 83 | +lazyLoad($('img.lazy')); |
84 | //焦点效果 | 84 | //焦点效果 |
85 | if ($('.banner-swiper').find('li').size() > 1) { | 85 | if ($('.banner-swiper').find('li').size() > 1) { |
86 | bannerSwiper = new Swiper('.banner-swiper', { | 86 | bannerSwiper = new Swiper('.banner-swiper', { |
@@ -96,7 +96,7 @@ if ($('.banner-swiper').find('li').size() > 1) { | @@ -96,7 +96,7 @@ if ($('.banner-swiper').find('li').size() > 1) { | ||
96 | } | 96 | } |
97 | 97 | ||
98 | if ($('.multi-browse').find('li').size() > 1) { | 98 | if ($('.multi-browse').find('li').size() > 1) { |
99 | - multiSwiper = new Swiper('.multi-browse', { | 99 | + multiSwiper = new Swiper('.multi-browse', { |
100 | lazyLoading: true, | 100 | lazyLoading: true, |
101 | lazyLoadingInPrevNext: true, | 101 | lazyLoadingInPrevNext: true, |
102 | lazyLoadingOnTransitionStart: true, | 102 | lazyLoadingOnTransitionStart: true, |
@@ -117,7 +117,7 @@ function getPageGoods(info) { | @@ -117,7 +117,7 @@ function getPageGoods(info) { | ||
117 | url: info.url, | 117 | url: info.url, |
118 | data: info.data, | 118 | data: info.data, |
119 | success: function(data) { | 119 | success: function(data) { |
120 | - info.callBack(data); | 120 | + info.callBack(data); |
121 | }, | 121 | }, |
122 | error: function() { | 122 | error: function() { |
123 | alert('网络断开连接了~'); | 123 | alert('网络断开连接了~'); |
@@ -133,21 +133,19 @@ function newData(callback) { | @@ -133,21 +133,19 @@ function newData(callback) { | ||
133 | req.data = { | 133 | req.data = { |
134 | type: 'newest', | 134 | type: 'newest', |
135 | order: '1', | 135 | order: '1', |
136 | - page: '1', | 136 | + page: navInfo.new.page, |
137 | shop_id: $shopId | 137 | shop_id: $shopId |
138 | - | ||
139 | }; | 138 | }; |
140 | req.callBack = function(data) { | 139 | req.callBack = function(data) { |
141 | $('#new-arrival').append(data); | 140 | $('#new-arrival').append(data); |
142 | navInfo.new.page++; | 141 | navInfo.new.page++; |
143 | myScroll.refresh(); | 142 | myScroll.refresh(); |
144 | - lazyLoad($('img.lazy')); | ||
145 | - $("#scroller").trigger('scroll'); | 143 | + lazyLoad($('#new-arrival .lazy')); |
146 | scH = $('#scroller').outerHeight(); | 144 | scH = $('#scroller').outerHeight(); |
147 | searching = false; | 145 | searching = false; |
148 | callback && $.isFunction(callback) && callback(); | 146 | callback && $.isFunction(callback) && callback(); |
149 | - } | ||
150 | - getPageGoods(req); | 147 | + }; |
148 | + getPageGoods(req); | ||
151 | } | 149 | } |
152 | 150 | ||
153 | function hotData(callback) { | 151 | function hotData(callback) { |
@@ -157,19 +155,18 @@ function hotData(callback) { | @@ -157,19 +155,18 @@ function hotData(callback) { | ||
157 | req.data = { | 155 | req.data = { |
158 | type: 'sales', | 156 | type: 'sales', |
159 | order: '1', | 157 | order: '1', |
160 | - page: '1', | 158 | + page: navInfo.hot.page, |
161 | shop_id: $shopId | 159 | shop_id: $shopId |
162 | }; | 160 | }; |
163 | req.callBack = function(data) { | 161 | req.callBack = function(data) { |
164 | $('#popularity').append(data); | 162 | $('#popularity').append(data); |
165 | navInfo.hot.page++; | 163 | navInfo.hot.page++; |
166 | myScroll.refresh(); | 164 | myScroll.refresh(); |
167 | - lazyLoad($('img.lazy')); | ||
168 | - $("#scroller").trigger('scroll'); | 165 | + lazyLoad($('#popularity .lazy')); |
169 | scH = $('#scroller').outerHeight(); | 166 | scH = $('#scroller').outerHeight(); |
170 | searching = false; | 167 | searching = false; |
171 | callback && $.isFunction(callback) && callback(); | 168 | callback && $.isFunction(callback) && callback(); |
172 | - } | 169 | + }; |
173 | getPageGoods(req); | 170 | getPageGoods(req); |
174 | } | 171 | } |
175 | 172 | ||
@@ -192,71 +189,64 @@ $.jqtab = function(nav, posNav, main) { | @@ -192,71 +189,64 @@ $.jqtab = function(nav, posNav, main) { | ||
192 | activeTab = $(this).attr('tab'); | 189 | activeTab = $(this).attr('tab'); |
193 | 190 | ||
194 | $nav1.removeClass('fixed-top'); | 191 | $nav1.removeClass('fixed-top'); |
195 | - | ||
196 | tabChange($(nav + ' li'), index); | 192 | tabChange($(nav + ' li'), index); |
197 | tabChange($(posNav + ' li'), index); | 193 | tabChange($(posNav + ' li'), index); |
198 | - | ||
199 | $(main).hide(); | 194 | $(main).hide(); |
200 | $('#' + activeTab).fadeIn(); | 195 | $('#' + activeTab).fadeIn(); |
201 | - | ||
202 | - if(activeTab === 'new-arrival'){ | 196 | + if (activeTab === 'new-arrival') { |
203 | newData(); | 197 | newData(); |
204 | viewType = 2; | 198 | viewType = 2; |
205 | - } else if(activeTab === 'popularity'){ | 199 | + } else if (activeTab === 'popularity') { |
206 | hotData(); | 200 | hotData(); |
207 | - viewType = 2; | 201 | + viewType = 3; |
208 | } else if (activeTab === 'home-page') { | 202 | } else if (activeTab === 'home-page') { |
203 | + | ||
209 | myScroll && myScroll.refresh(); | 204 | myScroll && myScroll.refresh(); |
210 | scH = $('#scroller').outerHeight(); | 205 | scH = $('#scroller').outerHeight(); |
211 | $nav1.removeClass('fixed-top'); | 206 | $nav1.removeClass('fixed-top'); |
212 | $nav1.removeClass('absolute'); | 207 | $nav1.removeClass('absolute'); |
213 | - | ||
214 | $nav2.removeClass('fixed-top'); | 208 | $nav2.removeClass('fixed-top'); |
215 | $nav2.removeClass('absolute'); | 209 | $nav2.removeClass('absolute'); |
216 | } | 210 | } |
217 | - | ||
218 | - myScroll.scrollTo(0,0); | 211 | + myScroll.scrollTo(0, 0); |
219 | $nav1.addClass('hide'); | 212 | $nav1.addClass('hide'); |
220 | 213 | ||
221 | return false; | 214 | return false; |
222 | }); | 215 | }); |
223 | }; | 216 | }; |
224 | -$.jqtab('#nav','#pos-nav','.main'); | ||
225 | - | 217 | +$.jqtab('#nav', '#pos-nav', '.main'); |
226 | $('#wrapper').addClass('scroll-wrapper'); | 218 | $('#wrapper').addClass('scroll-wrapper'); |
227 | -lazyLoad($('img.lazy')); | ||
228 | - | 219 | +// lazyLoad($('img.lazy')); |
229 | 220 | ||
230 | myScroll = new IScroll('#wrapper', { | 221 | myScroll = new IScroll('#wrapper', { |
231 | probeType: 3, | 222 | probeType: 3, |
232 | - mouseWheel: true, | 223 | + mouseWheel: true, |
233 | click: true | 224 | click: true |
234 | }); | 225 | }); |
235 | - | ||
236 | myScroll.on('scroll', function() { | 226 | myScroll.on('scroll', function() { |
237 | - sTop = -this.y; | 227 | + var scrollCall, |
228 | + sTop = -this.y; | ||
238 | 229 | ||
239 | if (sTop + winH * 2 > scH) { | 230 | if (sTop + winH * 2 > scH) { |
240 | - switch(viewType) { | 231 | + switch (viewType) { |
241 | case 2: | 232 | case 2: |
242 | - var scrollCall = function() { | 233 | + scrollCall = function() { |
243 | $nav1.css({ | 234 | $nav1.css({ |
244 | - transform: 'translate(0, ' + (- scH) + 'px)' | 235 | + transform: 'translate(0, ' + (-scH) + 'px)' |
245 | }); | 236 | }); |
246 | - } | ||
247 | - newData(scrollCall); | 237 | + }; |
238 | + newData(scrollCall); | ||
248 | break; | 239 | break; |
249 | case 3: | 240 | case 3: |
250 | - var scrollCall = function() { | 241 | + scrollCall = function() { |
251 | $nav1.css({ | 242 | $nav1.css({ |
252 | - transform: 'translate(0, ' + (- scH) + 'px)' | 243 | + transform: 'translate(0, ' + (-scH) + 'px)' |
253 | }); | 244 | }); |
254 | - } | 245 | + }; |
255 | hotData(scrollCall); | 246 | hotData(scrollCall); |
256 | break; | 247 | break; |
257 | } | 248 | } |
258 | } | 249 | } |
259 | - | ||
260 | if (sTop < imgH) { | 250 | if (sTop < imgH) { |
261 | if (!$nav1.hasClass('hide')) { | 251 | if (!$nav1.hasClass('hide')) { |
262 | $nav1.addClass('hide'); | 252 | $nav1.addClass('hide'); |
@@ -277,20 +267,19 @@ myScroll.on('scroll', function() { | @@ -277,20 +267,19 @@ myScroll.on('scroll', function() { | ||
277 | $nav1.addClass('fixed-top') | 267 | $nav1.addClass('fixed-top') |
278 | .removeClass('absolute') | 268 | .removeClass('absolute') |
279 | .css({ | 269 | .css({ |
280 | - transform: 'translate(0, ' + (- scH) + 'px)' | 270 | + transform: 'translate(0, ' + (-scH) + 'px)' |
281 | }); | 271 | }); |
282 | } | 272 | } |
283 | } else if (sTop < imgH + nav1H + main1H) { | 273 | } else if (sTop < imgH + nav1H + main1H) { |
284 | if ($('#home-page').is(':hidden')) { | 274 | if ($('#home-page').is(':hidden')) { |
285 | return false; | 275 | return false; |
286 | } | 276 | } |
287 | - | ||
288 | if (!$nav1.hasClass('absolute')) { | 277 | if (!$nav1.hasClass('absolute')) { |
289 | $nav1.addClass('absolute') | 278 | $nav1.addClass('absolute') |
290 | .removeClass('fixed-top'); | 279 | .removeClass('fixed-top'); |
291 | } | 280 | } |
292 | $nav1.css({ | 281 | $nav1.css({ |
293 | - transform: 'translate(0, ' + (imgH + main1H - sTop - scH) + 'px)' | 282 | + transform: 'translate(0, ' + (imgH + main1H - sTop - scH) + 'px)' |
294 | }); | 283 | }); |
295 | } | 284 | } |
296 | } else { | 285 | } else { |
@@ -310,12 +299,12 @@ myScroll.on('scroll', function() { | @@ -310,12 +299,12 @@ myScroll.on('scroll', function() { | ||
310 | $nav2.addClass('fixed-top') | 299 | $nav2.addClass('fixed-top') |
311 | .removeClass('absolute') | 300 | .removeClass('absolute') |
312 | .css({ | 301 | .css({ |
313 | - transform: 'translate(0, ' + (- scH) + 'px)' | 302 | + transform: 'translate(0, ' + (-scH) + 'px)' |
314 | }); | 303 | }); |
315 | } | 304 | } |
316 | } | 305 | } |
317 | } | 306 | } |
318 | - $("#scroller").trigger('scroll'); | 307 | + $('#scroller').trigger('scroll'); |
319 | }); | 308 | }); |
320 | 309 | ||
321 | 310 | ||
@@ -338,9 +327,9 @@ $(window).load(function() { | @@ -338,9 +327,9 @@ $(window).load(function() { | ||
338 | main1oH = $('#nav-main').outerHeight(); | 327 | main1oH = $('#nav-main').outerHeight(); |
339 | nav2H = $('#list-nav').outerHeight(); | 328 | nav2H = $('#list-nav').outerHeight(); |
340 | main2oH = $('#goods-container').outerHeight(); | 329 | main2oH = $('#goods-container').outerHeight(); |
341 | - setTimeout(function(){ | 330 | + setTimeout(function() { |
342 | scH = $('#scroller').outerHeight(); | 331 | scH = $('#scroller').outerHeight(); |
343 | - },1000); | 332 | + }, 1000); |
344 | }); | 333 | }); |
345 | 334 | ||
346 | 335 | ||
@@ -365,7 +354,7 @@ function search(opt) { | @@ -365,7 +354,7 @@ function search(opt) { | ||
365 | } | 354 | } |
366 | 355 | ||
367 | switch (opt.type) { | 356 | switch (opt.type) { |
368 | - case 'shop_id': | 357 | + case 'shop_id': |
369 | ext = { | 358 | ext = { |
370 | shop_id: opt.id | 359 | shop_id: opt.id |
371 | }; | 360 | }; |
@@ -430,7 +419,7 @@ function search(opt) { | @@ -430,7 +419,7 @@ function search(opt) { | ||
430 | //不需要重新加载并且数据请求结束 | 419 | //不需要重新加载并且数据请求结束 |
431 | return; | 420 | return; |
432 | } | 421 | } |
433 | - | 422 | + console.log(page) |
434 | $.extend(setting, defaultOpt, { | 423 | $.extend(setting, defaultOpt, { |
435 | type: navType, | 424 | type: navType, |
436 | order: nav.order, | 425 | order: nav.order, |
@@ -487,13 +476,11 @@ function search(opt) { | @@ -487,13 +476,11 @@ function search(opt) { | ||
487 | 476 | ||
488 | window.rePosFooter(); | 477 | window.rePosFooter(); |
489 | 478 | ||
490 | - setTimeout(function () { | 479 | + setTimeout(function() { |
491 | myScroll.refresh(); | 480 | myScroll.refresh(); |
492 | scH = $('#scroller').outerHeight(); | 481 | scH = $('#scroller').outerHeight(); |
493 | }, 1000); | 482 | }, 1000); |
494 | - | ||
495 | - | ||
496 | - }, | 483 | + }, |
497 | error: function() { | 484 | error: function() { |
498 | tip.show('网络断开连接了~'); | 485 | tip.show('网络断开连接了~'); |
499 | searching = false; | 486 | searching = false; |
@@ -509,12 +496,10 @@ $.ajax({ | @@ -509,12 +496,10 @@ $.ajax({ | ||
509 | success: function(data) { | 496 | success: function(data) { |
510 | $goodsContainer.append(data); | 497 | $goodsContainer.append(data); |
511 | 498 | ||
512 | - setTimeout(function () { | ||
513 | - myScroll.refresh(); | ||
514 | - scH = $('#scroller').outerHeight(); | ||
515 | - }, 1000); | ||
516 | - | ||
517 | - | 499 | + setTimeout(function() { |
500 | + myScroll.refresh(); | ||
501 | + scH = $('#scroller').outerHeight(); | ||
502 | + }, 1000); | ||
518 | 503 | ||
519 | //初始化filter&注册filter回调 | 504 | //初始化filter&注册filter回调 |
520 | filter.initFilter({ | 505 | filter.initFilter({ |
@@ -644,17 +629,16 @@ $subNav.on('touchend touchcancel', function(e) { | @@ -644,17 +629,16 @@ $subNav.on('touchend touchcancel', function(e) { | ||
644 | 629 | ||
645 | 630 | ||
646 | function scrollHandler() { | 631 | function scrollHandler() { |
647 | - | 632 | + |
648 | //当scroll到1/4$goodsContainer高度后继续请求下一页数据 | 633 | //当scroll到1/4$goodsContainer高度后继续请求下一页数据 |
649 | myScroll && myScroll.refresh(); | 634 | myScroll && myScroll.refresh(); |
650 | - | ||
651 | - if (sTop + winH > $('#scroller').height() - 0.25 * $goodsContainer.height() - 50){ | 635 | + if (sTop + winH > $('#scroller').height() - 0.25 * $goodsContainer.height() - 50) { |
652 | if ($pre !== undefined) { | 636 | if ($pre !== undefined) { |
653 | search({ | 637 | search({ |
654 | type: 'shop_id', | 638 | type: 'shop_id', |
655 | id: $shopId, | 639 | id: $shopId, |
656 | url: '/index/search/search' | 640 | url: '/index/search/search' |
657 | - }); | 641 | + }); |
658 | } | 642 | } |
659 | } | 643 | } |
660 | } | 644 | } |
@@ -669,59 +653,50 @@ search({ | @@ -669,59 +653,50 @@ search({ | ||
669 | type: 'shop_id', | 653 | type: 'shop_id', |
670 | id: $shopId, | 654 | id: $shopId, |
671 | url: '/index/search/search' | 655 | url: '/index/search/search' |
672 | - } | ||
673 | -); | 656 | +}); |
674 | 657 | ||
675 | $listNav.on('touchstart', 'li', function(e) { | 658 | $listNav.on('touchstart', 'li', function(e) { |
676 | $(this).addClass('bytouch'); | 659 | $(this).addClass('bytouch'); |
677 | }).on('touchend touchcancel', function() { | 660 | }).on('touchend touchcancel', function() { |
678 | $listNav.find('li').removeClass('bytouch'); | 661 | $listNav.find('li').removeClass('bytouch'); |
679 | myScroll.refresh(); | 662 | myScroll.refresh(); |
680 | - | ||
681 | - if (sTop > imgH + nav1H + main1oH) { | ||
682 | - myScroll.scrollTo(0,-(imgH + nav1H + main1oH + 10)); | ||
683 | - } | ||
684 | -}); | 663 | + }); |
685 | 664 | ||
686 | $posList.on('touchstart', 'li', function(e) { | 665 | $posList.on('touchstart', 'li', function(e) { |
687 | $(this).addClass('bytouch'); | 666 | $(this).addClass('bytouch'); |
688 | }).on('touchend touchcancel', function() { | 667 | }).on('touchend touchcancel', function() { |
689 | $posList.find('li').removeClass('bytouch'); | 668 | $posList.find('li').removeClass('bytouch'); |
690 | - myScroll.refresh(); | ||
691 | - | ||
692 | - if (sTop > imgH + nav1H + main1oH) { | ||
693 | - myScroll.scrollTo(0,-(imgH + nav1H + main1oH + 10)); | ||
694 | - } | 669 | + myScroll.refresh(); |
670 | + myScroll.scrollTo(0, -(imgH + nav1H + main1oH + 5)); | ||
695 | }); | 671 | }); |
696 | 672 | ||
697 | - | ||
698 | - | ||
699 | //底部导航点击 | 673 | //底部导航点击 |
700 | function fotterClick(group) { | 674 | function fotterClick(group) { |
701 | - $(group + ' li').on('touchstart', function() { | ||
702 | - $('.sub-group').addClass('hide'); | ||
703 | - if ($(this).find('.sub-group').length > 0){ | ||
704 | - $(this).find('.sub-group').removeClass('hide'); | ||
705 | - } | ||
706 | - }); | ||
707 | -}; | 675 | + $(group + ' li').on('touchstart', function() { |
676 | + $('.sub-group').addClass('hide'); | ||
677 | + if ($(this).find('.sub-group').length > 0) { | ||
678 | + $(this).find('.sub-group').removeClass('hide'); | ||
679 | + } | ||
680 | + }); | ||
681 | +} | ||
708 | 682 | ||
709 | fotterClick('.shop-foot-wrapper'); | 683 | fotterClick('.shop-foot-wrapper'); |
710 | 684 | ||
711 | -function stopPropagation(e) { | ||
712 | - if (e.stopPropagation){ | ||
713 | - e.stopPropagation(); | ||
714 | - }else { | ||
715 | - e.cancelBubble = true; } | ||
716 | -} | 685 | +function stopPropagation(e) { |
686 | + if (e.stopPropagation) { | ||
687 | + e.stopPropagation(); | ||
688 | + } else { | ||
689 | + e.cancelBubble = true; | ||
690 | + } | ||
691 | +} | ||
717 | 692 | ||
718 | -$(document).bind('touchstart', function(){ | ||
719 | - $('.sub-group').addClass('hide'); | ||
720 | -}); | 693 | +$(document).bind('touchstart', function() { |
694 | + $('.sub-group').addClass('hide'); | ||
695 | +}); | ||
721 | 696 | ||
722 | -$('.shop-foot-wrapper').bind('touchstart',function(e){ | ||
723 | - stopPropagation(e); | ||
724 | -}); | 697 | +$('.shop-foot-wrapper').bind('touchstart', function(e) { |
698 | + stopPropagation(e); | ||
699 | +}); | ||
725 | 700 | ||
726 | //收藏 | 701 | //收藏 |
727 | function postCollect(info) { | 702 | function postCollect(info) { |
@@ -739,10 +714,10 @@ function postCollect(info) { | @@ -739,10 +714,10 @@ function postCollect(info) { | ||
739 | 714 | ||
740 | success: function(data) { | 715 | success: function(data) { |
741 | 716 | ||
742 | - if (data.code === 200){ | 717 | + if (data.code === 200) { |
743 | if ($('#collect').hasClass('alreadyCollect')) { | 718 | if ($('#collect').hasClass('alreadyCollect')) { |
744 | $('#collect').attr('class', 'notCollect'); | 719 | $('#collect').attr('class', 'notCollect'); |
745 | - }else{ | 720 | + } else { |
746 | $('#collect').attr('class', 'alreadyCollect'); | 721 | $('#collect').attr('class', 'alreadyCollect'); |
747 | } | 722 | } |
748 | } | 723 | } |
@@ -754,11 +729,10 @@ function postCollect(info) { | @@ -754,11 +729,10 @@ function postCollect(info) { | ||
754 | $('.jump-login').click(); | 729 | $('.jump-login').click(); |
755 | } | 730 | } |
756 | 731 | ||
757 | - setTimeout(function () { | 732 | + setTimeout(function() { |
758 | myScroll.refresh(); | 733 | myScroll.refresh(); |
759 | scH = $('#scroller').outerHeight(); | 734 | scH = $('#scroller').outerHeight(); |
760 | }, 1000); | 735 | }, 1000); |
761 | - | ||
762 | searching = false; | 736 | searching = false; |
763 | }, | 737 | }, |
764 | error: function() { | 738 | error: function() { |
@@ -792,10 +766,10 @@ function cancelShop() { | @@ -792,10 +766,10 @@ function cancelShop() { | ||
792 | 766 | ||
793 | $('#collect').bind('touchstart', function() { | 767 | $('#collect').bind('touchstart', function() { |
794 | if ($('#collect').hasClass('alreadyCollect')) { | 768 | if ($('#collect').hasClass('alreadyCollect')) { |
795 | - cancelShop(); | ||
796 | - }else{ | 769 | + cancelShop(); |
770 | + } else { | ||
797 | collectShop(); | 771 | collectShop(); |
798 | } | 772 | } |
799 | - }); | 773 | +}); |
800 | 774 | ||
801 | 775 |
-
Please register or login to post a comment