"use client"; import React, { useState, useEffect } from "react"; import html2canvas from "html2canvas"; import baseRequest from "@/utils/baseRequest"; import { Toast } from "antd-mobile"; import { generateSignature } from "@/utils/crypto"; export default function Share({ params }) { //获取页面数据、生成二维码 const [data, setData] = useState({}); const [qrcodeUrl, setQrcodeUrl] = useState(""); const [isFetching, setIsFetching] = useState(true); useEffect(() => { const getData = async () => { try { const base = baseRequest(); const signature = generateSignature({ user_id: parseInt(params.user_id, 10), ...base, }); const detailResponse = await fetch( `/api/streamer/list_ext_by_user_id?signature=${signature}`, { method: "POST", headers: { "Content-Type": "application/json", }, body: JSON.stringify({ user_id: parseInt(params.user_id, 10), ...base, }), } ); const detailData = await detailResponse.json(); if (detailData.ret === -1) { Toast.show({ content: detailData.msg, }); return; } setData(detailData.data.streamer_ext); var QRCode = require("qrcode"); QRCode.toDataURL( `https://tiefen.fun/zone/${params.user_id}`, function (err, url) { setQrcodeUrl(url); } ); setIsFetching(false); } catch (error) { console.error(error); } }; getData(); }, []); //分享海报组件 const Poster = () => { return (
{data?.name}
ID
{data?.user_id}
邀您加入我的 「铁粉空间」