...
|
...
|
@@ -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');
|
...
|
...
|
@@ -38,4 +45,70 @@ $('#discount-nav').delegate('li', 'touchstart', function() { |
|
|
$curNav = $this;
|
|
|
|
|
|
$(document).trigger('scroll'); //Trigger lazyLoad
|
|
|
}); |
|
|
\ No newline at end of file |
|
|
});
|
|
|
|
|
|
//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 |
...
|
...
|
|