罗广聪

判断登录状态

... ... @@ -16,7 +16,9 @@ import Main from './src/pages/main';
export default class ProtectGod extends Component {
render() {
return (
<Main />
<Main
loginSuccess={false}
/>
);
}
}
... ...
import React, { Component } from "react";
import {
AppRegistry,
StyleSheet,
Text,
View,
Image,
TouchableOpacity,
ScrollView,
} from "react-native";
export default class Login extends Component {
constructor(props) {
super(props);
this.state = {};
}
componentDidMount() {
console.log("thisprops", this.props);
}
render() {
return (
<View style={styles.container}>
<Text>我是登录页面</Text>
</View>
);
}
}
const styles = StyleSheet.create({
container: {
flex: 1,
paddingTop: 64,
justifyContent: "flex-start",
alignItems: "stretch",
backgroundColor: "white",
paddingLeft: 38,
paddingRight: 38,
},
});
... ...
... ... @@ -13,7 +13,7 @@ import Home from "./Home/index";
import InsuranceCircle from "./InsuranceCircle/index";
import InsuranceChurch from "./InsuranceChurch/index";
import Mine from "./Mine/index";
import Login from "./Login";
var scale = Dimensions.get('window').scale;
... ... @@ -21,12 +21,20 @@ export default class Main extends Component {
constructor(props) {
super(props);
this.state = {
selectedItem: "home"
selectedItem: "home",
}
}
componentWillMount() {
console.log("loginSuccess",this.props);
}
render() {
// {this.state.loginSuccess ? {} : {}}
const { loginSuccess } = this.props;
return (
loginSuccess
? (
<TabBarIOS tintColor="#08CC6A" barTintColor="white">
<TabBarIOS.Item
title="首页"
... ... @@ -102,6 +110,85 @@ export default class Main extends Component {
/>
</TabBarIOS.Item>
</TabBarIOS>
)
: (
<Login />
)
// <TabBarIOS tintColor="#08CC6A" barTintColor="white">
// <TabBarIOS.Item
// title="首页"
// icon={require("../assets/tabbar/ic_home_n.png")}
// selected={this.state.selectedItem == "home"}
// onPress={() => {
// this.setState({
// selectedItem: "home"
// });
// }}
// >
// <NavigatorIOS
// style={{ flex: 1 }}
// initialRoute={{
// component: Home,
// title: "保护神"
// }}
// />
// </TabBarIOS.Item>
// <TabBarIOS.Item
// title="保圈"
// icon={require("../assets/tabbar/ic_circle_n.png")}
// selected={this.state.selectedItem == "insuranceCircle"}
// onPress={() => {
// this.setState({
// selectedItem: "insuranceCircle"
// });
// }}
// >
// <NavigatorIOS
// style={{ flex: 1 }}
// initialRoute={{
// component: InsuranceCircle,
// title: "保护神",
// }}
// />
// </TabBarIOS.Item>
// <TabBarIOS.Item
// title="保堂"
// icon={require("../assets/tabbar/ic_umbrella_n.png")}
// selected={this.state.selectedItem == "insuranceChurch"}
// onPress={() => {
// this.setState({
// selectedItem: "insuranceChurch"
// });
// }}
// >
// <NavigatorIOS
// style={{ flex: 1 }}
// initialRoute={{
// component: InsuranceChurch,
// title: "保护神"
// }}
// />
// </TabBarIOS.Item>
// <TabBarIOS.Item
// title="我的"
// icon={require("../assets/tabbar/ic_mine_n.png")}
// selected={this.state.selectedItem == "mine"}
// onPress={() => {
// this.setState({
// selectedItem: "mine"
// });
// }}
// >
// <NavigatorIOS
// style={{ flex: 1 }}
// initialRoute={{
// component: Mine,
// title: "保护神"
// }}
// />
// </TabBarIOS.Item>
// </TabBarIOS>
);
}
}
... ...