"use client"; import React, { useEffect, useRef, useState } from "react"; import { Image, Swiper, Divider, ImageViewer, Popover, Toast, } from "antd-mobile"; import { useRouter, useParams } from "next/navigation"; import Link from "next/link"; import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; import { faAngleLeft, faAngleRight, faEllipsisVertical, faCopy, faWarning, } from "@fortawesome/free-solid-svg-icons"; import requireAPI from "@/utils/requireAPI"; import AddWeChat from "@/components/AddWeChat"; import { handleFollow, checkRelation } from "@/api/public"; import { getStreamerDetailInfo } from "@/api/space"; import { get } from "@/utils/storeInfo"; import { handleShowVideo } from "@/utils/tools/handleFuns"; import clipboard from "copy-to-clipboard"; import ImagesMask from "@/components/ImagesMask"; // import * as Clipboard from "expo-clipboard"; export default function PersonSpace() { const { mid } = useParams(); const router = useRouter(); const [streamerInfo, setStreamerInfo] = useState(null); const [spaceData, setSpaceData] = useState(null); const [loading, setLoading] = useState(false); const [visible, setVisible] = useState(false); const [isFollow, setIsFollow] = useState(false); const [topPhotos, setTopPhotos] = useState([]); const currentIndex = useRef(); const imagesMaskRef = useRef(null); // 获取屏幕高度 // const scrollHeight = 600; useEffect(() => { handleGetStreamerInfo(); getSpaceData(); getRelationData(); }, []); const showPhotos = (photos, index) => { currentIndex.current = index; // const interval = setInterval(() => { // console.log("bbbbbb") // const bodyBox = document.getElementsByClassName("photos-bodyBox")[0]; // if (bodyBox) { // bodyBox.firstChild.lastChild.style.transform = `translateX(-${ // currentIndex.current * (window.innerWidth + 16) // }px)`; // // console.log(bodyBox.firstChild.lastChild.style.transform); // } // }, 400); // handleShowImages(index, photos, interval); // console.log(imagesMaskRef.current, photos); imagesMaskRef.current.show(photos, index, streamerInfo); // setVisible(true) // console.log(imagesMaskRef.current); // imagesMaskRef.current.show( // photos.map((item) => item?.url), // index // ); }; // const handleShowImages = (index, photos, interval) => { // const mediaDom = document.createElement("div"); // mediaDom.style.width = "100vw"; // document.body.appendChild(mediaDom); // mediaDom.className = `${ // photos[index]?.type == "hid" ? "mediaDom photos-body" : "mediaDom" // }`; // ImageViewer.clear(); // ImageViewer.Multi.show({ // images: photos.map((item) => item.url), // defaultIndex: index, // // renderFooter: (image, index) => { // // return renderFooter(photos[index]?.type == "hid", mediaDom); // // }, // getContainer: mediaDom, // onIndexChange: (index) => { // currentIndex.current = index; // mediaDom.className = `${ // photos[index]?.type == "hid" ? "mediaDom photos-body" : "mediaDom" // }`; // const leftBtn = document.getElementsByClassName("imagesBtnsControllerLeft")[0] // const rightBtn = document.getElementsByClassName("imagesBtnsControllerRight")[0] // if(leftBtn && rightBtn){ // if(!index){ // leftBtn.style.opacity=0.5 // rightBtn.style.opacity=1 // }else if(index==photos.length-1){ // leftBtn.style.opacity=1 // rightBtn.style.opacity=0.5 // }else{ // leftBtn.style.opacity=1 // rightBtn.style.opacity=1 // } // } // }, // afterClose: () => { // mediaDom.remove(); // clearInterval(interval); // }, // classNames: { body: "photos-bodyBox" }, // }); // }; const handleGetStreamerInfo = async () => { try { setLoading(true); const data = await getStreamerDetailInfo(Number(mid)); setStreamerInfo({ ...data, }); const photosArr = [ ...data?.streamer_ext?.cover?.images?.map((item) => ({ url: item.urls[0], type: "video", })), ...data?.streamer_ext?.album?.images.map((item) => ({ url: item.urls[0], type: "img", })), ]; // console.log("photosArr", photosArr); setTopPhotos(photosArr); setLoading(false); } catch (error) { console.error(error); } }; const getSpaceData = async () => { try { const data = await requireAPI("POST", "/api/zone/list_by_mid", { body: { mid: Number(mid), }, }); if (data.ret === -1) { Toast.show({ icon: "fail", content: data.msg, position: "top", }); return; } setSpaceData(data.data.list[0]); } catch (error) { console.error(error); } }; const getRelationData = async () => { const account = get("account"); const subMid = account.mid; const objMid = Number(mid); const temIsFollowed = await checkRelation(subMid, objMid, 0); setIsFollow(temIsFollowed); }; //保存内容到剪贴板 const copy = (_data) => { // console.log("_data", _data); clipboard(_data); Toast.show({ icon: "success", content: "已复制到剪贴板", position: "top", }); }; return (
{ router.back(); }} />
{ router.push("/messageDetail"); }} > 举报
} trigger="click" placement="left" > { // router.back(); }} />
{/* 内容 */}
{!!topPhotos.length && ( {topPhotos.map((photo, index) => (
{ if (photo.type == "video") { handleShowVideo({ url: streamerInfo?.streamer_ext?.shorts?.videos[0] ?.cover_urls[0], mp4: streamerInfo?.streamer_ext?.shorts?.videos[0] ?.urls[0], }); } else { showPhotos( topPhotos.filter((it) => it.type == "img"), topPhotos .filter((it) => it.type == "img") .indexOf(photo) ); } }} > { // Toast.show(`你点击了卡片 ${index + 1}`); // }} /> {photo.type == "video" && (
)}
))}
)}

