import './css/RegisterWindow.css'; import { PropTypes, Window, Content, Buttons, Form, FormControl, Label, Input, Button } from '../../third_party'; import Ajax from '../../utils/Ajax'; /** * 注册窗口 * @author tengge / https://github.com/tengge1 */ class RegisterWindow extends React.Component { constructor(props) { super(props); this.state = { username: '', password: '', confirmPassword: '', name: '' }; this.handleChange = this.handleChange.bind(this); this.handleLogin = this.handleLogin.bind(this, props.callback); this.handleClose = this.handleClose.bind(this); } render() { const { username, password, confirmPassword, name } = this.state; return
; } handleChange(value, name) { this.setState({ [name]: value }); } handleLogin() { const { username, password } = this.state; fetch(`/api/Login/Login`, { method: 'POST', headers: { 'Content-Type': 'application/x-www-form-urlencoded' }, body: `Username=${username}&Password=${password}` }).then(response => { response.json().then(json => { if (json.Code !== 200) { app.toast(_t(json.Msg)); return; } this.handleClose(); }); }); } handleClose() { app.removeElement(this); } } export default RegisterWindow;