<template>
  <div id="home">
    <div class="top">
        <div class="logo">
            <div class="left">
                <img src="@/assets/images/组 12.png" alt="">
            </div>
            <div class="right">
                <!-- <img src="@/assets/images/组 12.png" alt=""> -->
            </div>
        </div>
        <div class="menu" >
            <div :class="{'item':true, 'active': activeIndex==i}" v-for="(item,i) in menuList" @click="jumpTo(i)">
                {{item.name}}
            </div>
        </div>
        <div class="main-img">
            <img src="@/assets/images/组 10.png" alt="">
        </div>
    </div>
    <router-view/>
    <bottom></bottom>
  </div>
</template>

<script>
import bottom from '@/components/bottom'
export default {
    name: 'HomeView',
    components: {
        bottom
    },
    data(){
        return{
            menuList:[
                {
                    name: '主页',
                    url:'/home'
                },
                {
                    name: '走进中业',
                    url: '/introduce'
                },
                {
                    name: '资讯中心',
                    url: '/information'
                },
                {
                    name: '资质证书',
                    url: '/honor'
                },
                {
                    name: '工程案例',
                    url: '/cases'
                },
                {
                    name: '人才招聘',
                    url: '/recruit'
                },
                {
                    name: '办公入口'
                },
                
            ]
        
        }
    },
    computed:{
        activeIndex(){
            if(this.$route.path=='/home'){
                return 0
            }
            if(this.$route.path=='/introduce'){
                return 1
            }
            if(this.$route.path=='/information'){
                return 2
            }
            if(this.$route.path=='/honor'){
                return 3
            }
            if(this.$route.path=='/cases'){
                return 4
            }
            if(this.$route.path=='/recruit'){
                return 5
            }
        },
    },
    created(){
        if(this.$route.path=='/'){
            this.$router.push('/home')
        }
        
    },
    
    methods:{
        jumpTo(i){
            this.activeIndex = i
            this.$router.push({path: this.menuList[i].url})
        }
    }
}
</script>
<style lang="scss" scoped>
   #home{
        width: 100%;
        .top{
            .logo{
                position: fixed;
                z-index: 999;
                height: 1.25rem;
                width: 100%;
                background-color: #fff;
                display: flex;
                justify-content: space-between;
                align-items: center;
                padding: 0 4.5rem;
                .left{
                    img{
                        width: 3.125rem;
                        height: auto;
                    }
                }
            }
            .menu{
                position: fixed;
                z-index: 999;
                top: 1.25rem;
                width: 100%;
                height: .8rem;
                background-color: #171A89;
                display: flex;
                padding-left: 4.5rem;
                .item{
                    width: 2.125rem;
                    height: 100%;
                    text-align: center;
                    line-height: .8rem;
                    color: #fff;
                    font-size: .25rem;
                    cursor: pointer;
                }
                .active{
                    background-color: #E7000A;
                }

            }
            .main-img{
                img{
                    margin-top: 2.05rem;
                    width: 100%;
                    height: 8.5625rem;
                }
            }
        }
   }
        
</style>
