Authored by 梁志锋

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

framework @ 75bbc3b0
Subproject commit 119c247f5cf929aa1e059e40609bb16dd6b58f05
Subproject commit 75bbc3b075de19f239532f60c5995d06c5f814e2
... ...
... ... @@ -31,6 +31,12 @@ if (kidsType) {
//srcoll to load more
$(window).scroll(function () {
if ($(window).scrollTop() + winH >= $(document).height() - loadMoreH) {
// 没数据了,就不再加载
if (loading) {
return;
}
loading = true;
num = $goodList.children('.good-info').length;
$.ajax({
... ... @@ -40,6 +46,11 @@ $(window).scroll(function () {
page: page + 1
},
success: function(data) {
if (data === ' ') {
loading = true;
return;
}
$goodList.append(data);
//lazyLoad
... ...
... ... @@ -5,9 +5,16 @@ var $ = require('yoho.zepto'),
var $curNav,
$navList = $('#discount-nav'),
$newArrivalList = $('#discount-goods-list'),
$goods = $newArrivalList.children('.goods-list');
$goods = $newArrivalList.children('.goods-list'),
$goodList = $('.goods-list');
var swiper;
var index = 0,
winH = $(window).height(),
loadMoreH = $('#load-more').height(),
loading = false,
page = 0,
pd = "";
swiper = new Swiper('.swiper-container', {
lazyLoading: true,
... ... @@ -19,14 +26,14 @@ $curNav = $navList.children('.focus');
$('#discount-nav').delegate('li', 'touchstart', function() {
var $this = $(this),
$content,
index;
$content;
if ($this.hasClass('focus')) {
return;
}
index = $this.index();
pd = getSalePdByChoose(index);
$this.addClass('focus');
$curNav.removeClass('focus');
... ... @@ -39,3 +46,69 @@ $('#discount-nav').delegate('li', 'touchstart', function() {
$(document).trigger('scroll'); //Trigger lazyLoad
});
//srcoll to load more
$(window).scroll(function () {
if ($(window).scrollTop() + winH >= $(document).height() - loadMoreH) {
if (loading) {
return;
}
loading = true;
num = $goodList.children('.good-info').length;
$.ajax({
type: 'GET',
url: '/product/newsale/selectNewSale',
data: {
p_d: pd,
page: page + 1
},
success: function(data) {
if (data === ' ') {
//opt.end = true;
loading = false;
return;
}
$goodList.append(data);
//lazyLoad
//lazyLoad($goodList.children('.good-info:gt(' + (num - 1) + ')').find('img.lazy'));
lazyLoad($('.good-info').find('img.lazy'));
loading = false;
page++;
},
error: function() {
tip.show('网络断开连接了~');
loading = false;
}
});
}
});
/**
* 根据用户的选择获取商品折扣值
*
* @param int index
* @return string
*/
function getSalePdByChoose(index) {
var pd = "0.1,0.3";
switch (index) {
case 0:
pd = "0.1,0.3";
break;
case 1:
pd = "0.4,0.6";
break;
case 2:
pd = "0.7,0.9";
break;
case 3:
pd = "0.1,0.9";
break;
}
return pd;
}
\ No newline at end of file
... ...
... ... @@ -59,8 +59,9 @@ $(window).scroll(function () {
num = $goodList.children('.good-info').length;
$.ajax({
type: 'GET',
url: '/product/newsale/selectNewSale?dayLimit' + (index + 1),
url: '/product/newsale/selectNewSale',
data: {
dayLimit: index + 1,
page: page + 1
},
success: function(data) {
... ...