-
Notifications
You must be signed in to change notification settings - Fork 427
/
Copy pathWelcomePage.js
94 lines (84 loc) · 2.71 KB
/
WelcomePage.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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
/**
* Created by guoshuyu on 2017/11/7.
*/
import React, {Component} from 'react';
import {
View, Image, StatusBar, Platform, Animated, Easing
} from 'react-native';
import {Actions} from 'react-native-router-flux';
import styles, {screenHeight, screenWidth} from "../style"
import loginActions from '../store/actions/login'
import userActions from '../store/actions/user'
import {connect} from 'react-redux'
import {bindActionCreators} from 'redux'
import * as Constant from "../style/constant"
import LottieView from 'lottie-react-native';
/**
* 欢迎页
*/
@connect(
state => ({
state
}), dispatch => ({
actions: bindActionCreators(loginActions, dispatch),
})
)
export default class WelcomePage extends Component {
constructor(props) {
super(props);
this.toNext = this.toNext.bind(this);
this.state = {
progress: new Animated.Value(0),
};
}
componentDidMount() {
//是否登陆,是否用户信息
userActions.initUserInfo().then((res) => {
this.toNext(res)
});
Animated.timing(this.state.progress, {
toValue: 1,
duration: 2000,
easing: Easing.linear,
}).start();
}
componentWillUnmount() {
if (this.refs.lottieView) {
this.refs.lottieView.reset();
}
}
toNext(res) {
setTimeout(() => {
if (res && res.result) {
Actions.reset("root");
} else {
Actions.reset("LoginPage");
}
}, 2100);
}
render() {
return (
<View style={[styles.mainBox, {backgroundColor: Constant.white}]}>
<StatusBar hidden={true}/>
<View style={[styles.centered, {flex: 1}]}>
<Image source={require("../img/welcome.png")}
resizeMode={"contain"}
style={{width: screenWidth, height: screenHeight}}/>
<View style={[styles.absoluteFull, styles.centered, {justifyContent: "flex-end"}]}>
<View style={[styles.centered, {width: 150, height:150}]}>
<LottieView
ref="lottieView"
style={{
width: 150,
height: 150,
}}
source={require('../style/lottie/animation-w800-h800.json')}
progress={this.state.progress}
/>
</View>
</View>
</View>
</View>
)
}
}