<template>
	<view>
		<view class="bottom_tabbar">
			<view v-for="(item,index) in list" :key="index" @tap="changeTabbar(index)">
				<image :src="tabbarIndex===index?item.activeImg:item.inactiveImg"></image>
				<text :class="tabbarIndex===index?'on':''">{{item.text}}</text>

			</view>
		</view>
	</view>
</template>

<script>
	export default {
		props: {
			tabbarIndex: 0
		},
		data() {
			return {
				tabbarValue: 0,
				list: [{
						inactiveImg: './../../static/imgs/tabbar/icon1.png',
						activeImg: './../../static/imgs/tabbar/icon1_on.png',
						text: '首页',
						path: '/pages/index/index'
					},
					{
						inactiveImg: './../../static/imgs/tabbar/icon2.png',
						activeImg: './../../static/imgs/tabbar/icon2_on.png',
						text: '方案',
						path: '/pages/plan/index'
					},
					{
						inactiveImg: './../../static/imgs/tabbar/icon3.png',
						activeImg: './../../static/imgs/tabbar/icon3_on.png',
						text: '在线咨询',
						path: '/pages/consult/index'
					},
				],
			}
		},
		mounted() {
			this.tabbarValue = this.tabbarIndex;
		},
		methods: {
			changeTabbar(e) {
				if (!this.list[e].path) return this.$showToast('正在开发中...')
				this.tabbarValue = e;
				uni.reLaunch({
					url: this.list[e].path
				})
			}
		}
	}
</script>

<style scoped lang="less">
	.bottom_tabbar {
		width: 100%;
		height: 120rpx;
		background: #FFFFFF;
		// box-shadow: 0rpx 0rpx 20rpx 0rpx rgba(0, 0, 0, 0.08);
		// border-radius: 60rpx;
		display: flex;
		align-items: center;
		justify-content: space-around;
		position: fixed;
		left: 0;
		bottom: 0;
		background-color: #fff;
		z-index: 9;
		// 底部安全区域
		box-sizing: content-box;
		padding-bottom: 0 !important;
		padding-bottom: constant(safe-area-inset-bottom) !important;
		padding-bottom: env(safe-area-inset-bottom) !important;
		&>view {
			display: flex;
			flex-direction: column;
			align-items: center;
			justify-content: center;

			image {
				width: 48rpx;
				height: 48rpx;
			}

			text {
				margin-top: 4rpx;
				font-size: 24rpx;
				font-family: PingFangSC, PingFang SC;
				font-weight: 500;
				color: #666666;
				&.on{
					color: #385FDF;
				}
			}
		}
	}
</style>