node-swallowjs
Version:
epp portal
66 lines (65 loc) • 1.93 kB
JSX
var ChangePasswd = React.createClass({
mixins: [FormMixin],
shouldUpdate: false,
getInitialState() {
return {}
},
shouldComponentUpdate(nextProps, nextState) {
if(this.shouldUpdate) return true;
api.show('password', function(code, data) {
this.shouldUpdate = true;
this.replaceState({password: data}, function() {
this.shouldUpdate = false;
});
}.bind(this));
return false;
},
handleSubmit(e) {
api.update('password', TRIM(this.state.password), function(code) {
switch(code) {
case '1000':
this.state.message = "修改口令成功";
break;
case '2501':
logout();
return;
default:
this.state.message = "修改口令失败";
}
this.forceUpdate();
}.bind(this));
},
render() {
return (
<div>
<table align="center" border="0">
<tbody>
<tr>
<td align="center" colSpan="2">{this.props.children}</td>
</tr>
<tr>
<td>口令:</td>
<td>
<input {...this.linkState({
name: 'password',
type: 'text',
size: 16,
maxLength: 16
})}/>
</td>
</tr>
<tr>
<td height="16" colSpan="2"></td>
</tr>
<tr>
<td align="center" colSpan="2">
<input type="button" value="提交" onClick={this.handleSubmit}/>
</td>
</tr>
</tbody>
</table>
<OpResult content={this.state.message} />
</div>
)
}
});