lucencyHeader.vue 11 KB

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