|
|
@ -4,7 +4,7 @@ import React, { useState } from 'react';
|
|
|
|
import { ProFormCaptcha, ProFormCheckbox, ProFormText, LoginForm } from '@ant-design/pro-form';
|
|
|
|
import { ProFormCaptcha, ProFormCheckbox, ProFormText, LoginForm } from '@ant-design/pro-form';
|
|
|
|
import { useIntl, history, FormattedMessage, SelectLang, useModel } from 'umi';
|
|
|
|
import { useIntl, history, FormattedMessage, SelectLang, useModel } from 'umi';
|
|
|
|
import Footer from '@/components/Footer';
|
|
|
|
import Footer from '@/components/Footer';
|
|
|
|
import { login } from '@/services/ant-design-pro/api';
|
|
|
|
import { checkLogin, login } from '@/services/ant-design-pro/api';
|
|
|
|
import { getFakeCaptcha } from '@/services/ant-design-pro/login';
|
|
|
|
import { getFakeCaptcha } from '@/services/ant-design-pro/login';
|
|
|
|
|
|
|
|
|
|
|
|
import styles from './index.less';
|
|
|
|
import styles from './index.less';
|
|
|
@ -41,22 +41,26 @@ const Login: React.FC = () => {
|
|
|
|
|
|
|
|
|
|
|
|
const handleSubmit = async (values: API.LoginParams) => {
|
|
|
|
const handleSubmit = async (values: API.LoginParams) => {
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
// 登录
|
|
|
|
// 登录校验
|
|
|
|
const msg = await login({ ...values, type });
|
|
|
|
const {login_status} = await checkLogin({ ...values, type });
|
|
|
|
if (msg.success === true) {
|
|
|
|
if(login_status === '1'){
|
|
|
|
const defaultLoginSuccessMessage = '登录成功!';
|
|
|
|
// 登录产生cookie
|
|
|
|
message.success(defaultLoginSuccessMessage);
|
|
|
|
const msg = await login({ ...values, type });
|
|
|
|
await fetchUserInfo();
|
|
|
|
if (msg.success === true) {
|
|
|
|
/** 此方法会跳转到 redirect 参数所在的位置 */
|
|
|
|
const defaultLoginSuccessMessage = '登录成功!';
|
|
|
|
if (!history) return;
|
|
|
|
message.success(defaultLoginSuccessMessage);
|
|
|
|
const { query } = history.location;
|
|
|
|
await fetchUserInfo();
|
|
|
|
const { redirect } = query as { redirect: string };
|
|
|
|
/** 此方法会跳转到 redirect 参数所在的位置 */
|
|
|
|
history.push(redirect || '/');
|
|
|
|
if (!history) return;
|
|
|
|
return;
|
|
|
|
const { query } = history.location;
|
|
|
|
|
|
|
|
const { redirect } = query as { redirect: string };
|
|
|
|
|
|
|
|
history.push(redirect || '/');
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
console.log('msg..', msg);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
console.log('msg..', msg);
|
|
|
|
|
|
|
|
// 如果失败去设置用户错误信息
|
|
|
|
// 如果失败去设置用户错误信息
|
|
|
|
setUserLoginState(msg);
|
|
|
|
//setUserLoginState(msg);
|
|
|
|
} catch (error) {
|
|
|
|
} catch (error) {
|
|
|
|
const defaultLoginFailureMessage = msg?.info;
|
|
|
|
const defaultLoginFailureMessage = msg?.info;
|
|
|
|
message.error(defaultLoginFailureMessage);
|
|
|
|
message.error(defaultLoginFailureMessage);
|
|
|
|