header.vue 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226
  1. <template>
  2. <nav class="client-head">
  3. <div class="client-container head-layout">
  4. <div class="head-left mta-hidden-sm">
  5. <a :href="`${baseUrl}`" class="client-head-img"></a>
  6. <div @click="navChange">
  7. <el-menu
  8. :default-active="activeNav"
  9. :class="navClass"
  10. mode="horizontal"
  11. :router="false"
  12. >
  13. <template v-for="(item,index) in headerArrPhone">
  14. <el-submenu :index="`${item.keyPath}`" v-if="item.children && item.children.length > 0"
  15. popper-class="mta-menu-two">
  16. <template slot="title">{{item.content}}</template>
  17. <el-menu-item :index="`${child.keyPath}`" v-for="child of item.children"
  18. :key="child.keyPath">
  19. <mtaLink :path="child.keyPath" :instation="false" :content="child.content" v-if="child.hrefFlag"></mtaLink>
  20. <mtaLink :path="child.keyPath" :instation="true" :content="child.content"></mtaLink>
  21. </el-menu-item>
  22. </el-submenu>
  23. <el-menu-item :index="`${item.keyPath}`" v-else>
  24. <mtaLink :path="item.keyPath" :instation="false" :content="item.content" v-if="item.hrefFlag"></mtaLink>
  25. <mtaLink :path="item.keyPath" :instation="true" :content="item.content"></mtaLink>
  26. </el-menu-item>
  27. </template>
  28. </el-menu>
  29. </div>
  30. <a class="phone-tel-box mta-hidden-sm" href="tel:400-052-2130">咨询电话:400-052-2130</a>
  31. <!-- 手机按钮 -->
  32. <div class="phone-nav-btn mta-hidden-sm" @click="changeHeadNav"></div>
  33. </div>
  34. <div class="head-left mta-hidden-xs">
  35. <a :href="`${baseUrl}`" class="client-head-img"></a>
  36. <div>
  37. <div class="header-left-container">
  38. <a class="phone-tel-box" href="tel:400-052-2130"> <i class="phone-tel-box-icon"></i> <span>咨询电话:400-052-2130</span></a>
  39. <div class="head-right mta-hidden-xs">
  40. <a class="right-tel-btn" href="https://cdnks.mtavip.com/a/register?flug=2" target="_blank" v-if="showBtnFlag">免费试用</a>
  41. <!--<div class="system-box">
  42. <div>
  43. <a rel="nofollow" href="https://cdnks.mtavip.com/a/register?flug=1" target="_blank"><i></i><p>考试系统</p></a>
  44. <span></span>
  45. <a rel="nofollow" href="https://cdnks.mtavip.com/a/register?flug=2" target="_blank"><i></i><p>培训系统</p></a>
  46. </div>
  47. </div>-->
  48. <a rel="nofollow" href="https://cdnks.mtavip.com/a/registerLogin" target="_blank" v-if="showBtnFlag">管理员登录</a>
  49. </div></div>
  50. <div>
  51. <div @click="navChange">
  52. <el-menu
  53. :default-active="activeNav"
  54. :class="navClass"
  55. mode="horizontal"
  56. :router="false"
  57. @select="headMenuSelect"
  58. >
  59. <template v-for="(item,index) in headerArr">
  60. <el-submenu :index="`${item.keyPath}`" v-if="item.children && item.children.length > 0"
  61. popper-class="mta-menu-two">
  62. <template slot="title">{{item.content}}</template>
  63. <el-menu-item :index="`${child.keyPath}`" v-for="child of item.children"
  64. :key="child.keyPath">
  65. <mtaLink :path="child.keyPath" :instation="false" :content="child.content" v-if="child.hrefFlag" target="_blank"></mtaLink>
  66. <mtaLink :path="child.keyPath" :instation="true" :content="child.content" v-else></mtaLink>
  67. </el-menu-item>
  68. </el-submenu>
  69. <el-menu-item :index="`${item.keyPath}`" v-else>
  70. <mtaLink :path="item.keyPath" :instation="false" :content="item.content" v-if="item.hrefFlag" target="_blank"></mtaLink>
  71. <mtaLink :path="item.keyPath" :instation="true" :content="item.content" v-else></mtaLink>
  72. </el-menu-item>
  73. </template>
  74. </el-menu>
  75. </div>
  76. </div>
  77. </div>
  78. </div>
  79. </div>
  80. </nav>
  81. </template>
  82. <script>
  83. import mtaLink from '~/components/mtaLink/index';
  84. import { mapGetters } from 'vuex';
  85. let _ = require('lodash');
  86. export default {
  87. name: 'mtaHeader',
  88. components: {
  89. mtaLink,
  90. },
  91. computed: {
  92. activeNav() {
  93. return this.getActiveNav;
  94. },
  95. baseUrl() {
  96. return this.getBaseUrl;
  97. },
  98. ...mapGetters(['getActiveNav','getBaseUrl'])
  99. },
  100. data() {
  101. return {
  102. showBtnFlag:false,
  103. navClass:'head-nav-up',
  104. headerArrPhone: [
  105. {
  106. content: '首页',
  107. keyPath: '/',
  108. },
  109. {
  110. content: '考试系统',
  111. keyPath: '/examsystem',
  112. children: [],
  113. },
  114. {
  115. content: '培训系统',
  116. keyPath: '/trainsystem',
  117. children: [],
  118. },
  119. /* {
  120. content: '课程资源',
  121. keyPath: '/resources',
  122. children: [],
  123. },*/
  124. {
  125. content: '课程开发',
  126. keyPath: '/courseware',
  127. children: [],
  128. },
  129. {
  130. content: '客户案例',
  131. keyPath: '/news',
  132. children: [],
  133. },
  134. /* {
  135. content: '帮助中心',
  136. keyPath: '/helpCenter',
  137. children: [],
  138. },*/
  139. {
  140. content: '关于我们',
  141. keyPath: '/introduction',
  142. children: [],
  143. },
  144. ],
  145. headerArr: [
  146. {
  147. content: '首页',
  148. keyPath: '/',
  149. },
  150. {
  151. content: '考试系统',
  152. keyPath: '/examsystem',
  153. children: [],
  154. },
  155. {
  156. content: '培训系统',
  157. keyPath: '/trainsystem',
  158. children: [],
  159. },
  160. /* {
  161. content: '课程资源',
  162. keyPath: '/resources',
  163. children: [],
  164. },*/
  165. {
  166. content: '课程开发',
  167. keyPath: '/courseware',
  168. children: [],
  169. },
  170. {
  171. content: '客户案例',
  172. keyPath: '/news',
  173. children: [],
  174. },
  175. /* {
  176. content: '帮助中心',
  177. keyPath: '/helpCenter',
  178. children: [],
  179. },*/
  180. {
  181. content: '关于我们',
  182. keyPath: '/introduction',
  183. children: [],
  184. },
  185. ],
  186. };
  187. },
  188. methods:{
  189. headMenuSelect(index){
  190. if(index.indexOf('trainsystem') !== -1 || index.indexOf('examsystem') !== -1){
  191. this.showBtnFlag = true;
  192. }else {
  193. this.showBtnFlag = false;
  194. }
  195. },
  196. // 点击按钮菜单变化
  197. changeHeadNav(){
  198. if(this.navClass ==='head-nav-up' ){
  199. this.navClass = 'head-nav-down'
  200. }else{
  201. this.navClass = 'head-nav-up'
  202. }
  203. },
  204. navChange(){
  205. this.navClass = 'head-nav-up'
  206. },
  207. },
  208. created() {
  209. let str = this.$route.fullPath;
  210. //注意:!=-1即为为真,可以找到得情况
  211. if(str.indexOf('trainsystem') !== -1 || str.indexOf('examsystem') !== -1){
  212. this.showBtnFlag = true;
  213. }else {
  214. this.showBtnFlag = false;
  215. }
  216. }
  217. };
  218. </script>