|
|
<template> <div class="homepage"> <!-- <BackToHomeButton /> --> <!-- 顶部主图背景 --> <!-- <div class="main-icon"></div> -->
<img class="main-icon" :src="robot" alt="AI小财神" /> <!-- 按钮区域 --> <div class="buttons-container"> <!-- 第一行:夺宝奇兵模块和AI情绪模块 --> <div class="first-row"> <div class="btn-item" @click="goToDBQBmodel" ref="topLeftBtn"> <div class="btn-icon btn-dbqb"></div> <div class="btn-ball"></div> <div class="btn-text btn-text-dbqb"></div> </div>
<div class="btn-item" @click="goToEmotionsmodel" ref="topRightBtn"> <div class="btn-icon btn-ai"></div> <div class="btn-ball"></div> <div class="btn-text btn-text-ai"></div> </div> </div> <!-- 连接线SVG --> <svg class="connection-lines" ref="svgContainer" width="100%" height="100px" preserveAspectRatio="none"> <!-- 连接线上面两个模块到下面模块的曲线 --> <path v-if="pathData.leftPath" :d="pathData.leftPath" class="connection-line" /> <path v-if="pathData.rightPath" :d="pathData.rightPath" class="connection-line" /> </svg> <!-- 第二行:深度九大模型模块 --> <div class="second-row"> <div class="btn-item" @click="goToDeepNineModel" ref="bottomBtn"> <div class="btn-icon btn-deepnine"></div> <div class="btn-ball"></div> <div class="btn-text btn-text-deepnine"></div> </div> </div> </div>
<!-- 底部口号与说明 --> <div class="footer-wrapper"> <div class="footer-text1"></div> <div class="footer-text2"></div> </div> </div> </template>
<script setup> import { onMounted, ref, reactive, nextTick } from "vue"; import { useRouter } from "vue-router"; import { setHeight } from "@/utils/setHeight"; import { useDataStore } from "@/store/dataList.js"; const { getQueryVariable, setActiveTabIndex, getUserInfo } = useDataStore(); import robot from "@/assets/img/Selectmodel/机器人 拷贝.png"; import BackToHomeButton from "@/views/components/BackToHomeButton.vue"; import { useAppBridge } from "@/assets/js/useAppBridge.js"; const router = useRouter(); const pageRef = ref(null);
// 添加引用
const topLeftBtn = ref(null); const topRightBtn = ref(null); const bottomBtn = ref(null); const svgContainer = ref(null);
// 路径数据
const pathData = reactive({ leftPath: '', rightPath: '' });
onMounted(() => { // setHeight(pageRef.value)
const isPhone = /phone|pad|pod|iPhone|iPod|ios|iPad|Android|Mobile|BlackBerry|IEMobile|MQQBrowser|JUC|Fennec|wOSBrowser|BrowserNG|WebOS|Symbian|Windows Phone/i.test( navigator.userAgent );
!isPhone && localStorage.setItem( "localToken", decodeURIComponent(String(getQueryVariable("token"))) ); fnGetToken() // localStorage.setItem(
// "localToken",
// "pCtw6AYK0EHAaIexoFHsbZjtsfEAIhcmwkCFm6uKko8VPfMvyDiODL9v9c0veic9fIpQbvT8zN4sH/Si6Q"
// );
getUserInfo(); // 计算连接线路径
calculatePaths(); // 窗口大小改变时重新计算
window.addEventListener('resize', calculatePaths); });
// 获取元素中心点位置
const getElementCenter = (el) => { if (!el) return { x: 0, y: 0 }; const rect = el.getBoundingClientRect(); const containerRect = svgContainer.value.getBoundingClientRect(); return { x: rect.left + rect.width / 2 - containerRect.left, y: rect.top + rect.height / 2 - containerRect.top }; };
// 计算SVG路径
const calculatePaths = () => { nextTick(() => { if (!topLeftBtn.value || !topRightBtn.value || !bottomBtn.value || !svgContainer.value) { return; } const topLeft = getElementCenter(topLeftBtn.value); const topRight = getElementCenter(topRightBtn.value); const bottom = getElementCenter(bottomBtn.value); // 计算控制点(用于创建曲线效果)
const leftControlX = (topLeft.x + bottom.x) / 2; const leftControlY = (topLeft.y + bottom.y) / 2 - 30; const rightControlX = (topRight.x + bottom.x) / 2; const rightControlY = (topRight.y + bottom.y) / 2 - 30; // 创建路径字符串
pathData.leftPath = `M ${topLeft.x} ${topLeft.y} Q ${leftControlX} ${leftControlY} ${bottom.x} ${bottom.y}`; pathData.rightPath = `M ${topRight.x} ${topRight.y} Q ${rightControlX} ${rightControlY} ${bottom.x} ${bottom.y}`; }); };
// 获取token的核心函数
const fnGetToken = () => { console.log('进入fnGetToken') window.JWready = (ress) => { console.log('进入JWready') try { ress = JSON.parse(ress); // console.log(ress, 'ress')
} catch (error) { console.log(error, "fnGetToken error"); } //platform为5是app端
// platform.value = ress.data.platform
// 处理平台判断
console.log(ress.data.platform, "ress.data.platform"); if (!ress.data.platform) { // 非App环境通过URL参数获取
localStorage.setItem( "localToken", decodeURIComponent(String(getQueryVariable("token"))) ); // localStorage.setItem('localToken', "+SsksARQgUHIbIG3rRnnbZi0+fEeMx8pywnIlrmTxo5EOPR/wjWDV7w7+ZUseiBtf9kFa/atmNx6QfSpv5w")
} else { // App环境通过桥接获取
useAppBridge().packageFun( "JWgetStorage", (response) => { const res = JSON.parse(response); // 解析返回的结果
localStorage.setItem("localToken", res.data); // localStorage.setItem('localToken', "+SsksARQgUHIbIG3rRnnbZi0+fEeMx8pywnIlrmTxo5EOPR/wjWDV7w7+ZUseiBtf9kFa/atmNx6QfSpv5w")
}, 5, { key: "token", } ); } }; // console.log('出来了')
// 触发App桥接
useAppBridge().packageFun("JWwebReady", () => {}, 5, {}); };
const goToDBQBmodel = () => { router.push("/DBQBmodel"); }; const goToEmotionsmodel = () => { router.push("/Emotionsmodel"); }; const goToDeepNineModel = () => { router.push("/DeepNineModel"); }; </script>
<style scoped> .homepage { background-image: url("@/assets/img/Selectmodel/bg.png"); background-size: 100% 100%; background-position: center; background-repeat: no-repeat; width: 100vw; height: 100vh; /* min-height: 100vh; */ /* overflow-x: hidden; */ display: flex; flex-direction: column; align-items: center; /* box-sizing: border-box; text-align: center; */ background-attachment: fixed; justify-content: center; }
.main-icon { max-width: 350px; width: 28vw; /* max-width: 280px; */ height: auto; position: absolute; top: 20vh; }
/* ===== 默认(PC端)按钮区域 ===== */ .buttons-container { margin-top: 4vh; position: absolute; z-index: 5; width: 100%; display: flex; flex-direction: column; align-items: center; }
.connection-lines { width: 60vw; height: 100px; position: relative; z-index: 1; margin: 0 auto; }
.connection-line { stroke: #409eff; stroke-width: 2; fill: none; stroke-dasharray: 5, 5; animation: dash 1s linear infinite; }
@keyframes dash { to { stroke-dashoffset: -10; } }
/* 第一行:夺宝奇兵模块和AI情绪模块 */ .first-row { display: flex; justify-content: center; gap: 30vw; margin-bottom: 0; position: relative; z-index: 2; }
/* 第二行:深度九大模型模块 */ .second-row { display: flex; justify-content: center; position: relative; z-index: 2; margin-top: -30px; }
.btn-item { position: relative; display: flex; flex-direction: column; align-items: center; width: 90vw; max-width: 200px; cursor: pointer; animation: breathing 1.5s ease-in-out infinite; }
/* 呼吸动效关键帧 */ @keyframes breathing { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.02); } }
.btn-icon { /* height: 80px; width: 100%; */ background-size: contain; background-repeat: no-repeat; background-position: center; }
.btn-dbqb { height: 150px; width: 100%; background-image: url("@/assets/img/Selectmodel/-s-夺宝奇兵logo.png"); scale: 0.8; }
.btn-ai { height: 150px; width: 100%; background-image: url("@/assets/img/Selectmodel/金轮 拷贝.png"); z-index: 3; }
.btn-deepnine { height: 150px; width: 100%; background-image: url("https://d31zlh4on95l9h.cloudfront.net/images/35bf808538183be0062e4647570a9abd.png"); z-index: 3; }
.btn-ball { height: 150px; width: 150%; margin-top: -30px; background-image: url("@/assets/img/Selectmodel/球.png"); background-size: contain; background-repeat: no-repeat; background-position: center; position: relative; }
.btn-text { height: 200px; width: 150%; position: absolute; bottom: -20px; left: 50%; transform: translateX(-50%); background-size: contain; background-repeat: no-repeat; background-position: center; }
.btn-text-dbqb { background-image: url("@/assets/img/Selectmodel/-s-夺宝奇兵大模型.png"); }
.btn-text-ai { background-image: url("@/assets/img/Selectmodel/-s-AI情绪大模型.png"); }
.btn-text-deepnine { background-image: url("https://d31zlh4on95l9h.cloudfront.net/images/203dc0bcf1ae5d7187412a864a3263ee.png"); }
/* ===== 底部口号区域 ===== */ .footer-wrapper { /* margin-top: 6vh; */ display: flex; flex-direction: column; align-items: center; gap: 5vh; position: absolute; bottom: 20px; }
.footer-text1 { /* width: 200vw; */ /* max-width: 200vw; */ height: 6vw; background-image: url("@/assets/img/Selectmodel/智能体 拷贝.png"); background-size: 100% 100%; background-size: contain; background-repeat: no-repeat; background-position: center; width: 100vw; }
.footer-text2 { width: 70vw; max-width: 360px; height: 30px; /* margin-bottom: 60px; */ background-image: url("@/assets/img/Selectmodel/-s-弘历团队.png"); background-size: contain; background-repeat: no-repeat; background-position: center; }
/* 手机适配 */ @media screen and (max-width: 768px) { .homepage { background-image: url("@/assets/img/Selectmodel/手机bg.png"); /* height: auto; */ /* 解决底部留白 */ /* width: 100%; */ min-height: 100%; background-size: 100% 100%; overflow-x: hidden; }
.main-icon { background-image: url("@/assets/img/Selectmodel/机器人手机.png"); width: 70%; height: auto; background-repeat: no-repeat; background-size: 100% 100%; }
.buttons-container { margin-top: 8rem; position: relative; width: 100%; } .connection-lines { width: 80vw; height: 80px; } .connection-line { stroke-width: 1.5; } .first-row { gap: 10vw; margin-bottom: 0; } .second-row { margin-top: -20px; } /* 手机端倒三角布局 */ .buttons-container .btn-item:nth-child(2), .buttons-container .btn-item:nth-child(3) { margin-top: 0; } .buttons-container .btn-item:nth-child(2) { align-self: flex-end; } .buttons-container .btn-item:nth-child(3) { margin-left: 10vw; align-self: flex-start; margin-top: -150px; /* 负值使第三个按钮与第二个按钮在同一行 */ } .buttons-container .btn-item:first-child { margin-top: 8vh; align-self: center; }
.btn-item { width: 40vw; display: flex; flex-direction: column; align-items: center; position: relative; padding-bottom: 20px; }
.btn-icon { height: 80px; margin-bottom: -10px; }
.btn-ball { height: 80px; margin-top: -10px; position: relative; z-index: 1; }
.btn-text { position: absolute; bottom: 45px; width: 90%; height: 40px; z-index: 2; }
.footer-text1 { background-image: url("@/assets/img/Selectmodel/智能体.png"); width: 100vw; height: 10vw; margin-top: 10px; background-size: 100% 100%; /* 保证全宽显示 */ }
.footer-text2 { width: 70vw; margin-top: 10px; }
.footer-wrapper{ gap: 0; }
}
/* 平板适配 */ /* @media screen and (min-width: 769px) and (max-width: 1024px) { .homepage { background-image: url("@/assets/img/Selectmodel/手机bg.png"); }
.btn-item { padding-top: 20px; width: 300vw; position: relative; }
.buttons-container { gap: 30vw; margin-top: 5vh; }
.btn-icon, .btn-ball { height: 100px; width: 300px; }
.btn-text { height: 90px; width: 100%; top: 70%; left: 50%; transform: translate(-50%, -50%); } } */ </style>
|