header.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407
  1. <template>
  2. <header class="v-header clearfix">
  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/contact">联系我们</nuxt-link>
  58. </li>
  59. <!-- <li>
  60. <nuxt-link to="/about/auth">查询真伪</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. export default {
  80. name: "VHeader",
  81. data() {
  82. return {
  83. headFixed: true,
  84. headWhite: false,
  85. isHome: true,
  86. maxClientWidth: 980,
  87. productActive: false,
  88. aboutActive: false,
  89. };
  90. },
  91. watch: {
  92. $route () {
  93. this.handleRouterActive();
  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. let scrollTop = window.pageYOffset || document.documentElement.scrollTop || document.body.scrollTop;
  107. if(this.isHome && scrollTop <= 10) {
  108. this.headWhite = false;
  109. } else {
  110. this.headWhite = true;
  111. }
  112. },
  113. navEnter() {
  114. if(this.isHome && !this.headWhite) {
  115. this.headWhite = true;
  116. }
  117. },
  118. navLeave() {
  119. let scrollTop = window.pageYOffset || document.documentElement.scrollTop || document.body.scrollTop;
  120. if(this.isHome && scrollTop <= 0) {
  121. this.headWhite = false;
  122. }
  123. },
  124. handleRouterActive() {
  125. if(this.$route.fullPath == '/') {
  126. this.isHome = true;
  127. } else {
  128. this.isHome = false;
  129. this.headWhite = true;
  130. }
  131. if(this.$route.fullPath && this.$route.fullPath.includes('/about')) {
  132. this.aboutActive = true;
  133. } else {
  134. this.aboutActive = false;
  135. }
  136. if(this.$route.fullPath && this.$route.fullPath.includes('/product')) {
  137. this.productActive = true;
  138. } else {
  139. this.productActive = false;
  140. }
  141. }
  142. },
  143. destroyed() {
  144. window.removeEventListener("scroll", this.handleScroll);
  145. },
  146. };
  147. </script>
  148. <style lang="scss" scoped>
  149. @import '~static/common/style.sass';
  150. .nav-space {
  151. height: 72px;
  152. }
  153. .fixedTop {
  154. position: fixed;
  155. left: 0;
  156. top: 0;
  157. }
  158. #index-header {
  159. width: 100%;
  160. z-index: 666;
  161. background: transparent;
  162. &.head-white {
  163. background: #fff;
  164. transition: background 0.3s ease-in-out;
  165. .h-nav-list {
  166. li {
  167. &:first-child {
  168. // padding-left: 40px;
  169. .nuxt-link-active {
  170. color: $theme_gray333;
  171. // border-bottom: 2px solid transparent;
  172. &.nuxt-link-exact-active {
  173. color: $theme_color;
  174. &::after {
  175. // background: #ffffff;
  176. // background: $theme_color;
  177. }
  178. }
  179. }
  180. }
  181. a {
  182. color: $theme_gray333;
  183. transition: color 0.3s ease-in-out;
  184. &.nuxt-link-exact-active {
  185. color: $theme_color;
  186. }
  187. }
  188. .expand {
  189. color: $theme_gray333;
  190. }
  191. }
  192. .h-nav-list-child {
  193. transition: max-height .3s ease-in-out;
  194. li {
  195. .nuxt-link-exact-active {
  196. color: $theme_color;
  197. }
  198. }
  199. }
  200. .h-nav-li-more {
  201. .h-nav-list-parent {
  202. color: $theme_color;
  203. }
  204. .expand {
  205. color: $theme_color;
  206. }
  207. }
  208. .h-nav-li {
  209. .nuxt-link-exact-active {
  210. &:after {
  211. background: #236AFA;
  212. }
  213. }
  214. }
  215. }
  216. .h-nav-logo {
  217. h1 {
  218. background: url('~assets/images/home/logo@2x.png') no-repeat 0 0;
  219. background-size: 100% 100%;
  220. }
  221. }
  222. }
  223. .index-header-box {
  224. height: 72px;
  225. display: flex;
  226. align-items: center;
  227. box-sizing: border-box;
  228. }
  229. .h-nav-logo {
  230. h1 {
  231. display: block;
  232. height: 31px;
  233. width: 114px;
  234. background: url('~assets/images/home/logo_white@2x.png') no-repeat 0 0;
  235. text-indent: -9999px;
  236. overflow: hidden;
  237. background-size: 100% 100%;
  238. }
  239. }
  240. .i-h-nav {
  241. display: flex;
  242. align-items: center;
  243. height: 72px;
  244. font-size: 15px;
  245. margin-left: 137px;
  246. }
  247. .h-nav-list {
  248. display: block;
  249. width: 100%;
  250. height: 100%;
  251. font-size: 0;
  252. li {
  253. position: relative;
  254. display: inline-block;
  255. padding: 0 50px;
  256. line-height: 72px;
  257. box-sizing: border-box;
  258. font-size: 15px;
  259. &:first-child {
  260. // padding-left: 40px;
  261. .nuxt-link-active {
  262. color: #333;
  263. // border-bottom: 2px solid transparent;
  264. &.nuxt-link-exact-active {
  265. color: #ffffff;
  266. }
  267. }
  268. }
  269. &:hover {
  270. .h-nav-list-child {
  271. max-height: 500px;
  272. }
  273. .expand {
  274. color: $theme_color;
  275. }
  276. a {
  277. position: relative;
  278. color: $theme_color;
  279. transition: all 0.3s;
  280. font-family: PingFangSC-Medium, sans-serif;
  281. font-weight: 500;
  282. }
  283. }
  284. .nuxt-link-exact-active, .nuxt-link-active {
  285. position: relative;
  286. color: $theme_color;
  287. transition: all 0.3s;
  288. font-family: PingFangSC-Medium, sans-serif;
  289. font-weight: 500;
  290. }
  291. .expand {
  292. position: absolute;
  293. top: 0;
  294. right: 11px;
  295. font-size: 16px;
  296. color: #ffffff;
  297. transition: color 0.3s ease-in-out;
  298. }
  299. a {
  300. width: 100%;
  301. padding: 22px 0;
  302. color: #ffffff;
  303. -webkit-box-sizing: border-box;
  304. -moz-box-sizing: border-box;
  305. box-sizing: border-box;
  306. -webkit-transition: all 0.5s ease;
  307. -o-transition: all 0.5s ease;
  308. transition: all 0.5s ease;
  309. font-family: PingFangSC-Medium, sans-serif;
  310. font-weight: 400;
  311. }
  312. .h-nav-list-child {
  313. // position: absolute;
  314. // width: 100px;
  315. // border-radius: 0px 0px 4px 4px;
  316. // overflow: hidden;
  317. // max-height: 0;
  318. // background: #ffffff;
  319. // z-index: 999;
  320. // transition: max-height .3s ease-in-out;
  321. }
  322. }
  323. .h-nav-li {
  324. .nuxt-link-exact-active {
  325. &:after {
  326. content: '';
  327. position: absolute;
  328. bottom: 0;
  329. background: #ffffff;
  330. width: 40px;
  331. height: 2px;
  332. box-shadow: 0px 2px 4px 0px rgba(85, 141, 253, 0.4);
  333. left: 50%;
  334. transform: translateX(-50%);
  335. }
  336. }
  337. }
  338. .h-nav-list-child {
  339. position: absolute;
  340. width: 100px;
  341. border-radius: 0px 0px 4px 4px;
  342. overflow: hidden;
  343. max-height: 0;
  344. background: #ffffff;
  345. z-index: 999;
  346. line-height: 20px;
  347. li {
  348. width: 100%;
  349. height: 20px;
  350. font-size: 14px;
  351. text-align: center;
  352. line-height: 20px;
  353. margin: 10px 0 0;
  354. padding: 0;
  355. &:last-child {
  356. margin-bottom: 18px;
  357. }
  358. a {
  359. display: block;
  360. overflow: hidden;
  361. width: 100%;
  362. height: 100%;
  363. color: $theme_fu_bule;
  364. padding: 0;
  365. &:hover {
  366. color: $theme_color;
  367. }
  368. }
  369. }
  370. }
  371. .h-right {
  372. display: flex;
  373. .btn {
  374. width: 70px;
  375. height: 30px;
  376. line-height: 30px;
  377. text-align: center;
  378. }
  379. .h-regist {
  380. background: $theme_color_fu;
  381. box-shadow:0px 2px 12px 0px rgba(57,109,209,0.58);
  382. border-radius: 50px;
  383. color: #F8FFF7;
  384. }
  385. .h-login {
  386. border-radius: 50px;
  387. border:1px solid $theme_color_fu;
  388. color: $theme_color_fu;
  389. margin-right: 40px;
  390. }
  391. }
  392. }
  393. }
  394. </style>