<template>
	<view class="tabbar">
		<view :class="['item',current == 0?'active':'']" @click="currentTab(0)">
			<image v-if="current==0" src="../static/images/home-fill.png" mode=""></image>
			<image v-else src="../static/images/home.png" mode=""></image>
			<view class="name">
				首页
			</view>
		</view>
		<view v-if="$transformAuth('100202')" :class="['item',current == 1?'active':'']" @click="currentTab(1)">
			<image v-if="current==1" src="../static/images/scheduling-fill.png" mode=""></image>
			<image v-else src="../static/images/scheduling.png" mode=""></image>
			<view class="name">
				工作
			</view>
		</view>
		<view v-if="$transformAuth('101100')"  :class="['item',current == 2?'active':'']" @click="currentTab(2)">
			<image v-if="current==2" src="../static/images/student-fill.png" mode=""></image>
			<image v-else src="../static/images/student.png" mode=""></image>
			<view class="name">
				学生
			</view>
		</view>
		<view  :class="['item',current == 3?'active':'']" @click="currentTab(3)">
			<image v-if="current==3" src="../static/images/active-fill.png" mode=""></image>
			<image v-else src="../static/images/active.png" mode=""></image>
			<view class="name">
				活动
			</view>
		</view>
		<view :class="['item',current == 4?'active':'']" @click="currentTab(4)">
			<image v-if="current==4" src="../static/images/mine-fill.png" mode=""></image>
			<image v-else src="../static/images/mine.png" mode=""></image>
			<view class="name">
				我的
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		name: "tabbar",
		props: {
			current: {
				type: Number,
				default: 5
			}
		},

		data() {
			return {
				// current: ''
				roles: [],
				is_monitor: false,
				is_polling: false,
				is_admin: false,

			};
		},
		watch: {
			current() {
				console.log('opopopopop')
			},
		},
		onShow() {

		},
		created() {
			let status = false
			let roles = this.$store.state.vuex_user.roles
			let arr = []
			roles.map(item => {
				arr.push(item.name)
			})
			let index = arr.indexOf('polling')
			if (index >= 0) this.is_polling = true
			let index2 = arr.indexOf('monitor')
			if (index2 >= 0) this.is_monitor = true
			let index3 = arr.indexOf('admin')
			if (index3 >= 0) this.is_admin = true
			console.log(index, index2, index3, 'opopop')
		},
		methods: {

			currentTab(index) {
				console.log(index, 'opopopo')
				// this.current = index
				if (index == 0) {
					uni.reLaunch({
						url: '/pages/index/index'
					})
				} else if (index == 1) {
					console.log(index, 'opopop')
					uni.reLaunch({
						url: '/pages/scheduling/index'
					})
				} else if (index == 2) {
					uni.reLaunch({
						url: '/pages/student/index_new'
					})
				}
				else if (index == 3) {
					uni.reLaunch({
						url: '/pages/activity/index'
					})
				}
				else if (index == 4) {
					uni.reLaunch({
						url: '/pages/mine/index'
					})
				}
				
			},
		}
	}
</script>

<style lang="scss">
	.tabbar {
		height: 60px;
		padding: 5px 0;
		width: 100%;
		background-color: #fff;
		display: flex;
		align-items: center;
		justify-content: space-around;
		position: fixed;
		left: 0;
		bottom: 0;
		z-index: 2;

		button::after {
			border: none;
		}

		.item {
			text-align: center;

			image {
				width: 25px;
				height: 25px;
			}

			.name {
				// margin-top: -5px;
				// line-height: 25px;
				font-size: 12px;
				color: #909399;
				font-weight: 400;
			}
		}

		.active {
			image {
				width: 25px;
				height: 25px;
			}

			.name {
				font-size: 12px;
				color: #303133 !important;
				font-weight: 400;
			}
		}
	}
</style>
