LoginForm.jsx 1.7KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. import React from "react";
  2. import md5 from "md5";
  3. import { Button, Form, Input, Radio } from "antd";
  4. import { login } from "@/services/login";
  5. export default (props) => {
  6. const { onSuccess, mode, appid } = props;
  7. const [form] = Form.useForm();
  8. const [loading, setLoading] = React.useState(false);
  9. console.log(process.env.NODE_ENV);
  10. const onFinish = (values) => {
  11. setLoading(true);
  12. login({
  13. loginName: values.loginName,
  14. loginType: "platform.pc",
  15. password: md5(values.password),
  16. })
  17. .then((res) => {
  18. setLoading(true);
  19. onSuccess(res.user);
  20. setLoading(false);
  21. })
  22. .catch((err) => {
  23. // console.log('----err--', err);
  24. setLoading(false);
  25. });
  26. setLoading(false);
  27. };
  28. return (
  29. <Form
  30. form={form}
  31. layout="vertical"
  32. onFinish={onFinish}
  33. // style={{ width: "260px", marginTop: "24px", paddingBottom: "24px" }}
  34. >
  35. <Form.Item
  36. label="账户"
  37. name="loginName"
  38. rules={[{ required: true, message: "请输入账户" }]}
  39. >
  40. <Input placeholder="请输入账户" style={{ borderRadius: "4px" }} />
  41. </Form.Item>
  42. <Form.Item
  43. label="密 码"
  44. name="password"
  45. rules={[{ required: true, message: "请输入密码" }]}
  46. >
  47. <Input.Password
  48. placeholder="请输入密码"
  49. style={{ borderRadius: "4px" }}
  50. />
  51. </Form.Item>
  52. <Form.Item>
  53. <Button
  54. type="primary"
  55. size="large"
  56. style={{ width: "100%", marginTop: "24px", borderRadius: "4px" }}
  57. loading={loading}
  58. htmlType="submit"
  59. >
  60. 登录
  61. </Button>
  62. </Form.Item>
  63. </Form>
  64. );
  65. };