"use client"; import React, { useEffect, useState } from "react"; import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; import { faAngleRight } from "@fortawesome/free-solid-svg-icons"; import { Avatar, Image, Toast, Space } from "antd-mobile"; import { useRouter } from "next/navigation"; import { get } from "@/utils/storeInfo"; import requireAPI from "@/utils/requireAPI"; const My = () => { const [userInfo, setUserInfo] = useState({}); const router = useRouter(); const [streamerNavigates, setStreamerNavigates] = useState([]); const [userNavigates, setUserNavigates] = useState([]); useEffect(() => { const userInfo = get("account"); if (userInfo) { getData(userInfo); } }, []); const getData = async (oldUserInfo) => { const data = await requireAPI( "POST", "/api/account_relation/count", null, true ); if (data.ret === -1) { Toast.show({ icon: "fail", content: data.msg, position: "top", }); return; } const streamer = await requireAPI( "POST", "/api/streamer/list_ext_by_mid", null, true ); if (streamer.ret === -1) { Toast.show({ icon: "fail", content: streamer.msg, position: "top", }); return; } const account = await requireAPI( "POST", "/api/account/list_by_mid", null, true ); if (account.ret === -1) { Toast.show({ icon: "fail", content: account.msg, position: "top", }); return; } const statuses = await requireAPI( "POST", "/api/streamer_auth_approval/get_statuses", null ); if (statuses.ret === -1) { Toast.show({ icon: "fail", content: statuses.msg, position: "top", }); return; } const isInJoinProgress = (statuses.data.basic_status === 0 || statuses.data.basic_status === 1 || statuses.data.basic_status === 3) && statuses.data.details_status !== 1; setStreamerNavigates((old) => { if (account.data.account.role == 3 || isInJoinProgress) { const zoneLength = streamer.data?.streamer_ext?.zones?.length; let currentOld = [ { url: !zoneLength ? `my/createProfile` : `space/${account.data.account.mid}`, iconUrl: `icons/32DP/space.png`, title: !zoneLength ? "开通空间" : "我的空间", subTitle: account.data.account.role == 3 ? "创作者功能" : "完善资料后解锁", }, { url: `streamerPosts/${account.data.account.mid}`, iconUrl: "icons/32DP/myposts.png", title: "广场动态", subTitle: account.data.account.role == 3 ? "创作者功能" : "完善资料后解锁", }, { url: `my/wechatWaitingToAdd`, iconUrl: "icons/32DP/wechat.png", title: "待添加微信", subTitle: account.data.account.role == 3 ? "创作者功能" : "完善资料后解锁", }, { url: `my/editprofile`, iconUrl: "icons/32DP/editprofile.png", title: "编辑资料", subTitle: account.data.account.role == 3 ? "创作者功能" : "完善资料后解锁", }, // ...currentOld, ]; if (isInJoinProgress) { currentOld = [ { url: `my/streamerVerification/completeStreamerInformation`, iconUrl: "icons/32DP/editprofile.png", title: "完善资料", subTitle: "完善后解锁全部功能", status: statuses.data.details_status == 0 ? "审核中" : statuses.data.details_status == 2 ? "未通过" : null, // disable: !isInJoinProgress, }, ...currentOld, ]; } return currentOld; } return old; }); setUserNavigates((old) => { let currentOld = [ { url: `my/wallet`, iconUrl: "icons/32DP/wallet.png", title: "我的钱包", }, { url: `my/unlockedWechat`, iconUrl: "icons/32DP/wechat.png", title: "已解锁微信", }, { url: `/messageDetail`, iconUrl: "icons/32DP/contact.png", title: "联系客服", }, { url: `/my/addToHome`, iconUrl: "icons/32DP/toScreen.png", title: "添加到主屏幕", }, ]; if ( (account.data.account.role != 3 && !isInJoinProgress) || statuses.data.details_status === 2 ) { currentOld = [ { url: `my/wallet`, iconUrl: "icons/32DP/wallet.png", title: "我的钱包", }, { url: `my/unlockedWechat`, iconUrl: "icons/32DP/wechat.png", title: "已解锁微信", }, { url: `my/streamerVerification/joinStreamer`, iconUrl: "icons/32DP/join.png", title: "申请入驻", }, { url: `/messageDetail`, iconUrl: "icons/32DP/contact.png", title: "联系客服", }, { url: `/my/addToHome`, iconUrl: "icons/32DP/toScreen.png", title: "添加到主屏幕", }, ]; } return currentOld; }); setUserInfo({ ...data.data, ...account.data.account, ...streamer.data }); }; const ItemEle = ({ url, iconUrl, title, subTitle, toWebView, status, disable, }) => { return (
{userInfo.name}
{userInfo?.is_a_member === 1 && ({userInfo.name}
{userInfo?.is_a_member === 1 && ({userInfo?.follow_count || 0}
关注
{userInfo?.is_followed_count || 0}
粉丝
{userInfo.gold_num || 0}
金币
{userInfo.diamond_num || 0}
钻石