Skip to content

Commit

Permalink
更新示例demo
Browse files Browse the repository at this point in the history
  • Loading branch information
zhanq committed Apr 16, 2019
1 parent 374fe15 commit 0d71d53
Show file tree
Hide file tree
Showing 2 changed files with 85 additions and 38 deletions.
119 changes: 83 additions & 36 deletions example/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,16 @@ import { StyleSheet, Text, View, TouchableHighlight, ScrollView, TextInput, Aler
import JVerification from 'jverification-react-native'

var styles = StyleSheet.create({
parent: {
padding: 35,

flexDirection: 'column',
container: {
flex: 1,
justifyContent: 'center',
alignItems: 'center',
backgroundColor: '#F5FCFF',
},
setBtnStyle: {
width: 180,
width: 280,
justifyContent: 'center',
alignItems: 'center',
marginTop: 10,
borderWidth: 1,
borderColor: '#3e83d7',
Expand Down Expand Up @@ -51,7 +52,44 @@ class Button extends React.Component {
}
}

// type Props = {};
//一键登录页面自定义配置,需要在调用login之前设置
var config = {
navColor:-16742704, //导航栏颜色
navText: "一键登录", //导航栏标题
navTextColor:-1, //导航栏标题文字颜色
navReturnImage:"自定义返回按钮图片", //导航栏左侧返回按钮

logoHidden:false, //logo是否隐藏
logoImage:"umcsdk_mobile_logo", //logo(android默认为应用图标;ios默认无)
logoWidth:100, //logo宽
logoHeight:100, //logo高
logoOffsetY:75, //logo相对导航栏向下偏移量

numberColor:-16742704, //手机号码文字颜色
numOffsetY:200, //手机号码相对导航栏向下偏移量

sloganTextColor:-16742704, //slogan文字颜色
sloganOffsetY:250, //slogan相对导航栏向下偏移量

loginBtnText:"本机号码登录", //登录按钮文字
loginBtnTextColor:-1, //登录按钮文字颜色
loginBtnImageStyle:"自定义登录按钮样式", //登录按钮selector选择样式 (仅android)
loginBtnNormalImage:"自定义登录按钮正常图片", //登录按钮正常图片 (仅ios,三个同时设置生效)
loginBtnUnableImage:"自定义登录按钮失效图片", //登录按钮失效图片 (仅ios,三个同时设置生效)
loginBtnPressedImage:"自定义登录按钮按下图片", //登录按钮按下图片 (仅ios,三个同时设置生效)

loginBtnOffsetY:280, //登录按钮相对导航栏向下偏移量

privacyOneName:"自定义隐私条款一", //隐私条款一
privacyOneUrl:"https://www.jiguang.cn", //隐私条款一链接
privacyTwoName:"自定义隐私条款二", //隐私条款二
privacyTwoUrl:"https://www.jiguang.cn", //隐私条款二链接
privacyBasicColor:-16742704, //隐私条款基础文字颜色
privacyProtocolColor:-16777216, //隐私条款文字颜色
privacyCheckImage:"自定义选择图片", //隐私条款复选框选中图片
privacyUncheckImage:"自定义未选择图片", //隐私条款复选框未选中图片
privacyOffsetY:20 //隐私条款相对底部向上偏移量
}

export default class App extends React.Component {
constructor(props){
Expand All @@ -63,18 +101,23 @@ export default class App extends React.Component {
return (
<View style={styles.container}>
<Button title="init"
onPress={() => JVerification.init({
appKey: 'your appkey',
channel: 'the channel'
})}/>

onPress={() => JVerification.init({appKey :"您的appKey"}) }/>


<Button title="设置日志级别:Debug"
onPress={() => JVerification.setDebugEnable(true) }/>

<Button title="checkVerifyEnable"
onPress={() => JVerification.checkVerifyEnable((res) => {
Alert.alert("check verify enable",JSON.stringify(res));})}/>

<Button title="getToken"
onPress={() => {
if(Platform.OS == "android"){
JVerification.requestPermission(res => {
if(res.code == 0){
JVerification.getToken(res => {
Alert.alert("token", JSON.stringify(res));
Alert.alert("get token", JSON.stringify(res));
if(res.code == 2000){
this.setState({ token: res.content });
}
Expand All @@ -86,7 +129,7 @@ export default class App extends React.Component {
});
}else{
JVerification.getToken(res => {
Alert.alert("token", JSON.stringify(res));
Alert.alert("get token", JSON.stringify(res));
if (res.code == 2000) {
this.setState({ token: res.content });
}
Expand All @@ -95,36 +138,40 @@ export default class App extends React.Component {
}
}/>

<Button title="verifyNumber"
<Button title="numberVerify"
onPress={() => JVerification.verifyNumber({
number: 'your number',
number: '13802286451',
token: this.state.token
},(res) => {
Alert.alert('token', JSON.stringify(res));
Alert.alert('number verify', JSON.stringify(res));
})}/>

<Button title="setDebug"
onPress={() => JVerification.setDebug(true)}/>
<Button title="customLoginUI"
onPress={() => JVerification.setLoginUIConfig(config)}/>

<Button title="login"
onPress={() => JVerification.login((res) => {
Alert.alert("login",JSON.stringify(res));})}/>
</View>
);
}
}

const styles = StyleSheet.create({
container: {
flex: 1,
justifyContent: 'center',
alignItems: 'center',
backgroundColor: '#F5FCFF',
},
welcome: {
fontSize: 20,
textAlign: 'center',
margin: 10,
},
instructions: {
textAlign: 'center',
color: '#333333',
marginBottom: 5,
},
});
// const styles = StyleSheet.create({
// container: {
// flex: 1,
// justifyContent: 'center',
// alignItems: 'center',
// backgroundColor: '#F5FCFF',
// },
// welcome: {
// fontSize: 20,
// textAlign: 'center',
// margin: 10,
// },
// instructions: {
// textAlign: 'center',
// color: '#333333',
// marginBottom: 5,
// },
// });
4 changes: 2 additions & 2 deletions example/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
"test": "jest"
},
"dependencies": {
"jcore-react-native": "^1.3.0",
"jcore-react-native": "^1.3.2",
"jverification-react-native": "file:..",
"react": "16.6.0-alpha.8af6728",
"react": "^16.6.0-alpha.8af6728",
"react-native": "^0.57.4"
},
"devDependencies": {
Expand Down

0 comments on commit 0d71d53

Please sign in to comment.