/** @format */ import { FunctionComponent, useEffect, useState } from "react"; import { ProCard } from "@ant-design/pro-components"; import { Avatar, Button, Flex, Form, FormProps, Input, message, Select, Skeleton, Space, Tabs, Tag, } from "antd"; import styles from "./index.module.less"; import TextArea from "antd/es/input/TextArea"; import { getUserInfoApi, updateUserInfo } from "@/api/user"; import { observer } from "mobx-react"; import useStore from "@/utils/store/useStore.tsx"; const UserSetting: FunctionComponent = observer(() => { const [disable, setDisable] = useState(true); const [loading, setLoading] = useState(true); const [userInfo, setUserInfo] = useState({} as any); const [password, setPassword] = useState(""); const [phone, setPhone] = useState(""); const [email, setEmail] = useState(""); const store = useStore("user"); const userId: any = store.getUserId(); async function getUserInfo() { getUserInfoApi(userId).then((res: any) => { console.log(res); if (res && res.success && res.data) { setUserInfo(res.data); setLoading(false); } }); } type FieldType = { nickName?: string; // location?: string; introduce?: string; gender?: string; company?: string; blog?: string; }; async function updateUser(data: any) { updateUserInfo(data).then((res: any) => { if (res && res.success) { message.open({ type: "success", content: "修改成功", }); } else { message.open({ type: "error", content: "修改失败", }); } }); } const onFinish: FormProps["onFinish"] = (values) => { const data: any = { id: userId, ...values, }; updateUserInfo(data).then((res: any) => { if (res && res.success) { message.open({ type: "success", content: "修改成功", }); } else { message.open({ type: "error", content: "修改失败", }); } }); }; const onFinishFailed: FormProps["onFinishFailed"] = (errorInfo: any) => { message.open({ type: "error", content: errorInfo, }); }; useEffect(() => { getUserInfo().then(); }, []); const prefixSelector = ( ); // const ProFormText = (props: any) => { // return ( // // city} // width="md" // name="location" // disabled={disable}> // // ); // }; useEffect(() => {}, []); const TabItems = [ { label: 基础信息, key: "baseInfo", children: ( <>
{/**/} {/* label="邮箱"*/} {/* name="email"*/} {/* rules={[*/} {/* {*/} {/* type: "email",*/} {/* message: "请输入正确的邮箱!",*/} {/* },*/} {/* { required: true, message: "请输入邮箱!" },*/} {/* ]}>*/} {/* */} {/**/} label="昵称" name="nickName" rules={[ { type: "string", message: "用户名只能是3到16位(字母,数字,下划线,减号)!", pattern: /^[a-zA-Z0-9_-]{3,16}$/, }, { required: true, message: "请输入昵称!", }, ]}> label="性别" name="gender" rules={[{ required: true, message: "请输入性别!" }]}> {/**/} {/* label="地区"*/} {/* name="location"*/} {/* rules={[{ required: true, message: "请输入地区!" }]}>*/} {/* */} {/**/} label="公司" name="company"> label="博客" name="blog"> label="个人简介" name="introduce">