// const extConfig = tt.getExtConfigSync ? tt.getExtConfigSync() : {}
// let appVersion = extConfig.appVersion;
var app = getApp();
const config = require('../../config/config.js')
const Http = require('../../utils/HttpBasics.js')

Page({
  data: {
    date: null,
    date2: null,
    codeUrl:'',
    today:'',//当天日期
  },
  bindDateChange1: function(e) {
    this.setData({
      date: e.detail.value,
    })
  },
  bindDateChange2: function(e) {
    this.setData({
      date2: e.detail.value
    })
  },
  onLoad(){
    let date = new Date;
      let year = date.getFullYear();
      var month = '';
      let day = date.getDate();
      if(day<10){
        day = '0'+day
      }
      if (date.getMonth() + 1 < 10) {
        var month = '0' + (date.getMonth() + 1);
      } else {
        var month = date.getMonth() + 1;
      }
      this.setData({
        date: year + '-' + month + '-' + day,
        date2: year + '-' + month + '-' + day,
        today: year + '-' + month + '-' + day
      })
  },
  onShow(){

  },
  mode(){
    wx.hideLoading();
    tt.showLoading({
      title: '加载中...',
    })
    console.log(config.apiPrefix);
    Http.get({
      url:config.api.exportUrl,
      data:{
        verifyStartDate:this.data.date,
        verifyEndDate:this.data.date2
      }
    }).then(res=>{
      tt.hideLoading();
      if(res.data){
        this.setData({
          codeUrl:config.apiPrefix+res.data
        })
      }
    }).catch(err=>{
      wx.hideLoading();
      tt.showToast({
        title: err.message?err.message:err.data,
        icon:"none",
        duration:2000
      })
    })
  },
  goWebView(e){
    let this_ = this;
    tt.setClipboardData({
      data: this_.data.codeUrl,
      success: function() {
        tt.showToast({
          title: '复制成功 请到浏览器打开',
          icon: "none",
          duration: 3000,
        })
      }
    })
  },
 
})