Authored by 周少峰

Merge branch 'hotfix/brandSeries'

@@ -492,7 +492,7 @@ const getAdnav = (params) => { @@ -492,7 +492,7 @@ const getAdnav = (params) => {
492 492
493 if (result[1].code === 200 && result[1].data) { 493 if (result[1].code === 200 && result[1].data) {
494 dest.picTitle = brandFolderSeries; 494 dest.picTitle = brandFolderSeries;
495 - Object.assign(dest.list, searchHandler.handleFolderData(result[0].data)); 495 + Object.assign(dest.list, searchHandler.handleSeriesData(result[1].data));
496 } 496 }
497 497
498 498
@@ -731,9 +731,9 @@ exports.handlePagerData = (total, params) => { @@ -731,9 +731,9 @@ exports.handlePagerData = (total, params) => {
731 pages: [] 731 pages: []
732 }; 732 };
733 733
734 - let currentPage = parseInt((_.isEmpty(params.page) ? 1 : params.page), 10); // 当前页  
735 - let perPageCount = parseInt((_.isEmpty(params.limit) ? 60 : params.limit), 10); // 每页商品数  
736 - let totalPage = parseInt(total / perPageCount, 10) + 1; // 总页数 734 + let currentPage = parseInt(_.get(params, 'page', 1), 10); // 当前页
  735 + let perPageCount = parseInt(_.get(params, 'limit', 60), 10); // 每页商品数
  736 + let totalPage = Math.ceil(total / perPageCount); // 总页数
737 737
738 if (currentPage === 1) { 738 if (currentPage === 1) {
739 // 当前页为 1,一定没有上一页 739 // 当前页为 1,一定没有上一页
@@ -773,11 +773,14 @@ exports.handlePagerData = (total, params) => { @@ -773,11 +773,14 @@ exports.handlePagerData = (total, params) => {
773 } 773 }
774 } else if (currentPage > totalPage - 2) { 774 } else if (currentPage > totalPage - 2) {
775 for (let i = totalPage; i >= totalPage - 4; i--) { 775 for (let i = totalPage; i >= totalPage - 4; i--) {
776 - pages.push({  
777 - url: handleFilterUrl(params, {page: i}),  
778 - num: i,  
779 - cur: currentPage === i  
780 - }); 776 +
  777 + if (i > 0) {
  778 + pages.push({
  779 + url: handleFilterUrl(params, {page: i}),
  780 + num: i,
  781 + cur: currentPage === i
  782 + });
  783 + }
781 } 784 }
782 pages = _.sortBy(pages, ['num']); 785 pages = _.sortBy(pages, ['num']);
783 } 786 }
@@ -795,7 +798,7 @@ exports.handlePagerData = (total, params) => { @@ -795,7 +798,7 @@ exports.handlePagerData = (total, params) => {
795 num: '...' 798 num: '...'
796 }); 799 });
797 } 800 }
798 - if (currentPage < totalPage - 2) { 801 + if (currentPage < totalPage - 2 && totalPage > 5) {
799 nextPages.push({ 802 nextPages.push({
800 num: '...' 803 num: '...'
801 }); 804 });
@@ -1249,7 +1249,7 @@ exports.handleBrandBanner = (data) => { @@ -1249,7 +1249,7 @@ exports.handleBrandBanner = (data) => {
1249 }; 1249 };
1250 1250
1251 /** 1251 /**
1252 - * 处理品牌系列 1252 + * 处理品牌系列folder_id
1253 * @type {[type]} 1253 * @type {[type]}
1254 */ 1254 */
1255 exports.handleFolderData = (data) => { 1255 exports.handleFolderData = (data) => {
@@ -1266,6 +1266,23 @@ exports.handleFolderData = (data) => { @@ -1266,6 +1266,23 @@ exports.handleFolderData = (data) => {
1266 }; 1266 };
1267 1267
1268 /** 1268 /**
  1269 + * 处理品牌系列series
  1270 + * @type {[type]}
  1271 + */
  1272 +exports.handleSeriesData = (data) => {
  1273 + let dest = [];
  1274 +
  1275 + _.forEach(data, (value) => {
  1276 + dest.push({
  1277 + href: '?series=' + value.id,
  1278 + src: value.series_banner
  1279 + });
  1280 + });
  1281 +
  1282 + return dest;
  1283 +};
  1284 +
  1285 +/**
1269 * 筛选类链接处理的对外接口 1286 * 筛选类链接处理的对外接口
1270 * @type {[type]} 1287 * @type {[type]}
1271 */ 1288 */