"use client"; import React, { useEffect, useState } from "react"; import { Avatar, Divider, Toast } from "antd-mobile"; import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; import { faAngleLeft, faAngleRight } from "@fortawesome/free-solid-svg-icons"; import { useRouter } from "next/navigation"; import { get, save } from "@/utils/storeInfo"; import { uploadImage } from "@/utils/upload"; import { getUserInfo } from "@/api/public"; import require from "@/utils/require"; export default function SelectUserProfileItem() { const router = useRouter(); const [userInfo, setUserInfo] = useState({}); useEffect(() => { const userInfo = get("account"); if (setUserInfo) { setUserInfo(userInfo); } }, []); const uploadHead = async (e) => { const avatarId = await uploadImage(e.target.files[0]); try { const data = await require("POST", "/api/account/update", { body: { avatar: { image_ids: [avatarId] } }, }, true); if (data.ret === -1) { Toast.show({ icon: "fail", content: data.msg, position: "top", }); return; } //向服务器请求新的账号信息并保存到本地 const account = await getUserInfo(); save("account", JSON.stringify(account)); setUserInfo(account); } catch (error) { console.error(error); } }; return (
{ router.back(); }} />

修改资料

{/* 内容 */}
头像 {/* */}
{ router.push("/my/editUserProfile/editUserName"); }} > 昵称
{userInfo?.name} { router.push("my/editUserProfile/editUserName"); }} />
ID {userInfo?.user_id}
); } // const CustomUploadButton = ({ img }) => { // const [fileList, setFileList] = useState([ // { // url: img, // }, // ]); // const uploadImg = async (file) => { // console.log(file); // return { // url: URL.createObjectURL(file), // }; // }; // return ( // //
// //
//
// ); // };