Authored by 郭成尧

url-rewrite

... ... @@ -11,6 +11,7 @@ const headerModel = require('../../../doraemon/models/header');
const searchModel = require(`${mRoot}/search`);
const _ = require('lodash');
const helpers = global.yoho.helpers;
const stringProcess = require(`${utils}/string-process`);
const searchProcess = require(`${utils}/search-process`);
const productProcess = require(`${utils}/product-process`);
const listParamsProcess = require(`${utils}/list-params-process`);
... ... @@ -206,6 +207,10 @@ exports.search = (req, res, next) => {
params.uid = uid;
}
if (params.query) {
params.query = stringProcess.decodeURIComponent(params.query);
}
params.isApp = req.yoho.isApp;
params.limit = 24;
... ...
... ... @@ -141,14 +141,15 @@ router.get('/seckill/list', seckill.indexData);
router.post('/seckill/remind', seckill.remind); // only app; 秒杀提醒
router.get('/seckill/get-product-list', seckill.getProductList); // 秒杀列表根据活动id获取商品列表
router.get('/search/index', search.index); // 搜索主页
router.get('/search', search.index); // 搜索主页
router.get('/search/list', rewrite.resolvePathParams, search.list); // 搜索落地页
router.get('/search/filter', rewrite.resolvePathParamsAjax, search.filter); // filter
router.get('/search/fuzzyDatas', search.fuzzyDatas); // fuzzyDatas
router.get('/search/search', rewrite.resolvePathParamsAjax, search.search); // ajax 请求商品数据
router.get('/search/so/:query.html', rewrite.sortParams, chanpin.keyword); // 推广落地页
router.get('/search/chanpin/:id.html', rewrite.sortParams, chanpin.keyId);
router.get('/search/chanpin/goods', chanpin.searchGoods); // 搜索的商品
router.get('/search/list', rewrite.sortParams, search.list); // 搜索落地页
router.get('/search/filter', search.filter); // filter
router.get('/search/fuzzyDatas', search.fuzzyDatas); // fuzzyDatas
router.get('/search/search', search.search); // ajax 请求商品数据
router.get('/search/brand/goods', search.searchBrandGoods); // 搜索品牌下的商品
router.get('/search/shop/goods', search.searchShopGoods); // 搜索店铺下的商品
... ...
... ... @@ -35,14 +35,14 @@ module.exports = () => {
// 有查询关键字
if (_.keys(req.query).length) {
req.url = `/product/search/list?${querystring.stringify(req.query)}`;
return res.redirect(301, listParamsProcess.generatePathUrl(req.query, 'search/list'));
} else {
req.url = `/product/search/index?${querystring.stringify(req.query)}`;
req.url = '/search';
}
}
if (req.path === '/search') {
req.url = `/product/search/index?${querystring.stringify(req.query)}`;
return res.redirect(301, listParamsProcess.generatePathUrl(req.query, 'search/list'));
}
break;
... ...
... ... @@ -73,6 +73,11 @@ module.exports = () => {
req.url = `/product${req.url}`;
}
if (/^\/search/.test(req.url)) {
// 搜索
req.url = `/product${req.url}`;
}
next();
};
};
... ...