...
|
...
|
@@ -5,10 +5,12 @@ |
|
|
*/
|
|
|
|
|
|
var $ = require('jquery'),
|
|
|
Hammer = require('hammer'),
|
|
|
tip = require('../plugin/tip'),
|
|
|
lazyLoad = require('yoho.lazyload');
|
|
|
|
|
|
var winH = $(window).height(),
|
|
|
var navHammer,
|
|
|
winH = $(window).height(),
|
|
|
loadMoreH = $('#load-more').height(),
|
|
|
$goodList = $('#goods-list'),
|
|
|
loading = false,
|
...
|
...
|
@@ -35,8 +37,11 @@ if (kidsType) { |
|
|
|
|
|
$curNav = $navList.children('.focus');
|
|
|
|
|
|
$('#maybe-like-nav').delegate('li', 'tap', function() {
|
|
|
var $this = $(this),
|
|
|
navHammer = new Hammer($navList[0]);
|
|
|
navHammer.on('tap', function(e) {
|
|
|
var $this = $(e.target).closest('li'),
|
|
|
//$('#maybe-like-nav').delegate('li', 'touchstart', function() {
|
|
|
// var $this = $(this),
|
|
|
$goods = $('.goods-list'),
|
|
|
$content;
|
|
|
|
...
|
...
|
@@ -59,67 +64,74 @@ $('#maybe-like-nav').delegate('li', 'tap', function() { |
|
|
$(document).trigger('scroll'); //Trigger lazyLoad
|
|
|
});
|
|
|
|
|
|
$('.maybe-like p').on('touchstart', function (e) {
|
|
|
search();
|
|
|
});
|
|
|
|
|
|
//srcoll to load more
|
|
|
$(window).scroll(function () {
|
|
|
if ($(window).scrollTop() + winH >= $(document).height() - loadMoreH - 50) {
|
|
|
if (loading) {
|
|
|
return;
|
|
|
}
|
|
|
loading = true;
|
|
|
|
|
|
//num = $goodList.find('.good-info').length;
|
|
|
$.ajax({
|
|
|
type: 'GET',
|
|
|
url: url,
|
|
|
data: {
|
|
|
page: page + 1
|
|
|
},
|
|
|
success: function(data) {
|
|
|
if (data === ' ') {
|
|
|
loading = true;
|
|
|
if (gender) {
|
|
|
if (gender === '1,3') {
|
|
|
url = '/boys/bottomBanner';
|
|
|
} else {
|
|
|
url = '/girls/bottomBanner';
|
|
|
}
|
|
|
$.ajax({
|
|
|
type: 'GET',
|
|
|
url: url,
|
|
|
success: function(data) {
|
|
|
if (data) {
|
|
|
$('#load-more-img').show();
|
|
|
$('#load-more-img a').attr('href', data.url);
|
|
|
$('#load-more-img a > img').attr('src', data.img);
|
|
|
}
|
|
|
},
|
|
|
error: function() {
|
|
|
}
|
|
|
});
|
|
|
search();
|
|
|
}
|
|
|
});
|
|
|
|
|
|
function search() {
|
|
|
if (loading) {
|
|
|
return;
|
|
|
}
|
|
|
loading = true;
|
|
|
|
|
|
//num = $goodList.find('.good-info').length;
|
|
|
$.ajax({
|
|
|
type: 'GET',
|
|
|
url: url,
|
|
|
data: {
|
|
|
page: page + 1
|
|
|
},
|
|
|
success: function(data) {
|
|
|
if (data === ' ') {
|
|
|
loading = true;
|
|
|
if (gender) {
|
|
|
if (gender === '1,3') {
|
|
|
url = '/boys/bottomBanner';
|
|
|
} else {
|
|
|
url = '/girls/bottomBanner';
|
|
|
}
|
|
|
return;
|
|
|
}
|
|
|
$.ajax({
|
|
|
type: 'GET',
|
|
|
url: url,
|
|
|
success: function(data) {
|
|
|
if (data) {
|
|
|
$('#load-more-img').show();
|
|
|
$('#load-more-img a').attr('href', data.url);
|
|
|
$('#load-more-img a > img').attr('src', data.img);
|
|
|
}
|
|
|
},
|
|
|
error: function() {
|
|
|
}
|
|
|
});
|
|
|
|
|
|
num = $goodList.find('.good-info').length;
|
|
|
}
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
$goodList.append(data);
|
|
|
num = $goodList.find('.good-info').length;
|
|
|
|
|
|
// 2015/10/31 fei.hong: 修复第一页分页不显示图片的问题
|
|
|
if (num === 0) {
|
|
|
lazyLoad($goodList.find('.good-info').find('img.lazy'));
|
|
|
} else {
|
|
|
lazyLoad($goodList.find('.good-info:gt(' + (num - 1) + ')').find('img.lazy'));
|
|
|
}
|
|
|
$goodList.append(data);
|
|
|
|
|
|
loading = false;
|
|
|
page++;
|
|
|
},
|
|
|
error: function() {
|
|
|
tip.show('网络断开连接了~');
|
|
|
loading = false;
|
|
|
// 2015/10/31 fei.hong: 修复第一页分页不显示图片的问题
|
|
|
if (num === 0) {
|
|
|
lazyLoad($goodList.find('.good-info').find('img.lazy'));
|
|
|
} else {
|
|
|
lazyLoad($goodList.find('.good-info:gt(' + (num - 1) + ')').find('img.lazy'));
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
|
|
|
}); |
|
|
\ No newline at end of file |
|
|
loading = false;
|
|
|
page++;
|
|
|
},
|
|
|
error: function() {
|
|
|
tip.show('网络断开连接了~');
|
|
|
loading = false;
|
|
|
}
|
|
|
});
|
|
|
} |
|
|
\ No newline at end of file |
...
|
...
|
|