<template>
	  <view class="menu_wrapper">
	    <view class="menu_content">
	      <view v-for="item in menuLists" :key="item.link" class="tabbar_item" :class="{'active':item.link == currentPage}"
			@click="navTo(item,index)">
	        <view class="pic">
				<img v-if="item.link == currentPage" :src="'../../static/tabbar/' + item.selectedIconPath + '.png'" >
				<img v-else :src="'../../static/tabbar/' + item.iconPath + '.png'">
	        </view>
	        <view class="name">{{item.name}}</view>
	      </view>
	    </view>
	  </view>
</template>

<script>
import tabBarVue from './tabBar.vue';
	export default {
		props: ['currentPage'],
		name:"tabBar",
		data() {
			return {
				menuLists: [
				    {key:1,name:'首页',iconPath:'home',selectedIconPath:'home_active',link:'index'},
				    {key:2,name:'SFP智能财策',iconPath:'sfp',selectedIconPath:'sfp_active',link:'/product'},
				    {key:3,name:'CFFP认证',iconPath:'cffp',selectedIconPath:'cffp_active',link:'cffp'},
				    {key:4,name:'我的',iconPath:'my',selectedIconPath:'my_active',link:'personalCenter'},
				]
			}
		},
		methods: {
			navTo(item,index) {
				let _this = this;
				if (item.link !== _this.currentPage) {
					var isUrl = `/pages/${item.link}/${item.link}`
					const that = this
					uni.navigateTo({
						url: isUrl
					})
				}
			}	
		},
		mounted() {
			console.log(this.currentPage)
		}
	}
</script>

<style lang="scss" scoped>
	.menu_wrapper{
		position: fixed;
		bottom: 0;
		left: 50%;
		width: 100%;
		height: 70rpx;
		border-top: 1px solid #f5f5f5;
		background: #fff;
		color: #333;
		font-size: 12px;
		min-width: 320px;
		max-width: 640px;
		padding-bottom: 20px;
		transform: translateX(-50%);
		.menu_content{
			display: flex;
			align-items: center;
			justify-content: space-around;
			.pic{
				width: 70rpx;
				margin: 0 auto;
				img{
					max-width: 100%;
				}
			}
			.name{
				text-align: center;
			}
		}
	}
	
</style>