<template>
  <div id="visualizationHeader">
    <div class="left-title">
      <span>
         上海市住建行业基础数据应用系统
      </span>
    </div>
    <div class="top-menu">
      <div class="single" :class="[item.chosen?'single_chosen':'']" v-for="item in menuList"  :key="item.id">
        <span @click="changePath(item)">{{item.label}}</span>
      </div>
    </div>
    <div class="right-user">
      <el-icon class="single-icon"><User /></el-icon>
      <span>{{username}}</span>
      <el-icon class="single-icon" @click="logOut"><SwitchButton /></el-icon>
    </div>
  </div>
</template>

<script>
import {ref} from "vue";
import router from "@/router/index.js";
import {useUserStore} from "@/store/userStore.js";
import {User,SwitchButton} from "@element-plus/icons-vue";

export default {
  name: "VisualizationHeader",
  components:{
    User,
    SwitchButton
  },
  setup(){
    let userStore = useUserStore();
    let menuList = ref([
      {
        id:"01",
        name:"mainPage",
        chosen:true,
        label:"首页"
      },
      {
        id:"02",
        name:"houseBuilding",
        chosen:false,
        label:"房屋建筑"
      },
      {
        id:"03",
        name:"municipalFacilities",
        chosen:false,
        label:"市政设施"
      }
    ]);
    let username =ref('');
    username.value = userStore.userInfo.gxjh_username;
    function changePath(item){
      menuList.value.forEach((i)=>{
        if(i.name == item.name){
          i.chosen = true;
          router.push({name:item.name})
        }else{
          i.chosen = false;
        }
      })
    }
    function logOut(){
      userStore.userInfo = {};
      localStorage.setItem('exchangeUserInfo',null);
      window.location.href='https://cimweb.zjw.sh.cegn.cn:2007/cim-home/#/login';
    }
    return {
      logOut,
      menuList,
      changePath,
      username
    }
  }
}
</script>

<style scoped lang="scss">
#visualizationHeader{
  width: 100%;
  height: 87px;
  position: absolute;
  top: 0;
  left: 0;
  z-index: 2;
  background: url("../../assets/imgs/dbtbj.png") no-repeat;
  background-size: 100% 200%;
  display: flex;
  .left-title{
    padding-left: 29px;
    padding-right: 211px;
    display: flex;
    align-items: center;
    span{
      width: 485px;
      font-family: YouSheBiaoTiHei;
      font-weight: 400;
      font-size: 32px;
      color: #FFFFFF;
      text-shadow: 0px 8px 1px rgba(19,80,143,0.1);
      background: linear-gradient(0deg, rgba(119,186,255,1) 0%, rgba(233,248,255,1) 73%, rgba(255,255,255,1) 100%);
      opacity: 0.89;
      -webkit-background-clip: text;
      -webkit-text-fill-color: transparent;
    }
  }
  .top-menu{
    width: 493px;
    height: 80px;
    display: flex;
    justify-content: space-around;
    align-items: flex-start;
    .single{
      width: 163px;
      height: 76px;
      display: flex;
      justify-content: center;
      align-items: center;
      span{
        cursor: pointer;
        font-family: YouSheBiaoTiHei;
        font-weight: 400;
        font-size: 20px;
        color: #BBCDE6;
        opacity: 0.7;
      }
    }
    .single_chosen{
      background: url("../../assets/imgs/mkxz.png") no-repeat;
      background-size: 100% 100%;
      span{
        color: #BBCDE6;
        opacity: 1;
        background: linear-gradient(0deg, #ACE5FF 0%, #FFFFFF 100%);
        -webkit-background-clip: text;
        -webkit-text-fill-color: transparent;
      }
    }
  }
  .right-user{
    position: absolute;
    right: 30px;
    top:10px;
    width: 200px;
    height: 60px;
    display: flex;
    justify-content: center;
    align-items: center;
    color: #ffffff;
    font-size: 18px;
    span{
      padding-left: 6px;
    }
    .single-icon{
      padding-left: 20px;
      cursor: pointer;
    }
  }
}
</style>