<template>
	<view>
		<u-tabbar :value="tabbarValues" @change="name => tabbarValues = name" :fixed="true" :placeholder="true" activeColor="#007A69"
			:safeAreaInsetBottom="true" :border="false">
			<u-tabbar-item :text="item.text" v-for="(item,index) in list" :key="index"
				@click="changeTabbars(item,index)">
				<image class="u-page__item__slot-icon" slot="active-icon" :src="item.activeImg"></image>
				<image class="u-page__item__slot-icon" slot="inactive-icon" :src="item.inactiveImg"></image>
			</u-tabbar-item>
		</u-tabbar>
	</view>
</template>

<script>
	export default {
		props: {
			tabbarid: 0
		},
		data() {
			return {
				tabbarValues: 0,
				list: [{
						activeImg: 'https://i.ringzle.com/file/20240320/eb54f2488b4f45c9929d2fa78b104b80.png',
						inactiveImg: 'https://i.ringzle.com/file/20240106/29bd09ef7eb748f1820c335f86f74c61.png',
						text: '首页',
						paths: '/pagesHouse/home/index'
					},
					{
						activeImg: 'https://i.ringzle.com/file/20240320/df1512af95ff4f639e37b2fa905d7808.png',
						inactiveImg: 'https://i.ringzle.com/file/20240320/07590c34e1fc45e2af4786607418039b.png',
						text: '扫码核验',
						paths: '/pagesHouse/Verification/index'
					},
					{
						activeImg: 'https://i.ringzle.com/file/20240320/319f9665e40b40c7b056e1e50c8e1ce5.png',
						inactiveImg: 'https://i.ringzle.com/file/20240320/81146a88ac964a8ab1effff76f44c9d1.png',
						text: '我的',
						paths: '/pagesHouse/Mine/index'
					}
				]
			}
		},
		mounted() {
			this.tabbarValues = this.tabbarid;
		},
		methods: {
			changeTabbars(e, i) {
				console.log(e, i, '000');
				if (i == 1) {
					console.log('111111111111111111', )
					if (uni.getStorageSync('merchantType') == 4) {
					//	Verification/ems
						// uni.navigateTo({
						// 	url: "/pagesHouse/Verification/ems"		
						// });
						uni.scanCode({
							onlyFromCamera: true,
							success: (res) => {
								//
								if(JSON.parse(res.result).merchantId!=uni.getStorageSync('merchantId')){
									uni.showToast({
										title:'您的核销码不是该商家的核销码',
										icon:'none',
										duration:1500
									})
									setTimeout(()=>{
										uni.reLaunch({
											url:'/pagesHouse/home/index'
										})
									},1500)
								}else{
									uni.navigateTo({
										url: "/pagesHouse/Verification/detailsewm?list=" + res.result
									})
								}
													
							},
							error: (res) => {
								uni.reLaunch({
									url:'/pagesHouse/home/index'
								})
							}
						})
						
					} else {
						this.tabbarValues = i;
						uni.reLaunch({
							url: this.list[i].paths
						})
					}

				} else {
					this.tabbarValues = i;
					uni.reLaunch({
						url: this.list[i].paths
					})
				}
				// this.tabbarValues = i;
				// uni.reLaunch({
				// 	url: this.list[i].paths
				// })
			}
		}
	}
</script>

<style lang="less">
	/deep/.u-page__item__slot-icon {
		width: 38rpx;
		height: 38rpx;
		margin: 8rpx 0 4rpx;
	}
	/deep/.u-tabbar-item__text{
		color: #007A69;
	}
	/deep/.u-tabbar-item {
		&:nth-child(2){
			.u-page__item__slot-icon,image {
				width: 72rpx;
				height: 54rpx;
			}
		}
		
	}
</style>