QLogin.jsx 2.6KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. import React, { useEffect, useState } from "react";
  2. import { useNavigate } from "react-router-dom";
  3. import md5 from "md5";
  4. import { Button, Form, Input, Radio, Select, Row, Col, message } from "antd";
  5. import { login } from "@/services/login";
  6. import "./style.less";
  7. export default (props) => {
  8. const navigate = useNavigate();
  9. const [loading, setLoading] = React.useState(false);
  10. const [form] = Form.useForm();
  11. const onFinish = (values) => {
  12. setLoading(true);
  13. login({
  14. loginName: values.loginName,
  15. loginType: "platform.pc",
  16. password: md5(values.password),
  17. })
  18. .then((res) => {
  19. setLoading(true);
  20. try {
  21. navigate("/authentication");
  22. } catch (e) {
  23. message.error(e);
  24. }
  25. setLoading(false);
  26. })
  27. .catch((err) => {
  28. // console.log('----err--', err);
  29. setLoading(false);
  30. });
  31. setLoading(false);
  32. }
  33. return (
  34. <div className="qlogin-right-box">
  35. <div className="qlogin-right-title">登录你的Qbit账户</div>
  36. <Form
  37. form={form}
  38. layout="vertical"
  39. size="large"
  40. onFinish={onFinish}
  41. >
  42. <Form.Item
  43. label="手机号"
  44. name="loginName"
  45. // rules={[{ required: true }]}
  46. >
  47. <Input.Group>
  48. <Row>
  49. <Col span={8}>
  50. <Select defaultValue="+86">
  51. <Option value="+86" style={{ backgroundColor: '#f5f5f5' }}>+86</Option>
  52. <Option value="+852" style={{ backgroundColor: '#f5f5f5' }}>+852</Option>
  53. </Select>
  54. </Col>
  55. <Col span={16}><Input placeholder="请输入手机号" /></Col>
  56. </Row>
  57. </Input.Group>
  58. </Form.Item>
  59. <Form.Item
  60. label="密 码"
  61. name="password"
  62. rules={[{ required: true }]}
  63. >
  64. <Input.Password
  65. placeholder="请输入密码"
  66. style={{ borderRadius: "4px" }}
  67. />
  68. </Form.Item>
  69. <Form.Item>
  70. <Button
  71. type="primary"
  72. size="large"
  73. style={{ width: "100%", marginTop: "24px", borderRadius: "4px", height: '3em' }}
  74. htmlType="submit"
  75. >
  76. 登录
  77. </Button>
  78. </Form.Item>
  79. </Form>
  80. <div style={{ display: 'flex', alignItems: 'center' }}>
  81. <div>还没有Qbit账户?</div><Button type="link" onClick={() => navigate('/qRegister')}>立即注册</Button>
  82. </div>
  83. </div>
  84. )
  85. }