<template>
  <div class="menu">
    <div class="nav-left">
      <img class="logo" src="@/assets/images/logo-header.png" alt="logo" />
      <div class="text-title" @click="setStatus">{{ $t('components.learnSysLayout.navigation.title') }}</div>
    </div>
    <div class="nav-right">
      <div class="nav-a">
        <a :href="documentUrl" target="_blank">{{ $t('components.learnSysLayout.navigation.handlbook') }}</a>
        <!-- <a href="https://library.ciis.edu" target="_blank">{{ $t('components.learnSysLayout.navigation.library') }}</a> -->
      </div>
      <div class="nav-message"></div>
      <div class="notify" @click="goNotify()">
        {{ $t('components.learnSysLayout.navigation.tip') }}
        <div class="num" v-if="this.$store.getters.myMsg != 0">{{ this.$store.getters.myMsg }}</div>
      </div>
      <language-switch />
    </div>
  </div>
</template>

<script>
import LanguageSwitch from '@/components/languageSwitch/index.vue'
import cAction from '../../action'
// import Message from '@ezijing/web-message-sdk'
export default {
  components: { LanguageSwitch },
  data() {
    return {
      num: this.$store.getters.myMsg
    }
  },
  computed: {
    documentUrl() {
      return this.$store.state.documentUrl
    }
  },
  mounted() {
    cAction.Other.getNavMsg()
      .then(data => {
        this.$store.commit('myMsg', data.num)
      })
      .catch(e => {
        this.$message.error(e.message)
      })
    // 新版通知
    // Message({ container: '.nav-message', source: 'SOFIA_WEB', baseURL: webConf.others.messageBaseURL })
  },
  methods: {
    goNotify() {
      this.$router.push({ path: '/app/other/message' })
    },
    setStatus() {
      if (this.status) {
        this.status = false
      } else {
        this.status = true
      }
      this.$root.$emit('updateStatus', this.status)
    }
  }
}
</script>

<style scoped lang="scss">
.menu {
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: #b80037;
  .nav-left {
    float: left;
    position: relative;
    height: 100%;
    img.logo {
      position: absolute;
      left: 0;
      top: 50%;
      // height: 80%;
      width: 160px;
      transform: translateY(-50%);
    }
    .text-title {
      float: left;
      margin-left: 190px;
      line-height: 60px;
      font-size: 16px;
    }
  }
  .nav-right {
    display: flex;
    align-items: center;
  }
  .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;
      }
    }
  }
}
.nav-a {
  a {
    margin: 0 10px;
    color: #303133;
    text-decoration: none;
  }
}
</style>
