replyDetail.js 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  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.avatar = item.user.avatar;
  42. replyTemp.push(temp);
  43. console.log(replyTemp);
  44. });
  45. this.setData({
  46. comment: replyTemp
  47. })
  48. });
  49. }
  50. })