...
|
...
|
@@ -6,17 +6,22 @@ |
|
|
|
|
|
var $ = require('jquery'),
|
|
|
Swiper = require('yoho.iswiper'),
|
|
|
Hammer = require('hammer'),
|
|
|
lazyLoad = require('yoho.lazyload');
|
|
|
|
|
|
var swiper;
|
|
|
var swiper,
|
|
|
$ngc,
|
|
|
$pgc,
|
|
|
$dgc;
|
|
|
|
|
|
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)).addClass('hide'),
|
|
|
$dgc = $($goodsChildren.get(2)).addClass('hide');
|
|
|
|
|
|
var winH = $(window).height(),
|
|
|
noResult = '<p class="no-result">未找到相关搜索结果</p>';
|
...
|
...
|
@@ -60,11 +65,9 @@ var $listNav = $('#list-nav'), |
|
|
}
|
|
|
},
|
|
|
$pre = $listNav.find('.active'), //纪录进入筛选前的active项,初始为选中项
|
|
|
navHammer,
|
|
|
searching;
|
|
|
|
|
|
$pgc.addClass('hide');
|
|
|
$dgc.addClass('hide');
|
|
|
|
|
|
$('#today a').text(month + '月' + date + '号');
|
|
|
|
|
|
if ($('.swiper-container .swiper-slide').length > 1) {
|
...
|
...
|
@@ -92,6 +95,10 @@ function search(opt) { |
|
|
dayLimit,
|
|
|
page;
|
|
|
|
|
|
if (searching) {
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
if (opt) {
|
|
|
|
|
|
//筛选项变更则重置reload为true
|
...
|
...
|
@@ -161,10 +168,6 @@ function search(opt) { |
|
|
$.extend(defaultOpt, ext); //扩展筛选项
|
|
|
}
|
|
|
|
|
|
if (searching) {
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
//导航类别
|
|
|
if ($pre.hasClass('today')) {
|
|
|
navType = 'today';
|
...
|
...
|
@@ -201,7 +204,8 @@ function search(opt) { |
|
|
url: '/product/newsale/selectNewSale',
|
|
|
data: setting,
|
|
|
success: function(data) {
|
|
|
var $container;
|
|
|
var $container,
|
|
|
num;
|
|
|
|
|
|
switch (navType) {
|
|
|
case 'today':
|
...
|
...
|
@@ -224,11 +228,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;
|
...
|
...
|
@@ -241,9 +249,27 @@ function search(opt) { |
|
|
|
|
|
}
|
|
|
|
|
|
lazyLoad($('.lazy'));
|
|
|
$.ajax({
|
|
|
type: 'GET',
|
|
|
url: '/product/newsale/filter',
|
|
|
data: defaultOpt,
|
|
|
success: function(data) {
|
|
|
$goodsContainer.append(data);
|
|
|
|
|
|
filter.registerCbFn(search);
|
|
|
//初始化filter&注册filter回调
|
|
|
filter.initFilter({
|
|
|
fCbFn: search,
|
|
|
hCbFn: function() {
|
|
|
|
|
|
//切换active状态到$pre上
|
|
|
$pre.addClass('active');
|
|
|
$pre.siblings('.filter').removeClass('active');
|
|
|
},
|
|
|
missStatus: true
|
|
|
});
|
|
|
}
|
|
|
});
|
|
|
lazyLoad($('.lazy'));
|
|
|
|
|
|
//导航栏点击逻辑说明:
|
|
|
//1.点击非active项时切换active状态
|
...
|
...
|
@@ -251,9 +277,9 @@ filter.registerCbFn(search); |
|
|
//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;
|
...
|
...
|
|