<template>
	<view id="home">
		<manage-home v-if="userType==1" ref="manage"></manage-home>
		<user-home v-if="userType==2"></user-home>
		<supplier-home v-if="userType==3"></supplier-home>
		<tab-bar v-if="userType!=3"></tab-bar>
	</view>
</template>
<script>
	// #ifdef MP-WEIXIN
	import {
		manageHome
	} from '@/pages/views/home/manageWorkbench'
	import {
		userHome
	} from '@/pages/views/home/studentWorkbench.vue'
	import {
		supplierHome
	} from '@/pages/views/home/supplierWorkbench.vue'
	import {
		tabBar
	} from '@/pages/component/tabBar.vue'
	// #endif
	export default {
		name: "home",
		// #ifdef MP-WEIXIN
		components: {
			manageHome,
			userHome,
			supplierHome,
			tabBar
		},
		// #endif
		// #ifdef H5
		components: {
			"manageHome": () => import('@/pages/views/home/manageWorkbench.vue'),
			"userHome": () => import('@/pages/views/home/studentWorkbench.vue'),
			"supplierHome": () => import('@/pages/views/home/supplierWorkbench.vue'),
			"tabBar": () => import('@/pages/component/tabBar.vue'),
		},
		// #endif
		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%;
	}
</style>