<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>
    <!-- <s-language></s-language> -->
    <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>
  </div>
</template>

<script>
// import sLanguage from '@/components/languageSwitch/index.vue'
import cAction from '../../action'

export default {
  components: {},
  data () {
    return {
      num: this.$store.getters.myMsg
    }
  },
  mounted () {
    // request({
    //   component: this,
    //   actionName: 'Other',
    //   functionName: 'getNavMsg',
    //   data: {},
    //   thenCallback: data => {
    //     this.$store.commit('myMsg', data.num)
    //   },
    //   catchCallback: () => {},
    //   finallyCallback: () => {}
    // })
    cAction.Other.getNavMsg().then(data => {
      this.$store.commit('myMsg', data.num)
    }).catch(e => { this.$message.error(e.message) }).finally(() => { })
  },
  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 {
  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>
