...
|
...
|
@@ -25,21 +25,21 @@ const handleFilterUrl = (originParam, newParam) => { |
|
|
let newParamArray = _.keys(newParam);
|
|
|
|
|
|
// 判断参数是否已经存在
|
|
|
let isExist = !_.isEmpty(_.find(originParamArray, function(o) {
|
|
|
let isExist = !_.isEmpty(_.find(originParamArray, function (o) {
|
|
|
return o === newParamArray[0];
|
|
|
}));
|
|
|
|
|
|
if (isExist) {
|
|
|
tempOriginParam = Object.assign(tempOriginParam, originParam);
|
|
|
|
|
|
_.forEach(newParam, function(value, key) {
|
|
|
_.forEach(newParam, function (value, key) {
|
|
|
tempOriginParam[key] = value;
|
|
|
});
|
|
|
} else {
|
|
|
tempOriginParam = Object.assign(tempOriginParam, originParam, newParam);
|
|
|
}
|
|
|
|
|
|
_.forEach(tempOriginParam, function(value, key) {
|
|
|
_.forEach(tempOriginParam, function (value, key) {
|
|
|
dest = dest + key + '=' + value + '&';
|
|
|
});
|
|
|
|
...
|
...
|
@@ -80,8 +80,8 @@ const handleSalebreakingYardsSortData = (origin, params) => { |
|
|
if (!_.isEmpty(params.sort)) {
|
|
|
|
|
|
// 是否有分类筛选参数,如果有
|
|
|
_.forEach(params.sort.split(','), function(sortParam) {
|
|
|
_.forEach(origin, function(value) {
|
|
|
_.forEach(params.sort.split(','), function (sortParam) {
|
|
|
_.forEach(origin, function (value) {
|
|
|
|
|
|
// 判断是否在这组数据里面
|
|
|
if (!_.isEmpty(_.find(value.sort_id.split(','), o => {
|
...
|
...
|
@@ -89,7 +89,7 @@ const handleSalebreakingYardsSortData = (origin, params) => { |
|
|
}))) {
|
|
|
|
|
|
// 如果在某组数据里面,组合数据退出循环
|
|
|
_.forEach(value.sub, function(subValue) {
|
|
|
_.forEach(value.sub, function (subValue) {
|
|
|
let size = {};
|
|
|
|
|
|
size.checked =
|
...
|
...
|
@@ -104,8 +104,8 @@ const handleSalebreakingYardsSortData = (origin, params) => { |
|
|
});
|
|
|
});
|
|
|
} else { // 如果没有筛选参数,返回所有分类
|
|
|
_.forEach(origin, function(value) {
|
|
|
_.forEach(value.sub, function(subValue) {
|
|
|
_.forEach(origin, function (value) {
|
|
|
_.forEach(value.sub, function (subValue) {
|
|
|
let size = {};
|
|
|
|
|
|
size.checked = (parseInt(params.size, 10) === parseInt(subValue.size_id, 10)) ? true : false;
|
...
|
...
|
@@ -329,14 +329,6 @@ exports.handleSaleOptsData = (params, total) => { |
|
|
|
|
|
dest.curPage = _.isEmpty(params.page) ? 1 : params.page; // 当前页码数
|
|
|
|
|
|
// 上一页下一页
|
|
|
let preHref = (!_.isEmpty(params.page) && parseInt(params.page, 10) > 1) ?
|
|
|
parseInt(params.page, 10) - 1 : 1;
|
|
|
let nextHref = (!_.isEmpty(params.page)) ? parseInt(params.page, 10) + 1 : 2;
|
|
|
|
|
|
dest.preHref = handleFilterUrl(params, {page: preHref});
|
|
|
dest.nextHref = handleFilterUrl(params, {page: nextHref});
|
|
|
|
|
|
// 每页商品数量
|
|
|
dest.countPerPage = _.isEmpty(params.limit) ? 60 : params.limit;
|
|
|
|
...
|
...
|
@@ -346,6 +338,20 @@ exports.handleSaleOptsData = (params, total) => { |
|
|
// 每页多少商品
|
|
|
let paramsLimit = parseInt((_.isEmpty(params.limit) ? 60 : params.limit), 10);
|
|
|
|
|
|
// 上一页下一页
|
|
|
let preHref = (!_.isEmpty(params.page) && parseInt(params.page, 10) > 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});
|
|
|
} else if (dest.pageCount > 1 && (parseInt(params.page, 10) === 1)) {
|
|
|
dest.nextHref = handleFilterUrl(params, {page: nextHref});
|
|
|
} else if (dest.pageCount > 1 && (parseInt(params.page, 10) === dest.pageCount)) {
|
|
|
dest.preHref = handleFilterUrl(params, {page: preHref});
|
|
|
}
|
|
|
// 商品开始结束数
|
|
|
dest.start = (!_.isEmpty(params.page) ? (params.page - 1) : 0) * paramsLimit + 1;
|
|
|
dest.end = (dest.pageCount === parseInt(params.page, 10)) ?
|
...
|
...
|
@@ -374,7 +380,7 @@ exports.handleSaleSortData = (origin, params, extra) => { |
|
|
leftContent.allSort.list.push(perAllSort);
|
|
|
|
|
|
|
|
|
_.forEach(origin, function(value) {
|
|
|
_.forEach(origin, function (value) {
|
|
|
|
|
|
let category = {};
|
|
|
|
...
|
...
|
@@ -383,7 +389,7 @@ exports.handleSaleSortData = (origin, params, extra) => { |
|
|
category.childList = [];
|
|
|
category.href = handleFilterUrl(params, {sort: value.relation_parameter.sort});
|
|
|
category.active = false;
|
|
|
_.forEach(value.sub, function(subValue) {
|
|
|
_.forEach(value.sub, function (subValue) {
|
|
|
category.childList.push({
|
|
|
name: subValue.category_name,
|
|
|
num: subValue.node_count,
|
...
|
...
|
@@ -451,7 +457,7 @@ exports.handleSaleFilterData = (origin, params) => { |
|
|
if (!_.isEmpty(origin.brand)) {
|
|
|
let count = 0;
|
|
|
|
|
|
_.forEach(origin.brand, function(value) {
|
|
|
_.forEach(origin.brand, function (value) {
|
|
|
let brand = {};
|
|
|
|
|
|
brand.checked = (parseInt(params.brand, 10) === parseInt(value.id, 10)) ? true : false;
|
...
|
...
|
@@ -477,13 +483,13 @@ exports.handleSaleFilterData = (origin, params) => { |
|
|
}
|
|
|
|
|
|
// 来排排序
|
|
|
dest.brand.brandsShow = _.sortBy(dest.brand.brandsShow, function(o) {
|
|
|
dest.brand.brandsShow = _.sortBy(dest.brand.brandsShow, function (o) {
|
|
|
return o.index;
|
|
|
});
|
|
|
|
|
|
// 处理 价格 筛选数据
|
|
|
if (!_.isEmpty(origin.priceRange)) {
|
|
|
_.forEach(origin.priceRange, function(value, key) {
|
|
|
_.forEach(origin.priceRange, function (value, key) {
|
|
|
let price = {
|
|
|
checked: (params.price === key) ? true : false,
|
|
|
href: handleFilterUrl(params, {price: key}),
|
...
|
...
|
@@ -567,9 +573,9 @@ exports.handleBannerData = (origin) => { |
|
|
var dest = {};
|
|
|
|
|
|
dest.list = [];
|
|
|
_.forEach(origin, function(value) {
|
|
|
_.forEach(origin, function (value) {
|
|
|
if (value.template_name === 'focus') {
|
|
|
_.forEach(value.data, function(subValue) {
|
|
|
_.forEach(value.data, function (subValue) {
|
|
|
let banner = {};
|
|
|
|
|
|
banner.bannerHeight = 450;
|
...
|
...
|
|