header.vue 10 KB

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