<script>
  import config from './config'
  import store from '@/store'
  import { getToken } from '@/utils/auth'
import self from '@/utils/location.js';
import {getAdrinfo} from "@/api/index/index.js"
  export default {
    onLaunch: function() {
      this.initApp()
	  // 小程序强制更新
	  // #ifdef MP-WEIXIN
	  const updateManager = uni.getUpdateManager()
	    updateManager.onCheckForUpdate(function (res) {
	      // 请求完新版本信息的回调
			updateManager.onUpdateReady(function () {	   
			  uni.showModal({   
			    title: '更新提示',   
			    content: '新版本已经准备好,是否重启应用?',   
			    success: function (res) {   
			      if (res.confirm) { 
			        // 新的版本已经下载好,调用 applyUpdate 应用新版本并重启  
			        updateManager.applyUpdate()   
			      }
				   
			    }
				   
			  })
				   
			})
	    })
	   
	    updateManager.onUpdateFailed(function () {
	      // 新的版本下载失败
	      uni.showModal({
	        title: '更新提示',
	        content: '新版本下载失败',
	        showCancel: false
	      })
	   
	    })
		// #endif
    },
    methods: {
      // 初始化应用
      initApp() {
        // 初始化应用配置
        this.initConfig()
        // 检查用户登录状态
		this.checkLogin()
        //#ifdef H5
        
        //#endif
      },
      initConfig() {
        this.globalData.config = config
      },
	  getAdrinfoFn(res){
	  	var params={
	  		address:res.address,
	  		longitude:res.lng,
	  		latitude:res.lat,
	  	}
	  	getAdrinfo(params).then(res=>{
	  	})
	  },
      checkLogin() {
		  var that=this;
        if (getToken()) {
			// #ifndef H5
			self.getLocation(function(res){
				if(res==-1){
					// that.setflag=true
				}else{
					that.getAdrinfoFn(res)
				}			
			})
			// #endif
        }
      }
    }
  }
</script>

