Header.vue 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390
  1. <template>
  2. <!-- 头部整体盒子 -->
  3. <div id="header" class="container-fuild">
  4. <!-- 头部顶部 -->
  5. <div class="header-top container-fuild hidden-xs">
  6. <div class="container">
  7. <div class="server pull-left">
  8. <span class="glyphicon glyphicon-earphone"></span>15086621233
  9. <span class="glyphicon glyphicon-envelope"></span>zhanyuhangkong@163.com
  10. <span class="glyphicon glyphicon-time"></span>全天候服务
  11. </div>
  12. <div class="shejiao pull-right">
  13. <span class="glyphicon glyphicon-hand-right"></span>赶快联系我们吧!
  14. <span class="glyphicon glyphicon-hand-left"></span>
  15. </div>
  16. </div>
  17. </div>
  18. <!-- 电脑导航 -->
  19. <div class="header-nav container hidden-xs ">
  20. <!-- 导航 logo -->
  21. <div class="header-nav-logo">
  22. <img src="@/assets/img/logo_black.svg" alt="logo">
  23. </div>
  24. <!-- 导航内容 -->
  25. <ul class="header-nav-wrapper">
  26. <li
  27. v-for="(item,index) in navList"
  28. :key="index"
  29. :class="index==navIndex?'active':''"
  30. @click="navClick(index,item.name)"
  31. >
  32. <router-link :to="item.path">
  33. {{ item.name }}
  34. <span v-if="item.children.length>0" class="glyphicon glyphicon-menu-down"></span>
  35. <i class="underline"></i>
  36. </router-link>
  37. <dl v-if="item.children.length>0">
  38. <dt v-for="(i,n) in item.children" :key="n">
  39. <router-link :to="i.path">{{ i.name }}</router-link>
  40. </dt>
  41. </dl>
  42. </li>
  43. </ul>
  44. </div>
  45. <!-- 手机导航 -->
  46. <div class="header-nav-m container-fuild visible-xs">
  47. <div class="header-nav-m-logo">
  48. <img class="center-block" src="@/assets/img/logo_black.svg" alt="logo">
  49. </div>
  50. <!-- 导航栏 -->
  51. <div class="header-nav-m-menu text-center">
  52. {{ menuName }}
  53. <div
  54. class="header-nav-m-menu-wrapper"
  55. data-toggle="collapse"
  56. data-target="#menu"
  57. @click="menuClick"
  58. >
  59. <span :class="menuClass"></span>
  60. </div>
  61. <!-- 导航内容 -->
  62. <ul id="menu" class="header-nav-m-wrapper collapse">
  63. <li
  64. v-for="(item,index) in navList"
  65. :key="index"
  66. :class="index==navIndex?'active':''"
  67. @click="navClick(index,item.name)"
  68. data-toggle="collapse"
  69. data-target="#menu"
  70. >
  71. <router-link :to="item.path">
  72. {{ item.name }}
  73. <i class="underline"></i>
  74. </router-link>
  75. </li>
  76. </ul>
  77. </div>
  78. </div>
  79. </div>
  80. </template>
  81. <script>
  82. export default {
  83. name: "Header",
  84. data() {
  85. return {
  86. navIndex: sessionStorage.getItem('navIndex') ? sessionStorage.getItem('navIndex') : 0,
  87. menuName: "首页",
  88. menuClass: "glyphicon glyphicon-menu-down",
  89. navList: [
  90. {
  91. name: "首页",
  92. path: "/",
  93. children: []
  94. },
  95. {
  96. name: "产品",
  97. path: "/products",
  98. children: [
  99. {
  100. name: "行业应用无人机",
  101. path: "/products/djiAircraft"
  102. },
  103. {
  104. name: "无人机负载",
  105. path: "/products/payloads"
  106. },
  107. {
  108. name: "软件与服务",
  109. path: "/products/software"
  110. },
  111. {
  112. name: "软件定制开发",
  113. path: "/products/develop"
  114. },
  115. ]
  116. },
  117. {
  118. name: "解决方案",
  119. path: "/solutions",
  120. children: []
  121. },
  122. {
  123. name: "公司动态",
  124. path: "/news",
  125. children: []
  126. },
  127. {
  128. name: "公司介绍",
  129. path: "/info",
  130. children: []
  131. },
  132. ]
  133. };
  134. },
  135. methods: {
  136. navClick(index, name) {
  137. this.navIndex = index;
  138. sessionStorage.setItem('navIndex', index)
  139. this.menuName = name;
  140. },
  141. menuClick() {
  142. if (this.menuClass == "glyphicon glyphicon-menu-down") {
  143. this.menuClass = "glyphicon glyphicon-menu-up";
  144. } else {
  145. this.menuClass = "glyphicon glyphicon-menu-down";
  146. }
  147. }
  148. }
  149. };
  150. </script>
  151. <style scoped>
  152. /* 顶部 */
  153. #header {
  154. background: #f4f4f4;
  155. transition: all ease 0.6s;
  156. box-shadow: none;
  157. margin: 0;
  158. padding: 0;
  159. }
  160. #header .header-top {
  161. height: 30px;
  162. color: #fff;
  163. font-size: 10px;
  164. line-height: 30px;
  165. background: #474747;
  166. }
  167. /* 顶部的图标 */
  168. #header .header-top span {
  169. margin: 0 8px;
  170. }
  171. /* 导航栏 */
  172. #header .header-nav {
  173. height: 80px;
  174. }
  175. /* 导航栏 logo */
  176. #header .header-nav .header-nav-logo {
  177. width: 140px;
  178. height: 80px;
  179. float: left;
  180. padding: 20px;
  181. box-sizing: border-box;
  182. }
  183. /* 导航栏 logo 图片 */
  184. #header .header-nav .header-nav-logo img {
  185. width: 100%;
  186. height: 100%;
  187. object-fit: contain;
  188. }
  189. /* 导航栏 导航容器 */
  190. #header .header-nav-fixed .header-nav-wrapper {
  191. line-height: 30px;
  192. }
  193. #header .header-nav .header-nav-wrapper {
  194. float: right;
  195. height: 80px;
  196. display: flex;
  197. align-items: center;
  198. }
  199. /* 导航栏 每个导航 */
  200. #header .header-nav .header-nav-wrapper > li {
  201. float: left;
  202. margin: 0 15px;
  203. position: relative;
  204. }
  205. /* 导航栏 每个导航下面的 a 链接 */
  206. #header .header-nav .header-nav-wrapper > li > a {
  207. color: #000;
  208. font-size: 14px;
  209. font-weight: bold;
  210. padding: 13px 0;
  211. position: relative;
  212. }
  213. /* 导航栏 每个导航下面的 a 链接的下划线 */
  214. #header .header-nav .header-nav-wrapper > li > a > i {
  215. display: block;
  216. position: absolute;
  217. bottom: -2px;
  218. left: 50%;
  219. width: 0;
  220. height: 1px;
  221. opacity: 0;
  222. transition: all 0.3s ease;
  223. background-color: #1e73be;
  224. }
  225. /* 导航栏 每个导航下面的 a 链接的右侧小三角 */
  226. #header .header-nav .header-nav-wrapper > li > a > span {
  227. font-size: 10px;
  228. transition: transform ease 0.4s;
  229. }
  230. /* 导航栏 每个导航下面的 a 链接 鼠标滑上去的样式 */
  231. #header .header-nav .header-nav-wrapper > li > a:hover {
  232. color: #1e73be;
  233. text-decoration: none;
  234. }
  235. /* 导航栏 每个导航下面的 a 链接 鼠标滑上去下划线的样式 */
  236. #header .header-nav .header-nav-wrapper > li > a:hover .underline {
  237. opacity: 1;
  238. width: 100%;
  239. left: 0;
  240. }
  241. /* 导航栏 每个导航下面的 a 链接 鼠标滑上去三角标的样式 */
  242. #header .header-nav .header-nav-wrapper > li > a:hover span {
  243. transform: rotate(180deg);
  244. }
  245. /* 导航栏 每个导航下面的 a 链接 鼠标点击后的样式 */
  246. #header .header-nav .header-nav-wrapper > li.active > a {
  247. color: #1e73be;
  248. text-decoration: none;
  249. border-bottom: 2px solid #1e73be;
  250. }
  251. /* 导航栏 每个导航下面的二级导航容器 */
  252. #header .header-nav .header-nav-wrapper > li > dl {
  253. display: none;
  254. position: absolute;
  255. width: 150px;
  256. margin-top: 14px;
  257. left: 0;
  258. z-index: 999999;
  259. box-shadow: 0 0 1px 1px #f3f3f3;
  260. border-radius: 5px;
  261. background: #fff;
  262. }
  263. /* 导航栏 每个导航下面的二级导航容器的每个导航 */
  264. #header .header-nav .header-nav-wrapper > li > dl > dt {
  265. width: 100%;
  266. padding: 10px;
  267. border-bottom: 1px solid #f3f3f3;
  268. }
  269. /* 导航栏 每个导航下面的二级导航容器的每个导航 当鼠标滑上时的样式 */
  270. #header .header-nav .header-nav-wrapper > li > dl > dt > a:hover {
  271. text-decoration: none;
  272. }
  273. /* 导航栏 滑上一级导航显示二级导航 */
  274. #header .header-nav .header-nav-wrapper > li:hover dl {
  275. display: block;
  276. }
  277. #header .header-nav .header-nav-wrapper > li > dl > dt:hover {
  278. cursor: pointer;
  279. background: #f5f5f5;
  280. text-decoration: underline;
  281. text-decoration-color: #1e73be;
  282. }
  283. /* 移动端适配 */
  284. @media screen and (max-width: 997px) {
  285. /* 导航栏 logo 容器 */
  286. #header .header-nav-m .header-nav-m-logo {
  287. height: 70px;
  288. padding: 10px 15px;
  289. box-sizing: border-box;
  290. }
  291. /* 导航栏 logo 图片 */
  292. #header .header-nav-m .header-nav-m-logo img {
  293. width: 100%;
  294. height: 100%;
  295. object-fit: contain;
  296. }
  297. /* 导航栏 菜单容器 */
  298. #header .header-nav-m .header-nav-m-menu {
  299. color: #fff;
  300. height: 40px;
  301. font-size: 13px;
  302. line-height: 40px;
  303. background: #474747;
  304. position: relative;
  305. }
  306. /* 导航栏 菜单图标 */
  307. #header .header-nav-m .header-nav-m-menu-wrapper {
  308. position: absolute;
  309. top: 50%;
  310. right: 20px;
  311. margin-top: -20px;
  312. width: 50px;
  313. height: 40px;
  314. color: #fff;
  315. z-index: 999999;
  316. font-size: 12px;
  317. }
  318. /* 导航栏 */
  319. #header .header-nav-m .header-nav-m-wrapper {
  320. position: absolute;
  321. top: 40px;
  322. left: 0;
  323. width: 100%;
  324. background: #474747;
  325. z-index: 9999999;
  326. }
  327. /* 导航栏 每个导航 */
  328. #header .header-nav-m .header-nav-m-wrapper > li {
  329. height: 40px;
  330. line-height: 40px;
  331. border-bottom: 1px solid #ccc;
  332. }
  333. /* 导航栏 每个导航下面的 a 链接 */
  334. #header .header-nav-m .header-nav-m-wrapper > li > a {
  335. color: #fff;
  336. font-size: 13px;
  337. font-weight: bold;
  338. padding: 15px 0;
  339. position: relative;
  340. }
  341. /* 导航栏 每个导航下面的 a 链接的右侧小三角 */
  342. #header .header-nav .header-nav-wrapper > li > a > span {
  343. font-size: 10px;
  344. }
  345. }
  346. /* 平板适配 */
  347. @media screen and (min-width: 768px) and (max-width: 997px) {
  348. #header .header-nav .header-nav-logo {
  349. width: 120px;
  350. padding: 12px 15px;
  351. }
  352. }
  353. /* 大屏幕优化 */
  354. @media screen and (min-width: 1200px) {
  355. #header .header-nav .header-nav-logo {
  356. width: 160px;
  357. padding: 15px 25px;
  358. }
  359. }
  360. </style>