index.tsx 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. import { App, Button, Form, Input, Modal } from "antd"
  2. import React from "react"
  3. import '../../App.less'
  4. import { IdcardOutlined, UserOutlined } from "@ant-design/icons"
  5. import { useAjax } from "../../hooks/useAjax"
  6. import { realNameApi } from "../../api"
  7. import showMessage from "../../components/showMessage"
  8. interface Props {
  9. checkSwitch: boolean, // 是否强制实名
  10. onChange: () => void
  11. open?: boolean,
  12. onClose?: () => void
  13. isClick?: boolean
  14. }
  15. /**
  16. * 实名认证
  17. * @param param0
  18. * @returns
  19. */
  20. const AuthPop: React.FC<Props> = ({ checkSwitch, onChange, open, onClose, isClick }) => {
  21. /*********************************/
  22. const [form] = Form.useForm()
  23. const { message } = App.useApp()
  24. const realName = useAjax((params) => realNameApi(params))
  25. /*********************************/
  26. const onFinish = (values: any) => {
  27. realName.run(values).then(res => {
  28. if (+res.code === 200) {
  29. onChange()
  30. } else {
  31. showMessage.error(res.msg || '认证失败', message)
  32. }
  33. })
  34. };
  35. return <Modal
  36. open={open}
  37. width={310}
  38. centered={true}
  39. footer={null}
  40. keyboard={false}
  41. maskClosable={false}
  42. closable={isClick ? true : !checkSwitch}
  43. onCancel={(e) => { e.stopPropagation(); onClose?.() }}
  44. className="authPop"
  45. >
  46. <h4 className="float_pop-tit">实名认证</h4>
  47. <div className="float_pop-con">
  48. 根据国家规定,游戏用户需要进行实名认证。
  49. <span className="float_auth-msg"> · 信息仅用于认证且绝对保密</span>
  50. <span className="float_auth-msg"> · 未成年人游戏支付额度有限制</span>
  51. </div>
  52. <div style={{ marginTop: 10 }}>
  53. <Form
  54. name="basic"
  55. form={form}
  56. autoComplete='off'
  57. onFinish={onFinish}
  58. >
  59. <Form.Item name="cardName" style={{ marginBottom: 10 }} rules={[{ required: true, message: '请输入您的真实姓名!' }]}>
  60. <Input prefix={<UserOutlined />} placeholder="请输入您的真实姓名" size="large" />
  61. </Form.Item>
  62. <Form.Item name="cardId" rules={[{ required: true, message: '请输入您的身份证号码!' }]}>
  63. <Input prefix={<IdcardOutlined />} placeholder="请输入您的身份证号码" size="large" />
  64. </Form.Item>
  65. <Form.Item style={{ marginBottom: 10 }}>
  66. <Button type="primary" className="form_button" loading={realName.loading} htmlType="submit" size="large">立即认证</Button>
  67. </Form.Item>
  68. </Form>
  69. </div>
  70. </Modal>
  71. }
  72. export default React.memo(AuthPop)