Authored by 郭成尧

解决尺码处理重复问题

@@ -2,7 +2,7 @@ @@ -2,7 +2,7 @@
2 * @Author: Targaryen 2 * @Author: Targaryen
3 * @Date: 2016-06-02 15:50:47 3 * @Date: 2016-06-02 15:50:47
4 * @Last Modified by: Targaryen 4 * @Last Modified by: Targaryen
5 - * @Last Modified time: 2016-06-20 21:32:00 5 + * @Last Modified time: 2016-06-22 17:32:39
6 */ 6 */
7 7
8 'use strict'; 8 'use strict';
@@ -39,15 +39,15 @@ const handleFilterUrl = (originParam, newParam) => { @@ -39,15 +39,15 @@ const handleFilterUrl = (originParam, newParam) => {
39 const handleSaleNewSaleSortData = (params) => { 39 const handleSaleNewSaleSortData = (params) => {
40 return [{ 40 return [{
41 name: '1~3折', 41 name: '1~3折',
42 - href: handleFilterUrl(params, {p_d: '0.1,0.3'}), 42 + href: handleFilterUrl(params, { p_d: '0.1,0.3' }),
43 checked: params.p_d === '0.1,0.3' 43 checked: params.p_d === '0.1,0.3'
44 }, { 44 }, {
45 name: '4~6折', 45 name: '4~6折',
46 - href: handleFilterUrl(params, {p_d: '0.4,0.6'}), 46 + href: handleFilterUrl(params, { p_d: '0.4,0.6' }),
47 checked: params.p_d === '0.4,0.6' 47 checked: params.p_d === '0.4,0.6'
48 }, { 48 }, {
49 name: '7折以上', 49 name: '7折以上',
50 - href: handleFilterUrl(params, {p_d: '0.7,1'}), 50 + href: handleFilterUrl(params, { p_d: '0.7,1' }),
51 checked: params.p_d === '0.7,1' 51 checked: params.p_d === '0.7,1'
52 }]; 52 }];
53 }; 53 };
@@ -67,8 +67,8 @@ const handleSalebreakingYardsSortData = (origin, params) => { @@ -67,8 +67,8 @@ const handleSalebreakingYardsSortData = (origin, params) => {
67 67
68 // 判断是否在这组数据里面 68 // 判断是否在这组数据里面
69 if (!_.isEmpty(_.find(value.sort_id.split(','), o => { 69 if (!_.isEmpty(_.find(value.sort_id.split(','), o => {
70 - return o === sortParam;  
71 - }))) { 70 + return o === sortParam;
  71 + }))) {
72 72
73 // 如果在某组数据里面,组合数据退出循环 73 // 如果在某组数据里面,组合数据退出循环
74 _.forEach(value.sub, subValue => { 74 _.forEach(value.sub, subValue => {
@@ -153,8 +153,8 @@ const handleBrandCheckedData = (params, origin) => { @@ -153,8 +153,8 @@ const handleBrandCheckedData = (params, origin) => {
153 if (!_.isEmpty(origin)) { 153 if (!_.isEmpty(origin)) {
154 _.forEach(origin, (value) => { 154 _.forEach(origin, (value) => {
155 if (typeof _.find(intBrands, o => { 155 if (typeof _.find(intBrands, o => {
156 - return _.isEqual(o, value.id);  
157 - }) !== 'undefined') { 156 + return _.isEqual(o, value.id);
  157 + }) !== 'undefined') {
158 158
159 let checked = { 159 let checked = {
160 name: value.name 160 name: value.name
@@ -217,7 +217,7 @@ exports.handleSaleOptsData = (params, total, extra) => { @@ -217,7 +217,7 @@ exports.handleSaleOptsData = (params, total, extra) => {
217 217
218 switch (i) { 218 switch (i) {
219 case 0: 219 case 0:
220 - opt.href = handleFilterUrl(params, {order: 's_t_desc'}); 220 + opt.href = handleFilterUrl(params, { order: 's_t_desc' });
221 if (extra === 'discont') { // 如果是折扣专场 221 if (extra === 'discont') { // 如果是折扣专场
222 opt.name = '全部'; 222 opt.name = '全部';
223 if (_.isEmpty(params.order) || params.order === 's_t_desc') { 223 if (_.isEmpty(params.order) || params.order === 's_t_desc') {
@@ -238,16 +238,16 @@ exports.handleSaleOptsData = (params, total, extra) => { @@ -238,16 +238,16 @@ exports.handleSaleOptsData = (params, total, extra) => {
238 break; 238 break;
239 case 1: 239 case 1:
240 if (params.order !== 's_p_desc' && params.order !== 's_p_asc') { 240 if (params.order !== 's_p_desc' && params.order !== 's_p_asc') {
241 - opt.href = handleFilterUrl(params, {order: 's_p_desc'}); 241 + opt.href = handleFilterUrl(params, { order: 's_p_desc' });
242 opt.hasSortOrient = true; 242 opt.hasSortOrient = true;
243 } else { 243 } else {
244 opt.hasSortOrient = true; 244 opt.hasSortOrient = true;
245 opt.active = true; 245 opt.active = true;
246 if (params.order === 's_p_desc') { 246 if (params.order === 's_p_desc') {
247 - opt.href = handleFilterUrl(params, {order: 's_p_asc'}); 247 + opt.href = handleFilterUrl(params, { order: 's_p_asc' });
248 opt.desc = false; 248 opt.desc = false;
249 } else { 249 } else {
250 - opt.href = handleFilterUrl(params, {order: 's_p_desc'}); 250 + opt.href = handleFilterUrl(params, { order: 's_p_desc' });
251 opt.desc = true; 251 opt.desc = true;
252 } 252 }
253 } 253 }
@@ -256,16 +256,16 @@ exports.handleSaleOptsData = (params, total, extra) => { @@ -256,16 +256,16 @@ exports.handleSaleOptsData = (params, total, extra) => {
256 break; 256 break;
257 case 2: 257 case 2:
258 if (params.order !== 'p_d_desc' && params.order !== 'p_d_asc') { 258 if (params.order !== 'p_d_desc' && params.order !== 'p_d_asc') {
259 - opt.href = handleFilterUrl(params, {order: 'p_d_desc'}); 259 + opt.href = handleFilterUrl(params, { order: 'p_d_desc' });
260 opt.hasSortOrient = true; 260 opt.hasSortOrient = true;
261 } else { 261 } else {
262 opt.hasSortOrient = true; 262 opt.hasSortOrient = true;
263 opt.active = true; 263 opt.active = true;
264 if (params.order === 'p_d_desc') { 264 if (params.order === 'p_d_desc') {
265 - opt.href = handleFilterUrl(params, {order: 'p_d_asc'}); 265 + opt.href = handleFilterUrl(params, { order: 'p_d_asc' });
266 opt.desc = false; 266 opt.desc = false;
267 } else { 267 } else {
268 - opt.href = handleFilterUrl(params, {order: 'p_d_desc'}); 268 + opt.href = handleFilterUrl(params, { order: 'p_d_desc' });
269 opt.desc = true; 269 opt.desc = true;
270 } 270 }
271 } 271 }
@@ -274,16 +274,16 @@ exports.handleSaleOptsData = (params, total, extra) => { @@ -274,16 +274,16 @@ exports.handleSaleOptsData = (params, total, extra) => {
274 break; 274 break;
275 case 3: 275 case 3:
276 if (params.order !== 's_n_desc' && params.order !== 's_n_asc') { 276 if (params.order !== 's_n_desc' && params.order !== 's_n_asc') {
277 - opt.href = handleFilterUrl(params, {order: 's_n_desc'}); 277 + opt.href = handleFilterUrl(params, { order: 's_n_desc' });
278 opt.hasSortOrient = true; 278 opt.hasSortOrient = true;
279 } else { 279 } else {
280 opt.hasSortOrient = true; 280 opt.hasSortOrient = true;
281 opt.active = true; 281 opt.active = true;
282 if (params.order === 's_n_desc') { 282 if (params.order === 's_n_desc') {
283 - opt.href = handleFilterUrl(params, {order: 's_n_asc'}); 283 + opt.href = handleFilterUrl(params, { order: 's_n_asc' });
284 opt.desc = false; 284 opt.desc = false;
285 } else { 285 } else {
286 - opt.href = handleFilterUrl(params, {order: 's_n_desc'}); 286 + opt.href = handleFilterUrl(params, { order: 's_n_desc' });
287 opt.desc = true; 287 opt.desc = true;
288 } 288 }
289 } 289 }
@@ -299,13 +299,13 @@ exports.handleSaleOptsData = (params, total, extra) => { @@ -299,13 +299,13 @@ exports.handleSaleOptsData = (params, total, extra) => {
299 299
300 // 上下翻页数据处理 300 // 上下翻页数据处理
301 dest.pageCounts = [{ 301 dest.pageCounts = [{
302 - href: handleFilterUrl(params, {limit: 200}), 302 + href: handleFilterUrl(params, { limit: 200 }),
303 count: 200 303 count: 200
304 }, { 304 }, {
305 - href: handleFilterUrl(params, {limit: 100}), 305 + href: handleFilterUrl(params, { limit: 100 }),
306 count: 100 306 count: 100
307 }, { 307 }, {
308 - href: handleFilterUrl(params, {limit: 60}), 308 + href: handleFilterUrl(params, { limit: 60 }),
309 count: 60 309 count: 60
310 }]; 310 }];
311 311
@@ -322,17 +322,17 @@ exports.handleSaleOptsData = (params, total, extra) => { @@ -322,17 +322,17 @@ exports.handleSaleOptsData = (params, total, extra) => {
322 322
323 // 上一页下一页 323 // 上一页下一页
324 let preHref = (!_.isEmpty(params.page) && parseInt(params.page, 10) > 1) ? 324 let preHref = (!_.isEmpty(params.page) && parseInt(params.page, 10) > 1) ?
325 - parseInt(params.page, 10) - 1 : 1; 325 + parseInt(params.page, 10) - 1 : 1;
326 let nextHref = (!_.isEmpty(params.page)) ? parseInt(params.page, 10) + 1 : 2; 326 let nextHref = (!_.isEmpty(params.page)) ? parseInt(params.page, 10) + 1 : 2;
327 327
328 if (dest.pageCount > 1 && (parseInt(params.page, 10) !== 1) && 328 if (dest.pageCount > 1 && (parseInt(params.page, 10) !== 1) &&
329 (parseInt(params.page, 10) !== dest.pageCount)) { 329 (parseInt(params.page, 10) !== dest.pageCount)) {
330 - dest.preHref = handleFilterUrl(params, {page: preHref});  
331 - dest.nextHref = handleFilterUrl(params, {page: nextHref}); 330 + dest.preHref = handleFilterUrl(params, { page: preHref });
  331 + dest.nextHref = handleFilterUrl(params, { page: nextHref });
332 } else if (dest.pageCount > 1 && (parseInt(params.page, 10) === 1)) { 332 } else if (dest.pageCount > 1 && (parseInt(params.page, 10) === 1)) {
333 - dest.nextHref = handleFilterUrl(params, {page: nextHref}); 333 + dest.nextHref = handleFilterUrl(params, { page: nextHref });
334 } else if (dest.pageCount > 1 && (parseInt(params.page, 10) === dest.pageCount)) { 334 } else if (dest.pageCount > 1 && (parseInt(params.page, 10) === dest.pageCount)) {
335 - dest.preHref = handleFilterUrl(params, {page: preHref}); 335 + dest.preHref = handleFilterUrl(params, { page: preHref });
336 } 336 }
337 337
338 // 全部商品数 338 // 全部商品数
@@ -390,7 +390,7 @@ exports.handleSaleSortData = (origin, params, extra) => { @@ -390,7 +390,7 @@ exports.handleSaleSortData = (origin, params, extra) => {
390 name: value.category_name, 390 name: value.category_name,
391 num: value.node_count, 391 num: value.node_count,
392 childList: [], 392 childList: [],
393 - href: handleFilterUrl(params, {sort: value.relation_parameter.sort}), 393 + href: handleFilterUrl(params, { sort: value.relation_parameter.sort }),
394 active: params.sort === value.relation_parameter.sort 394 active: params.sort === value.relation_parameter.sort
395 }; 395 };
396 396
@@ -398,7 +398,7 @@ exports.handleSaleSortData = (origin, params, extra) => { @@ -398,7 +398,7 @@ exports.handleSaleSortData = (origin, params, extra) => {
398 category.childList.push({ 398 category.childList.push({
399 name: subValue.category_name, 399 name: subValue.category_name,
400 num: subValue.node_count, 400 num: subValue.node_count,
401 - href: handleFilterUrl(params, {sort: subValue.relation_parameter.sort}), 401 + href: handleFilterUrl(params, { sort: subValue.relation_parameter.sort }),
402 childActive: params.sort === subValue.relation_parameter.sort 402 childActive: params.sort === subValue.relation_parameter.sort
403 }); 403 });
404 if (params.sort === subValue.relation_parameter.sort) { 404 if (params.sort === subValue.relation_parameter.sort) {
@@ -424,16 +424,13 @@ exports.handleSaleFilterData = (origin, params) => { @@ -424,16 +424,13 @@ exports.handleSaleFilterData = (origin, params) => {
424 brand: { 424 brand: {
425 default: [], 425 default: [],
426 brandsShow: [], 426 brandsShow: [],
427 - brandIndex: [  
428 - {  
429 - index: 'all',  
430 - name: '全部'  
431 - },  
432 - {  
433 - index: '0-9',  
434 - name: '0~9'  
435 - }  
436 - ], 427 + brandIndex: [{
  428 + index: 'all',
  429 + name: '全部'
  430 + }, {
  431 + index: '0-9',
  432 + name: '0~9'
  433 + }],
437 showMore: true, 434 showMore: true,
438 showMulti: true 435 showMulti: true
439 }, 436 },
@@ -468,7 +465,7 @@ exports.handleSaleFilterData = (origin, params) => { @@ -468,7 +465,7 @@ exports.handleSaleFilterData = (origin, params) => {
468 checked: (typeof _.find(intBrands, o => { 465 checked: (typeof _.find(intBrands, o => {
469 return _.isEqual(o, value.id); 466 return _.isEqual(o, value.id);
470 }) !== 'undefined'), 467 }) !== 'undefined'),
471 - href: handleFilterUrl(params, {brand: value.id}), 468 + href: handleFilterUrl(params, { brand: value.id }),
472 name: value.brand_name, 469 name: value.brand_name,
473 key: value.brand_domain, 470 key: value.brand_domain,
474 id: value.id 471 id: value.id
@@ -503,7 +500,7 @@ exports.handleSaleFilterData = (origin, params) => { @@ -503,7 +500,7 @@ exports.handleSaleFilterData = (origin, params) => {
503 _.forEach(origin.priceRange, (value, key) => { 500 _.forEach(origin.priceRange, (value, key) => {
504 let price = { 501 let price = {
505 checked: params.price === key, 502 checked: params.price === key,
506 - href: handleFilterUrl(params, {price: key}), 503 + href: handleFilterUrl(params, { price: key }),
507 name: value 504 name: value
508 }; 505 };
509 506
@@ -514,30 +511,29 @@ exports.handleSaleFilterData = (origin, params) => { @@ -514,30 +511,29 @@ exports.handleSaleFilterData = (origin, params) => {
514 // 处理用户自主填写的价格区间 511 // 处理用户自主填写的价格区间
515 if (!priceRangechecked && params.price) { 512 if (!priceRangechecked && params.price) {
516 let customPrice = _.split(params.price, ','); 513 let customPrice = _.split(params.price, ',');
517 -  
518 - dest.customPrice = {  
519 - min: customPrice[0],  
520 - max: customPrice[1]  
521 - };  
522 - dest.checkedConditions.conditions.push({  
523 - name: '¥ ' + customPrice[0] + '-' + customPrice[1],  
524 - href: handleFilterUrl(params, {price: ''})  
525 - }); 514 +
  515 + if (customPrice[1] !== '99999') {
  516 + dest.customPrice = {
  517 + min: customPrice[0],
  518 + max: customPrice[1]
  519 + };
  520 + dest.checkedConditions.conditions.push({
  521 + name: '¥ ' + customPrice[0] + '-' + customPrice[1],
  522 + href: handleFilterUrl(params, { price: '' })
  523 + });
  524 + }
526 } 525 }
527 526
528 // 处理性别数据 527 // 处理性别数据
529 - dest.gender = [  
530 - {  
531 - name: 'BOYS',  
532 - href: handleFilterUrl(params, {gender: '1,3'}),  
533 - checked: params.gender === '1,3'  
534 - },  
535 - {  
536 - name: 'GIRLS',  
537 - href: handleFilterUrl(params, {gender: '2,3'}),  
538 - checked: params.gender === '2,3'  
539 - }  
540 - ]; 528 + dest.gender = [{
  529 + name: 'BOYS',
  530 + href: handleFilterUrl(params, { gender: '1,3' }),
  531 + checked: params.gender === '1,3'
  532 + }, {
  533 + name: 'GIRLS',
  534 + href: handleFilterUrl(params, { gender: '2,3' }),
  535 + checked: params.gender === '2,3'
  536 + }];
541 537
542 // 最新降价数据处理 538 // 最新降价数据处理
543 if (parseInt(params.saleType, 10) === 3) { 539 if (parseInt(params.saleType, 10) === 3) {
@@ -636,30 +632,25 @@ exports.handleBannerData = (origin) => { @@ -636,30 +632,25 @@ exports.handleBannerData = (origin) => {
636 * @type {[type]} 632 * @type {[type]}
637 */ 633 */
638 exports.handlePathNavData = (data, params) => { 634 exports.handlePathNavData = (data, params) => {
639 - let pathNav = [  
640 - {  
641 - href: '/product/outlets', // TODO  
642 - name: 'OUTLET',  
643 - pathTitle: 'OUTLET'  
644 - }  
645 - ]; 635 + let pathNav = [{
  636 + href: '/product/outlets', // TODO
  637 + name: 'OUTLET',
  638 + pathTitle: 'OUTLET'
  639 + }];
646 640
647 _.forEach(data, (sort) => { 641 _.forEach(data, (sort) => {
648 if (!_.isEmpty(sort.sub)) { 642 if (!_.isEmpty(sort.sub)) {
649 _.forEach(sort.sub, misort => { 643 _.forEach(sort.sub, misort => {
650 if (misort.relation_parameter.sort === params.sort || misort.category_id === params.misort) { 644 if (misort.relation_parameter.sort === params.sort || misort.category_id === params.misort) {
651 - pathNav.push(  
652 - {  
653 - href: helpers.urlFormat('outlets/list', {sort: params.sort}),  
654 - name: sort.category_name,  
655 - pathTitle: sort.category_name  
656 - },  
657 - {  
658 - href: helpers.urlFormat('outlets/list', {sort: params.sort}),  
659 - name: misort.category_name,  
660 - pathTitle: misort.category_name  
661 - }  
662 - ); 645 + pathNav.push({
  646 + href: helpers.urlFormat('outlets/list', { sort: params.sort }),
  647 + name: sort.category_name,
  648 + pathTitle: sort.category_name
  649 + }, {
  650 + href: helpers.urlFormat('outlets/list', { sort: params.sort }),
  651 + name: misort.category_name,
  652 + pathTitle: misort.category_name
  653 + });
663 } 654 }
664 }); 655 });
665 } 656 }
@@ -696,7 +687,7 @@ exports.handlePagerData = (total, params) => { @@ -696,7 +687,7 @@ exports.handlePagerData = (total, params) => {
696 // 当前页为 1,一定没有上一页 687 // 当前页为 1,一定没有上一页
697 delete dest.prePage; 688 delete dest.prePage;
698 } else { 689 } else {
699 - dest.prePage.url = handleFilterUrl(params, {page: currentPage - 1}); 690 + dest.prePage.url = handleFilterUrl(params, { page: currentPage - 1 });
700 } 691 }
701 692
702 if (currentPage === totalPage) { 693 if (currentPage === totalPage) {
@@ -704,7 +695,7 @@ exports.handlePagerData = (total, params) => { @@ -704,7 +695,7 @@ exports.handlePagerData = (total, params) => {
704 // 当前页为最后一页,一定没有下一页 695 // 当前页为最后一页,一定没有下一页
705 delete dest.nextPage; 696 delete dest.nextPage;
706 } else { 697 } else {
707 - dest.nextPage.url = handleFilterUrl(params, {page: currentPage + 1}); 698 + dest.nextPage.url = handleFilterUrl(params, { page: currentPage + 1 });
708 } 699 }
709 700
710 // 页码临时数据 701 // 页码临时数据
@@ -713,7 +704,7 @@ exports.handlePagerData = (total, params) => { @@ -713,7 +704,7 @@ exports.handlePagerData = (total, params) => {
713 if (currentPage > 2 && currentPage <= totalPage - 2) { 704 if (currentPage > 2 && currentPage <= totalPage - 2) {
714 for (let i = currentPage - 2; i <= ((currentPage + 2) > totalPage ? totalPage : (currentPage + 2)); i++) { 705 for (let i = currentPage - 2; i <= ((currentPage + 2) > totalPage ? totalPage : (currentPage + 2)); i++) {
715 pages.push({ 706 pages.push({
716 - url: handleFilterUrl(params, {page: i}), 707 + url: handleFilterUrl(params, { page: i }),
717 num: i, 708 num: i,
718 cur: currentPage === i 709 cur: currentPage === i
719 }); 710 });
@@ -723,7 +714,7 @@ exports.handlePagerData = (total, params) => { @@ -723,7 +714,7 @@ exports.handlePagerData = (total, params) => {
723 } else if (currentPage <= 2) { 714 } else if (currentPage <= 2) {
724 for (let i = 1; i <= (totalPage < 5 ? totalPage : 5); i++) { 715 for (let i = 1; i <= (totalPage < 5 ? totalPage : 5); i++) {
725 pages.push({ 716 pages.push({
726 - url: handleFilterUrl(params, {page: i}), 717 + url: handleFilterUrl(params, { page: i }),
727 num: i, 718 num: i,
728 cur: currentPage === i 719 cur: currentPage === i
729 }); 720 });
@@ -731,7 +722,7 @@ exports.handlePagerData = (total, params) => { @@ -731,7 +722,7 @@ exports.handlePagerData = (total, params) => {
731 } else if (currentPage > totalPage - 2) { 722 } else if (currentPage > totalPage - 2) {
732 for (let i = totalPage; i >= totalPage - 4; i--) { 723 for (let i = totalPage; i >= totalPage - 4; i--) {
733 pages.push({ 724 pages.push({
734 - url: handleFilterUrl(params, {page: i}), 725 + url: handleFilterUrl(params, { page: i }),
735 num: i, 726 num: i,
736 cur: currentPage === i 727 cur: currentPage === i
737 }); 728 });
@@ -745,7 +736,7 @@ exports.handlePagerData = (total, params) => { @@ -745,7 +736,7 @@ exports.handlePagerData = (total, params) => {
745 if (_.size(pages) === 5) { 736 if (_.size(pages) === 5) {
746 if (currentPage > 4) { 737 if (currentPage > 4) {
747 prevPages.push({ 738 prevPages.push({
748 - url: handleFilterUrl(params, {page: 1}), 739 + url: handleFilterUrl(params, { page: 1 }),
749 num: 1 740 num: 1
750 }); 741 });
751 prevPages.push({ 742 prevPages.push({
@@ -757,7 +748,7 @@ exports.handlePagerData = (total, params) => { @@ -757,7 +748,7 @@ exports.handlePagerData = (total, params) => {
757 num: '...' 748 num: '...'
758 }); 749 });
759 nextPages.push({ 750 nextPages.push({
760 - url: handleFilterUrl(params, {page: totalPage}), 751 + url: handleFilterUrl(params, { page: totalPage }),
761 num: totalPage 752 num: totalPage
762 }); 753 });
763 } 754 }