Authored by 郭成尧

list-params-handle

@@ -16,6 +16,7 @@ const searchModel = require(`${mRoot}/search`); @@ -16,6 +16,7 @@ const searchModel = require(`${mRoot}/search`);
16 const shopModel = require(`${mRoot}/shop`); 16 const shopModel = require(`${mRoot}/shop`);
17 const searchProcess = require(`${utils}/search-process`); 17 const searchProcess = require(`${utils}/search-process`);
18 const stringProcess = require(`${utils}/string-process`); 18 const stringProcess = require(`${utils}/string-process`);
  19 +const listParamsProcess = require(`${utils}/list-params-process`);
19 20
20 /** 21 /**
21 * 从 useragent 获取 uid 22 * 从 useragent 获取 uid
@@ -212,7 +213,7 @@ const category = (req, res, next) => { @@ -212,7 +213,7 @@ const category = (req, res, next) => {
212 } 213 }
213 214
214 let params = Object.assign({}, req.query); 215 let params = Object.assign({}, req.query);
215 - let seoTitle = decodeURIComponent(req.query.title || req.query.sort_name); 216 + let seoTitle = decodeURIComponent(req.query.title || req.query.sort_name || '商品列表');
216 217
217 /* 勿修改,唤起 APP 使用 */ 218 /* 勿修改,唤起 APP 使用 */
218 let appParams = Object.assign({}, req.query, { 219 let appParams = Object.assign({}, req.query, {
@@ -269,6 +270,16 @@ const category = (req, res, next) => { @@ -269,6 +270,16 @@ const category = (req, res, next) => {
269 }; 270 };
270 271
271 /** 272 /**
  273 + * 参数处理的前置处理,新的路由
  274 + */
  275 +const listNew = (req, res, next) => {
  276 + req.query = listParamsProcess.getParams(req.url);
  277 +
  278 + // 转发到旧的处理方法
  279 + category(req, res, next);
  280 +};
  281 +
  282 +/**
272 * 品牌店铺的入口 283 * 品牌店铺的入口
273 * @param req 284 * @param req
274 * @param res 285 * @param res
@@ -547,5 +558,6 @@ module.exports = { @@ -547,5 +558,6 @@ module.exports = {
547 shopFav, 558 shopFav,
548 baseShopFav, 559 baseShopFav,
549 shopCategory, 560 shopCategory,
550 - getBrandCouponsList 561 + getBrandCouponsList,
  562 + listNew
551 }; 563 };
@@ -158,6 +158,7 @@ router.get('/search/shop/goods', search.searchShopGoods); // 搜索店铺下的 @@ -158,6 +158,7 @@ router.get('/search/shop/goods', search.searchShopGoods); // 搜索店铺下的
158 // 品类 158 // 品类
159 router.get('/index/index', rewrite.sortParams, list.category); 159 router.get('/index/index', rewrite.sortParams, list.category);
160 router.get('/list/index', rewrite.sortParams, list.category); // 兼容 PC 的链接 160 router.get('/list/index', rewrite.sortParams, list.category); // 兼容 PC 的链接
  161 +router.get(/^\/list/, list.listNew); // 列表新的 URL
161 162
162 // 品牌 | 店铺 163 // 品牌 | 店铺
163 router.get('/index/shopAppCookie', list.shopAppCookie); 164 router.get('/index/shopAppCookie', list.shopAppCookie);
1 /** 1 /**
2 * URL 重写(主要用于兼容原来PHP的连接) 2 * URL 重写(主要用于兼容原来PHP的连接)
3 */ 3 */
4 -const querystring = require('querystring'); 4 +
5 const helpers = global.yoho.helpers; 5 const helpers = global.yoho.helpers;
6 -const listParamsProcess = require('../../utils/list-params-process');  
7 6
8 module.exports = () => { 7 module.exports = () => {
9 return (req, res, next) => { 8 return (req, res, next) => {
@@ -74,10 +73,8 @@ module.exports = () => { @@ -74,10 +73,8 @@ module.exports = () => {
74 } 73 }
75 74
76 if (/^\/list/.test(req.url)) { 75 if (/^\/list/.test(req.url)) {
77 - req.query = listParamsProcess.getParams(req.url);  
78 -  
79 - // 列表页路由重写 新路由  
80 - req.url = `/product/index/index?${querystring.stringify(req.query)}`; 76 + // 列表页路由重写 跳转到新的列表路由,进行参数的前置处理
  77 + req.url = `/product/${req.url}`;
81 } 78 }
82 79
83 next(); 80 next();
@@ -7,6 +7,7 @@ const PARAMMAP = { @@ -7,6 +7,7 @@ const PARAMMAP = {
7 gd: 'gender', 7 gd: 'gender',
8 sn: 'sort_name', 8 sn: 'sort_name',
9 so: 'sort', 9 so: 'sort',
  10 + ci: 'categoryId',
10 ms: 'msort', 11 ms: 'msort',
11 mi: 'misort', 12 mi: 'misort',
12 tp: 'type', 13 tp: 'type',
@@ -14,7 +15,7 @@ const PARAMMAP = { @@ -14,7 +15,7 @@ const PARAMMAP = {
14 cl: 'color', 15 cl: 'color',
15 pc: 'price', 16 pc: 'price',
16 bd: 'brand', 17 bd: 'brand',
17 - qr: 'type' 18 + qr: 'query'
18 }; 19 };
19 20
20 /** 21 /**