Authored by 郭成尧

init

... ... @@ -39,7 +39,7 @@ module.exports = class extends global.yoho.BaseModel {
if (firstItem.sub && firstItem.sub.length) {
_.map(firstItem.sub, function(secondItem) {
secondItem.url = helpers.urlFormat('/', utils.mapSort({
sort: _.get(secondItem, 'relation_parameter.sort'),
categoryId: _.get(secondItem, 'category_id'),
sort_name: secondItem.category_name,
gender: genderMap[key] || ''
}), 'list');
... ... @@ -48,14 +48,14 @@ module.exports = class extends global.yoho.BaseModel {
firstItem.sub.unshift({
category_name: `全部${firstItem.category_name}`,
url: helpers.urlFormat('/', utils.mapSort({
sort: _.get(firstItem, 'relation_parameter.sort'),
categoryId: _.get(firstItem, 'category_id'),
sort_name: firstItem.category_name,
gender: genderMap[key] || ''
}), 'list')
});
} else {
firstItem.url = helpers.urlFormat('/', utils.mapSort({
sort: _.get(firstItem, 'relation_parameter.sort'),
categoryId: _.get(firstItem, 'category_id'),
sort_name: firstItem.category_name,
gender: genderMap[key] || ''
}), 'list');
... ...
... ... @@ -212,6 +212,7 @@ const category = (req, res, next) => {
}
let params = Object.assign({}, req.query);
let seoTitle = decodeURIComponent(req.query.title || req.query.sort_name);
/* 勿修改,唤起 APP 使用 */
let appParams = Object.assign({}, req.query, {
... ... @@ -252,7 +253,7 @@ const category = (req, res, next) => {
currentHref: 'https://www.yohobuy.com/list?' // TODO
},
pageHeader: headerModel.setNav({
navTitle: req.query.title || req.query.sort_name
navTitle: seoTitle
}),
goodList: params,
firstPageGoods: firstPageGoods || [],
... ... @@ -263,7 +264,7 @@ const category = (req, res, next) => {
localCss: true,
appPath: appPath,
introText: req.query.intro_text
}, searchProcess.getListSeoData(req.query.gender, req.query.title || req.query.sort_name)));
}, searchProcess.getListSeoData(req.query.gender, seoTitle)));
}).catch(next);
};
... ...
... ... @@ -3,6 +3,7 @@
*/
const querystring = require('querystring');
const helpers = global.yoho.helpers;
const listParamsProcess = require('../../utils/list-params-process');
module.exports = () => {
return (req, res, next) => {
... ... @@ -73,6 +74,8 @@ module.exports = () => {
}
if (/^\/list/.test(req.url)) {
req.query = listParamsProcess.getParams(req.url);
// 列表页路由重写 新路由
req.url = `/product/index/index?${querystring.stringify(req.query)}`;
}
... ...
const _ = require('lodash');
/**
* 参数列表
*/
const PARAMMAP = {
gd: 'gender',
sn: 'sort_name',
so: 'sort',
ms: 'msort',
mi: 'misort',
tp: 'type',
sz: 'size',
cl: 'color',
pc: 'price',
bd: 'brand',
qr: 'type'
};
/**
* 获取标准参数
*/
const getParams = (url) => {
let params = [];
let paramStringRaw = _.split(url, '/list/')[1];
if (paramStringRaw) {
let paramsRaw = _.split(paramStringRaw, '-');
_.forEach(paramsRaw, paramRaw => {
let keyRaw = paramRaw.substr(0, 2);
let valueRaw = _.replace(paramRaw, keyRaw, '');
if (PARAMMAP[keyRaw]) {
params[PARAMMAP[keyRaw]] = valueRaw;
}
});
}
return params;
};
/**
* 生成链接
*/
const generateUrl = () => {
return '';
};
module.exports = {
getParams,
generateUrl
};
... ...