<template>
	<view class="tabbar-container">
		<block>
			<view class="tabbar-item" v-for="(item, index) in tabbarList"
				:class="[item.centerItem ? ' 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: 56,
						height: 44,
						"pagePath": "/pages/index/index",
						"text": "首页",
						"iconPath": "/static/img/icon_nav_home.png",
						"selectedIconPath": "/static/img/icon_nav_home_on.png"
					},
					{
						id: 1,
						centerItem: false,
						width: 54,
						height: 44,
						"pagePath": "/pages/guide/index",
						"text": "服务",
						"iconPath": "/static/img/icon_nav_service.png",
						"selectedIconPath": "/static/img/icon_nav_service_on.png"
					},
					{
						id: 2,
						centerItem: true,
						width: 111,
						height: 113,
						"pagePath": "/pages/vr/index",
						"text": "",
						"iconPath": "/static/img/icon_nav_vr.png",
						"selectedIconPath": "/static/img/icon_nav_vr.png"
					},
					{
						id: 3,
						centerItem: false,
						width: 56,
						height: 31,
						"pagePath": "/pages/exhibit/index",
						"text": "展览",
						"iconPath": "/static/img/icon_nav_guide.png",
						"selectedIconPath": "/static/img/icon_nav_guide_on.png"
					},
					{
						id: 4,
						centerItem: false,
						width: 44,
						height: 44,
						"pagePath": "/pages/mine/index",
						"text": "我的",
						"iconPath": "/static/img/icon_nav_user.png",
						"selectedIconPath": "/static/img/icon_nav_user_on.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>
	view {
		padding: 0;
		margin: 0;
		box-sizing: border-box;
	}

	.tabbar-container {
		position: fixed;
		bottom: 0;
		left: 0;
		width: 100%;
		height: 120rpx;
		box-shadow: 0 0 10px #999;
		display: flex;
		align-items: center;
		padding: 10rpx 0;
		color: #6E6E6E;
		z-index: 9999;
		background: #fff;
		background: #fff;
	}

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

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

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

	.tabbar-container .tabbar-item .item-top {
		width: 56rpx;
		height: 44rpx;
		margin: 10rpx 0;
	}

	.tabbar-container .center-item .item-top {
		flex-shrink: 0;
		width: 111rpx;
		height: 113rpx;
		position: absolute;
		top: -50rpx;
		left: calc(50% - 50rpx);
		border-radius: 50%;
		box-shadow: 0 0 5px #999;
		background-color: #ffffff;
	}

	.tabbar-container .tabbar-item .item-top image {
		vertical-align: middle;
	}

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

	.tabbar-container .center-item .item-bottom {
		position: absolute;
		bottom: 5rpx;
	}
</style>