import {
  getMessageList
} from '~/api/message'
import event from '~/mixins/event'
import reachBottom from '~/mixins/reachBottom'
Page({
  behaviors: [reachBottom,event],
  data: {},
  onLoad(options) {
    this.resetData()
    getMessageList({}, 'put')
  },
  loadMore() {
    this.getData(this.getMessageList)
  },
  getMessageList(data) {
    return new Promise(async (reslove) => {
      let res = await getMessageList(data)
      res.list.forEach(item => {
        item.content = item.content.split('\n')
      })
      reslove(res)
    })
  },
  onReachBottom() {
    this.loadMore()
  },
  onShareAppMessage: function (res) {
    const user = wx.getStorageSync('uid');
    return {
      title: '自从用了它，家里朗朗书声，美妙极了！你家孩子也快来试试！',
      path: `/pages/index/index?uid=${user}`,
      imageUrl: 'http://reader-wx.ai160.com/images/reader/v3/375-300-1.jpg'
    }
  },
})