tiefen_space_h5/app/share/[mid]/page.js

107 lines
3.2 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

"use client";
import React, { useEffect, useState } from "react";
import { Divider, Toast } from "antd-mobile";
import { useRouter, useParams, useSearchParams } from "next/navigation";
import clipboard from "copy-to-clipboard";
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
import {
faAngleLeft,
faAngleRight,
faWallet,
faPrint,
faDollar,
} from "@fortawesome/free-solid-svg-icons";
import { getStreamerInfo } from "@/api/space";
export default function ShareSpace({ data }) {
const router = useRouter();
const { mid } = useParams();
const searchParams = useSearchParams();
const webUrl = process.env.NEXT_PUBLIC_WEB_URL;
const [streamerInfo, setStreamerInfo] = useState(null);
useEffect(() => {
getStreamerInfo(Number(mid)).then((res) => {
setStreamerInfo(res);
});
}, []);
//保存内容到剪贴板
const copy = (_data) => {
// console.log("_data",_data)
clipboard(_data);
Toast.show({
icon: "success",
content: "已复制到剪贴板",
position: "top",
});
};
//复制口令
const copyShareCode = () => {
const shareCode = `${streamerInfo?.streamer_ext?.name}】『ID${streamerInfo?.streamer_ext?.user_id}复制此条消息打开铁粉空间APP查看详情${webUrl}/zone/${streamerInfo?.streamer_ext?.user_id}`;
copy(shareCode);
};
//复制邀请链接
const copyShareUrl = () => {
const shareCode = `${webUrl}/zone/${streamerInfo?.streamer_ext?.user_id}`;
// console.log("shareCode", shareCode);
copy(shareCode);
};
return (
<div className="">
<div className="p-4 fixed top-0 z-10 w-full">
<div className="w-9 h-9 flex items-center justify-center bg-[#FFFFFF1A] rounded-full float-left absolute">
<FontAwesomeIcon
icon={faAngleLeft}
style={{ maxWidth: "12px" }}
size="xl"
onClick={() => {
router.back();
}}
/>
</div>
<p className="text-base text-center leading-9">分享空间</p>
</div>
<div className="w-full flex flex-col p-4 pt-16">
<div onClick={copyShareCode} className="flex justify-between pt-4 pb-2">
<span className="text-base text-white">复制口令</span>
<FontAwesomeIcon
icon={faAngleRight}
size="xl"
style={{ maxWidth: "12px" }}
/>
</div>
<Divider />
<div
onClick={copyShareUrl}
className="flex justify-between w-full pt-4 pb-2"
>
<span className="text-base text-white">复制邀请链接</span>
<FontAwesomeIcon
icon={faAngleRight}
size="xl"
style={{ maxWidth: "12px" }}
/>
</div>
<Divider />
<div
onClick={() => {
router.push("/space/share/" + streamerInfo?.streamer_ext?.user_id);
}}
className="flex justify-between pt-4 pb-2"
>
<span className="text-base text-white">生成分享卡片</span>
<FontAwesomeIcon
icon={faAngleRight}
size="xl"
style={{ maxWidth: "12px" }}
/>
</div>
<Divider />
</div>
</div>
);
}