...
|
...
|
@@ -6,6 +6,7 @@ |
|
|
|
|
|
var $ = require('jquery'),
|
|
|
Swiper = require('yoho.iswiper'),
|
|
|
Hammer = require('hammer'),
|
|
|
lazyLoad = require('yoho.lazyload');
|
|
|
|
|
|
var swiper;
|
...
|
...
|
@@ -14,9 +15,10 @@ var filter = require('../../plugin/filter'); |
|
|
var loading = require('../../plugin/loading');
|
|
|
|
|
|
var $goodsContainer = $('#goods-container'),
|
|
|
$ngc = $($goodsContainer.children().get(0)),
|
|
|
$pgc = $($goodsContainer.children().get(1)),
|
|
|
$dgc = $($goodsContainer.children().get(2));
|
|
|
$goodsChildren = $goodsContainer.children(),
|
|
|
$ngc = $($goodsChildren.get(0)),
|
|
|
$pgc = $($goodsChildren.get(1)),
|
|
|
$dgc = $($goodsChildren.get(2));
|
|
|
|
|
|
var winH = $(window).height(),
|
|
|
noResult = '<p class="no-result">未找到相关搜索结果</p>';
|
...
|
...
|
@@ -56,6 +58,7 @@ var $listNav = $('#list-nav'), |
|
|
}
|
|
|
},
|
|
|
$pre = $listNav.find('.active'), //纪录进入筛选前的active项,初始为选中项
|
|
|
navHammer,
|
|
|
searching;
|
|
|
|
|
|
if ($('.swiper-container .swiper-slide').length > 1) {
|
...
|
...
|
@@ -82,6 +85,10 @@ function search(opt) { |
|
|
nav, navType,
|
|
|
page;
|
|
|
|
|
|
if (searching) {
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
if (opt) {
|
|
|
|
|
|
//筛选项变更则重置reload为true
|
...
|
...
|
@@ -136,9 +143,6 @@ function search(opt) { |
|
|
$.extend(defaultOpt, ext); //扩展筛选项
|
|
|
}
|
|
|
|
|
|
if (searching) {
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
//导航类别
|
|
|
if ($pre.hasClass('new')) {
|
...
|
...
|
@@ -174,7 +178,8 @@ function search(opt) { |
|
|
url: '/product/newsale/selectNewSale',
|
|
|
data: setting,
|
|
|
success: function(data) {
|
|
|
var $container;
|
|
|
var $container,
|
|
|
num;
|
|
|
|
|
|
switch (navType) {
|
|
|
case 'newest':
|
...
|
...
|
@@ -197,11 +202,15 @@ function search(opt) { |
|
|
} else {
|
|
|
if (nav.reload) {
|
|
|
$container.html(data);
|
|
|
lazyLoad($container.find('.lazy'));
|
|
|
} else {
|
|
|
num = $container.find('.good-info').length;
|
|
|
$container.append(data);
|
|
|
|
|
|
//lazy good-infos who append in
|
|
|
lazyLoad($container.find('.good-info:gt(' + (num - 1) + ') .lazy'));
|
|
|
}
|
|
|
|
|
|
lazyLoad($container.find('.lazy'));
|
|
|
}
|
|
|
|
|
|
nav.reload = false;
|
...
|
...
|
@@ -214,19 +223,37 @@ function search(opt) { |
|
|
|
|
|
}
|
|
|
|
|
|
$.ajax({
|
|
|
type: 'GET',
|
|
|
url: '/newArrival/filter',
|
|
|
data: defaultOpt,
|
|
|
success: function(data) {
|
|
|
$goodsContainer.append(data);
|
|
|
|
|
|
//初始化filter&注册filter回调
|
|
|
filter.initFilter({
|
|
|
fCbFn: search,
|
|
|
hCbFn: function() {
|
|
|
|
|
|
//切换active状态到$pre上
|
|
|
$pre.addClass('active');
|
|
|
$pre.siblings('.filter').removeClass('active');
|
|
|
},
|
|
|
missStatus: true
|
|
|
});
|
|
|
}
|
|
|
});
|
|
|
lazyLoad($('.lazy'));
|
|
|
|
|
|
filter.registerCbFn(search);
|
|
|
|
|
|
// loading.initLoadingMask();
|
|
|
//导航栏点击逻辑说明:
|
|
|
//1.点击非active项时切换active状态
|
|
|
//2.价格和折扣active状态时继续点击切换排序
|
|
|
//3.筛选无active时点击展开筛选面板
|
|
|
//4.筛选有active时点击隐藏筛选面板并恢复点击筛选前active项的active状态
|
|
|
//5.当前active为筛选并且点击其他项时,隐藏筛选面板
|
|
|
$listNav.delegate('li', 'touchstart', function() {
|
|
|
var $this = $(this),
|
|
|
navHammer = new Hammer($listNav[0]);
|
|
|
navHammer.on('tap', function(e) {
|
|
|
var $this = $(e.target).closest('li'),
|
|
|
nav,
|
|
|
navType,
|
|
|
$active;
|
...
|
...
|
|