<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: 10,
						centerItem: false,
						width: 37,
						height: 39,
						"text": "首页",
						"pagePath": "/pages/home/home",
						"iconPath": require("@/static/index_icon1.png"),
						"selectedIconPath": require("@/static/index_icon1.png")
					},
					{
						id: 11,
						centerItem: false,
						width: 53,
						height: 41,
						"text": "客服",
						"pagePath": "/pages/talk/talk",
						"iconPath": require("@/static/index_icon2.png"),
						"selectedIconPath": require("@/static/index_icon2.png")
					},
					{
						id: 12,
						centerItem: false,
						width: 36,
						height: 37,
						"text": "我的",
						"pagePath": "/pages/me/me",
						"iconPath": require("@/static/index_icon3.png"),
						"selectedIconPath": require("@/static/index_icon3.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: 20rpx 0;
		padding-bottom: 25rpx;
		color: #6E6E6E;
		z-index: 9999;
		background: #fff;
		background: #fff;
		box-shadow: 0 -6rpx 12rpx rgba(0, 0, 0, 0.1);
		/* 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;
		border-right: 1px solid #7a7a7a;
	}

	.tabbar-container .tabbar-item:last-child {
		border-right: none
	}

	.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: 50rpx;
	}

	.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>