...
|
...
|
@@ -26,6 +26,7 @@ const list = (req, res, next) => { |
|
|
let isQueryFirstClass = false; // 标识用户搜的是不是一级品类
|
|
|
let isQuerySecondClass = false; // 标识用户搜的是不是二级品类
|
|
|
let domain = null;
|
|
|
let uid = req.user.uid || 0;
|
|
|
|
|
|
if (params.shop_id) {
|
|
|
params.shopId = params.shop_id;
|
...
|
...
|
@@ -52,6 +53,10 @@ const list = (req, res, next) => { |
|
|
query = query.toLowerCase();
|
|
|
}
|
|
|
|
|
|
if (uid) {
|
|
|
initialData.uid = uid;
|
|
|
}
|
|
|
|
|
|
/* 判断是不是品牌, 是品牌跳到品牌列表页(显示搜索框),判断是不是品类, 是品类加导航标题(不显示搜索框) */
|
|
|
return Promise.all([
|
|
|
searchModel.getBrandDomain(query),
|
...
|
...
|
@@ -183,16 +188,26 @@ let fuzzyDatas = (req, res, next) => { |
|
|
* ajax 商品数据请求
|
|
|
*/
|
|
|
const search = (req, res, next) => {
|
|
|
res.header('Access-Control-Allow-Origin', '*');
|
|
|
let allowOrigin = _.get(req, 'headers.origin', null) ?
|
|
|
req.headers.origin : req.protocol + '://' + req.headers.host;
|
|
|
|
|
|
res.setHeader('Access-Control-Allow-Origin', allowOrigin);
|
|
|
res.setHeader('Access-Control-Allow-Credentials', 'true');
|
|
|
|
|
|
let params = Object.assign({}, req.query);
|
|
|
let uid = req.user.uid || 0;
|
|
|
|
|
|
if (uid) {
|
|
|
params.uid = uid;
|
|
|
}
|
|
|
|
|
|
params.isApp = req.yoho.isApp;
|
|
|
params.limit = 24;
|
|
|
|
|
|
searchModel.getSearchData(params).then((result) => {
|
|
|
|
|
|
if (result && result.list &&
|
|
|
parseInt(params.page) === 1 && parseInt(params.start) > 0) {
|
|
|
parseInt(params.page, 10) === 1 && parseInt(params.start, 10) > 0) {
|
|
|
// 首屏渲染时,使用 'start' 参数裁减已渲染数据
|
|
|
result.list = result.list.slice(params.start || 0);
|
|
|
}
|
...
|
...
|
|