pcNav.vue 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226
  1. <template>
  2. <div class="header-nav">
  3. <nuxt-link to="/" :class="{active : curActive === 'shouye'}">首页</nuxt-link>
  4. <nuxt-link to="/examsystem" class="xwzx-row" :class="{'active': curActive === 'examsystem'}">考试系统</nuxt-link>
  5. <nuxt-link to="/trainsystem" class="xwzx-row" :class="{'active': curActive === 'trainsystem'}">培训系统</nuxt-link>
  6. <el-popover
  7. placement="bottom"
  8. trigger="hover"
  9. popper-class="head-popper-box cp-popper-box"
  10. >
  11. <nuxt-link :to="item.url" v-for="(item,index) in kckfList" :key="index" class="head-popper-item">
  12. <i></i>
  13. <p>
  14. <span class="head-popper-title">{{ item.title }}</span>
  15. <span class="head-popper-des">{{ item.des }}</span>
  16. </p>
  17. </nuxt-link>
  18. <span class="head-nav-btn" slot="reference" :class="{active: curActive === 'courseware'}">课程定制服务<i class="el-icon-arrow-down el-icon--right"></i></span>
  19. </el-popover>
  20. <nuxt-link to="/news" :class="{active: curActive === 'news'}">新闻资讯</nuxt-link>
  21. <nuxt-link to="/introduction" :class="{active: curActive === 'introduction'}">关于我们</nuxt-link>
  22. </div>
  23. </template>
  24. <script>
  25. export default {
  26. name: "pcNav",
  27. data() {
  28. return {
  29. kckfList: [
  30. {
  31. img: '#',
  32. title: '梗概',
  33. des: '为企业量身定做专属课程',
  34. url: '/courseware/synopsis'
  35. },
  36. {
  37. img: '#',
  38. title: '课程定制',
  39. des: '海量精品课程专业定制',
  40. url: '/courseware/custom'
  41. },
  42. {
  43. img: '#',
  44. title: '平台运营',
  45. des: '完善的平台运营体系',
  46. url: '/courseware/platform'
  47. },
  48. {
  49. img: '#',
  50. title: '课程大赛',
  51. des: '助力企业推动培训学习进程',
  52. url: '/courseware/compete'
  53. }
  54. ],
  55. }
  56. },
  57. methods:{
  58. headNavClick(){
  59. this.$emit('headNavClick')
  60. },
  61. },
  62. computed: {
  63. curActive() {
  64. const courseware = this.kckfList.map(item => item.url);
  65. const routerPath = this.$route.path
  66. // 首页
  67. if (routerPath === '/' || routerPath === '/index') {
  68. return 'shouye'
  69. } else if (routerPath === '/examsystem') {
  70. return 'examsystem'
  71. }else if (routerPath === '/trainsystem') {
  72. return 'trainsystem'
  73. } else if (routerPath === '/news') {
  74. return 'news'
  75. } else if (routerPath === '/introduction') {
  76. return 'introduction'
  77. } else if (courseware.some(path => path === routerPath)) {
  78. return 'courseware'
  79. }
  80. }
  81. },
  82. watch: {
  83. '$route.path': {
  84. handler(newVal) {
  85. console.log(newVal)
  86. this.$emit('navChange',newVal)
  87. },
  88. immediate: true,
  89. }
  90. }
  91. }
  92. </script>
  93. <style lang="scss">
  94. //头部导航
  95. .header-nav {
  96. > span, > a {
  97. height: 60px;
  98. line-height: 60px;
  99. font-size: 18px;
  100. margin: 0 42px;
  101. color: #333333;
  102. cursor: pointer;
  103. }
  104. > a:last-child {
  105. margin-right: 0;
  106. }
  107. > a:visited {
  108. color: #333333;
  109. }
  110. > a.active {
  111. color: #2b5cfd;
  112. position: relative;
  113. }
  114. .active:before {
  115. content: '';
  116. width: 100%;
  117. bottom: -10px;
  118. left: 0;
  119. height: 2px;
  120. background-color: #2b5cfd;
  121. display: block;
  122. position: absolute;
  123. }
  124. // 导航按钮
  125. .head-nav-btn.active {
  126. position: relative;
  127. }
  128. .head-nav-btn.active:before {
  129. width: 70%;
  130. bottom: -10px;
  131. left: 4%;
  132. }
  133. }
  134. /* 导航二级菜单 */
  135. .head-popper-box {
  136. width: 940px;
  137. display: flex;
  138. align-items: center;
  139. top:104px!important;
  140. // 箭头
  141. .popper__arrow::after {
  142. content: ' ';
  143. width: 0;
  144. height: 0;
  145. overflow: hidden;
  146. position: absolute;
  147. border-width: 6px;
  148. border-style: dashed dashed solid;
  149. border-color: transparent transparent #2b5cfd !important;
  150. top: -12px;
  151. }
  152. // 列表
  153. .head-popper-item {
  154. width: 23%;
  155. display: flex;
  156. margin: 16px 1%;
  157. align-items: center;
  158. i {
  159. width: 34px;
  160. height: 34px;
  161. background-size: contain;
  162. display: inline-block;
  163. margin-right: 16px;
  164. background-repeat: no-repeat;
  165. background-position: center;
  166. }
  167. .head-popper-title {
  168. font-size: 14px;
  169. color: #333;
  170. margin-bottom: 4px;
  171. display: inline-block;
  172. }
  173. .head-popper-des {
  174. display: block;
  175. font-size: 12px;
  176. color: #9c9c9c;
  177. }
  178. }
  179. // 列表
  180. .head-popper-item:nth-child(1) {
  181. i {
  182. background-image:url("~static/images/client/component/head-cp-icon1.png");
  183. }
  184. }
  185. .head-popper-item:nth-child(2) {
  186. i {
  187. background-image:url("~static/images/client/component/head-cp-icon2.png");
  188. }
  189. }
  190. .head-popper-item:nth-child(3) {
  191. i {
  192. background-image:url("~static/images/client/component/head-cp-icon3.png");
  193. }
  194. }
  195. .head-popper-item:nth-child(4) {
  196. i {
  197. background-image:url("~static/images/client/component/head-cp-icon4.png");
  198. }
  199. }
  200. }
  201. .head-popper-box:before {
  202. content: ' ';
  203. width: 100%;
  204. height: 2px;
  205. position: absolute;
  206. left: 0;
  207. top: 0;
  208. background-color: #2b5cfd;
  209. border-radius: 4px 4px 0 0;
  210. }
  211. </style>