Authored by yyq

tdk

... ... @@ -12,6 +12,7 @@ const productProcess = require(`${utils}/product-process-simple`);
const searchHandler = require('./search-handler');
const listHandler = require('./list-handler');
const shopHandler = require('./shop-handler');
const seoHandler = require('./seo-handler');
const helpers = global.yoho.helpers;
const crypto = global.yoho.crypto;
const _ = require('lodash');
... ... @@ -149,8 +150,10 @@ function getListData(params, channel) {
}
});
const seo = seoHandler.getListSeo(channel, sortList, checkedList);
// seo
const seo = searchHandler.getListSeo(channel, sortList, checkedList);
// const seo = searchHandler.getListSeo(channel, sortList, checkedList);
if (sortName) {
return redis.all([
... ...
... ... @@ -71,6 +71,41 @@ const saleDefaultSeoMap = {
}
};
const listDefaultTdk = {
title: '【潮流商品】_潮流男装_潮流女装_潮流童装-YOHO!BUY 有货',
keywords: '潮流男装,潮流女装,潮流童装',
description: '潮流网购就上YOHO!BUY有货,有货网潮流商品专卖店提供潮流商品品牌、潮流商品价格、潮流商品图片等信息。销售正品新款潮流男装、潮流女装、潮流童装,全场低至4折,★全场品牌正品保证,支持货到付款!★' // eslint-disable-line
};
const getListSeo = (cen, sorts, checked) => {
let {brand, channel, color, style, sort} = getSeoCheckedParamsName(sorts, checked);
if (brand && _.indexOf(brand, '、') > -1) {
brand = '';
}
let name = _.compact([brand, channel, color, style, sort]).join('');
if (!name) {
return listDefaultTdk;
}
let desc = sort ? `${sort}:潮流网购就上YOHO!BUY有货,有货网${sort}专卖店提供${sort}品牌、${sort}价格、${sort}图片等信息。销售正品新款${sort},全场低至4,★全场品牌正品保证,支持货到付款!★` : listDefaultTdk.description; // eslint-disable-line
if (name === sort) {
return {
title: `【${sort}_${sort}品牌_${sort}价格_${sort}图片-YOHO!BUY 有货`,
keywords: `${sort},${sort}品牌,${sort}价格,${sort}图片`,
description: desc
};
} else {
return {
title: `【${name}_价格,图片,款式-YOHO!BUY 有货`,
keywords: name,
description: desc
};
}
};
const getSaleListSeo = (sorts, checked, type) => {
const defaultTdk = saleDefaultSeoMap[type] || {};
const kd = getSeoCheckedParamsName(sorts, checked);
... ... @@ -176,6 +211,7 @@ const getShopListSeo = (sorts, checked, shopInfo) => {
};
module.exports = {
getListSeo,
getSeoCheckedParamsName,
getSaleListSeo,
getGlobalListSeo,
... ...
... ... @@ -9,7 +9,6 @@
const _ = require('lodash');
// const logger = global.yoho.logger;
const queryString = require('querystring');
const minToFullMap = {
ag: 'age_level',
... ... @@ -48,9 +47,21 @@ const minToFullMap = {
};
const fullToMinMap = _.transform(minToFullMap, (result, value, key) => {
result[value] = key;
if (_.indexOf(['gender', 'brand', 'category_id', 'color', 'style'], value) > -1) {
result[value] = key;
}
}, {});
const sringifyParam = (param) => {
let arr = [];
_.forEach(param, (value, key) => {
arr.push(`${key}=${value}`);
});
return arr.join('&');
};
const transformKey = (params, isFull) => {
if (_.isEmpty(params)) {
return params;
... ... @@ -78,6 +89,12 @@ const transformKey = (params, isFull) => {
};
};
/**
* 筛选参数转化 min->full
* @param path 伪静态path
* @returns {Object}
*/
const minPathToFullParam = (path) => {
let obj = {};
... ... @@ -98,9 +115,11 @@ const minPathToFullParam = (path) => {
};
/**
* 筛选参数
* @param originParam 当前 URL 中的参数
* @param newParam 要拼接的 参数
* 筛选参数转化 full->min
* @param uri 基础uri
* @param params 当前 URL 中的参数
* @param newObj 新增的参数
* @param delObj 删除的参数
* @returns {string}
*/
const fullParamToMinPath = (uri, params, newObj, delObj = {}) => {
... ... @@ -123,7 +142,7 @@ const fullParamToMinPath = (uri, params, newObj, delObj = {}) => {
});
if (!_.isEmpty(transParams.extraParams)) {
extraQs = '?' + queryString.stringify(transParams.extraParams);
extraQs = '?' + sringifyParam(transParams.extraParams);
}
return _.trimEnd(uri, '/') + '/' + _.sortBy(pathArr).join('-') + extraQs;
... ...