罗广聪

判断登录状态

@@ -16,7 +16,9 @@ import Main from './src/pages/main'; @@ -16,7 +16,9 @@ import Main from './src/pages/main';
16 export default class ProtectGod extends Component { 16 export default class ProtectGod extends Component {
17 render() { 17 render() {
18 return ( 18 return (
19 - <Main /> 19 + <Main
  20 + loginSuccess={false}
  21 + />
20 ); 22 );
21 } 23 }
22 } 24 }
  1 +import React, { Component } from "react";
  2 +import {
  3 + AppRegistry,
  4 + StyleSheet,
  5 + Text,
  6 + View,
  7 + Image,
  8 + TouchableOpacity,
  9 + ScrollView,
  10 +} from "react-native";
  11 +
  12 +export default class Login extends Component {
  13 + constructor(props) {
  14 + super(props);
  15 + this.state = {};
  16 + }
  17 + componentDidMount() {
  18 + console.log("thisprops", this.props);
  19 + }
  20 + render() {
  21 + return (
  22 + <View style={styles.container}>
  23 + <Text>我是登录页面</Text>
  24 + </View>
  25 + );
  26 + }
  27 +}
  28 +
  29 +const styles = StyleSheet.create({
  30 + container: {
  31 + flex: 1,
  32 + paddingTop: 64,
  33 + justifyContent: "flex-start",
  34 + alignItems: "stretch",
  35 + backgroundColor: "white",
  36 + paddingLeft: 38,
  37 + paddingRight: 38,
  38 + },
  39 +});
@@ -13,7 +13,7 @@ import Home from "./Home/index"; @@ -13,7 +13,7 @@ import Home from "./Home/index";
13 import InsuranceCircle from "./InsuranceCircle/index"; 13 import InsuranceCircle from "./InsuranceCircle/index";
14 import InsuranceChurch from "./InsuranceChurch/index"; 14 import InsuranceChurch from "./InsuranceChurch/index";
15 import Mine from "./Mine/index"; 15 import Mine from "./Mine/index";
16 - 16 +import Login from "./Login";
17 17
18 var scale = Dimensions.get('window').scale; 18 var scale = Dimensions.get('window').scale;
19 19
@@ -21,12 +21,20 @@ export default class Main extends Component { @@ -21,12 +21,20 @@ export default class Main extends Component {
21 constructor(props) { 21 constructor(props) {
22 super(props); 22 super(props);
23 this.state = { 23 this.state = {
24 - selectedItem: "home" 24 + selectedItem: "home",
25 } 25 }
26 } 26 }
27 27
  28 + componentWillMount() {
  29 + console.log("loginSuccess",this.props);
  30 + }
  31 +
28 render() { 32 render() {
  33 + // {this.state.loginSuccess ? {} : {}}
  34 + const { loginSuccess } = this.props;
29 return ( 35 return (
  36 + loginSuccess
  37 + ? (
30 <TabBarIOS tintColor="#08CC6A" barTintColor="white"> 38 <TabBarIOS tintColor="#08CC6A" barTintColor="white">
31 <TabBarIOS.Item 39 <TabBarIOS.Item
32 title="首页" 40 title="首页"
@@ -102,6 +110,85 @@ export default class Main extends Component { @@ -102,6 +110,85 @@ export default class Main extends Component {
102 /> 110 />
103 </TabBarIOS.Item> 111 </TabBarIOS.Item>
104 </TabBarIOS> 112 </TabBarIOS>
  113 + )
  114 + : (
  115 + <Login />
  116 + )
  117 + // <TabBarIOS tintColor="#08CC6A" barTintColor="white">
  118 + // <TabBarIOS.Item
  119 + // title="首页"
  120 + // icon={require("../assets/tabbar/ic_home_n.png")}
  121 + // selected={this.state.selectedItem == "home"}
  122 + // onPress={() => {
  123 + // this.setState({
  124 + // selectedItem: "home"
  125 + // });
  126 + // }}
  127 + // >
  128 + // <NavigatorIOS
  129 + // style={{ flex: 1 }}
  130 + // initialRoute={{
  131 + // component: Home,
  132 + // title: "保护神"
  133 + // }}
  134 +
  135 + // />
  136 + // </TabBarIOS.Item>
  137 + // <TabBarIOS.Item
  138 + // title="保圈"
  139 + // icon={require("../assets/tabbar/ic_circle_n.png")}
  140 + // selected={this.state.selectedItem == "insuranceCircle"}
  141 + // onPress={() => {
  142 + // this.setState({
  143 + // selectedItem: "insuranceCircle"
  144 + // });
  145 + // }}
  146 + // >
  147 + // <NavigatorIOS
  148 + // style={{ flex: 1 }}
  149 + // initialRoute={{
  150 + // component: InsuranceCircle,
  151 + // title: "保护神",
  152 + // }}
  153 + // />
  154 + // </TabBarIOS.Item>
  155 + // <TabBarIOS.Item
  156 + // title="保堂"
  157 + // icon={require("../assets/tabbar/ic_umbrella_n.png")}
  158 + // selected={this.state.selectedItem == "insuranceChurch"}
  159 + // onPress={() => {
  160 + // this.setState({
  161 + // selectedItem: "insuranceChurch"
  162 + // });
  163 + // }}
  164 + // >
  165 + // <NavigatorIOS
  166 + // style={{ flex: 1 }}
  167 + // initialRoute={{
  168 + // component: InsuranceChurch,
  169 + // title: "保护神"
  170 + // }}
  171 + // />
  172 + // </TabBarIOS.Item>
  173 + // <TabBarIOS.Item
  174 + // title="我的"
  175 + // icon={require("../assets/tabbar/ic_mine_n.png")}
  176 + // selected={this.state.selectedItem == "mine"}
  177 + // onPress={() => {
  178 + // this.setState({
  179 + // selectedItem: "mine"
  180 + // });
  181 + // }}
  182 + // >
  183 + // <NavigatorIOS
  184 + // style={{ flex: 1 }}
  185 + // initialRoute={{
  186 + // component: Mine,
  187 + // title: "保护神"
  188 + // }}
  189 + // />
  190 + // </TabBarIOS.Item>
  191 + // </TabBarIOS>
105 ); 192 );
106 } 193 }
107 } 194 }