<template>
	<view id="home">
		<teacherHome class="flex-box-page" v-if="userType==1"></teacherHome>
		<pupilHome class="flex-box-page" v-if="userType==2"></pupilHome>
	</view>
</template>
<script>
	import {
		teacherHome
	} from '@/pages/views/teacherPage/teacherHome'
	import {
		pupilHome
	} from '@/pages/views/pupilPage/pupilHome'
	export default {
		name: "home",
		components: {
			teacherHome,
			pupilHome,
		},
		data() {
			return {
				userType: 0,
			}
		},
		onLoad() {
			
		},
		onShow() {
			if (uni.getStorageSync('token') && uni.getStorageSync('userId') && uni.getStorageSync('userType')) {
				this.userType = uni.getStorageSync('userType')
			} else {
				uni.removeStorageSync('token');
				uni.removeStorageSync('userId');
				uni.removeStorageSync('userType');
				uni.redirectTo({
					url: '/pages/login/login',
				});
			}
		},
		methods: {
		},
		onHide() {
			this.userType = 0;
		},
		onUnload() {
			this.userType = 0;
		}
	}
</script>

<style lang="stylus" scoped>
	#home {
		height: 100%;
		display: flex;
		flex-direction: column;
		.flex-box-page{
			flex:1;
			display: flex;
			flex-direction: column;
		}
	}
</style>