<template>
  <div id="app">
    <!-- <img src="./assets/logo.png"> -->
    <header>
      <span class="pageTitle">{{ $route.meta.pageTitle }}</span>
      <div class="right">
        <span class="userInfo">username</span>
        <span class="logout">退出</span>
      </div>
    </header>
    <nav>
      <div class="sysTitle">
        数据管理系统
      </div>
      <div class="list">
        <div class="list-title" :class="{ 'active': toggle.listTitle === 0 }" @click="toggle.listTitle = 0">
          <a href="javascirpt:void(0)">检测模块</a>
          <img src="static/img/xiala.png" alt="">
        </div>
        <div class="list-item">
          <router-link  :class="{ 'active': $route.path === '/checkInfo' }" :to="{ path: '/checkInfo' }">检测信息</router-link>
          <router-link  :class="{ 'active': $route.path === '/checkTemplate' }" :to="{ path: '/checkTemplate' }">检测模板</router-link>
          <router-link  :class="{ 'active': $route.path === '/processingRecord' }" :to="{ path: '/processingRecord' }">处理记录</router-link>
        </div>
        <div class="list-title" :class="{ 'active': toggle.listTitle === 1 }" @click="toggle.listTitle = 1">
          <a href="javascirpt:void(0)">数据模块</a>
          <img src="static/img/xiala.png" alt="">
        </div>
        <div class="list-item">
          <router-link :class="{ 'active': $route.path === '/channelData' }" :to="{ path: '/channelData' }">渠道数据</router-link>
          <router-link :class="{ 'active': $route.path === '/detailedData' }" :to="{ path: '/detailedData' }">详细数据</router-link>
        </div>
        <div class="list-title" :class="{ 'active': toggle.listTitle === 2 }" @click="toggle.listTitle = 2">
          <a href="javascirpt:void(0)">用户管理</a>
          <img src="static/img/xiala.png" alt="">
        </div>
        <div class="list-item">
          <router-link :class="{ 'active': $route.path === '/userManage' }" :to="{ path: '/userManage' }">用户管理</router-link>
        </div>
      </div>
    </nav>
    <section>
      <router-view/>
      <!-- <footer>&copy;2012-2017 zhiweidata.com, All Rights Reserved.京ICP备13015804号-1备案京公网安备11010502034130号</footer> -->
    </section>
  </div>
</template>

<script>
export default {
  name: 'app',
  data () {
    return {
      toggle: {
        listTitle: 0
      }
    }
  },
  mounted () {
    // 页面刷新后，左侧导航依然正确显示当前页
    if (this.$route.path.search(/^(\/checkInfo|\/checkTemplate|\/processingRecord)$/g) !== -1) {
      this.toggle.listTitle = 0
    } else if (this.$route.path.search(/^(\/channelData|\/detailedData)$/g) !== -1) {
      this.toggle.listTitle = 1
    } else {
      this.toggle.listTitle = 2
    }
  }
}
</script>

