...
|
...
|
@@ -27,16 +27,18 @@ var tip = require('../../plugin/tip'), |
|
|
var $subNav = $('.home-sub-nav'),
|
|
|
$collect = $('#collect'),
|
|
|
$goodsContainer = $('#goods-container'),
|
|
|
$goodsChildren = $goodsContainer.children(),
|
|
|
$ngc = $($goodsChildren.get(0)),
|
|
|
$pgc = $($goodsChildren.get(1)),
|
|
|
$dgc = $($goodsChildren.get(2)),
|
|
|
$ngc = $goodsContainer.children('.new-goods'),
|
|
|
$defaultgc = $goodsContainer.children('.default-goods'),
|
|
|
$sgc = $goodsContainer.children('.sale-goods'),
|
|
|
$pgc = $goodsContainer.children('.price-goods'),
|
|
|
$dgc = $goodsContainer.children('.discount-goods'),
|
|
|
shopId = $('input[name="shop_id"]').val(),
|
|
|
appVersion = $('input[name="app_version"]').val(),
|
|
|
brand = $('input[name="brand"]').val(),
|
|
|
coverChannel = $('input[name="coverChannel"]').val(),
|
|
|
favId = $('input[name="favId"]').val(),
|
|
|
uid = $('input[name="uid"]').val();
|
|
|
uid = $('input[name="uid"]').val(),
|
|
|
$newList = $('.new-list');
|
|
|
|
|
|
var winH = $(window).height(),
|
|
|
noResult = '<p class="no-result">未找到相关搜索结果</p>';
|
...
|
...
|
@@ -89,7 +91,7 @@ var $listNav = $('#list-nav'), |
|
|
// 导航数据信息
|
|
|
navInfo = {
|
|
|
new: {
|
|
|
order: 1,
|
|
|
order: 0,
|
|
|
reload: true,
|
|
|
page: 1,
|
|
|
end: false
|
...
|
...
|
@@ -97,12 +99,6 @@ var $listNav = $('#list-nav'), |
|
|
hot: {
|
|
|
order: 1,
|
|
|
reload: true,
|
|
|
page: 1,
|
|
|
end: false
|
|
|
},
|
|
|
newest: {
|
|
|
order: 0,
|
|
|
reload: true,
|
|
|
page: 0,
|
|
|
end: false
|
|
|
},
|
...
|
...
|
@@ -117,6 +113,18 @@ var $listNav = $('#list-nav'), |
|
|
reload: true,
|
|
|
page: 0,
|
|
|
end: false
|
|
|
},
|
|
|
default: {
|
|
|
order: 0,
|
|
|
reload: true,
|
|
|
page: 0,
|
|
|
end: false
|
|
|
},
|
|
|
sale: {
|
|
|
order: 0,
|
|
|
reload: true,
|
|
|
page: 0,
|
|
|
end: false
|
|
|
}
|
|
|
},
|
|
|
$pre = $listNav.find('.active'), // 纪录进入筛选前的active项,初始为选中项
|
...
|
...
|
@@ -199,7 +207,7 @@ function getPageGoods(info) { |
|
|
url: info.url,
|
|
|
data: info.data,
|
|
|
success: function(data) {
|
|
|
if (data === ' ') {
|
|
|
if (data === '') {
|
|
|
nav.end = true;
|
|
|
}
|
|
|
|
...
|
...
|
@@ -324,7 +332,8 @@ var theY; |
|
|
* 筛选后内容变化,导致nav1位置错掉,重新计算确保位置正确显示
|
|
|
*/
|
|
|
function reNav1Pos() {
|
|
|
var sTop = theY ? theY : 0;
|
|
|
var sTop = theY ? theY : 0, tra;
|
|
|
|
|
|
if (sTop < imgH + main1oH + nav1H) {
|
|
|
if ($nav1.hasClass('hide')) {
|
|
|
$nav1.removeClass('hide');
|
...
|
...
|
@@ -385,6 +394,7 @@ function scrollHandler() { |
|
|
if (sTop + winH * 2 > scH) {
|
|
|
scrollCall = function() {
|
|
|
var translate = 'translate3d(0, ' + (-scH) + 'px, 0)';
|
|
|
|
|
|
$nav1.css({
|
|
|
transform: translate,
|
|
|
'-moz-transform': translate,
|
...
|
...
|
@@ -620,11 +630,15 @@ function search(opt) { |
|
|
|
|
|
// 导航类别
|
|
|
if ($pre.hasClass('new')) {
|
|
|
navType = 'newest';
|
|
|
navType = 'new';
|
|
|
} else if ($pre.hasClass('price')) {
|
|
|
navType = 'price';
|
|
|
} else if ($pre.hasClass('discount')) {
|
|
|
navType = 'discount';
|
|
|
} else if ($pre.hasClass('default')) {
|
|
|
navType = 'default';
|
|
|
} else if ($pre.hasClass('sale')) {
|
|
|
navType = 'sale';
|
|
|
}
|
|
|
nav = navInfo[navType];
|
|
|
|
...
|
...
|
@@ -668,7 +682,7 @@ function search(opt) { |
|
|
num;
|
|
|
|
|
|
switch (navType) {
|
|
|
case 'newest':
|
|
|
case 'new':
|
|
|
$container = $ngc;
|
|
|
break;
|
|
|
case 'price':
|
...
|
...
|
@@ -677,11 +691,17 @@ function search(opt) { |
|
|
case 'discount':
|
|
|
$container = $dgc;
|
|
|
break;
|
|
|
case 'default':
|
|
|
$container = $defaultgc;
|
|
|
break;
|
|
|
case 'sale':
|
|
|
$container = $sgc;
|
|
|
break;
|
|
|
default:
|
|
|
break;
|
|
|
}
|
|
|
|
|
|
if (data === ' ') {
|
|
|
if (data === '') {
|
|
|
nav.end = true;
|
|
|
|
|
|
if (nav.reload) {
|
...
|
...
|
@@ -722,10 +742,88 @@ function search(opt) { |
|
|
}
|
|
|
|
|
|
|
|
|
$listNav.bind('contextmenu', function(e) {
|
|
|
$listNav.bind('contextmenu', function() {
|
|
|
return false;
|
|
|
});
|
|
|
|
|
|
function newListHide() {
|
|
|
var $firstLi = $('ul.pos-list').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 = $('ul.pos-list').find('li.first-li-more');
|
|
|
|
|
|
e.preventDefault();
|
|
|
if ($(this).hasClass('new')) {
|
|
|
navType = 'new';
|
|
|
} else if ($(this).hasClass('default')) {
|
|
|
navType = 'default';
|
|
|
} else if ($(this).hasClass('sale')) {
|
|
|
navType = 'sale';
|
|
|
}
|
|
|
|
|
|
$newList.addClass('hide');
|
|
|
$firstLiDom.find('.spanTest').text($(this).text());
|
|
|
$firstLiDom.attr('data-bp-id', bpIdData).addClass('active').siblings().removeClass('active');
|
|
|
$subNav.find('.first-li-more').removeClass('new default sale').addClass(navType);
|
|
|
|
|
|
$(document).trigger('shouldSendBpData', [bpIdData]);
|
|
|
newListHide();
|
|
|
|
|
|
// 切换container显示
|
|
|
$goodsContainer.children('.container:not(.hide)').addClass('hide');
|
|
|
|
|
|
switch (navType) {
|
|
|
case 'new':
|
|
|
$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;
|
|
|
}
|
|
|
|
|
|
search({
|
|
|
type: 'shop_id',
|
|
|
id: shopId,
|
|
|
brand: brand,
|
|
|
appVersion: appVersion,
|
|
|
url: location.protocol + '//m.yohobuy.com/product/search/search',
|
|
|
nextPage: false
|
|
|
});
|
|
|
});
|
|
|
|
|
|
$(document).on('touchstart', function(e) {
|
|
|
if (!$newList.hasClass('hide') &&
|
|
|
$(e.target).closest('.new-list, li.first-li-more').length <= 0) {
|
|
|
$newList.addClass('hide');
|
|
|
newListHide();
|
|
|
}
|
|
|
});
|
|
|
|
|
|
$subNav.on('touchend touchcancel', function(e) {
|
|
|
var $this = $(e.target).closest('li'),
|
|
|
cname,
|
...
|
...
|
@@ -735,6 +833,24 @@ $subNav.on('touchend touchcancel', function(e) { |
|
|
var bpIdData = $this.attr('data-bp-id') || '';
|
|
|
|
|
|
e.preventDefault();
|
|
|
|
|
|
if ($this.hasClass('first-li-more')) {
|
|
|
filter.hideFilter();
|
|
|
$newList.removeClass('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();
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
// 最新li 列表
|
|
|
$newList.addClass('hide');
|
|
|
|
|
|
$(document).trigger('shouldSendBpData', [bpIdData]);
|
|
|
|
|
|
if (typeof $this === 'undefined' || $this.length === 0) {
|
...
|
...
|
@@ -772,13 +888,19 @@ $subNav.on('touchend touchcancel', function(e) { |
|
|
|
|
|
if ($this.hasClass('new')) {
|
|
|
cname = '.new';
|
|
|
navType = 'newest';
|
|
|
navType = 'new';
|
|
|
} else if ($this.hasClass('price')) {
|
|
|
cname = '.price';
|
|
|
navType = 'price';
|
|
|
} else if ($this.hasClass('discount')) {
|
|
|
cname = '.discount';
|
|
|
navType = 'discount';
|
|
|
} else if ($this.hasClass('hot')) {
|
|
|
cname = '.default';
|
|
|
navType = 'default';
|
|
|
} else if ($this.hasClass('sale')) {
|
|
|
cname = '.sale';
|
|
|
navType = 'sale';
|
|
|
}
|
|
|
|
|
|
myScroll && myScroll.enable();
|
...
|
...
|
@@ -803,7 +925,7 @@ $subNav.on('touchend touchcancel', function(e) { |
|
|
$goodsContainer.children('.container:not(.hide)').addClass('hide');
|
|
|
|
|
|
switch (navType) {
|
|
|
case 'newest':
|
|
|
case 'new':
|
|
|
$ngc.removeClass('hide');
|
|
|
break;
|
|
|
|
...
|
...
|
@@ -814,6 +936,14 @@ $subNav.on('touchend touchcancel', function(e) { |
|
|
case 'discount':
|
|
|
$dgc.removeClass('hide');
|
|
|
break;
|
|
|
|
|
|
case 'default':
|
|
|
$defaultgc.removeClass('hide');
|
|
|
break;
|
|
|
|
|
|
case 'sale':
|
|
|
$sgc.removeClass('hide');
|
|
|
break;
|
|
|
default:
|
|
|
break;
|
|
|
}
|
...
|
...
|
@@ -832,7 +962,7 @@ $subNav.on('touchend touchcancel', function(e) { |
|
|
$goodsContainer.children('.container:not(.hide)').addClass('hide');
|
|
|
|
|
|
switch (navType) {
|
|
|
case 'newest':
|
|
|
case 'new':
|
|
|
$ngc.removeClass('hide');
|
|
|
break;
|
|
|
|
...
|
...
|
@@ -843,6 +973,14 @@ $subNav.on('touchend touchcancel', function(e) { |
|
|
case 'discount':
|
|
|
$dgc.removeClass('hide');
|
|
|
break;
|
|
|
|
|
|
case 'default':
|
|
|
$defaultgc.removeClass('hide');
|
|
|
break;
|
|
|
|
|
|
case 'sale':
|
|
|
$sgc.removeClass('hide');
|
|
|
break;
|
|
|
default:
|
|
|
break;
|
|
|
}
|
...
|
...
|
@@ -885,7 +1023,7 @@ filter.initFilter({ |
|
|
missStatus: true
|
|
|
});
|
|
|
|
|
|
$listNav.on('touchstart', 'li', function(e) {
|
|
|
$listNav.on('touchstart', 'li', function() {
|
|
|
$(this).addClass('bytouch');
|
|
|
}).on('touchend touchcancel', function() {
|
|
|
$listNav.find('li').removeClass('bytouch');
|
...
|
...
|
@@ -893,7 +1031,7 @@ $listNav.on('touchstart', 'li', function(e) { |
|
|
// myScroll && myScroll.refresh();
|
|
|
});
|
|
|
|
|
|
$nav2.on('touchstart', 'li', function(e) {
|
|
|
$nav2.on('touchstart', 'li', function() {
|
|
|
$(this).addClass('bytouch');
|
|
|
}).on('touchend touchcancel', function() {
|
|
|
$nav2.find('li').removeClass('bytouch');
|
...
|
...
|
@@ -929,6 +1067,7 @@ $nav2.on('touchstart', 'li', function(e) { |
|
|
|
|
|
$('.shop-foot-wrapper .buriedpoint').click(function() {
|
|
|
var subGroup = $(this).find('.sub-group');
|
|
|
|
|
|
if (subGroup.hasClass('hide')) {
|
|
|
subGroup.removeClass('hide');
|
|
|
} else {
|
...
|
...
|
@@ -953,7 +1092,7 @@ $collect.on('touchstart', function() { |
|
|
|
|
|
$.ajax({
|
|
|
method: 'get',
|
|
|
url: location.protocol + '//m.yohobuy.com' + '/product/opt/favoriteBrand',
|
|
|
url: location.protocol + '//m.yohobuy.com/product/opt/favoriteBrand',
|
|
|
data: {
|
|
|
id: favId ? favId : shopId,
|
|
|
appVersion: appVersion,
|
...
|
...
|
|