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