Kaynağa Gözat

1.增加react-native-device-info插件
2.Login界面增加接口请求。

zhangmengjie 5 yıl önce
ebeveyn
işleme
ef33b4b968

+ 3 - 1
android/app/src/main/AndroidManifest.xml

@@ -17,7 +17,9 @@
     <uses-permission android:name="com.xiaomi.permission.AUTH_THIRDPAY" />
     <uses-permission android:name="android.permission.CAMERA" />
     <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
-
+    <uses-permission android:name="android.permission.CHANGE_WIFI_STATE" />
+    <uses-permission android:name="android.permission.BLUETOOTH"/>
+    
     <application
         android:name="com.edufound.MainApplication"
         android:allowBackup="false"

+ 3 - 1
android/app/src/main/java/com/edufound/MainApplication.java

@@ -14,6 +14,7 @@ import com.github.yamill.orientation.OrientationPackage;
 import com.imagepicker.ImagePickerPackage;
 import com.swmansion.gesturehandler.react.RNGestureHandlerPackage;
 import com.theweflex.react.WeChatPackage;
+import com.learnium.RNDeviceInfo.RNDeviceInfo;
 
 import java.util.Arrays;
 import java.util.List;
@@ -36,7 +37,8 @@ public class MainApplication extends Application implements ReactApplication {
                     new ReactVideoPackage(),
                     new OrientationPackage(),
                     new ImagePickerPackage(),
-                    new WeChatPackage()
+                    new WeChatPackage(),
+                    new RNDeviceInfo()
             );
         }
 

+ 2 - 0
android/settings.gradle

@@ -1,4 +1,6 @@
 rootProject.name = 'efunbox_mobile_8'
+include ':react-native-device-info'
+project(':react-native-device-info').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-device-info/android')
 include ':react-native-wechat'
 project(':react-native-wechat').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-wechat/android')
 include ':react-native-image-picker'

+ 28 - 0
ios/efunbox_mobile_8.xcodeproj/project.pbxproj

@@ -46,6 +46,8 @@
 		E7126B830D54449191E5A4A3 /* libRNImagePicker.a in Frameworks */ = {isa = PBXBuildFile; fileRef = D4C934671D884A4AAA31603D /* libRNImagePicker.a */; };
 		EBD8BAD03DF74C0E96E4D170 /* libRCTWeChat.a in Frameworks */ = {isa = PBXBuildFile; fileRef = F42902D7FF684CA6A48558A1 /* libRCTWeChat.a */; };
 		D3F60855D8FF4C4A9C5D4ACA /* RCTWeChatTests.xctest in Resources */ = {isa = PBXBuildFile; fileRef = 7411A64812B4434AAAD1DBB5 /* RCTWeChatTests.xctest */; };
+		12BDF20DBE4141F8A990F8D7 /* libRNDeviceInfo.a in Frameworks */ = {isa = PBXBuildFile; fileRef = F9FCB46EDB7F456AB88EF68C /* libRNDeviceInfo.a */; };
+		5C6A0716F9C849D2B67AE09E /* libRNDeviceInfo-tvOS.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 505D2A7DD9E64E7B82EC655D /* libRNDeviceInfo-tvOS.a */; };
 /* End PBXBuildFile section */
 
 /* Begin PBXContainerItemProxy section */
@@ -365,6 +367,9 @@
 		593F0F0596BC4EB7996A9D21 /* RCTWeChat.xcodeproj */ = {isa = PBXFileReference; name = "RCTWeChat.xcodeproj"; path = "../node_modules/react-native-wechat/ios/RCTWeChat.xcodeproj"; sourceTree = "<group>"; fileEncoding = undefined; lastKnownFileType = wrapper.pb-project; explicitFileType = undefined; includeInIndex = 0; };
 		F42902D7FF684CA6A48558A1 /* libRCTWeChat.a */ = {isa = PBXFileReference; name = "libRCTWeChat.a"; path = "libRCTWeChat.a"; sourceTree = "<group>"; fileEncoding = undefined; lastKnownFileType = archive.ar; explicitFileType = undefined; includeInIndex = 0; };
 		7411A64812B4434AAAD1DBB5 /* RCTWeChatTests.xctest */ = {isa = PBXFileReference; name = "RCTWeChatTests.xctest"; path = "RCTWeChatTests.xctest"; sourceTree = "<group>"; fileEncoding = undefined; lastKnownFileType = wrapper.cfbundle; explicitFileType = undefined; includeInIndex = 0; };
