// pages/main/finalpay/home.js
var app = getApp();
var baseUrl = app.globalData.baseUrl;
Page({


  data: {
    declare_status: "",//申报状态
    refund_status: "",//退税状态
    pay_status: "",//补税状态
    payinfo:{},
    unitInfo: [{
      "declaring_unit": "申报单位",
      "declaring_unit_id": "申报单位id",
    },
      {
        "declaring_unit": "申报单位",
        "declaring_unit_id": "申报单位id",
      }],
    showUnit:false,
  },


  onLoad: function(options) {
    this.getPayInfo();
  },


  onReady: function() {

  },


  onShow: function() {

  },

  yearPick: function() {

  },

  getPayInfo:function(){
    var that = this
    this.Authorization = getApp().globalData.Authorization;
    wx.request({
      url: baseUrl + "payroll/v1/settlement-tax/declare-detail",
      header: {
        'Authorization': this.Authorization
      },
      data: { 'years': '2019' },
      success: function (result) {
        console.log("payinfo",result)
        if (result.statusCode==200) {
          that.setData({
            payinfo: result.data
          })
        }
      },
    })
  },

  getUnitInfo:function(){//获取申报单位
    var that = this
    this.Authorization = getApp().globalData.Authorization;
    that.setData({
      showUnit: true
    })
    wx.request({
      url: baseUrl + "payroll/v1/settlement-tax/declaring-unit",
      header: {
        'Authorization': this.Authorization
      },
      data: { },
      success: function (result) {
        console.log("unitInfo", result)
        if (result.statusCode == 200) {
          that.setData({
            unitInfo: result.data
          })
        }
      },
      complete:function(e){
        that.setData({
          showUnit:true
        })
      }
    })
  },

  // 跳转到H5页面测试
  skipH5_01: function() {
    wx.navigateTo({
      url: '../../common/webview?type=1',
    })
  },

  skipH5_02: function() {
    wx.navigateTo({
      url: '../../common/webview?type=2',
    })
  },

  finalpay_detail: function() {
    wx.navigateTo({
      url: 'incomeDetail/incomeDetail',
    })
  },

  declareHere: function() {
    this.getUnitInfo()
  },

  declareNotHere: function() {
    wx.showModal({
      title: '',
      content: '确认不在本单位进行汇算清缴申报吗?',
      confirmColor: '#357aeb',
      success(res) {
        if (res.confirm) {
          console.log('用户点击确定')
          
        } else if (res.cancel) {
          console.log('用户点击取消')
        }
      }
    })
  },

  onHide: function() {

  },


  onUnload: function() {

  },


  onPullDownRefresh: function() {

  },


  onReachBottom: function() {

  },


  onShareAppMessage: function() {

  }
})