login page
This commit is contained in:
@ -74,7 +74,19 @@ const Loading: React.FC<{}> = () => {
|
|||||||
// return;
|
// return;
|
||||||
// }
|
// }
|
||||||
// } else {
|
// } else {
|
||||||
setUserData(userData, userData.authorityList[0].roleCode, userData.authorityList[0]);
|
let role = userData.authorityList[0].roleCode;
|
||||||
|
let roleData = userData.authorityList[0];
|
||||||
|
|
||||||
|
const loginType = localStorage.getItem('loginType');
|
||||||
|
if (loginType) {
|
||||||
|
const roleCode = `ebtp-${loginType}`
|
||||||
|
const targetRole = userData.authorityList.find((ite: any) => ite.roleCode == roleCode);
|
||||||
|
if (targetRole) {
|
||||||
|
role = targetRole.roleCode;
|
||||||
|
roleData = targetRole;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
setUserData(userData, role, roleData);
|
||||||
// }
|
// }
|
||||||
// await setDict();//存字典
|
// await setDict();//存字典
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
@ -255,7 +267,10 @@ const Loading: React.FC<{}> = () => {
|
|||||||
await redirect(res, url, extra);
|
await redirect(res, url, extra);
|
||||||
} else {
|
} else {
|
||||||
if (status == 0) {
|
if (status == 0) {
|
||||||
await refreshUserData(res?.userType, token, url, extra);
|
// await refreshUserData(res?.userType, token, url, extra);
|
||||||
|
message.error("角色身份信息不存在").then(() => {
|
||||||
|
history.replace('/login');
|
||||||
|
});
|
||||||
} else {
|
} else {
|
||||||
error('401');
|
error('401');
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import React, { useEffect, useRef, useState } from 'react';
|
import React, { useEffect, useRef, useState } from 'react';
|
||||||
import { Form, Input, Button, Checkbox, Card, Typography } from 'antd';
|
import { Form, Input, Button, Checkbox, Card, Typography } from 'antd';
|
||||||
import { UserOutlined, LockOutlined, EyeInvisibleOutlined, EyeTwoTone } from '@ant-design/icons';
|
import { UserOutlined, LockOutlined, EyeInvisibleOutlined, EyeTwoTone } from '@ant-design/icons';
|
||||||
import { history } from '@umijs/max';
|
import { history, Helmet } from '@umijs/max';
|
||||||
import cookie from 'react-cookies';
|
import cookie from 'react-cookies';
|
||||||
import CaptchaInput from '@/components/CaptchaInput';
|
import CaptchaInput from '@/components/CaptchaInput';
|
||||||
import styles from './internal.less';
|
import styles from './internal.less';
|
||||||
@ -29,13 +29,21 @@ const InternalLogin: React.FC = () => {
|
|||||||
account: values.username,
|
account: values.username,
|
||||||
password: values.password,
|
password: values.password,
|
||||||
captcha: values.captcha,
|
captcha: values.captcha,
|
||||||
remember: values.remember,
|
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
setLoading(true);
|
setLoading(true);
|
||||||
const res = await internalUserLogin(params);
|
const res = await internalUserLogin(params);
|
||||||
|
setLoading(false);
|
||||||
if (res?.code === 200) {
|
if (res?.code === 200) {
|
||||||
sessionStorage.setItem('Authorization', res?.data?.token || '');
|
sessionStorage.setItem('Authorization', res?.data?.token || '');
|
||||||
|
if (values.remember) {
|
||||||
|
localStorage.setItem('remember_user', JSON.stringify({
|
||||||
|
username: values.username,
|
||||||
|
password: values.password,
|
||||||
|
}));
|
||||||
|
} else {
|
||||||
|
localStorage.removeItem('remember_user');
|
||||||
|
}
|
||||||
history.push('/redirect');
|
history.push('/redirect');
|
||||||
} else {
|
} else {
|
||||||
captchaRef.current?.refresh();
|
captchaRef.current?.refresh();
|
||||||
@ -48,8 +56,6 @@ const InternalLogin: React.FC = () => {
|
|||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('登录失败:', error);
|
console.error('登录失败:', error);
|
||||||
} finally {
|
|
||||||
setLoading(false);
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -137,6 +143,9 @@ const InternalLogin: React.FC = () => {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={styles.loginContainer}>
|
<div className={styles.loginContainer}>
|
||||||
|
<Helmet>
|
||||||
|
<title>登录</title>
|
||||||
|
</Helmet>
|
||||||
<Card className={styles.loginCard}>
|
<Card className={styles.loginCard}>
|
||||||
<Title level={2} style={{ textAlign: 'center', lineHeight: '80px', fontSize: 32, fontWeight: 700, marginBottom: 0 }}>
|
<Title level={2} style={{ textAlign: 'center', lineHeight: '80px', fontSize: 32, fontWeight: 700, marginBottom: 0 }}>
|
||||||
电子招投标平台
|
电子招投标平台
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import React, { useEffect, useRef, useState } from 'react';
|
import React, { useEffect, useRef, useState } from 'react';
|
||||||
import { Form, Input, Button, Checkbox, Card, Typography, Tabs } from 'antd';
|
import { Form, Input, Button, Checkbox, Card, Typography, Tabs } from 'antd';
|
||||||
import { UserOutlined, LockOutlined, EyeInvisibleOutlined, EyeTwoTone } from '@ant-design/icons';
|
import { UserOutlined, LockOutlined, EyeInvisibleOutlined, EyeTwoTone } from '@ant-design/icons';
|
||||||
import { history } from 'umi';
|
import { history, Helmet } from '@umijs/max';
|
||||||
import cookie from 'react-cookies';
|
import cookie from 'react-cookies';
|
||||||
import CaptchaInput from '@/components/CaptchaInput';
|
import CaptchaInput from '@/components/CaptchaInput';
|
||||||
import styles from './internal.less';
|
import styles from './internal.less';
|
||||||
@ -35,21 +35,29 @@ const Login: React.FC = () => {
|
|||||||
const [form] = Form.useForm();
|
const [form] = Form.useForm();
|
||||||
const [loading, setLoading] = useState(false);
|
const [loading, setLoading] = useState(false);
|
||||||
const [activeTab, setActiveTab] = useState<UserType>('supplier');
|
const [activeTab, setActiveTab] = useState<UserType>('supplier');
|
||||||
const captchaRef = useRef<any>(null);
|
const captchaRef = useRef<any>(null);
|
||||||
|
|
||||||
const onFinish = async (values: LoginFormValues) => {
|
const onFinish = async (values: LoginFormValues) => {
|
||||||
const params = {
|
const params = {
|
||||||
account: values.username,
|
account: values.username,
|
||||||
password: values.password,
|
password: values.password,
|
||||||
captcha: values.captcha,
|
captcha: values.captcha,
|
||||||
remember: values.remember,
|
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
setLoading(true);
|
setLoading(true);
|
||||||
const res = await userLogin(params, activeTab);
|
const res = await userLogin(params, activeTab);
|
||||||
|
setLoading(false);
|
||||||
if (res?.code === 200) {
|
if (res?.code === 200) {
|
||||||
sessionStorage.setItem('Authorization', res?.data?.token || '');
|
sessionStorage.setItem('Authorization', res?.data?.token || '');
|
||||||
|
localStorage.setItem('loginType', activeTab);
|
||||||
|
if (values.remember) {
|
||||||
|
localStorage.setItem('remember_user', JSON.stringify({
|
||||||
|
username: values.username,
|
||||||
|
password: values.password,
|
||||||
|
}));
|
||||||
|
} else {
|
||||||
|
localStorage.removeItem('remember_user');
|
||||||
|
}
|
||||||
history.push('/redirect');
|
history.push('/redirect');
|
||||||
} else {
|
} else {
|
||||||
captchaRef.current?.refresh();
|
captchaRef.current?.refresh();
|
||||||
@ -62,8 +70,6 @@ const Login: React.FC = () => {
|
|||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('登录失败:', error);
|
console.error('登录失败:', error);
|
||||||
} finally {
|
|
||||||
setLoading(false);
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -170,6 +176,9 @@ const Login: React.FC = () => {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={styles.loginContainer}>
|
<div className={styles.loginContainer}>
|
||||||
|
<Helmet>
|
||||||
|
<title>登录</title>
|
||||||
|
</Helmet>
|
||||||
<Card className={styles.loginCard}>
|
<Card className={styles.loginCard}>
|
||||||
<Title level={2} style={{ textAlign: 'center', lineHeight: '80px', fontSize: 32, fontWeight: 700, marginBottom: 0 }}>
|
<Title level={2} style={{ textAlign: 'center', lineHeight: '80px', fontSize: 32, fontWeight: 700, marginBottom: 0 }}>
|
||||||
电子招投标平台
|
电子招投标平台
|
||||||
|
Reference in New Issue
Block a user