<template>
  <el-container class="home">
    <el-header>
      <div>
        <img src="../assets/image/logo.png" alt />
        <span>测试平台</span>
      </div>
      <el-tag type="info" effect="dark">当前环境：{{ env }}</el-tag>
      <el-button type="info" @click="logout">退出</el-button>
    </el-header>
    <el-container>
      <el-aside width="200px">
        <el-menu
          :default-active="activePath"
          background-color="#525e70"
          text-color="#fff"
          active-text-color="#ffd04b"
          router
        >
          <!-- <el-submenu :index="1">
            <template slot="title">
              <i class="el-icon-s-check"></i>
              <span>自动化测试</span>
            </template>
            <el-menu-item index="/project" @click="saveNavState('/project')">
              <template slot="title">
                <span>项目管理</span>
              </template>
            </el-menu-item>
            <el-menu-item index="/case" @click="saveNavState('/case')">
              <template slot="title">
                <span>接口管理</span>
              </template>
            </el-menu-item>
            <el-menu-item index="/report" @click="saveNavState('/report')">
              <template slot="title">
                <span>测试报告</span>
              </template>
            </el-menu-item>
          </el-submenu>-->
          <el-submenu :index="2">
            <template slot="title">
              <i class="el-icon-money"></i>
              <span>现金分期</span>
            </template>
            <el-menu-item index="/xyqb/getLoanData" @click="saveNavState('/xyqb/getLoanData')">
              <template slot="title">
                <i class="el-icon-watermelon"></i>
                <span>捞数据</span>
              </template>
            </el-menu-item>
            <el-menu-item index="/xyqb/genLoanData" @click="saveNavState('/xyqb/genLoanData')">
              <template slot="title">
                <i class="el-icon-cherry"></i>
                <span>造数据</span>
              </template>
            </el-menu-item>
          </el-submenu>
          <el-submenu :index="3">
            <template slot="title">
              <i class="el-icon-s-shop"></i>
              <span>消费分期</span>
            </template>
            <el-menu-item index="/vcc/getData" @click="saveNavState('/vcc/getData')">
              <template slot="title">
                <i class="el-icon-grape"></i>
                <span>捞数据</span>
              </template>
            </el-menu-item>
            <el-menu-item index="/vcc/genData" @click="saveNavState('/vcc/genData')">
              <template slot="title">
                <i class="el-icon-apple"></i>
                <span>造数据</span>
              </template>
            </el-menu-item>
          </el-submenu>
        </el-menu>
      </el-aside>
      <el-main>
        <router-view></router-view>
      </el-main>
    </el-container>
  </el-container>
</template>

<script>
export default {
  data() {
    return {
      activePath: '',
      selectNamespace: '',
      env: window.sessionStorage.getItem('env')
    }
  },
  methods: {
    logout() {
      window.sessionStorage.clear()
      this.$router.push('/')
    },
    saveNavState(curPath) {
      this.activePath = curPath
      window.sessionStorage.setItem('activePath', curPath)
    }
  },
  created() {
    if (window.sessionStorage.getItem('env') === null) {
      this.$router.push('/')
    }
    this.activePath = window.sessionStorage.getItem('activePath')
  }
}
</script>

<style lang="less" scoped>
.home {
  height: 100%;
}
.el-header {
  background-color: #2a2961;
  display: flex;
  justify-content: space-between;
  color: #333;
  text-align: center;
  align-items: center;
  line-height: 60px;
  > div {
    display: flex;
    span {
      font-size: 22px;
      color: #ffffff;
      margin-left: 20px;
    }
    > img {
      height: 40px;
      width: 70px;
      margin-top: 12px;
    }
  }
}

.el-aside {
  background-color: #525e70;
  height: 100%;
  .el-menu {
    border-right: none;
  }
}

.el-main {
  background-color: #e9eef3;
}
</style>
