Authored by 梁志锋

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

... ... @@ -11,8 +11,12 @@ var info = require('./info'),
setLazyLoadAndMellipsis = info.setLazyLoadAndMellipsis,
loadMore = info.loadMore;
var $loadMoreInfo = $('#load-more-info');
var $loading = $(''),
$noMore = $('');
var winH = $(window).height(),
loadMoreH = $('#load-more').height();
loadMoreH = $loadMoreInfo.height();
var $infoList = $('#info-list'),
$infos = $infoList.children('.info-list'),
... ... @@ -24,6 +28,11 @@ 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'
... ... @@ -33,13 +42,16 @@ info.initInfosEvt($infoList);
//初始化各Nav下资讯加载的状态
(function() {
var gender = $('#gender').val();
$nav.children('.guang-nav-item').each(function() {
var type = $(this).data('type');
state[type] = {
page: 1,
end: false,
type: type
gender: gender,
type: type,
end: false
};
});
}());
... ... @@ -68,10 +80,19 @@ $nav.delegate('.guang-nav-item', 'touchstart', function() {
$curNav = $this;
curType = $this.data('type');
//重置当前Tab的load-more
if (state[curType].end) {
$loading.addClass('hide');
$noMore.removeClass('hide');
} else {
$loading.removeClass('hide');
$noMore.addClass('hide');
}
});
$(document).scroll(function() {
if ($(window).scrollTop() + winH >= $(document).height() - loadMoreH && !state[curType].end) {
if ($(window).scrollTop() + winH >= $(document).height() - loadMoreH) {
loadMore($infos, state[curType]);
}
});
\ No newline at end of file
... ...
... ... @@ -10,10 +10,19 @@ var $ = require('yoho.zepto'),
var tip = require('../plugin/tip');
var $loadMoreInfo = $('#load-more-info');
var $loading = $(''),
$noMore = $('');
var loading = false;
ellipsis.init();
if ($loadMoreInfo.length > 0) {
$loading = $loadMoreInfo.children('.loading');
$noMore = $loadMoreInfo.children('.no-more');
}
/**
* 设置指定资讯项的Lazyload和文字截取
* @params $infos 资讯项
... ... @@ -43,8 +52,8 @@ function initInfosEvt($container) {
url: '/guang/info/prise', //TODO:cancelPrise
data: {
id: $info.data('id')
}
}).then(function(data) {
},
success: function(data) {
var code = data.code;
if (code === 200) {
... ... @@ -52,8 +61,10 @@ function initInfosEvt($container) {
} else if (code === 400) {
tip.show('未登录');
}
}, function() {
},
error: function() {
tip.show('网络断开连接了~');
}
});
});
... ... @@ -70,30 +81,42 @@ function loadMore($container, opt) {
return;
}
if (opt.end) {
return;
}
loading = true;
$.ajax({
type: 'GET',
url: '/infos/get',
data: opt
}).then(function(data) {
var res,
$newInfos;
type: 'POST',
url: ' /guang/list/page',
data: opt,
success: function(data) {
var $newInfos;
//请求结束
if (data === ' ') {
opt.end = true;
loading = false;
if (data.code === 200) {
res = data.data;
//
$loading.addClass('hide');
$noMore.removeClass('hide');
if (res.end) {
opt.end = true;
return;
}
$container.append(res.infos);
$container.append(data);
$newInfos = $container.find('.guang-info:gt(' + (infosNum - 1) + ')');
setLazyLoadAndMellipsis($newInfos);
opt.page++;
}
loading = false;
},
error: function() {
tip.show('网络断开连接了~');
loading = false;
}
});
}
... ...
... ... @@ -12,6 +12,9 @@ var info = require('./info'),
var winH = $(window).height(),
loadMoreH = $('#load-more').height();
var $author = $('#author-infos');
var $tag = $('#tag');
var setting = {
page: 1,
end: false
... ... @@ -21,11 +24,19 @@ var $infos = $('#info-list');
info.initInfosEvt($infos);
$(document).scroll(function() {
if (setting.end) {
return;
}
if ($author.length > 0) {
$.extend(setting, {
authorId: $author.data('id')
});
}
if ($tag.length > 0) {
$.extend(setting, {
tag: $tag.val()
});
}
$(document).scroll(function() {
if ($(window).scrollTop() + winH >= $(document).height() - loadMoreH) {
loadMore($infos, setting);
}
... ...
... ... @@ -51,6 +51,10 @@ a {
outline: none;
}
.hide {
display: none;
}
@font-face {
font-family: "iconfont";
src: font-url('iconfont.eot'); /* IE9*/
... ...
... ... @@ -51,6 +51,7 @@
</div>
<span class="no-more status hide">没有更多啦</span>
</div>
<input id="gender" type="hidden" value={{gender}}>
{{/ guang}}
</div>
{{> layout/footer}}
\ No newline at end of file
... ...
... ... @@ -25,6 +25,9 @@
</div>
<span class="no-more status hide">没有更多啦</span>
</div>
{{#if tag}}
<input id="tag" type="hidden" value={{tag}}>
{{/if}}
{{/ guang}}
</div>
{{> layout/footer}}
\ No newline at end of file
... ...
{{> layout/page_footer}}
<script src="http://localhost:8000/static/js/sea.js?nowrap"></script>
<script>
{{#if rlsEnv}}
<link rel="stylesheet" href="http://cdn.yoho.cn/myohobuy/{{version}}/lib.js">
<link rel="stylesheet" href="http://cdn.yoho.cn/myohobuy/{{version}}/index.js">
{{/if}}
{{#if rlsEnv}}
{{/if}}
{{#if devEnv}}
<script src="http://localhost:8000/static/js/sea.js?nowrap"></script>
<script>
seajs.config({
base: 'http://localhost:8000/'
});
</script>
</script>
{{/if}}
{{> layout/use}}
</body>
</html>
\ No newline at end of file
... ...
... ... @@ -22,7 +22,17 @@
}());
})(document, window);
</script>
{{#if rlsEnv}}
<link rel="stylesheet" href="http://cdn.yoho.cn/myohobuy/{{version}}/index.css">
{{/if}}
{{#if rlsEnv}}
{{/if}}
{{#if devEnv}}
<link rel="stylesheet" href="http://static.dev.yohobuy.com/css/index.css">
{{/if}}
</head>
<body {{#if isPassportPage}}class=passport-body{{/if}}>
{{> layout/page_header}}
\ No newline at end of file
... ...