Authored by 刘传洋

guang

... ... @@ -269,6 +269,42 @@ exports.detail = (req, res, next) => {
};
/**
* 列表页(列表首页、标签列表页、作者列表页)动态数据,如:查看数,点赞数,评论数,是否点赞,是否回复
* @param req
* @param res
*/
exports.listDynamicData = (req, res) => {
let ids = req.query.ids;
guangModel.getDynamicDataByIds(ids).then(ret => {
res.status(200).send(ret);
});
};
/**
* 详情页动态数据,如:评论数,回复数,是否点赞,是否收藏
* @param req
* @param res
*/
exports.detailDynamicData = (req, res) => {
let id = req.query.id;
guangModel.getDynamicDataByIds(id).then(ret => {
res.status(200).send(ret);
});
};
exports.detailCommentData = (req, res) => {
let param = {
id: req.query.id,
page: req.query.page
};
res.render('', param);
};
/**
* 添加评论
*/
exports.comment = (req, res) => {
... ...
... ... @@ -822,6 +822,42 @@ const cancelCollect = (aid, uid) => serviceApi.get('guang/api/v1/favorite/cancel
uid: uid
});
/**
* 获取制指定文章的动态信息
* @param ids
* @returns {Promise.<T>|*}
*/
const getDynamicDataById = id => {
return serviceApi.get('', {
id: id
}).then(res => {
if (res && res.code === 200 && res.data) {
return res.data;
}
return Promise.reject('获取失败');
});
};
/**
* 获取制指定文章的动态信息
* @param ids
* @returns {Promise.<T>|*}
*/
const getDynamicDataByIds = ids => {
return serviceApi.get('', {
ids: ids
}).then(res => {
if (res && res.code === 200 && res.data) {
return res.data;
}
return Promise.reject('获取失败');
});
};
module.exports = {
getArticleList,
getHotTags,
... ... @@ -843,7 +879,10 @@ module.exports = {
praise,
cancelPraise,
collect,
cancelCollect
cancelCollect,
getDynamicDataById,
getDynamicDataByIds
};
... ...
/**
* 动态获取页面数据
* @author liuchuanyang
* @date 2016/10/09
*/
var $ = require('yoho-jquery');
function getDynamicById(id) {
'use strict';
var param = {
return_type: 'jsonp',
id: id
};
return $.getJSON('//guang.yohobuy.com/guang/suggest?callback=?', param);
}
function getDynamicByIds(ids) {
'use strict';
var param = {
return_type: 'jsonp',
ids: ids
};
return $.getJSON('//guang.yohobuy.com/guang/suggest?callback=?', param);
}
function getDynamicCommentList(id, page) {
'use strict';
var param = {
id: id,
page: page
};
return $.getJSON('//guang.yohobuy.com/guang/suggest?callback=?', param);
}
module.exports = {
getDynamicById,
getDynamicByIds,
getDynamicCommentList
};
... ...