...
|
...
|
@@ -15,6 +15,7 @@ var $goodsContainer = $('#goods-container'), |
|
|
$dgc = $goodsContainer.find('.discount-goods'),
|
|
|
$pgc = $goodsContainer.find('.price-goods'),
|
|
|
$agc = $goodsContainer.find('.all-goods'),
|
|
|
$cgc = $goodsContainer.find('.category-goods'),
|
|
|
$sgc = $goodsContainer.find('.sale-goods');
|
|
|
|
|
|
var winH = $(window).height(),
|
...
|
...
|
@@ -56,6 +57,13 @@ var $listNav = $('#list-nav'), |
|
|
reload: true,
|
|
|
page: 0,
|
|
|
end: false
|
|
|
},
|
|
|
category: {
|
|
|
order: 0,
|
|
|
reload: true,
|
|
|
fuck: true,
|
|
|
page: 0,
|
|
|
end: false
|
|
|
}
|
|
|
},
|
|
|
$pre = $listNav.find('.active'), // 纪录进入筛选前的active项,初始为选中项
|
...
|
...
|
@@ -90,7 +98,7 @@ $.extend(defaultOpt, { |
|
|
|
|
|
// 判断导航类型
|
|
|
function judgeType(dom) {
|
|
|
var navType;
|
|
|
var navType = 'category';
|
|
|
|
|
|
if (dom.hasClass('new')) {
|
|
|
navType = 'newest';
|
...
|
...
|
@@ -102,6 +110,8 @@ function judgeType(dom) { |
|
|
navType = 'sale';
|
|
|
} else if (dom.hasClass('all')) {
|
|
|
navType = 'all';
|
|
|
} else if (dom.hasClass('category')) {
|
|
|
navType = 'category';
|
|
|
}
|
|
|
|
|
|
return navType;
|
...
|
...
|
@@ -184,9 +194,7 @@ function search(opt, params) { |
|
|
$.extend(defaultOpt, ext); // 扩展筛选项
|
|
|
}
|
|
|
|
|
|
if (params) {
|
|
|
$.extend(defaultOpt, params);
|
|
|
}
|
|
|
$.extend(defaultOpt, params || {}); // 扩展筛选项
|
|
|
|
|
|
// 导航类别
|
|
|
navType = judgeType($pre);
|
...
|
...
|
@@ -240,6 +248,9 @@ function search(opt, params) { |
|
|
case 'all':
|
|
|
$container = $agc;
|
|
|
break;
|
|
|
case 'categroy':
|
|
|
$container = $cgc;
|
|
|
break;
|
|
|
default:
|
|
|
$container = $agc;
|
|
|
break;
|
...
|
...
|
@@ -257,7 +268,11 @@ function search(opt, params) { |
|
|
$container.html(noResult);
|
|
|
}
|
|
|
} else {
|
|
|
if (nav.reload) {
|
|
|
if (navType === 'category') {
|
|
|
nav.page = 1;
|
|
|
}
|
|
|
|
|
|
if (nav.reload || navType === 'category') {
|
|
|
$container.html(data);
|
|
|
lazyLoad($container.find('.lazy'));
|
|
|
} else {
|
...
|
...
|
@@ -359,7 +374,7 @@ $listNav.on('touchend touchcancel', function(e) { |
|
|
// 导航类别
|
|
|
navType = judgeType($this);
|
|
|
|
|
|
nav = navInfo[navType || 'all'];
|
|
|
nav = navInfo[navType];
|
|
|
|
|
|
if ($this.hasClass('active')) {
|
|
|
|
...
|
...
|
@@ -419,7 +434,7 @@ $listNav.on('touchend touchcancel', function(e) { |
|
|
$this.addClass('active');
|
|
|
}
|
|
|
|
|
|
if (nav && nav.reload) {
|
|
|
if (nav.reload) {
|
|
|
search();
|
|
|
}
|
|
|
}
|
...
|
...
|
@@ -442,8 +457,6 @@ $(window).scroll(function() { |
|
|
window.requestAnimationFrame(scrollHandler);
|
|
|
});
|
|
|
|
|
|
// 初始请求最新第一页数据
|
|
|
search();
|
|
|
|
|
|
$listNav.on('touchstart', 'li', function() {
|
|
|
$(this).addClass('bytouch');
|
...
|
...
|
@@ -451,5 +464,6 @@ $listNav.on('touchstart', 'li', function() { |
|
|
$listNav.find('li').removeClass('bytouch');
|
|
|
});
|
|
|
|
|
|
|
|
|
module.exports = search; |
|
|
module.exports = {
|
|
|
start: search
|
|
|
}; |
...
|
...
|
|