<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> -->
        <div class="logo-box">
          <img class="zj-logo" @click="goWebsite" src="https://webapp-pub.oss-cn-beijing.aliyuncs.com/project/seg-ppa/zj-logo.png" />
          <div class="line"></div>
          <img class="ppa-logo" @click="goWebsite" src="https://webapp-pub.oss-cn-beijing.aliyuncs.com/project/seg-ppa/paa-logo.png" />
          <nuxt-link to="/">
            <div class="title">科创+DBA</div>
          </nuxt-link>
          <!-- <img src="https://webapp-pub.oss-cn-beijing.aliyuncs.com/project/marywood/marywood_logo.svg" /> -->
        </div>

        <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" @click="$router.push('/my/account')">
            马上报名
          </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: {
    goWebsite() {
      // window.location.href = 'http://www.ezijing.com'
      window.location.href = '/'
    },
    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;
    .max-width-content {
      display: flex;
      align-items: center;
      img {
        // height: 55px;
        cursor: pointer;
        display: block;
      }
      .logo-box {
        display: flex;
        align-items: center;
        justify-content: center;
        padding: 20px 0;
        .zj-logo {
          height: 55px;
          cursor: pointer;
          display: block;
        }
        .ppa-logo{
          height: 60px;
          cursor: pointer;
          display: block;
        }
        .line {
          border-right: 1px solid #aa1941;
          height: 26px;
          width: 0;
          margin: 0 20px;
        }
        .title {
          font-size: 30px;
          font-weight: 500;
          color: #aa1941;
          box-sizing: border-box;
          white-space: nowrap;
          word-wrap: normal;
          word-break: keep-all;
          margin-left: 35px;
        }
      }
      .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: 30px;
          box-sizing: border-box;
          text-align: center;
          line-height: 30px;
          font-size: 12px;
          border-radius: 6px;
          margin-left: 10px;
          cursor: pointer;
        }
        .login {
          color: #333333;
          border: 1px solid #eaeaea;
        }
        .register {
          background: #aa1941;
          color: #fff;
        }
      }
      .language {
        margin-left: 24px;
        font-size: 14px;
        color: #333;
        cursor: pointer;
      }
    }
  }
  .max-width-content {
    width: 1200px;
    margin: 0 auto;
  }
  .head-nav-content {
    height: 72px;
  }
}
</style>
