<template>
  <div class="side_nav_bar">
    <h3 class="side_nav_bar_title" @click="titleAction">
      <img
        :src="require('../assets/imgs/tool_fuwu.png')"
        width="20"
        style="margin-right: 10px;"
      />
      <span v-text="title"></span>
    </h3>
    <ul class="side_nav_bar_list">
      <!-- active-class="current" -->
      <router-link
        tag="li"
        v-for="(nav, index) in navList"
        :class="{ current: $route.path.indexOf(nav.path) > -1 }"
        :key="'nav' + index"
        :to="nav.path"
      >
        <span v-text="nav.name"></span>
      </router-link>
    </ul>
  </div>
</template>

<script>
export default {
  name: "sideNavBar",
  props: {
    title: {
      type: String,
      default: () => "我的服务",
    },
    titlePath: {
      type: String,
      default: () => "",
    },
    navList: {
      type: Array,
      default: () => [],
    },
  },
  methods: {
    titleAction() {
      if (this.titlePath) {
        this.$router.push(this.titlePath);
      }
    },
  },
};
</script>

<style scoped>
.side_nav_bar {
  background-color: #0d1847;
}
.side_nav_bar_title {
  height: 40px;
  background-color: #182665;
  border-radius: 10px;
  overflow: hidden;
  margin: 20px 15px 20px;
  display: flex;
  justify-content: center;
  align-items: center;
  cursor: pointer;
}
.side_nav_bar_title > span {
  font-size: 16px;
  color: #c3caf8;
}
.side_nav_bar_list > li {
  padding: 12px 10px 12px 42px;
  border-left: 5px solid #0d1847;
  font-size: 14px;
  line-height: 24px;
  color: #e6ebfe;
  cursor: pointer;
}
.side_nav_bar_list > li:hover,
.side_nav_bar_list > li.current {
  border-left: 5px solid #e56600;
  background-color: #182665;
  color: #e6ebfe;
}
</style>
