ios的安装按钮是否出现,用apollo进行配置
This commit is contained in:
parent
2b9bc589fd
commit
6b177c8ed9
44
app/page.jsx
44
app/page.jsx
|
@ -5,9 +5,13 @@ import InOtherApp from "@/components/InOtherApp";
|
||||||
import Footer from "@/components/Footer";
|
import Footer from "@/components/Footer";
|
||||||
import IosInstallStepModal from "@/components/IosInstallStepModal/page";
|
import IosInstallStepModal from "@/components/IosInstallStepModal/page";
|
||||||
import { getCookie } from "cookies-next";
|
import { getCookie } from "cookies-next";
|
||||||
|
import baseRequest from "@/utils/baseRequest";
|
||||||
|
import { generateSignature } from "@/utils/crypto";
|
||||||
|
|
||||||
export default function Home() {
|
export default function Home() {
|
||||||
const [deviceType, setDeviceType] = useState("");
|
const [deviceType, setDeviceType] = useState("");
|
||||||
|
const [isIosInstallButtonVisible, setIsIosInstallButtonVisible] =
|
||||||
|
useState(true);
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const userAgent = navigator.userAgent;
|
const userAgent = navigator.userAgent;
|
||||||
//区分设备类型
|
//区分设备类型
|
||||||
|
@ -18,6 +22,37 @@ export default function Home() {
|
||||||
} else {
|
} else {
|
||||||
setDeviceType("pc");
|
setDeviceType("pc");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const handleIosInstallButtonVisibility = async () => {
|
||||||
|
try {
|
||||||
|
const base = baseRequest();
|
||||||
|
const body = {
|
||||||
|
...base,
|
||||||
|
};
|
||||||
|
const signature = generateSignature(body);
|
||||||
|
const _response = await fetch(
|
||||||
|
`/api/app/is_ios_install_button_visible?signature=${signature}`,
|
||||||
|
{
|
||||||
|
method: "POST",
|
||||||
|
headers: {
|
||||||
|
"Content-Type": "application/json",
|
||||||
|
},
|
||||||
|
body: JSON.stringify(body),
|
||||||
|
}
|
||||||
|
);
|
||||||
|
const _data = await _response.json();
|
||||||
|
if (_data.ret === -1) {
|
||||||
|
Toast.show({
|
||||||
|
content: _data.msg,
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (_data.data === 0) setIsIosInstallButtonVisible(false);
|
||||||
|
} catch (error) {
|
||||||
|
console.error(error);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
handleIosInstallButtonVisibility();
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
//ios安装教程Modal是否展示
|
//ios安装教程Modal是否展示
|
||||||
|
@ -155,7 +190,8 @@ export default function Home() {
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
<div className="flex flex-col items-center gap-2">
|
<div className="flex flex-col items-center gap-2">
|
||||||
{deviceType !== "pc" && (
|
{(deviceType === "Android" ||
|
||||||
|
(deviceType === "ios" && isIosInstallButtonVisible)) && (
|
||||||
<div
|
<div
|
||||||
className="btn bg-gradient-to-r from-[#FF668B] to-[#FF66F0] rounded-full text-white text-lg font-medium w-64 h-14"
|
className="btn bg-gradient-to-r from-[#FF668B] to-[#FF66F0] rounded-full text-white text-lg font-medium w-64 h-14"
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
|
@ -175,7 +211,11 @@ export default function Home() {
|
||||||
)}
|
)}
|
||||||
{deviceType === "ios" && (
|
{deviceType === "ios" && (
|
||||||
<div
|
<div
|
||||||
className="btn bg-[#FFFFFF1A] rounded-full text-white text-lg font-medium w-64 h-14"
|
className={`btn ${
|
||||||
|
deviceType === "ios" &&
|
||||||
|
!isIosInstallButtonVisible &&
|
||||||
|
"bg-gradient-to-r from-[#FF668B] to-[#FF66F0]"
|
||||||
|
} bg-[#FFFFFF1A] rounded-full text-white text-lg font-medium w-64 h-14`}
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
const inviter = getCookie("inviter");
|
const inviter = getCookie("inviter");
|
||||||
const url = `https://app.tiefen.fun?inviter=${inviter}`;
|
const url = `https://app.tiefen.fun?inviter=${inviter}`;
|
||||||
|
|
Loading…
Reference in New Issue