<template>
	<view class="tab-bar">
		<view class="footer">
			<view class="index" @click="swithTab(1)">
				<view>
					<image
						:src="currentPage === 1?'../../static/images/home/tab_home_on.png':'../../static/images/home/tab_home.png'">
					</image>
				</view>
				<view :class="[currentPage === 1?'current':'']">首页</view>
			</view>
			<view class="index" @click="swithTab(2)">
				<view>
					<image
						:src="currentPage === 2?'../../static/images/home/tab_service_on.png':'../../static/images/home/tab_service.png'">
					</image>
				</view>
				<view :class="[currentPage === 2?'current':'']">商标服务</view>
			</view>
			<view class="index" @click="swithTab(3)">
				<view>
					<image
						:src="currentPage === 3?'../../static/images/home/tab_mine_on.png':'../../static/images/home/tab_mine.png'">
					</image>
				</view>
				<view :class="[currentPage === 3?'current':'']">我的</view>
			</view>
		</view>
		<view class="bottom" v-if="plat.startsWith('iPhone')"></view>
	</view>
</template>

<script>
	export default {
		name: "tab-bar",
		data() {
			return {
				currentPage: 0,
				stationCode: null,
				plat: uni.getSystemInfoSync().model
			};
		},
		mounted() {
			this.getRoute()
		},
		methods: {
			swithTab(num) {
				if (num === 1) {
					uni.switchTab({
						url: '/pages/index/index',
					});
				} else if (num === 2) {
					uni.switchTab({
						url: '/pages/service/index',
					});
				} else if (num === 3) {
					if (this.$storage.getJson("token")) {
						uni.switchTab({
							url: '/pages/ucenter/index',
						});
					} else {
						uni.navigateTo({
							url: '/pages/public/login',
						});
					}
					// uni.switchTab({
					// 	url: '/pages/ucenter/index',
					// });
				}
			},
			getRoute() {
				let curPage = getCurrentPages();
				let route = curPage[curPage.length - 1].route
				if (route === 'pages/index/index') {
					this.currentPage = 1
				} else if (route === 'pages/service/index') {
					this.currentPage = 2
				} else if (route === 'pages/ucenter/index') {
					this.currentPage = 3
				}
			}
		}
	}
</script>

<style lang="scss" scoped>
	// ::v-deep .amap-logo {
	//   opacity: 0 !important;
	// }
	// ::v-deep .amap-copyright {
	//   opacity: 0 !important;
	// }
	.tab-bar {
		display: flex;
		flex-direction: column;
		position: fixed;
		left: 0;
		right: 0;
		bottom: 0rpx;

		.bottom {
			background-color: #fff;
			height: 68rpx;
			display: block;
		}

		.footer {
			width: 100%;
			height: 106rpx;
			// background-image: url(~@/static/bbg.png);
			
			// background-size: 100% 100%;
			background: #FFFFFF;
			display: flex;
			justify-content: space-around;
			padding-top: 15rpx;
			font-size: 26rpx;
			box-sizing: border-box;

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

			.index {
				width: 240rpx;
				text-align: center;
			}

			.scan {
				position: relative;
				display: flex;
				flex: 1;
				text-align: center;

				view:first-child {
					position: absolute;
					bottom: 30rpx;
					width: 100%;
				}

				view:last-child {
					position: absolute;
					bottom: 6rpx;
					width: 100%;
				}

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

			.hover {
				color: #58be6b;
			}

			.current {
				color: #959ea8;
			}
		}
	}
</style>