// pages/invoice/agreement/agreement.js
const app = getApp();
const api = app.api;
Page({

  /**
   * 页面的初始数据
   */
  data: {
    agreement:false,
    isShowPop:false,
    settleInfo:null
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    this.getData();
  },
  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

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

  },
  getData(){
    app.post(api.getUserSettleInfo).then(res=>{
      console.log(res);
      this.setData({
        settleInfo:res.data
      })
    })
  },
  triggerAgree(){
    this.setData({
      agreement:!this.data.agreement
    })
  },
  prevStep(){
    wx.navigateBack()
  },
  nextStep(){
    if(!this.data.agreement){
      wx.showToast({
        title:"请先勾选协议",
        icon:'none',
        duration:2000
      })
      return false
    }
    if(this.data.agreement&&this.data.settleInfo.isVerification==0){
      this.showPop()
    }else{
      wx.redirectTo({
        url:"/pages/invoice/contract/contract"
      })
    }
   /* app.post(api.).then(res=>{
      console.log(res)
    })*/
  },
  showPop(){
    this.setData({
      isShowPop:true
    });
  },
  hidePop(){
    this.setData({
      isShowPop:false
    });
  },
  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

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

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

  },

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

  },

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

  }
})