"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 (
{streamerInfo?.streamer_ext?.name}
分享
查看微信
{streamerInfo?.is_ironfanship_unlocked === 1 ? "已是铁粉" : "成为铁粉"}
{`${parseInt( streamerInfo?.expenditure / 100, 10 )}/${parseInt(streamerInfo?.ironfanship_price / 100, 10)}`}
{streamerInfo?.is_superfanship_unlocked === 1 ? "尊贵超粉" : "成为超粉"}
举报
查看微信
{streamerInfo?.is_ironfanship_unlocked === 1 ? "已是铁粉" : "成为铁粉"}
{/*0/299
*/}{streamerInfo?.is_superfanship_unlocked === 1 ? "尊贵超粉" : "成为超粉"}