Authored by hongweigao

单独获取品类数据

@@ -153,14 +153,19 @@ const index = (req) => { @@ -153,14 +153,19 @@ const index = (req) => {
153 yh_channel: channelMap[channel].yh_channel, 153 yh_channel: channelMap[channel].yh_channel,
154 uid: req.user.uid || '' 154 uid: req.user.uid || ''
155 }; 155 };
  156 +
156 let shopParams = Object.assign({}, params, {contentCode: channelMap[channel].code}); 157 let shopParams = Object.assign({}, params, {contentCode: channelMap[channel].code});
157 - let recParams = Object.assign({}, params); 158 + let recParams = Object.assign({}, params, {
  159 + sort: req.query.sort || '',
  160 + page: req.query.page || 1
  161 + });
158 162
159 let apiMethod = [ 163 let apiMethod = [
160 headerModel.requestHeaderData(channel), 164 headerModel.requestHeaderData(channel),
161 api.recShop(shopParams), 165 api.recShop(shopParams),
162 api.recBrand(params), 166 api.recBrand(params),
163 - api.recList(recParams) 167 + api.recList(Object.assign({}, params)),//获取品类
  168 + api.recList(recParams)//获取商品数据
164 ]; 169 ];
165 170
166 return Promise.all(apiMethod).then(result => { 171 return Promise.all(apiMethod).then(result => {
@@ -253,22 +258,32 @@ const index = (req) => { @@ -253,22 +258,32 @@ const index = (req) => {
253 // 推荐品类 258 // 推荐品类
254 _.forEach(groupSort, group =>{ 259 _.forEach(groupSort, group =>{
255 _.forEach(group.sub, subSort =>{ 260 _.forEach(group.sub, subSort =>{
  261 + let cateObj = {
  262 + cateId: subSort.category_id,
  263 + url: publicHandler.handleFilterUrl(params, {sort: subSort.relation_parameter.sort}),
  264 + name: subSort.category_name,
  265 + active: false
  266 + };
  267 +
256 if (ctyList.length < 20) { 268 if (ctyList.length < 20) {
257 - ctyList.push({  
258 - cateId: subSort.category_id,  
259 - url: publicHandler.handleFilterUrl(params, {sort: subSort.relation_parameter.sort}),  
260 - name: subSort.category_name  
261 - }); 269 + //默认选中判断
  270 + if (req.query.sort === subSort.relation_parameter.sort) {
  271 + cateObj.active = true;
  272 + }
  273 + ctyList.push(cateObj);
262 } else { 274 } else {
263 return true; 275 return true;
264 } 276 }
265 }); 277 });
266 }); 278 });
267 Object.assign(respData.newProduct.ctyList, ctyList); 279 Object.assign(respData.newProduct.ctyList, ctyList);
  280 + }
268 281
  282 + // 最新上架
  283 + if (result[4].code === 200 && result[4].data) {
269 // 列表数据 284 // 列表数据
270 - Object.assign(respData.newProduct, _proListHandler(result[3].data,  
271 - Object.assign({}, recParams, {channel: channel}))); 285 + Object.assign(respData.newProduct, _proListHandler(result[4].data,
  286 + Object.assign({}, recParams, {channel: channel})));
272 } 287 }
273 288
274 // 数据为空,不显示页面模块 289 // 数据为空,不显示页面模块