<template>
	<view class="static-footer-bar" :style="{ 'padding-bottom': safeAreaInsets.bottom + 'px' }">
		<view class="static-footer-li ellipsis" @click="tabChange(1)">
			<image src="../static/footBar-image/c1.png" class="static-footer-li-icon" v-if="type != 'home'"></image>
			<image src="../static/footBar-image/logo.png" class="static-footer-li-icon" v-if="type == 'home'"></image>
			<view :class="type == 'home' ? 'static-footer-li-title1' : 'static-footer-li-title'">
				{{ $t('components.footerBar.homepage') }}</view>
		</view>
		<view class="static-footer-li ellipsis" @click="tabChange(2)">
			<image src="../static/footBar-image/c2.png" class="static-footer-li-icon" v-if="type != 'marketSituation'">
			</image>
			<image src="../static/footBar-image/logo.png" class="static-footer-li-icon"
				v-if="type == 'marketSituation'"></image>
			<view :class="type == 'marketSituation' ? 'static-footer-li-title1' : 'static-footer-li-title'">
				{{ $t('components.footerBar.marketSituation') }}</view>
		</view>
		<view class="static-footer-li ellipsis" @click="tabChange(3)">
			<image src="../static/footBar-image/logo.png" class="static-footer-li-icon" v-if="type != 'deepMate'"></image>
			<image src="../static/footBar-image/logo.png" class="static-footer-li-icon" v-if="type == 'deepMate'">
			</image>
			<view :class="type == 'deepMate' ? 'static-footer-li-title1' : 'static-footer-li-title'">
				{{ $t('components.footerBar.deepMate') }}</view>
		</view>
		<view class="static-footer-li ellipsis" @click="tabChange(4)">
			<image src="../static/footBar-image/c4.png" class="static-footer-li-icon" v-if="type != 'deepExploration'">
			</image>
			<image src="../static/footBar-image/logo.png" class="static-footer-li-icon"
				v-if="type == 'deepExploration'"></image>
			<view :class="type == 'deepExploration' ? 'static-footer-li-title1' : 'static-footer-li-title'">
				{{ $t('components.footerBar.deepExploration') }}</view>
		</view>
		<view class="static-footer-li ellipsis" @click="tabChange(5)">
			<image src="../static/footBar-image/c5.png" class="static-footer-li-icon" v-if="type != 'member'"></image>
			<image src="../static/footBar-image/logo.png" class="static-footer-li-icon" v-if="type == 'member'"></image>
			<view :class="type == 'member' ? 'static-footer-li-title1' : 'static-footer-li-title'">
				{{ $t('components.footerBar.member') }}</view>
		</view>
	</view>
</template>

<script setup>
import { computed, onMounted } from 'vue'

// 定义 props
const props = defineProps({
	type: {
		type: String,
		default: ''
	}
})

// 计算属性：获取安全区域
const safeAreaInsets = computed(() => {
	// 获取系统信息中的安全区域
	const systemInfo = uni.getSystemInfoSync()
	return {
		bottom: systemInfo.safeAreaInsets?.bottom || 0
	}
})

// 方法：标签切换
const tabChange = (value) => {
	// console.log(value)
	if (value == 1) { //首页
		uni.redirectTo({
			url: '/pages/home/home',
			animationType: 'fade-in'
		})
	} else if (value == 2) { //行情
		uni.redirectTo({
			url: '/pages/home/marketSituation',
			animationType: 'fade-in'
		})
	} else if (value == 3) { //DeepMate
		uni.redirectTo({
			url: '/pages/home/deepMate',
			animationType: 'fade-in'
		})
	} else if (value == 4) { //深度探索
		if (props.type == 'deepExploration') return;
		uni.redirectTo({
			url: '/pages/home/deepExploration',
			animationType: 'fade-in'
		})
	} else if (value == 5) { //我的
		if (props.type == 'member') return;
		uni.redirectTo({
			url: '/pages/home/member',
			animationType: 'fade-in'
		})
	}
}

// 生命周期
onMounted(() => {
	// 组件挂载后的逻辑
})
</script>

<style scoped>
.static-footer-bar {
	width: 100%;
	height: 100rpx;
	border-top: 1px solid #E2E2E2;
	background: #fff;
}

.static-footer-li {
	display: inline-block;
	width: 20%;
	height: 100%;
	text-align: center;
	position: relative;
}

.static-footer-li-icon {
	width: 46rpx;
	height: 46rpx;
	margin: 12rpx 0;
}

.static-footer-li-title {
	width: 100%;
	height: 40rpx;
	line-height: 40rpx;
	font-size: 24rpx;
	text-align: center;
	margin-top: -20rpx;
	color: gray;
}

.static-footer-li-title1 {
	width: 100%;
	height: 40rpx;
	line-height: 40rpx;
	font-size: 24rpx;
	text-align: center;
	margin-top: -20rpx;
	color: black;
}

.unreadNum {
	position: absolute;
	right: 15%;
	background-color: #f00;
	color: #fff;
	font-size: 24rpx;
	padding: 0 6rpx;
	height: 36rpx;
	line-height: 36rpx;
	min-width: 36rpx;
	border-radius: 18rpx;
	z-index: 9;
}

.taskNew {
	position: absolute;
	right: 15%;
	height: 30rpx;
	z-index: 9;
}

.homeWorkUnRead {
	position: absolute;
	right: 30%;
	top: 10%;
	background-color: #f00;
	color: #fff;
	height: 12rpx;
	width: 12rpx;
	border-radius: 6rpx;
	z-index: 9;
}
</style>
