|
|
var $ = require('jquery'),
|
|
|
Swiper = require('yoho.iswiper'),
|
|
|
lazyLoad = require('yoho.lazyload');
|
|
|
Hammer = require('yoho.hammer');
|
|
|
|
|
|
var navSwiper;
|
|
|
Swiper = require('yoho.iswiper'),
|
|
|
lazyLoad = require('yoho.lazyload');
|
|
|
|
|
|
function hotrank(){
|
|
|
$.ajax({
|
|
|
type: 'GET',
|
|
|
url: '/product/newsale/selectHotrank',
|
|
|
dataType: 'html',
|
|
|
data: {
|
|
|
page: 1
|
|
|
},
|
|
|
success: function(data) {
|
|
|
$('#hotRank').append(data);
|
|
|
lazyLoad($('img.lazy'));
|
|
|
$('#yoho-footer').css('position', 'static');
|
|
|
navSwiper = new Swiper('.s-goods-nav', {
|
|
|
grabCursor: true,
|
|
|
slidesPerView: 'auto',
|
|
|
slideElement: 'li'
|
|
|
});
|
|
|
var page = 1,
|
|
|
winH,
|
|
|
hotnav,
|
|
|
sort = '',
|
|
|
id = '';
|
|
|
|
|
|
}
|
|
|
});
|
|
|
function hotrank(page, sort, tab_id) {
|
|
|
$.ajax({
|
|
|
type: 'GET',
|
|
|
url: '/product/newsale/selectHotrank',
|
|
|
dataType: 'html',
|
|
|
data: {
|
|
|
page: page,
|
|
|
sort: sort,
|
|
|
tab_id: tab_id
|
|
|
},
|
|
|
success: function(data) {
|
|
|
if (page === 1) {
|
|
|
$('#hotRank').html('');
|
|
|
}
|
|
|
$('#hotRank').append(data);
|
|
|
lazyLoad($('img.lazy'));
|
|
|
$('#yoho-footer').css('position', 'static');
|
|
|
navSwiper = new Swiper('.s-goods-nav', {
|
|
|
grabCursor: true,
|
|
|
slidesPerView: 'auto',
|
|
|
slideElement: 'li'
|
|
|
});
|
|
|
|
|
|
winH = $(window).height();
|
|
|
listTop = $('.rank-main').find('ul').offset().top;
|
|
|
$('.s-goods-nav .nav-item').each(function(index) {
|
|
|
hotnav = new Hammer($('.s-goods-nav .nav-item')[index]);
|
|
|
hotnav.on('tap', function(e) {
|
|
|
id = $('.s-goods-nav .nav-item').eq(index).data('id'),
|
|
|
sort = parseInt($('.s-goods-nav .nav-item').eq(index).data('sort').split('=')[1]);
|
|
|
hotrank(page, sort, id);
|
|
|
});
|
|
|
});
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
hotrank(); |
|
|
|
|
|
$(window).scroll(function () {
|
|
|
if (page === 2) {
|
|
|
return;
|
|
|
}
|
|
|
if ($(window).scrollTop() + winH < listTop + $('#hotRank').height() - 100) {
|
|
|
return;
|
|
|
}
|
|
|
page = 2;
|
|
|
hotrank(page, sort, id);
|
|
|
|
|
|
});
|
|
|
hotrank(page, sort, id); |
...
|
...
|
|