Showing
1 changed file
with
91 additions
and
11 deletions
| @@ -20,22 +20,38 @@ export default class Home extends Component { | @@ -20,22 +20,38 @@ export default class Home extends Component { | ||
| 20 | { | 20 | { |
| 21 | title: "1.我该称呼您先生还是女士呢?", | 21 | title: "1.我该称呼您先生还是女士呢?", |
| 22 | type: "select", | 22 | type: "select", |
| 23 | - answers: ["先生", "女士"] | 23 | + answers: ["先生", "女士"], |
| 24 | + selected: 0 | ||
| 24 | }, | 25 | }, |
| 25 | { | 26 | { |
| 26 | title: "2.请问您是否有家庭负债?", | 27 | title: "2.请问您是否有家庭负债?", |
| 27 | type: "select", | 28 | type: "select", |
| 28 | - answers: ["有贷款", "无贷款"] | 29 | + answers: ["有贷款", "无贷款"], |
| 30 | + selected: 0 | ||
| 29 | }, | 31 | }, |
| 30 | { | 32 | { |
| 31 | title: "3.您要为哪些家人投保呢?", | 33 | title: "3.您要为哪些家人投保呢?", |
| 32 | type: "select", | 34 | type: "select", |
| 33 | - answers: ["先生", "配偶", "儿子", "女儿", "母亲", "父亲"] | 35 | + answers: ["先生", "配偶", "儿子", "女儿", "母亲", "父亲"], |
| 36 | + selected: 0 | ||
| 34 | }, | 37 | }, |
| 35 | { | 38 | { |
| 36 | title: "4.选择出生日期", | 39 | title: "4.选择出生日期", |
| 37 | type: "date", | 40 | type: "date", |
| 38 | - answers: "1994.06.06" | 41 | + answers: ["请选择"], |
| 42 | + selected: 0 | ||
| 43 | + }, | ||
| 44 | + { | ||
| 45 | + title: "5.请问被保人的年收入是多少?", | ||
| 46 | + type: "select", | ||
| 47 | + answers: ["2万以下", "2万~10万", "10万以上"], | ||
| 48 | + selected: 0 | ||
| 49 | + }, | ||
| 50 | + { | ||
| 51 | + title: "6.被保人是否有社保?", | ||
| 52 | + type: "select", | ||
| 53 | + answers: ["有", "无"], | ||
| 54 | + selected: 0 | ||
| 39 | } | 55 | } |
| 40 | ], | 56 | ], |
| 41 | answerList: [] | 57 | answerList: [] |
| @@ -81,7 +97,7 @@ export default class Home extends Component { | @@ -81,7 +97,7 @@ export default class Home extends Component { | ||
| 81 | <Text style={styles.title}>{item.title}</Text> | 97 | <Text style={styles.title}>{item.title}</Text> |
| 82 | </View> | 98 | </View> |
| 83 | <View style={styles.answerContainer}> | 99 | <View style={styles.answerContainer}> |
| 84 | - {item.type == "select" ? ( | 100 | + {/* {item.type == "select" ? ( |
| 85 | item.answers.map((x, index2) => { | 101 | item.answers.map((x, index2) => { |
| 86 | return ( | 102 | return ( |
| 87 | <TouchableOpacity key={index2} style={styles.answerWrapper}> | 103 | <TouchableOpacity key={index2} style={styles.answerWrapper}> |
| @@ -90,10 +106,51 @@ export default class Home extends Component { | @@ -90,10 +106,51 @@ export default class Home extends Component { | ||
| 90 | ); | 106 | ); |
| 91 | }) | 107 | }) |
| 92 | ) : ( | 108 | ) : ( |
| 93 | - <TouchableOpacity> | 109 | + <TouchableOpacity style={styles.answerWrapper}> |
| 94 | <Text>{item.answers}</Text> | 110 | <Text>{item.answers}</Text> |
| 95 | </TouchableOpacity> | 111 | </TouchableOpacity> |
| 96 | - )} | 112 | + )} */} |
| 113 | + {item.answers.map((x, index2) => { | ||
| 114 | + return ( | ||
| 115 | + <TouchableOpacity | ||
| 116 | + key={index2} | ||
| 117 | + style={[ | ||
| 118 | + styles.answerWrapper, | ||
| 119 | + { | ||
| 120 | + backgroundColor: | ||
| 121 | + item.selected == index2 ? "#1B9341" : "white" | ||
| 122 | + } | ||
| 123 | + ]} | ||
| 124 | + onPress={() => { | ||
| 125 | + if (item.type == "select") { | ||
| 126 | + this.setState({ | ||
| 127 | + QuesList: [ | ||
| 128 | + ...this.state.QuesList.slice(0, index), | ||
| 129 | + { | ||
| 130 | + ...this.state.QuesList[index], | ||
| 131 | + selected: index2 | ||
| 132 | + }, | ||
| 133 | + ...this.state.QuesList.slice(index + 1) | ||
| 134 | + ] | ||
| 135 | + }); | ||
| 136 | + } else { | ||
| 137 | + { | ||
| 138 | + /* 选择日期 */ | ||
| 139 | + } | ||
| 140 | + } | ||
| 141 | + }} | ||
| 142 | + > | ||
| 143 | + <Text | ||
| 144 | + style={[ | ||
| 145 | + styles.answer, | ||
| 146 | + { color: item.selected == index2 ? "white" : "#242424" } | ||
| 147 | + ]} | ||
| 148 | + > | ||
| 149 | + {x} | ||
| 150 | + </Text> | ||
| 151 | + </TouchableOpacity> | ||
| 152 | + ); | ||
| 153 | + })} | ||
| 97 | </View> | 154 | </View> |
| 98 | </View> | 155 | </View> |
| 99 | ); | 156 | ); |
| @@ -102,7 +159,16 @@ export default class Home extends Component { | @@ -102,7 +159,16 @@ export default class Home extends Component { | ||
| 102 | 159 | ||
| 103 | render() { | 160 | render() { |
| 104 | const { navigate } = this.props.navigation; | 161 | const { navigate } = this.props.navigation; |
| 105 | - return <View style={styles.container}>{this._renderQuestion()}</View>; | 162 | + return ( |
| 163 | + <View style={styles.container}> | ||
| 164 | + <ScrollView> | ||
| 165 | + {this._renderQuestion()} | ||
| 166 | + <TouchableOpacity style={styles.confirmBtn}> | ||
| 167 | + <Text style={styles.confirmBtnText}>生成智能方案</Text> | ||
| 168 | + </TouchableOpacity> | ||
| 169 | + </ScrollView> | ||
| 170 | + </View> | ||
| 171 | + ); | ||
| 106 | } | 172 | } |
| 107 | } | 173 | } |
| 108 | 174 | ||
| @@ -136,16 +202,30 @@ const styles = StyleSheet.create({ | @@ -136,16 +202,30 @@ const styles = StyleSheet.create({ | ||
| 136 | answerWrapper: { | 202 | answerWrapper: { |
| 137 | marginRight: 18, | 203 | marginRight: 18, |
| 138 | marginTop: 17, | 204 | marginTop: 17, |
| 139 | - paddingHorizontal: 10, | 205 | + paddingHorizontal: 20, |
| 140 | paddingVertical: 4, | 206 | paddingVertical: 4, |
| 207 | + height: 30, | ||
| 141 | borderStyle: "solid", | 208 | borderStyle: "solid", |
| 142 | - borderColor: "#ccc", | 209 | + borderColor: "#E6E6E6", |
| 143 | borderWidth: 0.5, | 210 | borderWidth: 0.5, |
| 144 | justifyContent: "center", | 211 | justifyContent: "center", |
| 145 | alignItems: "center", | 212 | alignItems: "center", |
| 146 | borderRadius: 3 | 213 | borderRadius: 3 |
| 147 | }, | 214 | }, |
| 148 | answer: { | 215 | answer: { |
| 149 | - fontSize: 15, | 216 | + fontSize: 15 |
| 217 | + // color: "#242424", | ||
| 218 | + }, | ||
| 219 | + confirmBtn: { | ||
| 220 | + marginVertical: 20, | ||
| 221 | + justifyContent: "center", | ||
| 222 | + alignItems: "center", | ||
| 223 | + backgroundColor: "#1B9341", | ||
| 224 | + height: 45, | ||
| 225 | + borderRadius: 5 | ||
| 226 | + }, | ||
| 227 | + confirmBtnText: { | ||
| 228 | + fontSize: 16, | ||
| 229 | + color: "white" | ||
| 150 | } | 230 | } |
| 151 | }); | 231 | }); |
-
Please register or login to post a comment