<template>
	<view :class="['tabbar-box',isIpx?'ipx_button':'']">
		<view class="tabbar-container"> 
			<view v-for="(item,index) in list" :key='item.pagePath' @click="changeTab(item)"> 
				<view class="image_box">
					<image class="tabbar-image" :src="selected===item.pagePath?item.selectedIconPath:item.iconPath"  lazy-load="false"> </image>  
				</view>
				<text :style="'color: '+selected === item.pagePath ? selectedColor : color">{{item.text}}</text> 
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		name:"tabbar",
		props:{
			selected: {
			  type: String,
			  default: 'homePage'
			},
		},
		data() {
			return {
				isIpx:false,
				color: "#A0A0A0",
				selectedColor: "#2662FF",
				list: [
				  {
					"path": "/pages/index/index",
					"pagePath": "homePage",
					"text": "首页",
					"iconPath": "/static/tabBar/home.png",
					"selectedIconPath": "/static/tabBar/home_yes.png"
				  },
				  {
					"pagePath":"dateplanPage",
					"path": "/pages/dateplan/index",
					"text": "直播计划",
					"iconPath": "/static/tabBar/sphRank.png",
					"selectedIconPath": "/static/tabBar/sphRank_yes.png"
				  },
				  {
					"path":"/pages/brand/brand",
					"pagePath": "brandPage",
					"text": "品牌",
					"iconPath": "/static/tabBar/live.png",
					"selectedIconPath": "/static/tabBar/live.png"
				  },
				  {
					"path":"/pages/goods/goods",
					"pagePath": "goodsPage",
					"text": "商品",
					"iconPath": "/static/tabBar/cyRank.png",
					"selectedIconPath": "/static/tabBar/cyRank_yes.png"
				  },
				  {
					"path":"/pages/mine/mine",
					"pagePath": "minePage",
					"text": "我的",
					"iconPath": "/static/tabBar/wode.png",
					"selectedIconPath": "/static/tabBar/wode_yes.png"
				  }
				]
			};
		},
		mounted() {
			this.isIpx = this.$store.state.systemInfo.isIpx
		},
		methods: {
			changeTab(item){
				uni.switchTab({
					url:item.path
				})
			}
		}
	}
</script>

<style>
.tabbar-box{
  position: fixed;
  bottom: 0;
  width: 100%;
  height: 110rpx;
  background-color: #fff;
  box-shadow: 0 -4rpx 14rpx rgba(194, 194, 194, 0.5);
  z-index: 99999;
  padding-bottom: 16rpx;
}
.ipx_button {
  height: 130rpx;
}
.tabbar-container{
  display: flex;
  justify-content: space-between;
}
.tabbar-container>view{
  width: 20%;
  text-align: center;
  padding-top: 16rpx;
}
.tabbar-container>view>text{
  display: block;
  margin-top: 4rpx;
  font-size: 22rpx;
  line-height: 20rpx; 
}
.tabbar-image{
  display: inline-block;
  width: 46rpx;
  height: 46rpx;
}
/* .tabbar-container>view:nth-child(3) {
  margin-top: -54rpx;
}
.tabbar-container>view:nth-child(3) .image_box {
  width: 108rpx;
  background: #fff;
  border-radius: 50%;
  text-align: center;
  margin: auto;
  padding-top: 15rpx;
}
.tabbar-container>view:nth-child(3) image {
  width: 80rpx;
  height: 80rpx;
} */
.center {
  width: 108rpx;
  height: 108rpx;
  border-radius: 50%;
  position: fixed;
  bottom: 40rpx;
  left: 0;
  right: 0;
  margin: auto;
  box-shadow: 0 -4rpx 14rpx rgba(194, 194, 194, 0.5);
  z-index: 1;
}
</style>
