<script>
	import { calcDate } from '@/utils/date.js'
	import { tokenTime } from '@/common/setting.js'
	export default {
		data() {
			return { refreshLock: false }
		},
		onLaunch: function(options) {
			//var aa = {"path":"pages/index/index","query":{},"scene":1001,"referrerInfo":{"extraData":{"internet":true,"data":{"userCredential":"用户凭证","personIdentifier":"12010119610707201X","Fields":"data","personCode":"106470","depName":"吉林省公安厅","appCredential":"应用凭证","NetworkCode":"3","personId":"410000000000","police":"101470","mobile":"13122223331","personName":"张胜男","resourceList":[{"resourceRegionalismCode":"220000000000","resourceAddress":"http://20.3.1.162:9105/drs/ppc/v1/appQuery.do","resourceId":" 120000000000-3-0100-b0e037d83ecc4d43be788a5e9ddcbbe5","resourceServiceType":"10"}],"personType":"10","depCode":"220000000000","sex":"男","dataObjId":"资源id"}}},"channel":"","launcher":"default"} 
			//var dataOption = JSON.stringify(options)
			//console.log('MiniMall App Launch --- ' + options);
			//uni.setStorageSync('SzApp', dataOption);
			uni.setStorageSync('isSzApp',options.referrerInfo);	
		},
		onShow: function() {
			console.log('App Show')
		},
		onHide: function() {
			console.log('App Hide')
		},
		methods: {
			// 定时检测token
			refreshToken() {
				this.refreshTime = setInterval(() => {
					const token = uni.getStorageSync('token')
					const date = calcDate(token.datetime, new Date().getTime())
					if (!date) return
					if (date.seconds >= tokenTime && !this.refreshLock) {
						this.refreshLock = true
						this.$u.api
							.refreshToken(token.content, '000000')
							.then(res => {
								this.$u.func
									.refreshToken(res)
									.then(() => {
										this.refreshLock = false
									})
									.catch(() => {
										this.refreshLock = false
									})
							})
							.catch(() => {
								this.refreshLock = false
							})
					}
				}, 30000)
			}
		}
	}
</script>


<style lang="scss">
	/*uview全局样式*/
	@import 'uview-ui/index.scss';
	/*app全局样式*/
	@import 'static/style/app.scss';
	/*每个页面公共css */
	@import '@/uni_modules/uni-scss/index.scss';

	// 修改checkbox样式
	checkbox.curdCheck .wx-checkbox-input,
	checkbox.curdCheck .uni-checkbox-input {
		border-radius: 50% !important;
		border-color: #c8c9cc !important;
		color: #5f88ff !important;
	}

	checkbox.curdCheck .wx-checkbox-input-checked,
	checkbox.curdCheck .uni-checkbox-input-checked {
		// background-color: #5f88ff;
		color: #5f88ff !important;
		border-color: #5f88ff !important;
	}

	.uni-picker-container,
	.wx-picker-container {
		z-index: 10074;
	}

	uni-modal {
		z-index: 19999 !important;
	}
	
</style>
