登录与品类
This commit is contained in:
@ -3,7 +3,7 @@ import { Form, Input, Button, Checkbox, Tabs, message } from 'antd';
|
||||
import { UserOutlined, LockOutlined, EyeInvisibleOutlined, EyeTwoTone } from '@ant-design/icons';
|
||||
import { history, useIntl } from 'umi';
|
||||
import './login.less';
|
||||
import { getCaptcha, supplierLogin, expertLogin, accountLogin, getUserinfo, refreshDictCache } from '@/servers/api/login';
|
||||
import { getCaptcha, supplierLogin, expertLogin, accountLogin, getUserinfo, refreshDictCache, findMenuList } from '@/servers/api/login';
|
||||
|
||||
import { encryptWithRsa } from '@/utils/encryptWithRsa'
|
||||
|
||||
@ -26,18 +26,20 @@ const LoginPage: React.FC = () => {
|
||||
|
||||
useEffect(() => {
|
||||
fetchCaptcha();
|
||||
if(!sessionStorage.getItem('dict')) {
|
||||
if (!sessionStorage.getItem('dict')) {
|
||||
refreshDictCache().then((res) => {
|
||||
if(res.code == 200) {
|
||||
if (res.code == 200) {
|
||||
sessionStorage.setItem('dict', JSON.stringify(res.data))
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
form.setFieldsValue( { password: 'cosco2025', identifying: '1' } )
|
||||
|
||||
|
||||
}, [activeKey]);
|
||||
|
||||
// 组件挂载时,检查是否有记住的用户名
|
||||
// 组件挂载时,检查是否有记住的用户名
|
||||
useEffect(() => {
|
||||
// const savedUser = localStorage.getItem('remember_user');
|
||||
// if (savedUser) {
|
||||
@ -88,25 +90,14 @@ const LoginPage: React.FC = () => {
|
||||
// })
|
||||
}
|
||||
sessionStorage.setItem('currentUser', JSON.stringify(loginRes.data));
|
||||
|
||||
|
||||
getUserinfo().then(async (res) => {
|
||||
// if(res.code == 200) {
|
||||
const roleIdList = res.authorityList.map((item: any) => {
|
||||
return item.roleId
|
||||
})
|
||||
console.log(roleIdList, 'roleIdList');
|
||||
await getUserinfo().then(async (res) => {
|
||||
const roleIdList = res.authorityList.map((item: any) => item.roleId);
|
||||
sessionStorage.setItem('Userinfo', JSON.stringify(res));
|
||||
// const menuList = await findMenuList({ roleIdList });
|
||||
// sessionStorage.setItem('menuList', JSON.stringify(menuList.data));
|
||||
// }
|
||||
})
|
||||
|
||||
|
||||
|
||||
|
||||
message.success('登录成功');
|
||||
history.push('/index');
|
||||
const menuList: any = await findMenuList({ roleIdList });
|
||||
sessionStorage.setItem('menuList', JSON.stringify(menuList.data));
|
||||
message.success('登录成功');
|
||||
history.push('/index');
|
||||
});
|
||||
} else {
|
||||
message.error(loginRes.message || '登录失败');
|
||||
}
|
||||
@ -162,7 +153,7 @@ const LoginPage: React.FC = () => {
|
||||
|
||||
// 忘记密码点击
|
||||
const onForgot = () => {
|
||||
history.push('/forgot?type='+activeKey);
|
||||
history.push('/forgot?type=' + activeKey);
|
||||
}
|
||||
|
||||
return (
|
||||
@ -179,7 +170,7 @@ const LoginPage: React.FC = () => {
|
||||
<div className="login-tab-container">
|
||||
<Tabs activeKey={activeKey} onChange={handleTabChange} className='login-tabs'>
|
||||
<TabPane tab={intl.formatMessage({ id: 'login.tab.supplier' })} key="supplierLogin" />
|
||||
<TabPane tab={intl.formatMessage({ id: 'login.tab.expert' })} key="expertLogin" />
|
||||
{/* <TabPane tab={intl.formatMessage({ id: 'login.tab.expert' })} key="expertLogin" /> */}
|
||||
<TabPane tab={intl.formatMessage({ id: 'login.tab.agent' })} key="accountLogin" />
|
||||
</Tabs>
|
||||
</div>
|
||||
@ -239,7 +230,7 @@ const LoginPage: React.FC = () => {
|
||||
<Form.Item name="remember" valuePropName="checked" noStyle>
|
||||
<Checkbox>{intl.formatMessage({ id: 'login.remember' })}</Checkbox>
|
||||
</Form.Item>
|
||||
<Button type="link" onClick={()=>onForgot()} className="login-form-forgot" href="">
|
||||
<Button type="link" onClick={() => onForgot()} className="login-form-forgot" href="">
|
||||
{intl.formatMessage({ id: 'login.forgot' })}
|
||||
</Button>
|
||||
</div>
|
||||
|
Reference in New Issue
Block a user