Commit 52976fe483c1fccc59d68d05cc649b5699b6fade
1 parent
dbd74436
用户注册功能开发;
Showing
1 changed file
with
52 additions
and
6 deletions
src/components/UserRegistration/index.jsx
| 1 | 1 | import { useState, useEffect } from "react"; |
| 2 | -import { ConfigProvider, Modal, Form, Input, Select, message } from "antd"; | |
| 2 | +import { ConfigProvider, Modal, Form, Input, Select, message, Button } from "antd"; | |
| 3 | 3 | import commonConfig from "@/utils/config"; |
| 4 | 4 | import * as commonServices from "@/services/services"; |
| 5 | 5 | |
| ... | ... | @@ -33,7 +33,7 @@ const UserRegistration = ({ _this }) => { |
| 33 | 33 | if (!userRegisterMode) return ""; |
| 34 | 34 | |
| 35 | 35 | const props = UserRegistrationEvent(); |
| 36 | - const { customerData = [] } = props; | |
| 36 | + const { customerData = [], successModalVisible } = props; | |
| 37 | 37 | |
| 38 | 38 | const [form] = Form.useForm(); |
| 39 | 39 | |
| ... | ... | @@ -47,13 +47,40 @@ const UserRegistration = ({ _this }) => { |
| 47 | 47 | form.submit(); |
| 48 | 48 | }; |
| 49 | 49 | |
| 50 | - const onFinish = values => { | |
| 51 | - console.log("=====Success:", values); | |
| 50 | + const onFinish = ({ username, phonenumber, sCustomerId }) => { | |
| 51 | + const url = `${commonConfig.feedback_host}sftlogininfo/insertPasswordUserName/add`; | |
| 52 | + const params = { | |
| 53 | + sUserName: username, | |
| 54 | + sLanguage: "sChinese", | |
| 55 | + sBrandsId: "1111111111", | |
| 56 | + sSubsidiaryId: "1111111111", | |
| 57 | + sPhone: phonenumber, | |
| 58 | + sCustomerId, | |
| 59 | + }; | |
| 60 | + commonServices.postValueService("", params, url).then(({ data: result = {} }) => { | |
| 61 | + const { code = -1, msg = "接口出错" } = result; | |
| 62 | + if (code > -1) { | |
| 63 | + props.setState({ | |
| 64 | + successModalVisible: true, | |
| 65 | + phonenumber, | |
| 66 | + }); | |
| 67 | + } else { | |
| 68 | + message.error(msg); | |
| 69 | + } | |
| 70 | + }); | |
| 52 | 71 | }; |
| 53 | 72 | |
| 54 | 73 | return ( |
| 55 | 74 | <ConfigProvider prefixCls="antdV5"> |
| 56 | - <Modal title="用户注册" open={userRegisterMode} okText="确认" cancelText="取消" onOk={handleOk} onCancel={handleCancel} width={400}> | |
| 75 | + <Modal | |
| 76 | + title="用户注册" | |
| 77 | + open={userRegisterMode && !successModalVisible} | |
| 78 | + okText="确认" | |
| 79 | + cancelText="取消" | |
| 80 | + onOk={handleOk} | |
| 81 | + onCancel={handleCancel} | |
| 82 | + width={400} | |
| 83 | + > | |
| 57 | 84 | <Form |
| 58 | 85 | name="basic" |
| 59 | 86 | form={form} |
| ... | ... | @@ -71,7 +98,7 @@ const UserRegistration = ({ _this }) => { |
| 71 | 98 | |
| 72 | 99 | <Form.Item |
| 73 | 100 | label="手机号" |
| 74 | - name="telenumber" | |
| 101 | + name="phonenumber" | |
| 75 | 102 | rules={[ |
| 76 | 103 | { required: true, message: "未填写手机号!" }, |
| 77 | 104 | { |
| ... | ... | @@ -93,6 +120,25 @@ const UserRegistration = ({ _this }) => { |
| 93 | 120 | </Form.Item> |
| 94 | 121 | </Form> |
| 95 | 122 | </Modal> |
| 123 | + <Modal | |
| 124 | + open={successModalVisible} | |
| 125 | + title="注册成功" | |
| 126 | + onCancel={handleCancel} | |
| 127 | + footer={ | |
| 128 | + <Button type="primary" onClick={handleCancel}> | |
| 129 | + 确认 | |
| 130 | + </Button> | |
| 131 | + } | |
| 132 | + width={400} | |
| 133 | + > | |
| 134 | + <p style={{ fontWeight: "bold", fontSize: 16 }}>请等待【管理员审核】成功后用以下账号登陆!</p> | |
| 135 | + <p> | |
| 136 | + 用户名: <span style={{ fontSize: 16 }}>{props.phonenumber}</span> | |
| 137 | + </p> | |
| 138 | + <p> | |
| 139 | + 密 码: <span style={{ fontSize: 16 }}>{props.phonenumber}</span> | |
| 140 | + </p> | |
| 141 | + </Modal> | |
| 96 | 142 | </ConfigProvider> |
| 97 | 143 | ); |
| 98 | 144 | }; | ... | ... |