Authored by xuqi

product list

... ... @@ -749,6 +749,13 @@
],
filter: {
.. //筛选数据结构
}
},
brand: '',
gender: '',
msort: '',
color: '',
size: '',
price: '',
discount: ''
}
}
\ No newline at end of file
... ...
... ... @@ -208,6 +208,7 @@ filter.registerCbFn(search);
//5.当前active为筛选并且点击其他项时,隐藏筛选面板
$listNav.delegate('li', 'touchstart', function() {
var $this = $(this),
nav,
navType,
$active;
... ... @@ -229,6 +230,17 @@ $listNav.delegate('li', 'touchstart', function() {
filter.showFilter();
}
} else {
if ($this.hasClass('new')) {
navType = 'newest';
} else if ($this.hasClass('price')) {
navType = 'price';
} else if ($this.hasClass('discount')) {
navType = 'discount';
}
nav = navInfo[navType];
if ($this.hasClass('active')) {
//最新无排序切换
... ... @@ -240,35 +252,44 @@ $listNav.delegate('li', 'touchstart', function() {
// 价格/折扣切换排序状态
$this.find('.icon > .iconfont').toggleClass('cur');
$pre = $active; //更新pre为当前项
$pre = $this; //更新pre为当前项
nav.reload = true; //重置reload,HTML会被替换为逆序的HTML
nav.order = nav.order === 0 ? 1 : 0; //切换排序
}
} else {
$active = $this.siblings('.active');
$pre = $this; //$pre为除筛选导航的其他导航项,若当前active的为筛选,则把$pre置为当前点击项
if ($active.hasClass('filter')) {
$pre = $this; //$pre为除筛选导航的其他导航项,若当前active的为筛选,则把$pre置为当前点击项
//若之前active项为筛选,则隐藏筛选面板
filter.hideFilter();
} else {
$pre = $active;
//切换container显示
$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;
}
}
$active.removeClass('active');
$this.addClass('active');
$pre = $active;
}
if ($this.hasClass('new')) {
navType = 'newest';
} else if ($this.hasClass('price')) {
navType = 'price';
} else if ($this.hasClass('discount')) {
navType = 'discount';
}
if (navInfo[navType].reload) {
if (nav.reload) {
search();
}
}
... ...
... ... @@ -82,17 +82,44 @@
</li>
</ul>
<div id="goods-container" class="goods-container">
<div class="new-goods">
<div class="new-goods container">
{{# new}}
{{> good}}
{{/ new}}
</div>
<div class="price-goods hide"></div>
<div class="discount-goods hide"></div>
<div class="price-goods container hide"></div>
<div class="discount-goods container hide"></div>
{{> filter}}
</div>
{{#if brand}}
<input id="brand" type="hidden" value={{brand}}>
{{/if}}
{{#if gender}}
<input id="gender" type="hidden" value={{gender}}>
{{/if}}
{{#if msort}}
<input id="msort" type="hidden" value={{msort}}>
{{/if}}
{{#if color}}
<input id="color" type="hidden" value={{color}}>
{{/if}}
{{#if size}}
<input id="size" type="hidden" value={{size}}>
{{/if}}
{{#if price}}
<input id="price" type="hidden" value={{price}}>
{{/if}}
{{#if discount}}
<input id="discount" type="hidden" value={{discount}}>
{{/if}}
{{/ goodList}}
</div>
{{> layout/footer}}
\ No newline at end of file
... ...