Authored by 王水玲

sale

... ... @@ -35,7 +35,8 @@ const typeCont = {
price: ['s_p_desc', 's_p_asc'],
discount: ['p_d_desc', 'p_d_asc'],
sales: ['s_n_desc', 's_n_asc'],
newest: ['s_t_desc', 's_t_asc']
newest: ['s_t_desc', 's_t_asc'],
stock: ['s_s_desc', 's_s_asc']
};
/**
... ... @@ -248,9 +249,57 @@ const processProductList = (list, options) => {
*/
const processFilter = (list, options) => {
const filters = {
classify: {}
classify: []
};
const filtersType = {
brand: {
name: '所有品牌',
title: '品牌',
dataId: 'id',
subsName: 'brandName'
},
color: {
name: '所有颜色',
title: '颜色',
dataId: 'colorId',
subsName: 'colorName'
},
discount: {
name: '所有商品',
title: '折扣',
dataId: 'key',
subsName: 'name'
},
gender: {
name: '所有性别',
title: '性别',
dataId: 'key',
subsName: 'flag'
},
groupSort: {
name: '所有品类',
title: '品类',
dataId: 'relationParameter',
subsName: 'categoryName'
},
priceRange: {
name: '所有价格',
title: '价格',
dataId: 'key',
subsName: 'flag'
},
size: {
name: '所有尺码',
title: '尺码',
dataId: 'sizeId',
subsName: 'sizeName'
}
};
let subs = {};
let classify = {};
options = Object.assign({
gender: '1,2,3', // 默认选择的性别,默认1,2,3表示所有
exclude: null // 需要排除的字段
... ... @@ -258,8 +307,33 @@ const processFilter = (list, options) => {
list = camelCase(list);
_.forEach(list, (item, key) => {
console.log(key);
if (key === 'group_sort') {
return;
}
classify.dataType = key;
classify.name = filtersType[key].name;
classify.title = filtersType[key].typeCont;
_.forEach(item, (sub, index) => {
if (filtersType[key].dataId === 'key') {
subs.dataId = index;
} else if (filtersType[key].dataId === 'relationParameter') {
subs.dataId = item.relationParameter.sort;
} else {
subs.dataId = item[filtersType[key].dataId];
}
if (filtersType[key].subsName === 'flag') {
subs.name = index;
} else {
subs.name = sub[filtersType[key].subsName];
}
classify.subs.push(subs)
});
filters.classify.push(classify);
});
return filters;
};
... ...
... ... @@ -31,28 +31,24 @@ var $listNav = $('#list-nav'),
// 导航数据信息
navInfo = {
coat: {
order: 1,
reload: true,
page: 0,
end: false,
saleType: 1
},
trouser: {
order: 1,
reload: true,
page: 0,
end: false,
saleType: 1
},
shoes: {
order: 1,
reload: true,
page: 0,
end: false,
saleType: 1
},
other: {
order: 1,
reload: true,
page: 0,
end: false,
... ... @@ -89,12 +85,14 @@ $.each($listNav.find('li'), function(key, item) {
*/
function search(opt) {
var setting = {},
ext = [],
ext = {},
att,
nav, navType,
page,
i;
delete defaultOpt.size;
if (searching) {
return;
}
... ... @@ -150,8 +148,6 @@ function search(opt) {
}
$.extend(defaultOpt, ext); // 扩展筛选项
console.log(defaultOpt);
}
... ... @@ -177,8 +173,8 @@ function search(opt) {
}
$.extend(setting, defaultOpt, {
type: navType,
order: nav.order,
type: 'stock',
order: 0,
page: page
});
... ... @@ -319,7 +315,6 @@ $listNav.on('touchend touchcancel', function(e) {
nav = navInfo[navType];
if ($this.hasClass('active')) {
nav.reload = true;
return;
} else {
$active = $this.siblings('.active');
... ... @@ -396,12 +391,11 @@ $swiperSize.on('touchend touchcancel', function(e) {
nav = navInfo[navType];
if ($this.hasClass('active')) {
nav.reload = true;
return;
} else {
nav.reload = true;
$active = $this.siblings('.active');
$pre = $this; // $pre为除筛选导航的其他导航项,若当前active的为筛选,则把$pre置为当前点击项
$pre = $parentType; // $pre为除筛选导航的其他导航项,若当前active的为筛选,则把$pre置为当前点击项
$active.removeClass('active');
$this.addClass('active');
... ...