<script>
	export default {
		onLaunch: function() {
			console.log('App Launch')
			var now = new Date().getTime()
			var token = uni.getStorageSync('token')
			var time = uni.getStorageSync('time')
			if (token && time && now - time < 60000) { //一小时过期
				plus.navigator.closeSplashscreen();
				getApp().globalData.userId = uni.getStorageSync('userId')
				getApp().globalData.name = uni.getStorageSync('name')
				getApp().globalData.type = uni.getStorageSync('type')
				getApp().globalData.icon = uni.getStorageSync('icon')
				getApp().globalData.school = uni.getStorageSync('school')
				getApp().globalData.moblie = uni.getStorageSync('mobile')
				getApp().globalData.gender = uni.getStorageSync('gender')
				getApp().globalData.teamNameStorageCount = uni.getStorageSync('teamNameStorageCount')
				getApp().globalData.runningRecordStorageCount = uni.getStorageSync('runningRecordStorageCount')
				getApp().globalData.walkingRecordStorageCount = uni.getStorageSync('walkingRecordStorageCount')
			} else {
				uni.reLaunch({
					url: '/pages/login/login',
					success: () => {
						plus.navigator.closeSplashscreen();
					}
				})
			}
		},
		onShow: function() {
			// let push_clientid;
			// uni.getPushClientId({
			// 	success: (res) => {
			// 		push_clientid = res.cid
			// 		console.log('客户端推送标识:', push_clientid)
			// 		uniCloud.callFunction({
			// 				name: 'uni-cloud-push',
			// 				data: {
			// 					"appId": "__UNI__AAFC50C",
			// 					"push_clientid": push_clientid,
			// 					"title": "unitest",
			// 					"content": push_clientid,
			// 					"payload": {
			// 						"text": "ddddddoooo"
			// 					}
			// 				}
			// 			})
			// 			.then(res => {
			// 				console.log(res);
			// 			});
			// 	},
			// 	fail(err) {
			// 		console.log(err)
			// 	}
			// })
			console.log('App Show')
		},
		onHide: function() {
			console.log('App Hide')
			var time = new Date().getTime()
			uni.setStorageSync('time', time)
		},
		globalData: {
			userId: '',
			name: '',
			type: '',
			icon: '',
			teamNameStorageCount: 1,
			runningRecordStorageCount: 1,
			walkingRecordStorageCount: 1,
		}
	}
</script>

<style lang="scss">
	/* 注意要写在第一行，同时给style标签加入lang="scss"属性 */
	@import "@/uni_modules/uview-ui/index.scss";
</style>