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

<script>
export default {
  name: "sideNavBar",
  props: {
    title: {
      type: String,
      default: () => "我的服务",
    },
    titleIcon: {
      type: String,
      default: () => require("@/assets/imgs/tool_fuwu.png"),
    },
    titlePath: {
      type: String,
      default: () => "",
    },
    navList: {
      type: Array,
      default: () => [],
    },
    imgSrc: {
      type: String,
      default: "tool_fuwu",
    },
  },
  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_first_title {
  color: #c3caf8;
  font-size: 14px;
  padding: 10px 0 10px 34px;
  position: relative;
}
.side_nav_bar_first_title::before {
  content: "";
  position: absolute;
  left: 22px;
  top: 12px;
  width: 4px;
  height: 16px;
  background-color: #515fe7;
  border-radius: 2px;
}
.side_nav_bar_list > li {
  padding: 12px 10px 12px 42px;
  border-left: 5px solid #0d1847;
  font-size: 14px;
  line-height: 24px;
  color: #6573ae;
  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>
