<template>
	<view class="container">
		<view class="content" :class="tabValue">
			<course-home v-if="tabValue === 'courseHome'"></course-home>
			<course-mine v-if="tabValue === 'courseMine'"></course-mine>
		</view>
		<view class="bottom-block"></view>
		<view class="bottom-box">
			<view class="menu-box">
				<view class="menu-item-box" :class="{'is-active': tabValue === 'courseHome'}" @click="selectTab('courseHome')">
					<view class="iconfont icon-home"></view>
					<view class="text">首页</view>
				</view>
				<view class="menu-item-box" :class="{'is-active': tabValue === 'courseMine'}" @click="selectTab('courseMine')">
					<view class="iconfont icon-user-s"></view>
					<view class="text">我的</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import courseHome from './courseHome/courseHome.vue';
	import courseMine from './courseMine/courseMine.vue';

	export default {
		data() {
			return {
				tabValue: 'courseHome', // 默认选中的 Tab
			};
		},
		components: {
			courseHome,
			courseMine,
		},
		methods: {
			selectTab(value) {
				this.tabValue = value; // 设置当前选中的 Tab
			},
		},
	};
</script>

<style scoped lang="scss">
	.container {
		display: flex;
		flex-direction: column;
		height: 100vh;
	}

	.content {
		flex: 1;
		/* 内容区填充剩余空间 */
		padding: 0 30rpx;

		/* 内边距 */
	}
	.courseHome {
		background-color: #fff;
	}
	.courseMine {
		background-color: #f7f7f7;
	}
	.tabbar-block {
		flex: 0 0 auto;
		height: 150rpx;
		padding-bottom: env(safe-area-inset-bottom, 0);
	}
	.tabbar {
		-webkit-tap-highlight-color: rgba(0,0,0,0);
		position: fixed;
		width: 100vw;
		// height: 100rpx;
		bottom: 0;
		display: flex;
		justify-content: space-around;
		/* 平分 TabBar 各项 */
		background-color: #fff;
		/* TabBar 背景色 */
		padding-bottom: env(safe-area-inset-bottom, 0);
		/* 避免与底部黑条重叠 */

		/* 仅在上方添加阴影 */
		box-shadow: 5px -1px 0px rgba(0, 0, 0, 0.1);
		/* 上边阴影效果 */
		height: 150rpx;
		align-items: center;
		border-top: none;
		/* 去掉上边的边框,如果之前有的话 */
		border-bottom: none;
		/* 去掉下边的边框 */
	}
	.tab-item {

		// padding: 15rpx 0;
		flex: 1;
		/* 每个 TabBar 项均分 */
		text-align: center;
		/* 内容居中 */
		cursor: pointer;
		/* 鼠标指针样式 */
		display: flex;
		/* 激活状态下加粗显示 */
		flex-direction: column;
		align-items: center;
		font-size: 20rpx;

		image {
			width: 50rpx;
			height: 50rpx;
		}
	}

	.tab-item.active {
		color: #0069f6;
		/* 激活状态下的文本颜色 */

	}
	.bottom-block {
		flex: 0 0 auto;
		height: calc(112rpx + env(safe-area-inset-bottom, 0));
	}
	.bottom-box {
		padding: 5rpx 20rpx;
		background-color: $uni-bg-color-grey;
		border: 1rpx solid #E9E9E9;
		padding-bottom: calc(5rpx + env(safe-area-inset-bottom, 0));
		@include bottomMagnet();
		.menu-box {
			height: 100rpx;
			display: flex;
			align-items: center;
			.menu-item-box {
				width: calc(100% / 2);
				text-align: center;
				.iconfont {
					font-size: 55rpx;
				}
				.text {
					font-size: $uni-font-size-2;
				}
			}
			.is-active {
				color: $uni-color-primary;
			}
		}
	}
</style>