<template>
  <div class="head-mian">
    <div class="color-bar"></div>
    <div class="head-top-content">
      <div class="max-width-content">
        <!-- <nuxt-link to="/home">
          <img src="https://webapp-pub.oss-cn-beijing.aliyuncs.com/project/ciis/ezijing-logo.png" />
          <img style="margin-left:20px" src="https://webapp-pub.oss-cn-beijing.aliyuncs.com/project/seg-shms/seg-shms-logos.png" />
        </nuxt-link> -->
        <div class="logo-box">
          <img @click="goWebsite" src="https://webapp-pub.oss-cn-beijing.aliyuncs.com/project/exed/logo.png" />
          <!-- <nuxt-link to="/home" class="logo">
            <img src="https://webapp-pub.ezijing.com/project/seg-shms/shms0402.svg" />
          </nuxt-link> -->
        </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">
            <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'
    },
    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;
  min-width: 1200px;
  .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;
      // ::v-deep {
      //   a {
      //     display: flex;
      //     img {
      //       height: 55px;
      //       cursor: pointer;
      //       display: block;
      //     }
      //     img:first-child {
      //       margin-right: 10px;
      //     }
      //   }
      // }
      .logo-box {
        display: flex;
        img {
          height: 55px;
          cursor: pointer;
          display: block;
        }
        img:first-child {
          margin-right: 30px;
        }
      }
      .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;
          display: flex;
          justify-content: center;
        }
        .register {
          color: #333333;
          border: 1px solid #eaeaea;
          display: flex;
          justify-content: center;
        }
      }
      .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>
