import {
  getNewComment
} from '~/api/message'
import {
  ReplyComment
} from '~/api/video'
Page({
  data: {
    list: []
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad(options) {
    this.getNewComment()
  },
  async getNewComment() {
    let list = await getNewComment()
    console.log(list);
    this.setData({
      list
    })
  },
  setReply({
    currentTarget
  }) {
    console.log(currentTarget);
    wx.showModal({
      title: '回复评论',
      editable: true,
      confirmText: '发送',
      success: async (res) => {
        if (res.confirm) {
          if (!res.content) {
            return
          }
          let data = {
            postsId: currentTarget.dataset.id,
            content: res.content,
          }
          await ReplyComment(data)
          wx.showToast({
            title: '回复成功',
          })
        }
      }
    })
  },
  jumpUserInfo({
    currentTarget
  }) {
    wx.navigateTo({
      url: `/pages/personal/index?uid=${currentTarget.dataset.uid}&type=user`,
    })
  },
})