{streamerInfo?.streamer_ext?.name}

    {streamerInfo?.streamer_ext?.tag?.map((item, index) => (
  • {item}
  • ))}
  • {streamerInfo?.streamer_ext?.user_id}
  • {`全网粉丝 : ${streamerInfo?.streamer_ext?.fans || 0}万`}
  • {streamerInfo?.streamer_ext?.age && (
  • {streamerInfo?.streamer_ext?.gender === 1 ? ( ) : ( )} {streamerInfo?.streamer_ext?.age}岁
  • )} {streamerInfo?.streamer_ext?.height && (
  • {`${streamerInfo?.streamer_ext?.height}cm`}
  • )} {streamerInfo?.streamer_ext?.weight && (
  • {`${streamerInfo?.streamer_ext?.weight}kg`}
  • )} {streamerInfo?.streamer_ext?.constellation && (
  • {streamerInfo?.streamer_ext?.constellation}
  • )} {streamerInfo?.streamer_ext?.city && (
  • {streamerInfo?.streamer_ext?.city}
  • )}
{streamerInfo?.streamer_ext?.bio && (
个性签名| {streamerInfo?.streamer_ext?.bio}
)}
{spaceData && !!spaceData?.previews?.images?.length && ( <>
router.push( spaceData?.visitor_role === 4 ? `/space/person_space_introduce/${mid}` : `/space/${mid}` ) } >
空间动态
查看{spaceData?.zone_moment_count}条 { router.back(); }} />
{spaceData?.previews?.images ?.slice(0, 4) .map((item, index) => (
))}
)} <>

来这找我玩

  • 微信: setVisible(true)} > 点击查看
  • {streamerInfo?.streamer_ext?.platforms?.map((item) => (
  • {item?.link_name}:{item?.nickname}
    { copy(item.url); }} > {/* */} 复制
    {/* */} 前往
  • ))}
handleFollow(isFollow, Number(mid), setIsFollow)} > {isFollow ? "已关注" : "关注"}
router.push( "/messageDetail?mid=" + streamerInfo?.streamer_ext?.mid ) } > 私聊
setVisible(true)} > 添加微信
); }