<template>
  <nav class="client-head">
    <div class="client-container head-layout">
      <!-- 手机导航 -->
      <div class="head-left mta-hidden-sm">
        <a :href="`${baseUrl}`" class="client-head-img"></a>
        <!-- H5菜单 -->
        <sj-nav :class="navClass" @navChange="navChange"></sj-nav>
        <!-- 咨询电话 -->
        <a class="phone-tel-box mta-hidden-sm" href="tel:400-052-2130">咨询电话：400-052-2130</a>
        <!-- 手机按钮 -->
        <div class="phone-nav-btn mta-hidden-sm" @click="changeHeadNav"></div>
      </div>
      <!-- PC导航 -->
      <div class="head-left mta-hidden-xs">
        <a :href="`${baseUrl}`" class="client-head-img"></a>
        <div>
          <div class="header-left-container">
            <a class="phone-tel-box" href="tel:400-052-2130"> <i class="phone-tel-box-icon"></i> <span>咨询电话：400-052-2130</span></a>
            <div class="head-right mta-hidden-xs">
              <a class="right-tel-btn" href="https://cdnks.mtavip.com/a/register?flug=2" target="_blank" v-if="showBtnFlag">免费试用</a>
              <a rel="nofollow" href="https://cdnks.mtavip.com/a/registerLogin" target="_blank" v-if="showBtnFlag">管理员登录</a>
            </div></div>
          <!-- PC菜单 -->
          <pc-nav @navChange="headMenuSelect"></pc-nav>
        </div>
      </div>


    </div>
  </nav>
</template>

<script>
  import mtaLink        from '~/components/mtaLink/index';
  import { mapGetters } from 'vuex';
  import SjNav          from './mtaNav/sjNav';
  import PcNav          from './mtaNav/pcNav';

  let _ = require('lodash');
  export default {
    name:       'mtaHeader',
    components: {
      PcNav,
      SjNav,
      mtaLink,
    },
    computed: {
      activeNav() {
        return this.getActiveNav;
      },
      baseUrl() {
        return this.getBaseUrl;
      },
      ...mapGetters(['getActiveNav','getBaseUrl'])
    },
    data() {
      return {
        showBtnFlag:false,
        navClass:'head-nav-up',
        headerArrPhone:   [
          {
            content: '首页',
            keyPath: '/',
          },
          {
            content:  '考试系统',
            keyPath:  '/examsystem',
            children: [],
          },
          {
            content:  '培训系统',
            keyPath:  '/trainsystem',
            children: [],
          },
       /*   {
            content:  '课程资源',
            keyPath:  '/resources',
            children: [],
          },*/
          {
            content:  '课程开发',
            keyPath:  '/courseware',
            children: [],
          },
          {
            content:  '客户案例',
            keyPath:  '/news',
            children: [],
          },
          /*      {
                  content:  '帮助中心',
                  keyPath:  '/helpCenter',
                  children: [],
                },*/
          {
            content:  '关于我们',
            keyPath:  '/introduction',
            children: [],
          },

        ],
        headerArr:   [
          {
            content: '首页',
            keyPath: '/',
          },
          {
            content:  '考试系统',
            keyPath:  '/examsystem',
            children: [],
          },
          {
            content:  '培训系统',
            keyPath:  '/trainsystem',
            children: [],
          },
          /*   {
               content:  '课程资源',
               keyPath:  '/resources',
               children: [],
             },*/
          {
            content:  '课程开发',
            keyPath:  '/courseware',
            children: [],
          },
          {
            content:  '客户案例',
            keyPath:  '/news',
            children: [],
          },
          /*      {
                  content:  '帮助中心',
                  keyPath:  '/helpCenter',
                  children: [],
                },*/
          {
            content:  '关于我们',
            keyPath:  '/introduction',
            children: [],
          },

        ],
      };
    },
    methods:{
      headMenuSelect(index){
        if(index.indexOf('trainsystem') !== -1 || index.indexOf('examsystem') !== -1){
          this.showBtnFlag = true;
        }else {
          this.showBtnFlag = false;
        }
      },
      // 点击按钮菜单变化
      changeHeadNav(){
          if(this.navClass ==='head-nav-up' ){
              this.navClass = 'head-nav-down'
          }else{
            this.navClass = 'head-nav-up'
        }
      },
      navChange(){
        this.navClass = 'head-nav-up'
      },
    },
    created() {
      let str = this.$route.fullPath;
      //注意：！=-1即为为真，可以找到得情况
      if(str.indexOf('trainsystem') !== -1 || str.indexOf('examsystem') !== -1){
        this.showBtnFlag = true;
      }else {
        this.showBtnFlag = false;
      }
    }
  };
</script>
