...
|
...
|
@@ -37,30 +37,25 @@ const list = (req, res, next) => { |
|
|
params.shopId = params.shop_id;
|
|
|
}
|
|
|
|
|
|
// 获取第一页数据做服务端渲染
|
|
|
let initialData = {
|
|
|
query: query,
|
|
|
type: 'default',
|
|
|
order: '0',
|
|
|
page: 1,
|
|
|
limit: 6,
|
|
|
};
|
|
|
|
|
|
/* 判断是不是品牌, 是品牌跳到品牌列表页(显示搜索框),判断是不是品类, 是品类加导航标题(不显示搜索框) */
|
|
|
Promise.all([
|
|
|
searchModel.getAllBrandNames(),
|
|
|
searchModel.getClassNames()
|
|
|
searchModel.getBrandDomain(query),
|
|
|
searchModel.getClassNames(),
|
|
|
searchModel.getSearchData(initialData)
|
|
|
]).then(result => {
|
|
|
if (query) {
|
|
|
query = query.toLowerCase();
|
|
|
_.forEach(result[0], obj => {
|
|
|
|
|
|
if (query === obj.brandDomain) { // 精确查品牌域名
|
|
|
domain = query;
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
if (query === obj.brandName || query === obj.brandName || query === obj.brandName) { // 精确查品牌名称
|
|
|
domain = obj.brandDomain;
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
// if (obj.brandDomain.indexOf(query) > 0) { // 模糊查品牌域名
|
|
|
// domain = obj.brandDomain;
|
|
|
// return false;
|
|
|
// }
|
|
|
});
|
|
|
domain = result[0];
|
|
|
|
|
|
// 跳转到品牌商品列表页
|
|
|
if (domain !== null && !params.shop_id) {
|
...
|
...
|
@@ -115,6 +110,7 @@ const list = (req, res, next) => { |
|
|
title = params.title ? params.title : title;
|
|
|
|
|
|
res.render('search/list', {
|
|
|
_noLazy: true,
|
|
|
module: 'product',
|
|
|
page: 'search-list',
|
|
|
pageHeader: headerModel.setNav({
|
...
|
...
|
@@ -122,6 +118,7 @@ const list = (req, res, next) => { |
|
|
}),
|
|
|
title: title,
|
|
|
goodList: params,
|
|
|
firstPageGoodsList: result[2] || [],
|
|
|
pageFooter: true
|
|
|
});
|
|
|
}).catch(next);
|
...
|
...
|
@@ -183,6 +180,11 @@ const search = (req, res, next) => { |
|
|
|
|
|
params.isApp = req.yoho.isApp;
|
|
|
searchModel.getSearchData(params).then((result) => {
|
|
|
if (params.page === 1 && params.start > 0) {
|
|
|
// 首屏渲染时,使用 'start' 参数裁减已渲染数据
|
|
|
result = result.slice(params.start || 0);
|
|
|
}
|
|
|
|
|
|
res.render('search/page', {
|
|
|
layout: false,
|
|
|
new: result
|
...
|
...
|
|