<template>
	<view class="tabbar-container">
		<block>
			<view class="tabbar-item" v-for="(item, index) in tabbarList"
				 :class="[currentItem == item.id ? ' center-item' : '']"  @click="changeItem(item)">
				<view class="item-top">
					<image :style="{width:item.width+'rpx',height:item.height+'rpx'}"
						:src="currentItem == item.id ? item.selectedIconPath : item.iconPath"></image>
				</view>
				<view class="item-bottom" :class="[currentItem == item.id ? 'item-active' : '']">
					<text>{{ item.text }}</text>
				</view>
			</view>
		</block>
	</view>
</template>

<script>
	export default {
		props: {
			currentPage: {
				type: Number,
				default: 0
			}
		},
		data() {
			return {
				currentItem: 0,
				tabbarList: [{
						id: 0,
						centerItem: false,
						width: 71,
						height: 58,
						"text": "首页",
						"pagePath": "/pages/home/home",
						"iconPath": require("@/static/icon1.png"),
						"selectedIconPath": require("@/static/icon1-cur.png")
					},
					{
						id: 1,
						centerItem: false,
						width: 66,
						height: 61,
						"text": "线路",
						"pagePath": "/pages/line/line",
						"iconPath": require("@/static/icon2.png"),
						"selectedIconPath": require("@/static/icon2-cur.png")
					},
					{
						id: 2,
						centerItem: false,
						width: 54,
						height: 60,
						"text": "我的",
						"pagePath": "/pages/me/me",
						"iconPath": require("@/static/icon3.png"),
						"selectedIconPath": require("@/static/icon3-cur.png")
					}
				]
			};
		},
		mounted() {
			this.currentItem = this.currentPage;
			uni.hideTabBar();
		},
		methods: {
			changeItem(item) {
				let _this = this;
				console.log(item.pagePath)
				//_this.currentItem = item.id;
				
				uni.switchTab({
					url: item.pagePath
				});
			}
		}
	};
</script>
<style scoped>
	view {
		padding: 0;
		margin: 0;
		box-sizing: border-box;
	}

	.tabbar-container {
		position: fixed;
		bottom: 0;
		left: 0;
		width: 100%;
		height: 135rpx;
		display: flex;
		align-items: center;
		padding: 10rpx 0;
		color: #6E6E6E;
		z-index: 9999;
		background: #fff;
		background: #fff;
		border-top:10rpx solid #dbd0ba;
	}

	.tabbar-container .tabbar-item {
		width: 50%;
		/* height: 100rpx; */
		display: flex;
		flex-direction: column;
		/* justify-content: center; */
		align-items: center;
		text-align: center;
	}

	.tabbar-container .item-active {
		color: #73685c;
	}

	.tabbar-container .center-item {
		/* display: block;
		position: relative; */
	}

	.tabbar-container .tabbar-item .item-top {
		/* width: 56rpx;
		height: 44rpx; */
		margin: 10rpx 0;
		position: relative;
		width: 120rpx;
		height: 61rpx;
	}

	.tabbar-container .tabbar-item .item-top image {
		vertical-align: middle;
		position: relative;
		z-index:999999;
	}

	.tabbar-container .tabbar-item .item-bottom {
		font-size: 28rpx;
		width: 100%;
	}

	.tabbar-container .center-item .item-bottom {
		/* position: absolute;
		bottom: 5rpx; */
	}
	
	.tabbar-container .center-item .item-top::before {
		content:'';
		width: 120rpx;
		height: 80rpx;
		position: absolute;
		/* top: -50rpx;
		left: calc(50% - 50rpx); */
		top:5%;
		left:50%;
		transform: translate(-50%,-50%);
		border-radius: 60rpx 60rpx 0 0;
		box-shadow: 0 -6rpx 12rpx rgba(0, 0, 0, 0.1);
		z-index:99999;
		background-color: #fff;
		/* background-color: #ffffff; */
	}
</style>