+		18F4C7BFE3EB4947A8A72EB4 /* RNDeviceInfo.xcodeproj */ = {isa = PBXFileReference; name = "RNDeviceInfo.xcodeproj"; path = "../node_modules/react-native-device-info/ios/RNDeviceInfo.xcodeproj"; sourceTree = "<group>"; fileEncoding = undefined; lastKnownFileType = wrapper.pb-project; explicitFileType = undefined; includeInIndex = 0; };
+		F9FCB46EDB7F456AB88EF68C /* libRNDeviceInfo.a */ = {isa = PBXFileReference; name = "libRNDeviceInfo.a"; path = "libRNDeviceInfo.a"; sourceTree = "<group>"; fileEncoding = undefined; lastKnownFileType = archive.ar; explicitFileType = undefined; includeInIndex = 0; };
+		505D2A7DD9E64E7B82EC655D /* libRNDeviceInfo-tvOS.a */ = {isa = PBXFileReference; name = "libRNDeviceInfo-tvOS.a"; path = "libRNDeviceInfo-tvOS.a"; sourceTree = "<group>"; fileEncoding = undefined; lastKnownFileType = archive.ar; explicitFileType = undefined; includeInIndex = 0; };
 /* End PBXFileReference section */
 
 /* Begin PBXFrameworksBuildPhase section */
@@ -399,6 +404,7 @@
 				E7126B830D54449191E5A4A3 /* libRNImagePicker.a in Frameworks */,
 				EBD8BAD03DF74C0E96E4D170 /* libRCTWeChat.a in Frameworks */,
 				D3F60855D8FF4C4A9C5D4ACA /* RCTWeChatTests.xctest in Resources */,
+				12BDF20DBE4141F8A990F8D7 /* libRNDeviceInfo.a in Frameworks */,
 			);
 			runOnlyForDeploymentPostprocessing = 0;
 		};
@@ -416,6 +422,7 @@
 				2D02E4C71E0B4AEC006451C7 /* libRCTText-tvOS.a in Frameworks */,
 				2D02E4C81E0B4AEC006451C7 /* libRCTWebSocket-tvOS.a in Frameworks */,
 				40B60160FAE8416EABF8F455 /* libRNGestureHandler-tvOS.a in Frameworks */,
+				5C6A0716F9C849D2B67AE09E /* libRNDeviceInfo-tvOS.a in Frameworks */,
 			);
 			runOnlyForDeploymentPostprocessing = 0;
 		};
@@ -594,6 +601,7 @@
 				13F318D169DD4BA79CB54ED5 /* RCTOrientation.xcodeproj */,
 				B11B05F3205C483583EB7421 /* RNImagePicker.xcodeproj */,
 				593F0F0596BC4EB7996A9D21 /* RCTWeChat.xcodeproj */,
+				18F4C7BFE3EB4947A8A72EB4 /* RNDeviceInfo.xcodeproj */,
 			);
 			name = Libraries;
 			sourceTree = "<group>";
@@ -1228,6 +1236,8 @@
 					"\"$(SRCROOT)/$(TARGET_NAME)\"",
 					"\"$(SRCROOT)/$(TARGET_NAME)\"",
 					"\"$(SRCROOT)/$(TARGET_NAME)\"",
+					"\"$(SRCROOT)/$(TARGET_NAME)\"",
+					"\"$(SRCROOT)/$(TARGET_NAME)\"",
 				);
 				HEADER_SEARCH_PATHS = (
 					"$(inherited)",
@@ -1236,6 +1246,7 @@
 					"$(SRCROOT)\..\node_modules\react-native-orientation\iOS\RCTOrientation/**",
 					"$(SRCROOT)\..\node_modules\react-native-image-picker\ios",
 					"$(SRCROOT)\..\node_modules\react-native-wechat\ios",
+					"$(SRCROOT)\..\node_modules\react-native-device-info\ios\RNDeviceInfo",
 				);
 			};
 			name = Debug;
