replyDetail.js 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. import httpRequestApi from '../../../utils/APIClient';
  2. import {
  3. formatDate
  4. } from '../../../utils/util';
  5. Page({
  6. data: {
  7. class1: 'commentItem commentItemFirst',
  8. classNormal: 'commentItem',
  9. postId: '',
  10. comment: []
  11. },
  12. onLoad: function (option) {
  13. console.log(option)
  14. this.setData({
  15. postId: option.id
  16. })
  17. wx.setNavigationBarTitle({
  18. // title: option.count + '条回复' //页面标题为路由参数
  19. title: '回复详情' //页面标题为路由参数
  20. })
  21. this.uid = wx.getStorageSync('uid');
  22. this.getReplyDetail();
  23. },
  24. // 查询回复详情
  25. getReplyDetail: function () {
  26. // let uid = wx.getStorageSync('uid');
  27. httpRequestApi.getReplyComment(this.uid, this.data.postId).success((res) => {
  28. console.log(res);
  29. const replyList = res.data.data.replyVOList;
  30. const replied = res.data.data;
  31. const replyTemp = [];
  32. const authorDetail = {};
  33. authorDetail.name = replied.user.wechatName;
  34. authorDetail.text = replied.detailDesc;
  35. authorDetail.time = formatDate(replied.gmtModified,3);
  36. authorDetail.likes = replied.postsAttributeInfo.favors;
  37. authorDetail.avatar = replied.user.avatar;
  38. replyTemp.push(authorDetail);
  39. replyList.forEach(item => {
  40. const temp = {};
  41. temp.name = item.user.wechatName;
  42. temp.text = item.content;
  43. temp.time = formatDate(item.gmtModified,3);
  44. temp.likes = 0;
  45. temp.id = item.postId;
  46. temp.avatar = item.user.avatar;
  47. replyTemp.push(temp);
  48. console.log(replyTemp);
  49. });
  50. this.setData({
  51. comment: replyTemp
  52. })
  53. });
  54. },
  55. // 点赞评论
  56. likeCommend: function (e) {
  57. console.log(e);
  58. // let uid = wx.getStorageSync('uid');
  59. let followUid = e.currentTarget.dataset.id;
  60. let index = e.currentTarget.dataset.index;
  61. httpRequestApi.likeCommend(this.uid, followUid).success(res => {
  62. console.log(res);
  63. const str = `comment[${index}].likes`;
  64. this.setData({
  65. [str]: res.data.data.favors
  66. })
  67. });
  68. },
  69. // 设置点击时的id
  70. setSBId: function (e) {
  71. console.log(e)
  72. this.setData({
  73. // replySBId: e.currentTarget.dataset.id,
  74. replyModal: true
  75. })
  76. },
  77. // 回复某个评论
  78. replySB: function () {
  79. const data = {
  80. postsId: this.data.postId,
  81. content: this.data.inputSBValue
  82. }
  83. httpRequestApi.postReplyComment(this.uid, data).success(res => {
  84. this.setData({
  85. replyModal: false
  86. },()=>{
  87. this.getReplyDetail();
  88. })
  89. });
  90. },
  91. // 获取回复楼中楼的内容
  92. inputSBValue: function (e) {
  93. this.setData({
  94. inputSBValue: e.detail.value
  95. });
  96. },
  97. })