Authored by 郝肖肖

搜索 默认筛选添加 uid

... ... @@ -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);
}
... ...
... ... @@ -15,7 +15,7 @@ const cachePage = {
// 自定义频道
'/channel/:id.html': 1 * MINUTE,
//ajax获取频道页楼层
// ajax获取频道页楼层
'/channel/getResourceContent': 30 * MINUTE,
// 商品分类
... ... @@ -30,10 +30,12 @@ const cachePage = {
// 店铺推荐
'/product/detail/preference': 5 * MINUTE,
'/product/detail/intro/:productskn': 15 * MINUTE,
// 店铺人气单品
'/product/new/shop/hotlist': 5 * MINUTE,
// 店铺简介
'/product/index/intro' : 15 * MINUTE,
'/product/index/intro': 15 * MINUTE,
// 逛
'/guang/': 1 * MINUTE,
... ... @@ -57,9 +59,10 @@ const cachePage = {
'/product/list/index': 1 * MINUTE,
'/product/index/index': 1 * MINUTE,
'/product/index/brand': 1 * MINUTE,
'/product/search/filter': 1 * MINUTE,
'/product/search/search': 1 * MINUTE,
// 筛选默认须要添加uid参数
// '/product/search/search': 1 * MINUTE,
'/product/new': 1 * MINUTE,
... ...
... ... @@ -532,6 +532,9 @@ function search(opt) {
type: 'GET',
url: location.protocol + '//m.yohobuy.com/product/search/search',
data: setting,
xhrFields: {
withCredentials: true
},
success: function(data) {
var num,
$container,
... ...