|
| 1 | + |
| 2 | +import React, { PropTypes, Component } from 'react'; |
| 3 | +import withStyles from 'isomorphic-style-loader/lib/withStyles'; |
| 4 | +import s from './ChangePassword.css'; |
| 5 | +import _ from 'lodash'; |
| 6 | +import Link from '../Link'; |
| 7 | +import Button from '../Button'; |
| 8 | +import moment from 'moment'; |
| 9 | + |
| 10 | +class ChangePassword extends Component { |
| 11 | + static propTypes = { |
| 12 | + isFetching: PropTypes.bool, |
| 13 | + oldPassword: PropTypes.string, |
| 14 | + oldPasswordInputChange: PropTypes.func, |
| 15 | + newPassword: PropTypes.string, |
| 16 | + newPasswordInputChange: PropTypes.func, |
| 17 | + newPasswordConfirm: PropTypes.string, |
| 18 | + newPasswordConfirmInputChange: PropTypes.func, |
| 19 | + submit: PropTypes.func, |
| 20 | + }; |
| 21 | + |
| 22 | + static defaultProps = { |
| 23 | + isFetching: false, |
| 24 | + oldPassword: '', |
| 25 | + oldPasswordInputChange: (oldPassword)=>{}, |
| 26 | + newPassword: '', |
| 27 | + newPasswordInputChange: (newPassword)=>{}, |
| 28 | + newPasswordConfirm: '', |
| 29 | + newPasswordConfirmInputChange: (newPasswordConfirm)=>{}, |
| 30 | + submit: ()=>{}, |
| 31 | + }; |
| 32 | + |
| 33 | + constructor(){ |
| 34 | + super(); |
| 35 | + this.setOldPassword = this.setOldPassword.bind(this); |
| 36 | + this.setNewPassword = this.setNewPassword.bind(this); |
| 37 | + this.setNewPasswordConfirm = this.setNewPasswordConfirm.bind(this); |
| 38 | + } |
| 39 | + |
| 40 | + setOldPassword(event) { |
| 41 | + this.props.oldPasswordInputChange(event.target.value); |
| 42 | + } |
| 43 | + |
| 44 | + setNewPassword(event) { |
| 45 | + this.props.newPasswordInputChange(event.target.value); |
| 46 | + } |
| 47 | + |
| 48 | + setNewPasswordConfirm(event) { |
| 49 | + this.props.newPasswordConfirmInputChange(event.target.value); |
| 50 | + } |
| 51 | + |
| 52 | + render() { |
| 53 | + return ( |
| 54 | + <div className={s.root}> |
| 55 | + <div className={s.container}> |
| 56 | + <h1>修改密码</h1> |
| 57 | + <div className={s.formGroup}> |
| 58 | + <label className={s.label} htmlFor="oldPassword"> |
| 59 | + 旧密码: |
| 60 | + </label> |
| 61 | + <input |
| 62 | + className={s.input} |
| 63 | + onChange={this.setOldPassword} |
| 64 | + id="oldPassword" |
| 65 | + type="password" |
| 66 | + value={this.props.oldPassword} |
| 67 | + placeholder="请输入旧密码" |
| 68 | + autoFocus |
| 69 | + /> |
| 70 | + </div> |
| 71 | + <div className={s.formGroup}> |
| 72 | + <label className={s.label} htmlFor="newPassword"> |
| 73 | + 新密码: |
| 74 | + </label> |
| 75 | + <input |
| 76 | + className={s.input} |
| 77 | + onChange={this.setNewPassword} |
| 78 | + id="newPassword" |
| 79 | + type="password" |
| 80 | + value={this.props.newPassword} |
| 81 | + placeholder="请您输入新的密码" |
| 82 | + /> |
| 83 | + </div> |
| 84 | + <div className={s.formGroup}> |
| 85 | + <label className={s.label} htmlFor="newPasswordConfirm"> |
| 86 | + 确认新密码: |
| 87 | + </label> |
| 88 | + <input |
| 89 | + className={s.input} |
| 90 | + onChange={this.setNewPasswordConfirm} |
| 91 | + id="newPasswordConfirm" |
| 92 | + type="password" |
| 93 | + value={this.props.newPasswordConfirm} |
| 94 | + placeholder="请您再次输入新的密码" |
| 95 | + /> |
| 96 | + </div> |
| 97 | + <br/> |
| 98 | + <div className={s.formGroup}> |
| 99 | + <Button |
| 100 | + style={ |
| 101 | + this.props.isChecking ? |
| 102 | + { width:'71%', marginLeft: '27%', backgroundColor:'grey' } |
| 103 | + : { width:'71%', marginLeft: '27%' } |
| 104 | + } |
| 105 | + value="确认" |
| 106 | + onClick={()=>{ |
| 107 | + if (self.props.isChecking) { |
| 108 | + return; |
| 109 | + } |
| 110 | + self.props.submit(); |
| 111 | + }}/> |
| 112 | + </div> |
| 113 | + </div> |
| 114 | + </div> |
| 115 | + ); |
| 116 | + } |
| 117 | +} |
| 118 | +export default withStyles(s)(ChangePassword); |
0 commit comments