...
|
...
|
@@ -122,6 +122,8 @@ const _shareInfo = (id, getArticle) => { |
|
|
*/
|
|
|
const index = (req, res, next) => {
|
|
|
let id = req.query.id || req.params[0] || req.params.id,
|
|
|
uid = req.user.uid,
|
|
|
udid = req.sessionID || require('yoho-md5')(req.ip) || 'yoho',
|
|
|
gender = req.query.gender ||
|
|
|
req.query.channel && typeLib.channels[req.query.channel] ||
|
|
|
req.cookies._Channel && channels[req.cookies._Channel] ||
|
...
|
...
|
@@ -157,6 +159,12 @@ const index = (req, res, next) => { |
|
|
|
|
|
co(function* () {
|
|
|
let detail = yield req.ctx(DetailModel).packageData(id, isApp, isWeixin, channel, isShare);
|
|
|
let commentsTotal = yield req.ctx(DetailModel).commentsTotal({article_id: id});
|
|
|
let praise = yield req.ctx(DetailModel).getArticlePraiseAndFavor({
|
|
|
uid: uid,
|
|
|
id: id,
|
|
|
udid: udid
|
|
|
});
|
|
|
let data = {
|
|
|
guangDetail: true,
|
|
|
guang: {}
|
...
|
...
|
@@ -198,8 +206,11 @@ const index = (req, res, next) => { |
|
|
id: _.get(detail, 'getArticle.id'),
|
|
|
title: detail.getArticle.article_title,
|
|
|
publishTime: detail.getArticle.publishTime,
|
|
|
pageView: detail.getArticle.pageViews,
|
|
|
content: []
|
|
|
pageView: _.get(praise, 'browseNum', 0),
|
|
|
content: [],
|
|
|
praise: _.get(praise, 'praiseNum', 0),
|
|
|
praiseHeadIco: _.get(praise, 'praiseHeadIco', []),
|
|
|
commentsTotal: commentsTotal
|
|
|
};
|
|
|
if (!detail.getArticleContent) {
|
|
|
return next();
|
...
|
...
|
@@ -254,7 +265,8 @@ const index = (req, res, next) => { |
|
|
wechatShare: true,
|
|
|
isWeixin: isWeixin,
|
|
|
localCss: true,
|
|
|
isShare: isShare
|
|
|
isShare: isShare,
|
|
|
id: id
|
|
|
}, data, parameter));
|
|
|
})().catch(next);
|
|
|
};
|
...
|
...
|
@@ -287,6 +299,8 @@ const indexRedirect = (req, res, next) => { |
|
|
*/
|
|
|
const mini = (req, res, next) => {
|
|
|
let id = req.query.id,
|
|
|
uid = req.user.uid,
|
|
|
udid = req.sessionID || require('yoho-md5')(req.ip) || 'yoho',
|
|
|
gender = req.query.gender || req.cookies._Channel && channels[req.cookies._Channel] || 1,
|
|
|
isApp = req.query.app_version || req.query.appVersion || false; // 标识是不是APP访问的
|
|
|
|
...
|
...
|
@@ -302,6 +316,12 @@ const mini = (req, res, next) => { |
|
|
|
|
|
co(function* () {
|
|
|
let detail = yield req.ctx(DetailModel).packageData(id, isApp);
|
|
|
let commentsTotal = yield req.ctx(DetailModel).commentsTotal({article_id: id});
|
|
|
let praise = yield req.ctx(DetailModel).getArticlePraiseAndFavor({
|
|
|
uid: uid,
|
|
|
id: id,
|
|
|
udid: udid
|
|
|
});
|
|
|
let data = {
|
|
|
guangEzine: true,
|
|
|
guang: {}
|
...
|
...
|
@@ -317,8 +337,11 @@ const mini = (req, res, next) => { |
|
|
guang.detail = {
|
|
|
title: detail.getArticle.article_title,
|
|
|
publishTime: detail.getArticle.publishTime,
|
|
|
pageView: detail.getArticle.pageViews,
|
|
|
content: []
|
|
|
pageView: _.get(praise, 'browseNum', 0),
|
|
|
content: [],
|
|
|
praise: _.get(praise, 'praiseNum', 0),
|
|
|
praiseHeadIco: _.get(praise, 'praiseHeadIco', []),
|
|
|
commentsTotal: commentsTotal
|
|
|
};
|
|
|
|
|
|
|
...
|
...
|
@@ -349,7 +372,8 @@ const mini = (req, res, next) => { |
|
|
page: 'info-index',
|
|
|
title: '逛',
|
|
|
gender: gender,
|
|
|
wechatShare: true
|
|
|
wechatShare: true,
|
|
|
id: id
|
|
|
}, data));
|
|
|
} else {
|
|
|
return next();
|
...
|
...
|
@@ -423,9 +447,29 @@ const foryoho = (req, res, next) => { |
|
|
})().catch(next);
|
|
|
};
|
|
|
|
|
|
/**
|
|
|
* 异步获取逛文章评论
|
|
|
* @param {*} req
|
|
|
* @param {*} res
|
|
|
* @param {*} next
|
|
|
*/
|
|
|
const getComments = (req, res, next) => {
|
|
|
|
|
|
req.ctx(DetailModel).comments({
|
|
|
article_id: req.query.article_id,
|
|
|
page: req.query.page
|
|
|
}).then(result => {
|
|
|
return res.render('info/comments', {
|
|
|
comments: result,
|
|
|
layout: false
|
|
|
});
|
|
|
}).catch(next);
|
|
|
};
|
|
|
|
|
|
module.exports = {
|
|
|
index,
|
|
|
mini,
|
|
|
foryoho,
|
|
|
indexRedirect
|
|
|
indexRedirect,
|
|
|
getComments
|
|
|
}; |
...
|
...
|
|