Solution.js 4.39 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 = {};
  }
  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);
        }
      });
  }

  render() {
    console.log("solution", this.props.navigation.state.params.answerList);
    const { navigate } = this.props.navigation;
    return (
      <View style={styles.container}>
        <View style={styles.ownContaier}>
          <View style={styles.headerContainer}>
            <View style={styles.titleWrapper}>
              <Text style={styles.headerTitle}>关于自己的保险方案</Text>
            </View>
          </View>
          <View style={styles.infoContainer}>
            <View style={styles.leftInfoContaier}>
              <View style={styles.TInfoContaier}>
                <Text>年龄:</Text>
                <Text>16</Text>
              </View>
              <View style={styles.BInfoContaier}>
                <Text>个人年收入:</Text>
                <Text>10</Text>
              </View>
            </View>
            <View style={styles.rightInfoContaier}>
              <View style={styles.TInfoContaier}>
                <Text>社保:</Text>
                <Text>有社保</Text>
              </View>
              <View style={styles.BInfoContaier}>
                <Text>负责:</Text>
                <Text>XXX贷款</Text>
              </View>
            </View>
          </View>
          <View style={styles.adviceContainer}>
            <Text style={styles.adviceText}>
            作为家庭的经济支柱,压力和责任重大,应优先进行保险配置,且应占家庭保险的中支出和总保额的大比重,建议依次配置以下产品,以保障家庭持续、高品质的运营
            </Text>
          </View>
        </View>
        <View style={styles.configureContaier}>
          <View style={styles.headerContainer}>
            <View style={styles.titleWrapper}>
              <Text style={styles.headerTitle}>保险配置方案</Text>
            </View>
          </View>
          <View style={styles.tableContainer}>
            <Text>表格</Text>
          </View>
        </View>
      </View>
    );
  }
}

const styles = StyleSheet.create({
  container: {
    flex: 1,
    justifyContent: "flex-start",
    alignItems: "stretch",
    backgroundColor: "#F0F0F0"
  },
  ownContaier: {
    backgroundColor: "white",
    marginTop: 10
  },
  headerContainer: {
    marginLeft: 10,
    height: 45,
    justifyContent: "center",
    alignItems: "flex-start"
  },
  titleWrapper: {
    borderStyle: "solid",
    borderColor: "#009B3A",
    borderLeftWidth: 2,
    paddingLeft: 7
  },
  headerTitle: {
    fontSize: 16,
    fontWeight: "bold"
  },
  infoContainer: {
    marginLeft: 18,
    borderStyle: "solid",
    borderColor: "#E8E8E8",
    borderTopWidth: 0.5,
    flexDirection: "row",
    paddingVertical: 12,
  },
  leftInfoContaier: {
    flex: 1,
    justifyContent: "center",
    alignItems: "flex-start"
  },
  rightInfoContaier: {
    flex: 1,
    justifyContent: "center",
    alignItems: "flex-start"
  },
  TInfoContaier: {
    flexDirection: "row",
    marginBottom: 12,
  },
  BInfoContaier: {
    flexDirection: "row",
  },
  adviceContainer: {
    marginLeft: 18,
    paddingRight: 18,
    borderStyle: "solid",
    borderColor: "#E8E8E8",
    borderTopWidth: 0.5,
    paddingVertical: 12,
  },
  adviceText: {
    fontSize: 13,
    lineHeight: 20,
    color: "#242424",
  },
  configureContaier: {
    backgroundColor: "white",
    marginTop: 10
  }
});