Authored by 刘传洋

guang

@@ -269,6 +269,42 @@ exports.detail = (req, res, next) => { @@ -269,6 +269,42 @@ exports.detail = (req, res, next) => {
269 }; 269 };
270 270
271 /** 271 /**
  272 + * 列表页(列表首页、标签列表页、作者列表页)动态数据,如:查看数,点赞数,评论数,是否点赞,是否回复
  273 + * @param req
  274 + * @param res
  275 + */
  276 +exports.listDynamicData = (req, res) => {
  277 + let ids = req.query.ids;
  278 +
  279 + guangModel.getDynamicDataByIds(ids).then(ret => {
  280 + res.status(200).send(ret);
  281 + });
  282 +};
  283 +
  284 +/**
  285 + * 详情页动态数据,如:评论数,回复数,是否点赞,是否收藏
  286 + * @param req
  287 + * @param res
  288 + */
  289 +exports.detailDynamicData = (req, res) => {
  290 + let id = req.query.id;
  291 +
  292 + guangModel.getDynamicDataByIds(id).then(ret => {
  293 + res.status(200).send(ret);
  294 + });
  295 +};
  296 +
  297 +exports.detailCommentData = (req, res) => {
  298 +
  299 + let param = {
  300 + id: req.query.id,
  301 + page: req.query.page
  302 + };
  303 +
  304 + res.render('', param);
  305 +};
  306 +
  307 +/**
272 * 添加评论 308 * 添加评论
273 */ 309 */
274 exports.comment = (req, res) => { 310 exports.comment = (req, res) => {
@@ -822,6 +822,42 @@ const cancelCollect = (aid, uid) => serviceApi.get('guang/api/v1/favorite/cancel @@ -822,6 +822,42 @@ const cancelCollect = (aid, uid) => serviceApi.get('guang/api/v1/favorite/cancel
822 uid: uid 822 uid: uid
823 }); 823 });
824 824
  825 +/**
  826 + * 获取制指定文章的动态信息
  827 + * @param ids
  828 + * @returns {Promise.<T>|*}
  829 + */
  830 +const getDynamicDataById = id => {
  831 + return serviceApi.get('', {
  832 + id: id
  833 + }).then(res => {
  834 +
  835 + if (res && res.code === 200 && res.data) {
  836 + return res.data;
  837 + }
  838 +
  839 + return Promise.reject('获取失败');
  840 + });
  841 +};
  842 +
  843 +/**
  844 + * 获取制指定文章的动态信息
  845 + * @param ids
  846 + * @returns {Promise.<T>|*}
  847 + */
  848 +const getDynamicDataByIds = ids => {
  849 + return serviceApi.get('', {
  850 + ids: ids
  851 + }).then(res => {
  852 +
  853 + if (res && res.code === 200 && res.data) {
  854 + return res.data;
  855 + }
  856 +
  857 + return Promise.reject('获取失败');
  858 + });
  859 +};
  860 +
825 module.exports = { 861 module.exports = {
826 getArticleList, 862 getArticleList,
827 getHotTags, 863 getHotTags,
@@ -843,7 +879,10 @@ module.exports = { @@ -843,7 +879,10 @@ module.exports = {
843 praise, 879 praise,
844 cancelPraise, 880 cancelPraise,
845 collect, 881 collect,
846 - cancelCollect 882 + cancelCollect,
  883 +
  884 + getDynamicDataById,
  885 + getDynamicDataByIds
847 }; 886 };
848 887
849 888
  1 +/**
  2 + * 动态获取页面数据
  3 + * @author liuchuanyang
  4 + * @date 2016/10/09
  5 + */
  6 +var $ = require('yoho-jquery');
  7 +
  8 +function getDynamicById(id) {
  9 + 'use strict';
  10 +
  11 + var param = {
  12 + return_type: 'jsonp',
  13 + id: id
  14 + };
  15 +
  16 + return $.getJSON('//guang.yohobuy.com/guang/suggest?callback=?', param);
  17 +}
  18 +
  19 +function getDynamicByIds(ids) {
  20 + 'use strict';
  21 +
  22 + var param = {
  23 + return_type: 'jsonp',
  24 + ids: ids
  25 + };
  26 +
  27 + return $.getJSON('//guang.yohobuy.com/guang/suggest?callback=?', param);
  28 +}
  29 +
  30 +function getDynamicCommentList(id, page) {
  31 + 'use strict';
  32 +
  33 + var param = {
  34 + id: id,
  35 + page: page
  36 + };
  37 +
  38 + return $.getJSON('//guang.yohobuy.com/guang/suggest?callback=?', param);
  39 +}
  40 +
  41 +module.exports = {
  42 + getDynamicById,
  43 + getDynamicByIds,
  44 + getDynamicCommentList
  45 +};