import React from 'react'; import ajax from 'jquery/src/ajax/xhr.js' import $ from 'jquery/src/ajax'; import { Modal, Button, Icon, Input, message } from 'antd'; import './changeModal.less'; const ChangePw = React.createClass({ getInitialState() { return { visible: false }; }, showModal() { this.setState({ visible: true, }); }, logOut() { $.ajax({ method: "get", dataType: "json", url: globalConfig.context + "/login", }).done(function (data) { window.location.href = globalConfig.context + "/user/login.html" }); }, handleOk() { if (this.state.newPw.length < 6 || this.state.newPw.length > 20) { message.warning('请使用长度为6-20位的密码!'); } else if (this.state.confirmPw !== this.state.newPw) { message.warning('两次密码输入不相同!'); } else if (this.state.confirmPw === this.state.newPw) { $.ajax({ method: "POST", dataType: "json", crossDomain: false, url: globalConfig.context + "/api/user/pwd", data: { "password": this.state.oldPw, "newPassword": this.state.newPw } }).done(function (data) { if (!data.error.length) { message.success('修改成功!'); this.setState({ visible: false, }); this.logOut(); } else { message.warning(data.error[0].message); } }.bind(this)); }; }, handleCancel(e) { this.setState({ visible: false, }); }, oldPwChange(e) { this.state.oldPw = e.target.value; }, newPwChange(e) { this.state.newPw = e.target.value; }, confirmPwChange(e) { this.state.confirmPw = e.target.value; }, render() { return (
确认, ]} >

密码长度为6-20个字符,区分大小写

原密码:

新密码:

确认密码:

); }, }); export default ChangePw;