...
|
...
|
@@ -82,7 +82,7 @@ module.exports = class extends global.yoho.BaseModel { |
|
|
url: helpers.urlFormat(`/news/${articleData.id}_${articleData.cid}.html`),
|
|
|
img: helpers.image(articleData.image, width, height, 1),
|
|
|
title: articleData.title,
|
|
|
pTime: moment(articleData.update_time * 1000).format('YYYY年MM月DD HH:mm'),
|
|
|
pTime: articleData.update_time && moment(articleData.update_time * 1000).format('YYYY年MM月DD HH:mm'),
|
|
|
pView: articleData.views_num,
|
|
|
content: articleData.summary,
|
|
|
isVideo: articleData.videoUrl ? true : false
|
...
|
...
|
@@ -127,12 +127,12 @@ module.exports = class extends global.yoho.BaseModel { |
|
|
|
|
|
let apiMethod = [
|
|
|
headerModel.requestHeaderData(channel),
|
|
|
newsAPi.getPolymerizationList(params),
|
|
|
newsAPi.getRecoArticles(params),
|
|
|
newsAPi.getAds({
|
|
|
content_code: ADS_CODE[channel] || ADS_CODE.boys,
|
|
|
isAdDegrade: _.get(this.ctx, 'req.app.locals.pc.guang.removeAd', false)
|
|
|
}),
|
|
|
newsAPi.getPolymerizationList(params),
|
|
|
];
|
|
|
|
|
|
return Promise.all(apiMethod).then(result => {
|
...
|
...
|
@@ -141,14 +141,14 @@ module.exports = class extends global.yoho.BaseModel { |
|
|
// 头部数据
|
|
|
Object.assign(responseData, result[0]);
|
|
|
|
|
|
// 列表数据
|
|
|
Object.assign(responseData, this._formatArticle(result[1], params));
|
|
|
|
|
|
// 获取精彩推荐
|
|
|
Object.assign(responseData, this._formatRecoArticles(result[2]));
|
|
|
Object.assign(responseData, this._formatRecoArticles(result[1]));
|
|
|
|
|
|
// 获取广告数据
|
|
|
Object.assign(responseData, this._formatAds(result[3]));
|
|
|
Object.assign(responseData, this._formatAds(result[2]));
|
|
|
|
|
|
// 列表数据
|
|
|
Object.assign(responseData, this._formatArticle(result[3], params));
|
|
|
|
|
|
// 导航pathNav
|
|
|
Object.assign(responseData, this.getPathNav(channel));
|
...
|
...
|
@@ -157,29 +157,54 @@ module.exports = class extends global.yoho.BaseModel { |
|
|
});
|
|
|
}
|
|
|
|
|
|
_formatDetail(rdata) {
|
|
|
let contents = _.get(rdata, 'data.contents', {});
|
|
|
let header = {
|
|
|
title: contents.title,
|
|
|
time: contents.update_time && moment(contents.update_time * 1000).format('YYYY年MM月DD HH:mm'),
|
|
|
};
|
|
|
|
|
|
return {header: header, content: contents.content};
|
|
|
}
|
|
|
|
|
|
detail(channel, param) {
|
|
|
let params = {
|
|
|
id: param.id || 20735,
|
|
|
cid: param.cid || 11893
|
|
|
id: param.id,
|
|
|
cid: param.cid
|
|
|
};
|
|
|
let newsAPi = new NewsAPi(this.ctx);
|
|
|
let apiMethod = [
|
|
|
headerModel.requestHeaderData(channel),
|
|
|
new NewsAPi(this.ctx).getContentDetail(params)
|
|
|
newsAPi.getRecoArticles(params),
|
|
|
newsAPi.getAds({
|
|
|
content_code: ADS_CODE[channel] || ADS_CODE.boys,
|
|
|
isAdDegrade: _.get(this.ctx, 'req.app.locals.pc.guang.removeAd', false)
|
|
|
}),
|
|
|
newsAPi.getContentDetail(params)
|
|
|
];
|
|
|
|
|
|
return Promise.all(apiMethod).then(result => {
|
|
|
let responseData = {};
|
|
|
|
|
|
// 头部数据
|
|
|
Object.assign(responseData, result[0]);
|
|
|
|
|
|
// 获取精彩推荐
|
|
|
Object.assign(responseData, this._formatRecoArticles(result[1]));
|
|
|
|
|
|
// 获取广告数据
|
|
|
Object.assign(responseData, this._formatAds(result[2]));
|
|
|
|
|
|
// 列表数据
|
|
|
Object.assign(responseData, this._formatDetail(result[3], params));
|
|
|
|
|
|
// 导航pathNav
|
|
|
Object.assign(responseData, this.getPathNav(channel, [{
|
|
|
href: helpers.urlFormat('/news'),
|
|
|
name: '新闻详情页',
|
|
|
pathTitle: '新闻详情页'
|
|
|
name: _.get(responseData, 'header.title', '新闻详情页'),
|
|
|
pathTitle: _.get(responseData, 'header.title', '新闻详情页')
|
|
|
}]));
|
|
|
|
|
|
// 头部数据
|
|
|
Object.assign(responseData, result[0]);
|
|
|
|
|
|
return responseData;
|
|
|
});
|
|
|
}
|
...
|
...
|
|