<template>
  <div id="home">
    <div class="title">
      <div class="logo"></div>
      <div class="fontSize">
        <div class="fontLogo"></div>
      </div>
    </div>
    <div class="list_box">
      <div class="list">
        <div v-for="(item, index) in list" class="item" @click="openUrl(item)">
          <div><img :src="item.img" /></div>
          <div>{{ item.name }}</div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
  import { getList } from '@/api/home';
  export default {
    data() {
      return {
        list: []
      };
    },
    created() {
      this.getPages();
    },
    methods: {
      openUrl(item) {
        let url = window.open('https://' + item.linkUrl, '_blank');
      },
      async getPages() {
        let { list } = await getList({ pageNum: 1, size: 9999 });
        this.list = list.map((item) => {
          return {
            ...item,
            img:
              window.location.origin +
              '/api/main/file/getFile?objectName=' +
              item.iconPath
          };
        });
      }
    }
  };
</script>

<style lang="scss" scoped>
  @font-face {
    font-family: '优设标题黑';
    src: url('@/assets/font_icon/优设标题黑.ttf');
  }
  #home {
    height: calc(100vh - 96px);
    width: 100%;
    display: flex;
    flex-direction: column;
    background: url('@/assets/boxBg.png');
    background-size: 100% 100%;
    background-repeat: no-repeat;
    .title {
      flex: 2;
      display: flex;
      justify-content: center;
      align-items: center;
      position: relative;
      .fontSize {
        margin-top: 7rem;
        .fontLogo {
          width: 25vw;
          aspect-ratio: 9.7/1;
          background: url('@/assets/fontTitle.png');
          background-size: 100% 100%;
          background-repeat: no-repeat;
        }
      }
      .logo {
        position: absolute;
        left: 30px;
        top: 30px;
        width: 14vw;
        aspect-ratio: 5.6/1;
        // background: url('@/assets/cglogo.png');
        // background-size: 100% 100%;
        // background-repeat: no-repeat;
      }
    }
    .list_box {
      flex: 4;
      .list {
        padding: 10px;
        box-sizing: border-box;
        display: flex;
        justify-content: center;
        .item {
          background: url('@/assets/bg.png');
          background-repeat: no-repeat;
          background-size: 100% 100%;
          display: inline-block;
          width: 10vw;
          aspect-ratio: 0.7/1;
          padding: 10px;
          box-sizing: border-box;
          margin-right: 2rem;
          border-radius: 5px;
          cursor: pointer;
          display: flex;
          flex-direction: column;
          > div:first-child {
            flex: 1;
            display: flex;
            align-items: center;
            justify-content: center;
            > img {
              width: 100%;
              aspect-ratio: 16/16;
            }
          }
          > div:last-child {
            flex: 1;
            font-family: '优设标题黑';
            color: #1383f1;
            font-size: 2.8rem;
            display: flex;
            align-items: center;
            justify-content: center;
          }
        }
        .margin_0 {
          margin-right: 0;
        }
      }
    }
  }
</style>
