<template>
	<view class="page_body">
		<!-- 荣誉总览 -->
		<honor-overview v-if="state.tabBarValue=='honorOverview'"></honor-overview>
		<!-- 荣誉教师 -->
		<honor-teacher v-if="state.tabBarValue=='honorTeacher'"></honor-teacher>
		<!-- 我的荣誉 -->
		<my-honor v-if="state.tabBarValue=='myHonor'"></my-honor>
		<!-- 荣誉审核 -->
		<honor-audit v-if="state.tabBarValue=='honorAudit'"></honor-audit>
		<!-- 底部tabbar -->
		<pageTabbar :tabBarValue="state.tabBarValue" :tabBarList="state.tabBarList" @ChangeTabBarValue="ChangeTabBarValue"></pageTabbar>
	</view>
</template>

<script setup>
	import pageTabbar from '@/components/pageTabbar.vue';//底部tabbar
	import honorOverview from './honorOverview/index.vue';//荣誉总览
	import honorTeacher from './honorTeacher/index.vue';//荣誉教师
	import myHonor from './myHonor/index.vue';//我的荣誉
	import honorAudit from './honorAudit/index.vue';//荣誉审核
	import { reactive, ref,onMounted } from 'vue';
	import { useStore } from 'vuex';
	const store = useStore();
	const state = reactive({
		tabBarValue:'',
		tabBarList:[{
			"pathName":"myHonor",
			"iconPath": "/static/image/tabbar/myHonor.png",
			"selectedIconPath": "/static/image/tabbar/myHonor_cur.png",
			"text": "我的荣誉"
		},{
			"pathName":"honorAudit",
			"iconPath": "/static/image/tabbar/honorAudit.png",
			"selectedIconPath": "/static/image/tabbar/honorAudit_cur.png",
			"text": "荣誉审核"
		}]
	})
	//切换tabBar
	const ChangeTabBarValue = (name) => {
		state.tabBarValue = name;
	}
	onMounted(()=>{
		const roleCodes  = store.state?.userStore?.userInfo?.roleCodes || [];
		// 管理员和校长包含荣誉总览和荣誉教师，其他用户没有荣誉总览和荣誉教师
		if(roleCodes.includes('SCHOOL_MANAGER') || roleCodes.includes('SCHOOL_MASTER')){//管理员和校长
			const tabList = [{
				"pathName":"honorOverview",
				"iconPath": "/static/image/tabbar/honorOverview.png",
				"selectedIconPath": "/static/image/tabbar/honorOverview_cur.png",
				"text": "荣誉总览"
			},{
				"pathName":"honorTeacher",
				"iconPath": "/static/image/tabbar/honorTeacher.png",
				"selectedIconPath": "/static/image/tabbar/honorTeacher_cur.png",
				"text": "荣誉教师"
			}]
			state.tabBarList = [...tabList,...state.tabBarList];
			state.tabBarValue = 'honorOverview';
		}else{
			state.tabBarValue = 'myHonor';
		}
	})
</script>

<style lang="scss" scoped>
	.page_body{
		height: 100%;
		min-height: auto;
	}
</style>