<template>
  <view class="tabbar">
    <view
      v-for="(item, idx) in tabbarList"
      :key="idx"
      class="tabbar-item"
      @click="switchTab(item.pagePath)"
    >
      <image
        :src="current === idx ? item.selectedIconPath : item.iconPath"
        class="tabbar-icon"
      />
      <text :class="{ active: current === idx }">{{ item.text }}</text>
    </view>
  </view>
</template>

<script>
export default {
  props: {
    tabbarList: Array,
    current: Number
  },
  methods: {
    switchTab(path) {
      uni.switchTab({ url: path })
    }
  }
}
</script>

<style scoped>
.tabbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 999;
  display: flex;
  border-top: 1px solid #eee;
  background: #fff;
  height: 100rpx;
  padding-bottom: env(safe-area-inset-bottom);
  box-sizing: content-box;
  font-size: 24rpx;
  line-height: 1.2;
}
.tabbar-item {
  flex: 1;
  text-align: center;
  padding: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
}
.tabbar-icon {
  width: 44rpx;
  height: 44rpx;
  display: block;
  margin: 0 auto 4rpx auto;
  font-size: 0;
}
.tabbar-item text {
  font-size: 24rpx;
  line-height: 1.2;
}
.active {
  color: #1479ff;
}
</style> 