<template>
	<view class="bottom_tabbar">
		<view v-for="(item,index) in list" :key="index" @tap="changeTabbar(index)">
			<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: 'https://transcend.ringzle.com/xiaozhi-app/profile/2025/05/29/ac6b7c6f-295a-4961-a4b1-896d30f6afc3.png',
						activeImg: 'https://transcend.ringzle.com/xiaozhi-app/profile/2025/05/29/f87f6089-ccf6-49b3-b5f3-ccea6f775b8a.png',
						text: '首页',
						path: '/pages/home'
					},
					{
						inactiveImg: 'https://transcend.ringzle.com/xiaozhi-app/profile/2025/05/29/19d93986-7ba1-4ebf-90f2-c4e1f4851442.png',
						activeImg: 'https://transcend.ringzle.com/xiaozhi-app/profile/2025/05/29/b59813f0-3452-489c-906d-c45173b637d2.png',
						text: '角色',
						path: '/pages/role'
					},
					{
						inactiveImg: 'https://transcend.ringzle.com/xiaozhi-app/profile/2025/05/29/edb91711-f934-4e3d-90d2-3b5c79a93758.png',
						activeImg: 'https://transcend.ringzle.com/xiaozhi-app/profile/2025/05/29/07dcdc93-5fc7-4ef9-8576-feaf178ed447.png',
						text: '我的',
						path: '/pages/my'
					}
				],
				loginSuccessUrl:''
			}
		},
		mounted() {
			this.tabbarValue = this.tabbarIndex;
		},
		methods: {
			changeTabbar(e) {
				this.tabbarValue = e;
				uni.reLaunch({
					url: this.list[e].path
				})
			}
		}
	}
</script>

<style scoped lang="less">
	.bottom_tabbar {
		width: 100%;
		height: 172rpx;
		background: #FFFFFF;
		display: flex;
		position: fixed;
		left: 0;
		bottom: 0;
		z-index: 999;
		padding-top: 18rpx;
		box-sizing: border-box;
		box-shadow: 0rpx -2rpx 8rpx 0rpx rgba(0,0,0,0.06);

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

			image {
				width: 48rpx;
				height: 48rpx;
			}

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