Authored by shijian

更改yield方式

... ... @@ -1019,51 +1019,40 @@ const _getIntroInfo = (productSkn, maxSortId, additionalData)=> {
* @param array $navs
* @return array
*/
const _getSeoByGoodsInfo = (req, goodsInfo, navs) => {
return co(function*() {
let title, keywords, description;
let redisSeo = yield tdk('skn', goodsInfo.skn, req);
if (redisSeo[0]) {
req.tdk = {
title: redisSeo[1],
keywords: redisSeo[2],
description: redisSeo[3]
};
}
let brandName = '';
let sortName = '';
const _getSeoByGoodsInfo = (goodsInfo, navs) => {
let title = '';
let brandName = '';
let sortName = '';
goodsInfo = goodsInfo || {};
navs = navs || [];
goodsInfo = goodsInfo || {};
navs = navs || [];
if (goodsInfo.brandName) {
title = goodsInfo.brandName + ' ';
brandName = goodsInfo.brandName;
}
if (goodsInfo.brandName) {
title = goodsInfo.brandName + ' ';
brandName = goodsInfo.brandName;
}
if (_.get(navs, '[1].name')) {
sortName = navs[1].name;
title += navs[1].name + '|';
}
if (_.get(navs, '[1].name')) {
sortName = navs[1].name;
title += navs[1].name + '|';
}
title += goodsInfo.name + '正品 | YOHO!BUY 有货';
title += goodsInfo.name + '正品 | YOHO!BUY 有货';
keywords = brandName + sortName + ',' + brandName + '官网专卖店,' + brandName + '官方授权店,' +
brandName + '正品,' + brandName + '打折,' + brandName + '折扣店,' + brandName + '真品,' + brandName + '代购';
let keywords = brandName + sortName + ',' + brandName + '官网专卖店,' + brandName + '官方授权店,' +
brandName + '正品,' + brandName + '打折,' + brandName + '折扣店,' + brandName + '真品,' + brandName + '代购';
description = `YOHO!BUY 有货-${brandName}官方授权店,${goodsInfo.name}图片、报价、介绍。` +
`YOHO!BUY 有货${brandName}官网专卖店提供${brandName}正品、${brandName}真品、 ${brandName}打折、${brandName}代购等。`;
let description = `YOHO!BUY 有货-${brandName}官方授权店,${goodsInfo.name}图片、报价、介绍。` +
`YOHO!BUY 有货${brandName}官网专卖店提供${brandName}正品、${brandName}真品、 ${brandName}打折、${brandName}代购等。`;
let cononicalURL = goodsInfo.productUrl;
let cononicalURL = goodsInfo.productUrl;
return {
title: title,
keywords: keywords.replace(/~+/, ''),
description: description,
cononicalURL: cononicalURL
};
})();
return {
title: title,
keywords: keywords.replace(/~+/, ''),
description: description,
cononicalURL: cononicalURL
};
};
// 优惠券
... ... @@ -1549,7 +1538,8 @@ const showMainAsync = (req, data) => {
_getSortNavAsync(smallSortId, data.gender), // 面包屑导航
HeaderModel.requestHeaderData(data.channel), // 通用头部数据
_getProductIntroAsync(productId, productSkn), // 商品详细介绍
curUserProduct(productData) // 商品详细价格
curUserProduct(productData), // 商品详细价格
tdk('skn', data.skn, req) //seo
]);
let smallSortNavigator = requestData[0];
... ... @@ -1557,6 +1547,14 @@ const showMainAsync = (req, data) => {
let productDescription = requestData[2];
let productInfo = requestData[3];
if (requestData[4][0]) {
req.tdk = {
title: requestData[4][1],
keywords: requestData[4][2],
description: requestData[4][3]
};
}
// 拼装数据
let result = {};
... ... @@ -1570,7 +1568,7 @@ const showMainAsync = (req, data) => {
result.deatil = Object.assign(result.detail, intro);
// seo
result.seo = yield _getSeoByGoodsInfo(req, productInfo.goodsInfo, smallSortNavigator);
result.seo = _getSeoByGoodsInfo(productInfo.goodsInfo, smallSortNavigator);
// 商品页面统计
result.statGoodsInfo = Object.assign({fullSortName: smallSortNavigator.map(x => x.name).join('-')},
... ...