<script setup>
import { onMounted, ref } from 'vue'
import { useRouter } from 'vue-router'
import bgImage from '@/assets/img/homePage/bk.png'
import topIcon from '@/assets/img/homePage/AIicon.png'
import btnIcon from '@/assets/img/homePage/count-box.png'
import { setHeight } from '@/utils/setHeight'

const router = useRouter()
const pageRef = ref(null)

onMounted(() => {
    setHeight(pageRef.value)
})

const goToHomePage = () => {
    router.push('/homepage')  // 修改为实际路由
}
</script>

<template>
    <div ref="pageRef" class="homepage" :style="{ backgroundImage: `url(${bgImage})` }">
        <!-- 顶部图标 -->
        <img class="top-icon" :src="topIcon" alt="顶部图标" />
        <!-- 主标题 -->
        <div class="main-title">夺宝奇兵大模型</div>
        <!-- 副标题 -->
        <div class="sub-title">构建场景化交易</div>
        <!-- 中间文字 -->
        <div class="footer-text">
            数据可计算<br />
            场景可演绎<br />
            交易可掌控<br />
        </div>

        <!-- 底部按钮 -->
        <div class="buttons-container">
  <button class="btn-item" @click="goToHomePage">
    <img src="src\assets\img\homePage\count-box.png" alt="按钮图片" />
    <span class="btn-text">开启财运</span>
  </button>
</div>

    </div>
</template>

<style scoped>
.homepage {
    width: 100vw;
    height: 100vh;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;

    /* 使用flex布局，居中内容 */
    display: flex;
    flex-direction: column;
    justify-content: center;
    /* 居中内容 */
    align-items: center;
    /* 水平对齐 */
    color: white;
    text-align: center;
    box-sizing: border-box;
    padding: 0 20px;
}

/* 顶部图标 - 向上调整 */
.top-icon {
    width: 140px;
    height: 140px;
    margin-top: 50px;
    /* 向上调整图标位置 */
}

/* 主标题 */
.main-title {
    margin-top: 1.5rem;
    font-size: 4rem;
    font-weight: bold;
    text-align: center;
    letter-spacing: 7px;
}

/* 副标题 */
.sub-title {
    font-size: 3.1rem;
    font-weight: 500;
    margin-top: 0.5rem;
    font-weight: bold;
    letter-spacing: 5px;
}

/* 中间文字 */
.footer-text {
    font-size: 40px;
    line-height: 1.6;
    max-width: 320px;
    margin-top: 3%;
    white-space: pre-line;
    user-select: none;
    text-align: center;
    font-weight: bold;
    line-height: 4.5rem;
}

/* 按钮容器 */
.buttons-container {
  width: 100%;
  display: flex;
  justify-content: center;
  margin-top: 100px; /* 向下移动按钮 */
}

/* 按钮样式 */
.btn-item {
  position: relative;
  background-color: transparent;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  text-align: center;
  padding: 20px;
}

/* 按钮图标 */
.btn-item img {
  width: 160px; /* 调整按钮图片大小 */
  height: 200%;
}

/* 按钮文字 */
.btn-text {
  position: absolute;
  font-size: 30px; /* 设置文字大小 */
  color: #eccf27; /* 设置黄色字体 */
  font-weight: bold;
  letter-spacing: 2px; /* 设置字母间距 */
  text-align: center; /* 文字居中 */
  z-index: 1; /* 确保文字显示在按钮图片上 */
}
/* 响应式 - 手机 */
@media screen and (max-width: 600px) {
    .top-icon {
        width: 100px;
        height: 100px;
        margin-bottom: 20px;
    }

    .main-title {
        font-size: 40px;
    }

    .sub-title {
        font-size: 30px;
        margin-top: 0.5rem;
    }

    .footer-text {
        font-size: 30px;
        max-width: 260px;
        margin-top: 40px;
        line-height: 3.5rem;
    }

     .btn-item img {
    width: 130px;
  }

  .btn-text {
    font-size: 24px; /* 调整手机上的字体大小 */
  }
}

/* 响应式 - 平板 */
@media screen and (min-width: 601px) and (max-width: 1024px) {
    .top-icon {
        width: 120px;
        height: 120px;
        margin-bottom: 25px;
    }

    .footer-text {
        font-size: 40px;
        max-width: 260px;
        margin-top: 40px;
        line-height: 3.5rem;
    }

    .main-title {
        font-size: 40px;
    }

    .sub-title {
        font-size: 35px;
        margin-top: 0.5rem;
    }

     .btn-item img {
    width: 140px;
  }

  .btn-text {
    font-size: 28px; /* 调整平板上的字体大小 */
  }
}
</style>
