/** * Sample React Native App * https://github.com/facebook/react-native * * @format * @flow */ import React, { Component } from 'react'; import { AsyncStorage } from 'react-native'; import { createStackNavigator, createAppContainer } from 'react-navigation'; import Storage from 'react-native-storage'; import MainActivity from './pages/MainActivity'; import SchoolAge from './pages/SchoolAge'; import MainPage from './pages/components/MainPage'; import SchedulePage from './pages/components/SchedulePage'; import PersonalInfo from './pages/PersonalInfo'; import CourseDetails from './pages/CourseDetails'; import userCenter from './pages/userCenter'; import Order from './pages/buy/order'; import Ticket from './pages/buy/ticket'; import Buy from './pages/buy/buy'; import Login from './pages/Login'; import SearchResult from './pages/searchResult'; import PhoneBind from './pages/PhoneBind'; import Splash from './pages/Splash'; import './pages/components/RootView'; import commonutil from './pages/utils/commonutil'; const RootNavigator = createStackNavigator( { MainActivity: { screen: MainActivity }, SchoolAge: { screen: SchoolAge }, MainPage: { screen: MainPage }, SchedulePage: { screen: SchedulePage }, PersonalInfo: { screen: PersonalInfo }, userCenter: { screen: userCenter }, CourseDetails: { screen: CourseDetails }, Order: { screen: Order }, Ticket: { screen: Ticket }, Login: { screen: Login }, Buy: { screen: Buy }, SearchResult: { screen: SearchResult }, PhoneBind: { screen: PhoneBind }, Splash: { screen: Splash } }, { initialRouteName: 'Splash', headerMode: 'null' } ); const App = createAppContainer(RootNavigator); export default App; let storage = new Storage({ size: 1000, storageBackend: AsyncStorage, defaultExpires: null, enableCache: true }); global.storage = storage; getUserInfo().then((result) => { if (result == null) { global.userInfo = null; return true; } var json = JSON.parse(result); global.userInfo = { avatar: json.avatar, ageGroup: json.ageGroup, birthday: json.birthday, channel: json.channel, city: json.city, country: json.country, eid: json.eid, gmtCreated: json.gmtCreated, gmtModified: json.gmtModified, mobile: json.mobile, nickName: json.nickName, province: json.province, school: json.school, sex: json.sex, status: json.status, uid: json.uid, isVisitor: json.isVisitor }; }); async function getUserInfo() { let info = await global.storage .load({ key: 'userInfo' }) .then((result) => { return result; }) .catch((err) => { console.log('ERROR' + err.message); return null; }); return info; }