header.vue 9.4 KB

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