|
@@ -31,6 +31,8 @@ export default class PhoneBind extends BasePage {
|
|
|
type: '',
|
|
|
phone_num: '',
|
|
|
verification_text: '获取验证码',
|
|
|
+ verification_code: '',
|
|
|
+ http_verification_code: '',
|
|
|
page_title_text: '绑定手机号',
|
|
|
click_ok_text: '绑 定'
|
|
|
};
|
|
@@ -70,7 +72,9 @@ export default class PhoneBind extends BasePage {
|
|
|
</View>
|
|
|
</View>
|
|
|
<View style={styles.loginIn}>
|
|
|
- <Text style={styles.loginText}>{this.state.click_ok_text}</Text>
|
|
|
+ <Text style={styles.loginText} onPress={this.clickOK.bind(this)}>
|
|
|
+ {this.state.click_ok_text}
|
|
|
+ </Text>
|
|
|
</View>
|
|
|
<View style={styles.wechatLogin}>
|
|
|
{/* <Image source={require('./images/common/wechat.png')} /> */}
|
|
@@ -102,11 +106,22 @@ export default class PhoneBind extends BasePage {
|
|
|
getVerification() {
|
|
|
if (this.state.verification_text === '获取验证码') {
|
|
|
if (this.isPoneAvailable(this.state.phone_num)) {
|
|
|
- // http_user.getVerificationCode(this.state.phone_num);
|
|
|
- this.setState({
|
|
|
- verification_text: '60'
|
|
|
+ http_user.getVerificationCode(this.state.phone_num).then((result) => {
|
|
|
+ if (result.code != 200) {
|
|
|
+ ToastAndroid.show(result.message, ToastAndroid.SHORT);
|
|
|
+ } else {
|
|
|
+ console.log('====================================');
|
|
|
+ console.log(result.data);
|
|
|
+ console.log('====================================');
|
|
|
+ this.setState({
|
|
|
+ http_verification_code: result.data
|
|
|
+ });
|
|
|
+ }
|
|
|
+ this.setState({
|
|
|
+ verification_text: '60'
|
|
|
+ });
|
|
|
+ this.CountDown();
|
|
|
});
|
|
|
- this.CountDown();
|
|
|
} else {
|
|
|
ToastAndroid.show('请输入正确的手机号', ToastAndroid.SHORT);
|
|
|
}
|
|
@@ -120,14 +135,11 @@ export default class PhoneBind extends BasePage {
|
|
|
verification_text: '获取验证码'
|
|
|
});
|
|
|
} else {
|
|
|
- console.log('====================================');
|
|
|
- console.log(parseInt(this.state.verification_text) - 1 + '');
|
|
|
- console.log('====================================');
|
|
|
setTimeout(() => {
|
|
|
this.setState({
|
|
|
verification_text: parseInt(this.state.verification_text) - 1 + ''
|
|
|
});
|
|
|
- CountDown();
|
|
|
+ this.CountDown();
|
|
|
}, 1000);
|
|
|
}
|
|
|
}
|
|
@@ -143,6 +155,23 @@ export default class PhoneBind extends BasePage {
|
|
|
return true;
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ //绑定手机号
|
|
|
+ clickOK() {
|
|
|
+ if (this.state.http_verification_code == this.state.verification_code) {
|
|
|
+ let option = {
|
|
|
+ method: 'PUT', //请求方法
|
|
|
+ //请求体
|
|
|
+ body: {
|
|
|
+ mobile: this.state.phone_num,
|
|
|
+ sign: this.state.verification_code
|
|
|
+ }
|
|
|
+ };
|
|
|
+ http_user.bind_phone(option).then((result) => {});
|
|
|
+ } else {
|
|
|
+ ToastAndroid.show('验证码不正确', ToastAndroid.SHORT);
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
const styles = StyleSheet.create({
|