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.

294 lines
6.8 KiB

3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
  1. <template>
  2. <div ref="pageRef" class="homepage">
  3. <BackToHomeButton />
  4. <!-- 顶部图标 -->
  5. <img class="top-icon" :src="topIcon" alt="顶部图标" />
  6. <!-- 中间图示及说明 -->
  7. <div class="bottom-icon">
  8. <div class="content-container">
  9. <!-- 副标题 - 只在屏幕宽度小于等于1024px时显示 -->
  10. <img
  11. v-if="screenWidth <= 1024"
  12. class="sub-title"
  13. :src="subtitle"
  14. alt="四维作战体系"
  15. />
  16. <!-- 内容图 - 根据屏幕宽度动态切换 -->
  17. <img class="content-icon" :src="currentContentIcon" alt="四维情绪" />
  18. </div>
  19. <!-- 按钮区域 -->
  20. <div class="buttons-container">
  21. <button class="btn-item" @click="goToAiEmotion">
  22. <img :src="btnIcon" alt="开启财运" />
  23. </button>
  24. </div>
  25. </div>
  26. </div>
  27. <div v-if="noPermissonDialogVisible" class="noPermissionDialog">
  28. <div class="noPermissionContent" @click="closeNoPermissionDialog">
  29. <div class="noPermissionCloseBtn">
  30. <el-icon class="noPermissionIcon"><Close /></el-icon>
  31. </div>
  32. {{ noPermissonDialogObj.msg }}
  33. </div>
  34. </div>
  35. </template>
  36. <script setup>
  37. import { onMounted, ref, computed, onUnmounted } from "vue";
  38. import { useRouter } from "vue-router";
  39. // 移除背景图片的导入,改用CSS设置
  40. import topIcon from "@/assets/img/Emotionsmodel/大标题.png";
  41. import subtitle from "@/assets/img/Emotionsmodel/-s-标题 拷贝.png";
  42. import conteniconLarge from "@/assets/img/Emotionsmodel/_s_四维 拷贝.png";
  43. import conteniconSmall from "@/assets/img/Emotionsmodel/-s-四维.png";
  44. import btnIcon from "@/assets/img/Emotionsmodel/-s-开启财运.png";
  45. import { setHeight } from "@/utils/setHeight";
  46. import { checkStatusAPI } from "../api/AIxiaocaishen";
  47. import BackToHomeButton from "@/views/components/BackToHomeButton.vue";
  48. const router = useRouter();
  49. const pageRef = ref(null);
  50. const screenWidth = ref(window.innerWidth);
  51. // 根据屏幕宽度选择内容图片
  52. const currentContentIcon = computed(() => {
  53. return screenWidth.value > 1024 ? conteniconLarge : conteniconSmall;
  54. });
  55. const handleResize = () => {
  56. screenWidth.value = window.innerWidth;
  57. };
  58. onMounted(() => {
  59. setHeight(pageRef.value);
  60. window.addEventListener("resize", handleResize);
  61. });
  62. onUnmounted(() => {
  63. window.removeEventListener("resize", handleResize);
  64. });
  65. const noPermissonDialogVisible = ref(false);
  66. const noPermissonDialogObj = ref({});
  67. const goToAiEmotion = async () => {
  68. try {
  69. let params = {
  70. token: localStorage.getItem("localToken"),
  71. model: 2,
  72. };
  73. const userAgent = navigator.userAgent;
  74. let isMobile =
  75. /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(
  76. userAgent
  77. );
  78. let Client = "pc";
  79. if (isMobile) {
  80. if (/iPhone|iPad|iPod/i.test(userAgent)) {
  81. Client = "ios";
  82. } else if (/Android/i.test(userAgent)) {
  83. Client = "android";
  84. } else {
  85. Client = "android"; // 其他移动设备
  86. }
  87. }
  88. let headers = {
  89. Client: Client,
  90. };
  91. const res = await checkStatusAPI(headers, params);
  92. if (res.code == 200) {
  93. // 设置 sessionStorage 控制 homepage.vue 激活 AiEmotion tab
  94. sessionStorage.setItem("activeTabAI", "AiEmotion");
  95. sessionStorage.setItem("activeIndexAI", "1");
  96. router.push("/homePage");
  97. } else {
  98. console.log("无权限");
  99. noPermissonDialogVisible.value = true;
  100. noPermissonDialogObj.value.msg = res.msg;
  101. console.log("noPermissonDialogVisible", noPermissonDialogVisible.value);
  102. console.log("noPermissonDialogObj", noPermissonDialogObj.value);
  103. }
  104. } catch (e) {
  105. console.error("获取权限失败", e);
  106. }
  107. };
  108. const closeNoPermissionDialog = () => {
  109. noPermissonDialogVisible.value = false;
  110. };
  111. </script>
  112. <style scoped>
  113. .homepage {
  114. min-height: 100vh;
  115. background-image: url("@/assets/img/DBQBmodel/电脑背景.png");
  116. background-size: cover;
  117. background-position: center;
  118. background-repeat: no-repeat;
  119. display: flex;
  120. flex-direction: column;
  121. justify-content: space-evenly;
  122. align-items: center;
  123. }
  124. /* 顶部图标 */
  125. .top-icon {
  126. width: 20vw;
  127. min-width: 300px;
  128. height: auto;
  129. position: absolute;
  130. top: 10vh;
  131. }
  132. .bottom-icon {
  133. display: flex;
  134. flex-direction: column;
  135. align-items: center;
  136. position: absolute;
  137. bottom: 0vh;
  138. }
  139. /* 四维体系整体容器修复 */
  140. .content-container {
  141. display: flex;
  142. flex-direction: column;
  143. justify-content: center;
  144. align-items: center;
  145. width: 80%;
  146. height: auto;
  147. }
  148. /* 副标题 */
  149. .sub-title {
  150. width: 90%;
  151. max-width: 480px;
  152. height: auto;
  153. margin-top: 30px;
  154. }
  155. /* 内容图 */
  156. .content-icon {
  157. width: 100%;
  158. height: auto;
  159. }
  160. /* 按钮区域 */
  161. .buttons-container {
  162. margin-top: auto;
  163. margin-bottom: 3vh;
  164. display: flex;
  165. justify-content: center;
  166. align-items: center;
  167. width: 100%;
  168. }
  169. .btn-item {
  170. background: none;
  171. border: none;
  172. cursor: pointer;
  173. transition: transform 0.3s ease;
  174. }
  175. .btn-item:hover {
  176. transform: scale(1.05);
  177. }
  178. .btn-item img {
  179. width: 60%;
  180. height: auto;
  181. }
  182. .noPermissionDialog {
  183. width: 100%;
  184. display: flex;
  185. justify-content: center;
  186. align-items: center;
  187. position: fixed;
  188. bottom: 15%;
  189. /* margin: auto auto; */
  190. color: white;
  191. }
  192. .noPermissionCloseBtn {
  193. border-radius: 5px;
  194. border: 1px solid white;
  195. background-color: #8621d9;
  196. padding: 2px;
  197. display: flex;
  198. justify-content: center;
  199. align-items: center;
  200. position: absolute;
  201. top: -10px;
  202. right: -10px;
  203. }
  204. .noPermissionContent {
  205. position: relative;
  206. border-radius: 5px;
  207. border: 1px solid white;
  208. padding: 10px 30px;
  209. background-color: #261176;
  210. display: flex;
  211. justify-content: center;
  212. align-items: center;
  213. }
  214. @media (max-width: 1024px) {
  215. /* 四维体系整体容器修复 */
  216. .content-container {
  217. width: 60%;
  218. height: auto;
  219. }
  220. }
  221. /* 手机适配 */
  222. @media (max-width: 768px) {
  223. .homepage {
  224. min-height: 100vh;
  225. background-image: url("@/assets/img/DBQBmodel/手机背景.png");
  226. background-size: cover;
  227. background-position: center;
  228. background-repeat: no-repeat;
  229. display: flex;
  230. flex-direction: column;
  231. justify-content: space-evenly;
  232. align-items: center;
  233. }
  234. .top-icon {
  235. width: 80vw;
  236. margin-top: -1vh;
  237. }
  238. .sub-title {
  239. width: 95%;
  240. margin-top: -2vh;
  241. }
  242. /* 四维体系整体容器修复 */
  243. .content-container {
  244. width: 80%;
  245. height: auto;
  246. }
  247. .content-icon {
  248. width: 87%;
  249. }
  250. .buttons-container {
  251. margin-top: 4vh;
  252. margin-bottom: 4vh;
  253. }
  254. .btn-item img {
  255. width: 50%;
  256. height: auto;
  257. }
  258. }
  259. </style>