罗广聪

AIQues

@@ -8,7 +8,7 @@ import { @@ -8,7 +8,7 @@ import {
8 TouchableOpacity, 8 TouchableOpacity,
9 ScrollView, 9 ScrollView,
10 ListView, 10 ListView,
11 - Dimensions, 11 + Dimensions
12 } from "react-native"; 12 } from "react-native";
13 import { StackNavigator, TabNavigator } from "react-navigation"; 13 import { StackNavigator, TabNavigator } from "react-navigation";
14 14
@@ -19,15 +19,26 @@ export default class Home extends Component { @@ -19,15 +19,26 @@ export default class Home extends Component {
19 QuesList: [ 19 QuesList: [
20 { 20 {
21 title: "1.我该称呼您先生还是女士呢?", 21 title: "1.我该称呼您先生还是女士呢?",
22 - answers: ["先生","女士"], 22 + type: "select",
23 - },{ 23 + answers: ["先生", "女士"]
  24 + },
  25 + {
24 title: "2.请问您是否有家庭负债?", 26 title: "2.请问您是否有家庭负债?",
25 - answers: ["有贷款","无贷款"], 27 + type: "select",
26 - },{ 28 + answers: ["有贷款", "无贷款"]
  29 + },
  30 + {
27 title: "3.您要为哪些家人投保呢?", 31 title: "3.您要为哪些家人投保呢?",
28 - answers: ["先生","配偶","儿子","女儿","母亲","父亲"] 32 + type: "select",
  33 + answers: ["先生", "配偶", "儿子", "女儿", "母亲", "父亲"]
  34 + },
  35 + {
  36 + title: "4.选择出生日期",
  37 + type: "date",
  38 + answers: "1994.06.06"
29 } 39 }
30 - ] 40 + ],
  41 + answerList: []
31 }; 42 };
32 } 43 }
33 componentWillMount() {} 44 componentWillMount() {}
@@ -63,24 +74,36 @@ export default class Home extends Component { @@ -63,24 +74,36 @@ export default class Home extends Component {
63 } 74 }
64 75
65 _renderQuestion() { 76 _renderQuestion() {
66 - const { QuesList } = this.state; 77 + return this.state.QuesList.map((item, index) => {
67 - return ( 78 + return (
68 - <Text>列表</Text> 79 + <View style={styles.itemQuesContainer} key={index}>
69 - ) 80 + <View style={styles.titleContaier}>
  81 + <Text style={styles.title}>{item.title}</Text>
  82 + </View>
  83 + <View style={styles.answerContainer}>
  84 + {item.type == "select" ? (
  85 + item.answers.map((x, index2) => {
  86 + return (
  87 + <TouchableOpacity key={index2} style={styles.answerWrapper}>
  88 + <Text style={styles.answer}>{x}</Text>
  89 + </TouchableOpacity>
  90 + );
  91 + })
  92 + ) : (
  93 + <TouchableOpacity>
  94 + <Text>{item.answers}</Text>
  95 + </TouchableOpacity>
  96 + )}
  97 + </View>
  98 + </View>
  99 + );
  100 + });
70 } 101 }
71 102
72 render() { 103 render() {
73 - // console.log("首页的this.props", this);  
74 - // console.log("render首页文章列表", this.state.ListData);  
75 const { navigate } = this.props.navigation; 104 const { navigate } = this.props.navigation;
76 - return ( 105 + return <View style={styles.container}>{this._renderQuestion()}</View>;
77 - <View style={styles.container}>  
78 - <Text>智能问题</Text>  
79 - {this._renderQuestion()}  
80 - </View>  
81 - );  
82 } 106 }
83 -  
84 } 107 }
85 108
86 const styles = StyleSheet.create({ 109 const styles = StyleSheet.create({
@@ -88,6 +111,41 @@ const styles = StyleSheet.create({ @@ -88,6 +111,41 @@ const styles = StyleSheet.create({
88 flex: 1, 111 flex: 1,
89 justifyContent: "flex-start", 112 justifyContent: "flex-start",
90 alignItems: "stretch", 113 alignItems: "stretch",
91 - backgroundColor: "#F0F0F0" 114 + backgroundColor: "#F0F0F0",
  115 + paddingHorizontal: 12,
  116 + paddingTop: 12
  117 + },
  118 + itemQuesContainer: {
  119 + backgroundColor: "white",
  120 + marginBottom: 12,
  121 + borderRadius: 4
92 }, 122 },
  123 + titleContaier: {
  124 + paddingHorizontal: 14,
  125 + paddingVertical: 17
  126 + },
  127 + answerContainer: {
  128 + borderStyle: "solid",
  129 + borderColor: "#E6E6E6",
  130 + borderTopWidth: 0.5,
  131 + paddingHorizontal: 14,
  132 + paddingBottom: 17,
  133 + flexDirection: "row",
  134 + flexWrap: "wrap"
  135 + },
  136 + answerWrapper: {
  137 + marginRight: 18,
  138 + marginTop: 17,
  139 + paddingHorizontal: 10,
  140 + paddingVertical: 4,
  141 + borderStyle: "solid",
  142 + borderColor: "#ccc",
  143 + borderWidth: 0.5,
  144 + justifyContent: "center",
  145 + alignItems: "center",
  146 + borderRadius: 3
  147 + },
  148 + answer: {
  149 + fontSize: 15,
  150 + }
93 }); 151 });