Authored by yyq

Merge branch 'hotfix/4.6-23' of git.yoho.cn:fe/yohobuy-node into hotfix/4.6-23

... ... @@ -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
}];
... ... @@ -322,17 +322,17 @@ exports.handleSaleOptsData = (params, total, extra) => {
// 上一页下一页
let preHref = (!_.isEmpty(params.page) && parseInt(params.page, 10) > 1) ?
parseInt(params.page, 10) - 1 : 1;
parseInt(params.page, 10) - 1 : 1;
let nextHref = (!_.isEmpty(params.page)) ? parseInt(params.page, 10) + 1 : 2;
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) {
... ... @@ -457,7 +457,8 @@ exports.handleSaleFilterData = (origin, params) => {
_.forEach(brands, value => {
intBrands.push(parseInt(value, 10));
});
if (!_.isEmpty(origin.brand)) {
if (origin.brand) {
let count = 0;
_.forEach(origin.brand, function(value) {
... ... @@ -465,7 +466,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
... ... @@ -487,12 +488,15 @@ exports.handleSaleFilterData = (origin, params) => {
count++;
});
// 品牌排序
dest.brand.brandsShow = _.sortBy(dest.brand.brandsShow, o => {
return o.index;
});
} else {
delete dest.brand;
// 没有品牌的情况下将 brand 设置为 false,前端不显示 品牌
if (_.size(dest.brand.brandsShow) <= 0) {
dest.brand = false;
} else {
// 品牌排序
dest.brand.brandsShow = _.sortBy(dest.brand.brandsShow, o => {
return o.index;
});
}
}
// 处理价格筛选数据
... ... @@ -505,7 +509,7 @@ exports.handleSaleFilterData = (origin, params) => {
}
let price = {
checked: params.price === key,
href: handleFilterUrl(params, { price: key }),
href: handleFilterUrl(params, {price: key}),
name: value
};
... ... @@ -524,7 +528,7 @@ exports.handleSaleFilterData = (origin, params) => {
};
dest.checkedConditions.conditions.push({
name: '¥ ' + customPrice[0] + '-' + customPrice[1],
href: handleFilterUrl(params, { price: '' })
href: handleFilterUrl(params, {price: ''})
});
}
}
... ... @@ -532,11 +536,11 @@ exports.handleSaleFilterData = (origin, params) => {
// 处理性别数据
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'
}];
... ... @@ -596,8 +600,10 @@ exports.handleSaleFilterData = (origin, params) => {
handleCheckedData(params, dest.gender, 'gender'));
// 处理品牌筛选数据
dest.checkedConditions.conditions = _.union(dest.checkedConditions.conditions,
handleBrandCheckedData(params, dest.brand.brandsShow));
if (dest.brand.brandsShow) {
dest.checkedConditions.conditions = _.union(dest.checkedConditions.conditions,
handleBrandCheckedData(params, dest.brand.brandsShow));
}
// 处理价格筛选数据
dest.checkedConditions.conditions = _.union(dest.checkedConditions.conditions,
... ... @@ -654,7 +660,7 @@ exports.handlePathNavData = (data, params) => {
_.forEach(sort.sub, misort => {
if (misort.relation_parameter.sort === params.sort) {
pathNav.push({
href: helpers.urlFormat('/product/outlets/list', { sort: sort.relation_parameter.sort }),
href: helpers.urlFormat('/product/outlets/list', {sort: sort.relation_parameter.sort}),
name: sort.category_name,
pathTitle: sort.category_name
}, {
... ... @@ -696,7 +702,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 +710,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 +719,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 +729,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 +737,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 +751,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 +763,7 @@ exports.handlePagerData = (total, params) => {
num: '...'
});
nextPages.push({
url: handleFilterUrl(params, { page: totalPage }),
url: handleFilterUrl(params, {page: totalPage}),
num: totalPage
});
}
... ...