Showing
2 changed files
with
29 additions
and
5 deletions
| @@ -153,13 +153,35 @@ export default class Home extends Component { | @@ -153,13 +153,35 @@ export default class Home extends Component { | ||
| 153 | }); | 153 | }); |
| 154 | } | 154 | } |
| 155 | 155 | ||
| 156 | + submit() { | ||
| 157 | + const that = this; | ||
| 158 | + let Temp = this.state.QuesList.map(item => item.answers[item.selected]); | ||
| 159 | + console.log(Temp) | ||
| 160 | + Temp.splice(3,1,that.format(that.state.date)); | ||
| 161 | + that.setState({ | ||
| 162 | + answerList: Temp | ||
| 163 | + }) | ||
| 164 | + } | ||
| 165 | + | ||
| 166 | + format(date) { | ||
| 167 | + const Year = date.getFullYear(); | ||
| 168 | + const Month = date.getMonth(); | ||
| 169 | + const Day = date.getDate(); | ||
| 170 | + return `${Year}-${Month}-${Day}`; | ||
| 171 | + } | ||
| 172 | + | ||
| 156 | render() { | 173 | render() { |
| 157 | const { navigate } = this.props.navigation; | 174 | const { navigate } = this.props.navigation; |
| 158 | return ( | 175 | return ( |
| 159 | <View style={styles.container}> | 176 | <View style={styles.container}> |
| 160 | <ScrollView> | 177 | <ScrollView> |
| 161 | {this._renderQuestion()} | 178 | {this._renderQuestion()} |
| 162 | - <TouchableOpacity style={styles.confirmBtn}> | 179 | + <TouchableOpacity |
| 180 | + onPress={() => { | ||
| 181 | + this.submit(); | ||
| 182 | + }} | ||
| 183 | + style={styles.confirmBtn} | ||
| 184 | + > | ||
| 163 | <Text style={styles.confirmBtnText}>生成智能方案</Text> | 185 | <Text style={styles.confirmBtnText}>生成智能方案</Text> |
| 164 | </TouchableOpacity> | 186 | </TouchableOpacity> |
| 165 | </ScrollView> | 187 | </ScrollView> |
| @@ -225,6 +247,6 @@ const styles = StyleSheet.create({ | @@ -225,6 +247,6 @@ const styles = StyleSheet.create({ | ||
| 225 | color: "white" | 247 | color: "white" |
| 226 | }, | 248 | }, |
| 227 | dateWrapper: { | 249 | dateWrapper: { |
| 228 | - width: 300, | 250 | + width: 300 |
| 229 | - }, | 251 | + } |
| 230 | }); | 252 | }); |
| @@ -71,10 +71,12 @@ export default class Home extends Component { | @@ -71,10 +71,12 @@ export default class Home extends Component { | ||
| 71 | 71 | ||
| 72 | <TouchableOpacity | 72 | <TouchableOpacity |
| 73 | onPress={() => { | 73 | onPress={() => { |
| 74 | - {/* alert(this.state.date); */} | 74 | + { |
| 75 | + /* alert(this.state.date); */ | ||
| 76 | + } | ||
| 75 | this.setState({ | 77 | this.setState({ |
| 76 | showDate: !this.state.showDate | 78 | showDate: !this.state.showDate |
| 77 | - }) | 79 | + }); |
| 78 | }} | 80 | }} |
| 79 | > | 81 | > |
| 80 | <Text>打印时间</Text> | 82 | <Text>打印时间</Text> |
-
Please register or login to post a comment