"use client"; import React, { useEffect, useState } from "react"; import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; import { faAngleRight } from "@fortawesome/free-solid-svg-icons"; import { Avatar, Toast, Space } from "antd-mobile"; import { useRouter } from "next/navigation"; import { get, save } from "@/utils/storeInfo"; import requireAPI from "@/utils/requireAPI"; import OwnIcon from "@/components/OwnIcon"; import OwnImage from "@/components/OwnImage"; import { getVipPrice } from "@/utils/auth"; import baseRequest from "@/utils/baseRequest"; 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; } save("account", account.data.account); 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 vipPrice = await getVipPrice(); 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 ? "创作者功能" : "完善资料后解锁", }, { url: `my/refund/refundList`, iconUrl: "/icons/32DP/refund.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: `my/streamerVerification/joinEntrance`, iconUrl: "/icons/32DP/join.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/joinEntrance`, // 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, vipPrice, }); }; const ItemEle = ({ url, iconUrl, title, subTitle, toWebView, status, disable, }) => { return (
  • { subTitle != "完善资料后解锁" && !disable && router.push( toWebView ? `/webView/${encodeURIComponent(url)}` : url ); }} >
    {title}
    {status || subTitle}
    {!disable && ( )}
  • ); }; return (
    router.push("my/editUserProfile/selectUserProfileItem") } >
    router.push("my/setting")} >
    {userInfo?.role === 3 ? (
    router.push("profile/" + userInfo.mid)} >

    {userInfo.name}

    {userInfo?.is_a_member === 1 && ( )}
    {userInfo.user_id}
    ) : (

    {userInfo.name}

    {userInfo?.is_a_member === 1 && ( )}
    {userInfo.user_id}
    )} {/*会员功能*/}
    { const base = baseRequest(); router.push( `/webView/${encodeURIComponent( `/vip?base=${encodeURIComponent(JSON.stringify(base))}` )}` ); }} className="flex flex-col p-2.5 rounded-2xl mt-3.5 bg-[#301024] mb-4" >
    {userInfo?.is_a_member !== 1 ? "开通会员保存图片" : "尊贵的永久会员"}
    {userInfo?.is_a_member !== 1 ? "限时优惠活动" : "已解锁全部会员权益"}
    {userInfo?.is_a_member !== 1 && (
    ¥{userInfo.vipPrice}/永久
    )}
    {/* 主播用户 */} {!!streamerNavigates.length && (
    )} {/* 普通用户 */} {!!userNavigates.length && (
    )}
    ); }; export default My;