<template>
	<view >
		<view class="tab-bar" >
			<view class="tabbar-border"></view>
			<view class="item" v-for="(item, index) in tabList" :key="index" @click="redirectTo(item.link)">
				<view class="bd">	
					<view class="icon" style="margin-bottom: 10rpx;">
							<image  :src="tabIndex==index?item.iconPathS:item.iconPath" />		
					</view>
					<!-- <view
						class="label"	
						:style="{ color: tabIndex==index? 'var(--base-color)' : '#999' }">
						{{ item.text }}
					</view> -->
					<view
						class="label"
						:class=" tabIndex==index?'xuanzhong':'weixuanzhong'">
						{{ item.text }}
					</view>
					
				
				</view>
			</view>
		</view>
		<!-- 解决fixed定位后底部导航栏塌陷问题 -->
		<view class="tab-bar-placeholder"></view>
	</view>
</template>

<script>
export default {
	name: 'diy-bottom-nav',
	props: {
		tabIndex:{
			default:()=>0
		}
	},
	data() {
		return {
			tabList:[
				{
					iconPath:this.$util.img(`/upload/weapp/pageSalesman/tabbar/1.png`),
					iconPathS:this.$util.img(`/upload/weapp/pageSalesman/tabbar/1s.png`),
					text:'首页',
					link:'/page_salesman_index/index/index'
				},
				{
					iconPath:this.$util.img(`/upload/weapp/pageSalesman/tabbar/2.png`),
					iconPathS:this.$util.img(`/upload/weapp/pageSalesman/tabbar/2s.png`),
					text:'数据报表',
					link:'/page_salesman_reportForm/index/index'
				},
				{
					iconPath:this.$util.img(`/upload/weapp/pageSalesman/tabbar/3.png`),
					iconPathS:this.$util.img(`/upload/weapp/pageSalesman/tabbar/3s.png`),
					text:'订单',
					link:'/page_salesman_order/index/index'
				},
				{
					iconPath:this.$util.img(`/upload/weapp/pageSalesman/tabbar/4.png`),
					iconPathS:this.$util.img(`/upload/weapp/pageSalesman/tabbar/4s.png`),
					text:'客户',
					link:'/page_salesman_customer/index/index'
				},
			],
		
		};
	},
	mounted() {
		let currentPage = getCurrentPages()[getCurrentPages().length - 1];
		this.currentRoute = currentPage.route;
	
	},
	computed: {
	
	},
	watch: {
		
	},
	methods: {
		redirectTo(link) {
			uni.redirectTo({
				url:link
			})
			// uni.switchTab({
			// 	url:link
			// })
		},
	
	}
};
</script>

<style lang="scss">
.xuanzhong{
	color:rgb(33, 187, 243);
}
.weixuanzhong{
	color: #999;
}
.placeholder {
	height: 112rpx;
	&.bluge {
		height: 180rpx;
		// color: rgb(33, 187, 243);
	}
}

.safe-area {
	padding-bottom: 0;
	padding-bottom: constant(safe-area-inset-bottom);
	padding-bottom: env(safe-area-inset-bottom);
}

.tab-bar {
	background-color: #fff;
	box-sizing: border-box;
	position: fixed;
	left: 0;
	bottom: 0;
	width: 100%;
	z-index: 998;
	display: flex;
	border-top: 2rpx solid #f5f5f5;
	padding-bottom: 0;
	padding-bottom: constant(safe-area-inset-bottom);
	padding-bottom: env(safe-area-inset-bottom);
	
	.tabbar-border {
		background-color: rgba(255, 255, 255, 0.329412);
		position: absolute;
		left: 0;
		top: 0;
		width: 100%;
		height: 2rpx;
		-webkit-transform: scaleY(0.5);
		transform: scaleY(0.5);
	}

	.item {
		display: flex;
		align-items: center;
		-webkit-box-orient: vertical;
		-webkit-box-direction: normal;
		flex: 1;
		flex-direction: column;
		padding-bottom: 10rpx;
		box-sizing: border-box;

		.bd {
			position: relative;
			height: 100rpx;
			flex-direction: column;
			text-align: center;
			display: flex;
			flex-direction: column;
			justify-content: center;
			align-items: center;

			.icon {
				position: relative;
				display: inline-block;
				margin-top: 10rpx;
				width: 40rpx;
				height: 40rpx;
				font-size: 40rpx;
				image {
					width: 100%;
					height: 100%;
				}
				> view {
					height: inherit;
					display: flex;
					align-items: center;
				}
				.bar-icon {
					font-size: 42rpx;
				}
			}

			.label {
				position: relative;
				text-align: center;
				font-size: 24rpx;
				line-height: 1;
				margin-top: 12rpx;
			}
		}

		&.bulge {
			.bd {
				position: relative;
				height: 100rpx;
				flex-direction: column;
				text-align: center;

				.icon {
					margin-top: -60rpx;
					margin-bottom: 4rpx;
					border-radius: 50%;
					width: 100rpx;
					height: 102rpx;
					padding: 10rpx;
					border-top: 2rpx solid #f5f5f5;
					background-color: #fff;
					box-sizing: border-box;

					image {
						width: 100%;
						height: 100%;
						border-radius: 50%;
					}
				}

				.label {
					position: relative;
					text-align: center;
					font-size: 24rpx;
					line-height: 1.6;
					height: 40rpx;
					line-height: 40rpx;
				}
			}
		}

		.cartNumberBtn {
			position: absolute;
			top: -8rpx;
			right: -18rpx;
			width: 24rpx;
			height: 24rpx !important;
			display: flex;
			justify-content: center;
			align-items: center;
			color: #fff;
			padding: 6rpx;
			border-radius: 50%;
			z-index: 99;
			&.max {
				width: 40rpx;
				border-radius: 24rpx;
				right: -28rpx;
			}
		}
	}
}
.tab-bar-placeholder {
	padding-bottom: calc(constant(safe-area-inset-bottom) + 112rpx);
	padding-bottom: calc(env(safe-area-inset-bottom) + 112rpx);
}
</style>