<style lang="scss">
  @import '@/static/scss/index.scss';
  @import "@/static/style.css";
  /* #ifdef MP-WEIXIN */
  .ytbox /deep/ uni-textarea{flex: 1;width: auto;text-align: right;}
  
  .xmmain /deep/ .uni-data-checklist .checklist-group{display: block;}
    .xmmain /deep/ .uni-data-checklist .checklist-group .checklist-box{padding: 28rpx 0;margin: 0;}
     
     .xmmain /deep/ .uni-data-checklist .checklist-group .checklist-box .checklist-text{color: #343434;font-size: 34rpx;font-weight: bold;}
    .xmmain /deep/ .uni-data-checklist .checklist-group .checklist-box .checkbox__inner{margin-right: 32rpx;}
    .xmmain  /deep/ .uni-data-checklist .checklist-group .checklist-box.is--default.is-checked .checkbox__inner{border-color: #FF440B; background-color: #FF440B;}
    .xmmain /deep/ .uni-data-checklist .checklist-group .checklist-box.is--default.is-checked .checklist-text{color: #343434;}
  
 .addbox /deep/ .uni-forms{flex: 1;}
 .addbox /deep/ .uni-forms-item__label{flex: 0 0 auto;width: auto !important;font-size: 30rpx;font-weight: bold;
 color: #161616;}
 .addbox /deep/ .uni-forms .uni-forms-item{margin-bottom: 0;padding: 4rpx 32rpx;
 	// &:nth-of-type(3){margin-bottom: 0;border-bottom: 0;}
 }
 .addbox /deep/  .uni-easyinput{height: 70rpx;}
 // .addbox /deep/  .uni-textarea-textarea{height: auto;}
 .addbox /deep/ .uni-forms-item__content{display: flex;align-items: center;flex-direction: row;}
 .addbox /deep/ .uni-easyinput{flex: 1;text-align: right;}
 .addbox /deep/ .uni-easyinput__placeholder-class{font-size: 30rpx;}
 .addbox /deep/ .uni-easyinput__content-input{font-size: 30rpx;}
  .addbox /deep/ .uni-forms-item__error{margin-top:-12rpx;left: auto;right: 0;}
  .addbox /deep/ .uni-data-checklist .checklist-group .checklist-box{margin-right: 30rpx;}
  .addbox /deep/ .uni-forms-item__content{justify-content: flex-end;}
   .addbox /deep/ .uni-data-checklist .checklist-group{justify-content: flex-end;}
   
   
   //注册
   .regbox /deep/ .uni-forms{flex: 1;}
      .regbox /deep/ .uni-forms-item__label{flex: 0 0 auto;width: auto !important;font-size: 32rpx;font-weight: bold;
      color: #161616;}
      .regbox /deep/ .uni-forms .uni-forms-item{padding: 28rpx 24rpx 20rpx;border-bottom: 2rpx #C1C1C1 solid;margin-bottom: 0;
      	// &:nth-of-type(3){margin-bottom: 0;border-bottom: 0;}
      }
      .regbox /deep/ .uni-forms-item__content{display: flex;align-items: center;flex-direction: row;}
      .regbox /deep/ .uni-easyinput{flex: 1;text-align: right;}
      .regbox /deep/ .uni-easyinput__placeholder-class{font-size: 30rpx;}
      .regbox /deep/ .uni-easyinput__content-input{font-size: 30rpx;}
       .regbox /deep/ .uni-forms-item__error{margin-top:20rpx;left: auto;right: 0;}
	.container  .regbox /deep/ .uni-forms .uni-forms-item{padding: 10rpx 24rpx 10rpx;border-bottom: none;}
	.container  .regbox /deep/ .uni-forms-item__error{margin-top:-16rpx;left: auto;right: 0;}
// 日期格式
.mind /deep/ .uni-input-wrapper{text-align: right;font-size: 30rpx;}
.mind /deep/ .uni-date__x-input{padding: 0;text-align: right;font-size: 30rpx;}
.mind /deep/ .uni-date-x{padding: 0;}
.mind /deep/ .uniui-calendar::before{display: none;}
.mind /deep/ .uni-input-placeholder{color:#AAAAAA;font-size: 30rpx;}


// 历史记录
.zb-table /deep/ .zb-table-fixed{background: #F1F5FF !important;}
.zb-table /deep/ .item-th{text-align: center !important;padding: 0 4rpx;background: #F1F5FF !important;text-align: center;border-bottom: none !important;}
.zb-table /deep/ .item-td{text-align: center !important;padding: 0 4rpx;}
.container /deep/ .zb-table-fixed{background: #F1F5FF !important;}
.container /deep/ .item-th{text-align: center !important;padding: 0 4rpx;background: #F1F5FF !important;text-align: center;}
.container /deep/ .item-td{text-align: center !important;padding: 0 4rpx;}
// 工资条
.pay .paybox /deep/  .zb-table-header{background-color: #F2F5FB !important;}
.pay .paybox /deep/  .zb-table-applet .zb-table-header .zb-stick-side{background-color: #F2F5FB !important;}
.pay .paybox /deep/  .odd{background-color: #F2F5FB !important;}
.pay .paybox /deep/ .item-td{border-bottom: none !important;font-weight: bold !important;font-size: 26rpx ;}
.pay .paybox /deep/ .item-th{border-bottom: none !important;background-color: #F2F5FB !important;font-weight: bold !important;font-size: 26rpx;}
.pay .paybox /deep/ .zb-table-tbody{padding-bottom: 20rpx !important;}
.detail /deep/  .zb-table-header{background-color: #F2F5FB !important;}
.detail /deep/  .zb-table-applet .zb-table-header .zb-stick-side{background-color: #F2F5FB !important;}
.detail /deep/  .odd{background-color: #F2F5FB !important;}
.detail /deep/ .item-td{border-bottom: none !important;}
.detail /deep/ .item-th{border-bottom: none !important;background-color: #F2F5FB !important;}
  /* #endif */

</style>