Authored by 刘传洋

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

... ... @@ -101,7 +101,7 @@ exports.getBrandViewList = (channel) => {
let apiMethod = [
headerModel.requestHeaderData(channel),
brandsModel.getBrandViewTop(channel),
brandsModel.getBrandViewList(channel, 1, 5) // 分屏加载
brandsModel.getBrandViewList(channel) // 分屏加载
];
return api.all(apiMethod).then(result => {
... ...
... ... @@ -7,6 +7,7 @@
const mRoot = '../models';
const list = require(`${mRoot}/list`);
const helpers = global.yoho.helpers;
const _ = require('lodash');
// 搜索相关接口
const searchApi = require(`${mRoot}/search-api`);
... ... @@ -32,12 +33,22 @@ const shop = (shopId, req, res, next, brandInfo) => {
page: 'shop',
shopId: shopId
});
// 店铺装修为空则不cache
if (!result.shopTopBanner) {
res.set('Cache-Control', 'no-cache');
}
res.render('list/shop-index', result);
}).catch(next);
} else { // 基础模板
list.getBaseShopData(req.query, Object.assign({uid: req.user.uid}, brandInfo),
req.yoho.channel, shopId).then(result => {
Object.assign(result, {page: 'list'});
// 基础店铺装修为空则不cache
if (!result.shopTopBannerBase) {
res.set('Cache-Control', 'no-cache');
}
res.render('list/brand', result);
}).catch(next);
}
... ... @@ -55,6 +66,11 @@ exports.index = (req, res, next) => {
list.getListData(req.query, req.yoho.channel).then(result => {
Object.assign(resData, result);
// 查询结果为空则不cache
if (_.isEmpty(_.get(resData, 'list.goods', []))) {
res.set('Cache-Control', 'no-cache');
}
res.render('list/index', resData);
}).catch(next);
... ... @@ -71,6 +87,11 @@ exports.new = (req, res, next) => {
list.getListNewData(Object.assign({order: 's_t_desc'}, req.query), req.yoho.channel).then(result => {
Object.assign(resData, result);
// 查询结果为空则不cache
if (_.isEmpty(_.get(resData, 'list.goods', []))) {
res.set('Cache-Control', 'no-cache');
}
res.render('list/index', resData);
}).catch(next);
... ... @@ -166,6 +187,11 @@ exports.shopList = (req, res, next) => {
if (req.query.query) {
result.shopKey = req.query.query;
}
// 店铺装修为空则不cache
if (!result.shopTopBanner) {
res.set('Cache-Control', 'no-cache');
}
res.render('list/shop-list', result);
}).catch(next);
};
... ...
... ... @@ -13,7 +13,6 @@ var $tabs = $('.brands-tabs');
var $list = $('.brands-list');
var $gory = $('.brands-category');
var $news = $('.news-txt ul');
var $clearfix = $list.find('dl.clearfix');
var $brand = $list.find('li>a');
var $category = $gory.find('a');
var $tab = $tabs.find('li>a');
... ... @@ -213,21 +212,4 @@ function bindHoverEvent() {
});
}
if ($clearfix.length < 26) {
$.ajax({
url: '/brands/brandList',
type: 'POST',
data: {
start: $clearfix.length ? ($clearfix.length + 1) : 1
},
success: function(_data) {
if (_data) {
$list.append(_data);
$brand = $list.find('li>a');
bindHoverEvent();
}
}
});
}
bindHoverEvent();
... ...