<template>
  <div class="fwgl_container">
    <side-nav-bar
      title="消息与推送管理"
      imgSrc="tool_ic_tuisong"
      :nav-list="navList"
      :title-path="navList[0] && navList[0].path"
    ></side-nav-bar>
    <div class="main_container">
      <router-view :key="'type_' + $route.params.type"></router-view>
    </div>
  </div>
</template>

<script>
import sideNavBar from "@/components/side-nav-bar";

export default {
  components: {
    sideNavBar
  },
  data: () => ({
    userNav: [
      {
        name: "推荐位管理",
        path: `/message/recommended`
      },
      {
        name: "定向推送管理",
        path: `/message/directed_push`
      },
      {
        name: "消息提醒管理",
        path: `/message/message_alert`
      },
      {
        name: "benner管理",
        path: `/message/banner`
      },
      {
        name: "消息模板管理",
        path: `/message/message_template`
      }
    ],
    navList: []
  }),
  watch: {
    "$route.fullPath"(path) {
      this.initNavList();
    }
  },
  methods: {
    initNavList() {
      // this.$api.general.getNowMenu({ teamName: "APAAS3" }).then(response => {
      //   if (response.data.success == 1) {
      //     let arr = response.data.data[0].Child;
      //     let user_index = arr.findIndex(item => item.visit_url == "/message");
      //     if (user_index != -1) {
      //       this.navList = arr[user_index].Child;
      //       this.navList.forEach(item => {
      //         item.name = item.menu_name;
      //         item.path = item.visit_url;
      //       });
      //     }
      //   }
      // });
      this.navList = this.userNav;
    }
  },
  mounted() {
    this.initNavList();
  }
};
</script>

<style scoped>
.fwgl_container {
  height: calc(100vh - 84px);
  display: flex;
  justify-content: flex-start;
  align-items: stretch;
}
.side_nav_bar {
  width: 200px;
  flex-shrink: 0;
}
.main_container {
  width: calc(100% - 200px);
  flex-grow: 1;
  flex-shrink: 1;
  background-color: #f6f7fb;
  overflow: auto;
}
</style>
