Authored by xuqi

guang home loading

... ... @@ -8,7 +8,6 @@ var $ = require('yoho.zepto'),
Swiper = require('yoho.iswiper');
var info = require('./info'),
setLazyLoadAndMellipsis = info.setLazyLoadAndMellipsis,
loadMore = info.loadMore;
var $loadMoreInfo = $('#load-more-info');
... ... @@ -45,10 +44,11 @@ info.initInfosEvt($infoList);
var gender = $('#gender').val();
$nav.children('.guang-nav-item').each(function() {
var type = $(this).data('type');
var type = $(this).data('type'),
focus = $(this).hasClass('focus');
state[type] = {
page: 1,
page: focus ? 1 : 0,
gender: gender,
type: type,
end: false
... ... @@ -65,6 +65,9 @@ $nav.delegate('.guang-nav-item', 'tap', function() {
return;
}
$curNav = $this;
curType = $this.data('type');
index = $this.index();
$this.addClass('focus');
... ... @@ -75,11 +78,7 @@ $nav.delegate('.guang-nav-item', 'tap', function() {
$content = $infos.eq(index);
$content.removeClass('hide');
//lazyload & mellipsis
setLazyLoadAndMellipsis($content.children('.guang-info'));
$curNav = $this;
curType = $this.data('type');
loadMore($content, state[curType]);
//重置当前Tab的load-more
if (state[curType].end) {
... ... @@ -93,6 +92,6 @@ $nav.delegate('.guang-nav-item', 'tap', function() {
$(document).scroll(function() {
if ($(window).scrollTop() + winH >= $(document).height() - loadMoreH) {
loadMore($infos, state[curType]);
loadMore($infos.not('hide'), state[curType]);
}
});
\ No newline at end of file
... ...
... ... @@ -9,12 +9,13 @@ var $ = require('yoho.zepto'),
lazyLoad = require('yoho.zeptolazyload');
var tip = require('../plugin/tip');
var loading = require('../plugin/loading');
var $loadMoreInfo = $('#load-more-info');
var $loading = $(''),
$noMore = $('');
var loading = false;
var searching = false;
ellipsis.init();
... ... @@ -84,7 +85,7 @@ function initInfosEvt($container) {
* 资讯LoadMore
*/
function loadMore($container, opt) {
if (loading) {
if (searching) {
return;
}
... ... @@ -92,7 +93,13 @@ function loadMore($container, opt) {
return;
}
loading = true;
if (opt.page === 0) {
//显示loading
loading.showLoadingMask();
}
searching = true;
$.ajax({
type: 'GET',
url: ' /guang/index/page',
... ... @@ -100,7 +107,7 @@ function loadMore($container, opt) {
success: function(data) {
if (data === ' ') {
opt.end = true;
loading = false;
searching = false;
//
$loading.addClass('hide');
... ... @@ -112,13 +119,17 @@ function loadMore($container, opt) {
setLazyLoadAndMellipsis($container.find('.guang-info'));
if (opt.page === 0) {
loading.hideLoadingMask();
}
opt.page++;
loading = false;
searching = false;
},
error: function() {
tip.show('网络断开连接了~');
loading = false;
searching = false;
}
});
}
... ...