// 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": "bjxa",
      "declaring_unit_id": "申报单位id",
    },
      {
        "declaring_unit": "albb",
        "declaring_unit_id": "申报单位id",
      }],
    showUnit:false,
    declaring_unit_id:"",
    showModal_selfDeclare: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('用户点击取消')
        }
      }
    })
  },

  unitPick:function(e){//选择申报单位
    console.log("unitPick",e)
    this.setData({
      declaring_unit_id:"",
      showUnit: false
    })

  },

  selfdeclare_close(){//关闭自行申报弹窗
    this.setData({
      showModal_selfDeclare: false
    })
  },

  declareBySelf:function(){//查看自行申报方式
    this.setData({
      showModal_selfDeclare: true
    })
  },

  godeclareHistory:function(){
    wx.redirectTo({
      url: '../advancepayment/adPayHome',
    })
  },

  noOtherUnitInfo:function(){//没有其他单位个税申报

  },

  otherUnitInfo: function () {//有其他单位个税申报
    wx.navigateTo({
      url: 'addUnitInfo/addUnitInfo',
    })
  },

  onHide: function() {

  },


  onUnload: function() {

  },


  onPullDownRefresh: function() {

  },


  onReachBottom: function() {

  },


  onShareAppMessage: function() {

  }
})