...
|
...
|
@@ -38,7 +38,7 @@ var $subNav = $('.home-sub-nav'), |
|
|
brand = $('input[name="brand"]').val(),
|
|
|
coverChannel = $('input[name="coverChannel"]').val(),
|
|
|
favId = $('input[name="favId"]').val(),
|
|
|
uid = $('input[name="uid"]').val();
|
|
|
uid = window.queryString.uid;
|
|
|
|
|
|
var winH = $(window).height(),
|
|
|
noResult = '<p class="no-result">未找到相关搜索结果</p>';
|
...
|
...
|
@@ -70,12 +70,13 @@ var defaultOpt = require('../common/query-param'); |
|
|
|
|
|
$.ajax({
|
|
|
type: 'GET',
|
|
|
url: '/product/index/shopFav',
|
|
|
url: location.protocol + '//m.yohobuy.com/product/index/shopFav',
|
|
|
xhrFields: {
|
|
|
withCredentials: true
|
|
|
},
|
|
|
data: {
|
|
|
shopId: $('.shopId').val()
|
|
|
shopId: $('.shopId').val(),
|
|
|
uid: uid
|
|
|
},
|
|
|
success: function(data) {
|
|
|
if (data.collect) {
|
...
|
...
|
@@ -123,6 +124,8 @@ var defaultOpt = require('../common/query-param'); |
|
|
|
|
|
// 切换active状态到$pre上
|
|
|
$pre.addClass('active');
|
|
|
|
|
|
$('#pos-list').addClass('hide');
|
|
|
$pre.siblings('.filter').removeClass('active');
|
|
|
subNavScrollTo();
|
|
|
}
|
...
|
...
|
@@ -383,7 +386,10 @@ function tabChange(dom, index) { |
|
|
|
|
|
|
|
|
|
|
|
function scrollHandler() {
|
|
|
function scrollHandler(e) {
|
|
|
if (!$('.filter-mask').hasClass('hide')) {
|
|
|
return;
|
|
|
}
|
|
|
var scrollCall,
|
|
|
sTop = $(document).scrollTop(),
|
|
|
scH = $('#scroller').outerHeight(),
|
...
|
...
|
@@ -424,9 +430,15 @@ function scrollHandler() { |
|
|
}
|
|
|
$nav2.removeClass('hide');
|
|
|
$nav1.addClass('hide');
|
|
|
if (!$newList.hasClass('hide')) {
|
|
|
$newList.addClass('classics');
|
|
|
}
|
|
|
} else if (sTop > nav1OffsetTop && $('#nav').length) {
|
|
|
$nav1.removeClass('hide');
|
|
|
$nav2.addClass('hide');
|
|
|
if (!$newList.hasClass('hide')) {
|
|
|
$newList.removeClass('classics');
|
|
|
}
|
|
|
} else {
|
|
|
$nav1.addClass('hide');
|
|
|
$nav2.addClass('hide');
|
...
|
...
|
@@ -439,7 +451,8 @@ document.addEventListener('touchmove', function(e) { |
|
|
// e.preventDefault();
|
|
|
}
|
|
|
if ($('.filter-mask').length && !$('.filter-mask').hasClass('hide')) {
|
|
|
e.preventDefault();
|
|
|
// e.preventDefault();
|
|
|
// e.stopPropagation();
|
|
|
}
|
|
|
}, false);
|
|
|
|
...
|
...
|
@@ -655,7 +668,7 @@ function search(opt, callback) { |
|
|
bindGoodThumbClick();
|
|
|
setTimeout(function() {
|
|
|
callback && callback();
|
|
|
}, 0)
|
|
|
}, 0);
|
|
|
},
|
|
|
error: function() {
|
|
|
tip.show('网络断开连接了~');
|
...
|
...
|
@@ -699,6 +712,7 @@ $newList.on('touchstart', 'li', function(e) { |
|
|
}
|
|
|
|
|
|
$newList.addClass('hide');
|
|
|
$('#pos-list').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);
|
...
|
...
|
@@ -780,6 +794,11 @@ $subNav.on('touchend touchcancel', function(e) { |
|
|
if ($this.hasClass('first-li-more')) {
|
|
|
filter.hideFilter();
|
|
|
$newList.toggleClass('hide');
|
|
|
if ($('#pos-list').hasClass('hide')) {
|
|
|
$newList.removeClass('classics');
|
|
|
} else {
|
|
|
$newList.addClass('classics');
|
|
|
}
|
|
|
if ($this.hasClass('default')) {
|
|
|
$newList.find('li.default').addClass('active').siblings().removeClass('active');
|
|
|
} else if ($this.hasClass('new')) {
|
...
|
...
|
@@ -788,119 +807,133 @@ $subNav.on('touchend touchcancel', function(e) { |
|
|
$newList.find('li.sale').addClass('active').siblings().removeClass('active');
|
|
|
}
|
|
|
newListHide();
|
|
|
if ($('#pos-list').hasClass('hide')) {
|
|
|
subNavScrollTo();
|
|
|
}
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
// 最新li 列表
|
|
|
$newList.addClass('hide');
|
|
|
|
|
|
if ($this.hasClass('filter')) {
|
|
|
} else {
|
|
|
// 最新li 列表
|
|
|
$newList.addClass('hide');
|
|
|
|
|
|
// 筛选面板切换状态
|
|
|
if ($this.hasClass('active') && !$('.filter-mask').hasClass('hide')) {
|
|
|
$('.home-sub-nav>li.filter').removeClass('active');
|
|
|
$this.removeClass('active');
|
|
|
filter.hideFilter();
|
|
|
} else {
|
|
|
$('.home-sub-nav>li.filter').addClass('active');
|
|
|
$this.addClass('active');
|
|
|
if ($this.hasClass('filter')) {
|
|
|
|
|
|
filter.showFilter();
|
|
|
// 筛选面板切换状态
|
|
|
if ($this.hasClass('active') && !$('.filter-mask').hasClass('hide')) {
|
|
|
$('.home-sub-nav>li.filter').removeClass('active');
|
|
|
$this.removeClass('active');
|
|
|
filter.hideFilter();
|
|
|
|
|
|
if ($this.closest('.pos-list').length > 0) {
|
|
|
$('.filter-mask').addClass('call-by-fix').css('top', '');
|
|
|
} else {
|
|
|
$('.filter-mask').removeClass('call-by-fix').css('top', $this.offset().top + nav1H);
|
|
|
}
|
|
|
$('.home-sub-nav>li.filter').addClass('active');
|
|
|
$this.addClass('active');
|
|
|
|
|
|
}
|
|
|
if ($('#pos-list').hasClass('hide')) {
|
|
|
subNavScrollTo();
|
|
|
}
|
|
|
} else {
|
|
|
filter.showFilter();
|
|
|
|
|
|
filter.hideFilter();// 隐藏面板
|
|
|
|
|
|
if ($this.hasClass('new')) {
|
|
|
cname = '.new';
|
|
|
navType = 'newest';
|
|
|
} else if ($this.hasClass('price')) {
|
|
|
cname = '.price';
|
|
|
navType = 'price';
|
|
|
} else if ($this.hasClass('discount')) {
|
|
|
cname = '.discount';
|
|
|
navType = 'discount';
|
|
|
} else if ($this.hasClass('default')) {
|
|
|
cname = '.default';
|
|
|
navType = 'default';
|
|
|
}
|
|
|
|
|
|
nav = navInfo[navType];
|
|
|
var reloadCb = function() {
|
|
|
$goodsContainer.children('.container:not(.hide)').addClass('hide');
|
|
|
switch (navType) {
|
|
|
case 'newest':
|
|
|
$ngc.removeClass('hide');
|
|
|
break;
|
|
|
|
|
|
case 'price':
|
|
|
$pgc.removeClass('hide');
|
|
|
break;
|
|
|
if ($this.closest('.pos-list').length > 0) {
|
|
|
$('.filter-mask').addClass('call-by-fix').css('top', '');
|
|
|
} else {
|
|
|
$('.filter-mask').removeClass('call-by-fix').css('top', $this.offset().top + nav1H);
|
|
|
}
|
|
|
if ($('#pos-list').hasClass('hide')) {
|
|
|
$('#pos-list').removeClass('hide');
|
|
|
}
|
|
|
|
|
|
case 'discount':
|
|
|
$dgc.removeClass('hide');
|
|
|
break;
|
|
|
case 'default':
|
|
|
$defaultgc.removeClass('hide');
|
|
|
break;
|
|
|
default:
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
if ($this.hasClass('active')) {
|
|
|
} else {
|
|
|
|
|
|
filter.hideFilter();// 隐藏面板
|
|
|
|
|
|
// 最新无排序切换
|
|
|
if ($this.hasClass('new')) {
|
|
|
return;
|
|
|
cname = '.new';
|
|
|
navType = 'newest';
|
|
|
} else if ($this.hasClass('price')) {
|
|
|
cname = '.price';
|
|
|
navType = 'price';
|
|
|
} else if ($this.hasClass('discount')) {
|
|
|
cname = '.discount';
|
|
|
navType = 'discount';
|
|
|
} else if ($this.hasClass('default')) {
|
|
|
cname = '.default';
|
|
|
navType = 'default';
|
|
|
}
|
|
|
|
|
|
if ($this.hasClass('price') || $this.hasClass('discount')) {
|
|
|
$this = $subNav.find(cname);
|
|
|
nav = navInfo[navType];
|
|
|
var reloadCb = function() {
|
|
|
$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;
|
|
|
default:
|
|
|
break;
|
|
|
}
|
|
|
};
|
|
|
|
|
|
// 价格/折扣切换排序状态
|
|
|
$this.find('.icon > .iconfont').toggleClass('cur');
|
|
|
nav.reload = true; // 重置reload,HTML会被替换为逆序的HTML
|
|
|
nav.order = nav.order === 0 ? 1 : 0; // 切换排序
|
|
|
if ($this.hasClass('active')) {
|
|
|
|
|
|
}
|
|
|
} else {
|
|
|
$active = $subNav.find('.active');
|
|
|
// 最新无排序切换
|
|
|
if ($this.hasClass('new')) {
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
if ($active.hasClass('filter')) {
|
|
|
if ($this.hasClass('price') || $this.hasClass('discount')) {
|
|
|
$this = $subNav.find(cname);
|
|
|
|
|
|
// 若之前active项为筛选,则隐藏筛选面板
|
|
|
filter.hideFilter();
|
|
|
}
|
|
|
$subNav.children().removeClass('active');
|
|
|
$subNav.find(cname).addClass('active');
|
|
|
}
|
|
|
if (!$('#pos-list').hasClass('hide')) {
|
|
|
subNavScrollTo();
|
|
|
// 价格/折扣切换排序状态
|
|
|
$this.find('.icon > .iconfont').toggleClass('cur');
|
|
|
nav.reload = true; // 重置reload,HTML会被替换为逆序的HTML
|
|
|
nav.order = nav.order === 0 ? 1 : 0; // 切换排序
|
|
|
|
|
|
}
|
|
|
} else {
|
|
|
$active = $subNav.find('.active');
|
|
|
|
|
|
if ($active.hasClass('filter')) {
|
|
|
|
|
|
// 若之前active项为筛选,则隐藏筛选面板
|
|
|
filter.hideFilter();
|
|
|
}
|
|
|
$subNav.children().removeClass('active');
|
|
|
$subNav.find(cname).addClass('active');
|
|
|
}
|
|
|
if (!$('#pos-list').hasClass('hide')) {
|
|
|
subNavScrollTo();
|
|
|
}
|
|
|
if (nav.reload) {
|
|
|
search({
|
|
|
type: 'shop_id',
|
|
|
id: shopId,
|
|
|
brand: brand,
|
|
|
appVersion: appVersion,
|
|
|
url: '/product/search/search',
|
|
|
nextPage: false
|
|
|
}, reloadCb);
|
|
|
}
|
|
|
}
|
|
|
if (nav.reload) {
|
|
|
search({
|
|
|
type: 'shop_id',
|
|
|
id: shopId,
|
|
|
brand: brand,
|
|
|
appVersion: appVersion,
|
|
|
url: '/product/search/search',
|
|
|
nextPage: false
|
|
|
}, reloadCb);
|
|
|
}
|
|
|
if ($('#list-nav').offset().top > $(document).scrollTop() && $('.filter-mask').hasClass('hide')) {
|
|
|
if ($this.hasClass('first-li-more') && !$('#pos-list').hasClass('hide')) {
|
|
|
if ($('.new-list').hasClass('hide')) {
|
|
|
$('.new-list').removeClass('full-height');
|
|
|
$('#pos-list').addClass('hide');
|
|
|
} else {
|
|
|
$('.new-list').addClass('full-height');
|
|
|
}
|
|
|
} else {
|
|
|
$('#pos-list').addClass('hide');
|
|
|
}
|
|
|
} else {
|
|
|
$('.new-list').removeClass('full-height');
|
|
|
}
|
|
|
|
|
|
e.stopPropagation();
|
|
|
});
|
|
|
|
...
|
...
|
@@ -945,7 +978,7 @@ $collect.on('touchstart', function() { |
|
|
|
|
|
$.ajax({
|
|
|
method: 'get',
|
|
|
url: '' + '/product/opt/favoriteBrand',
|
|
|
url: location.protocol + '//m.yohobuy.com/product/opt/favoriteBrand',
|
|
|
data: {
|
|
|
id: favId ? favId : shopId,
|
|
|
appVersion: appVersion,
|
...
|
...
|
|