index.js 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. import {
  2. getNewComment
  3. } from '~/api/message'
  4. import {
  5. ReplyComment
  6. } from '~/api/video'
  7. Page({
  8. data: {
  9. list: []
  10. },
  11. /**
  12. * 生命周期函数--监听页面加载
  13. */
  14. onLoad(options) {
  15. this.getNewComment()
  16. },
  17. async getNewComment() {
  18. let list = await getNewComment()
  19. this.setData({
  20. list
  21. })
  22. },
  23. setReply({
  24. currentTarget
  25. }) {
  26. wx.showModal({
  27. title: '回复评论',
  28. editable: true,
  29. confirmText: '发送',
  30. success: async (res) => {
  31. if (res.confirm) {
  32. if (!res.content) {
  33. return
  34. }
  35. let data = {
  36. postsId: currentTarget.dataset.id,
  37. content: res.content,
  38. }
  39. await ReplyComment(data)
  40. wx.showToast({
  41. title: '回复成功',
  42. })
  43. }
  44. }
  45. })
  46. },
  47. jumpUserInfo({
  48. currentTarget
  49. }) {
  50. wx.navigateTo({
  51. url: `/pages/personal/index?uid=${currentTarget.dataset.uid}&type=user`,
  52. })
  53. },
  54. jumpWork({
  55. currentTarget
  56. }) {
  57. wx.navigateTo({
  58. url: `/pages/userWorks/index?id=${currentTarget.dataset.id}`,
  59. })
  60. },
  61. })