<template>
  <div class="head-mian">
    <div class="color-bar"></div>
    <div class="head-top-content">
      <div class="max-width-content">
        <!-- <nuxt-link to="/">
          <img src="https://zws-imgs-pub.ezijing.com/static/public/307f688850f8308a5c944bd129436fe0.png" />
        </nuxt-link> -->
        <nuxt-link to="/">
          <div class="logo-box">
            <img src="http://zws-imgs-pub.oss-cn-beijing.aliyuncs.com/static/ezijing/logo/ezijing-logo.svg" />
            <div style="font-weight: 400;font-size: 28px;color: #AF1941;margin-top:10px;margin-left:20px">
              1+1 国际硕士
            </div>
            <!-- <img src="https://webapp-pub.oss-cn-beijing.aliyuncs.com/project/marywood/marywood_logo.svg" /> -->
          </div>
        </nuxt-link>
        <div class="user" v-if="user.id">
          <span>{{ user.realname || user.nickname }}</span
          ><em>|</em><span class="logout" @click="logout">{{ $t('menu.out') }}</span>
        </div>
        <div class="login-btn-box" v-else>
          <div class="login">
            <a :href="loginURL">{{ $t('menu.fastLogin') }}</a>
          </div>
          <div class="register">
            <a :href="registerURL">{{ $t('menu.register') }}</a>
          </div>
        </div>
        <!-- <div class="language">
          <span @click="switchLocale('zh-CN')">中文</span> / <span @click="switchLocale('en-US')">EN</span>
        </div> -->
      </div>
    </div>
    <div class="head-nav-content max-width-content">
      <app-menu></app-menu>
      <div class="search-box"></div>
    </div>
  </div>
</template>
<script>
import AppMenu from './Menu'
export default {
  components: {
    AppMenu
  },
  data() {
    return {}
  },
  methods: {
    logout() {
      this.$store.dispatch('logout')
    },
    switchLocale(locale) {
      this.$i18n.locale = locale
      this.$cookies.set('lang', locale)
      process.client && location.reload()
    }
  },
  computed: {
    user() {
      return this.$store.state.user || {}
    },
    loginURL() {
      return process.client
        ? `${process.env.loginURL}/login/index?redirect_uri=${encodeURIComponent(
            location.origin + this.$route.fullPath
          )}`
        : ''
    },
    registerURL() {
      return process.client
        ? `${process.env.loginURL}/register?redirect_uri=${encodeURIComponent(location.origin + this.$route.fullPath)}`
        : ''
    }
  }
}
</script>
<style lang="scss" scoped>
ul,
li {
  margin: 0;
  padding: 0;
  list-style: none;
}
.head-mian {
  width: 100%;
  background: #fff;
  .color-bar {
    height: 10px;
    background: #aa1941;
  }
  .head-top-content {
    // width: 1200px;
    // margin: 0 auto;
    border: 1px solid #ebebeb;
    padding: 23px 0 22px;
    .max-width-content {
      display: flex;
      align-items: center;
      img {
        height: 55px;
        cursor: pointer;
        display: block;
      }
      .logo-box {
        display: flex;
        img {
          height: 55px;
          cursor: pointer;
          display: block;
          &:nth-child(2) {
            margin-left: 20px;
          }
        }
      }
      .user {
        margin-left: auto;
        font-size: 14px;
        em {
          font-size: 14px;
          font-style: normal;
          padding: 0 14px;
        }
        .logout {
          cursor: pointer;
        }
      }
      .login-btn-box {
        margin-left: auto;
        display: flex;
        div {
          width: 72px;
          height: 24px;
          box-sizing: border-box;
          text-align: center;
          line-height: 24px;
          font-size: 12px;
          border-radius: 6px;
          margin-left: 10px;
          cursor: pointer;
        }
        .login {
          background: #aa1941;
          color: #fff;
        }
        .register {
          color: #333333;
          border: 1px solid #eaeaea;
        }
      }
      .language {
        margin-left: 24px;
        font-size: 14px;
        color: #333;
        cursor: pointer;
      }
    }
  }
  .max-width-content {
    width: 1200px;
    margin: 0 auto;
  }
  .head-nav-content {
    height: 72px;
    display: flex;
    align-items: center;
  }
}
</style>
