|
@@ -1,28 +1,37 @@
|
|
|
<template>
|
|
|
- <div class="header-layout" :class="{active: headActive}" @mouseenter="active = true" @mouseleave="active = false">
|
|
|
- <router-link :to="{name: 'home'}" class="logo">
|
|
|
- <i class="iconfont icon-logo_a"></i>
|
|
|
- <i class="iconfont icon-logo_b"></i>
|
|
|
- </router-link>
|
|
|
+ <div class="header-layout">
|
|
|
+ <div class="logo-layout">
|
|
|
+ <router-link :to="{name: 'home'}" class="logo">
|
|
|
+ <i class="iconfont icon-logo_a"></i>
|
|
|
+ <i class="iconfont icon-logo_b"></i>
|
|
|
+ </router-link>
|
|
|
+ </div>
|
|
|
<div class="menu">
|
|
|
<div class="lang">
|
|
|
- <a :class="{active: language === 'en'}" @click="$store.commit('change_language', 'en')">En</a>
|
|
|
- <a :class="{active: language === 'cn'}" @click="$store.commit('change_language', 'cn')">Cn</a>
|
|
|
+ <vcenter>
|
|
|
+ <a :class="{active: language === 'en'}" @click="$store.commit('change_language', 'en')">En</a>
|
|
|
+ <a :class="{active: language === 'cn'}" @click="$store.commit('change_language', 'cn')">Cn</a>
|
|
|
+ </vcenter>
|
|
|
</div>
|
|
|
- <div class="list">
|
|
|
+ <div class="list" ref="list" @mouseleave="hoverCp !== 'isearch' && hideCp()">
|
|
|
<a
|
|
|
v-for="nav in navs"
|
|
|
:key="nav.text"
|
|
|
- @mouseover="overHandle(nav)"
|
|
|
- @mouseout="outHandle"
|
|
|
+ @mouseenter="hoverCp !== 'isearch' && showCp(nav.cp, 135)"
|
|
|
@click="clickHandle(nav)"
|
|
|
- :class="{active: cp === nav.cp}">
|
|
|
+ :class="{active: hoverCp === nav.cp}">
|
|
|
{{nav.text}}
|
|
|
</a>
|
|
|
+
|
|
|
+ <div class="child-layout" :style="{maxHeight: height + 'px'}">
|
|
|
+ <i class="silp" :style="{left: split + 'px'}"></i>
|
|
|
+ <slot :split="split" :cp="hoverCp" />
|
|
|
+ </div>
|
|
|
+
|
|
|
</div>
|
|
|
</div>
|
|
|
<div class="ctrl">
|
|
|
- <a class="search" @click="$store.commit('change_nav', 'isearch')" :class="{active: cp === 'isearch'}">
|
|
|
+ <a class="search" @click="searchHandle" :class="{active: hoverCp === 'isearch'}">
|
|
|
<vcenter>
|
|
|
<i class="iconfont icon-sousuo open"></i>
|
|
|
<i class="iconfont icon-cuo hide"></i>
|
|
@@ -41,12 +50,16 @@
|
|
|
<script>
|
|
|
import {mapState} from 'vuex'
|
|
|
import vcenter from '@/components/vcenter'
|
|
|
+import { getPosition } from '@/util'
|
|
|
|
|
|
export default {
|
|
|
data () {
|
|
|
return {
|
|
|
+ height: 0,
|
|
|
+ hoverCp: null,
|
|
|
+ split: 0,
|
|
|
overb: false,
|
|
|
- active: false,
|
|
|
+ active: true,
|
|
|
navs: [
|
|
|
{text: '产品购买', cp: 'iproduct'},
|
|
|
{text: '核心技术', cp: 'videos'},
|
|
@@ -60,52 +73,47 @@ export default {
|
|
|
clickHandle (nav) {
|
|
|
this.$router.push({name: nav.cp})
|
|
|
},
|
|
|
- overHandle (nav) {
|
|
|
+ showCp (cp, height) {
|
|
|
+ this.$bus.$emit('showMask')
|
|
|
clearTimeout(this.timeout)
|
|
|
- this.$store.commit('change_nav', nav.cp)
|
|
|
+ this.hoverCp = cp
|
|
|
+ this.height = height
|
|
|
},
|
|
|
- outHandle () {
|
|
|
+ hideCp () {
|
|
|
+ this.$bus.$emit('hideMask')
|
|
|
+ this.height = 0
|
|
|
clearTimeout(this.timeout)
|
|
|
this.timeout = setTimeout(() => {
|
|
|
- this.$store.commit('change_nav', '')
|
|
|
- }, 300)
|
|
|
+ this.hoverCp = null
|
|
|
+ }, 700)
|
|
|
+ },
|
|
|
+ searchHandle () {
|
|
|
+ if (this.hoverCp === 'isearch') {
|
|
|
+ this.hideCp()
|
|
|
+ } else {
|
|
|
+ this.showCp('isearch', window.innerHeight - 68)
|
|
|
+ }
|
|
|
}
|
|
|
},
|
|
|
computed: {
|
|
|
...mapState({
|
|
|
- language: state => state.language.current,
|
|
|
- cp: state => state.ui.nav
|
|
|
- }),
|
|
|
- headActive () {
|
|
|
- return this.active || this.cp || this.overb
|
|
|
- }
|
|
|
- },
|
|
|
- watch: {
|
|
|
- cp (newVal) {
|
|
|
- let nav = this.navs.find(nav => nav.cp === newVal)
|
|
|
- nav && nav.to && this.$router.push(nav.to)
|
|
|
- }
|
|
|
+ language: state => state.language.current
|
|
|
+ })
|
|
|
},
|
|
|
mounted () {
|
|
|
- this.scrollHandle = () => {
|
|
|
- this.overb = (window.scrollY || window.pageYOffset) > 0
|
|
|
+ this.sizeHandle = () => {
|
|
|
+ this.split = getPosition(this.$refs.list).x
|
|
|
}
|
|
|
- window.addEventListener('scroll', this.scrollHandle)
|
|
|
- this.$bus.$on('nav_over', () => {
|
|
|
- clearTimeout(this.timeout)
|
|
|
- })
|
|
|
- this.$bus.$on('nav_out', () => {
|
|
|
- let index = this.navs.findIndex(nav => nav.cp === this.cp)
|
|
|
- ~index && this.$store.commit('change_nav', '')
|
|
|
- })
|
|
|
+ window.addEventListener('resize', this.sizeHandle)
|
|
|
+ setTimeout(this.sizeHandle, 300)
|
|
|
},
|
|
|
- beforeDestroy () {
|
|
|
- window.removeEventListener('scroll', this.scrollHandle)
|
|
|
+ destroyed () {
|
|
|
+ window.removeEventListener('resize', this.sizeHandle)
|
|
|
},
|
|
|
components: {vcenter}
|
|
|
}
|
|
|
</script>
|
|
|
|
|
|
<style lang="scss" scoped>
|
|
|
-@import './style.scss';
|
|
|
+@import './istyle.scss';
|
|
|
</style>
|