@@ -1264,6 +1275,8 @@
 					"\"$(SRCROOT)/$(TARGET_NAME)\"",
 					"\"$(SRCROOT)/$(TARGET_NAME)\"",
 					"\"$(SRCROOT)/$(TARGET_NAME)\"",
+					"\"$(SRCROOT)/$(TARGET_NAME)\"",
+					"\"$(SRCROOT)/$(TARGET_NAME)\"",
 				);
 				HEADER_SEARCH_PATHS = (
 					"$(inherited)",
@@ -1272,6 +1285,7 @@
 					"$(SRCROOT)\..\node_modules\react-native-orientation\iOS\RCTOrientation/**",
 					"$(SRCROOT)\..\node_modules\react-native-image-picker\ios",
 					"$(SRCROOT)\..\node_modules\react-native-wechat\ios",
+					"$(SRCROOT)\..\node_modules\react-native-device-info\ios\RNDeviceInfo",
 				);
 			};
 			name = Release;
@@ -1299,6 +1313,7 @@
 					"$(SRCROOT)\..\node_modules\react-native-orientation\iOS\RCTOrientation/**",
 					"$(SRCROOT)\..\node_modules\react-native-image-picker\ios",
 					"$(SRCROOT)\..\node_modules\react-native-wechat\ios",
+					"$(SRCROOT)\..\node_modules\react-native-device-info\ios\RNDeviceInfo",
 				);
 			};
 			name = Debug;
@@ -1325,6 +1340,7 @@
 					"$(SRCROOT)\..\node_modules\react-native-orientation\iOS\RCTOrientation/**",
 					"$(SRCROOT)\..\node_modules\react-native-image-picker\ios",
 					"$(SRCROOT)\..\node_modules\react-native-wechat\ios",
+					"$(SRCROOT)\..\node_modules\react-native-device-info\ios\RNDeviceInfo",
 				);
 			};
 			name = Release;
@@ -1361,6 +1377,8 @@
 					"\"$(SRCROOT)/$(TARGET_NAME)\"",
 					"\"$(SRCROOT)/$(TARGET_NAME)\"",
 					"\"$(SRCROOT)/$(TARGET_NAME)\"",
+					"\"$(SRCROOT)/$(TARGET_NAME)\"",
+					"\"$(SRCROOT)/$(TARGET_NAME)\"",
 				);
 				HEADER_SEARCH_PATHS = (
 					"$(inherited)",
@@ -1369,6 +1387,7 @@
 					"$(SRCROOT)\..\node_modules\react-native-orientation\iOS\RCTOrientation/**",
 					"$(SRCROOT)\..\node_modules\react-native-image-picker\ios",
 					"$(SRCROOT)\..\node_modules\react-native-wechat\ios",
+					"$(SRCROOT)\..\node_modules\react-native-device-info\ios\RNDeviceInfo",
 				);
 			};
 			name = Debug;
@@ -1405,6 +1424,8 @@
 					"\"$(SRCROOT)/$(TARGET_NAME)\"",
 					"\"$(SRCROOT)/$(TARGET_NAME)\"",
 					"\"$(SRCROOT)/$(TARGET_NAME)\"",
+					"\"$(SRCROOT)/$(TARGET_NAME)\"",
+					"\"$(SRCROOT)/$(TARGET_NAME)\"",
 				);
 				HEADER_SEARCH_PATHS = (
 					"$(inherited)",
@@ -1413,6 +1434,7 @@
 					"$(SRCROOT)\..\node_modules\react-native-orientation\iOS\RCTOrientation/**",
 					"$(SRCROOT)\..\node_modules\react-native-image-picker\ios",
 					"$(SRCROOT)\..\node_modules\react-native-wechat\ios",
+					"$(SRCROOT)\..\node_modules\react-native-device-info\ios\RNDeviceInfo",
 				);
 			};
 			name = Release;
@@ -1448,6 +1470,8 @@
 					"\"$(SRCROOT)/$(TARGET_NAME)\"",
 					"\"$(SRCROOT)/$(TARGET_NAME)\"",
 					"\"$(SRCROOT)/$(TARGET_NAME)\"",
