"use client"; import React, { useEffect, useState, useRef, useMemo } from "react"; import { Image, Mask, FloatingPanel, JumboTabs, List, InfiniteScroll, ProgressBar, Toast, } from "antd-mobile"; import { useRouter, useParams } from "next/navigation"; import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; import { faAngleLeft, faRefresh } from "@fortawesome/free-solid-svg-icons"; import PostItem from "@/components/PostItem"; import PostItemSkeleton from "@/components/skeletons/PostItemSkeleton"; import Empty from "@/components/Empty"; import require from "@/utils/require"; import AddWeChat from "@/components/AddWeChat"; import SeeTiefen from "@/components/SeeTiefen"; import DefaultMask from "@/components/DefaultMask"; import { getSpaceData, getStreamerInfo } from "@/api/space"; const anchors = [ window.innerHeight - 280, window.innerHeight - 280, window.innerHeight - 60, ]; const tabItems = [ { label: "全部", key: "all" }, { label: "铁粉专享", key: "ironFan" }, { label: "超粉专享", key: "chaofen" }, ]; export default function PersonSpace() { const router = useRouter(); const { id } = useParams(); const contentBox = useRef(); const [hasMore, setHasMore] = useState(true); const [scrollHeight, setScrollHeight] = useState(0); const [postList, setPostList] = useState([]); const [offset, setOffset] = useState(0); const [maskVisible, setMaskVisible] = useState({ visible: false, type: "" }); const [currentKey, setCurrentKey] = useState("all"); const [loading, setLoading] = useState(false); const [streamerInfo, setStreamerInfo] = useState(null); const [currentTime, setCurrentTime] = useState(); const scrollRef = useRef(null); //退款中Modal是否展示 const [isRefundingModalVisible, setIsRefundingModalVisible] = useState(false); const ironFanProgress = useMemo( () => Math.floor( (streamerInfo?.expenditure / streamerInfo?.ironfanship_price) * 100 ), [streamerInfo] ); useEffect(() => { setScrollHeight(window.innerHeight - 126); if (contentBox.current) { contentBox.current.style.transform = "translateY(-12px)"; // debugger } getStreamerInfo(Number(id)).then((res) => { setStreamerInfo(res); }); getCurrentTime(); getSpaceData(Number(id)).then((res) => { if (res) { const { isRefunding, noRole } = res; isRefunding && router.push("/"); noRole && router.push("/person_space_introduce/" + id); } }); }, []); useEffect(() => { if (currentKey) { firstRequest(currentKey); } }, [currentKey, streamerInfo]); const getCurrentTime = async () => { setCurrentTime(Math.floor(new Date().getTime() / 1000)); }; async function loadMore() { if (!offset) return; const append = await getPostList(streamerInfo.id, currentKey, offset); if (append) { setPostList((val) => [...val, ...append]); setHasMore(append.length > 0); } } const getPostList = async (zid, activeKey, offset) => { try { setLoading(true); let body = { zid: zid, ct_upper_bound: Math.floor(new Date().getTime() / 1000), offset, limit: 4, }; switch (activeKey) { case "all": body = body; break; case "ironFan": body = { ...body, c_type: 1, is_ironfan_visible: 1, }; break; case "chaofen": body = { ...body, c_type: 1, }; break; default: break; } const data = await require("POST", "/api/zone_moment/list_by_zid", { body, }); if (data.ret === -1) { Toast.show({ icon: "fail", content: data.msg, position: "top", }); return; } setLoading(false); setOffset(offset + 1); return data.data.list; } catch (error) { setLoading(false); } }; const firstRequest = (currentKey) => { let floatingPanel = document.getElementsByClassName( "adm-floating-panel-content" )[0]; floatingPanel?.scrollTo(0, 0); setOffset(0); setHasMore(true); if (streamerInfo) { getPostList(streamerInfo.id, currentKey, 0).then((res) => { setPostList(res || []); }); } }; return (
{ router.back(); }} />
router.push("setting")} />
{/* 内容 */}

{streamerInfo?.streamer_ext?.name}

{streamerInfo?.streamer_ext?.user_id}
{streamerInfo?.zone_moment_count}
setMaskVisible(true)} >

分享

  • setMaskVisible({ visible: true, type: "weChat" }) } >

    查看微信

  • setMaskVisible({ visible: true, type: "ironFan" }) } >

    {streamerInfo?.is_ironfanship_unlocked === 1 ? "已是铁粉" : "成为铁粉"}

    {`${parseInt( streamerInfo?.expenditure / 100, 10 )}/${parseInt(streamerInfo?.ironfanship_price / 100, 10)}`}

  • { streamerInfo?.is_superfanship_unlocked === 1 ? setCurrentKey("chaofen") : router.push("/pay"); }} >

    {streamerInfo?.is_superfanship_unlocked === 1 ? "尊贵超粉" : "成为超粉"}

  • setMaskVisible(true)} >

    举报

  • {streamerInfo?.visitor_role === 3 && (
  • router.push("VisibleToOneselfSpacePosts")} className="flex flex-col items-center" >

    审核未通过

  • )}
setCurrentKey(key)} activeKey={currentKey} className="bg-deepBg pb-12" > {tabItems.map((it) => (
) } destroyOnClose={true} >
{loading && ( <> )} {!postList.length && (
)} {postList.map((item, index) => ( ))}
))}
{ // router.refresh(); // }} onClick={() => { firstRequest(); }} />
{maskVisible.type == "weChat" && ( setMaskVisible({ visible: false, type: "" })} price={streamerInfo?.streamer_ext?.wechat_coin_price} name={streamerInfo?.streamer_ext?.name} streamerMid={streamerInfo?.streamer_ext?.mid} avatar={streamerInfo?.streamer_ext?.avatar?.images[0]?.urls[0]} streamerData={streamerInfo} /> )} {maskVisible.type == "ironFan" && ( { setMaskVisible({ visible: false, type: "" }); }} handleClick={() => { setCurrentKey("ironFan"); setMaskVisible({ visible: false, type: "" }); }} /> )} { setIsRefundingModalVisible(false); // setTimeout(() => navigation.replace("HomeTab"), 500); }} /> {/*
{ router.push("/pay"); }} > 39.9元立即加入
*/}
); }