...
|
...
|
@@ -29,9 +29,11 @@ var $subNav = $('.home-sub-nav'), |
|
|
$collect = $('#collect'),
|
|
|
$goodsContainer = $('#goods-container'),
|
|
|
$goodsChildren = $goodsContainer.children(),
|
|
|
$defaultgc = $goodsContainer.children('.default-goods'),
|
|
|
$ngc = $($goodsChildren.get(0)),
|
|
|
$pgc = $($goodsChildren.get(1)),
|
|
|
$dgc = $($goodsChildren.get(2)),
|
|
|
$newList = $('.new-list'),
|
|
|
shopId = $('input[name="shop_id"]').val(),
|
|
|
appVersion = $('input[name="app_version"]').val(),
|
|
|
brand = $('input[name="brand"]').val(),
|
...
|
...
|
@@ -141,6 +143,12 @@ var $listNav = $('#list-nav'), |
|
|
page: 1,
|
|
|
end: false
|
|
|
},
|
|
|
default: {
|
|
|
order: 0,
|
|
|
reload: true,
|
|
|
page: 1,
|
|
|
end: false
|
|
|
},
|
|
|
hot: {
|
|
|
order: 1,
|
|
|
reload: true,
|
...
|
...
|
@@ -544,6 +552,8 @@ function search(opt, callback) { |
|
|
navType = 'price';
|
|
|
} else if ($pre.hasClass('discount')) {
|
|
|
navType = 'discount';
|
|
|
} else if ($pre.hasClass('default')) {
|
|
|
navType = 'default';
|
|
|
}
|
|
|
nav = navInfo[navType];
|
|
|
|
...
|
...
|
@@ -596,6 +606,9 @@ function search(opt, callback) { |
|
|
case 'discount':
|
|
|
$container = $dgc;
|
|
|
break;
|
|
|
case 'default':
|
|
|
$container = $defaultgc;
|
|
|
break;
|
|
|
default:
|
|
|
break;
|
|
|
}
|
...
|
...
|
@@ -646,7 +659,94 @@ function search(opt, callback) { |
|
|
$listNav.bind('contextmenu', function(e) {
|
|
|
return false;
|
|
|
});
|
|
|
function newListHide() {
|
|
|
var $firstLi = $listNav.find('li.first-li-more');
|
|
|
|
|
|
if ($newList.hasClass('hide')) {
|
|
|
$firstLi.find('span.up').addClass('hide');
|
|
|
$firstLi.find('span.down').removeClass('hide');
|
|
|
} else {
|
|
|
$firstLi.find('span.down').addClass('hide');
|
|
|
$firstLi.find('span.up').removeClass('hide');
|
|
|
}
|
|
|
}
|
|
|
$newList.on('touchstart', 'li', function(e) {
|
|
|
var navType, bpIdData = $(this).attr('data-bp-id') || '',
|
|
|
$firstLiDom = $subNav.find('li.first-li-more'),
|
|
|
cls = '';
|
|
|
|
|
|
e.preventDefault();
|
|
|
if ($(this).hasClass('new')) {
|
|
|
navType = 'newest';
|
|
|
cls = 'new';
|
|
|
} else if ($(this).hasClass('default')) {
|
|
|
navType = 'default';
|
|
|
cls = 'default';
|
|
|
} else if ($(this).hasClass('sale')) {
|
|
|
navType = 'sale';
|
|
|
cls = 'sale';
|
|
|
}
|
|
|
|
|
|
$newList.addClass('hide');
|
|
|
$firstLiDom.find('.nav-txt').text($(this).text());
|
|
|
$firstLiDom.attr('data-bp-id', bpIdData).addClass('active').siblings().removeClass('active');
|
|
|
$subNav.find('.first-li-more').removeClass('new default sale').addClass(cls);
|
|
|
|
|
|
$(document).trigger('shouldSendBpData', [bpIdData]);
|
|
|
newListHide();
|
|
|
|
|
|
// 切换container显示
|
|
|
$goodsContainer.children('.container:not(.hide)').addClass('hide');
|
|
|
|
|
|
switch (navType) {
|
|
|
case 'newest':
|
|
|
$ngc.removeClass('hide');
|
|
|
break;
|
|
|
|
|
|
case 'price':
|
|
|
$pgc.removeClass('hide');
|
|
|
break;
|
|
|
|
|
|
case 'discount':
|
|
|
$dgc.removeClass('hide');
|
|
|
break;
|
|
|
|
|
|
case 'default':
|
|
|
$defaultgc.removeClass('hide');
|
|
|
break;
|
|
|
|
|
|
case 'sale':
|
|
|
$sgc.removeClass('hide');
|
|
|
break;
|
|
|
default:
|
|
|
break;
|
|
|
}
|
|
|
$pre = $('.first-li-more');
|
|
|
var nav = navInfo[navType];
|
|
|
if (nav.reload) {
|
|
|
search({
|
|
|
type: 'shop_id',
|
|
|
id: shopId,
|
|
|
brand: brand,
|
|
|
appVersion: appVersion,
|
|
|
url: '/product/search/search',
|
|
|
nextPage: false
|
|
|
}, function() {
|
|
|
});
|
|
|
}
|
|
|
|
|
|
});
|
|
|
|
|
|
$(document).on('touchstart', function(e) {
|
|
|
if (!$newList.hasClass('hide') &&
|
|
|
$(e.target).closest('.new-list, li.first-li-more').length <= 0) {
|
|
|
$newList.addClass('hide');
|
|
|
newListHide();
|
|
|
}
|
|
|
});
|
|
|
function subNavScrollTo() {
|
|
|
window.scrollTo(0, $('#list-nav').offset().top + 5)
|
|
|
}
|
|
|
$subNav.on('touchend touchcancel', function(e) {
|
|
|
var $this = $(e.target).closest('li'),
|
|
|
cname,
|
...
|
...
|
@@ -661,6 +761,22 @@ $subNav.on('touchend touchcancel', function(e) { |
|
|
if (typeof $this === 'undefined' || $this.length === 0) {
|
|
|
return;
|
|
|
}
|
|
|
if ($this.hasClass('first-li-more')) {
|
|
|
filter.hideFilter();
|
|
|
$newList.toggleClass('hide');
|
|
|
if ($this.hasClass('default')) {
|
|
|
$newList.find('li.default').addClass('active').siblings().removeClass('active');
|
|
|
} else if ($this.hasClass('new')) {
|
|
|
$newList.find('li.new').addClass('active').siblings().removeClass('active');
|
|
|
} else if ($this.hasClass('sale')) {
|
|
|
$newList.find('li.sale').addClass('active').siblings().removeClass('active');
|
|
|
}
|
|
|
newListHide();
|
|
|
subNavScrollTo();
|
|
|
return true;
|
|
|
}
|
|
|
// 最新li 列表
|
|
|
$newList.addClass('hide');
|
|
|
|
|
|
if ($this.hasClass('filter')) {
|
|
|
|
...
|
...
|
@@ -682,7 +798,7 @@ $subNav.on('touchend touchcancel', function(e) { |
|
|
}
|
|
|
|
|
|
}
|
|
|
window.scrollTo(0, $('#list-nav').offset().top + 5)
|
|
|
subNavScrollTo();
|
|
|
} else {
|
|
|
|
|
|
filter.hideFilter();// 隐藏面板
|
...
|
...
|
@@ -696,7 +812,10 @@ $subNav.on('touchend touchcancel', function(e) { |
|
|
} else if ($this.hasClass('discount')) {
|
|
|
cname = '.discount';
|
|
|
navType = 'discount';
|
|
|
}
|
|
|
} else if ($this.hasClass('default')) {
|
|
|
cname = '.default';
|
|
|
navType = 'default';
|
|
|
}
|
|
|
|
|
|
nav = navInfo[navType];
|
|
|
|
...
|
...
|
@@ -729,6 +848,10 @@ $subNav.on('touchend touchcancel', function(e) { |
|
|
case 'discount':
|
|
|
$dgc.removeClass('hide');
|
|
|
break;
|
|
|
|
|
|
case 'default':
|
|
|
$defaultgc.removeClass('hide');
|
|
|
break;
|
|
|
default:
|
|
|
break;
|
|
|
}
|
...
|
...
|
@@ -758,6 +881,10 @@ $subNav.on('touchend touchcancel', function(e) { |
|
|
case 'discount':
|
|
|
$dgc.removeClass('hide');
|
|
|
break;
|
|
|
|
|
|
case 'default':
|
|
|
$defaultgc.removeClass('hide');
|
|
|
break;
|
|
|
default:
|
|
|
break;
|
|
|
}
|
...
|
...
|
@@ -776,7 +903,7 @@ $subNav.on('touchend touchcancel', function(e) { |
|
|
url: '/product/search/search',
|
|
|
nextPage: false
|
|
|
}, function() {
|
|
|
window.scrollTo(0, $('#list-nav').offset().top + 5)
|
|
|
subNavScrollTo();
|
|
|
});
|
|
|
}
|
|
|
}
|
...
|
...
|
|