...
|
...
|
@@ -2,8 +2,10 @@ |
|
|
|
|
|
const _ = require('lodash');
|
|
|
const helpers = global.yoho.helpers;
|
|
|
const utils = '../../../utils';
|
|
|
const redis = require(`${utils}/redis`);
|
|
|
const NewsAPi = require('./news-api');
|
|
|
const utils = require('./utils');
|
|
|
const newsUtils = require('./utils');
|
|
|
const moment = require('moment');
|
|
|
const ATYPE = 'yohobuy4008899646,yohogroup,YOHO_GIRL,mars-app';
|
|
|
|
...
|
...
|
@@ -24,7 +26,7 @@ module.exports = class extends global.yoho.BaseModel { |
|
|
|
|
|
lresult = {
|
|
|
id: articleData.id,
|
|
|
url: helpers.urlFormat(`/news/${articleData.id}_${articleData.cid}.html`),
|
|
|
url: helpers.urlFormat(`/guang/news/${articleData.id}_${articleData.cid}.html`),
|
|
|
img: helpers.image(articleData.image, width, height, 1),
|
|
|
title: articleData.title,
|
|
|
publishTime: articleData.update_time && moment(articleData.update_time * 1000).format('MM月DD HH:mm'),
|
...
|
...
|
@@ -80,15 +82,18 @@ module.exports = class extends global.yoho.BaseModel { |
|
|
title: contents.title,
|
|
|
summary: contents.summary,
|
|
|
tag: contents.tag,
|
|
|
syncTypeName: contents.syncTypeName || 'YOHO潮流志',
|
|
|
publishTime: contents.update_time && moment(contents.update_time * 1000).format('MM月DD HH:mm'),
|
|
|
};
|
|
|
let content = utils.filterPhtml(contents.content, [
|
|
|
let content = newsUtils.filterPhtml(contents.content.replace(/www.yohobuy.com/ig, 'm.yohobuy.com'), [
|
|
|
'阅读原文',
|
|
|
'点击这里',
|
|
|
'点这里'
|
|
|
]);
|
|
|
|
|
|
return {header: header, content: utils.filterAhtml(content)};
|
|
|
content = newsUtils.filterAhtml(content);
|
|
|
|
|
|
return {header: header, content: newsUtils.imgAlt(content, contents.title, 5)};
|
|
|
}
|
|
|
|
|
|
detail(channel, param) {
|
...
|
...
|
@@ -96,16 +101,25 @@ module.exports = class extends global.yoho.BaseModel { |
|
|
id: param.id,
|
|
|
cid: param.cid
|
|
|
};
|
|
|
let newsAPi = new NewsAPi(this.ctx);
|
|
|
|
|
|
return newsAPi.getContentDetail(params).then(result => {
|
|
|
return redis.all([
|
|
|
['get', `global:yoho:news:detail:${params.id}-${params.cid}`]
|
|
|
]).then(redisData => {
|
|
|
redisData = JSON.parse(redisData[0] || '{}');
|
|
|
|
|
|
if (!redisData.data) {
|
|
|
return new NewsAPi(this.ctx).getContentDetail(params);
|
|
|
}
|
|
|
|
|
|
return redisData;
|
|
|
}).then(result => {
|
|
|
let responseData = {};
|
|
|
|
|
|
// 详情页数据
|
|
|
Object.assign(responseData, this._formatDetail(result, params));
|
|
|
|
|
|
// seo
|
|
|
let title = _.get(responseData, 'header.title', '新闻详情页');
|
|
|
let title = _.get(responseData, 'header.title', '潮流资讯详情页');
|
|
|
let keywords = [];
|
|
|
let tags = _.compact(_.get(responseData, 'header.tag', []).map(el => {
|
|
|
return el.tag_name;
|
...
|
...
|
|