Authored by 郭成尧

解决尺码处理重复问题

... ... @@ -2,7 +2,7 @@
* @Author: Targaryen
* @Date: 2016-06-02 15:50:47
* @Last Modified by: Targaryen
* @Last Modified time: 2016-06-20 21:32:00
* @Last Modified time: 2016-06-22 17:32:39
*/
'use strict';
... ... @@ -39,15 +39,15 @@ const handleFilterUrl = (originParam, newParam) => {
const handleSaleNewSaleSortData = (params) => {
return [{
name: '1~3折',
href: handleFilterUrl(params, {p_d: '0.1,0.3'}),
href: handleFilterUrl(params, { p_d: '0.1,0.3' }),
checked: params.p_d === '0.1,0.3'
}, {
name: '4~6折',
href: handleFilterUrl(params, {p_d: '0.4,0.6'}),
href: handleFilterUrl(params, { p_d: '0.4,0.6' }),
checked: params.p_d === '0.4,0.6'
}, {
name: '7折以上',
href: handleFilterUrl(params, {p_d: '0.7,1'}),
href: handleFilterUrl(params, { p_d: '0.7,1' }),
checked: params.p_d === '0.7,1'
}];
};
... ... @@ -217,7 +217,7 @@ exports.handleSaleOptsData = (params, total, extra) => {
switch (i) {
case 0:
opt.href = handleFilterUrl(params, {order: 's_t_desc'});
opt.href = handleFilterUrl(params, { order: 's_t_desc' });
if (extra === 'discont') { // 如果是折扣专场
opt.name = '全部';
if (_.isEmpty(params.order) || params.order === 's_t_desc') {
... ... @@ -238,16 +238,16 @@ exports.handleSaleOptsData = (params, total, extra) => {
break;
case 1:
if (params.order !== 's_p_desc' && params.order !== 's_p_asc') {
opt.href = handleFilterUrl(params, {order: 's_p_desc'});
opt.href = handleFilterUrl(params, { order: 's_p_desc' });
opt.hasSortOrient = true;
} else {
opt.hasSortOrient = true;
opt.active = true;
if (params.order === 's_p_desc') {
opt.href = handleFilterUrl(params, {order: 's_p_asc'});
opt.href = handleFilterUrl(params, { order: 's_p_asc' });
opt.desc = false;
} else {
opt.href = handleFilterUrl(params, {order: 's_p_desc'});
opt.href = handleFilterUrl(params, { order: 's_p_desc' });
opt.desc = true;
}
}
... ... @@ -256,16 +256,16 @@ exports.handleSaleOptsData = (params, total, extra) => {
break;
case 2:
if (params.order !== 'p_d_desc' && params.order !== 'p_d_asc') {
opt.href = handleFilterUrl(params, {order: 'p_d_desc'});
opt.href = handleFilterUrl(params, { order: 'p_d_desc' });
opt.hasSortOrient = true;
} else {
opt.hasSortOrient = true;
opt.active = true;
if (params.order === 'p_d_desc') {
opt.href = handleFilterUrl(params, {order: 'p_d_asc'});
opt.href = handleFilterUrl(params, { order: 'p_d_asc' });
opt.desc = false;
} else {
opt.href = handleFilterUrl(params, {order: 'p_d_desc'});
opt.href = handleFilterUrl(params, { order: 'p_d_desc' });
opt.desc = true;
}
}
... ... @@ -274,16 +274,16 @@ exports.handleSaleOptsData = (params, total, extra) => {
break;
case 3:
if (params.order !== 's_n_desc' && params.order !== 's_n_asc') {
opt.href = handleFilterUrl(params, {order: 's_n_desc'});
opt.href = handleFilterUrl(params, { order: 's_n_desc' });
opt.hasSortOrient = true;
} else {
opt.hasSortOrient = true;
opt.active = true;
if (params.order === 's_n_desc') {
opt.href = handleFilterUrl(params, {order: 's_n_asc'});
opt.href = handleFilterUrl(params, { order: 's_n_asc' });
opt.desc = false;
} else {
opt.href = handleFilterUrl(params, {order: 's_n_desc'});
opt.href = handleFilterUrl(params, { order: 's_n_desc' });
opt.desc = true;
}
}
... ... @@ -299,13 +299,13 @@ exports.handleSaleOptsData = (params, total, extra) => {
// 上下翻页数据处理
dest.pageCounts = [{
href: handleFilterUrl(params, {limit: 200}),
href: handleFilterUrl(params, { limit: 200 }),
count: 200
}, {
href: handleFilterUrl(params, {limit: 100}),
href: handleFilterUrl(params, { limit: 100 }),
count: 100
}, {
href: handleFilterUrl(params, {limit: 60}),
href: handleFilterUrl(params, { limit: 60 }),
count: 60
}];
... ... @@ -327,12 +327,12 @@ exports.handleSaleOptsData = (params, total, extra) => {
if (dest.pageCount > 1 && (parseInt(params.page, 10) !== 1) &&
(parseInt(params.page, 10) !== dest.pageCount)) {
dest.preHref = handleFilterUrl(params, {page: preHref});
dest.nextHref = handleFilterUrl(params, {page: nextHref});
dest.preHref = handleFilterUrl(params, { page: preHref });
dest.nextHref = handleFilterUrl(params, { page: nextHref });
} else if (dest.pageCount > 1 && (parseInt(params.page, 10) === 1)) {
dest.nextHref = handleFilterUrl(params, {page: nextHref});
dest.nextHref = handleFilterUrl(params, { page: nextHref });
} else if (dest.pageCount > 1 && (parseInt(params.page, 10) === dest.pageCount)) {
dest.preHref = handleFilterUrl(params, {page: preHref});
dest.preHref = handleFilterUrl(params, { page: preHref });
}
// 全部商品数
... ... @@ -390,7 +390,7 @@ exports.handleSaleSortData = (origin, params, extra) => {
name: value.category_name,
num: value.node_count,
childList: [],
href: handleFilterUrl(params, {sort: value.relation_parameter.sort}),
href: handleFilterUrl(params, { sort: value.relation_parameter.sort }),
active: params.sort === value.relation_parameter.sort
};
... ... @@ -398,7 +398,7 @@ exports.handleSaleSortData = (origin, params, extra) => {
category.childList.push({
name: subValue.category_name,
num: subValue.node_count,
href: handleFilterUrl(params, {sort: subValue.relation_parameter.sort}),
href: handleFilterUrl(params, { sort: subValue.relation_parameter.sort }),
childActive: params.sort === subValue.relation_parameter.sort
});
if (params.sort === subValue.relation_parameter.sort) {
... ... @@ -424,16 +424,13 @@ exports.handleSaleFilterData = (origin, params) => {
brand: {
default: [],
brandsShow: [],
brandIndex: [
{
brandIndex: [{
index: 'all',
name: '全部'
},
{
}, {
index: '0-9',
name: '0~9'
}
],
}],
showMore: true,
showMulti: true
},
... ... @@ -468,7 +465,7 @@ exports.handleSaleFilterData = (origin, params) => {
checked: (typeof _.find(intBrands, o => {
return _.isEqual(o, value.id);
}) !== 'undefined'),
href: handleFilterUrl(params, {brand: value.id}),
href: handleFilterUrl(params, { brand: value.id }),
name: value.brand_name,
key: value.brand_domain,
id: value.id
... ... @@ -503,7 +500,7 @@ exports.handleSaleFilterData = (origin, params) => {
_.forEach(origin.priceRange, (value, key) => {
let price = {
checked: params.price === key,
href: handleFilterUrl(params, {price: key}),
href: handleFilterUrl(params, { price: key }),
name: value
};
... ... @@ -515,29 +512,28 @@ exports.handleSaleFilterData = (origin, params) => {
if (!priceRangechecked && params.price) {
let customPrice = _.split(params.price, ',');
if (customPrice[1] !== '99999') {
dest.customPrice = {
min: customPrice[0],
max: customPrice[1]
};
dest.checkedConditions.conditions.push({
name: '¥ ' + customPrice[0] + '-' + customPrice[1],
href: handleFilterUrl(params, {price: ''})
href: handleFilterUrl(params, { price: '' })
});
}
}
// 处理性别数据
dest.gender = [
{
dest.gender = [{
name: 'BOYS',
href: handleFilterUrl(params, {gender: '1,3'}),
href: handleFilterUrl(params, { gender: '1,3' }),
checked: params.gender === '1,3'
},
{
}, {
name: 'GIRLS',
href: handleFilterUrl(params, {gender: '2,3'}),
href: handleFilterUrl(params, { gender: '2,3' }),
checked: params.gender === '2,3'
}
];
}];
// 最新降价数据处理
if (parseInt(params.saleType, 10) === 3) {
... ... @@ -636,30 +632,25 @@ exports.handleBannerData = (origin) => {
* @type {[type]}
*/
exports.handlePathNavData = (data, params) => {
let pathNav = [
{
let pathNav = [{
href: '/product/outlets', // TODO
name: 'OUTLET',
pathTitle: 'OUTLET'
}
];
}];
_.forEach(data, (sort) => {
if (!_.isEmpty(sort.sub)) {
_.forEach(sort.sub, misort => {
if (misort.relation_parameter.sort === params.sort || misort.category_id === params.misort) {
pathNav.push(
{
href: helpers.urlFormat('outlets/list', {sort: params.sort}),
pathNav.push({
href: helpers.urlFormat('outlets/list', { sort: params.sort }),
name: sort.category_name,
pathTitle: sort.category_name
},
{
href: helpers.urlFormat('outlets/list', {sort: params.sort}),
}, {
href: helpers.urlFormat('outlets/list', { sort: params.sort }),
name: misort.category_name,
pathTitle: misort.category_name
}
);
});
}
});
}
... ... @@ -696,7 +687,7 @@ exports.handlePagerData = (total, params) => {
// 当前页为 1,一定没有上一页
delete dest.prePage;
} else {
dest.prePage.url = handleFilterUrl(params, {page: currentPage - 1});
dest.prePage.url = handleFilterUrl(params, { page: currentPage - 1 });
}
if (currentPage === totalPage) {
... ... @@ -704,7 +695,7 @@ exports.handlePagerData = (total, params) => {
// 当前页为最后一页,一定没有下一页
delete dest.nextPage;
} else {
dest.nextPage.url = handleFilterUrl(params, {page: currentPage + 1});
dest.nextPage.url = handleFilterUrl(params, { page: currentPage + 1 });
}
// 页码临时数据
... ... @@ -713,7 +704,7 @@ exports.handlePagerData = (total, params) => {
if (currentPage > 2 && currentPage <= totalPage - 2) {
for (let i = currentPage - 2; i <= ((currentPage + 2) > totalPage ? totalPage : (currentPage + 2)); i++) {
pages.push({
url: handleFilterUrl(params, {page: i}),
url: handleFilterUrl(params, { page: i }),
num: i,
cur: currentPage === i
});
... ... @@ -723,7 +714,7 @@ exports.handlePagerData = (total, params) => {
} else if (currentPage <= 2) {
for (let i = 1; i <= (totalPage < 5 ? totalPage : 5); i++) {
pages.push({
url: handleFilterUrl(params, {page: i}),
url: handleFilterUrl(params, { page: i }),
num: i,
cur: currentPage === i
});
... ... @@ -731,7 +722,7 @@ exports.handlePagerData = (total, params) => {
} else if (currentPage > totalPage - 2) {
for (let i = totalPage; i >= totalPage - 4; i--) {
pages.push({
url: handleFilterUrl(params, {page: i}),
url: handleFilterUrl(params, { page: i }),
num: i,
cur: currentPage === i
});
... ... @@ -745,7 +736,7 @@ exports.handlePagerData = (total, params) => {
if (_.size(pages) === 5) {
if (currentPage > 4) {
prevPages.push({
url: handleFilterUrl(params, {page: 1}),
url: handleFilterUrl(params, { page: 1 }),
num: 1
});
prevPages.push({
... ... @@ -757,7 +748,7 @@ exports.handlePagerData = (total, params) => {
num: '...'
});
nextPages.push({
url: handleFilterUrl(params, {page: totalPage}),
url: handleFilterUrl(params, { page: totalPage }),
num: totalPage
});
}
... ...