Pārlūkot izejas kodu

1.增加跳过登录方式

zhangmengjie 5 gadi atpakaļ
vecāks
revīzija
a241ce27cb
3 mainītis faili ar 59 papildinājumiem un 66 dzēšanām
  1. 44 55
      pages/Login.js
  2. 5 1
      pages/services/api.js
  3. 10 10
      pages/services/user.js

+ 44 - 55
pages/Login.js

@@ -16,53 +16,54 @@ export default class Login extends BasePage {
 		verification_text: '获取验证码',
 		verification_code: '',
 		http_verification_code: '',
-		deviceCode: '',
-		sss: ''
+		deviceCode: ''
 	};
 	render() {
 		return (
 			<View style={styles.wrapper}>
-				<StatusBar backgroundColor={'white'} translucent={true} barStyle={'dark-content'} />
-				<View style={styles.jump}>
-					<TouchableOpacity style={styles.jumpBtn} onPress={this.jumpBtn.bind(this)}>
-						<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}>
+				<View style={{ height: this.getWindowHeight() }}>
+					<StatusBar backgroundColor={'white'} translucent={true} barStyle={'dark-content'} />
+					<View style={styles.jump}>
+						<TouchableOpacity style={styles.jumpBtn} onPress={this.jumpBtn.bind(this)}>
+							<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.signText}
-							onChangeText={(text) => this.setState({ verification_code: text })}
-							value={this.state.verification_code}
-							placeholder={'请输入验证码'}
+							style={styles.phoneText}
+							onChangeText={(text) => this.setState({ phone_num: text })}
+							value={this.state.phone_num}
+							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 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>
 			</View>
 		);
@@ -133,7 +134,7 @@ export default class Login extends BasePage {
 				body: {
 					mobile: this.state.phone_num,
 					sign: this.state.verification_code,
-					channel: '006',
+					channel: commonutil.getAppCode(),
 					deviceCode: this.state.deviceCode
 				}
 			};
@@ -175,19 +176,7 @@ export default class Login extends BasePage {
 	}
 
 	jumpBtn() {
-		let option = {
-			method: 'POST',
-			body: {
-				channel: '006',
-				deviceCode: this.state.deviceCode,
-				openId: '',
-				unionId: '',
-				avatar: '',
-				sex: '',
-				nickName: ''
-			}
-		};
-		http_user.jumpLogin(option).then((result) => {
+		http_user.jumpLogin(this.state.deviceCode, commonutil.getAppCode()).then((result) => {
 			if (result.code == 200) {
 				//登陆成功了,可以存储用户数据到本地
 				console.log('====================================');
@@ -225,7 +214,7 @@ export default class Login extends BasePage {
 			let option = {
 				method: 'POST',
 				body: {
-					channel: '006',
+					channel: commonutil.getAppCode(),
 					deviceCode: this.state.deviceCode,
 					openId: user['openid'],
 					unionId: user['unionid'],

+ 5 - 1
pages/services/api.js

@@ -5,7 +5,8 @@ const url = {
 	upload_img: 'http://ott80test-base.yifangjiaoyu.cn/file/upload',
 	get_member: 'http://ott80test-trade.yifangjiaoyu.cn/customer/order/member',
 	pay_url: 'http://ott80test-trade.yifangjiaoyu.cn/mobile',
-	get_voucher: 'http://ott80test-trade.yifangjiaoyu.cn/mobile/voucher'
+	get_voucher: 'http://ott80test-trade.yifangjiaoyu.cn/mobile/voucher',
+	get_isLogin: 'http://ott80test-base.yifangjiaoyu.cn/mobile/user/isLogin'
 };
 
 export default class APIConfig {
@@ -32,4 +33,7 @@ export default class APIConfig {
 	static getVoucherUrl() {
 		return url.get_voucher;
 	}
+	static getIsLogin() {
+		return url.get_isLogin;
+	}
 }

+ 10 - 10
pages/services/user.js

@@ -3,10 +3,6 @@ import efunRequest from '../utils/efunRequest';
 import request from '../utils/request';
 
 export default class user {
-	static update_UserInfo(opts) {
-		console.log('opts', opts);
-		return request(APIConfig.getUserUrl(``), opts);
-	}
 	// 个人中心
 	static userMember() {
 		return request(`http://ott80test-base.yifangjiaoyu.cn/mobile/user/member`, {
@@ -65,21 +61,21 @@ export default class user {
 
 	//绑定微信
 	static bind_wechat(opts) {
-		return request(APIConfig.getUserUrl(`/wechatBind`), opts);
+		return request(APIConfig.getUserUrl() + `/wechatBind`, opts);
 	}
 
 	//获取验证码
 	static getVerificationCode(phone) {
-		return request(APIConfig.getUserUrl(`/sendCode?mobile=` + phone));
+		return request(APIConfig.getUserUrl() + `/sendCode?mobile=` + phone);
 	}
 	//绑定手机号
 	static bind_phone(opts) {
-		return request(APIConfig.getUserUrl(`/mobileBind`), opts);
+		return request(APIConfig.getUserUrl() + `/mobileBind`, opts);
 	}
 
 	//手机号登陆注册
 	static mobileLoginAndReg(opts) {
-		return request(APIConfig.getUserUrl(`/mobileLoginAndReg`), opts);
+		return request(APIConfig.getUserUrl() + `/mobileLoginAndReg`, opts);
 	}
 
 	//微信登陆
@@ -87,8 +83,12 @@ export default class user {
 		return request(APIConfig.getUserUrl(``), opts);
 	}
 	//跳过
-	static jumpLogin(opts) {
-		return request(APIConfig.getUserUrl(``), opts);
+	static jumpLogin(deviceCode, channel) {
+		console.log('====================================');
+		console.log('deviceCode', deviceCode);
+		console.log('channel', channel);
+		console.log('====================================');
+		return request(APIConfig.getIsLogin() + `?deviceCode=` + deviceCode + '&channel=' + channel, { method: 'GET' });
 	}
 }