Authored by Rock Zhang

Merge branch 'feature/wap325' of git.dev.yoho.cn:web/yohobuy into feature/wap325

@@ -4,8 +4,7 @@ @@ -4,8 +4,7 @@
4 * @date: 2015/10/10 4 * @date: 2015/10/10
5 */ 5 */
6 6
7 -var $ = require('jquery'),  
8 - Swiper = require('yoho.iswiper'); 7 +var $ = require('jquery');
9 8
10 var info = require('./info'), 9 var info = require('./info'),
11 loadMore = info.loadMore; 10 loadMore = info.loadMore;
@@ -24,18 +23,12 @@ var $infoList = $('#info-list'), @@ -24,18 +23,12 @@ var $infoList = $('#info-list'),
24 23
25 var state = {}; 24 var state = {};
26 25
27 -var mySwiper;  
28 -  
29 if ($loadMoreInfo.length > 0) { 26 if ($loadMoreInfo.length > 0) {
30 $loading = $loadMoreInfo.children('.loading'); 27 $loading = $loadMoreInfo.children('.loading');
31 $noMore = $loadMoreInfo.children('.no-more'); 28 $noMore = $loadMoreInfo.children('.no-more');
32 } 29 }
33 30
34 -mySwiper = new Swiper('.swiper-container', {  
35 - lazyLoading: true,  
36 - pagination: '.swiper-pagination',  
37 - autoplay: 3000  
38 -}); 31 +info.initSwiper(curType);
39 32
40 info.initInfosEvt($infoList); 33 info.initInfosEvt($infoList);
41 34
@@ -86,9 +79,8 @@ $nav.on('touchend touchcancel', function(e) { @@ -86,9 +79,8 @@ $nav.on('touchend touchcancel', function(e) {
86 $loading.addClass('hide'); 79 $loading.addClass('hide');
87 $noMore.addClass('hide'); 80 $noMore.addClass('hide');
88 81
89 - loadMore($content, $.extend({  
90 - isTab: true  
91 - }, state[curType])); 82 + state[curType].isTab = true;
  83 + loadMore($content, state[curType]);
92 } else { 84 } else {
93 85
94 //重置当前Tab的load-more 86 //重置当前Tab的load-more
@@ -7,16 +7,19 @@ @@ -7,16 +7,19 @@
7 var $ = require('jquery'), 7 var $ = require('jquery'),
8 Hammer = require('yoho.hammer'), 8 Hammer = require('yoho.hammer'),
9 ellipsis = require('mlellipsis'), 9 ellipsis = require('mlellipsis'),
10 - lazyLoad = require('yoho.lazyload'); 10 + lazyLoad = require('yoho.lazyload'),
  11 + Swiper = require('yoho.iswiper');
11 12
12 var tip = require('../plugin/tip'); 13 var tip = require('../plugin/tip');
13 var loading = require('../plugin/loading'); 14 var loading = require('../plugin/loading');
14 15
15 var $loadMoreInfo = $('#load-more-info'); 16 var $loadMoreInfo = $('#load-more-info');
16 var $loading = $(''), 17 var $loading = $(''),
17 - $noMore = $(''); 18 + $noMore = $(''),
  19 + $swiper = $('');
18 20
19 var searching = false; 21 var searching = false;
  22 +var mySwiper = {};
20 23
21 ellipsis.init(); 24 ellipsis.init();
22 25
@@ -25,6 +28,19 @@ if ($loadMoreInfo.length > 0) { @@ -25,6 +28,19 @@ if ($loadMoreInfo.length > 0) {
25 $noMore = $loadMoreInfo.children('.no-more'); 28 $noMore = $loadMoreInfo.children('.no-more');
26 } 29 }
27 30
  31 +//初始化swiper
  32 +function initSwiper(typeId) {
  33 + if (typeof typeId === undefined) {
  34 + return;
  35 + }
  36 + mySwiper[typeId] = new Swiper('.swiper-cont-' + typeId, {
  37 + lazyLoading: true,
  38 + wrapperClass: 'swiper-wrap-' + typeId,
  39 + pagination: '.swiper-pagi-' + typeId,
  40 + autoplay: 3000
  41 + });
  42 +}
  43 +
28 /** 44 /**
29 * 设置指定资讯项的Lazyload和文字截取 45 * 设置指定资讯项的Lazyload和文字截取
30 * @params $infos 资讯项 46 * @params $infos 资讯项
@@ -175,6 +191,14 @@ function loadMore($container, opt, url) { @@ -175,6 +191,14 @@ function loadMore($container, opt, url) {
175 191
176 $container.append(data); 192 $container.append(data);
177 193
  194 + $swiper = $container.find('.swiper-container');
  195 + if ($swiper.length) {
  196 + $swiper.addClass('swiper-cont-' + opt.type);
  197 + $swiper.children('.swiper-wrapper').addClass('swiper-wrap-' + opt.type);
  198 + $swiper.children('.swiper-pagination').addClass('swiper-pagi-' + opt.type);
  199 + initSwiper(opt.type);
  200 + }
  201 +
178 if (num > 0) { 202 if (num > 0) {
179 $newItems = $container.find('.guang-info:gt(' + (num - 1) + ')'); 203 $newItems = $container.find('.guang-info:gt(' + (num - 1) + ')');
180 } else { 204 } else {
@@ -194,14 +218,19 @@ function loadMore($container, opt, url) { @@ -194,14 +218,19 @@ function loadMore($container, opt, url) {
194 opt.page++; 218 opt.page++;
195 219
196 searching = false; 220 searching = false;
  221 + delete opt.isTab;
197 }, 222 },
198 error: function() { 223 error: function() {
199 tip.show('网络断开连接了~'); 224 tip.show('网络断开连接了~');
200 searching = false; 225 searching = false;
  226 + delete opt.isTab;
201 } 227 }
202 }); 228 });
203 } 229 }
204 230
  231 +
  232 +exports.mySwiper = mySwiper;
  233 +exports.initSwiper = initSwiper;
205 exports.initInfosEvt = initInfosEvt; 234 exports.initInfosEvt = initInfosEvt;
206 exports.setLazyLoadAndMellipsis = setLazyLoadAndMellipsis; 235 exports.setLazyLoadAndMellipsis = setLazyLoadAndMellipsis;
207 exports.loadMore = loadMore; 236 exports.loadMore = loadMore;
@@ -9,8 +9,32 @@ @@ -9,8 +9,32 @@
9 </li> 9 </li>
10 {{/ navs}} 10 {{/ navs}}
11 </ul> 11 </ul>
12 - <div class="guang-item-content">  
13 - {{> guang/home}} 12 +
  13 + <div id="info-list" class="info-list-container">
  14 + {{# infos}}
  15 + <div class="info-list{{^show}} hide{{/show}}">
  16 + {{#if show}}
  17 + {{#if ../swiper}}
  18 + <div class="swiper-container swiper-cont-{{@index}}">
  19 + <div class="swiper-wrapper swiper-wrap-{{@index}}">
  20 + {{# swiper}}
  21 + <div class="swiper-slide">
  22 + <a href="{{url}}">
  23 + <img class="swiper-lazy" data-src="{{img}}">
  24 + </a>
  25 + <div class="swiper-lazy-preloader"></div>
  26 + </div>
  27 + {{/ swiper}}
  28 + </div>
  29 + <div class="swiper-pagination swiper-pagi-{{@index}}"></div>
  30 + </div>
  31 + {{/if}}
  32 + {{/if}}
  33 + {{# info}}
  34 + {{> guang/info}}
  35 + {{/ info}}
  36 + </div>
  37 + {{/ infos}}
14 </div> 38 </div>
15 39
16 <div id="load-more-info" class="load-more-info"> 40 <div id="load-more-info" class="load-more-info">
  1 +{{#if swiper}}
  2 + <div class="swiper-container">
  3 + <div class="swiper-wrapper">
  4 + {{# swiper}}
  5 + <div class="swiper-slide">
  6 + <a href="{{url}}">
  7 + <img class="swiper-lazy" data-src="{{img}}">
  8 + </a>
  9 + <div class="swiper-lazy-preloader"></div>
  10 + </div>
  11 + {{/ swiper}}
  12 + </div>
  13 + <div class="swiper-pagination"></div>
  14 + </div>
  15 +{{/if}}
  16 +
1 {{# infos}} 17 {{# infos}}
2 {{> guang/info}} 18 {{> guang/info}}
3 {{/ infos}} 19 {{/ infos}}
1 -{{#if swiper}}  
2 - <div class="swiper-container">  
3 - <div class="swiper-wrapper">  
4 - {{# swiper}}  
5 - <div class="swiper-slide">  
6 - <a href="{{url}}">  
7 - <img class="swiper-lazy" data-src="{{img}}">  
8 - </a>  
9 - <div class="swiper-lazy-preloader"></div>  
10 - </div>  
11 - {{/ swiper}}  
12 - </div>  
13 - <div class="swiper-pagination"></div>  
14 - </div>  
15 -{{/if}}  
16 -  
17 -<div id="info-list" class="info-list-container">  
18 - {{# infos}}  
19 - <div class="info-list{{^show}} hide{{/show}}">  
20 - {{# info}}  
21 - {{> guang/info}}  
22 - {{/ info}}  
23 - </div>  
24 - {{/ infos}}  
25 -</div>