Authored by yyq

Merge branch 'feature/seoUrl302' into release/5.5

... ... @@ -127,7 +127,42 @@ exports.new = (req, res, next) => {
res.render('list/index', resData);
}).catch(next);
};
/**
* 新品到着(带频道)
* @param {[type]} req [description]
* @param {[type]} res [description]
* @return {[type]} [description]
*/
exports.newWithChannel = (req, res, next) => {
let channel = req.params[0];
req.query = req.query || {};
// 根据 XXXX-new 中的频道处理查询参数
switch (channel) {
case 'boys':
req.yoho.channel = 'boys';
req.query = Object.assign({gender: '1,3', msort: '1,3,4,6,7,8,308,360'}, req.query);
break;
case 'girls':
req.yoho.channel = 'girls';
req.query = Object.assign({gender: '2,3', msort: '1,3,4,6,7,8,308,360'}, req.query);
break;
case 'kids':
req.yoho.channel = 'kids';
req.query = Object.assign({gender: '1,2,3', msort: '365'}, req.query);
break;
case 'lifestyle':
req.yoho.channel = 'lifestyle';
req.query = Object.assign({gender: '1,2,3', msort: '10'}, req.query);
break;
default:
break;
}
this.new(req, res, next);
};
/**
... ...
... ... @@ -9,6 +9,8 @@
const mRoot = '../models';
const sale = require(`${mRoot}/sale`); // sale model
const channelList = ['boys', 'girls', 'kids', 'lifestyle'];
/**
* sale 首页
* @param {[type]} req [description]
... ... @@ -18,6 +20,11 @@ const sale = require(`${mRoot}/sale`); // sale 页 model
exports.index = (req, res, next) => {
let channel = req.yoho.channel;
// SEO url 改造
if (req.params && req.params[0] && channelList.indexOf(req.params[0]) > -1) {
channel = req.params[0];
}
// 真实数据输出
sale.getSaleIndexData(channel).then(result => {
res.render('sale/index', Object.assign({
... ...
... ... @@ -471,7 +471,7 @@ const getShopAbout = (shopId, uid, channel) => {
shopId: shopId,
bannerHeight: 150,
shopHome: `/?shopId=${shopId}`,
shopIntro: `/about?shopId=${shopId}`,
shopIntro: `/shop${shopId}-about`,
coled: _.get(result, '[2].data.is_favorite', 'N') === 'Y'
});
_.set(resData, 'brand.shopBanner', decorator.shopTopBannerBase);
... ... @@ -928,7 +928,7 @@ const getBaseShopData = (params, extra, channel, shopId) => {
shopId: shopId,
bannerHeight: 150,
shopHome: `/?shopId=${shopId}`,
shopIntro: `/about?shopId=${shopId}`,
shopIntro: `/shop${shopId}-about`,
coled: _.get(result[2], 'data.is_favorite', 'N') === 'Y'
});
... ...
... ... @@ -24,6 +24,21 @@ const checksName = {
limited: '限量'
};
const sortFilterParam = (param) => {
let resData = [];
_.forEach(param, (value, key) => {
resData.push({
key: key,
value: value
});
});
return _.sortBy(resData, [o => {
return o.key;
}]);
};
/**
* 处理用于筛选的 URL , 拼接 URL 参数
* @param originParam 当前 URL 中的参数
... ... @@ -39,10 +54,13 @@ const handleFilterUrl = (originParam, newParam, delParam) => {
tempOriginParam = Object.assign(tempOriginParam, originParam, newParam);
delete tempOriginParam.uid;
_.forEach(tempOriginParam, function(value, key) {
if (!delParam[key] && value) {
_.forEach(sortFilterParam(tempOriginParam), info => {
if (!delParam[info.key] && info.value) {
// NOTE: 这里会对 query 进行编码,因为 query 有可以能是中文
dest += key === 'query' ? `${key}=${encodeURIComponent(value)}&` : `${key}=${value}&`;
if (info.key === 'query') {
info.value = encodeURIComponent(info.value);
}
dest += `${info.key}=${info.value}&`;
}
});
... ... @@ -65,7 +83,12 @@ const handleCheckedData = (params, origin, param) => {
let tempPatam = _.cloneDeep(params);
// 删除选中
delete tempPatam[param];
if (param === 'gender') {
// 某些特殊带频道信息页面,清除性别,需将gender设为1,2,3 (2017-3 配合SEO进行URL改造)
tempPatam[param] = '1,2,3';
} else {
delete tempPatam[param];
}
dest.push({
name: value.name,
... ... @@ -779,7 +802,8 @@ exports.handleFilterData = (origin, params, total) => {
}
// 清除所有选中数据
let remainParams = {};
// 某些特殊带频道信息页面,清除性别,需将gender设为1,2,3 (2017-3 配合SEO进行URL改造)
let remainParams = {gender: '1,2,3'};
if (params.id) {
remainParams.id = params.id;
... ...
... ... @@ -46,6 +46,7 @@ const newArrive = require(`${cRoot}/newArrive`);
// 商品促销routers
router.get('/sale', sale.index); // sale 首页
router.get(/\/(.*)-sale/, sale.index); // sale 首页(SEO改造)
router.get('/sale/discount/detail', sale.discount); // 折扣专场详情页
router.get('/sale/vip', sale.vip); // VIP 活动专区
router.get('/sale/breakingYards', sale.breakingYards); // 断码区
... ... @@ -95,6 +96,7 @@ router.get('/list/index', gbk2utf, list.index);
// 新品到着
router.get('/list/new', list.new);
router.get(/\/list\/(.*)-new/, list.newWithChannel);
// 品牌店铺
router.get('/index/brand', list.brand); // 品牌店铺页
... ...
... ... @@ -52,6 +52,8 @@ module.exports = () => {
{ // eslint-disable-line
if (!req.path || req.path === '/') {
req.url = '/product/list/index';
} else if (/\/(.*)-new/.exec(req.path) !== null) {
req.url = `/product/list/${RegExp.$1}-new`;
} else if (req.path === '/new') {
req.url = '/product/list/new';
}
... ... @@ -67,12 +69,14 @@ module.exports = () => {
}
default: // 其它(识别为品牌)
{ // eslint-disable-line
req.query.domain = req.subdomains[0];
if (!req.path || req.path === '/') {
req.url = `/product/index/brand?domain=${req.subdomains[0]}`;
req.query.domain = req.subdomains[0];
} else if (req.path === '/about') {
req.url = `/product/index/about?domain=${req.subdomains[0]}`;
req.query.domain = req.subdomains[0];
} else if (/\/shop([\d]+)-about/.exec(req.path) !== null) {
req.query.shopId = RegExp.$1;
req.url = '/product/index/about';
}
break;
}
... ...