2023-08-30 13:55:59 +08:00
|
|
|
|
import { Form, Input, Button, Checkbox, message, Col, Row } from 'antd';
|
|
|
|
|
import { useNavigate } from 'react-router-dom';
|
|
|
|
|
import { passwordLogin } from '../../api';
|
|
|
|
|
import '../../index.less';
|
|
|
|
|
import loginStore from '../../store/login.store';
|
|
|
|
|
|
|
|
|
|
function Login (e) {
|
|
|
|
|
let navigate = useNavigate();
|
|
|
|
|
const [form] = Form.useForm();
|
|
|
|
|
let onFinish = async (values) => {
|
2023-10-16 22:18:50 +08:00
|
|
|
|
passwordLogin({phone: values.phone, password: values.password}).then((e) => {
|
2023-08-30 13:55:59 +08:00
|
|
|
|
if (!e.success) {
|
2023-10-15 23:29:59 +08:00
|
|
|
|
message.error(e.message);
|
2023-08-30 13:55:59 +08:00
|
|
|
|
} else {
|
2024-05-27 16:17:02 +08:00
|
|
|
|
let setToken = loginStore;
|
|
|
|
|
setToken.setAuthName(e.data.username);
|
|
|
|
|
setToken.setToken(e.data.token)
|
2023-10-15 23:29:59 +08:00
|
|
|
|
navigate('/home');
|
2023-08-30 13:55:59 +08:00
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
let onFinishFailed = (errorInfo) => {
|
|
|
|
|
console.log('Failed:', errorInfo);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<Form
|
|
|
|
|
form={form}
|
|
|
|
|
name="basic"
|
|
|
|
|
labelCol={{
|
|
|
|
|
span: 16,
|
|
|
|
|
offset: 4,
|
|
|
|
|
}}
|
|
|
|
|
wrapperCol={{
|
|
|
|
|
span: 16,
|
|
|
|
|
offset: 4,
|
|
|
|
|
}}
|
|
|
|
|
layout='vertical'
|
|
|
|
|
initialValues={{
|
|
|
|
|
remember: true,
|
|
|
|
|
}}
|
|
|
|
|
onFinish={onFinish}
|
|
|
|
|
onFinishFailed={onFinishFailed}
|
|
|
|
|
autoComplete="off"
|
|
|
|
|
>
|
|
|
|
|
<Form.Item
|
2023-10-16 22:18:50 +08:00
|
|
|
|
label="手机号"
|
|
|
|
|
name="phone"
|
2023-08-30 13:55:59 +08:00
|
|
|
|
className='formItemStyle'
|
|
|
|
|
rules={[
|
|
|
|
|
{
|
|
|
|
|
required: true,
|
2023-10-16 22:18:50 +08:00
|
|
|
|
message: '手机号不能为空!',
|
2023-08-30 13:55:59 +08:00
|
|
|
|
},
|
|
|
|
|
]}
|
2023-09-06 20:23:32 +08:00
|
|
|
|
style={{marginBottom: '45px'}}
|
2023-08-30 13:55:59 +08:00
|
|
|
|
>
|
2023-10-16 22:18:50 +08:00
|
|
|
|
<Input placeholder='请输入手机号'/>
|
2023-08-30 13:55:59 +08:00
|
|
|
|
</Form.Item>
|
|
|
|
|
|
|
|
|
|
<Form.Item
|
|
|
|
|
label="密码"
|
|
|
|
|
name="password"
|
|
|
|
|
className='formItemStyle'
|
|
|
|
|
rules={[
|
|
|
|
|
{
|
|
|
|
|
required: true,
|
|
|
|
|
message: '密码不能为空!',
|
|
|
|
|
},
|
|
|
|
|
]}
|
|
|
|
|
>
|
|
|
|
|
<Input.Password placeholder='请输入密码' bordered={false}/>
|
|
|
|
|
</Form.Item>
|
|
|
|
|
|
2023-10-15 23:29:59 +08:00
|
|
|
|
{/* <Form.Item
|
2023-08-30 13:55:59 +08:00
|
|
|
|
name="remember"
|
|
|
|
|
valuePropName="checked"
|
2023-09-06 20:23:32 +08:00
|
|
|
|
style={{marginTop: '38px'}}
|
2023-08-30 13:55:59 +08:00
|
|
|
|
>
|
|
|
|
|
<Checkbox style={{fontSize: '18px'}}>同意<a>服务条款</a></Checkbox>
|
|
|
|
|
<a style={{float: 'right', fontSize: '18px'}}>忘记密码?</a>
|
2023-10-15 23:29:59 +08:00
|
|
|
|
</Form.Item> */}
|
2023-08-30 13:55:59 +08:00
|
|
|
|
|
2023-09-06 20:23:32 +08:00
|
|
|
|
<Form.Item style={{marginTop: '68px'}}>
|
2023-11-08 17:31:50 +08:00
|
|
|
|
<Button type="primary" htmlType="submit" style={{height: '60px'}} block>密码登录</Button>
|
2023-10-15 23:29:59 +08:00
|
|
|
|
<a className='new-user' href='/register'>新用户注册</a>
|
2023-08-30 13:55:59 +08:00
|
|
|
|
</Form.Item>
|
|
|
|
|
</Form>
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
export default Login;
|