|
@@ -25,21 +25,21 @@ const handleFilterUrl = (originParam, newParam) => { |
|
@@ -25,21 +25,21 @@ const handleFilterUrl = (originParam, newParam) => { |
25
|
let newParamArray = _.keys(newParam);
|
25
|
let newParamArray = _.keys(newParam);
|
26
|
|
26
|
|
27
|
// 判断参数是否已经存在
|
27
|
// 判断参数是否已经存在
|
28
|
- let isExist = !_.isEmpty(_.find(originParamArray, function(o) {
|
28
|
+ let isExist = !_.isEmpty(_.find(originParamArray, function (o) {
|
29
|
return o === newParamArray[0];
|
29
|
return o === newParamArray[0];
|
30
|
}));
|
30
|
}));
|
31
|
|
31
|
|
32
|
if (isExist) {
|
32
|
if (isExist) {
|
33
|
tempOriginParam = Object.assign(tempOriginParam, originParam);
|
33
|
tempOriginParam = Object.assign(tempOriginParam, originParam);
|
34
|
|
34
|
|
35
|
- _.forEach(newParam, function(value, key) {
|
35
|
+ _.forEach(newParam, function (value, key) {
|
36
|
tempOriginParam[key] = value;
|
36
|
tempOriginParam[key] = value;
|
37
|
});
|
37
|
});
|
38
|
} else {
|
38
|
} else {
|
39
|
tempOriginParam = Object.assign(tempOriginParam, originParam, newParam);
|
39
|
tempOriginParam = Object.assign(tempOriginParam, originParam, newParam);
|
40
|
}
|
40
|
}
|
41
|
|
41
|
|
42
|
- _.forEach(tempOriginParam, function(value, key) {
|
42
|
+ _.forEach(tempOriginParam, function (value, key) {
|
43
|
dest = dest + key + '=' + value + '&';
|
43
|
dest = dest + key + '=' + value + '&';
|
44
|
});
|
44
|
});
|
45
|
|
45
|
|
|
@@ -80,16 +80,16 @@ const handleSalebreakingYardsSortData = (origin, params) => { |
|
@@ -80,16 +80,16 @@ const handleSalebreakingYardsSortData = (origin, params) => { |
80
|
if (!_.isEmpty(params.sort)) {
|
80
|
if (!_.isEmpty(params.sort)) {
|
81
|
|
81
|
|
82
|
// 是否有分类筛选参数,如果有
|
82
|
// 是否有分类筛选参数,如果有
|
83
|
- _.forEach(params.sort.split(','), function(sortParam) {
|
|
|
84
|
- _.forEach(origin, function(value) {
|
83
|
+ _.forEach(params.sort.split(','), function (sortParam) {
|
|
|
84
|
+ _.forEach(origin, function (value) {
|
85
|
|
85
|
|
86
|
// 判断是否在这组数据里面
|
86
|
// 判断是否在这组数据里面
|
87
|
if (!_.isEmpty(_.find(value.sort_id.split(','), o => {
|
87
|
if (!_.isEmpty(_.find(value.sort_id.split(','), o => {
|
88
|
- return o === sortParam;
|
|
|
89
|
- }))) {
|
88
|
+ return o === sortParam;
|
|
|
89
|
+ }))) {
|
90
|
|
90
|
|
91
|
// 如果在某组数据里面,组合数据退出循环
|
91
|
// 如果在某组数据里面,组合数据退出循环
|
92
|
- _.forEach(value.sub, function(subValue) {
|
92
|
+ _.forEach(value.sub, function (subValue) {
|
93
|
let size = {};
|
93
|
let size = {};
|
94
|
|
94
|
|
95
|
size.checked =
|
95
|
size.checked =
|
|
@@ -104,8 +104,8 @@ const handleSalebreakingYardsSortData = (origin, params) => { |
|
@@ -104,8 +104,8 @@ const handleSalebreakingYardsSortData = (origin, params) => { |
104
|
});
|
104
|
});
|
105
|
});
|
105
|
});
|
106
|
} else { // 如果没有筛选参数,返回所有分类
|
106
|
} else { // 如果没有筛选参数,返回所有分类
|
107
|
- _.forEach(origin, function(value) {
|
|
|
108
|
- _.forEach(value.sub, function(subValue) {
|
107
|
+ _.forEach(origin, function (value) {
|
|
|
108
|
+ _.forEach(value.sub, function (subValue) {
|
109
|
let size = {};
|
109
|
let size = {};
|
110
|
|
110
|
|
111
|
size.checked = (parseInt(params.size, 10) === parseInt(subValue.size_id, 10)) ? true : false;
|
111
|
size.checked = (parseInt(params.size, 10) === parseInt(subValue.size_id, 10)) ? true : false;
|
|
@@ -329,14 +329,6 @@ exports.handleSaleOptsData = (params, total) => { |
|
@@ -329,14 +329,6 @@ exports.handleSaleOptsData = (params, total) => { |
329
|
|
329
|
|
330
|
dest.curPage = _.isEmpty(params.page) ? 1 : params.page; // 当前页码数
|
330
|
dest.curPage = _.isEmpty(params.page) ? 1 : params.page; // 当前页码数
|
331
|
|
331
|
|
332
|
- // 上一页下一页
|
|
|
333
|
- let preHref = (!_.isEmpty(params.page) && parseInt(params.page, 10) > 1) ?
|
|
|
334
|
- parseInt(params.page, 10) - 1 : 1;
|
|
|
335
|
- let nextHref = (!_.isEmpty(params.page)) ? parseInt(params.page, 10) + 1 : 2;
|
|
|
336
|
-
|
|
|
337
|
- dest.preHref = handleFilterUrl(params, {page: preHref});
|
|
|
338
|
- dest.nextHref = handleFilterUrl(params, {page: nextHref});
|
|
|
339
|
-
|
|
|
340
|
// 每页商品数量
|
332
|
// 每页商品数量
|
341
|
dest.countPerPage = _.isEmpty(params.limit) ? 60 : params.limit;
|
333
|
dest.countPerPage = _.isEmpty(params.limit) ? 60 : params.limit;
|
342
|
|
334
|
|
|
@@ -346,6 +338,20 @@ exports.handleSaleOptsData = (params, total) => { |
|
@@ -346,6 +338,20 @@ exports.handleSaleOptsData = (params, total) => { |
346
|
// 每页多少商品
|
338
|
// 每页多少商品
|
347
|
let paramsLimit = parseInt((_.isEmpty(params.limit) ? 60 : params.limit), 10);
|
339
|
let paramsLimit = parseInt((_.isEmpty(params.limit) ? 60 : params.limit), 10);
|
348
|
|
340
|
|
|
|
341
|
+ // 上一页下一页
|
|
|
342
|
+ let preHref = (!_.isEmpty(params.page) && parseInt(params.page, 10) > 1) ?
|
|
|
343
|
+ parseInt(params.page, 10) - 1 : 1;
|
|
|
344
|
+ let nextHref = (!_.isEmpty(params.page)) ? parseInt(params.page, 10) + 1 : 2;
|
|
|
345
|
+
|
|
|
346
|
+ if (dest.pageCount > 1 && (parseInt(params.page, 10) !== 1) &&
|
|
|
347
|
+ (parseInt(params.page, 10) !== dest.pageCount)) {
|
|
|
348
|
+ dest.preHref = handleFilterUrl(params, {page: preHref});
|
|
|
349
|
+ dest.nextHref = handleFilterUrl(params, {page: nextHref});
|
|
|
350
|
+ } else if (dest.pageCount > 1 && (parseInt(params.page, 10) === 1)) {
|
|
|
351
|
+ dest.nextHref = handleFilterUrl(params, {page: nextHref});
|
|
|
352
|
+ } else if (dest.pageCount > 1 && (parseInt(params.page, 10) === dest.pageCount)) {
|
|
|
353
|
+ dest.preHref = handleFilterUrl(params, {page: preHref});
|
|
|
354
|
+ }
|
349
|
// 商品开始结束数
|
355
|
// 商品开始结束数
|
350
|
dest.start = (!_.isEmpty(params.page) ? (params.page - 1) : 0) * paramsLimit + 1;
|
356
|
dest.start = (!_.isEmpty(params.page) ? (params.page - 1) : 0) * paramsLimit + 1;
|
351
|
dest.end = (dest.pageCount === parseInt(params.page, 10)) ?
|
357
|
dest.end = (dest.pageCount === parseInt(params.page, 10)) ?
|
|
@@ -374,7 +380,7 @@ exports.handleSaleSortData = (origin, params, extra) => { |
|
@@ -374,7 +380,7 @@ exports.handleSaleSortData = (origin, params, extra) => { |
374
|
leftContent.allSort.list.push(perAllSort);
|
380
|
leftContent.allSort.list.push(perAllSort);
|
375
|
|
381
|
|
376
|
|
382
|
|
377
|
- _.forEach(origin, function(value) {
|
383
|
+ _.forEach(origin, function (value) {
|
378
|
|
384
|
|
379
|
let category = {};
|
385
|
let category = {};
|
380
|
|
386
|
|
|
@@ -383,7 +389,7 @@ exports.handleSaleSortData = (origin, params, extra) => { |
|
@@ -383,7 +389,7 @@ exports.handleSaleSortData = (origin, params, extra) => { |
383
|
category.childList = [];
|
389
|
category.childList = [];
|
384
|
category.href = handleFilterUrl(params, {sort: value.relation_parameter.sort});
|
390
|
category.href = handleFilterUrl(params, {sort: value.relation_parameter.sort});
|
385
|
category.active = false;
|
391
|
category.active = false;
|
386
|
- _.forEach(value.sub, function(subValue) {
|
392
|
+ _.forEach(value.sub, function (subValue) {
|
387
|
category.childList.push({
|
393
|
category.childList.push({
|
388
|
name: subValue.category_name,
|
394
|
name: subValue.category_name,
|
389
|
num: subValue.node_count,
|
395
|
num: subValue.node_count,
|
|
@@ -451,7 +457,7 @@ exports.handleSaleFilterData = (origin, params) => { |
|
@@ -451,7 +457,7 @@ exports.handleSaleFilterData = (origin, params) => { |
451
|
if (!_.isEmpty(origin.brand)) {
|
457
|
if (!_.isEmpty(origin.brand)) {
|
452
|
let count = 0;
|
458
|
let count = 0;
|
453
|
|
459
|
|
454
|
- _.forEach(origin.brand, function(value) {
|
460
|
+ _.forEach(origin.brand, function (value) {
|
455
|
let brand = {};
|
461
|
let brand = {};
|
456
|
|
462
|
|
457
|
brand.checked = (parseInt(params.brand, 10) === parseInt(value.id, 10)) ? true : false;
|
463
|
brand.checked = (parseInt(params.brand, 10) === parseInt(value.id, 10)) ? true : false;
|
|
@@ -477,13 +483,13 @@ exports.handleSaleFilterData = (origin, params) => { |
|
@@ -477,13 +483,13 @@ exports.handleSaleFilterData = (origin, params) => { |
477
|
}
|
483
|
}
|
478
|
|
484
|
|
479
|
// 来排排序
|
485
|
// 来排排序
|
480
|
- dest.brand.brandsShow = _.sortBy(dest.brand.brandsShow, function(o) {
|
486
|
+ dest.brand.brandsShow = _.sortBy(dest.brand.brandsShow, function (o) {
|
481
|
return o.index;
|
487
|
return o.index;
|
482
|
});
|
488
|
});
|
483
|
|
489
|
|
484
|
// 处理 价格 筛选数据
|
490
|
// 处理 价格 筛选数据
|
485
|
if (!_.isEmpty(origin.priceRange)) {
|
491
|
if (!_.isEmpty(origin.priceRange)) {
|
486
|
- _.forEach(origin.priceRange, function(value, key) {
|
492
|
+ _.forEach(origin.priceRange, function (value, key) {
|
487
|
let price = {
|
493
|
let price = {
|
488
|
checked: (params.price === key) ? true : false,
|
494
|
checked: (params.price === key) ? true : false,
|
489
|
href: handleFilterUrl(params, {price: key}),
|
495
|
href: handleFilterUrl(params, {price: key}),
|
|
@@ -567,9 +573,9 @@ exports.handleBannerData = (origin) => { |
|
@@ -567,9 +573,9 @@ exports.handleBannerData = (origin) => { |
567
|
var dest = {};
|
573
|
var dest = {};
|
568
|
|
574
|
|
569
|
dest.list = [];
|
575
|
dest.list = [];
|
570
|
- _.forEach(origin, function(value) {
|
576
|
+ _.forEach(origin, function (value) {
|
571
|
if (value.template_name === 'focus') {
|
577
|
if (value.template_name === 'focus') {
|
572
|
- _.forEach(value.data, function(subValue) {
|
578
|
+ _.forEach(value.data, function (subValue) {
|
573
|
let banner = {};
|
579
|
let banner = {};
|
574
|
|
580
|
|
575
|
banner.bannerHeight = 450;
|
581
|
banner.bannerHeight = 450;
|