<template>
	<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="{'active':tabbarIndex===index}">{{item.text}}</text>
		</view>
	</view>
</template>

<script>
	export default {
		props: {
			tabbarIndex: 0
		},
		data() {
			return {
				tabbarValue: 0,
				list: [
					{
						inactiveImg: this.$imgBase+'clockingin/clock_inactive.png',
						activeImg: this.$imgBase+'clockingin/clock_active.png',
						text: '打卡',
						path: '/pagesClockin/index'
					},
					{
						inactiveImg: this.$imgBase+'clockingin/statistics_inactive.png',
						activeImg: this.$imgBase+'clockingin/statistics_active.png',
						text: '统计',
						path: '/pagesStatistics/index'
					},
					// {
					// 	inactiveImg: this.$imgBase+'clockingin/set_inactive.png',
					// 	activeImg: this.$imgBase+'clockingin/set_active.png',
					// 	text: '设置',
					// 	path: '/pagesSetting/index'
					// },
				]
			}
		},
		mounted() {
			this.tabbarValue = this.tabbarIndex;
		},
		methods: {
			changeTabbar(e) {
				this.tabbarValue = e;
				uni.reLaunch({
					url: this.list[e].path
				})
			}
		}
	}
</script>

<style scoped lang="less">
	.bottom_tabbar {
		width: 100%;
		height: 168rpx;
		background: #FFFFFF;
		display: flex;
		position: fixed;
		left: 0;
		bottom: 0;
		z-index: 999;
		padding-top: 10rpx;
		box-sizing: border-box;
		border-top: 1rpx solid lavender;

		&>view {
			width: calc(100% / 2);
			height: 100%;
			display: flex;
			flex-direction: column;
			align-items: center;

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

			text {
				margin-top: 6rpx;
				font-family: PingFangSC, PingFang SC;
				font-weight: 400;
				font-size: 24rpx;
				color: #86909C;
				line-height: 33rpx;
				text-align: center;
				&.active{
					font-weight: bold;
					color: #198CFF;
				}
			}
		}
	}
</style>