| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513 |
- <template>
- <div class="header w-screen pad:w-full h-12 pad:h-32 static pad:fixed flex justify-center flex-col items-center">
- <div class="container
- flex-shrink
- flex h-10 pad:h-24 justify-center items-center
- pad:justify-start pad:items-start
- ">
- <a class="w-48 pad:w-64 pc:w-72 flex-shrink-0 z-40" href="/">
- <img src="/headerLogo.png" alt="" class="logo">
- </a>
- <div class="hidden pad:flex w-full h-full items-center ">
- <div class="">
- <img src="/image/logotext2.png" alt="">
- </div>
- <div class="menus w-full">
- <div class="top-menu">
- <a class="menu" href="/">{{ lang===langType.cn?"首页":getLangText("首页") }}</a>
- <a class="menu" @click="switchLangClickHandle">
- {{ lang===langType.cn?"English":getLangText("English") }}
- </a>
- </div>
- <ul class="subMenu">
- <li class="menu" v-for="(item,i) in menus" :key="item.url+'_'+i"
- :title="lang===langType.cn?item.text:getLangText(item.text)">
- <a :href="item.url" >{{lang===langType.cn?item.text:getAbbrText(item.text)}}</a>
- </li>
- </ul>
- </div>
- </div>
- </div>
- <div :class="`container header-menu ${isPhone?'header-menu-phone':''}`">
- <div class="menu-btn" @click="switchMenu" @touch="switchMenu">
- <svg-icon icon-class="more"/>
- </div>
- <ul :class="`main-menus ${isShow?'':'main-menus-hide'}`" >
- <li class="main-menu"
- v-for="(item,i) in mainMenus"
- :key="`main-${item.path}-${i}`"
- @mouseenter="showSubMenu(item)"
- @mouseleave="startHideSubMenu(item)"
- >
- <a :href="lang===langType.cn?item.path:getLangPathStr(item.path)" >{{lang===langType.cn?item.text:getAbbrText(item.text)}}</a>
- <span class="now" v-if="pageKey===item.key"></span>
- <menu-drop
- v-show="item.showSub"
- v-if="item.isSub"
- :type="item.subKey"
- :lang="lang"
- :pHref="item.path"
- />
- </li>
- </ul>
- <div :class="`search-box absolute right-0 top-0 z-50 ${searchShow?'search-box-show':''}`"
- v-click-outside="hideSearch"
- >
- <div class="search" @click="switchSearch">
- <input type="text" v-model="searchKey"
- placeholder="搜索咨询与产品">
- <button @click="searchItem" >
- <svg-icon icon-class="search" />
- </button>
- <div class="phoneClose" @click.stop="hideSearch">
- <svg-icon icon-class="close" />
- </div>
- </div>
- </div>
- </div>
- </div>
- </template>
- <script>
- import langMap from "~/map/langMap";
- import menuDrop from "~/components/header/menuDrops/menuDrop";
- export default {
- name: "lucencyHeader",
- props: {
- lang:{
- default: langMap.lang.cn
- },
- pageKey:{
- default: "index"
- },
- isPhone: {
- default: true
- }
- },
- components:{
- menuDrop
- },
- data(){
- return {
- langType: langMap.lang,
- menus: [
- {
- url:'https://gpscore.net/',
- text: '合方圆管理平台'
- },
- {
- url:'/',
- text: '智慧能源'
- },
- {
- url:'/',
- text: '输电线路摄像头'
- },
- {
- url:'https://gpscore.net/',
- text: '4G低功耗摄像头'
- },
- {
- url:'https://gpscore.net/',
- text: '自动变焦双目协同摄像头'
- },
- {
- url:'https://gpscore.net/',
- text: 'M2M产品'
- },
- {
- url:'https://gpscore.net/',
- text: '智能终端'
- },
- ],
- mainMenus:[
- {
- key: "index",
- path: "/",
- text: "首页"
- },
- {
- key: "product",
- path: "/product",
- text: "产品中心",
- isSub: true,
- subKey: "product",
- showSub: false
- },
- {
- key: "solution",
- path: "/solution",
- text: "解决方案",
- isSub: true,
- subKey: "solution",
- showSub: false
- },
- {
- key: "news",
- path: "/news",
- text: "新闻中心"
- },
- {
- key: "support",
- path: "/support",
- text: "技术支持",
- sub:{
- type: "support",
- }
- },
- {
- key: "about",
- path: "/about",
- text: "关于我们",
- sub:{
- type: "about",
- }
- }
- ],
- searchKey: "",
- nowSub: "",
- hideTimer: null,
- isShow: false,
- searchShow: false,
- }
- },
- mounted() {
- },
- // 指令
- directives: {
- // 点击外部,执行隐藏
- clickOutside: {
- bind(el, binding, vnode) {
- function documentHandler(e) {
- if (el.contains(e.target)) {
- return false;
- }
- if (binding.expression) {
- binding.value(e);
- }
- }
- el.__vueClickOutside__ = documentHandler;
- document.addEventListener('click', documentHandler);
- },
- unbind(el, binding) {
- document.removeEventListener('click', el.__vueClickOutside__);
- delete el.__vueClickOutside__;
- }
- }
- },
- methods:{
- getLangText(str){
- return langMap.getText(this.lang,str);
- },
- getAbbrText(str){
- return langMap.getAbbrText(this.lang,str);
- },
- getLangPathStr(pathStr){
- return langMap.getLangPathStr(this.lang,pathStr)
- },
- switchLangClickHandle(){
- this.$root.$emit('changeLang');
- },
- searchItem(){
- console.log('searching....')
- },
- showSubMenu(item){
- // console.log("0000000")
- if(item.isSub){
- // 清除隐藏定时器
- if(this.hideTimer){
- clearTimeout(this.hideTimer);
- this.hideTimer = null;
- }
- if(this.nowSub !== item.key){
- // 不同key切换
- let oldItem = this.mainMenus.find(val => val.key === this.nowSub);
- console.log(oldItem)
- if(oldItem){
- this.hideSubMenu(oldItem);
- }
- }
- item.showSub = true;
- this.nowSub = item.key;
- }
- },
- startHideSubMenu(item){
- this.hideTimer = setTimeout(()=>{
- this.hideSubMenu(item);
- },700)
- },
- hideSubMenu(item){
- item.showSub = false;
- this.nowSub = "";
- if(this.hideTimer){
- clearTimeout(this.hideTimer);
- this.hideTimer = null;
- }
- },
- switchMenu(){
- if(this.isPhone){
- console.log('切换按钮显示隐藏')
- this.isShow = !this.isShow;
- }
- },
- hideSearch(){
- console.log('hide search')
- this.searchShow = false;
- },
- showSearch(){
- this.searchShow = true;
- },
- switchSearch(){
- if(!this.searchShow){
- this.showSearch();
- }
- }
- }
- }
- </script>
- <style scoped>
- .header{
- backdrop-filter: blur(5px);
- box-shadow: 0px 2px 6px 0px rgb(0 0 0 / 20%);
- /*text-shadow: 0 0 5px skyblue;*/
- }
- .header-content > .logo{
- display: block;
- width: 260px;
- height: 70px;
- margin-top: 7.5px;
- }
- .header-content > .logo img{
- display: block;
- width: auto;
- height: 65px;
- }
- .menus{
- height: 40px;
- position: relative;
- display: flex;
- flex-direction: column;
- align-items: flex-end;
- /*margin-top: -28px;*/
- }
- .menus .top-menu{
- width: auto;
- height: 30px;
- right: 0;
- top: -20px;
- position: absolute;
- }
- .menus .menu{
- padding: 0 5px;
- list-style: none;
- cursor: pointer;
- color: #16a0d7;
- font-size: 1.1em;
- }
- .menus .menu:hover{
- color: skyblue !important;
- }
- .menus .subMenu{
- max-width: 100%;
- height: 100%;
- display: flex;
- list-style: none;
- align-items: center;
- position: relative;
- right: 0;
- }
- .menus .subMenu .menu{
- font-size: 0.85em;
- color: #343434;
- }
- .header-menu{
- position: relative;
- height: 2rem;
- display: flex;
- /*justify-content: space-between;*/
- }
- .header-menu-phone{
- position: absolute;
- }
- .header-menu .menu-btn{
- display: none;
- }
- .header-menu .main-menus{
- height: 100%;
- list-style: none;
- display: flex;
- align-items: flex-end;
- font-size: 1.15em;
- }
- .header-menu-phone .menu-btn{
- display: flex;
- height: 100%;
- align-items: center;
- justify-content: center;
- font-size: 1.2rem;
- padding: 0 15px;
- color: paleturquoise;
- }
- .header-menu-phone .main-menus{
- position: absolute;
- height: auto;
- padding: 5px;
- display: block;
- top: 100%;
- left: 0;
- background-color: #fff;
- }
- .header-menu-phone .main-menus-hide{
- left: -100%;
- }
- .main-menus .main-menu{
- width: auto;
- height: auto;
- /*color: #1a1a1a;*/
- margin-left: 15px;
- cursor: pointer;
- position: relative;
- }
- .main-menus .main-menu:first-child{
- margin-left: 0;
- }
- .header-menu-phone .main-menus .main-menu:first-child{
- margin-left: 15px;
- }
- .main-menus .main-menu > a{
- display: block;
- padding: 3px 20px 3px 5px;
- }
- .main-menus .main-menu > a:hover{
- color: orangered;
- }
- .main-menus .main-menu > a::before{
- content: "";
- width: 0;
- margin: 0 auto;
- height: 2px;
- background-color: #1e45e7;
- transition: all 0.6s;
- position: absolute;
- bottom: 0;
- left: 50%;
- }
- .main-menus .main-menu > .now{
- width: 100%;
- height: 2px;
- background-color: #1e45e7;
- position: absolute;
- bottom: 0;
- left: 0;
- overflow: hidden;
- }
- .main-menus .main-menu > a:hover:before{
- width: 100%;
- left: 0;
- }
- .search-box{
- height: 26px;
- display: flex;
- border-radius: 50%;
- align-items: center;
- font-size: 0.9em;
- width: 26px;
- transition: width 0.6s;
- box-shadow: 1px 1px 4px red ;
- }
- .search-box-show{
- width: 200px;
- }
- .header-menu-phone .search-box-show{
- width: 100%;
- }
- .search-box .search{
- height: 26px;
- width: 100%;
- border-radius: 26px;
- border: 1px solid gray;
- display: flex;
- position: relative;
- background-color: transparent;
- }
- .header-menu-phone .search-box-show .search{
- background-color: #fff;
- height: 30px;
- border-radius: 30px;
- }
- .search-box .search .phoneClose{
- width: 26px;
- height: 26px;
- align-items: center;
- justify-content: center;
- position: absolute;
- right: 0;
- top: 0;
- color: #1a1a1a;
- cursor: pointer;
- display: none;
- }
- .header-menu-phone .search-box-show .search .phoneClose{
- display: flex;
- width: 30px;
- height: 30px;
- font-size: 1.2rem;
- }
- .search > * {
- outline: none;
- }
- .search > input{
- display: block;
- width: 100%;
- height: 24px;
- border-radius: 24px;
- padding-left: 5px;
- padding-right: 15px;
- font-size: 0.85em;
- }
- .header-menu-phone .search-box-show .search > input{
- padding-left: 30px;
- height: 30px;
- border-radius: 30px;
- }
- .search > button{
- display: flex;
- width: 24px;
- height: 24px;
- position: absolute;
- top: 0;
- right: 3px;
- font-size: 1.2rem;
- justify-content: center;
- align-items: center;
- }
- .header-menu-phone .search-box-show .search > button{
- left: 2px;
- right: auto;
- width: 30px;
- height: 30px;
- }
- .search:hover > button{
- color: orange;
- }
- </style>
|