Authored by 刘传洋

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

... ... @@ -197,10 +197,14 @@ exports.isFavoriteBrand = (req, res, next) => {
let uid = req.user.uid;
let brandId = req.body.brandId;
if (!req.xhr || !req.body.brandId || !uid) {
if (!req.xhr) {
return next();
}
if (!req.body.brandId || !uid) {
return res.json({code: 400, message: '用户未登录或缺少参数'});
}
searchApi.isFavoriteBrand(uid, brandId).then(result => {
res.json(result);
}).catch(next);
... ...
... ... @@ -81,16 +81,20 @@ exports.getListData = (params, channel) => {
// 获取左侧类目数据
if (result[1].code === 200) {
let dps = {};
if (params.gender) {
dps.gender = params.gender;
}
finalResult.list = Object.assign(
searchHandler.handlePathNavData(result[1].data.sort, params, 'sort', channel), {
leftContent: searchHandler.handleSortData(result[1].data.sort, params)
leftContent: searchHandler.handleSortData(result[1].data.sort, dps)
});
}
// 获取商品数据和顶部筛选条件
if (result[2].code === 200) {
Object.assign(finalResult.list, {
// filters: searchHandler.handleFilterData(result[2].data.filter, params),
filters: searchHandler.handleFilterDataAll(result[2].data, params),
opts: searchHandler.handleOptsData(params, result[2].data.total, result[2].data.filter),
totalCount: result[2].data.total,
... ... @@ -148,19 +152,23 @@ exports.getListNewData = (params, channel) => {
leftContent: {}
}
};
let dps = {};
if (params.gender) {
dps.gender = params.gender;
}
// 获取左侧类目数据
if (result[1].code === 200) {
finalResult.list = Object.assign(
searchHandler.handlePathNavData(result[1].data.sort, params, 'new', channel), {
leftContent: searchHandler.handleSortData(result[1].data.sort, params)
leftContent: searchHandler.handleSortData(result[1].data.sort, dps)
});
}
// 获取商品数据和顶部筛选条件
if (result[2].code === 200) {
Object.assign(finalResult.list, {
// filters: searchHandler.handleFilterData(result[2].data.filter, params),
filters: searchHandler.handleFilterDataAll(result[2].data, params),
opts: searchHandler.handleOptsData(params, result[2].data.total, result[2].data.filter),
totalCount: result[2].data.total,
... ... @@ -176,7 +184,7 @@ exports.getListNewData = (params, channel) => {
// 新品上架
if (result[3] && result[3].code === 200) {
Object.assign(finalResult.list.leftContent, searchHandler.handleWeekNew(result[3].data, params));
Object.assign(finalResult.list.leftContent, searchHandler.handleWeekNew(result[3].data, dps));
}
finalResult.criteo = {skn: searchHandler.getCriteo(_.get(finalResult.list, 'goods'))};
... ... @@ -247,8 +255,13 @@ exports.getBrandData = (params, extra, channel) => {
// 获取左侧类目数据
if (result[1].code === 200) {
let dps = {};
if (params.gender) {
dps.gender = params.gender;
}
Object.assign(finalResult.brand, {
leftContent: searchHandler.handleSortData(result[1].data.sort, params)
leftContent: searchHandler.handleSortData(result[1].data.sort, dps)
}, searchHandler.handlePathNavData(extra, params, 'brand', channel));
}
... ... @@ -564,7 +577,8 @@ exports.getShopData = (shopId, channel, params, shopInfo) => {
for (let i = 0; i < 3; i++) {
trendList.push({
href: articleList[i].url,
src: articleList[i].src,
src: helpers.getForceSourceUrl(articleList[i].src) +
'?imageView/1/w/{width}/h/{height}',
mainTitle: articleList[i].title,
Subtitle: articleList[i].intro
});
... ...
... ... @@ -481,7 +481,7 @@ exports.handleSortData = (origin, params) => {
sortId: value.sort_id
}
],
href: handleFilterUrl(params, {msort: value.sort_id}),
href: handleFilterUrl(params, {msort: value.sort_id}, {misort: true}),
active: params.msort === value.sort_id,
sortId: value.sort_id
};
... ... @@ -604,18 +604,26 @@ exports.handleFilterData = (origin, params, total) => {
// 处理用户自主填写的价格区间
if (!priceRangechecked && params.price) {
let customPrice = _.split(params.price, ',');
let customPrice = _.split(params.price, ','),
min = customPrice[0] || 0,
name;
if (customPrice[1] !== '99999') {
dest.customPrice = {
min: customPrice[0],
max: customPrice[1]
};
dest.checkedConditions.conditions.push({
name: '¥ ' + customPrice[0] + '-' + customPrice[1],
href: handleFilterUrl(params, {price: ''})
});
customPrice[0] = customPrice[0];
name = ${min}-${customPrice[1]}`;
if (!customPrice[1]) {
customPrice[1] = '';
name = ${min}以上`;
}
dest.customPrice = {
min: customPrice[0],
max: customPrice[1]
};
dest.checkedConditions.conditions.push({
name: name,
href: handleFilterUrl(params, {}, {price: true})
});
}
// 处理性别数据
... ... @@ -851,7 +859,10 @@ exports.handleSeniorFilterData = (data, params) => {
return resData;
};
exports.handleFilterDataAll = (data, params) => {
exports.handleFilterDataAll = (data, qs) => {
let params = _.cloneDeep(qs);
_.unset(params, 'page'); // 去除筛选项page
let baseFilter = this.handleFilterData(data.filter, params, data.total);
let seniorFilter = this.handleSeniorFilterData({
... ...
... ... @@ -44,8 +44,13 @@ exports.getSearchData = (params, channel) => {
// 获取左侧类目数据
if (result[1].code === 200) {
let dps = {};
if (params.query) {
dps.query = params.query;
}
finalResult.search = {
leftContent: searchHandler.handleSortData(result[1].data.sort, params)
leftContent: searchHandler.handleSortData(result[1].data.sort, dps)
};
}
... ...
... ... @@ -7,7 +7,6 @@
module.exports = () => {
return (req, res, next) => {
let searchReg = /^\/product\//;
if (req.subdomains.length) {
... ... @@ -28,7 +27,11 @@ module.exports = () => {
}
break;
case 'list': // 商品列表
req.url = req.path === '/new' ? '/product/list/new' : '/product/list/index';
if (!req.path || req.path === '/') {
req.url = '/product/list/index';
} else if (req.path === '/new') {
req.url = '/product/list/new';
}
break;
case 'sale': // 促销
if (!req.path || req.path === '/') {
... ...