import { useState } from 'react' import { Image, Text, View } from 'react-native' import { AButton, ACheckbox, AForm, AFormItem, AInput } from '@/components/common/ao' import { IconQq, IconWeixin, IconZhiwen } from '@/components/iconfont' import { Divider } from '@/components/ui/divider' import useFormValidation from '@/hooks/useFormValidation' import alovaInstance from '@/request' import { toast } from '@/utils/toast' interface LoginForm { username: string password: string rememberMe: boolean socialType?: 'qq' | 'weixin' | 'fingerprint' } export default function AuthLogin() { const [form, setForm] = useState({ username: '', password: '', rememberMe: true, }) const handleInputChange = (field: keyof LoginForm, value: string) => { setForm(prev => ({ ...prev, [field]: value })) } // 验证规则 const rules = { username: { required: true, message: '账号是必填项' }, password: { required: true, message: '密码是必填项' }, } const { isValid } = useFormValidation(form, rules) const loginDefault = () => { alovaInstance.Post('/auth/test', { title: 'foo', body: 'bar', userId: 1, }) .then((res) => { console.log('成功返回:', res) }) .catch((err) => { console.log('请求失败或未授权:', err) }) } const loginQq = () => { toast.show({ title: '功能待开发,请稍等. . .' }) } const loginWx = () => { toast.show({ title: '功能待开发,请稍等. . .' }) } const loginZhiwen = () => { toast.show({ title: '功能待开发,请稍等. . .' }) } return ( handleInputChange('username', text)} /> handleInputChange('password', text)} /> setForm(prev => ({ ...prev, rememberMe: checked }))} label="记住我" /> 忘记密码? 登录 社交账号 ) }