From 305945672e52b0f95af4339c5236ecc326634863 Mon Sep 17 00:00:00 2001 From: yezian Date: Fri, 12 Jan 2024 20:43:37 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E4=B8=BB=E6=92=AD=E9=82=80?= =?UTF-8?q?=E8=AF=B7=E7=94=A8=E6=88=B7=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/[user_id]/_components/WechatBar/index.jsx | 6 +++++- app/[user_id]/page.jsx | 19 +++++++++++++++++-- app/auth/login/phonenumlogin/page.jsx | 6 ++++++ components/AuthBar/index.jsx | 3 ++- 4 files changed, 30 insertions(+), 4 deletions(-) diff --git a/app/[user_id]/_components/WechatBar/index.jsx b/app/[user_id]/_components/WechatBar/index.jsx index 799b8d8..3b40251 100644 --- a/app/[user_id]/_components/WechatBar/index.jsx +++ b/app/[user_id]/_components/WechatBar/index.jsx @@ -16,6 +16,7 @@ export default function WechatBar({ price, streamerMid, auto_response_message, + onClickDownloadApp, }) { const router = useRouter(); const [showBuyWechat, setShowBuyWechat] = useState(false); @@ -93,7 +94,10 @@ export default function WechatBar({
router.push("/")} + onClick={() => { + onClickDownloadApp(); + router.push("/"); + }} >

diff --git a/app/[user_id]/page.jsx b/app/[user_id]/page.jsx index 1725c6f..0d75dfa 100644 --- a/app/[user_id]/page.jsx +++ b/app/[user_id]/page.jsx @@ -11,6 +11,7 @@ import Image from "next/image"; import verification from "@/public/icon/verification.png"; import icon_border from "@/public/images/icon_border.png"; import Link from "next/link"; +import { setCookie } from "cookies-next"; export default function StreamerDetail({ params }) { //页面数据 @@ -50,6 +51,19 @@ export default function StreamerDetail({ params }) { }; getData(); }, []); + + //将主播链接复制到剪贴板,并存cookie + const copyAndSetCookieInviter = async () => { + try { + setCookie("inviter", data?.user_id); + await navigator.clipboard.writeText( + `【${data?.name}】『ID:${data?.user_id}』,复制此条消息,打开铁粉空间APP,查看详情https://tiefen.fun/${data?.user_id}` + ); + } catch (error) { + console.error("复制到剪贴板时出现错误:", error); + } + }; + return (

@@ -64,7 +78,7 @@ export default function StreamerDetail({ params }) {
- +
{data?.platforms?.map((item, index) => (
铁粉空间

下载APP探索更多

- +

立即下载

diff --git a/app/auth/login/phonenumlogin/page.jsx b/app/auth/login/phonenumlogin/page.jsx index 1bcc299..2489c95 100644 --- a/app/auth/login/phonenumlogin/page.jsx +++ b/app/auth/login/phonenumlogin/page.jsx @@ -8,6 +8,7 @@ import { signIn } from "@/utils/auth"; import Link from "next/link"; import baseRequest from "@/utils/baseRequest"; import { generateSignature } from "@/utils/crypto"; +import { getCookie } from "cookies-next"; export default function PhonenumLogin() { const router = useRouter(); @@ -104,6 +105,9 @@ export default function PhonenumLogin() { return; } + //读取邀请人 + const inviter = getCookie("inviter"); + //对手机号进行RSA加密 const encrypt = new JSEncrypt(); encrypt.setPublicKey(process.env.NEXT_PUBLIC_RSA_KEY); @@ -113,6 +117,7 @@ export default function PhonenumLogin() { mobile_phone: mobile_phone, region_code: regionCode, veri_code: value.veri_code, + inviter: inviter, ...base, }); //发送登录请求 @@ -128,6 +133,7 @@ export default function PhonenumLogin() { mobile_phone: mobile_phone, region_code: regionCode, veri_code: value.veri_code, + inviter: inviter, ...base, }), } diff --git a/components/AuthBar/index.jsx b/components/AuthBar/index.jsx index a2178d4..3f8dffe 100644 --- a/components/AuthBar/index.jsx +++ b/components/AuthBar/index.jsx @@ -5,7 +5,7 @@ import { checkAuth, signOut } from "@/utils/auth"; import { getCookie } from "cookies-next"; import { useRouter } from "next/navigation"; -export default function AuthBar() { +export default function AuthBar({ onNotLoginedClick = () => {} }) { const router = useRouter(); const [isLogined, setIsLogined] = useState(); const [cookies, setCookies] = useState(); @@ -31,6 +31,7 @@ export default function AuthBar() { //点击登录 const handleSignIn = () => { + onNotLoginedClick(); router.push("/auth/login/phonenumlogin"); };