<template>
	<view class="content">
		<!-- isIphoneX判断是否为刘海屏在main.js里，好像uniapp有一个css变量获取刘海屏的安全区域 -->
		<view class="tabBar" :style="{height:isIphoneX?'140rpx':'98rpx'}">
			<view class="tabBar_list" :style="{paddingBottom:isIphoneX?'40rpx':''}">
				<view  @tap="cut_index('/seller/pages/home/home')" class="tabBar_item">
					<image v-if="show_index == 0" src="../static/icon-home-active@3x.png"></image>
					<image v-else src="../static/icon-home@3x.png"></image>
					<view :class="{'tabBar_name':true,'nav_active':show_index == 0}">首页</view>
				</view>
				<view @tap="cut_index('/seller/pages/category/category')" class="tabBar_item">
					<image v-if="show_index == 1" src="../static/icon-sort-active@3x.png"></image>
					<image v-else src="../static/icon-sort@3x.png"></image>
					<view :class="{'tabBar_name':true,'nav_active':show_index == 1}">分类</view>
				</view>
				<view  @tap="cut_index('/seller/pages/user/user')" class="tabBar_item">
					<image v-if="show_index == 2" src="../static/icon-user-active@3x.png"></image>
					<image v-else src="../static/icon-user@3x.png"></image>
					<view :class="{'tabBar_name':true,'nav_active':show_index == 2}">我的</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		props:{
			activeIndex:{
				type:Number
			}
		},
		data() {
			return {
				show_index:0,//控制显示那个组件
				isIphoneX:this.$store.state.isIphoneX
			}
		},
		created() {
			this.show_index = this.activeIndex
		},
		methods: {
			// 切换组件
			cut_index(url){
				this.$api.navigateTo(url)
			}
		}
	}
</script>

<style lang="scss">
	.tabBar{ 
		width:100%;
		height: 98rpx;
		background: #fff;
		border-top:1px solid #E5E5E5;
		position: fixed;
		bottom:0px;
		left:0px;
		right:0px;
		display: flex;
		align-items: center;
		justify-content: center;
		.tabBar_list{ 
			width:86%;
			display: flex;
			justify-content: space-between;
			image{ 
				width:48rpx;
				height: 48rpx;
				margin-bottom:2rpx
			}
			.tabBar_item{ 
				width:68rpx;
				display: flex;
				justify-content: center;
				align-items: center;
				flex-direction: column;
				font-size: 20rpx;
				color: #999999;
			}
		 } 
	}
	.nav_active{
		color: $color-system;
	}
</style>
