<template>
  <div class="menu">
    <div class="nav-left">
      <img class="logo" src="../../assets/img/logo-header.png" alt="logo" />
      <div class="text-title" @click="setStatus">在线学习系统</div>
    </div>
    <div class="notify" @click="goNotify()">通知
      <div class="num" v-if="num">{{num}}</div>
    </div>
  </div>
</template>

<script>
import { request } from '@actions'

export default {
  data () {
    return {
      num: 0
    }
  },
  mounted () {
    request({
      component: this,
      actionName: 'msgAction',
      functionName: 'getMyMsg',
      data: {},
      thenCallback: data => {
        this.num = data.length
      },
      catchCallback: () => {},
      finallyCallback: () => {}
    })
  },
  methods: {
    goNotify () {
      this.$router.push({ path: '/app/my-grade/message' })
    },
    setStatus () {
      if (this.status) {
        this.status = false
      } else {
        this.status = true
      }
      this.$root.$emit('updateStatus', this.status)
    }
  }
}
</script>

<style scoped lang="scss">
.menu {
  width: 100%;
  height: 100%;
  color: #ffffff;
  .nav-left {
    float: left;
    position: relative;
    height: 100%;
    img.logo {
      position: absolute;
      left: 0;
      top: 50%;
      height: 37%;
      width: auto;
      transform: translateY(-50%);
    }
    .text-title {
      float: left;
      margin-left: 190px;
      line-height: 60px;
      font-size: 16px;
    }
  }
  .notify {
    position: relative;
    float: right;
    padding: 0 20px;
    line-height: 60px;
    font-size: 16px;
    cursor: pointer;
    .num {
      position: absolute;
      top: 9px;
      left: 50px;
      padding: 1px 5px 2px 4px;
      font-size: 12px;
      line-height: 14px;
      color: #ffffff;
      background: #fb2121;
      border-radius: 50%;
    }
    &:hover {
      color: #b49441;
    }
  }
}

@media (max-width: 767px) {
  .menu {
    .nav-left {
      img.logo {
        display: none;
      }
      .text-title {
        margin-left: 0;
      }
    }
  }
}
</style>
