You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

200 lines
4.4 KiB

2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
  1. <template>
  2. <div ref="pageRef" class="homepage">
  3. <!-- 顶部图标 -->
  4. <img class="top-icon" :src="topIcon" alt="顶部图标" />
  5. <!-- 中间图示及说明 -->
  6. <div class="bottom-icon">
  7. <div class="content-container">
  8. <!-- 副标题 - 只在屏幕宽度小于等于1024px时显示 -->
  9. <img
  10. v-if="screenWidth <= 1024"
  11. class="sub-title"
  12. :src="subtitle"
  13. alt="四维作战体系"
  14. />
  15. <!-- 内容图 - 根据屏幕宽度动态切换 -->
  16. <img class="content-icon" :src="currentContentIcon" alt="四维情绪" />
  17. </div>
  18. <!-- 按钮区域 -->
  19. <div class="buttons-container">
  20. <button class="btn-item" @click="goToAiEmotion">
  21. <img :src="btnIcon" alt="开启财运" />
  22. </button>
  23. </div>
  24. </div>
  25. </div>
  26. </template>
  27. <script setup>
  28. import { onMounted, ref, computed, onUnmounted } from "vue";
  29. import { useRouter } from "vue-router";
  30. // 移除背景图片的导入,改用CSS设置
  31. import topIcon from "@/assets/img/Emotionsmodel/大标题.png";
  32. import subtitle from "@/assets/img/Emotionsmodel/-s-标题 拷贝.png";
  33. import conteniconLarge from "@/assets/img/Emotionsmodel/_s_四维 拷贝.png";
  34. import conteniconSmall from "@/assets/img/Emotionsmodel/-s-四维.png";
  35. import btnIcon from "@/assets/img/Emotionsmodel/-s-开启财运.png";
  36. import { setHeight } from "@/utils/setHeight";
  37. const router = useRouter();
  38. const pageRef = ref(null);
  39. const screenWidth = ref(window.innerWidth);
  40. // 根据屏幕宽度选择内容图片
  41. const currentContentIcon = computed(() => {
  42. return screenWidth.value > 1024 ? conteniconLarge : conteniconSmall;
  43. });
  44. const handleResize = () => {
  45. screenWidth.value = window.innerWidth;
  46. };
  47. onMounted(() => {
  48. setHeight(pageRef.value);
  49. window.addEventListener("resize", handleResize);
  50. });
  51. onUnmounted(() => {
  52. window.removeEventListener("resize", handleResize);
  53. });
  54. const goToAiEmotion = () => {
  55. // 设置 sessionStorage 控制 homepage.vue 激活 AiEmotion tab
  56. sessionStorage.setItem("activeTabAI", "AiEmotion");
  57. sessionStorage.setItem("activeIndexAI", "1");
  58. router.push("/homePage");
  59. };
  60. </script>
  61. <style scoped>
  62. .homepage {
  63. min-height: 100vh;
  64. background-image: url("@/assets/img/DBQBmodel/电脑背景.png");
  65. background-size: cover;
  66. background-position: center;
  67. background-repeat: no-repeat;
  68. display: flex;
  69. flex-direction: column;
  70. justify-content: space-evenly;
  71. align-items: center;
  72. }
  73. /* 顶部图标 */
  74. .top-icon {
  75. width: 20vw;
  76. min-width: 300px;
  77. height: auto;
  78. position: absolute;
  79. top: 10vh;
  80. }
  81. .bottom-icon {
  82. display: flex;
  83. flex-direction: column;
  84. align-items: center;
  85. position: absolute;
  86. bottom: 0vh;
  87. }
  88. /* 四维体系整体容器修复 */
  89. .content-container {
  90. display: flex;
  91. flex-direction: column;
  92. justify-content: center;
  93. align-items: center;
  94. width: 80%;
  95. height: auto;
  96. }
  97. /* 副标题 */
  98. .sub-title {
  99. width: 90%;
  100. max-width: 480px;
  101. height: auto;
  102. margin-top: 30px;
  103. }
  104. /* 内容图 */
  105. .content-icon {
  106. width: 100%;
  107. height: auto;
  108. }
  109. /* 按钮区域 */
  110. .buttons-container {
  111. margin-top: auto;
  112. margin-bottom: 3vh;
  113. display: flex;
  114. justify-content: center;
  115. align-items: center;
  116. width: 100%;
  117. }
  118. .btn-item {
  119. background: none;
  120. border: none;
  121. cursor: pointer;
  122. transition: transform 0.3s ease;
  123. }
  124. .btn-item:hover {
  125. transform: scale(1.05);
  126. }
  127. .btn-item img {
  128. width: 60%;
  129. height: auto;
  130. }
  131. @media (max-width: 1024px) {
  132. /* 四维体系整体容器修复 */
  133. .content-container {
  134. width: 60%;
  135. height: auto;
  136. }
  137. }
  138. /* 手机适配 */
  139. @media (max-width: 768px) {
  140. .homepage {
  141. min-height: 100vh;
  142. background-image: url("@/assets/img/DBQBmodel/手机背景.png");
  143. background-size: cover;
  144. background-position: center;
  145. background-repeat: no-repeat;
  146. display: flex;
  147. flex-direction: column;
  148. justify-content: space-evenly;
  149. align-items: center;
  150. }
  151. .top-icon {
  152. width: 80vw;
  153. margin-top: -1vh;
  154. }
  155. .sub-title {
  156. width: 95%;
  157. margin-top: -2vh;
  158. }
  159. /* 四维体系整体容器修复 */
  160. .content-container {
  161. width: 80%;
  162. height: auto;
  163. }
  164. .content-icon {
  165. width: 87%;
  166. }
  167. .buttons-container {
  168. margin-top: 4vh;
  169. margin-bottom: 4vh;
  170. }
  171. .btn-item img {
  172. width: 50%;
  173. height: auto;
  174. }
  175. }
  176. </style>