-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathindex.ios.js
63 lines (54 loc) · 1.27 KB
/
index.ios.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
import React from 'react-native';
import Login from './IOSapp/containers/login';
import Guide from './IOSapp/containers/Guide';
import { userStorage } from './IOSapp/Storage';
import ThemeColor from './IOSapp/style/ColorTheme';
import App from './IOSapp/containers/App';
const {
AppRegistry,
Component,
StyleSheet,
} = React;
class NiniCall extends Component {
state = {
isLogin: false,
};
componentWillMount() {
// 保存登录状态
userStorage.getUserId(this.keepLogin)
}
keepLogin = (err, id) => {
if (id) {
this.setState({
isLogin: true,
userId: id
});
}
};
handleLoginSuccess = (userInfo) => {
this.setState({
isLogin: true,
userInfo: userInfo,
userId: userInfo._id,
});
};
render() {
const { isLogin, userId, userInfo } = this.state;
return (
isLogin?<App
userId={userId}
userInfo={userInfo}
/> : <Guide
style={[{ flex: 1 }, styles.wrapStyle]}
handleLoginSuccess={this.handleLoginSuccess}
itemWrapperStyle={styles.wrapStyle}
/>
);
}
}
const styles = StyleSheet.create({
wrapStyle: {
backgroundColor: ThemeColor.background,
},
});
AppRegistry.registerComponent('NiniCall', () => NiniCall);