u
This commit is contained in:
1 parent
ca2fa3543d
commit
7333e6695f
13 files changed
+211
-105
No files matched your search
@@ -1,6 +1,6 @@
|
||||
import type { AFormRef } from '@/components/common/ao'
|
||||
import { Lock, UserRound } from 'lucide-react-native'
|
||||
import { useEffect, useRef, useState } from 'react'
|
||||
import { useRef, useState } from 'react'
|
||||
import { Image, ScrollView, View } from 'react-native'
|
||||
|
||||
import { AForm, AFormItem, AInput } from '@/components/common/ao'
|
||||
@@ -11,28 +11,16 @@ interface RegisterForm {
|
||||
username: string
|
||||
password: string
|
||||
confirmPassword: string
|
||||
a: string
|
||||
b: string
|
||||
c: string
|
||||
d: string
|
||||
e: string
|
||||
f: string
|
||||
}
|
||||
|
||||
export default function AuthLogin() {
|
||||
export default function AuthRegister() {
|
||||
const scrollRef = useRef<ScrollView>(null)
|
||||
|
||||
const toast = useToast()
|
||||
|
||||
const [form, setForm] = useState<RegisterForm>({
|
||||
username: '',
|
||||
password: '',
|
||||
confirmPassword: '',
|
||||
a: '',
|
||||
b: '',
|
||||
c: '',
|
||||
d: '',
|
||||
e: '',
|
||||
f: '',
|
||||
})
|
||||
const [loading, setLoading] = useState(false)
|
||||
const formRef = useRef<AFormRef>(null)
|
||||
@@ -41,7 +29,7 @@ export default function AuthLogin() {
|
||||
setForm(prev => ({ ...prev, [field]: value }))
|
||||
}
|
||||
|
||||
const defaultLogin = () => {
|
||||
const handleRegister = () => {
|
||||
if (formRef.current?.validate()) {
|
||||
setLoading(true)
|
||||
toast.show({ title: '校验通过,开始注册', action: 'success' })
|
||||
@@ -55,10 +43,18 @@ export default function AuthLogin() {
|
||||
return (
|
||||
<ScrollView ref={scrollRef} style={{ flex: 1 }}>
|
||||
<View className="flex flex-col items-center px-6">
|
||||
<Image source={require('@/static/images/logo.png')} style={{ width: 120, height: 120 }} className="my-12" />
|
||||
<Image
|
||||
source={require('@/static/images/logo.png')}
|
||||
style={{ width: 120, height: 120 }}
|
||||
className="my-12"
|
||||
/>
|
||||
|
||||
<AForm ref={formRef} form={form} scrollRef={scrollRef}>
|
||||
<AFormItem name="username" label="账号" isRequired>
|
||||
<AFormItem
|
||||
name="username"
|
||||
label="账号"
|
||||
isRequired
|
||||
>
|
||||
<AInput
|
||||
placeholder="请输入账号"
|
||||
leftIcon={UserRound}
|
||||
@@ -70,9 +66,9 @@ export default function AuthLogin() {
|
||||
<AFormItem
|
||||
name="password"
|
||||
label="密码"
|
||||
isRequired
|
||||
rules={[
|
||||
(val: any) => val && !/\d{6}/.test(val) ? '请输入6位数字密码' : null,
|
||||
{ required: true, message: '密码是必填项' },
|
||||
{ pattern: /^\d{6}$/, message: '请输入6位数字密码' },
|
||||
]}
|
||||
>
|
||||
<AInput
|
||||
@@ -87,9 +83,12 @@ export default function AuthLogin() {
|
||||
<AFormItem
|
||||
name="confirmPassword"
|
||||
label="确认密码"
|
||||
isRequired
|
||||
rules={[
|
||||
(val: any) => val !== form.password ? '两次密码不一致' : null,
|
||||
{ required: true, message: '确认密码是必填项' },
|
||||
{
|
||||
validator: val => val === form.password,
|
||||
message: '两次密码不一致',
|
||||
},
|
||||
]}
|
||||
>
|
||||
<AInput
|
||||
@@ -100,21 +99,9 @@ export default function AuthLogin() {
|
||||
onChange={text => handleInputChange('confirmPassword', text)}
|
||||
/>
|
||||
</AFormItem>
|
||||
|
||||
{/* 其他表单项 */}
|
||||
{['a', 'b', 'c', 'd', 'e', 'f'].map(field => (
|
||||
<AFormItem key={field} name={field} label={field} isRequired>
|
||||
<AInput
|
||||
placeholder="请输入"
|
||||
isPassword
|
||||
value={form[field]}
|
||||
onChange={text => handleInputChange(field, text)}
|
||||
/>
|
||||
</AFormItem>
|
||||
))}
|
||||
</AForm>
|
||||
|
||||
<Button className="w-full mb-4" onPress={defaultLogin} disabled={loading}>
|
||||
<Button className="w-full mb-4" onPress={handleRegister} disabled={loading}>
|
||||
{loading
|
||||
? (
|
||||
<>
|
||||
|
||||
Reference in new issue
Block a user