...
|
...
|
@@ -21,9 +21,9 @@ let $pgc = $goodsContainer.children('.price-goods'); |
|
|
let $dgc = $goodsContainer.children('.discount-goods');
|
|
|
let $listNav = $('#list-nav'); // 筛选项列表
|
|
|
let $pre = $listNav.find('.active'); // 记录进入筛选前的active项,初始为选中项
|
|
|
let $filterBox = $('.filter-box');
|
|
|
let $filterBody = $('.filter-body');
|
|
|
|
|
|
let allGoodsTabClickTimes = 0;
|
|
|
let navInfo = {
|
|
|
price: {
|
|
|
order: 1,
|
...
|
...
|
@@ -116,39 +116,36 @@ function getGoodsList() { |
|
|
* 加载筛选数据
|
|
|
*/
|
|
|
function getFilter() {
|
|
|
if (allGoodsTabClickTimes === 0) {
|
|
|
// 第一次点进来调用
|
|
|
|
|
|
$.ajax({
|
|
|
type: 'GET',
|
|
|
url: location.protocol + '//m.yohobuy.com/product/search/filter',
|
|
|
data: defaultOpt,
|
|
|
success: function(data) {
|
|
|
if (data) { // 判断需要再严禁些,确定数据正常后再 ++
|
|
|
allGoodsTabClickTimes++;
|
|
|
}
|
|
|
$goodsContainer.append(data);
|
|
|
$.ajax({
|
|
|
type: 'GET',
|
|
|
url: location.protocol + '//m.yohobuy.com/product/search/filter',
|
|
|
data: defaultOpt,
|
|
|
success: function(data) {
|
|
|
$goodsContainer.append(data);
|
|
|
|
|
|
// 初始化filter&注册filter回调
|
|
|
filter.initFilter({
|
|
|
fCbFn: getGoodsList,
|
|
|
hCbFn: function() {
|
|
|
// 初始化filter&注册filter回调
|
|
|
filter.initFilter({
|
|
|
fCbFn: getGoodsList,
|
|
|
hCbFn: function() {
|
|
|
|
|
|
// 切换active状态到$pre上
|
|
|
$pre.addClass('active');
|
|
|
$pre.siblings('.filter').removeClass('active');
|
|
|
}
|
|
|
});
|
|
|
// 切换active状态到$pre上
|
|
|
$pre.addClass('active');
|
|
|
$pre.siblings('.filter').removeClass('active');
|
|
|
}
|
|
|
});
|
|
|
|
|
|
$filterBody = $('.filter-body');
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
$filterBody = $('.filter-body');
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
|
|
|
// 绑定 getfilter 方法,在点击全部商品 Tab 时调用
|
|
|
Tab.prototype.getfilter = getFilter;
|
|
|
Tab.prototype.getgoodslist = getGoodsList;
|
|
|
Tab.prototype.getgoodslist = getGoodsList; // 获取商品列表
|
|
|
Tab.prototype.filterhide = function() { // 隐藏筛选 TAB
|
|
|
$filterBox.css('display', 'none');
|
|
|
};
|
|
|
Tab.prototype.filtershow = function() { // 显示筛选 TAB
|
|
|
$filterBox.css('display', 'block');
|
|
|
};
|
|
|
|
|
|
$listNav.bind('contextmenu', function() {
|
|
|
return false;
|
...
|
...
|
@@ -262,3 +259,4 @@ $listNav.on('touchend touchcancel', function(e) { |
|
|
}
|
|
|
}
|
|
|
});
|
|
|
getFilter(); |
...
|
...
|
|