<template>
  <u-tabbar
    v-model="current"
    :before-switch="beforeSwitch"
    :list="list"
    @change="change"
  ></u-tabbar>
  <!-- <tabbar
    v-model="current"
    :before-switch="beforeSwitch"
    :list="list"
    @change="change"
  ></tabbar> -->
</template>

<script>
import tabbar from "./tabbar.vue";
export default {
  name: "myTabbar",
  options: { styleIsolation: "shared" },
  data() {
    return {
      list: [
        {
          pagePath: "/pages/index/index",
          iconPath: "/../../static/nav1.png",
          selectedIconPath: "/../../static/nav1_on.png",
          text: "首页",
        },
        {
          pagePath: "/pages/course/index",
          iconPath: "/../../static/nav2.png",
          selectedIconPath: "/../../static/nav2_on.png",
          text: "选课",
        },
        {
          pagePath: "/pages/learn/index",
          iconPath: "/../../static/nav6.png",
          selectedIconPath: "/../../static/nav6_on.png",
          text: "学习",
        },
        {
          pagePath: "/pages/questionBank/index",
          iconPath: "/../../static/nav3.png",
          selectedIconPath: "/../../static/nav3_on.png",
          text: "题库",
        },
        {
          pagePath: "/pages/information/index",
          iconPath: "/../../static/nav4.png",
          selectedIconPath: "/../../static/nav4_on.png",
          text: "资料",
        },
        {
          pagePath: "/pages/wd/index",
          iconPath: "/../../static/nav5.png",
          selectedIconPath: "/../../static/nav5_on.png",
          text: "我的",
        },
      ],
      current: 0,
    };
  },

  mounted() {},

  methods: {
    beforeSwitch(index) {
      return true; // 或者根据逻辑返回false
    },
    change(index) {
      this.current = index;
      if (index === 4) {
        this.toInformation();
      }
    },
    toInformation() {
      uni.reLaunch({
        url: "/pages/information/index",
      });
    },
  },
  components: {
    tabbar,
  },
};
</script>

<style lang="scss">
.u-tabbar {
  ::v-deep &__content {
    z-index: 10000 !important;
  }
}
</style>
