import { View, Text, ScrollView } from "react-native"; import React, { useState, useEffect } from "react"; import { useTailwind } from "tailwind-rn"; import { useSafeAreaInsets } from "react-native-safe-area-context"; import { get, save } from "../../utils/storeInfo"; import baseRequest from "../../utils/baseRequest"; import Toast from "react-native-toast-message"; import { Image } from "expo-image"; import { useHeaderHeight } from "@react-navigation/elements"; import Empty from "../../components/Empty"; import { generateSignature } from "../../utils/crypto"; export default function UserProfile({ navigation, route }) { const blurhash = "LcKUTa%gOYWBYRt6xuoJo~s8V@fk"; const tailwind = useTailwind(); const insets = useSafeAreaInsets(); const headerHeight = useHeaderHeight(); //获取当前页面数据 const [data, setData] = useState(); useEffect(() => { const getData = async () => { //获取环境变量 const apiUrl = process.env.EXPO_PUBLIC_API_URL; const account = await get("account"); const base = await baseRequest(); const signature = await generateSignature({ ...base, mid: account.mid, }); try { //获取账号基本信息 const accountResponse = await fetch( `${apiUrl}/api/account/list_by_mid?signature=${signature}`, { method: "POST", headers: { "Content-Type": "application/json", }, body: JSON.stringify({ ...base, mid: account.mid, }), } ); const accountData = await accountResponse.json(); if (accountData.ret === -1) { Toast.show({ type: "error", text1: accountData.msg, topOffset: 60, }); return; } await save("account", accountData.data.account); setData(accountData.data.account); } catch (error) { console.error(error); } }; getData(); }, []); return ( {data?.name} ID {data?.user_id} ); }