<template>
	<view class="container">
		<enterNavigator :selectedIndex="nav_current_index" @clickToIndex='homeNavigatorClick'/>
		<home :viewTop="subviewTop" :viewHeight="subviewHeight" v-if="nav_current_index == config.page_index.home" />
		<AIChat :viewTop="subviewTop" :viewHeight="subviewHeight" v-if="nav_current_index == config.page_index.ai_chat" />
		<AIDraw :viewTop="subviewTop" :viewHeight="subviewHeight" v-if="nav_current_index == config.page_index.ai_draw" />
	</view>
</template>

<script>
	import enterNavigator from '../../pages/enter/enter-navigator.vue'
	import home from '../../pages/home/home.vue'
	import AIChat from '../../pages/AI_chat/AI_chat.vue'
	import AIDraw from '../../pages/AI-draw/AI-draw.vue'
	import config from '../../utils/config.js'
	export default {
		data() {
			return {
				nav_current_index: 0,     // 当前导航索引
				subviewTop: 0,
				subviewHeight: 0,
			}
		},
		methods: {
			homeNavigatorClick(index) {
				if(index == config.page_index.ai_chat ||
				   index == config.page_index.ai_draw) {
					if(this.tools.is_login_gotoLogin() == false) {
						return
					}
				}
				this.nav_current_index = index
			}
		},
		mounted() {
			let systemInfo = uni.getSystemInfoSync()
			
			this.subviewTop = 60
			this.subviewHeight = systemInfo.screenHeight - this.subviewTop
		},
		components: {
			enterNavigator,
			home,
			AIChat,
			AIDraw
		}
	}
</script>

<style lang="scss">
	.container{
		
	}
</style>
