<!-- 初始化页面 -->
<template>
	<view>
		<loading></loading>
	</view>
</template>

<script>
	import {
		mapState
	} from 'vuex'
	export default {
		computed: {
			...mapState('m_children', ['examData', 'workData', 'swapData'])
		},
		onLoad() {
			//缓存中同步token
			if (!uni.getStorageSync('token')) {
				console.log('无Token跳转登录');
				setTimeout(function() {
					uni.redirectTo({
						url: '/subpkg/startup/login'
					})
				}, 1500);

			} else {
				if (!uni.getStorageSync('phoneNumber')) {
					uni.redirectTo({
						url: '/subpkg/startup/guide'
					})
					return console.log('有Token无手机号跳转引导页');
				}
				if (!uni.getStorageSync('childInfo')) {
					uni.redirectTo({
						url: '/subpkg/startup/options'
					})
					return console.log('有Token有手机号无孩子信息跳转选择页');
				}
				console.log('有Token跳转首页');
				this.allTasks()
			}
		},
		methods: {
			//获得异步请求返回值
			async allTasks() {
				try {
					await this.$initTab()
					uni.switchTab({
						url: '/pages/tab_home/tab_home'
					})
				} catch (e) {
					this.$logOut()
				}
			},
		}
	}
</script>

<style lang="scss">

</style>
