import {
  getNewComment
} from '~/api/message'
import {
  ReplyComment
} from '~/api/video'
import event from '~/mixins/event'
import reachBottom from '~/mixins/reachBottom'
Page({
  behaviors: [reachBottom,event],
  data: {},
  onShow(options) {
    this.resetData()
  },
  loadMore() {
    this.getData(getNewComment, {
      pageSize: 20
    })
  },
  setReply({
    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`,
    })
  },
  jumpWork({
    currentTarget
  }) {
    let {
      id,
      commentlog
    } = currentTarget.dataset
    wx.navigateTo({
      url: `/pages/userWorks/index?id=${id}&onceId=${commentlog}&type=comment`,
    })
  },
})