Question.js 2.07 KB
import React, { Component } from "react";
import {
  AppRegistry,
  StyleSheet,
  Text,
  View,
  Image,
  TouchableOpacity,
  ScrollView,
  ListView,
  Dimensions,
} from "react-native";
import { StackNavigator, TabNavigator } from "react-navigation";

export default class Home extends Component {
  constructor(props) {
    super(props);
    this.state = {
      QuesList: [
        {
          title: "1.我该称呼您先生还是女士呢?",
          answers: ["先生","女士"],
        },{
          title: "2.请问您是否有家庭负债?",
          answers: ["有贷款","无贷款"],
        },{
          title: "3.您要为哪些家人投保呢?",
          answers: ["先生","配偶","儿子","女儿","母亲","父亲"]
        }
      ]
    };
  }
  componentWillMount() {}

  componentDidMount() {}

  getListData() {
    let that = this;
    return fetch(`https://devpay.brae.co/test/insurance/topic`, {
      method: "POST",
      headers: {
        Accept: "application/json",
        "Content-Type": "application/json"
      }
    })
      .then(resp => {
        if (resp.status === 200) {
          return resp.json();
        } else {
          console.error("something went wrong!");
        }
      })
      .then(respJson => {
        if (respJson.enmsg != "ok") {
          alert(respJson.cnmsg);
        } else {
          that.setState({
            ListData: respJson.data.topic
          });
          console.log("首页列表", this.state.ListData);
        }
      });
  }

  _renderQuestion() {
    const { QuesList } = this.state;
    return (
      <Text>列表</Text>
    )
  }

  render() {
    // console.log("首页的this.props", this);
    // console.log("render首页文章列表", this.state.ListData);
    const { navigate } = this.props.navigation;
    return (
      <View style={styles.container}>
        <Text>智能问题</Text>
        {this._renderQuestion()}
      </View>
    );
  }

}

const styles = StyleSheet.create({
  container: {
    flex: 1,
    justifyContent: "flex-start",
    alignItems: "stretch",
    backgroundColor: "#F0F0F0"
  },
});