|
|
|
@ -8,9 +8,8 @@ import { useShallow } from 'zustand/react/shallow';
|
|
|
|
|
|
|
|
|
|
import { Button } from '@/components';
|
|
|
|
|
import { useLogin, useLoginRedirect } from '@/hooks';
|
|
|
|
|
import { apiSendSMS, apiUserLogin } from '@/services';
|
|
|
|
|
import { apiSendSMS } from '@/services';
|
|
|
|
|
import { useUserStore } from '@/store';
|
|
|
|
|
import { setAccessToken } from '@/utils';
|
|
|
|
|
|
|
|
|
|
export default function LoginForm({ className }: { className?: string }) {
|
|
|
|
|
const redirect = useLoginRedirect();
|
|
|
|
@ -24,8 +23,8 @@ export default function LoginForm({ className }: { className?: string }) {
|
|
|
|
|
})),
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
const [phone, setPhone] = useState<string>('18812345678'); // 手机号
|
|
|
|
|
const [authCode, setAuthCode] = useState<string>('123456'); // 验证码
|
|
|
|
|
const [phone, setPhone] = useState<string>(''); // 手机号
|
|
|
|
|
const [authCode, setAuthCode] = useState<string>(''); // 验证码
|
|
|
|
|
const [errorText, setErrorText] = useState<string>(''); // 验证码
|
|
|
|
|
const [buttonText, setButtonText] = useState<string>('获取验证码'); // 获取验证码 按钮文案
|
|
|
|
|
const [time, setTime] = useState<number>(0); // 倒计时
|
|
|
|
@ -38,7 +37,7 @@ export default function LoginForm({ className }: { className?: string }) {
|
|
|
|
|
setBtnLoading(true);
|
|
|
|
|
|
|
|
|
|
// 设置倒计时
|
|
|
|
|
const gapTime: number = 14;
|
|
|
|
|
const gapTime: number = 59;
|
|
|
|
|
setTime(gapTime);
|
|
|
|
|
const timer = setTimeout(() => {
|
|
|
|
|
setBtnLoading(false);
|
|
|
|
@ -69,7 +68,7 @@ export default function LoginForm({ className }: { className?: string }) {
|
|
|
|
|
if (result.code === 200) {
|
|
|
|
|
setShowLogin(false);
|
|
|
|
|
await getUserInfo();
|
|
|
|
|
// router.replace(redirect);
|
|
|
|
|
router.replace(redirect);
|
|
|
|
|
} else {
|
|
|
|
|
setErrorText(result.message);
|
|
|
|
|
setBtnLoading(false);
|
|
|
|
|