Authored by lixia.zhang

验证码倒计时,review by 戴强

... ... @@ -70,9 +70,11 @@ let styles = StyleSheet.create({
titleContainer: {
alignItems:'center',
marginTop: 19,
marginBottom:15
marginBottom:15,
},
contentContainer: {
marginLeft: 15,
marginRight: 15
},
content: {
color: '#444444',
... ...
... ... @@ -31,7 +31,54 @@ export default class UserLogoutReason extends Component {
image0Degree: 0,
image1Degree: 0,
image2Degree: 0,
image3Degree: 0
image3Degree: 0,
countDown: 59,
tickTimeOut: false,
resendBtnText: '获取',
}
}
_startTimer() {
this.timer = setInterval(function () {
let count = this.state.countDown - 1;
if (count < 0) {
count = 60;
this.setState({
countDown: count,
tickTimeOut: true,
resendBtnText: '获取',
});
}
if (!this.state.tickTimeOut) {
this.setState({
countDown: count,
resendBtnText: count+'s',
});
}
}.bind(this), 1000);
}
componentWillUnmount() {
this.timer && clearInterval(this.timer);
}
_sendConfirmPaySnsCode() {
if (this.state.mobile == '') {
this.props.mobileEmptyTip();
return;
}
if (this.state.resendBtnText !== '获取') {
return;
}else {
this.setState({
countDown: 60,
tickTimeOut: false,
resendBtnText: '59s',
});
this._startTimer();
var degrees = this.state.image0Degree + ',' + this.state.image1Degree + ',' + this.state.image2Degree + ',' + this.state.image3Degree;
this.props.fetchCanleCode && this.props.fetchCanleCode(this.state.mobile, degrees)
}
}
... ... @@ -103,10 +150,9 @@ export default class UserLogoutReason extends Component {
<TouchableOpacity
style={{width:70,height:35,marginRight:5}}
onPress={() => {
var degrees = this.state.image0Degree + ',' + this.state.image1Degree + ',' + this.state.image2Degree + ',' + this.state.image3Degree;
this.props.fetchCanleCode && this.props.fetchCanleCode(this.state.mobile, degrees)
this._sendConfirmPaySnsCode()
}}>
<Text style={{lineHeight:30,textAlign:'right',fontSize:14,color:'#444444',letterSpacing:-0.34}}>获取</Text>
<Text style={{lineHeight:30,textAlign:'right',fontSize:14,color:'#444444',letterSpacing:-0.34}}>{this.state.resendBtnText}</Text>
</TouchableOpacity>
</View>
{this.props.imageCheckSwitchState ?
... ...
... ... @@ -51,6 +51,7 @@ class UserLogoutReasonContainer extends Component {
this._changeImageCode = this._changeImageCode.bind(this);
this._onPromptHidden = this._onPromptHidden.bind(this);
this._gotoLogoutStatus = this._gotoLogoutStatus.bind(this);
this._mobileEmptyTip = this._mobileEmptyTip.bind(this);
}
componentDidMount() {
... ... @@ -85,6 +86,10 @@ class UserLogoutReasonContainer extends Component {
this.props.actions.updateTipMessage('');
}
_mobileEmptyTip() {
this.props.actions.updateTipMessage('手机号不能为空');
}
_gotoLogoutStatus(){
this.props.actions.gotoLogoutStatus();
}
... ... @@ -106,6 +111,7 @@ class UserLogoutReasonContainer extends Component {
changeImageCode={this._changeImageCode}
onPromptHidden={this._onPromptHidden}
gotoLogoutStatus={this._gotoLogoutStatus}
mobileEmptyTip={this._mobileEmptyTip}
submitBtnEnable={submitBtnEnable}
showModalFlag={showModalFlag}
imageCheckSwitchState={imageCheckSwitchState}
... ...
... ... @@ -94,8 +94,7 @@ export function confirmLogout(code, reason) {
let udid = ReactNative.NativeModules.RNNativeConfig.udid;
return new UserLogoutReasonService('http://api-test3.yohops.com:9999/').confirmLogout(code, reason, udid)
.then(json => {
console.log(json);
// dispatch(showLogoutReasonModal(false));
dispatch(showLogoutReasonModal(false));
dispatch(gotoLogoutStatus());
})
... ...