<template>
  <el-menu class="navbar" mode="horizontal">
    <hamburger
      class="hamburger-container"
      :toggleClick="toggleSideBar"
      :isActive="sidebar.opened"
    ></hamburger>
    <breadcrumb></breadcrumb>
    <div class="remind"  @click="jump()">
     <i class="el-icon-message-solid"></i>
     <p v-show="newNotice"></p>
    </div>
    <!-- <div class="notice">111</div> -->
    <el-dropdown class="avatar-container" trigger="click">
      <div class="avatar-wrapper">
        <img class="user-avatar" :src="avatar" />
        <i class="el-icon-caret-bottom"></i>
      </div>
      <el-dropdown-menu class="user-dropdown" slot="dropdown">
        <router-link class="inlineBlock" to="/">
          <el-dropdown-item>
            首页
          </el-dropdown-item>
        </router-link>
        <el-dropdown-item divided>
          <span @click="logout" style="display:block;">退出</span>
        </el-dropdown-item>
      </el-dropdown-menu>
    </el-dropdown>
  </el-menu>
</template>

<script>
import { mapGetters } from "vuex";
import Breadcrumb from "@/components/Breadcrumb";
import Hamburger from "@/components/Hamburger";
import {
 fullNotice,
 fullNoticeList
} from "@/api/cso2";
const defaultListQuery = {
  pageNum: 1,
  pageSize: 10
};

export default {
  components: {
    Breadcrumb,
    Hamburger
  },
  computed: {
    ...mapGetters(["sidebar", "avatar"])
  },
  data(){
    return{
      listQuery: Object.assign({}, defaultListQuery),
      list: null,
      pageSize: null,
      pageNum: null,
      newNotice: false,
      roles:""
    }

  },
  mounted() {
    //  this.roles = this.$store.state.user.roles;
    //  console.log(this.roles,'roles');
     this.getData()
   
  },
  methods: {
    getData(){
      fullNotice().then(res => {
      //  console.log(res, "fullNotice");
        if(res.data > 0){
          this.newNotice = true
        }
      });
    },
    jump(){
      // if(roles.includes('超级管理员')){
      //   this.$router.push({ path: "/home"})
      //   console.log('超级管理员');
      // }
      // else if(roles.includes('cso主管')){
      //   this.$router.push({ path: "/homePage/csoMasterHome"})
      //   console.log('cso主管');
      // }
      // else if(roles.includes('教务老师')){
      //   this.$router.push({ path: "/homePage/jiaowuHome"})
      //   console.log('教务老师');
      // }
      // else if(roles.includes('客服部老师')){
      //   this.$router.push({ path: "/kfHome/index"})
      //   console.log('客服部老师');
      // }
      // else if(roles.includes('客服部主管')){
      //   this.$router.push({ path: "/kfmHome/index"})
      //   console.log('客服部主管');
      // }
      // else if(roles.includes('学服部主管')){
      //   this.$router.push({ path: "/xfmHome/index"})
      //   console.log('学服部主管');
      // }
      // else{
      //   this.$router.push({ path: "/xfhome/index"})
      //    console.log('学服部老师');
      // }
     //console.log(roles,'jump');
      this.$router.push({ path: "/home"})
       this.newNotice = false
    },
    toggleSideBar() {
      this.$store.dispatch("ToggleSideBar");
    },
    logout() {
      this.$store.dispatch("LogOut").then(() => {
        location.reload(); // 为了重新实例化vue-router对象 避免bug
      });
    }
  }
};
</script>

<style rel="stylesheet/scss" lang="scss" scoped>
.navbar {
  height: 50px;
  line-height: 50px;
  border-radius: 0px !important;
  .hamburger-container {
    line-height: 58px;
    height: 50px;
    float: left;
    padding: 0 10px;
  }
  .screenfull {
    position: absolute;
    right: 90px;
    top: 16px;
    color: red;
  }
  //全服通知
  .remind {
    position: absolute;
    top: 5px;
    right: 150px;
    width: 40px;
    height: 40px;
    background-color: #999999;
    border-radius: 20px;
    text-align: center;
    line-height: 40px;
    cursor: pointer;
  }
     p{
      position: absolute;
      background-color: red;
      border-radius: 10px;
      width: 10px;
      height: 10px;
      right: 1px;
      top: 9px;
    }
  .avatar-container {
    height: 50px;
    display: inline-block;
    position: absolute;
    right: 35px;
    .avatar-wrapper {
      cursor: pointer;
      margin-top: 5px;
      position: relative;
      .user-avatar {
        width: 40px;
        height: 40px;
        border-radius: 10px;
      }
      .el-icon-caret-bottom {
        position: absolute;
        right: -20px;
        top: 25px;
        font-size: 12px;
      }
    }
  }
}
</style>
