<template>
	<view>
		<u-tabbar v-model="myCurrent" :list="tabbarList" :before-switch="beforeSwitch" mid-button-size="72" :mid-button="true" inactive-color="#ADB8C2" active-color="#5098FF">
		</u-tabbar>

	</view>
</template>

<script>
	var img1=require('@/assets/img/tabbarImg/item1a.svg')
	var img2=require('@/assets/img/tabbarImg/item1b.svg')

	var img7=require('@/assets/img/tabbarImg/item4a.svg')
	var img8=require('@/assets/img/tabbarImg/item4b.svg')
	
	var img0=require('@/assets/img/tabbarImg/item0.png')
	
	import * as WxJsApi from '@/apis/utils/wxJsApi.js'
	
	export default {
		name: "Tabbar",
		props: {
			current: 0,
			elderStatus: false
		},
		data() {
			return {
				oldindex: this.current,
				myCurrent: this.current,
				tabbarList: [{

						iconPath: img2,
						selectedIconPath: img1,
						text: '主页 ',
						pagePath: "/pages/index/index",
					},
					 {
					 	iconPath: img0,
					 	selectedIconPath: img0,
					 	text: '',
						midButton: true,
					 	pagePath2: "",
					 	
					 },
					// {
					// 	iconPath: img6,
					// 	selectedIconPath: img5,
					// 	text: '用户',
					// 	pagePath: "/pages/userTab/index",
						
					// },
					
					{
						iconPath: img8,
						selectedIconPath: img7,

						text: '我的',
						pagePath: "/pages/myTab/index",
					}
				],
			};

		},
		methods: {
			beforeSwitch(index){
				var item=this.tabbarList[index]
				if(item.pagePath){
						return true;
				}else{
					console.log(111)
					return false;
				}
				
			},
			//微信扫二维码
			getScanCode() {
				console.log("getScanCode")
				if (this.userId) {
					WxJsApi.scanQRCode(1).then(res => {
						var url=res;
						//("scanQRCode------" + res)
						if(res&&this.branchParameterBl()&&url.indexOf('youdian.hbjp.com.cn')!=-1){
							
								if(url.indexOf('?code=')!=-1){
									url=url.replace('?code=','?code1233=')
								}
								
								
								if(process.car.NODE_ENV=='test'){
									url='https://youdian.hbjp.com.cn/charging-prod/mobile-charging-car-test/#/'
									+url.split("#/")[1]
								}else{
									url='https://youdian.hbjp.com.cn/charging-prod/mobile-charging-car/#/'
									+url.split("#/")[1]
								}
								console.log(url)
								//window.location.href=url;
								this.youdianurl=url
								this.youdianshow=true
							
						}else if (res) {
							
							API.scanCode(res).then((response) => {
			
							}).catch(error => {
								uni.showToast({
									title: error,
									icon: "none"
								})
							})
						}
					}).catch(error => {
			
					})
				} else {
					uni.navigateTo({
						url: '/pages/login/login'
					})
				}
			},
			

		},
		mounted() {
			console.log(111+"mounted")
			WxJsApi.getWxConfig(['scanQRCode']).then((res) => {
				// //(res)
			}).catch(error => {
				//(res)
			})
			
		},
		destroyed() {

		}


	}
</script>

<style>

</style>
