罗广聪

发布按钮的条件判断

@@ -115,7 +115,10 @@ const ProtectGod = StackNavigator( @@ -115,7 +115,10 @@ const ProtectGod = StackNavigator(
115 ProductTemplate: { screen: ProductTemplate }, 115 ProductTemplate: { screen: ProductTemplate },
116 ArticleTemplate: { screen: ArticleTemplate }, 116 ArticleTemplate: { screen: ArticleTemplate },
117 Details: { screen: Details }, 117 Details: { screen: Details },
118 - Release: { screen: Release }, 118 + Release: {
  119 + screen: Release,
  120 + navigationOptions: { headerTitle: "发布" }
  121 + },
119 Discover: { screen: Discover }, 122 Discover: { screen: Discover },
120 AIBegin: { 123 AIBegin: {
121 screen: AIBegin, 124 screen: AIBegin,
@@ -140,7 +143,7 @@ const ProtectGod = StackNavigator( @@ -140,7 +143,7 @@ const ProtectGod = StackNavigator(
140 HealthResult: { 143 HealthResult: {
141 screen: HealthResult, 144 screen: HealthResult,
142 navigationOptions: { headerTitle: "健康问卷" } 145 navigationOptions: { headerTitle: "健康问卷" }
143 - }, 146 + }
144 }, 147 },
145 { 148 {
146 navigationOptions: { 149 navigationOptions: {
@@ -19,6 +19,8 @@ export default class Home extends Component { @@ -19,6 +19,8 @@ export default class Home extends Component {
19 this.state = { 19 this.state = {
20 gridData: { 20 gridData: {
21 title: ["角色", "建议产品", "建议保额", "保险年限", "缴费期限", "年缴保费"], 21 title: ["角色", "建议产品", "建议保额", "保险年限", "缴费期限", "年缴保费"],
  22 + actor: "父亲",
  23 + age: "42岁",
22 products: [ 24 products: [
23 { 25 {
24 name: "成人意外险", 26 name: "成人意外险",
@@ -7,15 +7,30 @@ import { @@ -7,15 +7,30 @@ import {
7 ScrollView, 7 ScrollView,
8 TouchableOpacity, 8 TouchableOpacity,
9 Image, 9 Image,
  10 + AsyncStorage,
  11 + Alert,
10 } from "react-native"; 12 } from "react-native";
11 import { StackNavigator, TabNavigator } from "react-navigation"; 13 import { StackNavigator, TabNavigator } from "react-navigation";
12 import Details from "./details"; 14 import Details from "./details";
13 15
14 export default class InsuranceCircle extends Component { 16 export default class InsuranceCircle extends Component {
15 - static navigationOptions = { 17 + static navigationOptions = ({ navigation }) => {
16 - // headerRight: this._rightBtn() 18 + const { state, setParams, navigate } = navigation;
17 - } 19 + // console.log("保圈页面-发布", state);
18 - 20 + return {
  21 + headerRight: (
  22 + <TouchableOpacity
  23 + style={{ marginRight: 13 }}
  24 + onPress={() => state.params.testLoginAndGo()}
  25 + >
  26 + <Image
  27 + source={require("../../assets/circle/ic_announce.png")}
  28 + style={{ width: 19, height: 19 }}
  29 + />
  30 + </TouchableOpacity>
  31 + )
  32 + };
  33 + };
19 constructor(props) { 34 constructor(props) {
20 super(props); 35 super(props);
21 this.state = { 36 this.state = {
@@ -23,37 +38,68 @@ export default class InsuranceCircle extends Component { @@ -23,37 +38,68 @@ export default class InsuranceCircle extends Component {
23 IS_LOGIN: "", 38 IS_LOGIN: "",
24 USER_ID: "", 39 USER_ID: "",
25 NICKNAME: "", 40 NICKNAME: "",
26 - PROFESSION: "", 41 + PROFESSION: ""
27 }; 42 };
28 } 43 }
29 -  
30 componentWillMount() { 44 componentWillMount() {
31 - this.getAsyncStorage(); 45 + // this.getAsyncStorage();
32 this.getArticles(); 46 this.getArticles();
33 } 47 }
34 - 48 + componentDidMount() {
35 - _rightBtn() { 49 + this.props.navigation.setParams({
36 - return ( 50 + testLoginAndGo: this.testLoginAndGo.bind(this)
37 - <TouchableOpacity style={{marginRight: 13}} onPress={() => {}}> 51 + });
38 - <Image source={require("../../assets/circle/ic_announce.png")} style={{width: 19,height: 19}} /> 52 + }
39 - </TouchableOpacity> 53 + testLoginAndGo() {
40 - ) 54 + const that = this;
  55 + const { navigate } = this.props.navigation;
  56 + console.log("为何是underfined?",this);
  57 + // this.getAsyncStorage();
  58 + AsyncStorage.multiGet(
  59 + ["IS_LOGIN", "USER_ID", "NICKNAME", "PROFESSION"],
  60 + (err, result) => {
  61 + if (err) {
  62 + console.error(err);
  63 + }
  64 + console.log("点击登录后的值", result);
  65 + that.setState({
  66 + IS_LOGIN: result[0][1],
  67 + USER_ID: result[1][1] != null ? result[1][1] : "",
  68 + NICKNAME: result[2][1] != null ? result[2][1] : "",
  69 + PROFESSION: result[3][1] != null ? result[3][1] : ""
  70 + },() => {
  71 + if (this.state.IS_LOGIN == 'yes') {
  72 + navigate("Release");
  73 + } else {
  74 + Alert.alert("请先登录账号");
  75 + }
  76 + });
  77 + }
  78 + );
  79 + // if (this.state.IS_LOGIN == 'yes') {
  80 + // navigate("Release");
  81 + // } else {
  82 + // Alert.alert("请先登录账号");
  83 + // }
41 } 84 }
42 85
43 getAsyncStorage() { 86 getAsyncStorage() {
44 const that = this; 87 const that = this;
45 - AsyncStorage.multiGet(["IS_LOGIN","USER_ID","NICKNAME","PROFESSION"],(err, result) => { 88 + AsyncStorage.multiGet(
46 - if (err) { 89 + ["IS_LOGIN", "USER_ID", "NICKNAME", "PROFESSION"],
47 - console.error(err); 90 + (err, result) => {
  91 + if (err) {
  92 + console.error(err);
  93 + }
  94 + console.log("点击登录后的值", result);
  95 + that.setState({
  96 + IS_LOGIN: result[0][1],
  97 + USER_ID: result[1][1] != null ? result[1][1] : "",
  98 + NICKNAME: result[2][1] != null ? result[2][1] : "",
  99 + PROFESSION: result[3][1] != null ? result[3][1] : ""
  100 + });
48 } 101 }
49 - console.log("点击登录后的值",result) 102 + );
50 - that.setState({  
51 - IS_LOGIN: result[0][1],  
52 - USER_ID: (result[1][1] != null) ? result[1][1] : "",  
53 - NICKNAME: (result[2][1] != null) ? result[2][1] : "",  
54 - PROFESSION: (result[3][1] != null) ? result[3][1] : "",  
55 - })  
56 - })  
57 } 103 }
58 104
59 getArticles() { 105 getArticles() {
@@ -78,7 +124,7 @@ export default class InsuranceCircle extends Component { @@ -78,7 +124,7 @@ export default class InsuranceCircle extends Component {
78 alert(respJson.cnmsg); 124 alert(respJson.cnmsg);
79 } else { 125 } else {
80 that.setState({ 126 that.setState({
81 - ListData: respJson.data.data, 127 + ListData: respJson.data.data
82 }); 128 });
83 console.log("state.ListData", this.state.ListData); 129 console.log("state.ListData", this.state.ListData);
84 } 130 }