@@ -17,6 +17,7 @@ class ChangePassword extends Component {
1717 newPasswordConfirm : PropTypes . string ,
1818 newPasswordConfirmInputChange : PropTypes . func ,
1919 submit : PropTypes . func ,
20+ error : PropTypes . object ,
2021 } ;
2122
2223 static defaultProps = {
@@ -28,10 +29,12 @@ class ChangePassword extends Component {
2829 newPasswordConfirm : '' ,
2930 newPasswordConfirmInputChange : ( newPasswordConfirm ) => { } ,
3031 submit : ( ) => { } ,
32+ error : { } ,
3133 } ;
3234
3335 constructor ( ) {
3436 super ( ) ;
37+ this . state = { field1 : false , field2 : false , field3 : false } ;
3538 this . setOldPassword = this . setOldPassword . bind ( this ) ;
3639 this . setNewPassword = this . setNewPassword . bind ( this ) ;
3740 this . setNewPasswordConfirm = this . setNewPasswordConfirm . bind ( this ) ;
@@ -50,10 +53,26 @@ class ChangePassword extends Component {
5053 }
5154
5255 render ( ) {
56+ let self = this ;
57+ let isValidate = true ;
58+ let oldPasswordTips = '' ;
59+ if ( ! this . props . oldPassword ) {
60+ isValidate = false ;
61+ oldPasswordTips = '请您输入旧密码' ;
62+ }
63+ let newPasswordTips = '' ;
64+ let newPasswordConfirmTips = '' ;
65+ if ( this . props . newPassword . length < 6 ) {
66+ newPasswordTips = '请您输入6~22位字符或数字'
67+ }
68+ if ( ! _ . eq ( this . props . newPassword , this . props . newPasswordConfirm ) ) {
69+ isValidate = false ;
70+ newPasswordConfirmTips = '两次输入的密码不一致'
71+ }
72+
5373 return (
5474 < div className = { s . root } >
5575 < div className = { s . container } >
56- < h1 > 修改密码</ h1 >
5776 < div className = { s . formGroup } >
5877 < label className = { s . label } htmlFor = "oldPassword" >
5978 旧密码:
@@ -66,8 +85,14 @@ class ChangePassword extends Component {
6685 value = { this . props . oldPassword }
6786 placeholder = "请输入旧密码"
6887 autoFocus
88+ onBlur = { ( ) => this . setState ( { field1 : true } ) }
6989 />
7090 </ div >
91+ {
92+ this . state . field1 ?
93+ < div className = { s . errorTip } > { oldPasswordTips } </ div >
94+ : null
95+ }
7196 < div className = { s . formGroup } >
7297 < label className = { s . label } htmlFor = "newPassword" >
7398 新密码:
@@ -79,8 +104,14 @@ class ChangePassword extends Component {
79104 type = "password"
80105 value = { this . props . newPassword }
81106 placeholder = "请您输入新的密码"
107+ onBlur = { ( ) => this . setState ( { field2 : true } ) }
82108 />
83109 </ div >
110+ {
111+ this . state . field2 ?
112+ < div className = { s . errorTip } > { newPasswordTips } </ div >
113+ : null
114+ }
84115 < div className = { s . formGroup } >
85116 < label className = { s . label } htmlFor = "newPasswordConfirm" >
86117 确认新密码:
@@ -92,19 +123,26 @@ class ChangePassword extends Component {
92123 type = "password"
93124 value = { this . props . newPasswordConfirm }
94125 placeholder = "请您再次输入新的密码"
126+ onBlur = { ( ) => this . setState ( { field3 : true } ) }
95127 />
96128 </ div >
129+ {
130+ this . state . field3 ?
131+ < div className = { s . errorTip } > { newPasswordConfirmTips } </ div >
132+ : null
133+ }
97134 < br />
135+ < div className = { s . errorTip } > { _ . get ( this . props , 'error.message' ) } </ div >
98136 < div className = { s . formGroup } >
99137 < Button
100138 style = {
101- this . props . isChecking ?
139+ this . props . isFetching || ! isValidate ?
102140 { width :'71%' , marginLeft : '27%' , backgroundColor :'grey' }
103141 : { width :'71%' , marginLeft : '27%' }
104142 }
105143 value = "确认"
106144 onClick = { ( ) => {
107- if ( self . props . isChecking ) {
145+ if ( self . props . isFetching || ! isValidate ) {
108146 return ;
109147 }
110148 self . props . submit ( ) ;
0 commit comments