const app = getApp();
Page({

  /**
   * 页面的初始数据
   */
  data: {
    star_num: 3,
    datalist: '',
  },
  getdatalist() {
    let that = this;
    let url = 'index/member_center/index';
    let head = {
      'XX-Token': wx.getStorageSync('token')
    }
    app.post(url, {}, head).then((res) => {
      console.log(res)
      that.setData({
        datalist: res
      })
    }).catch((err) => {

    })
  },
  // 我的个人信息
  getmy() {

    wx.navigateTo({
      url: '/pages/mydetail/mydetail',
    })


  },
  // 管理员
  goamdin(e) {
    wx.navigateTo({
      url: '/pages/admin/admin?type=' + e.currentTarget.dataset.type
    })

  },
  // 我的活动
  getMyactive() {

    let that = this;
    let url = '/index/second/checkTranStatus';
    let head = {
      'XX-Token': wx.getStorageSync('token')
    }

    app.post(url, {}, head).then((res) => {
      console.log(res)
      if (res.code == 40000) {
        wx.showModal({
          title: '提示',
          content: '请先成为志愿者'

        })
      } else {
        wx.navigateTo({
          url: '/pages/myactivity/myactivity',
        })
      }
    }).catch((err) => {})
  },
  //我的团队  
  getMyteam() {

    let that = this;
    let url = '/index/second/checkTranStatus';
    let head = {
      'XX-Token': wx.getStorageSync('token')
    }

    app.post(url, {}, head).then((res) => {
      console.log(res)
      if (res.code == 40000) {
        wx.showModal({
          title: '提示',
          content: '请先成为志愿者'

        })
      } else {
        wx.navigateTo({
          url: '/pages/myteam/myteam',
        })
      }
    }).catch((err) => {})
  },
  // 我的培训
  getMytrain() {

    let that = this;
    let url = '/index/second/checkTranStatus';
    let head = {
      'XX-Token': wx.getStorageSync('token')
    }

    app.post(url, {}, head).then((res) => {
      console.log(res)
      if (res.code == 40000) {
        wx.showModal({
          title: '提示',
          content: '请先成为志愿者'

        })
      } else {
        wx.navigateTo({
          url: '/pages/mytrain/mytrain',
        })

      }
    }).catch((err) => {})

  },
  // 志愿回馈
  getfeedback() {
    let that = this;
    let url = '/index/second/checkTranStatus';
    let head = {
      'XX-Token': wx.getStorageSync('token')
    }
    app.post(url, {}, head).then((res) => {
      console.log(res)
      if (res.code == 40000) {
        wx.showModal({
          title: '提示',
          content: '请先成为志愿者'

        })

      } else {
        wx.navigateTo({
          url: '/pages/myfeedback/myfeedback',
        })
      }


    }).catch((err) => {

    })
  },

  // 成为志愿者
  getVolunteer(e) {
    // console.log(e)
    wx.navigateTo({
      url: '/pages/apply/apply?id=' + this.data.datalist.id + "&is_submit=" + this.data.datalist.is_submit,

    })
  },
  // 电子证件
  getCertificate() {

    let that = this;
    let url = '/index/second/checkTranStatus';
    let head = {
      'XX-Token': wx.getStorageSync('token')
    }
    app.post(url, {}, head).then((res) => {
      console.log(res)
      if (res.code == 40000) {
        wx.showModal({
          title: '提示',
          content: '请先成为志愿者'

        })

      } else {
        wx.navigateTo({
          url: '/pages/mycertificate/mycertificate',
        })
      }


    }).catch((err) => {

    })
    
  },

  // 我的地址
  getmyAdd() {
    wx.navigateTo({
      url: '/pages/myaddress/myaddress?id=' + this.data.datalist.id,
    })

  },
  // 我的志愿回馈
  getmyfeedback() {
    wx.navigateTo({
      url: '/pages/myfeedback_lists/myfeedback_lists',
    })
  },
  // 管理条例
  getRule(e) {
    wx.navigateTo({
      url: '/pages/guanlitiaoli/guanlitiaoli',
    })
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    wx.hideShareMenu()
  },

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

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
    let that = this;
    that.getdatalist();
  },

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

  },

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

  },

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

  },

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

  },

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

  }
})