<template>
  <u-tabbar
    v-model="current"
    :before-switch="beforeSwitch"
    :list="list"
    @change="change"
  ></u-tabbar>
</template>
<script>
import config from "@/common/config";
export default {
  name: "myTabbar",
  options: { styleIsolation: "shared" },
  data() {
    return {
      list: [
        {
          pagePath: "/pages/index/index",
          iconPath: config.BASE_IMG_URL + "web/icon/nav1.png",
          selectedIconPath: config.BASE_IMG_URL + "web/icon/nav1_on.png",
          text: "首页",
        },
        {
          pagePath: "/pages/course/index",
          iconPath: config.BASE_IMG_URL + "/web/icon/nav2.png",
          selectedIconPath: config.BASE_IMG_URL + "/web/icon/nav2_on.png",
          text: "选课",
        },
        {
          pagePath: "/pages/learn/index",
          iconPath: config.BASE_IMG_URL + "/web/icon/nav6.png",
          selectedIconPath: config.BASE_IMG_URL + "/web/icon/nav6_on.png",
          text: "学习",
        },
        {
          pagePath: "/pages/questionBank/index",
          iconPath: config.BASE_IMG_URL + "/web/icon/nav3.png",
          selectedIconPath: config.BASE_IMG_URL + "/web/icon/nav3_on.png",
          text: "题库",
        },
        {
          pagePath: "/pages/information/index",
          iconPath: config.BASE_IMG_URL + "/web/icon/nav4.png",
          selectedIconPath: config.BASE_IMG_URL + "/web/icon/nav4_on.png",
          text: "资料",
        },
        {
          pagePath: "/pages/wd/index",
          iconPath: config.BASE_IMG_URL + "/web/icon/nav5.png",
          selectedIconPath: config.BASE_IMG_URL + "/web/icon/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",
      });
    },
  },
};
</script>

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