|
@@ -3,27 +3,18 @@
|
|
*/
|
|
*/
|
|
import React, { Component } from 'react';
|
|
import React, { Component } from 'react';
|
|
import {
|
|
import {
|
|
- Platform,
|
|
|
|
StyleSheet,
|
|
StyleSheet,
|
|
Text,
|
|
Text,
|
|
View,
|
|
View,
|
|
Image,
|
|
Image,
|
|
TouchableOpacity,
|
|
TouchableOpacity,
|
|
- ImageBackground,
|
|
|
|
- Button,
|
|
|
|
- StatusBar,
|
|
|
|
- Modal,
|
|
|
|
- TouchableHighlight,
|
|
|
|
ToastAndroid,
|
|
ToastAndroid,
|
|
- DeviceEventEmitter,
|
|
|
|
|
|
+ StatusBar,
|
|
TextInput,
|
|
TextInput,
|
|
- ScrollView
|
|
|
|
|
|
+ BackHandler
|
|
} from 'react-native';
|
|
} from 'react-native';
|
|
import BasePage from './BasePage';
|
|
import BasePage from './BasePage';
|
|
import Dimensions from './utils/dimensions';
|
|
import Dimensions from './utils/dimensions';
|
|
-import ShopBox from './components/ShopBox';
|
|
|
|
-import TopicTitle from './components/TopicTitle';
|
|
|
|
-import ScrollRow from './components/ScrollRow';
|
|
|
|
import http_user from './services/user';
|
|
import http_user from './services/user';
|
|
import commonutil from './utils/commonutil';
|
|
import commonutil from './utils/commonutil';
|
|
|
|
|
|
@@ -35,15 +26,29 @@ export default class PhoneBind extends BasePage {
|
|
verification_code: '',
|
|
verification_code: '',
|
|
http_verification_code: '',
|
|
http_verification_code: '',
|
|
page_title_text: '绑定手机号',
|
|
page_title_text: '绑定手机号',
|
|
- click_ok_text: '绑 定'
|
|
|
|
|
|
+ click_ok_text: '绑 定',
|
|
|
|
+ phone_bind_result: false
|
|
};
|
|
};
|
|
render() {
|
|
render() {
|
|
return (
|
|
return (
|
|
<View style={styles.wrapper}>
|
|
<View style={styles.wrapper}>
|
|
- <View style={styles.jump}>
|
|
|
|
- <TouchableOpacity style={styles.jumpBtn}>
|
|
|
|
- <Text style={styles.jumpText}>{this.state.page_title_text}</Text>
|
|
|
|
- </TouchableOpacity>
|
|
|
|
|
|
+ <StatusBar backgroundColor={'white'} translucent={true} barStyle={'dark-content'} />
|
|
|
|
+
|
|
|
|
+ <View style={{ flex: 2 }}>
|
|
|
|
+ <View style={{ marginTop: '6%', flex: 2, flexDirection: 'row' }}>
|
|
|
|
+ <TouchableOpacity
|
|
|
|
+ style={{ marginLeft: '5%' }}
|
|
|
|
+ activeOpacity={1}
|
|
|
|
+ onPress={this.backresult.bind(this)}
|
|
|
|
+ >
|
|
|
|
+ <Image source={require('./images/schedulePage/back_black.png')} />
|
|
|
|
+ </TouchableOpacity>
|
|
|
|
+ </View>
|
|
|
|
+ <View style={styles.jump}>
|
|
|
|
+ <TouchableOpacity style={styles.jumpBtn}>
|
|
|
|
+ <Text style={styles.jumpText}>{this.state.page_title_text}</Text>
|
|
|
|
+ </TouchableOpacity>
|
|
|
|
+ </View>
|
|
</View>
|
|
</View>
|
|
<View style={styles.phoneNumberBox}>
|
|
<View style={styles.phoneNumberBox}>
|
|
<Text style={styles.phoneNumber}>手机号</Text>
|
|
<Text style={styles.phoneNumber}>手机号</Text>
|
|
@@ -86,24 +91,39 @@ export default class PhoneBind extends BasePage {
|
|
);
|
|
);
|
|
}
|
|
}
|
|
componentWillMount() {
|
|
componentWillMount() {
|
|
- switch (this.props.navigation.state.params.type) {
|
|
|
|
|
|
+ BackHandler.addEventListener('hardwareBackPress', this.onBackAndroid);
|
|
|
|
+ var type;
|
|
|
|
+ if (this.props.navigation.state.params == undefined) {
|
|
|
|
+ type = 1;
|
|
|
|
+ } else {
|
|
|
|
+ type = this.props.navigation.state.params.type;
|
|
|
|
+ }
|
|
|
|
+ switch (type) {
|
|
case 1:
|
|
case 1:
|
|
this.setState({
|
|
this.setState({
|
|
- type: this.props.navigation.state.params.type,
|
|
|
|
|
|
+ type: type,
|
|
page_title_text: '绑定手机号',
|
|
page_title_text: '绑定手机号',
|
|
click_ok_text: '绑 定'
|
|
click_ok_text: '绑 定'
|
|
});
|
|
});
|
|
break;
|
|
break;
|
|
case 2:
|
|
case 2:
|
|
this.setState({
|
|
this.setState({
|
|
- type: this.props.navigation.state.params.type,
|
|
|
|
|
|
+ type: type,
|
|
page_title_text: '修改手机号',
|
|
page_title_text: '修改手机号',
|
|
click_ok_text: '修 改'
|
|
click_ok_text: '修 改'
|
|
});
|
|
});
|
|
break;
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+ componentWillUnmount() {
|
|
|
|
+ BackHandler.removeEventListener('hardwareBackPress', this.onBackAndroid);
|
|
|
|
+ }
|
|
|
|
|
|
|
|
+ onBackAndroid = () => {
|
|
|
|
+ this.props.navigation.state.params.bind_phone_back(this.state.phone_num, this.state.phone_bind_result);
|
|
|
|
+ this.props.navigation.goBack();
|
|
|
|
+ return true;
|
|
|
|
+ };
|
|
getVerification() {
|
|
getVerification() {
|
|
if (this.state.verification_text === '获取验证码') {
|
|
if (this.state.verification_text === '获取验证码') {
|
|
if (commonutil.isPoneAvailable(this.state.phone_num)) {
|
|
if (commonutil.isPoneAvailable(this.state.phone_num)) {
|
|
@@ -148,6 +168,14 @@ export default class PhoneBind extends BasePage {
|
|
|
|
|
|
//绑定手机号
|
|
//绑定手机号
|
|
clickOK() {
|
|
clickOK() {
|
|
|
|
+ if (!commonutil.isPoneAvailable(this.state.phone_num)) {
|
|
|
|
+ ToastAndroid.show('请输入正确的手机号', ToastAndroid.SHORT);
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ if (this.state.verification_code == '') {
|
|
|
|
+ ToastAndroid.show('请输入验证码', ToastAndroid.SHORT);
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
if (this.state.http_verification_code == this.state.verification_code) {
|
|
if (this.state.http_verification_code == this.state.verification_code) {
|
|
let option = {
|
|
let option = {
|
|
method: 'PUT', //请求方法
|
|
method: 'PUT', //请求方法
|
|
@@ -157,11 +185,28 @@ export default class PhoneBind extends BasePage {
|
|
sign: this.state.verification_code
|
|
sign: this.state.verification_code
|
|
}
|
|
}
|
|
};
|
|
};
|
|
- http_user.bind_phone(option).then((result) => {});
|
|
|
|
|
|
+ http_user.bind_phone(option).then((result) => {
|
|
|
|
+ if (result.code == 200) {
|
|
|
|
+ this.setState({
|
|
|
|
+ phone_bind_result: true
|
|
|
|
+ });
|
|
|
|
+ ToastAndroid.show(result.message, ToastAndroid.SHORT);
|
|
|
|
+ } else {
|
|
|
|
+ this.setState({
|
|
|
|
+ phone_bind_result: false
|
|
|
|
+ });
|
|
|
|
+ ToastAndroid.show(result.message, ToastAndroid.SHORT);
|
|
|
|
+ }
|
|
|
|
+ });
|
|
} else {
|
|
} else {
|
|
ToastAndroid.show('验证码不正确', ToastAndroid.SHORT);
|
|
ToastAndroid.show('验证码不正确', ToastAndroid.SHORT);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ backresult() {
|
|
|
|
+ this.props.navigation.state.params.bind_phone_back(this.state.phone_num, this.state.phone_bind_result);
|
|
|
|
+ this.props.navigation.goBack();
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
const styles = StyleSheet.create({
|
|
const styles = StyleSheet.create({
|