<template >
	<view>
		<u-tabbar v-model="myCurrent" :list="tabbarList" 
		:before-switch="beforeSwitch"
		 active-color="#1677ff"></u-tabbar>
		
	</view>
</template>

<script>
 	import * as API from '@/apis/role.js'
 	
 	export default {
		name:"tabbarJob",
		props:{
			current: 0,
			
		},
		data() {
			return {
				tabbarList:API.getList(this.carhelp.getPersonInfo()),
				activeColor:"#5098FF",
				oldindex:0,
				 myCurrent:0,
				
				
			};
			
		},computed:{
				currentNum(){
					
					for(var i in this.tabbarList){
						var item=this.tabbarList[i]
						if(item.current==this.current){
							return i;
						}
					}
					return -1;
				},
		},
		methods:{
			relist(){
				this.tabbarList=API.getList(this.carhelp.getPersonInfo());
				this.myCurrent=this.currentNum;
			},
			setcount(){
				// console.log("currentNum")
				// console.log(this.currentNum)
				this.myCurrent=this.currentNum;
			},
			beforeSwitch(index){
				
				
				if(index==this.currentNum){
					return false
				}
				var url =this.tabbarList[index].pagePath2;
				
				uni.navigateTo({
					url: url
				})
				if(index==1){
					this.myCurrent=this.oldindex;
					return false;
				}else{
					return true;
				}
				
			},
			
		},create(){
			
		}
		,mounted(){
			console.log("mounted")
			this.myCurrent=this.currentNum;
		},destroyed(){
		}
		
	}
</script>

<style>
	 
</style>
