Authored by wenjiekong

折扣详情页,添加个默认排序

... ... @@ -212,34 +212,38 @@ exports.handleSaleOptsData = (params, total, extra) => {
};
// 用来标记是否是折扣专场,折扣专场只需要前三个排序参数
let count = (extra === 'discont') ? 4 : 5;
let count = (extra === 'discont') ? 3 : 4;
if (extra === 'default') {
let defaultOpt = {},
defaultParams = params;
defaultOpt.href = handleFilterUrl(params, {order: ''});
defaultOpt.name = '默认';
defaultOpt.hasSortOrient = true;
if (_.isEmpty(params.order)) {
defaultOpt.active = true;
} else {
defaultOpt.active = false;
}
defaultOpt.desc = true;
dest.sortType.push(defaultOpt);
}
for (let i = 0; i < count; i++) {
let opt = {};
switch (i) {
case 0:
opt.href = handleFilterUrl(params, {order: 'shelve_time:desc'});
opt.href = handleFilterUrl(params, {order: 's_t_desc'});
if (extra === 'discont') { // 如果是折扣专场
opt.name = '全部';
if (_.isEmpty(params.order) || params.order === 'shelve_time:desc') {
if (_.isEmpty(params.order) || params.order === 's_t_desc') {
opt.active = true;
} else {
opt.active = false;
}
} else {
opt.name = '默认';
opt.hasSortOrient = true;
if (_.isEmpty(params.order) || params.order === 'shelve_time:desc') {
opt.active = true;
} else {
opt.active = false;
}
opt.desc = true;
}
break;
case 1:
if (extra !== 'discont') {
if (params.order !== 's_t_desc' && params.order !== 's_t_asc') {
opt.href = handleFilterUrl(params, {order: 's_t_desc'});
opt.hasSortOrient = true;
... ... @@ -258,7 +262,7 @@ exports.handleSaleOptsData = (params, total, extra) => {
opt.name = '最新';
}
break;
case 2:
case 1:
if (params.order !== 's_p_desc' && params.order !== 's_p_asc') {
opt.href = handleFilterUrl(params, {order: 's_p_desc'});
opt.hasSortOrient = true;
... ... @@ -276,7 +280,7 @@ exports.handleSaleOptsData = (params, total, extra) => {
opt.name = '价格';
break;
case 3:
case 2:
if (params.order !== 'p_d_desc' && params.order !== 'p_d_asc') {
opt.href = handleFilterUrl(params, {order: 'p_d_desc'});
opt.hasSortOrient = true;
... ... @@ -294,7 +298,7 @@ exports.handleSaleOptsData = (params, total, extra) => {
opt.name = '折扣';
break;
case 4:
case 3:
if (params.order !== 's_n_desc' && params.order !== 's_n_asc') {
opt.href = handleFilterUrl(params, {order: 's_n_desc'});
opt.hasSortOrient = true;
... ...
... ... @@ -366,6 +366,11 @@ exports.getSaleDiscountData = (params, channel) => {
]).then(result => {
let finalResult = result[0];
//默认order: ''
if (_.isEmpty(params.order)) {
Object.assign(params, {order: ''})
}
// 处理折扣专场标题 banner 数据
if (result[1].code === 200) {
if (_.size(result[1].data) === 1) {
... ... @@ -383,7 +388,13 @@ exports.getSaleDiscountData = (params, channel) => {
}
}
return api.all([
saleApi.getSaleGoodsList({channel: channel, saleType: '3', limit: '1', productPool: result[1].data[0].product_pool}),
saleApi.getSaleGoodsList({
channel: channel,
saleType: '3',
limit: '1',
productPool: result[1].data[0].product_pool,
order: ''
}),
saleApi.getSaleGoodsList(Object.assign(params, {productPool: result[1].data[0].product_pool}))
]).then(subResult => {
... ... @@ -393,7 +404,7 @@ exports.getSaleDiscountData = (params, channel) => {
leftContent: publicHandler.handleSaleSortData(subResult[0].data.filter.group_sort, params, 'discount'),
saleList: {
footPager: publicHandler.handlePagerData(subResult[0].data.total, params),
opts: publicHandler.handleSaleOptsData(params, subResult[0].data.total)
opts: publicHandler.handleSaleOptsData(params, subResult[0].data.total, 'default')
}
});
} else {
... ...