...
|
...
|
@@ -23,7 +23,7 @@ const handleFilterUrl = (originParam, newParam) => { |
|
|
|
|
|
tempOriginParam = Object.assign(tempOriginParam, originParam, newParam);
|
|
|
|
|
|
_.forEach(tempOriginParam, function(value, key) {
|
|
|
_.forEach(tempOriginParam, function (value, key) {
|
|
|
dest = dest + key + '=' + value + '&';
|
|
|
});
|
|
|
|
...
|
...
|
@@ -66,8 +66,8 @@ const handleSalebreakingYardsSortData = (origin, params) => { |
|
|
|
|
|
// 判断是否在这组数据里面
|
|
|
if (!_.isEmpty(_.find(value.sort_id.split(','), o => {
|
|
|
return o === sortParam;
|
|
|
}))) {
|
|
|
return o === sortParam;
|
|
|
}))) {
|
|
|
|
|
|
// 如果在某组数据里面,组合数据退出循环
|
|
|
_.forEach(value.sub, subValue => {
|
...
|
...
|
@@ -152,8 +152,8 @@ const handleBrandCheckedData = (params, origin) => { |
|
|
if (!_.isEmpty(origin)) {
|
|
|
_.forEach(origin, (value) => {
|
|
|
if (typeof _.find(intBrands, o => {
|
|
|
return _.isEqual(o, value.id);
|
|
|
}) !== 'undefined') {
|
|
|
return _.isEqual(o, value.id);
|
|
|
}) !== 'undefined') {
|
|
|
|
|
|
let checked = {
|
|
|
name: value.name
|
...
|
...
|
@@ -543,7 +543,7 @@ exports.handleSaleFilterData = (origin, params) => { |
|
|
if (!_.isEmpty(origin.brand)) {
|
|
|
let count = 0;
|
|
|
|
|
|
_.forEach(origin.brand, function(value) {
|
|
|
_.forEach(origin.brand, function (value) {
|
|
|
let brand = {
|
|
|
checked: (typeof _.find(intBrands, o => {
|
|
|
return _.isEqual(o, value.id);
|
...
|
...
|
@@ -678,7 +678,7 @@ exports.handleBannerData = (origin) => { |
|
|
let dest = {};
|
|
|
|
|
|
dest.list = [];
|
|
|
_.forEach(origin, function(value) {
|
|
|
_.forEach(origin, function (value) {
|
|
|
if (value.template_name === 'focus') {
|
|
|
_.forEach(value.data, subValue => {
|
|
|
|
...
|
...
|
@@ -736,6 +736,104 @@ exports.handlePathNavData = (data, params) => { |
|
|
};
|
|
|
|
|
|
/**
|
|
|
* 分页
|
|
|
* @param {[type]} total 总页数
|
|
|
* @param {[type]} params 筛选条件
|
|
|
* @return {[type]} [description]
|
|
|
*/
|
|
|
exports.handlePagerData = (total, params) => {
|
|
|
let dest = {
|
|
|
prePage: {
|
|
|
url: ''
|
|
|
},
|
|
|
nextPage: {
|
|
|
url: ''
|
|
|
},
|
|
|
pages: []
|
|
|
};
|
|
|
|
|
|
let currentPage = parseInt((_.isEmpty(params.page) ? 1 : params.page), 10); // 当前页
|
|
|
let perPageCount = parseInt((_.isEmpty(params.limit) ? 60 : params.limit), 10); // 每页商品数
|
|
|
let totalPage = parseInt(total / perPageCount, 10) + 1; // 总页数
|
|
|
|
|
|
if (currentPage === 1) {
|
|
|
// 当前页为 1,一定没有上一页
|
|
|
delete dest.prePage;
|
|
|
} else {
|
|
|
dest.prePage.url = handleFilterUrl(params, {page: currentPage - 1});
|
|
|
}
|
|
|
|
|
|
if (currentPage === totalPage) {
|
|
|
|
|
|
// 当前页为最后一页,一定没有下一页
|
|
|
delete dest.nextPage;
|
|
|
} else {
|
|
|
dest.nextPage.url = handleFilterUrl(params, {page: currentPage + 1});
|
|
|
}
|
|
|
|
|
|
// 页码临时数据
|
|
|
let pages = [];
|
|
|
|
|
|
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}),
|
|
|
num: i,
|
|
|
cur: currentPage === i
|
|
|
});
|
|
|
}
|
|
|
|
|
|
// 处理页码小于等于 2 的情况
|
|
|
} else if (currentPage <= 2) {
|
|
|
for (let i = 1; i <= (totalPage < 5 ? totalPage : 5); i++) {
|
|
|
pages.push({
|
|
|
url: handleFilterUrl(params, {page: i}),
|
|
|
num: i,
|
|
|
cur: currentPage === i
|
|
|
});
|
|
|
}
|
|
|
} else if (currentPage > totalPage - 2) {
|
|
|
for (let i = totalPage; i >= totalPage - 4; i--) {
|
|
|
pages.push({
|
|
|
url: handleFilterUrl(params, {page: i}),
|
|
|
num: i,
|
|
|
cur: currentPage === i
|
|
|
});
|
|
|
}
|
|
|
pages = _.sortBy(pages, ['num']);
|
|
|
}
|
|
|
|
|
|
let prevPages = [];
|
|
|
let nextPages = [];
|
|
|
|
|
|
if (_.size(pages) === 5) {
|
|
|
if (currentPage > 4) {
|
|
|
prevPages.push({
|
|
|
url: handleFilterUrl(params, {page: 1}),
|
|
|
num: 1
|
|
|
});
|
|
|
prevPages.push({
|
|
|
num: '...'
|
|
|
});
|
|
|
}
|
|
|
if (currentPage < totalPage - 2) {
|
|
|
nextPages.push({
|
|
|
num: '...'
|
|
|
});
|
|
|
nextPages.push({
|
|
|
url: handleFilterUrl(params, {page: totalPage}),
|
|
|
num: totalPage
|
|
|
});
|
|
|
}
|
|
|
}
|
|
|
|
|
|
dest.pages = _.concat(prevPages, pages, nextPages);
|
|
|
|
|
|
return dest;
|
|
|
|
|
|
};
|
|
|
|
|
|
/**
|
|
|
* 筛选类链接处理的对外接口
|
|
|
* @type {[type]}
|
|
|
*/
|
...
|
...
|
|