<template>
	<u-tabbar
		:value="currIndex"
		:fixed="true"
		:placeholder="false"
		:safeAreaInsetBottom="false"
	>
		<u-tabbar-item text="首页" icon="home" @click="changeTab(HOME_INDEX)"></u-tabbar-item>
		<u-tabbar-item text="车辆管理" icon="car" @click="changeTab(CAR_INDEX)"></u-tabbar-item>
		<u-tabbar-item text="车辆监测" icon="eye" @click="changeTab(MONITOR_INDEX)"></u-tabbar-item>
		<u-tabbar-item text="实时联动" icon="share" @click="changeTab(LIVE_INDEX)"></u-tabbar-item>
		<!-- <u-tabbar-item text="我的" icon="account" @click="changeTab(4)"></u-tabbar-item> -->
	</u-tabbar>
</template>

<script>
	import { HOME_INDEX, CAR_INDEX, MONITOR_INDEX, LIVE_INDEX } from '../../config/constants'
	import { isDriver, isAdmin } from '@/utils/common.js'
	export default {
		data() {
			return {
				HOME_INDEX, CAR_INDEX, MONITOR_INDEX, LIVE_INDEX,
				curr: 0
			}
		},
		computed: {
			currIndex() {
				return getApp().globalData.tabIndex
			},
			isDriver,
			isAdmin
		},
		mounted() {
			
		},
		methods: {
			changeTab(index) {
				getApp().globalData.tabIndex = index
			
				if(index === HOME_INDEX) {
					uni.redirectTo({
						url: '/pages/home/home'
					})
				}else if(index === CAR_INDEX) {
					uni.redirectTo({
						url: '/pages/carManager/carManager'
					})
				}else if(index == MONITOR_INDEX) {
					uni.redirectTo({
						url: '/pages/monitor/monitor'
					})
				} else if(index === LIVE_INDEX) {
					
				} else if(index === 4) {
					
				}
			}
		}
	}
</script>

<style>
</style>