<template>
	<view>
		<view>asdfasdf asdf</view>
		<u-tabbar :list="vuex_tabBarList" :before-switch="beforeSwitch" :mid-button="false"></u-tabbar>
	</view>
</template>

<script>
	import {
	    mapState,
	    mapMutations,
	} from 'vuex'
	export default {
		data() {
			return {
				
			}
		},
		computed: {
			...mapState(['hasLogin','vuex_vinScanNums','vuex_scanMaxNums','vuex_tabBarList']),
			userInfo(){
				return this.$store.state.vuex_userInfo
			},
		},
		methods: {
			// 扫描vin
			beforeSwitch(index){
				console.log(index)
				if(index==1){
					this.openCamera()
				}else{
					return true
				}
			},
			// 去扫描
			openCamera(){
				if(this.hasLogin){
					if(this.userInfo.sysUserFlag == '0'){
						if(this.vuex_vinScanNums < this.vuex_scanMaxNums){
							uni.navigateTo({
								url: "/pages/scan-frame/scan-frame"
							})
						}else{
							uni.showModal({
								title: '提示',
								content: '个人用户扫描VIN仅限10次，您的次数已用完！',
								confirmText: '好的',
								showCancel: false,
								success(res) {}
							})
						}
					}else{
						uni.navigateTo({
							url: "/pages/scan-frame/scan-frame"
						})
					}
				}else{
					uni.navigateTo({
						url: '/pages/login/login'
					})
				}
			},
		}
	}
</script>

<style>

</style>
