<template>
  <div class="gyq_container">
    <div class="item_wrap">
      <div class="title">您好，欢迎登录</div>
      <div class="item_list">
        <div class="item" v-for="(item, index) in quickStore.quickMenus" :key="item.id" @click="menuClick(item.menuId)">
          <img class="icon" :src="icons[index + 1]" alt="">
          {{ returnMenuName(item.menuId) }}
        </div>
      </div>
    </div>
  </div>
</template>

<script setup>
import { onMounted, nextTick } from "vue";
import { useQuickStore, usePermissionStore, useUserStore } from "@/store";

import icon1 from "@/assets/index_quick1.png";
import icon2 from "@/assets/index_quick2.png";
import icon3 from "@/assets/index_quick3.png";
import icon4 from "@/assets/index_quick4.png";
import icon5 from "@/assets/index_quick5.png";
import icon6 from "@/assets/index_quick6.png";

const icons = {
  1: icon1,
  2: icon2,
  3: icon3,
  4: icon4,
  5: icon5,
  6: icon6,
};

const userStore = useUserStore();
const quickStore = useQuickStore();
const permissionStore = usePermissionStore();

function returnMenuName(menuId) {
  return permissionStore.returnMenuName(menuId);
}

function menuClick(menuId) {
  permissionStore.menuJump(menuId);
}

onMounted(async () => {
  await nextTick();
  console.log('quickStore.quickMenus', quickStore.quickMenus);
})
</script>

<style scoped lang="scss">
.gyq_container {
  width: 100%;
  height: 100%;
  background: url('@/assets/index_bg.png') no-repeat center center / cover;
  display: flex;
  align-items: center;
  padding-bottom: 50px;
}

.item_wrap {
  padding-left: 300px;

  .title {
    font-size: 40px;
    margin-bottom: 50px;
    font-weight: bold;
  }

  .item_list {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: repeat(2, 1fr);
    grid-column-gap: 90px;
    grid-row-gap: 90px;

    .item {
      width: 152px;
      height: 83px;
      border-radius: 20px;
      background: linear-gradient(115deg, #9EC4FF 5.9%, #6668E8 111.62%);
      position: relative;
      display: flex;
      align-items: center;
      justify-content: center;
      font-size: 16px;
      color: #fff;
      padding-left: 30px;

      &:hover {
        cursor: pointer;

        .icon {
          transform: translateY(-10px);
        }
      }

      .icon {
        position: absolute;
        left: -30px;
        top: -20px;
        width: 83px;
        height: 78px;
        transition: all 0.3s ease-in-out;
      }
    }
  }
}
</style>