<template>
	<header class="v-header clearfix">
		<div id="index-header" :class="headFixed == true ? 'fixedTop' : ''">
			<div class="index-header-box">
        <div class="h-nav-logo">
          <nuxt-link to="/">
            <img src="~/assets/images/index/logo_icon.png" alt="" srcset="">
          </nuxt-link>
          <div class="name">中德智慧教育</div>
        </div>
				<div class="i-h-nav">
					<ul class="h-nav-list">
						<li>
							<nuxt-link to="/">首页</nuxt-link>
						</li>
						<li>
							<nuxt-link to="/product">产品与服务</nuxt-link>
							<ul class="h-nav-list-child">
								<li>
									<nuxt-link target="_blank" to="/product/list">教具玩具</nuxt-link>
								</li>
								<li>
									<nuxt-link target="_blank" to="/product/course">多端课堂</nuxt-link>
								</li>
							</ul>
              <div class="expand"></div>
						</li>
						<li>
							<nuxt-link to="/leader">新闻资讯</nuxt-link>
						</li>
						<li>
							<nuxt-link to="/experice">网校中心</nuxt-link>
						</li>
						<li>
							<nuxt-link target="_blank" to="/campus">全国校区</nuxt-link>
						</li>
						<li>
							<nuxt-link target="_blank" to="/news">加盟合作</nuxt-link>
						</li>
						<li>
							<nuxt-link to="/about">关于我们</nuxt-link>
							<ul class="h-nav-list-child">
								<li>
									<nuxt-link target="_blank" to="/about/brand">品牌故事</nuxt-link>
								</li>
								<li>
									<nuxt-link target="_blank" to="/about/team">专家团队</nuxt-link>
								</li>
								<li>
									<nuxt-link target="_blank" to="/about/contact">联系我们</nuxt-link>
								</li>
							</ul>
              <div class="expand"></div>
						</li>
					</ul>
				</div>
        <!-- <div class="h-right">
          <div class="h-login btn">登录</div>
          <div class="h-regist btn">注册</div>
        </div> -->
			</div>
		</div>
	</header>
</template>

<script>
import { mapState } from "vuex";

export default {
  name: "VHeader",
  data() {
    return {
      headFixed: true,
      maxClientWidth: 980,
      isShowCode: false,
    };
  },
  computed: {
    ...mapState(["headProdNav", "headNewsNav", "headJobNav"]),
  },
  mounted() {
    //监听滚动条
    window.addEventListener("scroll", this.handleScroll);
  },
  methods: {
    handleScroll() {
      // var scrollTop = window.pageYOffset || document.documentElement.scrollTop || document.body.scrollTop;
      // var offsetTop = document.querySelector('.h-nav-list').offsetTop;
      // if (scrollTop > offsetTop) {
      // 	this.headFixed = true;
      // } else {
      // 	this.headFixed = false;
      // }
    },
    showCode() {
      this.isShowCode = !this.isShowCode;
    },
  },
  destroyed() {
    window.removeEventListener("scroll", this.handleScroll);
  },
};
</script>

<style lang="scss" scoped>
@import '~static/common/style.sass';

#index-header {
  width: 1200px;
  top: 36px;
  left: 50%;
  transform: translateX(-50%);
  /* width: 100%; */
  /* height: 158px; */
  background: #fff;
  z-index: 666;
  box-shadow: 0px 2px 35px 0px rgba(6,8,71,0.17);
  border-radius: 8px;
}

.fixedTop {
  position: fixed;
  /* top: -100px; */
  left: 0;
}

.index-header-box {
  height: 82px;
  display: flex;
  align-items: center;
  /* background: #fff; */
  box-sizing: border-box;
}


.i-h-nav {
  display: flex;
  align-items: center;
  // width: 1200px;
  height: 82px;
  // margin: 0 auto;
  font-size: 15px;
  // text-align: center;
  margin-right: 34px;
}

.h-nav-logo {
  font-size: 0;
  display: flex;
  align-items: center;
  padding-right: 22px;
  border-right: 1px solid #F0F1F2;
}