+					"\"$(SRCROOT)/$(TARGET_NAME)\"",
+					"\"$(SRCROOT)/$(TARGET_NAME)\"",
 				);
 				HEADER_SEARCH_PATHS = (
 					"$(inherited)",
@@ -1456,6 +1480,7 @@
 					"$(SRCROOT)\..\node_modules\react-native-orientation\iOS\RCTOrientation/**",
 					"$(SRCROOT)\..\node_modules\react-native-image-picker\ios",
 					"$(SRCROOT)\..\node_modules\react-native-wechat\ios",
+					"$(SRCROOT)\..\node_modules\react-native-device-info\ios\RNDeviceInfo",
 				);
 			};
 			name = Debug;
@@ -1491,6 +1516,8 @@
 					"\"$(SRCROOT)/$(TARGET_NAME)\"",
 					"\"$(SRCROOT)/$(TARGET_NAME)\"",
 					"\"$(SRCROOT)/$(TARGET_NAME)\"",
+					"\"$(SRCROOT)/$(TARGET_NAME)\"",
+					"\"$(SRCROOT)/$(TARGET_NAME)\"",
 				);
 				HEADER_SEARCH_PATHS = (
 					"$(inherited)",
@@ -1499,6 +1526,7 @@
 					"$(SRCROOT)\..\node_modules\react-native-orientation\iOS\RCTOrientation/**",
 					"$(SRCROOT)\..\node_modules\react-native-image-picker\ios",
 					"$(SRCROOT)\..\node_modules\react-native-wechat\ios",
+					"$(SRCROOT)\..\node_modules\react-native-device-info\ios\RNDeviceInfo",
 				);
 			};
 			name = Release;

+ 35 - 11
package-lock.json

