<template>
	<view>
		<u-tabbar :value="selectedIndex"   @change="name=>change(name)" :fixed="true" :placeholder="true" :safeAreaInsetBottom="true">
			<u-tabbar-item name='home'  v-if="!isAuditUser" :text="this.$t('tabbar.home')" icon="home"></u-tabbar-item>
			<u-tabbar-item name='approval' v-if="isAuditUser" :text="$t('tabbar.approval')"  icon="edit-pen" ></u-tabbar-item>
			<u-tabbar-item name='report'  :text="this.$t('tabbar.report')" icon="file-text"></u-tabbar-item>
			<u-tabbar-item name='info' :text="this.$t('tabbar.my')" icon="account"></u-tabbar-item>
			
		</u-tabbar>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				selectedIndex: getApp().globalData.tabIndex,
				isAuditUser:uni.getStorageSync('isAuditUser'),
				isDealerUser:uni.getStorageSync('isDealerUser'),
			}
		},

		computed: {
		},
		onReady() {
		  console.log("golbalData.tabIndex",getApp().globalData.tabIndex);
		},
		methods: {
			change(e) {
				console.log(e,'----------------');
				getApp().globalData.tabIndex=e;
				var address= "";
				if(e=='home'){
					address= "/pages/home/home";
				}
				else if(e=='report'){
					address= "/pages/report/report";
				}
				else if(e=='info'){
					address= "/pages/info/info";
				}
				else if(e=='approval'){
					address= "/pages/approval/approvallist";
				}
				if(!address){
					uni.showToast({
						title: '不支持该功能，请核实',
						icon: 'none',
						duration: 3000,
					})
					return;
				}
				console.log("当前索引，", e)
				console.log(address);
				uni.switchTab({
					url: address
				})


			}
		}
	}
</script>

<style>

</style>
