"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 requireAPI from "@/utils/requireAPI"; import AddWeChat from "@/components/AddWeChat"; import SeeTiefen from "@/components/SeeTiefen"; import DefaultMask from "@/components/DefaultMask"; import { getSpaceData, getStreamerInfo } from "@/api/space"; import baseRequest from "@/utils/baseRequest"; const anchors = [ window.innerHeight - 280, window.innerHeight - 280, window.innerHeight - 60, ]; export default function PersonSpace() { const base = baseRequest(); const router = useRouter(); const { id } = useParams(); const contentBox = useRef(); const [hasMore, setHasMore] = useState(true); const [scrollHeight, setScrollHeight] = useState(0); const [postList, setPostList] = useState([]); const [tabItems, setTabItems] = 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) => { let tabitems = res.is_superfanship_enabled ? [ { label: "全部", key: "all" }, { label: "铁粉专享", key: "ironFan" }, { label: "超粉专享", key: "chaofen" }, ] : [ { label: "全部", key: "all" }, { label: "铁粉专享", key: "ironFan" }, ]; setTabItems(tabitems); setStreamerInfo(res); }); getCurrentTime(); getSpaceData(Number(id)).then((res) => { if (res) { const { isRefunding, noRole } = res; isRefunding && router.push("/"); noRole && router.replace("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; } // console.log("body",body) const data = await requireAPI("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(data.data.offset); setHasMore(data.data.more); return data.data.list; } catch (error) { setLoading(false); } }; const firstRequest = (currentKey) => { if (typeof window == "undefined") return; let floatingPanel = document.getElementsByClassName( "adm-floating-panel-content" )[0]; floatingPanel?.scrollTo(0, 0); setOffset(0); setHasMore(true); if (!postList.length) return; if (streamerInfo) { getPostList(streamerInfo.id, currentKey, 0).then((res) => { setPostList(res || []); }); } }; return (
{ router.back(); }} />
router.push( "setting?data=" + encodeURIComponent( JSON.stringify({ mid: streamerInfo?.mid, id: streamerInfo?.id, ct: streamerInfo?.streamer_ext?.ct, user_id: streamerInfo?.streamer_ext?.user_id, name: streamerInfo?.streamer_ext?.name, visitor_role: streamerInfo?.visitor_role, avatar: streamerInfo?.streamer_ext?.avatar?.images[0]?.urls[0], admission_price: streamerInfo?.admission_price, }) ) ) } />
{/* 内容 */}

{streamerInfo?.streamer_ext?.name}

{streamerInfo?.streamer_ext?.user_id}
{streamerInfo?.zone_moment_count}
router.push("/share/" + streamerInfo?.streamer_ext?.mid) } >

分享

  • 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_enabled && (
  • { // console.log( // "streamerInfo?.is_superfanship_unlocked === 1", // streamerInfo?.is_superfanship_unlocked === 1 // ); streamerInfo?.is_superfanship_unlocked === 1 ? setCurrentKey("chaofen") : router.push( "/webView/" + encodeURIComponent( "/zone/pay/" + streamerInfo?.id + "/h5_zone_superfanship/0" + "?base=" + encodeURIComponent(JSON.stringify(base)) ) ); }} >

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

  • )}
  • { router.push("/messageDetail"); }} >

    举报

setCurrentKey(key)} activeKey={currentKey} className="bg-deepBg pb-12" > {tabItems.map((it) => (
) } destroyOnClose={true} >
{loading && !postList.length && ( <> )} {/* {!postList.length && !loading && (
)} */} {postList.map((item, index) => ( ))}
))}
{ // router.refresh(); // }} onClick={() => { firstRequest(); }} />
{streamerInfo?.visitor_role != 3 && ( )} {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); }} />
); }