Skip to content

Commit 0d71d53

Browse files
author
zhanq
committed
更新示例demo
1 parent 374fe15 commit 0d71d53

File tree

2 files changed

+85
-38
lines changed

2 files changed

+85
-38
lines changed

example/App.js

Lines changed: 83 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,16 @@ import { StyleSheet, Text, View, TouchableHighlight, ScrollView, TextInput, Aler
33
import JVerification from 'jverification-react-native'
44

55
var styles = StyleSheet.create({
6-
parent: {
7-
padding: 35,
8-
9-
flexDirection: 'column',
6+
container: {
7+
flex: 1,
108
justifyContent: 'center',
119
alignItems: 'center',
10+
backgroundColor: '#F5FCFF',
1211
},
1312
setBtnStyle: {
14-
width: 180,
13+
width: 280,
14+
justifyContent: 'center',
15+
alignItems: 'center',
1516
marginTop: 10,
1617
borderWidth: 1,
1718
borderColor: '#3e83d7',
@@ -51,7 +52,44 @@ class Button extends React.Component {
5152
}
5253
}
5354

54-
// type Props = {};
55+
//一键登录页面自定义配置,需要在调用login之前设置
56+
var config = {
57+
navColor:-16742704, //导航栏颜色
58+
navText: "一键登录", //导航栏标题
59+
navTextColor:-1, //导航栏标题文字颜色
60+
navReturnImage:"自定义返回按钮图片", //导航栏左侧返回按钮
61+
62+
logoHidden:false, //logo是否隐藏
63+
logoImage:"umcsdk_mobile_logo", //logo(android默认为应用图标;ios默认无)
64+
logoWidth:100, //logo宽
65+
logoHeight:100, //logo高
66+
logoOffsetY:75, //logo相对导航栏向下偏移量
67+
68+
numberColor:-16742704, //手机号码文字颜色
69+
numOffsetY:200, //手机号码相对导航栏向下偏移量
70+
71+
sloganTextColor:-16742704, //slogan文字颜色
72+
sloganOffsetY:250, //slogan相对导航栏向下偏移量
73+
74+
loginBtnText:"本机号码登录", //登录按钮文字
75+
loginBtnTextColor:-1, //登录按钮文字颜色
76+
loginBtnImageStyle:"自定义登录按钮样式", //登录按钮selector选择样式 (仅android)
77+
loginBtnNormalImage:"自定义登录按钮正常图片", //登录按钮正常图片 (仅ios,三个同时设置生效)
78+
loginBtnUnableImage:"自定义登录按钮失效图片", //登录按钮失效图片 (仅ios,三个同时设置生效)
79+
loginBtnPressedImage:"自定义登录按钮按下图片", //登录按钮按下图片 (仅ios,三个同时设置生效)
80+
81+
loginBtnOffsetY:280, //登录按钮相对导航栏向下偏移量
82+
83+
privacyOneName:"自定义隐私条款一", //隐私条款一
84+
privacyOneUrl:"https://www.jiguang.cn", //隐私条款一链接
85+
privacyTwoName:"自定义隐私条款二", //隐私条款二
86+
privacyTwoUrl:"https://www.jiguang.cn", //隐私条款二链接
87+
privacyBasicColor:-16742704, //隐私条款基础文字颜色
88+
privacyProtocolColor:-16777216, //隐私条款文字颜色
89+
privacyCheckImage:"自定义选择图片", //隐私条款复选框选中图片
90+
privacyUncheckImage:"自定义未选择图片", //隐私条款复选框未选中图片
91+
privacyOffsetY:20 //隐私条款相对底部向上偏移量
92+
}
5593

5694
export default class App extends React.Component {
5795
constructor(props){
@@ -63,18 +101,23 @@ export default class App extends React.Component {
63101
return (
64102
<View style={styles.container}>
65103
<Button title="init"
66-
onPress={() => JVerification.init({
67-
appKey: 'your appkey',
68-
channel: 'the channel'
69-
})}/>
70-
104+
onPress={() => JVerification.init({appKey :"您的appKey"}) }/>
105+
106+
107+
<Button title="设置日志级别:Debug"
108+
onPress={() => JVerification.setDebugEnable(true) }/>
109+
110+
<Button title="checkVerifyEnable"
111+
onPress={() => JVerification.checkVerifyEnable((res) => {
112+
Alert.alert("check verify enable",JSON.stringify(res));})}/>
113+
71114
<Button title="getToken"
72115
onPress={() => {
73116
if(Platform.OS == "android"){
74117
JVerification.requestPermission(res => {
75118
if(res.code == 0){
76119
JVerification.getToken(res => {
77-
Alert.alert("token", JSON.stringify(res));
120+
Alert.alert("get token", JSON.stringify(res));
78121
if(res.code == 2000){
79122
this.setState({ token: res.content });
80123
}
@@ -86,7 +129,7 @@ export default class App extends React.Component {
86129
});
87130
}else{
88131
JVerification.getToken(res => {
89-
Alert.alert("token", JSON.stringify(res));
132+
Alert.alert("get token", JSON.stringify(res));
90133
if (res.code == 2000) {
91134
this.setState({ token: res.content });
92135
}
@@ -95,36 +138,40 @@ export default class App extends React.Component {
95138
}
96139
}/>
97140

98-
<Button title="verifyNumber"
141+
<Button title="numberVerify"
99142
onPress={() => JVerification.verifyNumber({
100-
number: 'your number',
143+
number: '13802286451',
101144
token: this.state.token
102145
},(res) => {
103-
Alert.alert('token', JSON.stringify(res));
146+
Alert.alert('number verify', JSON.stringify(res));
104147
})}/>
105148

106-
<Button title="setDebug"
107-
onPress={() => JVerification.setDebug(true)}/>
149+
<Button title="customLoginUI"
150+
onPress={() => JVerification.setLoginUIConfig(config)}/>
151+
152+
<Button title="login"
153+
onPress={() => JVerification.login((res) => {
154+
Alert.alert("login",JSON.stringify(res));})}/>
108155
</View>
109156
);
110157
}
111158
}
112159

113-
const styles = StyleSheet.create({
114-
container: {
115-
flex: 1,
116-
justifyContent: 'center',
117-
alignItems: 'center',
118-
backgroundColor: '#F5FCFF',
119-
},
120-
welcome: {
121-
fontSize: 20,
122-
textAlign: 'center',
123-
margin: 10,
124-
},
125-
instructions: {
126-
textAlign: 'center',
127-
color: '#333333',
128-
marginBottom: 5,
129-
},
130-
});
160+
// const styles = StyleSheet.create({
161+
// container: {
162+
// flex: 1,
163+
// justifyContent: 'center',
164+
// alignItems: 'center',
165+
// backgroundColor: '#F5FCFF',
166+
// },
167+
// welcome: {
168+
// fontSize: 20,
169+
// textAlign: 'center',
170+
// margin: 10,
171+
// },
172+
// instructions: {
173+
// textAlign: 'center',
174+
// color: '#333333',
175+
// marginBottom: 5,
176+
// },
177+
// });

example/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@
77
"test": "jest"
88
},
99
"dependencies": {
10-
"jcore-react-native": "^1.3.0",
10+
"jcore-react-native": "^1.3.2",
1111
"jverification-react-native": "file:..",
12-
"react": "16.6.0-alpha.8af6728",
12+
"react": "^16.6.0-alpha.8af6728",
1313
"react-native": "^0.57.4"
1414
},
1515
"devDependencies": {

0 commit comments

Comments
 (0)