header.vue 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396
  1. <template>
  2. <header class="v-header clearfix">
  3. <div id="nav-space" class="nav-space"></div>
  4. <div id="index-header" :class="headFixed == true ? 'fixedTop' : ''">
  5. <div class="index-header-box w1200">
  6. <div class="h-nav-logo">
  7. <nuxt-link to="/">
  8. <img src="~/assets/images/index/logo_icon.png" alt="" srcset="">
  9. </nuxt-link>
  10. <div class="name">
  11. <nuxt-link to="/">
  12. 中德智慧教育
  13. </nuxt-link>
  14. </div>
  15. </div>
  16. <div class="i-h-nav">
  17. <ul class="h-nav-list">
  18. <li class="h-nav-li">
  19. <nuxt-link to="/">首页</nuxt-link>
  20. </li>
  21. <li :class="{'h-nav-li-more': productActive}">
  22. <a class="h-nav-list-parent" href="javascript:void(0)">产品与服务</a>
  23. <!-- <nuxt-link to="">产品与服务</nuxt-link> -->
  24. <ul class="h-nav-list-child">
  25. <li>
  26. <nuxt-link to="/product/list">教具玩具</nuxt-link>
  27. </li>
  28. <li>
  29. <nuxt-link to="/product/course">多端课堂</nuxt-link>
  30. </li>
  31. </ul>
  32. <div class="expand">
  33. <i class="el-icon-arrow-down"></i>
  34. </div>
  35. </li>
  36. <li class="h-nav-li">
  37. <nuxt-link to="/news">新闻资讯</nuxt-link>
  38. </li>
  39. <li class="h-nav-li">
  40. <a target="_blank" href="https://course.zaojiao.net/index" rel="noopener noreferrer">网校中心</a>
  41. <!-- <nuxt-link to="/experice">网校中心</nuxt-link> -->
  42. </li>
  43. <li class="h-nav-li">
  44. <nuxt-link to="/campus">全国校区</nuxt-link>
  45. </li>
  46. <li class="h-nav-li">
  47. <nuxt-link to="/cooperate">加盟合作</nuxt-link>
  48. </li>
  49. <li :class="{'h-nav-li-more': aboutActive}">
  50. <a class="h-nav-list-parent" href="javascript:void(0)">关于我们</a>
  51. <!-- <nuxt-link to="">关于我们</nuxt-link> -->
  52. <ul class="h-nav-list-child">
  53. <li>
  54. <nuxt-link to="/about/brand">品牌故事</nuxt-link>
  55. </li>
  56. <li>
  57. <nuxt-link to="/about/team">专家团队</nuxt-link>
  58. </li>
  59. <li>
  60. <nuxt-link to="/about/contact">联系我们</nuxt-link>
  61. </li>
  62. </ul>
  63. <div class="expand">
  64. <i class="el-icon-arrow-down"></i>
  65. </div>
  66. </li>
  67. </ul>
  68. </div>
  69. <!-- <div class="h-right">
  70. <div class="h-login btn">登录</div>
  71. <div class="h-regist btn">注册</div>
  72. </div> -->
  73. </div>
  74. </div>
  75. </header>
  76. </template>
  77. <script>
  78. import { mapState } from "vuex";
  79. import { turquoise } from 'color-name';
  80. export default {
  81. name: "VHeader",
  82. data() {
  83. return {
  84. headFixed: true,
  85. maxClientWidth: 980,
  86. productActive: false,
  87. aboutActive: false,
  88. };
  89. },
  90. watch: {
  91. $route () {
  92. this.handleRouterActive();
  93. console.log('route changed', this.$route.fullPath)
  94. }
  95. },
  96. computed: {
  97. ...mapState(["headProdNav", "headNewsNav", "headJobNav"]),
  98. },
  99. mounted() {
  100. //监听滚动条
  101. window.addEventListener("scroll", this.handleScroll);
  102. this.handleRouterActive();
  103. },
  104. methods: {
  105. handleScroll() {
  106. // var scrollTop = window.pageYOffset || document.documentElement.scrollTop || document.body.scrollTop;
  107. // var offsetTop = document.querySelector('.h-nav-list').offsetTop;
  108. // if (scrollTop > offsetTop) {
  109. // this.headFixed = true;
  110. // } else {
  111. // this.headFixed = false;
  112. // }
  113. },
  114. handleRouterActive() {
  115. if(this.$route.fullPath && this.$route.fullPath.includes('/about')) {
  116. this.aboutActive = true;
  117. } else {
  118. this.aboutActive = false;
  119. }
  120. if(this.$route.fullPath && this.$route.fullPath.includes('/product')) {
  121. this.productActive = true;
  122. } else {
  123. this.productActive = false;
  124. }
  125. }
  126. },
  127. destroyed() {
  128. window.removeEventListener("scroll", this.handleScroll);
  129. },
  130. };
  131. </script>
  132. <style lang="scss" scoped>
  133. @import '~static/common/style.sass';
  134. .h-nav-list {
  135. .h-nav-li-more {
  136. .h-nav-list-parent {
  137. color: $theme_color;
  138. }
  139. .expand {
  140. color: $theme_color;
  141. }
  142. }
  143. }
  144. .nav-space {
  145. height: 72px;
  146. }
  147. #index-header {
  148. // width: 1200px;
  149. // top: 36px;
  150. // left: 50%;
  151. // transform: translateX(-50%);
  152. width: 100%;
  153. /* height: 158px; */
  154. background: #fff;
  155. z-index: 666;
  156. // box-shadow: 0px 2px 35px 0px rgba(6,8,71,0.17);
  157. // border-radius: 8px;
  158. }
  159. .fixedTop {
  160. position: fixed;
  161. /* top: -100px; */
  162. left: 0;
  163. top: 0;
  164. }
  165. .index-header-box {
  166. height: 72px;
  167. display: flex;
  168. align-items: center;
  169. /* background: #fff; */
  170. box-sizing: border-box;
  171. }
  172. .i-h-nav {
  173. display: flex;
  174. align-items: center;
  175. // width: 1200px;
  176. height: 72px;
  177. // margin: 0 auto;
  178. font-size: 15px;
  179. // text-align: center;
  180. margin-right: 34px;
  181. }
  182. .h-nav-logo {
  183. font-size: 0;
  184. display: flex;
  185. align-items: center;
  186. padding-right: 37px;
  187. border-right: 1px solid #F0F1F2;
  188. }
  189. .h-nav-logo img {
  190. height: 40px;
  191. margin: 0 16px 0 22px;
  192. }
  193. .h-nav-logo .name {
  194. width: 108px;
  195. height: 25px;
  196. line-height: 25px;
  197. font-size: 18px;
  198. font-family: PingFangSC-Semibold, sans-serif;
  199. font-weight: 600;
  200. a {
  201. color: $theme_color;
  202. }
  203. }
  204. ul.h-nav-list {
  205. display: block;
  206. width: 100%;
  207. height: 100%;
  208. font-size: 0;
  209. }
  210. .h-nav-list > li {
  211. position: relative;
  212. display: inline-block;
  213. padding: 0 34px;
  214. line-height: 72px;
  215. box-sizing: border-box;
  216. font-size: 15px;
  217. }
  218. .h-nav-list > li:first-child {
  219. padding-left: 40px;
  220. }
  221. .h-nav-list > li > a {
  222. width: 100%;
  223. padding: 22px 0;
  224. color: $theme_gray333;
  225. -webkit-box-sizing: border-box;
  226. -moz-box-sizing: border-box;
  227. box-sizing: border-box;
  228. -webkit-transition: all 0.5s ease;
  229. -o-transition: all 0.5s ease;
  230. transition: all 0.5s ease;
  231. // font-family: PingFangSC-Medium, sans-serif;
  232. font-weight: 400;
  233. }
  234. .h-nav-list > li .expand {
  235. position: absolute;
  236. top: 0;
  237. right: 11px;
  238. font-size: 16px;
  239. // width: 16px;
  240. // height: 10px;
  241. color: #DBDBDB;
  242. // background-image: url('~assets/images/index/arrow_down.png');
  243. // background-size: 16px 10px;
  244. // background-repeat: no-repeat;
  245. }
  246. .h-nav-list > li:hover .expand {
  247. color: $theme_color;
  248. // background-image: url('~assets/images/index/arrow_down_bg_blue.png');
  249. }
  250. .h-nav-list > li:hover > a,
  251. .h-nav-list li .nuxt-link-exact-active,
  252. .h-nav-list li .nuxt-link-active {
  253. position: relative;
  254. color: $theme_color;
  255. transition: all 0.3s;
  256. font-family: PingFangSC-Medium, sans-serif;
  257. font-weight: 500;
  258. // border-bottom: 2px solid $theme_color_fu;
  259. }
  260. .h-nav-list {
  261. .h-nav-li {
  262. .nuxt-link-exact-active{
  263. &:after {
  264. content: '';
  265. position: absolute;
  266. bottom: 0;
  267. background: $theme_color;
  268. width: 40px;
  269. height: 2px;
  270. box-shadow: 0px 2px 4px 0px rgba(85, 141, 253, 0.4);
  271. left: 50%;
  272. transform: translateX(-50%);
  273. }
  274. }
  275. // :not(.h-nav-list-child) {
  276. // }
  277. }
  278. }
  279. // .h-nav-list li.h-nav-li
  280. // .nuxt-link-exact-active{
  281. // &:after {
  282. // content: ''; /*CSS伪类用法*/
  283. // position: absolute; /*定位背景横线的位置*/
  284. // bottom: 0;
  285. // background: $theme_color; /*宽和高做出来的背景横线*/
  286. // width: 40px;
  287. // height: 2px;
  288. // box-shadow: 0px 2px 4px 0px rgba(85, 141, 253, 0.4);
  289. // left: 50%;
  290. // transform: translateX(-50%);
  291. // }
  292. // }
  293. .h-nav-list > li:first-child .nuxt-link-active {
  294. color: $theme_fu_bule;
  295. border-bottom: 2px solid transparent;
  296. }
  297. .h-nav-list > li:first-child .nuxt-link-active.nuxt-link-exact-active {
  298. // border-bottom: 2px solid $theme_color_fu;
  299. color: $theme_color;
  300. }
  301. // .h-nav-list-child li a.nuxt-link-exact-active {
  302. // // border: none;
  303. // }
  304. .h-nav-list > li .h-nav-list-child {
  305. position: absolute;
  306. // left: 50%;
  307. // transform: translateX(-50%);
  308. width: 100px;
  309. border-radius: 0px 0px 4px 4px;
  310. overflow: hidden;
  311. max-height: 0;
  312. // margin-left: -50px;
  313. /* background: #f2f3f4; */
  314. background: #ffffff;
  315. z-index: 999;
  316. // padding: 10px 0;
  317. // transition: all .5s ease;
  318. transition: max-height .3s ease-in-out;
  319. }
  320. .h-nav-list > li:hover .h-nav-list-child {
  321. max-height: 500px;
  322. }
  323. ul.h-nav-list-child > li {
  324. width: 100%;
  325. height: 20px;
  326. font-size: 14px;
  327. text-align: center;
  328. line-height: 20px;
  329. margin: 10px 0 0;
  330. &:last-child {
  331. margin-bottom: 18px;
  332. }
  333. }
  334. ul.h-nav-list-child li a {
  335. display: block;
  336. overflow: hidden;
  337. width: 100%;
  338. height: 100%;
  339. color: $theme_fu_bule;
  340. // border: none;
  341. }
  342. ul.h-nav-list-child li a:hover {
  343. color: $theme_color;
  344. }
  345. .h-right {
  346. display: flex;
  347. .btn {
  348. width: 70px;
  349. height: 30px;
  350. line-height: 30px;
  351. text-align: center;
  352. }
  353. .h-regist {
  354. background: $theme_color_fu;
  355. box-shadow:0px 2px 12px 0px rgba(57,109,209,0.58);
  356. border-radius: 50px;
  357. color: #F8FFF7;
  358. }
  359. .h-login {
  360. border-radius: 50px;
  361. border:1px solid $theme_color_fu;
  362. color: $theme_color_fu;
  363. margin-right: 40px;
  364. }
  365. }
  366. </style>