// pages/mine/mine.js

const app = getApp()

Page({

  /**
   * 页面的初始数据
   */
  data: {
    callPhone:false,
    show_apply:false,
    personal:'',
    account:'',
    username:'',
    cash:'',
    userid:''
  },

  /**
   * 生命周期函数--监听页面加载
   */
  // 财务记录
  financial_record(){
    wx.navigateTo({
      url: '/pages/financialRecord/financialRecord',
    })
  },

  //报名记录
  record(){
    wx.navigateTo({
      url: '/pages/record/record',
    })
  },
  // 我的简历
  myResume2(){
    wx.navigateTo({
      url: '/pages/myResume/myResume',
    
      //url: '/pages/myResume2/myResume2',
    })
  },
  // 岗位收藏
  record2(){
    wx.navigateTo({
      url: '/pages/record2/record2',
    })
  },

  // 报名名单
  registration(){
    wx.navigateTo({
      url: '/pages/registration/registration',
    })
  },

  // 发布岗位
  toPublish(){

    let name='发布岗位'
   wx.navigateTo({
     url: '/pages/atHome/atHome?categories_name='+name+'&userid='+this.data.userid,
   })
    // wx.switchTab({
    //   url: '/pages/publish/publish',
    // })
    // wx.navigateTo({
    //   url: '/pages/publish/publish',
    // })
  },

  // 推荐有奖
  toRecommend(){
    wx.navigateTo({
      url: '/pages/recommend/recommend',
    })
  },
  // 意见反馈
  toFeedback(){
    wx.navigateTo({
      url: '/pages/feedback/feedback',
    })
  },

  // 我的消息
  myMessage(){
    wx.navigateTo({
      url: '/pages/myMessage/myMessage',
    })
  },

  // 打开手机客服
  open_phone(){
    this.setData({
      callPhone:true
    })
  },
  // 关闭手机客服
  close_phone(){
    this.setData({
      callPhone:false
    })
  },
  // 打开提现框
  open_apply(){
    this.setData({
      show_apply:true
    })
  },
  // 关闭提现框
  close_apply(){
    this.setData({
      show_apply:false
    })
  },
  onLoad: function (options) {
    
    // this.getPay()
  },

  // 账号
  enterAccount(e){
    console.log(e)
    this.setData({
      account: e.detail.value
    })
  },
  // 姓名
  enterUsername(e){
    console.log(e)
    this.setData({
      username: e.detail.value
    })
  },
  // 提现金额
  enterCash(e){
    this.setData({
      cash: e.detail.value
    })
  },

  // 提交审核
  subPay(){
    let that = this;
    if (that.data.account==''){
      wx.showToast({
        title: '请输入支付宝账户',
        icon:'none'
      })
    } else if (that.data.username==''){
      wx.showToast({
        title: '请输入账户姓名',
        icon: 'none'
      })
    }else if(that.data.cash==''){
      wx.showToast({
        title: '请输入提现金额',
        icon: 'none'
      })
    }else{
      let url = 'index/share/submit_audit';
      let params = {
        alipay: that.data.account,
        name: that.data.username,
        total: that.data.cash,
      }
      let header = {
        "XX-Token": wx.getStorageSync('token'),
        "XX-Device-Type": 'wxapp'
      }
      app.post(url, params, header).then((res) => {
        console.log(res);
        wx.showToast({
          title: '提交成功',
          icon: 'none',
          duration: 1500
        })
        setTimeout(function () {
          wx.navigateTo({
            url: '/pages/mine/mine',
          })
        }, 1000)

      }).catch((err) => {
          wx.showToast({
            title: err.data.msg,
            icon:"none"
          })
      })
    }
    
  },
  // 获取个人中心信息
  getPersonal() {

    let that = this;
    let url = 'index/user/me'
    let params = {

    }
    let header = {
      "XX-Token": wx.getStorageSync('token'),
      "XX-Device-Type": 'wxapp'
    }
    app.post(url, params, header).then((res) => {
      console.log(res);
      // 获取值
      that.setData({
        personal: res.data,
        userid:res.data.id
      })





    }).catch((err) => {

    })
  },


//拨打电话
  surephone(){
    wx.makePhoneCall({
      phoneNumber: '4008008820',
    })
  },
  

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

  },

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

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

  },

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

  },

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

  },

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

  },

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

  }
})