ソースを参照

Merge branch 'master' of http://gogs.efunbox.cn/Rorschach/efunbox-mobile-8

Limengbo 5 年 前
コミット
c04507ca77

+ 0 - 3
android/app/src/main/java/com/edufound/mobile/Util/AndroidUtil.java

@@ -2,7 +2,6 @@ package com.edufound.mobile.Util;
 
 import android.content.Intent;
 import android.support.annotation.Nullable;
-import android.util.Log;
 import android.widget.Toast;
 
 import com.edufound.mobile.activity.WebActivity;
@@ -13,8 +12,6 @@ import com.facebook.react.bridge.ReactContextBaseJavaModule;
 import com.facebook.react.bridge.ReactMethod;
 import com.facebook.react.bridge.WritableMap;
 import com.facebook.react.modules.core.DeviceEventManagerModule;
-import com.tencent.mm.opensdk.modelbiz.WXLaunchMiniProgram;
-import com.theweflex.react.WeChatModule;
 
 import java.util.HashMap;
 import java.util.Map;

+ 235 - 0
pages/PhoneBind.js

@@ -0,0 +1,235 @@
+/* 
+ * 登录
+*/
+import React, { Component } from 'react';
+import {
+	Platform,
+	StyleSheet,
+	Text,
+	View,
+	Image,
+	TouchableOpacity,
+	ImageBackground,
+	Button,
+	StatusBar,
+	Modal,
+	TouchableHighlight,
+	ToastAndroid,
+	DeviceEventEmitter,
+	TextInput,
+	ScrollView
+} from 'react-native';
+import BasePage from './BasePage';
+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';
+
+export default class PhoneBind extends BasePage {
+	state = {
+		type: '',
+		phone_num: '',
+		verification_text: '获取验证码',
+		page_title_text: '绑定手机号',
+		click_ok_text: '绑 定'
+	};
+	render() {
+		return (
+			<View style={styles.wrapper}>
+				<View style={styles.jump}>
+					<TouchableOpacity style={styles.jumpBtn}>
+						<Text style={styles.jumpText}>{this.state.page_title_text}</Text>
+					</TouchableOpacity>
+				</View>
+				<View style={styles.phoneNumberBox}>
+					<Text style={styles.phoneNumber}>手机号</Text>
+					<TextInput
+						style={styles.phoneText}
+						maxLength={11}
+						onChangeText={(text) => this.setState({ phone_num: text })}
+						value={this.state.phone_num}
+						placeholder={'请输入手机号'}
+					/>
+				</View>
+				<View style={styles.signNumberBox}>
+					<Text style={styles.phoneNumber}>验证码</Text>
+					<View style={styles.signNumberLine2}>
+						<TextInput
+							style={styles.signText}
+							maxLength={4}
+							onChangeText={(text) => this.setState({ verification_code: text })}
+							value={this.state.verification_code}
+							placeholder={'请输入验证码'}
+						/>
+						<TouchableOpacity>
+							<Text style={styles.getSign} onPress={this.getVerification.bind(this)}>
+								{this.state.verification_text}
+							</Text>
+						</TouchableOpacity>
+					</View>
+				</View>
+				<View style={styles.loginIn}>
+					<Text style={styles.loginText}>{this.state.click_ok_text}</Text>
+				</View>
+				<View style={styles.wechatLogin}>
+					{/* <Image source={require('./images/common/wechat.png')} /> */}
+					<Text style={styles.wechatLoginText} />
+					{/* <Image source={require('./images/common/arrowRight.png')} /> */}
+				</View>
+			</View>
+		);
+	}
+	componentWillMount() {
+		switch (this.props.navigation.state.params.type) {
+			case 1:
+				this.setState({
+					type: this.props.navigation.state.params.type,
+					page_title_text: '绑定手机号',
+					click_ok_text: '绑 定'
+				});
+				break;
+			case 2:
+				this.setState({
+					type: this.props.navigation.state.params.type,
+					page_title_text: '修改手机号',
+					click_ok_text: '修 改'
+				});
+				break;
+		}
+	}
+
+	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'
+				});
+				this.CountDown();
+			} else {
+				ToastAndroid.show('请输入正确的手机号', ToastAndroid.SHORT);
+			}
+		} else {
+		}
+	}
+
+	CountDown() {
+		if (parseInt(this.state.verification_text) == 0) {
+			this.setState({
+				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();
+			}, 1000);
+		}
+	}
+
+	//验证手机号
+	isPoneAvailable(str) {
+		let myreg = /^[1][3,4,5,7,8][0-9]{9}$/;
+		if (str.length == 0 || str == null) {
+			return false;
+		} else if (!myreg.test(str)) {
+			return false;
+		} else {
+			return true;
+		}
+	}
+}
+
+const styles = StyleSheet.create({
+	wrapper: {
+		flex: 1
+	},
+	jumpText: {
+		color: '#3e3e3e',
+		fontSize: 16,
+		marginRight: 4
+	},
+	jump: {
+		// width: Dimensions.width,
+		flex: 2,
+		alignItems: 'center',
+		justifyContent: 'center',
+		paddingHorizontal: '8%'
+	},
+	jumpBtn: {
+		flexDirection: 'row',
+		alignItems: 'center',
+		justifyContent: 'center'
+	},
+	phoneNumberBox: {
+		flex: 2,
+		paddingHorizontal: '8%'
+	},
+	phoneNumber: {
+		color: '#3e3e3e',
+		fontSize: 18,
+		marginBottom: 10
+	},
+	phoneText: {
+		width: '100%',
+		height: Dimensions.getHeight(50),
+		borderRadius: 25,
+		backgroundColor: '#f3f3f3'
+	},
+	signNumberBox: {
+		flex: 2,
+		paddingHorizontal: '8%'
+	},
+	signNumberLine2: {
+		flexDirection: 'row',
+		width: Dimensions.width
+	},
+	signText: {
+		width: '54%',
+		height: Dimensions.getHeight(50),
+		borderRadius: 25,
+		backgroundColor: '#f3f3f3',
+		marginRight: 9
+	},
+	getSign: {
+		width: 105,
+		height: Dimensions.getHeight(50),
+		borderRadius: 25,
+		backgroundColor: '#38da84',
+		lineHeight: Dimensions.getHeight(50),
+		color: '#fff',
+		fontSize: 16,
+		textAlign: 'center'
+	},
+	loginIn: {
+		flex: 3,
+		paddingHorizontal: '8%'
+	},
+	loginText: {
+		width: '100%',
+		height: Dimensions.getHeight(50),
+		backgroundColor: '#63aeff',
+		textAlign: 'center',
+		lineHeight: Dimensions.getHeight(50),
+		color: '#fff',
+		fontSize: 20,
+		borderRadius: 25
+	},
+	wechatLogin: {
+		flex: 3,
+		flexDirection: 'row',
+		paddingHorizontal: '33.6%',
+		alignItems: 'center',
+		justifyContent: 'center'
+	},
+	wechatLoginText: {
+		fontSize: 16,
+		color: '#3e3e3e',
+		marginHorizontal: 6
+	}
+});