@@ -2845,7 +2845,8 @@
         },
         "ansi-regex": {
           "version": "2.1.1",
-          "bundled": true
+          "bundled": true,
+          "optional": true
         },
         "aproba": {
           "version": "1.2.0",
@@ -2863,11 +2864,13 @@
         },
         "balanced-match": {
           "version": "1.0.0",
-          "bundled": true
+          "bundled": true,
+          "optional": true
         },
         "brace-expansion": {
           "version": "1.1.11",
           "bundled": true,
+          "optional": true,
           "requires": {
             "balanced-match": "^1.0.0",
             "concat-map": "0.0.1"
@@ -2880,15 +2883,18 @@
         },
         "code-point-at": {
           "version": "1.1.0",
-          "bundled": true
+          "bundled": true,
+          "optional": true
         },
         "concat-map": {
           "version": "0.0.1",
-          "bundled": true
+          "bundled": true,
+          "optional": true
         },
         "console-control-strings": {
           "version": "1.1.0",
-          "bundled": true
+          "bundled": true,
+          "optional": true
         },
         "core-util-is": {
           "version": "1.0.2",
@@ -2991,7 +2997,8 @@
         },
         "inherits": {
           "version": "2.0.3",
-          "bundled": true
+          "bundled": true,
+          "optional": true
         },
         "ini": {
           "version": "1.3.5",
@@ -3001,6 +3008,7 @@
         "is-fullwidth-code-point": {
           "version": "1.0.0",
           "bundled": true,
+          "optional": true,
           "requires": {
             "number-is-nan": "^1.0.0"
           }
@@ -3013,17 +3021,20 @@
         "minimatch": {
           "version": "3.0.4",
           "bundled": true,
+          "optional": true,
           "requires": {
             "brace-expansion": "^1.1.7"
           }
         },
         "minimist": {
           "version": "0.0.8",
-          "bundled": true
+          "bundled": true,
+          "optional": true
         },
         "minipass": {
           "version": "2.3.5",
           "bundled": true,
+          "optional": true,
           "requires": {
             "safe-buffer": "^5.1.2",
             "yallist": "^3.0.0"
@@ -3040,6 +3051,7 @@
         "mkdirp": {
           "version": "0.5.1",
           "bundled": true,
+          "optional": true,
           "requires": {
             "minimist": "0.0.8"
           }
@@ -3112,7 +3124,8 @@
         },
         "number-is-nan": {
           "version": "1.0.1",
-          "bundled": true
+          "bundled": true,
+          "optional": true
         },
         "object-assign": {
           "version": "4.1.1",
@@ -3122,6 +3135,7 @@
         "once": {
           "version": "1.4.0",
           "bundled": true,
+          "optional": true,
           "requires": {
             "wrappy": "1"
           }
@@ -3197,7 +3211,8 @@
         },
         "safe-buffer": {
           "version": "5.1.2",
-          "bundled": true
+          "bundled": true,
+          "optional": true
         },
         "safer-buffer": {
           "version": "2.1.2",
@@ -3227,6 +3242,7 @@
         "string-width": {
           "version": "1.0.2",
           "bundled": true,
+          "optional": true,
           "requires": {
             "code-point-at": "^1.0.0",
             "is-fullwidth-code-point": "^1.0.0",
@@ -3244,6 +3260,7 @@
         "strip-ansi": {
           "version": "3.0.1",
           "bundled": true,
+          "optional": true,
           "requires": {
             "ansi-regex": "^2.0.0"
           }
@@ -3282,11 +3299,13 @@
         },
         "wrappy": {
           "version": "1.0.2",
-          "bundled": true
+          "bundled": true,
+          "optional": true
         },
         "yallist": {
           "version": "3.0.3",
-          "bundled": true
+          "bundled": true,
+          "optional": true
         }
       }
     },
@@ -7072,6 +7091,11 @@
         }
       }
     },
+    "react-native-device-info": {
+      "version": "2.1.1",
+      "resolved": "https://registry.npm.taobao.org/react-native-device-info/download/react-native-device-info-2.1.1.tgz",
+      "integrity": "sha1-xt3AIgM3VqXkxYmeuD45C1oYzBc="
+    },
     "react-native-gesture-handler": {
       "version": "1.1.0",
       "resolved": "https://registry.npm.taobao.org/react-native-gesture-handler/download/react-native-gesture-handler-1.1.0.tgz",

+ 1 - 0
package.json

@@ -14,6 +14,7 @@
     "react-art": "^16.8.6",
     "react-dom": "^16.8.6",
     "react-native": "0.59.4",
+    "react-native-device-info": "^2.1.1",
     "react-native-gesture-handler": "^1.1.0",
     "react-native-image-picker": "^0.28.1",
     "react-native-orientation": "^3.1.3",

+ 289 - 152
pages/Login.js

@@ -1,166 +1,303 @@
 /* 
  * 登录
 */
-import React, { Component } from "react";
-import {
-    Platform,
-    StyleSheet,
-    Text,
-    View,
-    Image,
-    TouchableOpacity,
-    ImageBackground,
-    Button,
-    StatusBar,
-    Modal,
-    TouchableHighlight,
-    DeviceEventEmitter,
-    TextInput,
-    ScrollView
-} from "react-native";
-import BasePage from "./BasePage";
+import React, { Component } from 'react';
+import { StyleSheet, Text, View, Image, TouchableOpacity, StatusBar, ToastAndroid, TextInput } from 'react-native';
+import BasePage from './BasePage';
 import Dimensions from './utils/dimensions';
-import ShopBox from "./components/ShopBox";
+import ShopBox from './components/ShopBox';
 import TopicTitle from './components/TopicTitle';
 import ScrollRow from './components/ScrollRow';
+import DeviceInfo from 'react-native-device-info';
+import commonutil from './utils/commonutil';
+import http_user from './services/user';
+import wechat from './utils/wechat';
 
 export default class Login extends BasePage {
-    state = {
+	state = {
+		phone_num: '',
+		verification_text: '获取验证码',
+		verification_code: '',
+		http_verification_code: '',
+		deviceCode: ''
+	};
+	render() {
+		return (
+			<View style={styles.wrapper}>
+				<StatusBar backgroundColor={'white'} translucent={true} barStyle={'dark-content'} />
+				<View style={styles.jump}>
+					<TouchableOpacity style={styles.jumpBtn}>
+						<Text style={styles.jumpText}>跳过</Text>
+						<Image source={require('./images/common/arrowRight.png')} />
+					</TouchableOpacity>
+				</View>
+				<View style={styles.phoneNumberBox}>
+					<Text style={styles.phoneNumber}>手机号</Text>
+					<TextInput
+						style={styles.phoneText}
+						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}
+							onChangeText={(text) => this.setState({ verification_code: text })}
+							value={this.state.verification_code}
+							placeholder={'请输入验证码'}
+						/>
+						<TouchableOpacity onPress={this.getVerification.bind(this)}>
+							<Text style={styles.getSign}> {this.state.verification_text}</Text>
+						</TouchableOpacity>
+					</View>
+				</View>
+				<View style={styles.loginIn}>
+					<Text style={styles.loginText} onPress={this.clickOK.bind(this)}>
+						登录
+					</Text>
+				</View>
+				<View style={styles.wechatLogin}>
+					<Image source={require('./images/common/wechat.png')} />
+					<Text style={styles.wechatLoginText} onPress={this.wechatLogin.bind(this)}>
+						微信登录
+					</Text>
+					<Image source={require('./images/common/arrowRight.png')} />
+				</View>
+			</View>
+		);
+	}
 
+	componentWillMount() {
+		console.log('================================================'); // e.g US
+		console.log('Device getUniqueID', DeviceInfo.getUniqueID()); // e.g US
+		console.log('Device getSerialNumber', DeviceInfo.getSerialNumber()); // e.g US
+		console.log('================================================'); // e.g US
+		this.setState({
+			deviceCode: DeviceInfo.getUniqueID() + DeviceInfo.getSerialNumber()
+		});
+	}
 
-    };
-    render() {
-        return (
-            <View style={styles.wrapper}>
-                <View style={styles.jump}>
-                    <TouchableOpacity style={styles.jumpBtn}>
-                        <Text style={styles.jumpText}>跳过</Text>
-                        <Image source={require('./images/common/arrowRight.png')}></Image>
-                    </TouchableOpacity>
-                </View>
-                <View style={styles.phoneNumberBox}>
-                    <Text style={styles.phoneNumber}>手机号</Text>
-                    <TextInput
-                        style={styles.phoneText}
-                        onChangeText={(text) => this.setState({ text })}
-                        value={this.state.text}
-                        placeholder={'请输入手机号'}
-                    />
-                </View>
-                <View style={styles.signNumberBox}>
-                    <Text style={styles.phoneNumber}>验证码</Text>
-                    <View style={styles.signNumberLine2}>
-                        <TextInput
-                            style={styles.signText}
-                            onChangeText={(text) => this.setState({ text })}
-                            value={this.state.text}
-                            placeholder={'请输入验证码'}
-                        />
-                        <TouchableOpacity>
-                            <Text style={styles.getSign}>获取验证码</Text>
-                        </TouchableOpacity>
-                    </View>
-                </View>
-                <View style={styles.loginIn}>
-                    <Text style={styles.loginText}>登录</Text>
-                </View>
-                <View style={styles.wechatLogin}>
-                    <Image source={require('./images/common/wechat.png')}></Image>
-                    <Text style={styles.wechatLoginText}>微信登录</Text>
-                    <Image source={require('./images/common/arrowRight.png')}></Image>
-                </View>
-            </View>
-        )
-    }
+	getVerification() {
+		if (this.state.verification_text === '获取验证码') {
+			if (commonutil.isPoneAvailable(this.state.phone_num)) {
+				http_user.getVerificationCode(this.state.phone_num).then((result) => {
+					if (result.code != 200) {
+						ToastAndroid.show(result.message, ToastAndroid.SHORT);
+						return;
+					} else {
+						console.log('====================================');
+						console.log(result.data);
+						console.log('====================================');
+						this.setState({
+							http_verification_code: result.data
+						});
+					}
+					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 {
+			setTimeout(() => {
+				this.setState({
+					verification_text: parseInt(this.state.verification_text) - 1 + ''
+				});
+				this.CountDown();
+			}, 1000);
+		}
+	}
+
+	//绑定手机号
+	clickOK() {
+		//请求报错
+		//参数
+		/**
+         * 
+         * {
+	        "channel": "006",
+	        "deviceCode": "fb3dcd333348ZX1G42CPJD",
+	        "mobile": "15810271473",
+	        "sign": "9999"
+            }   
+         * 
+         * 
+         * 
+         * 
+         */
+		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) {
+			let option = {
+				method: 'POST', //请求方法
+				//请求体
+				body: {
+					mobile: this.state.phone_num,
+					sign: this.state.verification_code,
+					channel: '006',
+					deviceCode: this.state.deviceCode
+				}
+			};
+			http_user.mobileLoginAndReg(option).then((result) => {
+				if (result.code == 200) {
+					ToastAndroid.show(result.message, ToastAndroid.SHORT);
+				} else {
+					ToastAndroid.show(result.message, ToastAndroid.SHORT);
+				}
+			});
+		} else {
+			ToastAndroid.show('验证码不正确', ToastAndroid.SHORT);
+		}
+	}
+
+	wechatLogin() {
+		//网络请求 status 500
+		/**
+         * {
+	        "channel": "006",
+	        "deviceCode": "fb3dcd333348ZX1G42CPJD",
+	        "openId": "odI7ls2Bk_0A2_Y0E6D4dAKuSsqs",
+        	"unionId": "o8sgct5UksQ7kfrSGTBRRgwY5oVU",
+        	"avatar": "",
+	        "sex": "2",
+        	"nickName": "雨露"
+            }
+         * 
+         * 
+         * 
+         */
+		console.log('this.state.deviceCode:' + this.state.deviceCode);
+		wechat.wechatLogin((user) => {
+			let option = {
+				method: 'POST',
+				body: {
+					channel: '006',
+					deviceCode: this.state.deviceCode,
+					openId: user['openid'],
+					unionId: user['unionid'],
+					avatar: user['province'] + user['city'],
+					sex: +user['sex'],
+					nickName: user['nickname']
+				}
+			};
+			http_user.wechatLogin(option).then((result) => {
+				if (result.code == 200) {
+					//登陆成功了,可以存储用户数据到本地
+					ToastAndroid.show(result.message, ToastAndroid.SHORT);
+				} else {
+					ToastAndroid.show(result.message, ToastAndroid.SHORT);
+				}
+				console.log('result-------:' + result);
+			});
+		});
+	}
 }
 
 const styles = StyleSheet.create({
-    wrapper: {
-        flex: 1
-    },
-    jumpText: {
-        color: '#3e3e3e',
-        fontSize: 16,
-        marginRight: 4
-    },
-    jump: {
-        // width: Dimensions.width,
-        flex: 2,
-        alignItems: 'flex-end',
-        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
-    }
-})
+	wrapper: {
+		flex: 1
+	},
+	jumpText: {
+		color: '#3e3e3e',
+		fontSize: 16,
+		marginRight: 4
+	},
+	jump: {
+		// width: Dimensions.width,
+		flex: 2,
+		alignItems: 'flex-end',
+		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
+	}
+});

+ 1 - 1
pages/PersonalInfo.js

@@ -917,7 +917,7 @@ export default class PersonalInfo extends BasePage {
 			ToastAndroid.show('修改成功', ToastAndroid.SHORT);
 			this.setState({ phone: phone_num, phone_bind_result: result, show_bind_phone: true });
 		} else {
-			ToastAndroid.show('修改失败', ToastAndroid.SHORT);
+			// ToastAndroid.show('修改失败', ToastAndroid.SHORT);
 		}
 	}
 }

+ 15 - 1
pages/services/user.js

@@ -13,19 +13,33 @@ export default class user {
 			method: 'get'
 		});
 	}
+
+	//更新个人信息
 	static update_UserInfo(opts) {
 		return request(APIConfig.getUserUrl(``), opts);
 	}
 
+	//绑定微信
 	static bind_wechat(opts) {
 		return request(APIConfig.getUserUrl(`/wechatBind`), opts);
 	}
 
+	//获取验证码
 	static getVerificationCode(phone) {
 		return request(APIConfig.getUserUrl(`/sendCode?mobile=` + phone));
 	}
-
+	//绑定手机号
 	static bind_phone(opts) {
 		return request(APIConfig.getUserUrl(`/mobileBind`), opts);
 	}
+
+	//手机号登陆注册
+	static mobileLoginAndReg(opts) {
+		return request(APIConfig.getUserUrl(`/mobileLoginAndReg`), opts);
+	}
+
+	//微信登陆
+	static wechatLogin(opts) {
+		return request(APIConfig.getUserUrl(``), opts);
+	}
 }