<template>
	<view>
		1
	</view>
</template>

<script>
	import helper from 'common/helper.js'
	export default {
		onLaunch: function() {},
		onShow: function() {
			/* #ifndef H5 */
			const getInfo = (token) => {
				uni.request({
					url: `${helper.serverUrl}/user/getInfo`,
					header: {
						Authorization: `Bearer ${token}`
					},
					success(resp) {
						console.log('success', resp);
						if (resp?.data?.code !== 200) {
							uni.reLaunch({
								url: '/pages/login/login',
								success() {
									// plus.navigator.closeSplashscreen();
								},
								fail(err) {
									console.log('reLaunch', err);
								}
							})
						} else {
							uni.reLaunch({
								url: '/pages/index/index',
								success() {
									// plus.navigator.closeSplashscreen();
								},
								fail(err) {
									console.log('reLaunch', err);
								}
							})
						}
					},
					fail(err) {
						console.log('error', err);
						if (token) {
							uni.reLaunch({
								url: '/pages/index/index',
								success() {
									// plus.navigator.closeSplashscreen();
								},
								fail(err) {
									console.log('reLaunch', err);
								}
							})
						} else {
							uni.reLaunch({
								url: '/pages/login/login',
								success() {
									// plus.navigator.closeSplashscreen();
								}
							})
						}
					}
				})

			}
			uni.getStorage({
				key: 'token',
				success(token) {
					if (token) {
						helper.tempToken = token.data;
					}
					getInfo(token.data)
				},
				fail(err) {
					console.log('err', err)
					getInfo()
				}
			})
			/* #endif */
		},
		onHide: function() {}
	}
</script>

<style>
</style>