<script>
	import {
		mapState,
		mapActions
	} from 'vuex';
	export default {
		globalData: {
			latitude: '',
			longitude: '',
			version: '',
			city:'',
			cityCode:'',
			isLogin: true,
		},
		onLaunch: function() {
			this.checkToken();
			console.log('App Launch')
		},
		onShow: function() {
			console.log('App Show')
		},
		onHide: function() {
			console.log('App Hide')
		},
		methods:{
			...mapActions([
				'setUserInfo'
			]),
			checkToken(){
				const tokenStartTime = uni.getStorageSync('tokenStartTime');
				const userToken = uni.getStorageSync('userToken');
				const timeOver = 1 * 24 * 3600 * 1000
				let date = new Date().getTime()
				if(date - tokenStartTime > timeOver || !tokenStartTime || !userToken) {
					 console.log('token已过期');
					 uni.removeStorageSync('userToken')
					 uni.removeStorageSync('tokenStartTime')
				}
			}
		},
	}
</script>

<style lang="less">
	@import "common/css/iconfont.css";
	@import "common/css/common.less";
</style>
