|
|
var $ = require('yoho-jquery'),
|
|
|
|
|
|
// Swiper = require('yoho.iswiper'),
|
|
|
lazyLoad = require('yoho-jquery-lazyload'),
|
|
|
loading = require('../plugin/loading');
|
|
|
|
|
|
var page = 1,
|
|
|
winH,
|
|
|
listTop,
|
|
|
navSwiper,
|
|
|
notab = 0,
|
|
|
sort = '',
|
|
|
id = '',
|
|
|
hotrankNav,
|
|
|
noResult = '<p class="no-result">未找到相关搜索结果</p>';
|
|
|
|
|
|
require('../common/suspend-cart');
|
|
|
require('../common');
|
|
|
|
|
|
var share = require('../common/share');
|
|
|
|
|
|
share({
|
|
|
title: '有货【会员日】开启啦!9月28日潮集狂欢趴等你来HI!限时6大福利,快参与起来喽~',
|
|
|
link: location.href,
|
|
|
desc: 'YOHO!BUY',
|
|
|
imgUrl: 'http://static.yohobuy.com/m/v1/img/touch/apple-touch-icon-144x144-precomposed-new.png'
|
|
|
|
|
|
});
|
|
|
|
|
|
function hotrank(page, sort, tabId, notab) {
|
|
|
loading.showLoadingMask();
|
|
|
$.ajax({
|
|
|
type: 'GET',
|
|
|
url: '/product/newsale/selectHotrank?' + sort,
|
|
|
dataType: 'html',
|
|
|
data: {
|
|
|
page: page,
|
|
|
tab_id: tabId,
|
|
|
notab: notab
|
|
|
},
|
|
|
success: function(data) {
|
|
|
if (data === ' ') {
|
|
|
if ($('.rank-main').length < 1 && $('.goods-nav').length < 1) {
|
|
|
$('#hotRank').html(noResult);
|
|
|
} else {
|
|
|
if (page === 1) {
|
|
|
hotrankNav = $('.goods-nav').prop('outerHTML');
|
|
|
|
|
|
$('#hotRank').html(hotrankNav + noResult);
|
|
|
}
|
|
|
}
|
|
|
} else {
|
|
|
$('.no-result').remove();
|
|
|
if (page === 1) {
|
|
|
$('.rank-main').remove();
|
|
|
}
|
|
|
$('#hotRank').append(data);
|
|
|
}
|
|
|
|
|
|
lazyLoad($('img.lazy'));
|
|
|
$('.rank-main ul li:gt(9)').find('.item-content i').removeClass('top');
|
|
|
winH = $(window).height();
|
|
|
if ($('.rank-main').length !== 0) {
|
|
|
$('#yoho-footer').css('position', 'static');
|
|
|
listTop = $('.rank-main').find('ul').offset().top;
|
|
|
} else {
|
|
|
$('#yoho-footer').css({
|
|
|
position: 'fixed',
|
|
|
width: '100%'
|
|
|
});
|
|
|
}
|
|
|
navSwiper = new Swiper('.s-goods-nav', {
|
|
|
grabCursor: true,
|
|
|
slidesPerView: 'auto',
|
|
|
slideElement: 'li'
|
|
|
});
|
|
|
loading.hideLoadingMask();
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
|
|
|
function scrollHandler() {
|
|
|
if (page === 2) {
|
|
|
return;
|
|
|
}
|
|
|
if ($(window).scrollTop() + winH < listTop + $('#hotRank').height() - 100) {
|
|
|
return;
|
|
|
}
|
|
|
page = 2;
|
|
|
notab = 1;
|
|
|
hotrank(page, sort, id, notab);
|
|
|
}
|
|
|
|
|
|
$(window).scroll(function() {
|
|
|
window.requestAnimationFrame(scrollHandler);
|
|
|
});
|
|
|
|
|
|
hotrank(page, sort, id, notab);
|
|
|
$('#hotRank').on('touchend touchcancel', function(e) {
|
|
|
var ev = ev || window.event;
|
|
|
var target = ev.target || ev.srcElement;
|
|
|
|
|
|
if (target.nodeName.toLowerCase() === 'span') {
|
|
|
$('.s-goods-nav .nav-item').removeClass('active');
|
|
|
target.parentNode.className = 'active ' + target.parentNode.className;
|
|
|
id = target.getAttribute('data-id') ? target.getAttribute('data-id') : '';
|
|
|
sort = target.getAttribute('data-sort') ? target.getAttribute('data-sort') : '';
|
|
|
page = 1;
|
|
|
notab = 1;
|
|
|
hotrank(page, sort, id, notab);
|
|
|
}
|
|
|
});
|
|
|
$('#hotRank').bind('contextmenu', function(e) {
|
|
|
return false;
|
|
|
});
|
|
|
$('#hotRank').on('touchstart', function(e) {
|
|
|
var ev = ev || window.event;
|
|
|
var target = ev.target || ev.srcElement;
|
|
|
|
|
|
if (target.nodeName.toLowerCase() === 'span') {
|
|
|
target.parentNode.className = 'bgActive ' + target.parentNode.className;
|
|
|
}
|
|
|
}).on('touchend touchcancel', function() {
|
|
|
$('.s-goods-nav .nav-item').removeClass('bgActive');
|
|
|
});
|
|
|
|
...
|
...
|
|