<template>
  <div class="container-box">
    <pre-header></pre-header>
    <div class="container">
      <div class="aside">
        <nav-left :platInfo="platInfo"></nav-left>
      </div>
      <div class="main" ref="mainBox">
        <router-view :platInfo="platInfo"></router-view>
      </div>
    </div>
  </div>
</template>

<script>
  import PreHeader from '../components/preHeader'
  import NavLeft from '../components/navLeft'
  import axios from 'axios';
  import ApiConfig from "../config/api-config";
  export default {
    data() {
      return {
        platInfo: [],
      }
    },
    components: {
      PreHeader,
      NavLeft
    },
    created() {
      this.getPlatInfo();
      this.getRobotBank();
      if (!sessionStorage.getItem("isLogin")) {
        this.$router.push({
          path: '/'
        });
      }
    },
    methods: {
      getPlatInfo() {
        axios.post(ApiConfig.GetPlatformInfo).then( res =>{
          if (res.data.code === 200) {
            this.platInfo = res.data.data;
            sessionStorage.setItem('platInfo', JSON.stringify(this.platInfo))
            // console.log(this.platInfo)
          }
        })
      },
      getRobotBank() {
        axios.post(ApiConfig.GetRobotBank,{class : "bank"}).then( res => {
          if (res.data.code === 200) {
            sessionStorage.setItem('robotBankList',JSON.stringify(res.data.data))
          }
        });
        axios.post(ApiConfig.GetRobotBank,{class : "admin"}).then( res => {
          if (res.data.code === 200) {
            sessionStorage.setItem('robotAdminList',JSON.stringify(res.data.data))
          }
        })
      },
    },
    watch: {
      $route() {
        this.$refs.mainBox.scrollTop = 0;
      }
    }
  }
</script>

<style scoped>
  .container-box{
    height: 100%;
    padding-top: 80px;
  }
  .container{
    height: 100%;
    position: relative;
    .aside{
      width: 200px;
      height: 100%;
      float: left;
      overflow: hidden;
    }
    .main{
      position: absolute;
      top: 0;
      bottom: 0;
      left: 200px;
      right: 0;
      min-width: 1000px;
      overflow: auto;
    }

  }
</style>
