Authored by xuqi

filter in newsale

... ... @@ -17,13 +17,6 @@ var missStatus; //是否忽略选中状态
//隐藏筛选界面
function hideFilter() {
$filter.addClass('hide');
if (missStatus) {
//重置一级筛选项选中状态
$filter.find('.classify-item.active').removeClass('active');
$filter.find('.classify-item:first-child').addClass('active');
}
}
//显示筛选界面
... ... @@ -31,6 +24,7 @@ function showFilter() {
$filter.removeClass('hide');
}
//主筛选项Tap事件句柄
function classifyTapEvt($this) {
if ($this.hasClass('active')) {
return;
... ... @@ -41,9 +35,8 @@ function classifyTapEvt($this) {
$this.addClass('active');
}
function subClassifyTapEvt($this) {
var id = $this.data('id');
//子筛选项选中处理
function setSubClassify($this) {
var $sub = $this.closest('.sub-classify');
var $shower = $sub.siblings('.shower');
... ... @@ -72,6 +65,17 @@ function subClassifyTapEvt($this) {
$shower.removeClass('default');
}
return $sub;
}
//子筛选项Tap句柄
function subClassifyTapEvt($this) {
var id = $this.data('id');
var $sub;
$sub = setSubClassify($this);
if (fCbFn) {
fCbFn({
type: $sub.data('type'),
... ... @@ -80,12 +84,6 @@ function subClassifyTapEvt($this) {
}
hideFilter();
//重置选中状态
if (missStatus) {
$this.removeClass('chosed');
$sub.children(':first-child').addClass('chosed');
}
}
//初始化筛选
... ... @@ -133,8 +131,25 @@ function initFilter(opt) {
});
}
//重置筛选面板
function resetFilter() {
if (typeof $filter === 'undefined') {
return;
}
//重置子筛选项
$('.sub-classify').each(function() {
setSubClassify($(this).children(':first-child'));
});
//重置主筛选项
classifyTapEvt($('.classify > :first-child'));
}
exports.initFilter = initFilter;
exports.showFilter = showFilter;
exports.hideFilter = hideFilter;
exports.resetFilter = resetFilter;
\ No newline at end of file
... ...
... ... @@ -41,6 +41,8 @@ var defaultOpt = {
dayLimit: 1
};
var storeOpt = $.extend({}, defaultOpt); //存储默认筛选条件以便重置
var now = new Date(),
month = now.getMonth() + 1,
date = now.getDate();
... ... @@ -267,8 +269,7 @@ $.ajax({
//切换active状态到$pre上
$pre.addClass('active');
$pre.siblings('.filter').removeClass('active');
},
missStatus: true
}
});
}
});
... ... @@ -343,6 +344,10 @@ navHammer.on('tap', function(e) {
$dgc.removeClass('hide');
break;
}
//重置筛选项
filter.resetFilter();
defaultOpt = $.extend({}, storeOpt);
}
$active.removeClass('active');
... ...