replyDetail.js 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. import httpRequestApi from '../../../utils/APIClient';
  2. import {formatDate} from '../../../utils/util';
  3. Page({
  4. data: {
  5. class1: 'commentItem commentItemFirst',
  6. classNormal: 'commentItem',
  7. postId: '',
  8. comment:[]
  9. },
  10. onLoad: function (option) {
  11. console.log(option)
  12. this.setData({
  13. postId: option.id
  14. })
  15. wx.setNavigationBarTitle({
  16. title: option.count + '条回复'//页面标题为路由参数
  17. })
  18. this.getReplyDetail();
  19. },
  20. // 查询回复详情
  21. getReplyDetail: function () {
  22. let uid = wx.getStorageSync('uid');
  23. httpRequestApi.getReplyComment(uid, this.data.postId).success((res) => {
  24. console.log(res);
  25. const replyList = res.data.data.replyVOList;
  26. const replied = res.data.data;
  27. const replyTemp = [];
  28. const authorDetail = {};
  29. authorDetail.name = replied.user.wechatName;
  30. authorDetail.text = replied.detailDesc;
  31. authorDetail.time = formatDate(replied.gmtCreated,3);
  32. authorDetail.likes = replied.postsAttributeInfo.favors;
  33. authorDetail.avatar = replied.user.avatar;
  34. replyTemp.push(authorDetail);
  35. replyList.forEach(item => {
  36. const temp = {};
  37. temp.name = item.user.wechatName;
  38. temp.text = item.content;
  39. temp.time = formatDate(item.gmtCreated,3);
  40. temp.likes = 0;
  41. temp.id = item.postId;
  42. temp.avatar = item.user.avatar;
  43. replyTemp.push(temp);
  44. console.log(replyTemp);
  45. });
  46. this.setData({
  47. comment: replyTemp
  48. })
  49. });
  50. },
  51. // 点赞评论
  52. likeCommend: function (e) {
  53. console.log(e);
  54. let uid = wx.getStorageSync('uid');
  55. let followUid = e.currentTarget.dataset.id;
  56. let index = e.currentTarget.dataset.index;
  57. httpRequestApi.likeCommend(uid, followUid).success(res => {
  58. console.log(res);
  59. const str = `comment[${index}].likes`;
  60. this.setData({
  61. [str]: res.data.data.favors
  62. })
  63. });
  64. },
  65. })