<template>
	<view class="bottom_tabbar">
		<view v-for="(item,index) in list" :key="index" @tap="changeTabbar(index)" :class="{'fb':index===1}">
			<image :src="tabbarIndex===index?item.activeImg:item.inactiveImg"></image>
			<text :class="{'active':tabbarIndex===index}">{{item.text}}</text>
		</view>
	</view>
</template>

<script>
	export default {
		props: {
			tabbarIndex: 0
		},
		data() {
			return {
				tabbarValue: 0,
				list: [
					{
						inactiveImg: this.$imgBase+'tab_home1.png',
						activeImg: this.$imgBase+'tab_home2.png',
						text: '首页',
						path: '/pages/home'
					},
					{
						inactiveImg: this.$imgBase+'tab_publish.png',
						activeImg: this.$imgBase+'tab_publish.png',
						text: '发布问卷',
						path: '/pages/publish'
					},
					{
						inactiveImg: this.$imgBase+'tab_user1.png',
						activeImg: this.$imgBase+'tab_user2.png',
						text: '我的',
						path: '/pages/my'
					}
				],
				loginSuccessUrl:''
			}
		},
		mounted() {
			this.tabbarValue = this.tabbarIndex;
		},
		methods: {
			changeTabbar(e) {
				this.tabbarValue = e;
				if(e===1&&!this.isLogin()) return
				uni.reLaunch({
					url: this.list[e].path
				})
			}
		}
	}
</script>

<style scoped lang="scss">
	.bottom_tabbar {
		width: 100%;
		height: 174rpx;
		background-image: url('https://gitee.com/hw_0302/chuang-heng-wechat-images/raw/master/tab_bg.png');
		background-position: left bottom;
		background-repeat: no-repeat;
		background-size: 100% 100%;
		display: flex;
		position: fixed;
		left: 0;
		bottom: 0;
		z-index: 999;

		&>view {
			width: calc(100% / 3);
			height: 100%;
			display: flex;
			flex-direction: column;
			align-items: center;

			image {
				width: 42rpx;
				height: 46rpx;
				margin-top: 37rpx;
			}
			&.fb{
				image{
					width: 72rpx;
					height: 72rpx;
					margin-top: 12rpx;
				}
			}

			text {
				margin-top: 14rpx;
				font-family: PingFang-SC, PingFang-SC;
				font-weight: bold;
				font-size: 22rpx;
				color: #7C909F;
				line-height: 22rpx;
				text-align: center;
				&.active{
					font-weight: bold;
					color: #002846;
				}
			}
		}
	}
</style>