.h-nav-logo img {
  height: 38px;
  margin: 0 16px 0 22px;
}

.h-nav-logo .name {
  width: 108px;
  height: 25px;
  line-height: 25px;
  font-size: 18px;
  font-family: PingFangSC-Semibold,PingFang SC;
  font-weight: 600;
  color: $theme_color;
}

ul.h-nav-list {
  display: block;
  width: 100%;
  height: 100%;
  font-size: 0;
}

.h-nav-list > li {
  position: relative;
  display: inline-block;
  padding: 0 35px;
  line-height: 82px;
  box-sizing: border-box;
  font-size: 15px;
}

.h-nav-list > li:first-child {
  padding-left: 40px;
}

.h-nav-list > li > a {
  width: 100%;
  padding: 22px 0;
  color: $theme_fu_bule;
  -webkit-box-sizing: border-box;
  -moz-box-sizing: border-box;
  box-sizing: border-box;
  -webkit-transition: all 0.5s ease;
  -o-transition: all 0.5s ease;
  transition: all 0.5s ease;
  font-family: PingFangSC-Medium,PingFang SC;
  font-weight: 500;
}

.h-nav-list > li .expand {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  right: 4px;
  font-size: 0;
  width: 16px;
  height: 10px;
  background-image: url('~assets/images/index/arrow_down.png');
  background-size: 16px 10px;
  background-repeat: no-repeat;
}

.h-nav-list > li:hover .expand {
  background-size: 16px 10px;
  background-image: url('~assets/images/index/arrow_down_bg_blue.png');
}

.h-nav-list > li:hover > a,
.h-nav-list li .nuxt-link-exact-active,
.h-nav-list li .nuxt-link-active {
  color: $theme_color_fu;
  // border-bottom: 2px solid $theme_color_fu;
}

.h-nav-list > li:first-child .nuxt-link-active {
  color: $theme_fu_bule;
  border-bottom: 2px solid transparent;
}

.h-nav-list > li:first-child .nuxt-link-active.nuxt-link-exact-active {
  // border-bottom: 2px solid $theme_color_fu;
  color: $theme_color_fu;
}
// .h-nav-list-child li a.nuxt-link-exact-active {
//   // border: none;
// }
.h-nav-list > li .h-nav-list-child {
  visibility: hidden;
  position: absolute;
  // left: 50%;
  // transform: translateX(-50%);
  width: 100px;
  border-radius: 0px 0px 3px 3px;
  overflow: hidden;
  height: 0;
  // margin-left: -50px;
  /* background: #f2f3f4; */
  background: #ffffff;
  opacity: 0;
  filter: alpha(opacity=0);
  z-index: 999;
  padding: 10px 0;
  transition: all .5s ease;
}


.h-nav-list > li:hover .h-nav-list-child {
  visibility: visible;
  height: auto;
  -webkit-transition: all .5s ease;
  -o-transition: all .5s ease;
  transition: all .5s ease;
  opacity: 100;
  filter: alpha(opacity=1);
}

ul.h-nav-list-child > li {
  width: 100%;
  height: 30px;
  font-size: 14px;
  text-align: center;
  line-height: 30px;
}

ul.h-nav-list-child li a {
  display: block;
  overflow: hidden;
  width: 100%;
  height: 100%;
  color: $theme_fu_bule;
  // border: none;
}

ul.h-nav-list-child li a:hover {
  color: $theme_color_fu;
}

.h-right {
  display: flex;
  .btn {
    width: 70px;
    height: 30px;
    line-height: 30px;
    text-align: center;
  }
  .h-regist {
    background: $theme_color_fu;
    box-shadow:0px 2px 12px 0px rgba(57,109,209,0.58);
    border-radius: 50px;
    color: #F8FFF7;
  }
  .h-login {
    border-radius: 50px;
    border:1px solid $theme_color_fu;
    color: $theme_color_fu;
    margin-right: 40px;
  }
}

</style>