Authored by 刘传洋

Merge branch 'release/hbs' of http://git.yoho.cn/fe/yohobuy-node into release/hbs

@@ -101,7 +101,7 @@ exports.getBrandViewList = (channel) => { @@ -101,7 +101,7 @@ exports.getBrandViewList = (channel) => {
101 let apiMethod = [ 101 let apiMethod = [
102 headerModel.requestHeaderData(channel), 102 headerModel.requestHeaderData(channel),
103 brandsModel.getBrandViewTop(channel), 103 brandsModel.getBrandViewTop(channel),
104 - brandsModel.getBrandViewList(channel, 1, 5) // 分屏加载 104 + brandsModel.getBrandViewList(channel) // 分屏加载
105 ]; 105 ];
106 106
107 return api.all(apiMethod).then(result => { 107 return api.all(apiMethod).then(result => {
@@ -7,6 +7,7 @@ @@ -7,6 +7,7 @@
7 const mRoot = '../models'; 7 const mRoot = '../models';
8 const list = require(`${mRoot}/list`); 8 const list = require(`${mRoot}/list`);
9 const helpers = global.yoho.helpers; 9 const helpers = global.yoho.helpers;
  10 +const _ = require('lodash');
10 11
11 // 搜索相关接口 12 // 搜索相关接口
12 const searchApi = require(`${mRoot}/search-api`); 13 const searchApi = require(`${mRoot}/search-api`);
@@ -32,12 +33,22 @@ const shop = (shopId, req, res, next, brandInfo) => { @@ -32,12 +33,22 @@ const shop = (shopId, req, res, next, brandInfo) => {
32 page: 'shop', 33 page: 'shop',
33 shopId: shopId 34 shopId: shopId
34 }); 35 });
  36 +
  37 + // 店铺装修为空则不cache
  38 + if (!result.shopTopBanner) {
  39 + res.set('Cache-Control', 'no-cache');
  40 + }
35 res.render('list/shop-index', result); 41 res.render('list/shop-index', result);
36 }).catch(next); 42 }).catch(next);
37 } else { // 基础模板 43 } else { // 基础模板
38 list.getBaseShopData(req.query, Object.assign({uid: req.user.uid}, brandInfo), 44 list.getBaseShopData(req.query, Object.assign({uid: req.user.uid}, brandInfo),
39 req.yoho.channel, shopId).then(result => { 45 req.yoho.channel, shopId).then(result => {
40 Object.assign(result, {page: 'list'}); 46 Object.assign(result, {page: 'list'});
  47 +
  48 + // 基础店铺装修为空则不cache
  49 + if (!result.shopTopBannerBase) {
  50 + res.set('Cache-Control', 'no-cache');
  51 + }
41 res.render('list/brand', result); 52 res.render('list/brand', result);
42 }).catch(next); 53 }).catch(next);
43 } 54 }
@@ -55,6 +66,11 @@ exports.index = (req, res, next) => { @@ -55,6 +66,11 @@ exports.index = (req, res, next) => {
55 66
56 list.getListData(req.query, req.yoho.channel).then(result => { 67 list.getListData(req.query, req.yoho.channel).then(result => {
57 Object.assign(resData, result); 68 Object.assign(resData, result);
  69 +
  70 + // 查询结果为空则不cache
  71 + if (_.isEmpty(_.get(resData, 'list.goods', []))) {
  72 + res.set('Cache-Control', 'no-cache');
  73 + }
58 res.render('list/index', resData); 74 res.render('list/index', resData);
59 }).catch(next); 75 }).catch(next);
60 76
@@ -71,6 +87,11 @@ exports.new = (req, res, next) => { @@ -71,6 +87,11 @@ exports.new = (req, res, next) => {
71 87
72 list.getListNewData(Object.assign({order: 's_t_desc'}, req.query), req.yoho.channel).then(result => { 88 list.getListNewData(Object.assign({order: 's_t_desc'}, req.query), req.yoho.channel).then(result => {
73 Object.assign(resData, result); 89 Object.assign(resData, result);
  90 +
  91 + // 查询结果为空则不cache
  92 + if (_.isEmpty(_.get(resData, 'list.goods', []))) {
  93 + res.set('Cache-Control', 'no-cache');
  94 + }
74 res.render('list/index', resData); 95 res.render('list/index', resData);
75 }).catch(next); 96 }).catch(next);
76 97
@@ -166,6 +187,11 @@ exports.shopList = (req, res, next) => { @@ -166,6 +187,11 @@ exports.shopList = (req, res, next) => {
166 if (req.query.query) { 187 if (req.query.query) {
167 result.shopKey = req.query.query; 188 result.shopKey = req.query.query;
168 } 189 }
  190 +
  191 + // 店铺装修为空则不cache
  192 + if (!result.shopTopBanner) {
  193 + res.set('Cache-Control', 'no-cache');
  194 + }
169 res.render('list/shop-list', result); 195 res.render('list/shop-list', result);
170 }).catch(next); 196 }).catch(next);
171 }; 197 };
@@ -13,7 +13,6 @@ var $tabs = $('.brands-tabs'); @@ -13,7 +13,6 @@ var $tabs = $('.brands-tabs');
13 var $list = $('.brands-list'); 13 var $list = $('.brands-list');
14 var $gory = $('.brands-category'); 14 var $gory = $('.brands-category');
15 var $news = $('.news-txt ul'); 15 var $news = $('.news-txt ul');
16 -var $clearfix = $list.find('dl.clearfix');  
17 var $brand = $list.find('li>a'); 16 var $brand = $list.find('li>a');
18 var $category = $gory.find('a'); 17 var $category = $gory.find('a');
19 var $tab = $tabs.find('li>a'); 18 var $tab = $tabs.find('li>a');
@@ -213,21 +212,4 @@ function bindHoverEvent() { @@ -213,21 +212,4 @@ function bindHoverEvent() {
213 }); 212 });
214 } 213 }
215 214
216 -if ($clearfix.length < 26) {  
217 - $.ajax({  
218 - url: '/brands/brandList',  
219 - type: 'POST',  
220 - data: {  
221 - start: $clearfix.length ? ($clearfix.length + 1) : 1  
222 - },  
223 - success: function(_data) {  
224 - if (_data) {  
225 - $list.append(_data);  
226 - $brand = $list.find('li>a');  
227 - bindHoverEvent();  
228 - }  
229 - }  
230 - });  
231 -}  
232 -  
233 bindHoverEvent(); 215 bindHoverEvent();