master
zhengpengju 3 years ago
parent 30e310a1f8
commit a45b26d862

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

@ -36,9 +36,19 @@ export async function outLogin(options?: { [key: string]: any }) {
});
}
/** 登录接口 POST /api/login/account */
/** 登录校验接口 POST */
export async function checkLogin(body: API.LoginParams, options?: { [key: string]: any }) {
return request<API.LoginResult>('/dsideal_yy/checkLoginStatus', {
method: 'POST',
requestType: 'form',
data: body,
...(options || {}),
});
}
/** 登录接口 POST */
export async function login(body: API.LoginParams, options?: { [key: string]: any }) {
return request<API.LoginResult>('/dsideal_yy/checkLoginStatus', { // /dsideal_yy/login/doLogin?login_type=1
return request<API.LoginResult>('/dsideal_yy/login/doLogin?login_type=1', {
method: 'POST',
requestType: 'form',
data: body,

Loading…
Cancel
Save