lucencyHeader.vue 9.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455
  1. <template>
  2. <div class="header w-screen h-12 pad:h-32 static pad:fixed flex justify-center flex-col items-center">
  3. <div class="container
  4. flex-shrink
  5. flex h-10 pad:h-24 justify-center items-center
  6. pad:justify-start pad:items-start
  7. ">
  8. <a class="w-48 pad:w-64 pc:w-72 flex-shrink-0 z-50" href="/">
  9. <img src="/headerLogo.png" alt="" class="logo">
  10. </a>
  11. <div class="hidden pad:flex w-full h-full items-center ">
  12. <div class="">
  13. <img src="/image/logotext2.png" alt="">
  14. </div>
  15. <div class="menus w-full">
  16. <div class="top-menu">
  17. <a class="menu" href="/">{{ lang===langType.cn?"首页":getLangText("首页") }}</a>
  18. <a class="menu" @click="switchLangClickHandle">
  19. {{ lang===langType.cn?"English":getLangText("English") }}
  20. </a>
  21. </div>
  22. <ul class="subMenu">
  23. <li class="menu" v-for="(item,i) in menus" :key="item.url+'_'+i"
  24. :title="lang===langType.cn?item.text:getLangText(item.text)">
  25. <a :href="item.url" >{{lang===langType.cn?item.text:getAbbrText(item.text)}}</a>
  26. </li>
  27. </ul>
  28. </div>
  29. </div>
  30. </div>
  31. <div :class="`container header-menu ${isPhone?'header-menu-phone':''}`">
  32. <div class="menu-btn" @click="switchMenu" @touch="switchMenu">
  33. <svg-icon icon-class="more"/>
  34. </div>
  35. <ul :class="`main-menus ${isShow?'':'main-menus-hide'}`" >
  36. <li class="main-menu"
  37. v-for="(item,i) in mainMenus"
  38. :key="`main-${item.path}-${i}`"
  39. @mouseenter="showSubMenu(item)"
  40. @mouseleave="startHideSubMenu(item)"
  41. >
  42. <a :href="lang===langType.cn?item.path:getLangPathStr(item.path)" >{{lang===langType.cn?item.text:getAbbrText(item.text)}}</a>
  43. <span class="now" v-if="pageKey===item.key"></span>
  44. <menu-drop
  45. v-show="item.showSub"
  46. v-if="item.isSub"
  47. :type="item.subKey"
  48. :lang="lang"
  49. :pHref="item.path"
  50. />
  51. </li>
  52. </ul>
  53. <div :class="`search-box absolute right-0 top-0 ${searchShow?'search-box-show':''}`"
  54. v-click-outside="hideSearch"
  55. >
  56. <div class="search">
  57. <input type="text" v-model="searchKey"
  58. placeholder="搜索咨询与产品">
  59. <button @click="searchItem" >
  60. <svg-icon icon-class="search" />
  61. </button>
  62. </div>
  63. </div>
  64. </div>
  65. </div>
  66. </template>
  67. <script>
  68. import langMap from "~/map/langMap";
  69. import menuDrop from "~/components/header/menuDrops/menuDrop";
  70. export default {
  71. name: "lucencyHeader",
  72. props: {
  73. lang:{
  74. default: langMap.lang.cn
  75. },
  76. pageKey:{
  77. default: "index"
  78. },
  79. isPhone: {
  80. default: true
  81. }
  82. },
  83. components:{
  84. menuDrop
  85. },
  86. data(){
  87. return {
  88. langType: langMap.lang,
  89. menus: [
  90. {
  91. url:'https://gpscore.net/',
  92. text: '合方圆管理平台'
  93. },
  94. {
  95. url:'/',
  96. text: '智慧能源'
  97. },
  98. {
  99. url:'/',
  100. text: '输电线路摄像头'
  101. },
  102. {
  103. url:'https://gpscore.net/',
  104. text: '4G低功耗摄像头'
  105. },
  106. {
  107. url:'https://gpscore.net/',
  108. text: '自动变焦双目协同摄像头'
  109. },
  110. {
  111. url:'https://gpscore.net/',
  112. text: 'M2M产品'
  113. },
  114. {
  115. url:'https://gpscore.net/',
  116. text: '智能终端'
  117. },
  118. ],
  119. mainMenus:[
  120. {
  121. key: "index",
  122. path: "/",
  123. text: "首页"
  124. },
  125. {
  126. key: "product",
  127. path: "/product",
  128. text: "产品中心",
  129. isSub: true,
  130. subKey: "product",
  131. showSub: false
  132. },
  133. {
  134. key: "solution",
  135. path: "/solution",
  136. text: "解决方案",
  137. isSub: true,
  138. subKey: "solution",
  139. showSub: false
  140. },
  141. {
  142. key: "news",
  143. path: "/news",
  144. text: "新闻中心"
  145. },
  146. {
  147. key: "support",
  148. path: "/support",
  149. text: "技术支持",
  150. sub:{
  151. type: "support",
  152. }
  153. },
  154. {
  155. key: "about",
  156. path: "/about",
  157. text: "关于我们",
  158. sub:{
  159. type: "about",
  160. }
  161. }
  162. ],
  163. searchKey: "",
  164. nowSub: "",
  165. hideTimer: null,
  166. isShow: false,
  167. searchShow: false,
  168. }
  169. },
  170. mounted() {
  171. },
  172. // 指令
  173. directives: {
  174. // 点击外部,执行隐藏
  175. clickOutside: {
  176. bind(el, binding, vnode) {
  177. function documentHandler(e) {
  178. if (el.contains(e.target)) {
  179. return false;
  180. }
  181. if (binding.expression) {
  182. binding.value(e);
  183. }
  184. }
  185. el.__vueClickOutside__ = documentHandler;
  186. document.addEventListener('click', documentHandler);
  187. },
  188. unbind(el, binding) {
  189. document.removeEventListener('click', el.__vueClickOutside__);
  190. delete el.__vueClickOutside__;
  191. }
  192. }
  193. },
  194. methods:{
  195. getLangText(str){
  196. return langMap.getText(this.lang,str);
  197. },
  198. getAbbrText(str){
  199. return langMap.getAbbrText(this.lang,str);
  200. },
  201. getLangPathStr(pathStr){
  202. return langMap.getLangPathStr(this.lang,pathStr)
  203. },
  204. switchLangClickHandle(){
  205. this.$root.$emit('changeLang');
  206. },
  207. searchItem(){
  208. },
  209. showSubMenu(item){
  210. // console.log("0000000")
  211. if(item.isSub){
  212. // 清除隐藏定时器
  213. if(this.hideTimer){
  214. clearTimeout(this.hideTimer);
  215. this.hideTimer = null;
  216. }
  217. if(this.nowSub !== item.key){
  218. // 不同key切换
  219. let oldItem = this.mainMenus.find(val => val.key === this.nowSub);
  220. console.log(oldItem)
  221. if(oldItem){
  222. this.hideSubMenu(oldItem);
  223. }
  224. }
  225. item.showSub = true;
  226. this.nowSub = item.key;
  227. }
  228. },
  229. startHideSubMenu(item){
  230. this.hideTimer = setTimeout(()=>{
  231. this.hideSubMenu(item);
  232. },700)
  233. },
  234. hideSubMenu(item){
  235. item.showSub = false;
  236. this.nowSub = "";
  237. if(this.hideTimer){
  238. clearTimeout(this.hideTimer);
  239. this.hideTimer = null;
  240. }
  241. },
  242. switchMenu(){
  243. if(this.isPhone){
  244. console.log('切换按钮显示隐藏')
  245. this.isShow = !this.isShow;
  246. }
  247. }
  248. }
  249. }
  250. </script>
  251. <style scoped>
  252. .header{
  253. backdrop-filter: blur(5px);
  254. box-shadow: 0px 2px 6px 0px rgb(0 0 0 / 20%);
  255. /*text-shadow: 0 0 5px skyblue;*/
  256. }
  257. .header-content > .logo{
  258. display: block;
  259. width: 260px;
  260. height: 70px;
  261. margin-top: 7.5px;
  262. }
  263. .header-content > .logo img{
  264. display: block;
  265. width: auto;
  266. height: 65px;
  267. }
  268. .menus{
  269. height: 40px;
  270. position: relative;
  271. display: flex;
  272. flex-direction: column;
  273. align-items: flex-end;
  274. /*margin-top: -28px;*/
  275. }
  276. .menus .top-menu{
  277. width: auto;
  278. height: 30px;
  279. right: 0;
  280. top: -20px;
  281. position: absolute;
  282. }
  283. .menus .menu{
  284. padding: 0 5px;
  285. list-style: none;
  286. cursor: pointer;
  287. color: #16a0d7;
  288. font-size: 1.1em;
  289. }
  290. .menus .menu:hover{
  291. color: skyblue !important;
  292. }
  293. .menus .subMenu{
  294. max-width: 100%;
  295. height: 100%;
  296. display: flex;
  297. list-style: none;
  298. align-items: center;
  299. position: relative;
  300. right: 0;
  301. }
  302. .menus .subMenu .menu{
  303. font-size: 0.85em;
  304. color: #343434;
  305. }
  306. .header-menu{
  307. position: relative;
  308. height: 2rem;
  309. display: flex;
  310. /*justify-content: space-between;*/
  311. }
  312. .header-menu-phone{
  313. position: absolute;
  314. }
  315. .header-menu .menu-btn{
  316. display: none;
  317. }
  318. .header-menu .main-menus{
  319. height: 100%;
  320. list-style: none;
  321. display: flex;
  322. align-items: flex-end;
  323. font-size: 1.15em;
  324. }
  325. .header-menu-phone .menu-btn{
  326. display: flex;
  327. height: 100%;
  328. align-items: center;
  329. justify-content: center;
  330. font-size: 1.2rem;
  331. padding: 0 15px;
  332. color: paleturquoise;
  333. }
  334. .header-menu-phone .main-menus{
  335. position: absolute;
  336. height: auto;
  337. padding: 5px;
  338. display: block;
  339. top: 100%;
  340. left: 0;
  341. background-color: #fff;
  342. }
  343. .header-menu-phone .main-menus-hide{
  344. left: -100%;
  345. }
  346. .main-menus .main-menu{
  347. width: auto;
  348. height: auto;
  349. /*color: #1a1a1a;*/
  350. margin-left: 15px;
  351. cursor: pointer;
  352. position: relative;
  353. }
  354. .main-menus .main-menu:first-child{
  355. margin-left: 0;
  356. }
  357. .header-menu-phone .main-menus .main-menu:first-child{
  358. margin-left: 15px;
  359. }
  360. .main-menus .main-menu > a{
  361. display: block;
  362. padding: 3px 20px 3px 5px;
  363. }
  364. .main-menus .main-menu > a:hover{
  365. color: orangered;
  366. }
  367. .main-menus .main-menu > a::before{
  368. content: "";
  369. width: 0;
  370. margin: 0 auto;
  371. height: 2px;
  372. background-color: #1e45e7;
  373. transition: all 0.6s;
  374. position: absolute;
  375. bottom: 0;
  376. left: 50%;
  377. }
  378. .main-menus .main-menu > .now{
  379. width: 100%;
  380. height: 2px;
  381. background-color: #1e45e7;
  382. position: absolute;
  383. bottom: 0;
  384. left: 0;
  385. overflow: hidden;
  386. }
  387. .main-menus .main-menu > a:hover:before{
  388. width: 100%;
  389. left: 0;
  390. }
  391. .search-box{
  392. height: 26px;
  393. display: flex;
  394. border-radius: 50%;
  395. align-items: center;
  396. font-size: 0.9em;
  397. width: 26px;
  398. transition: width 0.6s;
  399. box-shadow: 1px 1px 4px red ;
  400. }
  401. .search-box .search{
  402. height: 26px;
  403. width: 100%;
  404. border-radius: 26px;
  405. border: 1px solid gray;
  406. display: flex;
  407. position: relative;
  408. background-color: transparent;
  409. }
  410. .search > * {
  411. outline: none;
  412. }
  413. .search > input{
  414. display: block;
  415. width: 100%;
  416. height: 24px;
  417. border-radius: 24px;
  418. padding-left: 5px;
  419. padding-right: 15px;
  420. font-size: 0.85em;
  421. }
  422. .search > button{
  423. display: block;
  424. width: 24px;
  425. height: 24px;
  426. position: absolute;
  427. top: 0;
  428. right: 3px;
  429. }
  430. .search > button:hover{
  431. color: orange;
  432. }
  433. </style>