|
|
/**
|
|
|
* 折扣专区
|
|
|
* @author: liangzhifeng<zhifeng.liang@yoho.cn>
|
|
|
* @date: 2015/10/23
|
|
|
* 商品列表页
|
|
|
* @author: xuqi<qi.xu@yoho.cn>
|
|
|
* @date: 2015/10/20
|
|
|
*/
|
|
|
|
|
|
var $ = require('yoho.zepto'),
|
|
|
Swiper = require('yoho.iswiper'),
|
|
|
lazyLoad = require('yoho.zeptolazyload');
|
|
|
|
|
|
var swiper;
|
|
|
|
|
|
var filter = require('../../plugin/filter');
|
|
|
|
|
|
var $goodsContainer = $('#goods-container'),
|
|
|
$ngc = $($goodsContainer.children().get(0)),
|
|
|
$pgc = $($goodsContainer.children().get(1)),
|
|
|
$dgc = $($goodsContainer.children().get(2)),
|
|
|
$all = $($goodsContainer.children().get(3));
|
|
|
$ngc = $goodsContainer.children('.new-goods'),
|
|
|
$pgc = $goodsContainer.children('.price-goods'),
|
|
|
$dgc = $goodsContainer.children('.discount-goods');
|
|
|
|
|
|
var winH = $(window).height();
|
|
|
|
...
|
...
|
@@ -25,35 +27,26 @@ var defaultOpt = { |
|
|
color: $('#color').val(),
|
|
|
size: $('#size').val(),
|
|
|
price: $('#price').val(),
|
|
|
discount: $('#discount').val(),
|
|
|
limit: $('#limit').val(),
|
|
|
channel: $('#channel').val(),
|
|
|
p_d: $('#p_d').val()
|
|
|
discount: $('#discount').val()
|
|
|
};
|
|
|
|
|
|
var $listNav = $('#list-nav'),
|
|
|
|
|
|
//导航数据信息
|
|
|
navInfo = {
|
|
|
discount13: {
|
|
|
order: 0,
|
|
|
reload: true,
|
|
|
page: 0,
|
|
|
end: false
|
|
|
},
|
|
|
discount46: {
|
|
|
order: 0,
|
|
|
newest: {
|
|
|
order: 1,
|
|
|
reload: true,
|
|
|
page: 0,
|
|
|
end: false
|
|
|
},
|
|
|
discount79: {
|
|
|
price: {
|
|
|
order: 0,
|
|
|
reload: true,
|
|
|
page: 0,
|
|
|
end: false
|
|
|
},
|
|
|
all: {
|
|
|
discount: {
|
|
|
order: 0,
|
|
|
reload: true,
|
|
|
page: 0,
|
...
|
...
|
@@ -63,9 +56,10 @@ var $listNav = $('#list-nav'), |
|
|
$pre, //纪录进入筛选前的active项
|
|
|
searching;
|
|
|
|
|
|
$pgc.addClass('hide');
|
|
|
$dgc.addClass('hide');
|
|
|
$all.addClass('hide');
|
|
|
swiper = new Swiper('.swiper-container', {
|
|
|
lazyLoading: true,
|
|
|
pagination: '.swiper-pagination'
|
|
|
});
|
|
|
|
|
|
/**
|
|
|
* 筛选注册的回调,筛选子项点击后逻辑
|
...
|
...
|
@@ -128,21 +122,6 @@ function search(opt) { |
|
|
discount: opt.id
|
|
|
};
|
|
|
break;
|
|
|
case 'limit':
|
|
|
ext = {
|
|
|
limit: opt.id
|
|
|
};
|
|
|
break;
|
|
|
case 'channel':
|
|
|
ext = {
|
|
|
channel: opt.id
|
|
|
};
|
|
|
break;
|
|
|
case 'p_d':
|
|
|
ext = {
|
|
|
p_d: opt.id
|
|
|
};
|
|
|
break;
|
|
|
}
|
|
|
|
|
|
$.extend(defaultOpt, ext); //扩展筛选项
|
...
|
...
|
@@ -153,14 +132,12 @@ function search(opt) { |
|
|
}
|
|
|
|
|
|
//导航类别
|
|
|
if ($pre === undefined || $pre.hasClass('discount13')) {
|
|
|
navType = 'discount13';
|
|
|
} else if ($pre.hasClass('discount46')) {
|
|
|
navType = 'discount46';
|
|
|
} else if ($pre.hasClass('discount79')) {
|
|
|
navType = 'discount79';
|
|
|
} else if ($pre.hasClass('all')) {
|
|
|
navType = 'all';
|
|
|
if ($pre === undefined || $pre.hasClass('new')) {
|
|
|
navType = 'newest';
|
|
|
} else if ($pre.hasClass('price')) {
|
|
|
navType = 'price';
|
|
|
} else if ($pre.hasClass('discount')) {
|
|
|
navType = 'discount';
|
|
|
}
|
|
|
|
|
|
nav = navInfo[navType];
|
...
|
...
|
@@ -175,6 +152,7 @@ function search(opt) { |
|
|
}
|
|
|
|
|
|
$.extend(setting, defaultOpt, {
|
|
|
type: navType,
|
|
|
order: nav.order,
|
|
|
page: page
|
|
|
});
|
...
|
...
|
@@ -190,18 +168,15 @@ function search(opt) { |
|
|
$container;
|
|
|
|
|
|
switch (navType) {
|
|
|
case 'discount13':
|
|
|
case 'newest':
|
|
|
$container = $ngc;
|
|
|
break;
|
|
|
case 'discount46':
|
|
|
case 'price':
|
|
|
$container = $pgc;
|
|
|
break;
|
|
|
case 'discount79':
|
|
|
case 'discount':
|
|
|
$container = $dgc;
|
|
|
break;
|
|
|
case 'all':
|
|
|
$container = $all;
|
|
|
break;
|
|
|
}
|
|
|
|
|
|
if (data === ' ') {
|
...
|
...
|
@@ -264,26 +239,31 @@ $listNav.delegate('li', 'touchstart', function() { |
|
|
}
|
|
|
} else {
|
|
|
|
|
|
if ($this.hasClass('discount13')) {
|
|
|
navType = 'discount13';
|
|
|
} else if ($this.hasClass('discount46')) {
|
|
|
navType = 'discount46';
|
|
|
} else if ($this.hasClass('discount79')) {
|
|
|
navType = 'discount79';
|
|
|
} else if ($this.hasClass('all')) {
|
|
|
navType = 'all';
|
|
|
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')) {
|
|
|
|
|
|
// 折扣切换排序状态
|
|
|
$this.find('.icon > .iconfont').toggleClass('cur');
|
|
|
$pre = $this;
|
|
|
nav.reload = true; //重置reload,HTML会被替换为逆序的HTML
|
|
|
nav.order = nav.order === 0 ? 1 : 0; //切换排序
|
|
|
//最新无排序切换
|
|
|
if ($this.hasClass('new')) {
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
if ($this.hasClass('price') || $this.hasClass('discount')) {
|
|
|
|
|
|
// 价格/折扣切换排序状态
|
|
|
$this.find('.icon > .iconfont').toggleClass('cur');
|
|
|
$pre = $this; //更新pre为当前项
|
|
|
nav.reload = true; //重置reload,HTML会被替换为逆序的HTML
|
|
|
nav.order = nav.order === 0 ? 1 : 0; //切换排序
|
|
|
}
|
|
|
} else {
|
|
|
$active = $this.siblings('.active');
|
|
|
|
...
|
...
|
@@ -299,19 +279,15 @@ $listNav.delegate('li', 'touchstart', function() { |
|
|
$goodsContainer.children('.container:not(.hide)').addClass('hide');
|
|
|
|
|
|
switch (navType) {
|
|
|
case 'discount13':
|
|
|
case 'newest':
|
|
|
$ngc.removeClass('hide');
|
|
|
break;
|
|
|
|
|
|
case 'discount46':
|
|
|
case 'price':
|
|
|
$pgc.removeClass('hide');
|
|
|
break;
|
|
|
|
|
|
case 'discount79':
|
|
|
$dgc.removeClass('hide');
|
|
|
break;
|
|
|
|
|
|
case 'all':
|
|
|
case 'discount':
|
|
|
$dgc.removeClass('hide');
|
|
|
break;
|
|
|
}
|
...
|
...
|
@@ -334,4 +310,5 @@ $(window).scroll(function() { |
|
|
$(document).height() - 0.25 * $goodsContainer.height()) {
|
|
|
search();
|
|
|
}
|
|
|
}); |
|
|
\ No newline at end of file |
|
|
}); |
|
|
|
|
|
\ No newline at end of file |
...
|
...
|
|