<style lang="scss">
body{
  height: 100%;
}
#app {
  /*font-family: 'Avenir', Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-align: center;
  color: #2c3e50;
  margin-top: 60px;*/
  position: absolute;
  width: 100%;
  min-width: 1366px;
  min-height: 100%;
  background-color: #394048;
  line-height: 1.5;
  &>header{
    position: absolute;
    right: 0;
    top: 0;
    width: calc(100% - 230px);
    height: 50px;
    background-color: #F8FCFF;
    padding: 0 50px;
    .pageTitle{
      font-size: 20px;
      line-height: 50px;
    }
    .right{
      float: right;
      height: 50px;
      span{
        display: inline-block;
        position: relative;
        line-height: 50px;
        padding: 0 10px 0 35px;
        background-repeat: no-repeat;
        background-position: 5px center;
        &:nth-of-type(1){ background-image: url('/static/img/user.png'); }
        &:nth-of-type(2){ background-image: url('/static/img/exit.png'); }
      }
      .logout{
        transition: all 0.2s ease;
        &:hover{
          background-color: #E5E5E5;
          cursor: pointer;
        }
        &:before{
          display: inline-block;
          content: "";
          position: absolute;
          width: 1px;
          height: 65%;
          background-color: #000;
          left: 0;
          top: 50%;
          transform: translateY(-50%);
        }
      }
    }
  }
  &>nav{
    position: absolute;
    left: 0;
    top: 0;
    width: 230px;
    height: 100%;
    background-color: #282D33;
    color: #9ea9b9;
    .sysTitle{
      height: 50px;
      line-height: 180px;
      overflow: hidden;
      background-image: url('/static/img/nav-title.png');
      background-repeat: no-repeat;
      background-position: center;
      margin-bottom: 20px;
    }
    .list-title a, .list-item a{
      display: block;
      text-align: center;
      line-height: 50px;
      text-indent: -15px;
      transition: all 0.2s ease;
      &:hover, &.active{
        color: #fff;
      }
    }
    .list-title{
      position: relative;
      background-repeat: no-repeat;
      background-position: 20px center;
      &:nth-of-type(1){ background-image: url('/static/img/list-1.png'); }
      &:nth-of-type(3){ background-image: url('/static/img/list-2.png'); }
      &:nth-of-type(5){ background-image: url('/static/img/list-3.png'); }
      img{
        position: absolute;
        right: 20px;
        top: 50%;
        transform: translateY(-50%) rotate(90deg);
        transition: all 0.2s ease;
      }
      &.active{
        img{
          transform: translateY(-50%) rotate(0deg);
        }
        &+.list-item a{
          margin-top: 0px;
        }
      }
    }
    .list-item{
      overflow: hidden;
      a{
        margin-top: -50px;
        &:hover, &.active{
          background-color: #14181B;
        }
      }
    }
  }
  &>section{
    position: absolute;
    right: 0;
    top: 50px;
    width: calc(100% - 230px);
    height: calc(100% - 50px);
    overflow-y: auto;
    /*定义滚动条高宽及背景 高宽分别对应横竖滚动条的尺寸*/
    &::-webkit-scrollbar{
      width: 8px;
      height: 8px;
      background-color: #F5F5F5;
    }
    /*定义滚动条轨道 内阴影+圆角*/
    &::-webkit-scrollbar-track{
      // border-radius: 10px;
      background-color: #394048;
      border-left: 1px solid #121315;
    }
    /*定义滑块 内阴影+圆角*/
    &::-webkit-scrollbar-thumb{
      border-radius: 2px;
      background-color: rgba(73,175,247,0.3);
      &:hover{
        background-color: rgba(73,175,247,0.7);
      }
    }
    &>div{
      position: relative;
      padding-bottom: 150px;
      min-height: 100%;
      &:after{
        display: block;
        content: "©2012-2017 zhiweidata.com, All Rights Reserved.京ICP备13015804号-1备案京公网安备11010502034130号";
        position: absolute;
        width: 100%;
        height: 30px;
        line-height: 30px;
        text-align: center;
        left: 0;
        bottom: 0;
        color: #7F868E;
        font-size: 12px;
      }
    }
  }
}
</style>

<!-- 项目公共样式 -->

<style lang="scss">
  .searchInput{
    width: 412px;
    height: 36px;
    border-radius: 3px;
    border: 1px solid #4E5560;
    background-color: #262D33;
    background-image: url('/static/img/search.png');
    background-repeat: no-repeat;
    background-position: 10px center;
    padding: 3px 6px 3px 50px;
    color: #d4d4d4;
    &:focus{
      border-color: #49B0F7;
    }
  }
  .btn1{
    &:not([disabled]){
      width: 122px;
      height: 33px;
      border: 1px solid #4E5560;
      background-color: #262D33;
      color: #848D94;
      border-radius: 2px;
    }
  }
</style>
