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

  /**
   * 页面的初始数据
   */
  data: {
    mask_state: false,
    more_state: false,
    tab_current: 1,
    open_user_id: '',
    look: 0,
    look_type: ''
  },
  
  cancleMask() {
    this.setData({
      mask_state: false
    })
  },
  editInfo() {
    wx.navigateTo({
      url: '/pages/index/info/info',
    })
  },

  showMore() {
    this.setData({
      more_state: !(this.data.more_state)
    })
  },

  goBox() {
    wx.navigateTo({
      url: '/pages/my/draft/draft',
    })
  },

  goList(e) {
    var status=e.currentTarget.dataset.status
    wx.navigateTo({
      url: '/pages/index/fans/fans?status=' + status,
    })
  },

  goMessage(){
    wx.navigateTo({
      url: '/pages/index/message/message',
    })
  },

  chargeTime(e) {
    var current = e.currentTarget.dataset.current
    var tab_current = this.data.tab_current
    if (tab_current == current) {
      return false
    } else {
      this.setData({
        tab_current: current
      })
    }
  },

  getData() {
    let url = '/home/index/userPage'
    let params = {
      open_user_id: this.data.open_user_id,
      look: this.data.look,
      look_type: this.data.look_type
    }
    let header = {
      "XX-Token": wx.getStorageSync('token'),
      'XX-Device-Type': 'wxapp'
    }
    app.post(url, params, header).then((res) => {
      if (res.data.code == 20000) {
        this.setData({
          avatar: res.data.data.avatar, 
          fans_num: res.data.data.fans_num,
          host: res.data.data.host,
          host_num: res.data.data.host_num,
          list: res.data.data.list,
          signature: res.data.data.signature,
          user_nickname: res.data.data.user_nickname
        })
      }

    })
  },


  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function(options) {
    this.getData()
  },

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

  },

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

  },

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

  },

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

  },

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

  },

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

  },

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

  }
})