Authored by 周少峰

so redirect to chanpin

... ... @@ -9,9 +9,6 @@ const mRoot = '../models';
const search = require(`${mRoot}/search`);
const _ = require('lodash');
const helpers = global.yoho.helpers;
const utils = '../../../utils';
const stringCode = require(`${utils}/string-code`);
const config = global.yoho.config;
/**
... ... @@ -175,37 +172,6 @@ const searchLessRecommend = (req, res, next) => {
* @param {[type]} res [description]
* @return {[type]} [description]
*/
const keyword = (req, res, next) => {
let params = req.query;
let query = stringCode.hexToUtf8(req.params.id || '');
let resData = {};
return search.getSearchKeywordData(Object.assign(params, {query: query}),
req.yoho.channel).then(result => {
Object.assign(resData, result, {
pageNoFollow: true,
title: `${query}价格_图片_品牌_怎么样-YOHO!BUY有货`,
keywords: `${query},${query}价格,${query}图片,${query}怎么样,${query}品牌,YOHO!BUY有货`,
description: `YOHO!BUY有货网yohobuy.com是国内专业的${query}网上潮流购物商城,为您找到${_.get(result,
'search.totalCount', 0)}${query}、产品的详细参数,实时报价,价格行情,图片、评价、品牌等信息。买${query},就上YOHO!BUY有货`
});
if (!_.get(resData, 'search.goods') || !_.get(resData, 'search.goods').length) {
_.set(resData, 'search.keyWord', query);
return res.render('search/no-result', resData);
}
res.render('search/index', resData);
}).catch(next);
};
/**
* 搜索推荐列表页
* @param {[type]} req [description]
* @param {[type]} res [description]
* @return {[type]} [description]
*/
const keyId = (req, res, next) => {
let params = req.query;
let id = req.params.id;
... ... @@ -242,7 +208,6 @@ module.exports = {
searchFilterBrands,
searchHistory, // 搜索历史记录
searchLessRecommend,
keyword,
keyId
};
... ...
... ... @@ -102,7 +102,6 @@ router.get('/search/suggest', search.suggest); // 搜索提示
router.get('/api/suggest', search.suggest4Old);
router.get('/search/history', search.searchHistory); // 搜索历史提示
router.get('/search/less/recommend', search.searchLessRecommend);// 搜索少或无 有可能喜欢
router.get('/search/keyword/:id', search.keyword);
router.get('/search/chanpin/:id', search.keyId);
// 商品分类列表页
... ...
... ... @@ -73,9 +73,18 @@ module.exports = [
// 推荐词列表页
{
type: TYPE.rewrite,
type: TYPE.redirect,
origin: /^\/so\/(.*)\.html(.*)/,
target: (req, match, p1) => `/product/search/keyword/${p1}`
target: (req, match, p1) => {
let urls = {
E6B3A2E782B9E995BFE8A296E8A1ACE8A1A3: 123,
E688B7E5A496E58C85E9858D: 124
};
return urls[p1] ?
helpers.urlFormat(`/chanpin/${urls[p1]}.html`, null, 'www') :
helpers.urlFormat('/', null, 'www');
}
},
// 推荐词id列表页
... ...