// pages/index/fans/fans.js
const app = getApp()
Page({

  /**
   * 页面的初始数据
   */
  data: {
    status: '',
    list: [],
    mask_state:false,
    id:0,
  },

  goUserInfo(e) {
    var id = e.currentTarget.dataset.id
    wx.navigateTo({
      url: '/pages/my/userInfo/userInfo?id=' + id,
    })
  },

  getData() {
    let url = '/home/index/checkFans'
    let params = {
      status: this.data.status,
      open_user_id:this.data.id,
      page:1
    }
    let header = {
      "XX-Token": wx.getStorageSync('token'),
      'XX-Device-Type': 'wxapp'
    }
    app.post(url, params, header).then((res) => {
      console.log(res)
      var list = res.data.data.list
      if (res.data.code == 20000) {
        this.setData({
          list: list
        })
      }
    })
  },


  //关注接口
  // attentionInfo(e) {
  //   let that = this;
  //   var id = e.currentTarget.dataset.id
  //   var status = e.currentTarget.dataset.status
  //   let url = '/home/index/host';
  //   let param = {
  //     open_user_id: id,
  //     status: status
  //   }
  //   let header = {
  //     'XX-Token': wx.getStorageSync('token'),
  //     'XX-Device-Type': 'wxapp'
  //   }
  //   app.post(url, param, header).then((res) => {
  //     if (res.data.code == 20000) {
  //       this.getData()
  //     }
  //   })
  // },

  showMask(e) {
    var id = e.currentTarget.dataset.id
    var status = e.currentTarget.dataset.status
    wx.setStorageSync('id', id)
    wx.setStorageSync('status', status)
    this.setData({
      mask_state: true,
      // id: id,
      // status: status
    })
  },

  cancleMask() {
    this.setData({
      mask_state: false
    })
  },
  attentionInfo() {
    var id = wx.getStorageSync('id')
    var status = parseInt(wx.getStorageSync('status'))
    var that = this
    let url = '/home/index/host';
    let param = {
      open_user_id:id,
      status:status ,
    }
    let header = {
      'XX-Token': wx.getStorageSync('token'),
      'XX-Device-Type': 'wxapp'
    }
    app.post(url, param, header).then((res) => {
      if (res.data.code == 20000) {
        that.getData()
      }
    })
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function(options) {
    this.setData({
      status: options.status ? options.status : '',
      id: options.id ? options.id : 0
    })
    this.getData()
    if (options.status == 1) {
      wx.setNavigationBarTitle({
        title: '关注',
      })
    }
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function() {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function() {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function() {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function() {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function() {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function() {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function() {

  }
})