<template>
  <div>
    <div class="headerSection">
      <div class="header-container width1200">
        <router-link :to="{ path: '/' }"
                     class="logo">
          <img src="../assets/images/logo.png"
               width="136px"
               height="40px"
               alt="">
        </router-link>
        <div class="menu">
          <router-link :class="checkActive==1?'active':''"
                       @click.native="change(1)"
                       :to="{ path: '/' }">首页</router-link>
          <router-link :class="checkActive==2?'active':''"
                       @click.native="change(2)"
                       :to="{ path: '/project' }">产品</router-link>
          <router-link :class="checkActive==3?'active':''"
                       @click.native="change(3)"
                       :to="{ path: '/consult' }">咨询</router-link>

          <router-link :class="checkActive==4?'active':''"
                       @click.native="change(4)"
                       :to="{ path: '/aboutUs' }">关于我们</router-link>
          <div class="bandBtn">合作机构</div>
        </div>
      </div>
    </div>
    <div class="wall"></div>
  </div>

</template>
<script>
export default {
  name: 'headerSection',
  props: ['name'],
  data () {
    return {
      checkActive: 1
    }
  },
  mounted () {
    let url = this.$route
    console.log(url)
    switch (url.path) {
      case '/': {
        this.change(1)
        break
      }
      case '/project': {
        this.change(2)
        break
      }
      case '/consult': {
        this.change(3)
        break
      }
      case '/aboutUs': {
        this.change(4)
        break
      }
    }
  },
  methods: {
    change (num) {
      this.checkActive = num;
    }
  }
}
</script>

<style lang="less" scoped>
.bandBtn {
  width: 112px;
  height: 30px;
  background: #2dc7aa;
  border-radius: 4px;
  color: #fff;
  margin-left: 70px;
  line-height: 30px;
  cursor: pointer;
  position: relative;
  top: 8px;
}
.wall {
  height: 82px;
}
.headerSection {
  background-color: #fff;
  position: fixed;
  width: 100%;
  top: 0px;
  z-index: 1000;
  .header-container {
    margin: 0 auto;
    // overflow: hidden;
    display: flex;
    flex-direction: row;
    justify-content: space-between;
    height: 80px;
    padding-top: 17px;
  }
  .logo {
    // float: left;
    width: 159px;
    height: 48px;
  }
  .menu {
    display: flex;
    flex-direction: row;
    font-size: 16px;
    a {
      margin-left: 80px;
      color: #565757;
      line-height: 48px;
      text-decoration: none;
      position: relative;
      // display: block;
      text-decoration: none;
      text-transform: uppercase;
      transition: 0.5s;
      &::after {
        position: absolute;
        content: "";
        top: 60%;
        left: 0;
        width: 100%;
        height: 3px;
        background-color: #000;
        z-index: 100;
        transform: scaleX(0);
        transform-origin: right;
        transition: transform 0.5s;
      }
      &:hover,
      &.hover {
        color: #000000;
        font-weight: 600;
      }
      &:hover::after {
        transform: scaleX(1);
        transform-origin: left;
      }
    }
  }
  a.active {
    color: #000 !important;
    font-weight: 600;
    &::after {
      position: absolute;
      content: "";
      top: 60%;
      left: 0;
      width: 100%;
      height: 3px;
      background-color: #000;
      z-index: 100;
      transform: scaleX(1);
      transform-origin: left;
    }
  }
}
</style>

