Authored by Rock Zhang

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

... ... @@ -4,8 +4,7 @@
* @date: 2015/10/10
*/
var $ = require('jquery'),
Swiper = require('yoho.iswiper');
var $ = require('jquery');
var info = require('./info'),
loadMore = info.loadMore;
... ... @@ -24,18 +23,12 @@ var $infoList = $('#info-list'),
var state = {};
var mySwiper;
if ($loadMoreInfo.length > 0) {
$loading = $loadMoreInfo.children('.loading');
$noMore = $loadMoreInfo.children('.no-more');
}
mySwiper = new Swiper('.swiper-container', {
lazyLoading: true,
pagination: '.swiper-pagination',
autoplay: 3000
});
info.initSwiper(curType);
info.initInfosEvt($infoList);
... ... @@ -86,9 +79,8 @@ $nav.on('touchend touchcancel', function(e) {
$loading.addClass('hide');
$noMore.addClass('hide');
loadMore($content, $.extend({
isTab: true
}, state[curType]));
state[curType].isTab = true;
loadMore($content, state[curType]);
} else {
//重置当前Tab的load-more
... ...
... ... @@ -7,16 +7,19 @@
var $ = require('jquery'),
Hammer = require('yoho.hammer'),
ellipsis = require('mlellipsis'),
lazyLoad = require('yoho.lazyload');
lazyLoad = require('yoho.lazyload'),
Swiper = require('yoho.iswiper');
var tip = require('../plugin/tip');
var loading = require('../plugin/loading');
var $loadMoreInfo = $('#load-more-info');
var $loading = $(''),
$noMore = $('');
$noMore = $(''),
$swiper = $('');
var searching = false;
var mySwiper = {};
ellipsis.init();
... ... @@ -25,6 +28,19 @@ if ($loadMoreInfo.length > 0) {
$noMore = $loadMoreInfo.children('.no-more');
}
//初始化swiper
function initSwiper(typeId) {
if (typeof typeId === undefined) {
return;
}
mySwiper[typeId] = new Swiper('.swiper-cont-' + typeId, {
lazyLoading: true,
wrapperClass: 'swiper-wrap-' + typeId,
pagination: '.swiper-pagi-' + typeId,
autoplay: 3000
});
}
/**
* 设置指定资讯项的Lazyload和文字截取
* @params $infos 资讯项
... ... @@ -175,6 +191,14 @@ function loadMore($container, opt, url) {
$container.append(data);
$swiper = $container.find('.swiper-container');
if ($swiper.length) {
$swiper.addClass('swiper-cont-' + opt.type);
$swiper.children('.swiper-wrapper').addClass('swiper-wrap-' + opt.type);
$swiper.children('.swiper-pagination').addClass('swiper-pagi-' + opt.type);
initSwiper(opt.type);
}
if (num > 0) {
$newItems = $container.find('.guang-info:gt(' + (num - 1) + ')');
} else {
... ... @@ -194,14 +218,19 @@ function loadMore($container, opt, url) {
opt.page++;
searching = false;
delete opt.isTab;
},
error: function() {
tip.show('网络断开连接了~');
searching = false;
delete opt.isTab;
}
});
}
exports.mySwiper = mySwiper;
exports.initSwiper = initSwiper;
exports.initInfosEvt = initInfosEvt;
exports.setLazyLoadAndMellipsis = setLazyLoadAndMellipsis;
exports.loadMore = loadMore;
\ No newline at end of file
... ...
{{> guang/home}}
\ No newline at end of file
... ... @@ -9,8 +9,32 @@
</li>
{{/ navs}}
</ul>
<div class="guang-item-content">
{{> guang/home}}
<div id="info-list" class="info-list-container">
{{# infos}}
<div class="info-list{{^show}} hide{{/show}}">
{{#if show}}
{{#if ../swiper}}
<div class="swiper-container swiper-cont-{{@index}}">
<div class="swiper-wrapper swiper-wrap-{{@index}}">
{{# swiper}}
<div class="swiper-slide">
<a href="{{url}}">
<img class="swiper-lazy" data-src="{{img}}">
</a>
<div class="swiper-lazy-preloader"></div>
</div>
{{/ swiper}}
</div>
<div class="swiper-pagination swiper-pagi-{{@index}}"></div>
</div>
{{/if}}
{{/if}}
{{# info}}
{{> guang/info}}
{{/ info}}
</div>
{{/ infos}}
</div>
<div id="load-more-info" class="load-more-info">
... ...
{{#if swiper}}
<div class="swiper-container">
<div class="swiper-wrapper">
{{# swiper}}
<div class="swiper-slide">
<a href="{{url}}">
<img class="swiper-lazy" data-src="{{img}}">
</a>
<div class="swiper-lazy-preloader"></div>
</div>
{{/ swiper}}
</div>
<div class="swiper-pagination"></div>
</div>
{{/if}}
{{# infos}}
{{> guang/info}}
{{/ infos}}
\ No newline at end of file
... ...
{{#if swiper}}
<div class="swiper-container">
<div class="swiper-wrapper">
{{# swiper}}
<div class="swiper-slide">
<a href="{{url}}">
<img class="swiper-lazy" data-src="{{img}}">
</a>
<div class="swiper-lazy-preloader"></div>
</div>
{{/ swiper}}
</div>
<div class="swiper-pagination"></div>
</div>
{{/if}}
<div id="info-list" class="info-list-container">
{{# infos}}
<div class="info-list{{^show}} hide{{/show}}">
{{# info}}
{{> guang/info}}
{{/ info}}
</div>
{{/ infos}}
</div>
\ No newline at end of file