Authored by 毕凯

Merge branch 'hotfix/seoList' into 'release/6.4'

Hotfix/seo list



See merge request !1203
... ... @@ -15,6 +15,24 @@ const redirect = (req, res) => {
return res.redirect(301, pathParamsUrl);
};
const _formatParams = (query) => {
let finalParams = {};
if (query.price) {
finalParams.price = query.price;
}
if (query.color) {
finalParams.color = query.color;
}
if (query.gender) {
finalParams.gender = query.gender;
}
return finalParams;
};
const list = (req, res, next) => {
let brand = req.query.brand;
let sort = req.query.sort;
... ... @@ -37,7 +55,7 @@ const list = (req, res, next) => {
param.sort = sort;
}
let arrs = [model.list(param)];
let arrs = [model.list(_.assign(param, _formatParams(req.query)))];
if (brand) {
arrs.push(model.getBrand({
... ...
... ... @@ -13,7 +13,7 @@ const newModel = require(`${mRoot}/new`);
const searchModel = require(`${mRoot}/search`);
const _ = require('lodash');
const helpers = global.yoho.helpers;
const qs = require('querystring');
const listParamsProcess = require(`${utils}/list-params-process`);
const channelToAppChannel = (channel) => {
return {
... ... @@ -109,12 +109,10 @@ const newGoods = (req, res, next) => {
// 301到新路由
const newGoodsRedirect = (req, res) => {
let param = qs.stringify(req.query);
let pathParamsUrl = listParamsProcess.generatePathUrl(req.query, req.path);
let urlPath = _.replace(pathParamsUrl, '//m.yohobuy.com/new', `//m.yohobuy.com/${req.yoho.channel}-new`);
if (param) {
param = '?' + param;
}
res.redirect(301, `/${req.yoho.channel}-new/${param}`);
return res.redirect(301, urlPath);
};
/**
... ...
... ... @@ -72,7 +72,7 @@ exports.detail = (param) => {
}
if (result.brand_info && result.brand_info.brand_id) {
result.brand_info.brand_url = `//m.yohobuy.com/product/global/list?brand=${result.brand_info.brand_id}`;
result.brand_info.brand_url = `//m.yohobuy.com/list/global/bd${result.brand_info.brand_id}`;
}
if (result.illustrate_contents && result.illustrate_contents.length) {
... ...
... ... @@ -117,8 +117,8 @@ router.get('/:channel-sale/vip(/:pathParams)?',
rewrite.resolve,
rewrite.resolvePathParams,
sale.vip);
router.get('/:channel-sale/', rewrite.resolve, sale.index);
router.get('/:channel-sale/discount', rewrite.resolve, sale.discount);
router.get('/:channel-sale(/)?(*)?', rewrite.resolve, sale.index);
router.get('/sale/discount', sale.discount);
router.get('/sale/discount/detail', sale.discountDetail);
... ...
... ... @@ -73,6 +73,11 @@ module.exports = () => {
req.url = `/product${req.url}`;
}
if (/^\/sale/.test(req.url)) {
// 匹配 life-style-sale
req.url = `/product${req.url}`;
}
next();
};
};
... ...