const app = getApp()
Page({

  /**
   * 页面的初始数据
   */
  data: {
    companyUser:[
      {name:'忽忽',phone:'12345678900',isAuth:'1'},
      {name:'忽忽',phone:'12345678900',isAuth:'1'},
      {name:'忽忽',phone:'12345678900',isAuth:'0'},
      {name:'忽忽',phone:'12345678900',isAuth:'1'},
    ],
    activeIndex:'00'
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    this.getpageCompanyUser();
  },
  getpageCompanyUser(keywords,status){
    var that = this;
    app.requestP({
      url:'/companyUser/pageCompanyUser',
      method:'post',
      contentType:' application/json',
      data:{
        keywords: keywords || '',
        pageNum: 1,
        pageSize: 100,
        status: status || ''
      }
    }).then(res=>{
      that.setData({
        companyUserList:res.data.data.rows
      })
    })
  },
  tabs(e){
    var index = e.currentTarget.dataset.index;
    this.setData({
      activeIndex:index
    })
    this.getpageCompanyUser('',index == '00' ? '':index);
  },
  verify(e){
    var index = e.currentTarget.dataset.index;
    var id = e.currentTarget.dataset.id;
    var that = this;
    app.requestP({
      url:'/companyUser/verify',
      method:'post',
      contentType:' application/json',
      data:{
        id,
        status:index
      }
    }).then(res=>{
      app.showToptip(that,'success',res.data.msg);
      this.getpageCompanyUser();
    }).catch(err=>{
      app.showToptip(that,'error',err.data.msg);
    })
  },
  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

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

  },

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

  },

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

  },

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

  },

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

  },

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

  }
})