Authored by 周少峰

list new

@@ -32,7 +32,7 @@ exports.index = (req, res, next) => { @@ -32,7 +32,7 @@ exports.index = (req, res, next) => {
32 exports.new = (req, res, next) => { 32 exports.new = (req, res, next) => {
33 let resData = {}; 33 let resData = {};
34 34
35 - list.getListData(req.query).then(result => { 35 + list.getListNewData(req.query).then(result => {
36 Object.assign(resData, result); 36 Object.assign(resData, result);
37 res.render('list/index', resData); 37 res.render('list/index', resData);
38 }).catch(next); 38 }).catch(next);
@@ -82,3 +82,54 @@ exports.getListData = (params) => { @@ -82,3 +82,54 @@ exports.getListData = (params) => {
82 return finalResult; 82 return finalResult;
83 }); 83 });
84 }; 84 };
  85 +
  86 +/**
  87 + * 获取新品到着数据
  88 + */
  89 +exports.getListNewData = (params) => {
  90 + // 调用接口
  91 + let apiMethod = [
  92 + headerModel.requestHeaderData(),
  93 + searchApi.getSortList(),
  94 + searchApi.getProductList(params),
  95 + searchApi.getWeekNew(params)
  96 + ];
  97 +
  98 + return api.all(apiMethod).then(result => {
  99 + let finalResult = {
  100 + headerData: Object.assign(result[0].headerData, {
  101 + header: true
  102 + }),
  103 + list: {
  104 + leftContent: {}
  105 + }
  106 + };
  107 +
  108 + // 获取左侧类目数据
  109 + if (result[1].code === 200) {
  110 + finalResult.list = {
  111 + leftContent: searchHandler.handleSortData(result[1].data.sort, params),
  112 + pathNav: searchHandler.handlePathNavData(result[1].data.sort, params, 'new')
  113 + };
  114 + }
  115 +
  116 + // 获取商品数据和顶部筛选条件
  117 + if (result[2].code === 200) {
  118 + Object.assign(finalResult.list, {
  119 + filters: searchHandler.handleFilterData(result[2].data.filter, params),
  120 + opts: searchHandler.handleOptsData(params, result[2].data.total, result[2].data.filter),
  121 + totalCount: result[2].data.total,
  122 + footPager: searchHandler.handlePagerData(result[2].data.total, params),
  123 + goods: productProcess.processProductList(result[2].data.product_list,
  124 + Object.assign({showDiscount: false}, params))
  125 + });
  126 + }
  127 +
  128 + // 新品上架
  129 + if (result[3] && result[3].code === 200) {
  130 + Object.assign(finalResult.list.leftContent, searchHandler.handleWeekNew(result[3].data, params));
  131 + }
  132 +
  133 + return finalResult;
  134 + });
  135 +};
@@ -81,7 +81,13 @@ const getBrandFolder = (params) => { @@ -81,7 +81,13 @@ const getBrandFolder = (params) => {
81 * @return 81 * @return
82 */ 82 */
83 const getWeekNew = (params) => { 83 const getWeekNew = (params) => {
84 - return yohoApi.get('', params); 84 +
  85 + let finalParams = {
  86 + method: 'web.regular.recent'
  87 + };
  88 +
  89 + Object.assign(finalParams, params);
  90 + return yohoApi.get('', finalParams);
85 }; 91 };
86 92
87 /** 93 /**
@@ -51,13 +51,14 @@ const handleCheckedData = (params, origin, param) => { @@ -51,13 +51,14 @@ const handleCheckedData = (params, origin, param) => {
51 if (!_.isEmpty(origin)) { 51 if (!_.isEmpty(origin)) {
52 _.forEach(origin, value => { 52 _.forEach(origin, value => {
53 if (value.checked) { 53 if (value.checked) {
54 - let tempPatam = {}; 54 + let tempPatam = _.cloneDeep(params);
55 55
56 - tempPatam[param] = ''; 56 + // 删除选中
  57 + delete tempPatam[param];
57 58
58 dest.push({ 59 dest.push({
59 name: value.name, 60 name: value.name,
60 - href: handleFilterUrl(params, tempPatam) 61 + href: handleFilterUrl(tempPatam)
61 }); 62 });
62 } 63 }
63 }); 64 });
@@ -842,6 +843,28 @@ exports.handleSortAds = (data) => { @@ -842,6 +843,28 @@ exports.handleSortAds = (data) => {
842 }; 843 };
843 844
844 /** 845 /**
  846 + * 处理一周新品上架
  847 + * @type {[type]}
  848 + */
  849 +exports.handleWeekNew = (data, params) => {
  850 + let dest = {
  851 + newSales: {
  852 + name: '',
  853 + list: []
  854 + }
  855 + };
  856 +
  857 + _.forEach(data.recent, function(value, key) {
  858 + dest.newSales.list.push({
  859 + name: key,
  860 + href: handleFilterUrl(params, {shelveTime: key}),
  861 + active: key === params.shelveTime
  862 + });
  863 + });
  864 +
  865 + return dest;
  866 +};
  867 +/**
845 * 筛选类链接处理的对外接口 868 * 筛选类链接处理的对外接口
846 * @type {[type]} 869 * @type {[type]}
847 */ 870 */