<template>
	<view class="">
		<view class="tabbar-bug"></view>
		<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 :src="currentItem==item.id?item.selectIcon:item.icon"></image>
				</view>
				<view class="item-bottom" :class="[currentItem==item.id ? 'item-active' : '']">
					<text>{{item.text}}</text>
				</view>
			</view>
		</block>
		<publishSlide v-if="slideVisit" @quitSlide="quitSlide"></publishSlide>
		</view>
		
	</view>
</template>

<script>
	export default {
		props: {
			currentPage: {
				type: Number,
				default: 0
			}
		},
		data() {
			return {
				slideVisit: false,
				currentItem: 0,
				tabbarList: [{
					id: 0,
					path: "/pages/index/index",
					icon: "/static/tabbar/di_icon_syh.png",
					selectIcon: "/static/tabbar/di_icon_sy.png",
					text: "首页",
					centerItem: false
				}, {
					id: 1,
					path: "/pages/shopTransfer/shopTransfer",
					icon: "/static/tabbar/di_icon_zrh.png",
					selectIcon: "/static/tabbar/di_icon_zr.png",
					text: "店铺转让",
					centerItem: false
				}, {
					id: 2,
					icon: "/static/tabbar/di_icon_fb.png",
					text: "发布",
					centerItem: true
				}, {
					id: 3,
					path: "/pages/shopAddress/shopAddress",
					icon: "/static/tabbar/di_icon_dzh.png",
					selectIcon: "/static/tabbar/di_icon_dz.png",
					text: "找店地址",
					centerItem: false
				}, {
					id: 4,
					path: "/pages/my/my",
					icon: "/static/tabbar/di_icon_wdh.png",
					selectIcon: "/static/tabbar/di_icon_wd.png",
					text: "我的",
					centerItem: false
				}]
			};
		},
		mounted() {
			this.currentItem = this.currentPage;
			uni.hideTabBar();
		},
		methods: {
			quitSlide() {
				this.slideVisit = false
			},
			changeItem(item) {
				if (item.id == 2) {
					this.slideVisit = true
				}
				let _this = this;
				uni.switchTab({
					url: item.path
				});

			}
		}
	}
</script>
<style scoped>
	.tabbar-bug {
		position: absolute;
		width: 100%;
		height: 98rpx;
	}
	view {
		padding: 0;
		margin: 0;
		box-sizing: border-box;
	}

	.tabbar-container {
		position: fixed;
		bottom: 0;
		left: 0;
		width: 100%;
		height: 98rpx;
		display: flex;
		align-items: center;
		/* padding: 5rpx 0; */
		color: #999999;
		z-index: 200;
		background-color: #fff;
	}

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

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

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

	}

	.tabbar-container .tabbar-item .item-top {
		width: 50rpx;
		height: 50rpx;
		padding: 0rpx;
	}

	.tabbar-container .center-item .item-top {
		flex-shrink: 0;
		width: 100rpx;
		height: 100rpx;
		position: absolute;
		top: -61rpx;
		left: calc(50% - 50rpx);
		border-radius: 50%;
	}

	.tabbar-container .tabbar-item .item-top image {
		width: 100%;
		height: 100%;
	}

	tabbar-container .tabbar-item:nth-child(3) .item-top image {
		background: #ff0000;
	}

	.tabbar-container .tabbar-item .item-bottom {
		font-size: 22rpx;
		width: 100%;
		margin-top: 3rpx;
	}

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