<template>
  <div class="container">
    <div class="image">
      <img src="../assets/images/command-center/map.png" />
      <!-- 标记点 -->
      <!--  @mouseenter="handleMouseenter" @mouseleave="handleMouseleave" -->
      <div class="sign" @click="clickBtn">
        <!-- <img src="../assets/images/command-center/marker.png" > -->
        <div class="sign-item"></div>
      </div>
      <!-- 信息窗体 -->
      <div class="information-form" v-if="open">
        <div class="form">
          <div class="form-item" style="height: 30px;" v-for="(item, key) in informationForm" :key="key">
            <span class="label">{{ item.label }}</span>
            <div class="bottom">
              <span class="value" :style="{ fontStyle: item.unit ? 'italic' : '' }">{{ item.value }}</span>
              <span v-if="item.value" class="unit">&nbsp;{{ item.unit }}</span>
            </div>
          </div>
        </div>
      </div>
    </div>
    <LeftThree class="butProcess"/>
  </div>
</template>

<script>
import { listProjectInfo } from '@/assets/js/api/zhongjianFourth'
import LeftThree from './leftThree/index.vue'

export default {
  components: { LeftThree },
  data() {
    return {
      projectSn:"",
      // 信息窗体开关
      open: true,
      // 信息窗体表单
      informationForm: {
        projectName: { label: '项目名称:', value: '' },
        bulidStatus: { label: '项目状态:', value: '' },
        constructionStage: { label: '形象进度:', value: '' },
        households:{label: '户数:', value: ''},
        // val2:{label: '已完成投资:', value: ''},
        projectAcreage: { label: '工程面积:', value: '', unit: '' },
        constructionUnit: { label: '建设单位:', value: ''},
        projectAddress: { label: '项目地址:', value: '' },
      },
      // 项目状态枚举
      projectStatusEnum: {
        0: '未开工',
        1: '在建',
        2: '停工',
        3: '验收',
        4: '完工'
      },
      // 形象进度枚举
      constructionStageEnum: {
        1: '施工证获取',
        2: '土方开挖',
        3: '桩基',
        4: '支护开始',
        5: '垫层完成',
        6: '正负零',
        7: '工程达到预售条件',
        8: '主体施工',
        9: '主体封顶',
        10: '装饰装修',
        11: '景观园林',
        12: '主体交付',
        13: '预售证获取',
        14: '规划验收',
        15: '竣工备案完成'
      }
    }
  },
  created() {
    this.projectSn=localStorage.getItem('sn')
  },
  mounted(){
    this.getList()
  },
  methods: {
    /** 查询数据 */
    getList() {
      listProjectInfo({ projectSn: this.projectSn }).then(res => {
        console.log('项目信息: ', res)
        const informationForm = this.informationForm
        Object.keys(informationForm).forEach(key => {
          
          if (key === 'constructionStage') {
            informationForm[key].value = this.constructionStageEnum[res.result[key]]
          } else if (key === 'bulidStatus') {
            informationForm[key].value = this.projectStatusEnum[res.result[key]]
          } else {
            informationForm[key].value = res.result[key]
          }
        })
      })
    },
    // 标记点 鼠标移入事件
    // handleMouseenter() {
    //   this.open = true
    // },
    // // 标记点 鼠标移出事件
    // handleMouseleave() {
    //   this.open = false
    // },
    clickBtn(){
      this.open = !this.open
    }
  }
}
</script>

<style lang="less" scoped>
.container {
  display: grid;
  place-items: center;
  width: 100%;
  height: 100%;

  .image {
    width: 100%;
    position: relative;
    img {
      width: 100%;
    }

    // 标记点
    .sign {
      position: absolute;
      right: 28%;
      bottom: 15%;

      width: 50px;
      height: 50px;
      cursor: pointer;

      &:hover + .information-form,
      .information-form:hover {
        display: block !important;
      }

      &::before {
        content: '';
        display: block;

        box-sizing: border-box;
        position: absolute;
        left: 50%;
        top: 50%;
        transform: translate(-50%, -50%);
        z-index: 8;
        width: 20px;
        height: 20px;
        background-color: #328e99;
        border-radius: 50%;
        border: 2px solid #ff6700;
        animation: change-small 1.1s ease-in-out infinite;
      }

      &::after {
        content: '';
        display: block;

        box-sizing: border-box;
        position: absolute;
        left: 50%;
        top: 50%;
        transform: translate(-50%, -50%);
        width: 20px;
        height: 20px;
        background-color: #328e99;
        border-radius: 50%;
        border: 2px solid #ff6700;
        animation: change 2.2s ease-in-out infinite;
      }

      .sign-item {
        position: absolute;
        left: 50%;
        top: 50%;
        transform: translate(-50%, -50%);
        z-index: 9;
        width: 20px;
        height: 20px;
        background-color: #ff6700;
        border-radius: 50%;
        &::before {
          content: '';
          display: block;
          position: absolute;
          left: 50%;
          top: 50%;
          transform: translate(-50%, -50%);
          width: 10px;
          height: 10px;
          background-color: #7a5a4e;
          border-radius: 50%;
        }
      }
    }

    @keyframes change-small {
      from {
        width: 20px;
        height: 20px;
        opacity: 0;
      }
      to {
        width: 32px;
        height: 32px;
        opacity: 1;
      }
    }


    @keyframes change {
      from {
        width: 20px;
        height: 20px;
        opacity: 0;
      }
      to {
        width: 45px;
        height: 45px;
        opacity: 1;
      }
    }

    

    // 信息窗体
    .information-form {
      // display: none;
      position: absolute;
      right: 15%;
      top: 35%;
      padding: 20px;
      width: 290px;
      height: 275px;
      font-size: 14px;
      background-color: #44bfc598;
      border: 2px solid #89a483;
      border-radius: 4px;
      transition: all 0.3s;
      .form {
        display: flex;
        flex-direction: column;
        justify-content: space-between;
        height: 100%;
        .form-item {
          display: flex;
          align-items: center;
          padding: 5px 0;
          font-weight: bold;
          .label {
            margin-right: 10px;
            white-space: nowrap;
            color: #002636;
          }

          .bottom {
            color: #000;
          }
        }
      }
    }
  }
  .butProcess{
    margin: 0% 5% 5% 5%;
    // margin-bottom: 5%;
    // margin-right: 5%;
  }
}
</style>