Splash.js 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. import React, { PureComponent } from 'react';
  2. import { StyleSheet, Text, View, Image, TouchableOpacity, StatusBar, ToastAndroid, TextInput } from 'react-native';
  3. import BasePage from './BasePage';
  4. import SplashScreen from 'react-native-splash-screen';
  5. import commonutil from './utils/commonutil';
  6. import http_showcase from '../pages/services/showcase';
  7. export default class Splash extends BasePage {
  8. state = {
  9. boothContent: { uri: '' }
  10. };
  11. render() {
  12. return (
  13. <View style={{ flex: 1 }}>
  14. <StatusBar backgroundColor={'transparent'} translucent={true} />
  15. {this.state.boothContent.uri.length > 0 ? (
  16. <Image source={this.state.boothContent} style={{ width: '100%', height: '100%' }} />
  17. ) : null}
  18. </View>
  19. );
  20. }
  21. componentWillMount() {
  22. commonutil.getFileUserInfo().then((res) => {
  23. if (global.userInfo == undefined || global.userInfo == null) {
  24. this.getShowCase();
  25. this.Advertisement(false);
  26. } else {
  27. console.log('====================================');
  28. console.log('assfsafdasas', global.userInfo);
  29. console.log('====================================');
  30. this.getShowCase();
  31. this.Advertisement(true);
  32. }
  33. });
  34. }
  35. getShowCase() {
  36. http_showcase.getSTARTING_UP_RECOMMEND().then((res) => {
  37. this.setState({
  38. boothContent: { uri: res.data[0].boothContent }
  39. });
  40. SplashScreen.hide();
  41. });
  42. }
  43. //获取用户之后的操作,或者是别的操作。
  44. Advertisement(bool) {
  45. //假装3秒广告
  46. setTimeout(() => {
  47. if (bool) {
  48. this.clearPageToNext('MainPage');
  49. } else {
  50. this.clearPageToNext('Login');
  51. }
  52. }, 5000);
  53. }
  54. }