Authored by 毕凯

Merge remote-tracking branch 'origin/feature/baiduJsonLD' into release/6.4

... ... @@ -15,6 +15,7 @@ const guangProcess = require(`${global.utils}/guang-process`);
const headerModel = require('../../../doraemon/models/header'); // 头部model
const aboutModel = require('../../../doraemon/models/about');
const tdk = require('../../../utils/getTDK');
const moment = require('moment');
const qs = require('querystring');
const channels = {
boys: 1,
... ... @@ -227,11 +228,13 @@ const index = (req, res, next) => {
data.guang.author.url = helpers.https(url);
}
let guang = data.guang;
let singleImages = _.filter(detail.getArticleContent, {singleImage: {template_name: 'single_image'}});
let mipPic = _.get(singleImages, '[0].singleImage.data[0].src', '');
guang.detail = {
id: _.get(detail, 'getArticle.id'),
title: detail.getArticle.article_title,
publishTime: detail.getArticle.publishTime,
publishTime: moment.unix(detail.getArticle.publish_time).format('YYYY-MM-DDTHH:mm:ss'),
pageView: _.get(praise, 'browseNum', 0),
content: [],
praise: _.get(praise, 'praiseNum', 0),
... ... @@ -302,7 +305,14 @@ const index = (req, res, next) => {
isWeixin: isWeixin,
localCss: true,
isShare: isShare,
id: id
id: id,
showAnaJson: {
miptitle: data.title,
mipPublishTime: guang.detail.publishTime,
mipPics: [mipPic],
mipDes: guang.shareDesc,
mipUrl: `${req.protocol}://m.yohobuy.com/guang/${id}.html`
}
}, data, parameter));
})().catch(next);
};
... ...
... ... @@ -19,7 +19,7 @@ const channels = {
};
const mipDate = (day) => {
return moment(day).format('YYYY-MM-DDTHH:mm:ss');
return moment.unix(day).format('YYYY-MM-DDTHH:mm:ss');
};
// const testStr = '';
... ... @@ -164,12 +164,16 @@ const detailIndex = (req, res, next) => {
data.guang.author.url = helpers.https(url);
}
let guang = data.guang;
let mipPublishTime = mipDate(detail.getArticle.publish_time);
let singleImages = _.filter(detail.getArticleContent, {singleImage: {template_name: 'single_image'}});
let mipPic = _.get(singleImages, '[0].singleImage.data[0].src', '');
guang.detail = {
id: _.get(detail, 'getArticle.id'),
title: detail.getArticle.article_title,
publishTime: detail.getArticle.publishTime,
publishTime: moment.unix(detail.getArticle.publish_time).format('YYYY-MM-DD HH:mm:ss'),
pageView: detail.getArticle.pageViews,
content: []
};
... ... @@ -208,16 +212,18 @@ const detailIndex = (req, res, next) => {
gender: gender,
localStyle: processContents.css,
title: detail.getArticle.article_title,
mipId: id,
mipPublishTime: mipDate(detail.getArticle.publish_time * 1000),
mipPic: detail.getArticle.cover_image ? detail.getArticle.cover_image.split('?')[0] : '',
mipDes: detail.getArticle.article_summary,
mipUrl: `https://m.yohobuy.com${req.originalUrl}`,
miphtml: `https://m.yohobuy.com/mip/guang/${id}.html`,
canonical: {
currentHref: `https://m.yohobuy.com/guang/${id}.html`
},
showAnaJson: true
showAnaJson: {
miptitle: `${detail.getArticle.article_title} | Yoho!Buy有货 | 潮流购物逛不停`,
mipId: id,
mipPublishTime: mipPublishTime,
mipPics: [mipPic],
mipDes: detail.getArticle.article_summary,
mipUrl: `${req.protocol}://m.yohobuy.com${req.originalUrl}`,
miphtml: `${req.protocol}://m.yohobuy.com/mip/guang/${id}.html`
}
}, data));
})().catch(next);
};
... ...
... ... @@ -9,6 +9,7 @@ const newDetailModel = require('../models/new-detail');
const listModel = require('../models/list');
const headerModel = require('../../../doraemon/models/header'); // 头部model
const qs = require('querystring');
const moment = require('moment');
const tdk = require('../../../utils/getTDK');
const helpers = global.yoho.helpers;
... ... @@ -57,6 +58,20 @@ const newDetail = {
let appPath = 'yohobuy://yohobuy.com/goapp?openby:yohobuy={"action":"go.productDetail","params":' +
JSON.stringify(appParams) +
'}';
let mipPics = _.map(_.get(result, 'bannerTop.list', []), item => {
return item.img.replace(/\?(.*)/g, '?imageView2/{mode}/w/{width}/h/{height}');
});
if (mipPics.length <= 0) {
mipPics.push(_.get(result, 'bannerTop.img', '').replace(
/\?(.*)/g,
'?imageView2/{mode}/w/{width}/h/{height}'
));
}
let title = `【${result.brandName}${result.sortName}${result.goodsName}|YOHO!BUY 有货`;
let description = result.goodsName + ' 有货网仅售' + result.goodsPrice.currentPrice + '元,购买' +
result.brandName + result.sortName + ',了解' + result.brandName + result.sortName + '商品信息就上有货网!';
// param:品牌ID, name:品牌名称, miniQrType 1:商品 2 品牌,miniapp_type 0:有货,1:新与力
let miniPath = `${global.yoho.config.domains.api}wechat/miniapp/img-check.jpg?miniapp_type=0&param=${result.productSkn}&miniQrType=1`.replace(/http:|https:/, ''); // eslint-disable-line
... ... @@ -68,16 +83,22 @@ const newDetail = {
canonical: {
currentHref: `https://www.yohobuy.com${req.originalUrl}`
},
title: `【${result.brandName}${result.sortName}${result.goodsName}|YOHO!BUY 有货`,
title: title,
keywords: result.brandName + result.sortName + ',' + result.brandName + result.sortName + '价格,' +
result.brandName + result.sortName + '图片,',
description: result.goodsName + ' 有货网仅售' + result.goodsPrice.currentPrice + '元,购买' +
result.brandName + result.sortName + ',了解' + result.brandName + result.sortName + '商品信息就上有货网!',
description: description,
pageFooter: true,
localCss: true,
appPath: appPath,
miniPath: miniPath,
isMarsApp: req.yoho.isMarsApp // 判断mars
isMarsApp: req.yoho.isMarsApp, // 判断mars
showAnaJson: {
miptitle: title,
mipPublishTime: moment.unix(result.shelveTime).format('YYYY-MM-DDTHH:mm:ss'), // mip日期必填
mipPics: mipPics.slice(0, 5),
mipDes: description,
mipUrl: `${req.protocol}://m.yohobuy.com/product/${result.productSkn}.html`
}
});
}).catch(next);
},
... ...
... ... @@ -22,6 +22,8 @@
<link rel="dns-prefetch" href="{{this}}">
{{/dnsPrefetch.hosts}}
{{> ld-json}}
<script>
{{#ifand isProduction wap.open.bughd}}
window._timeStart = new Date().getTime();
... ...
... ... @@ -13,21 +13,7 @@
{{css}}
{{localStyle}}
</style>
{{#if showAnaJson}}
<script type="application/ld+json">
{
"@context": "https://ziyuan.baidu.com/contexts/cambrian.jsonld",
"@id": "{{mipUrl}}",
"appid": "1583402501013173",
"title": "{{title}} | Yoho!Buy有货 | 潮流购物逛不停",
"images": [
"{{mipPic}}"
],
"description": "{{mipDes}}",
"pubDate": "{{mipPublishTime}}"
}
</script>
{{/if}}
{{> ld-json}}
</head>
<body>
<div class="main-wrap">{{{body}}}</div>
... ...
{{# showAnaJson}}
<script type="application/ld+json">
{
"@context": "https://ziyuan.baidu.com/contexts/cambrian.jsonld",
"@id": "{{mipUrl}}",
"appid": "1583402501013173",
"title": "{{miptitle}}",
"images": [
{{# mipPics}}
{{#isEqualOr @index 0}}
{{#if .}}"http:{{image . 750 500 1}}"{{/if}}
{{else}}
{{#if .}},"http:{{image . 750 500 1}}"{{/if}}
{{/isEqualOr}}
{{/mipPics}}
],
"description": "{{mipDes}}",
"pubDate": "{{mipPublishTime}}"
}
</script>
{{/showAnaJson}}
... ...
... ... @@ -27,6 +27,11 @@ class DetailProcess {
// 商品促销短语
origin.sales_phrase && origin.sales_phrase !== ' ' && (dest.goodsSubtitle = origin.sales_phrase);
// 商品短语
dest.phrase = _.get(origin, 'phrase', '');
dest.shelveTime = _.get(origin, 'shelveTime', 0);
// 商品标签
if (origin.tags) {
let productTags = {};
... ...