+ 22 - 2
pages/components/PersonalInfo.js

@@ -50,6 +50,8 @@ export default class PersonalInfo extends BasePage {
 		birthday_time: 0,
 		photo_uri: require('../images/userInfo/default_photo.png'),
 		phone: '',
+		phone_bind_result: false,
+		phone_bind_type: 1, //1是绑定,2是修改
 		phone_bind_color: '',
 		wechat_nickName: '',
 		wechat_bind_color: ''
@@ -684,14 +686,24 @@ export default class PersonalInfo extends BasePage {
 		if (this.state.phone == null || this.state.phone === '') {
 			this.setState({
 				phone_bind_color: 'red',
+				phone_bind_type: 1,
 				phone: '未绑定'
 			});
+		} else {
+			this.setState({
+				phone_bind_color: 'rgba(113, 113, 113, 1)',
+				phone_bind_type: 2
+			});
 		}
-		if (this.state.phone == null || this.state.phone === '') {
+		if (this.state.wechat_nickName == null || this.state.wechat_nickName === '') {
 			this.setState({
 				wechat_bind_color: 'red',
 				wechat_nickName: '未绑定'
 			});
+		} else {
+			this.setState({
+				wechat_bind_color: 'rgba(113, 113, 113, 1)'
+			});
 		}
 	}
 
@@ -787,7 +799,10 @@ export default class PersonalInfo extends BasePage {
 				break;
 			//手机号
 			case 6:
-				alert('手机号');
+				this.props.navigation.navigate('PhoneBind', {
+					type: this.state.phone_bind_type,
+					BindData: this.bind_phone.bind(this)
+				});
 				break;
 			//微信
 			case 7:
@@ -880,6 +895,11 @@ export default class PersonalInfo extends BasePage {
 			console.log(res);
 		});
 	}
+
+	bind_phone(phone_num, result) {
+		alert('绑定手机号回传');
+		this.setState({ phone: phone_num, phone_bind_result: result });
+	}
 }
 
 const styles = StyleSheet.create({

+ 4 - 2
pages/services/user.js

@@ -14,12 +14,14 @@ export default class user {
     });
   }
 	static update_UserInfo(opts) {
-		console.log('opts', opts);
 		return request(APIConfig.getUserUrl(``), opts);
 	}
 
 	static bind_wechat(opts) {
-		console.log('opts', opts);
 		return request(APIConfig.getUserUrl(`/wechatBind`), opts);
 	}
+
+	static getVerificationCode(phone) {
+		return request(APIConfig.getUserUrl(`/sendCode?mobile=` + phone));
+	}
 }