Browse Source

1.个人信息页面读取本地个人信息赋值

zhangmengjie 5 years ago
parent
commit
789b502434
3 changed files with 553 additions and 540 deletions
  1. 94 48
      pages/PersonalInfo.js
  2. 0 3
      pages/Splash.js
  3. 459 489
      pages/components/BirthdayModal.js

+ 94 - 48
pages/PersonalInfo.js

@@ -35,10 +35,10 @@ type Props = {};
 
 export default class PersonalInfo extends BasePage {
 	state = {
-		nickName: '初始昵称',
+		user_nickName: '未设置',
 		schoolName: '未设置',
-		provinceName: '广东省',
-		citys: '深圳市',
+		provinceName: '未设置',
+		citys: '',
 		grade_text: '七年级',
 		grade_index: 6,
 		birthday_year: 0,
@@ -49,9 +49,9 @@ export default class PersonalInfo extends BasePage {
 		phone: '',
 		phone_bind_result: false,
 		phone_bind_type: 1, //1是绑定,2是修改
-		phone_bind_color: '',
+		phone_bind_color: 'red',
 		wechat_nickName: '',
-		wechat_bind_color: '',
+		wechat_bind_color: 'red',
 		show_bind_phone: false
 	};
 
@@ -253,7 +253,7 @@ export default class PersonalInfo extends BasePage {
 												numberOfLines={1}
 												ellipsizeMode={'tail'}
 											>
-												{this.state.nickName}
+												{this.state.user_nickName}
 											</Text>
 										</View>
 										<View
@@ -672,44 +672,73 @@ export default class PersonalInfo extends BasePage {
 	}
 
 	componentWillMount() {
-		var date = new Date();
-		var year = date.getFullYear().toString();
-		var month = (date.getMonth() + 1).toString();
-		var day = date.getDate().toString();
-		this.setState({
-			birthday_year: year,
-			birthday_month: month,
-			birthday_day: day,
-			birthday_time: year + '年' + month + '月' + day + '日'
-		});
-		if (this.state.phone == null || this.state.phone === '') {
-			this.setState({
-				phone_bind_color: 'red',
-				phone_bind_type: 1,
-				phone: '未绑定'
-			});
-		} else {
-			this.setState({
-				phone_bind_color: 'rgba(113, 113, 113, 1)',
-				phone_bind_type: 2
-			});
-		}
-		if (this.state.wechat_nickName == null || this.state.wechat_nickName === '') {
-			this.setState({
-				wechat_bind_color: 'red',
-				wechat_nickName: '未绑定'
-			});
-		} else {
-			this.setState({
-				wechat_bind_color: 'rgba(113, 113, 113, 1)'
-			});
-		}
+		//获取用户信息
+		this.getUserInfo();
 		BackHandler.addEventListener('hardwareBackPress', this.onBackAndroid);
 	}
 	componentWillUnmount() {
 		BackHandler.removeEventListener('hardwareBackPress', this.onBackAndroid);
 	}
 
+	async getUserInfo() {
+		let userinfo = await global.storage
+			.load({
+				key: 'userInfo'
+			})
+			.then((result) => {
+				console.log('============PersonalInfo========================');
+				console.log(result.user.birthday);
+				console.log('============PersonalInfo========================');
+				var time = this.formaterDate(result.user.birthday);
+				this.setState({
+					schoolName:
+
+							result.user.school === '' ? '未设置' :
+							result.user.school,
+					provinceName:
+
+							result.user.province === '' ? '未设置' :
+							result.user.province,
+					citys:
+
+							result.user.city === '' ? '未设置' :
+							result.user.city,
+					phone: result.user.mobile,
+					wechat_nickName: result.user.wechat_nickName,
+					user_nickName: result.user.nickName,
+					birthday_time: time
+				});
+
+				if (this.state.phone == null || this.state.phone === '') {
+					this.setState({
+						phone_bind_color: 'red',
+						phone_bind_type: 1,
+						phone: '未绑定'
+					});
+				} else {
+					this.setState({
+						phone_bind_color: 'rgba(113, 113, 113, 1)',
+						phone_bind_type: 2
+					});
+				}
+				if (this.state.wechat_nickName == null || this.state.wechat_nickName === '') {
+					this.setState({
+						wechat_bind_color: 'red',
+						wechat_nickName: '未绑定'
+					});
+				} else {
+					this.setState({
+						wechat_bind_color: 'rgba(113, 113, 113, 1)'
+					});
+				}
+				return result;
+			})
+			.catch((err) => {
+				console.log('PersonalInfo:ERROR' + err.message);
+				return null;
+			});
+	}
+
 	onBackAndroid = () => {
 		if (this.state.show_bind_phone) {
 			this.setState({
@@ -723,12 +752,11 @@ export default class PersonalInfo extends BasePage {
 
 	getArraowImg(type) {
 		return (
-			<TouchableOpacity
+			<View
 				style={{
 					width: '100%',
 					height: '100%',
 					alignItems: 'center',
-
 					resizeMode: 'contain',
 					justifyContent: 'center'
 				}}
@@ -741,7 +769,7 @@ export default class PersonalInfo extends BasePage {
 						height: '30%'
 					}}
 				/>
-			</TouchableOpacity>
+			</View>
 		);
 	}
 
@@ -852,13 +880,9 @@ export default class PersonalInfo extends BasePage {
 	}
 
 	logout() {
-		const resetAction = StackActions.reset({
-			index: 0,
-			actions: [
-				NavigationActions.navigate({ routeName: 'Login' }) //要跳转到的页面名字
-			]
-		});
-		this.props.navigation.dispatch(resetAction);
+		//清空存储的用户信息
+		global.storage.remove({ key: 'userInfo' });
+		this.clearPageToNext('Login');
 	}
 
 	updateState(input_text, type) {
@@ -920,6 +944,28 @@ export default class PersonalInfo extends BasePage {
 			// ToastAndroid.show('修改失败', ToastAndroid.SHORT);
 		}
 	}
+
+	formaterDate(date) {
+		var date = new Date(date);
+		var Y = date.getFullYear() + '';
+		var M =
+			(
+				date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) :
+				date.getMonth() + 1) + '';
+
+		var D =
+			(
+				date.getDate() < 10 ? '0' + date.getDate() :
+				date.getDate()) + ' ';
+
+		//影响选择出生年月日了。
+		this.setState({
+			birthday_year: Y,
+			birthday_month: M,
+			birthday_day: D
+		});
+		return Y + '-' + M + '-' + D;
+	}
 }
 
 class BindPhoneSuccess extends BasePage {

+ 0 - 3
pages/Splash.js

@@ -37,9 +37,6 @@ export default class Splash extends BasePage {
 				key: 'userInfo'
 			})
 			.then((result) => {
-				console.log('====================================');
-				console.log(result);
-				console.log('====================================');
 				this.setState({
 					exist: true
 				});

+ 459 - 489
pages/components/BirthdayModal.js

@@ -6,522 +6,492 @@
  * @flow
  */
 
-import React, { Component } from "react";
+import React, { Component } from 'react';
 import {
-  Platform,
-  StyleSheet,
-  Text,
-  View,
-  Image,
-  TouchableOpacity,
-  ImageBackground,
-  TextInput,
-  Button,
-  StatusBar,
-  Modal,
-  ScrollView,
-  TouchableHighlight,
-  DeviceEventEmitter,
-  findNodeHandle,
-  UIManager
-} from "react-native";
+	Platform,
+	StyleSheet,
+	Text,
+	View,
+	Image,
+	TouchableOpacity,
+	ImageBackground,
+	TextInput,
+	Button,
+	StatusBar,
+	Modal,
+	ScrollView,
+	TouchableHighlight,
+	DeviceEventEmitter,
+	findNodeHandle,
+	UIManager
+} from 'react-native';
 
 type Props = {};
 export default class BirthdayModal extends Component<Props> {
-  state = {
-    text_height: -1,
-    modalVisible: false,
-    year_type: false, //true为闰年,false为平年
-    year_array_views: [],
-    year_array: [],
-    year_array_views_index: -1,
-    month_array_views: [],
-    month_array_views_indexs: -1,
-    month_array: [
-      "1",
-      "2",
-      "3",
-      "4",
-      "5",
-      "6",
-      "7",
-      "8",
-      "9",
-      "10",
-      "11",
-      "12"
-    ],
-    day_array: [
-      "1",
-      "2",
-      "3",
-      "4",
-      "5",
-      "6",
-      "7",
-      "8",
-      "9",
-      "10",
-      "11",
-      "12",
-      "13",
-      "14",
-      "15",
-      "16",
-      "17",
-      "18",
-      "19",
-      "20",
-      "21",
-      "22",
-      "23",
-      "24",
-      "25",
-      "26",
-      "27",
-      "28",
-      "29",
-      "30",
-      "31"
-    ],
-    day_array_views: [],
-    day_array_views_index: -1
-  };
+	state = {
+		text_height: -1,
+		modalVisible: false,
+		year_type: false, //true为闰年,false为平年
+		year_array_views: [],
+		year_array: [],
+		year_array_views_index: -1,
+		month_array_views: [],
+		month_array_views_indexs: -1,
+		month_array: [ '1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12' ],
+		day_array: [
+			'1',
+			'2',
+			'3',
+			'4',
+			'5',
+			'6',
+			'7',
+			'8',
+			'9',
+			'10',
+			'11',
+			'12',
+			'13',
+			'14',
+			'15',
+			'16',
+			'17',
+			'18',
+			'19',
+			'20',
+			'21',
+			'22',
+			'23',
+			'24',
+			'25',
+			'26',
+			'27',
+			'28',
+			'29',
+			'30',
+			'31'
+		],
+		day_array_views: [],
+		day_array_views_index: -1
+	};
 
-  render() {
-    return (
-      <Modal
-        animationType="slide"
-        transparent={true}
-        visible={this.state.modalVisible}
-        onRequestClose={() => {
-          this.setState({ modalVisible: false });
-        }}
-      >
-        <View
-          style={{
-            flex: 1,
-            flexDirection: "column"
-          }}
-        >
-          <TouchableOpacity
-            style={{
-              flex: 3.2,
-              backgroundColor: "rgba(0, 0, 0, 0.5)",
-              width: "100%"
-            }}
-            activeOpacity={1}
-            onPress={() =>
-              this.setState({
-                modalVisible: false
-              })
-            }
-          />
-          <View
-            style={{
-              flex: 2,
-              backgroundColor: "white",
-              flexDirection: "column",
-              justifyContent: "center",
-              alignItems: "center",
-              width: "100%"
-            }}
-          >
-            <View
-              style={{
-                flex: 1,
-                flexDirection: "row",
-                alignItems: "center",
-                justifyContent: "center"
-              }}
-            >
-              <TouchableOpacity
-                style={{
-                  flex: 1
-                }}
-                activeOpacity={1}
-                onPress={() => this.cancel()}
-              >
-                <View
-                  style={{
-                    flex: 1,
-                    alignItems: "center",
-                    justifyContent: "center"
-                  }}
-                >
-                  <Text
-                    style={{
-                      fontSize: 20,
-                      color: "rgba(59, 59, 59, 1)",
-                      textAlignVertical: "center"
-                    }}
-                  >
-                    取消
-                  </Text>
-                </View>
-              </TouchableOpacity>
-              <View style={{ flex: 3.5 }} />
-              <TouchableOpacity
-                style={{
-                  flex: 1
-                }}
-                activeOpacity={1}
-                onPress={() => this.commit()}
-              >
-                <View
-                  style={{
-                    flex: 1,
-                    alignItems: "center",
-                    justifyContent: "center"
-                  }}
-                >
-                  <Text
-                    style={{
-                      fontSize: 20,
-                      color: "rgba(59, 59, 59, 1)",
-                      textAlignVertical: "center"
-                    }}
-                  >
-                    完成
-                  </Text>
-                </View>
-              </TouchableOpacity>
-            </View>
-            <View
-              style={{
-                flex: 0.05,
-                width: "90%",
-                backgroundColor: "rgba(246, 247, 248, 1)"
-              }}
-            />
-            <View
-              style={{
-                flex: 5,
-                flexDirection: "row"
-              }}
-            >
-              <View
-                style={{
-                  flex: 1
-                }}
-              >
-                <ScrollView
-                  style={{
-                    flex: 1
-                  }}
-                  ref={view => (this.year_scroll = view)}
-                  onLayout={() => this.year_onlayout()}
-                  showsVerticalScrollIndicator={false}
-                >
-                  {this.create_year_item()}
-                </ScrollView>
-              </View>
-              <View
-                style={{
-                  flex: 1
-                }}
-              >
-                <ScrollView
-                  ref={view => (this.month_scroll = view)}
-                  onLayout={() => this.month_onlayout()}
-                  style={{
-                    flex: 1
-                  }}
-                  showsVerticalScrollIndicator={false}
-                >
-                  {this.create_month_item()}
-                </ScrollView>
-              </View>
-              <View
-                style={{
-                  flex: 1
-                }}
-              >
-                <ScrollView
-                  ref={view => (this.day_scroll = view)}
-                  onLayout={() => this.day__onlayout()}
-                  style={{
-                    flex: 1
-                  }}
-                  showsVerticalScrollIndicator={false}
-                >
-                  {this.create_day_item()}
-                </ScrollView>
-              </View>
-            </View>
-          </View>
-        </View>
-      </Modal>
-    );
-  }
+	render() {
+		return (
+			<Modal
+				animationType="slide"
+				transparent={true}
+				visible={this.state.modalVisible}
+				onRequestClose={() => {
+					this.setState({ modalVisible: false });
+				}}
+			>
+				<View
+					style={{
+						flex: 1,
+						flexDirection: 'column'
+					}}
+				>
+					<TouchableOpacity
+						style={{
+							flex: 3.2,
+							backgroundColor: 'rgba(0, 0, 0, 0.5)',
+							width: '100%'
+						}}
+						activeOpacity={1}
+						onPress={() =>
+							this.setState({
+								modalVisible: false
+							})}
+					/>
+					<View
+						style={{
+							flex: 2,
+							backgroundColor: 'white',
+							flexDirection: 'column',
+							justifyContent: 'center',
+							alignItems: 'center',
+							width: '100%'
+						}}
+					>
+						<View
+							style={{
+								flex: 1,
+								flexDirection: 'row',
+								alignItems: 'center',
+								justifyContent: 'center'
+							}}
+						>
+							<TouchableOpacity
+								style={{
+									flex: 1
+								}}
+								activeOpacity={1}
+								onPress={() => this.cancel()}
+							>
+								<View
+									style={{
+										flex: 1,
+										alignItems: 'center',
+										justifyContent: 'center'
+									}}
+								>
+									<Text
+										style={{
+											fontSize: 20,
+											color: 'rgba(59, 59, 59, 1)',
+											textAlignVertical: 'center'
+										}}
+									>
+										取消
+									</Text>
+								</View>
+							</TouchableOpacity>
+							<View style={{ flex: 3.5 }} />
+							<TouchableOpacity
+								style={{
+									flex: 1
+								}}
+								activeOpacity={1}
+								onPress={() => this.commit()}
+							>
+								<View
+									style={{
+										flex: 1,
+										alignItems: 'center',
+										justifyContent: 'center'
+									}}
+								>
+									<Text
+										style={{
+											fontSize: 20,
+											color: 'rgba(59, 59, 59, 1)',
+											textAlignVertical: 'center'
+										}}
+									>
+										完成
+									</Text>
+								</View>
+							</TouchableOpacity>
+						</View>
+						<View
+							style={{
+								flex: 0.05,
+								width: '90%',
+								backgroundColor: 'rgba(246, 247, 248, 1)'
+							}}
+						/>
+						<View
+							style={{
+								flex: 5,
+								flexDirection: 'row'
+							}}
+						>
+							<View
+								style={{
+									flex: 1
+								}}
+							>
+								<ScrollView
+									style={{
+										flex: 1
+									}}
+									ref={(view) => (this.year_scroll = view)}
+									onLayout={() => this.year_onlayout()}
+									showsVerticalScrollIndicator={false}
+								>
+									{this.create_year_item()}
+								</ScrollView>
+							</View>
+							<View
+								style={{
+									flex: 1
+								}}
+							>
+								<ScrollView
+									ref={(view) => (this.month_scroll = view)}
+									onLayout={() => this.month_onlayout()}
+									style={{
+										flex: 1
+									}}
+									showsVerticalScrollIndicator={false}
+								>
+									{this.create_month_item()}
+								</ScrollView>
+							</View>
+							<View
+								style={{
+									flex: 1
+								}}
+							>
+								<ScrollView
+									ref={(view) => (this.day_scroll = view)}
+									onLayout={() => this.day__onlayout()}
+									style={{
+										flex: 1
+									}}
+									showsVerticalScrollIndicator={false}
+								>
+									{this.create_day_item()}
+								</ScrollView>
+							</View>
+						</View>
+					</View>
+				</View>
+			</Modal>
+		);
+	}
 
-  componentWillMount() {
-    var date = new Date();
-    var year = parseInt(this.props.year);
-    if (this.state.year_array.length == 0) {
-      let position = 0;
-      for (
-        let index = parseInt(year - 50);
-        index < parseInt(year + 10);
-        index++
-      ) {
-        if (parseInt(year) == index) {
-          this.setState({
-            year_array_views_index: position
-          });
-        }
+	componentWillMount() {
+		var date = new Date();
+		var year = parseInt(this.props.year);
+		if (this.state.year_array.length == 0) {
+			let position = 0;
+			for (let index = parseInt(year - 50); index < parseInt(year + 10); index++) {
+				if (parseInt(year) == index) {
+					this.setState({
+						year_array_views_index: position
+					});
+				}
 
-        this.state.year_array.push(index);
-        position++;
-      }
-    }
-    console.log(parseInt(date.getDate()));
-    this.setState({
-      month_array_views_indexs: parseInt(this.props.month) - 1,
-      day_array_views_index: parseInt(this.props.day) - 1
-    });
+				this.state.year_array.push(index);
+				position++;
+			}
+		}
+		console.log(parseInt(date.getDate()));
+		this.setState({
+			month_array_views_indexs: parseInt(this.props.month),
+			day_array_views_index: parseInt(this.props.day)
+		});
 
-    // var hour = date.getHours().toString();
-    // var minute = date.getMinutes().toString();
-  }
+		// var hour = date.getHours().toString();
+		// var minute = date.getMinutes().toString();
+	}
 
-  year_onlayout() {
-    if (this.state.year_array_views_index != -1) {
-      this.year_scroll.scrollTo({
-        x: 0,
-        y: (this.state.text_height + 20) * this.state.year_array_views_index,
-        duration: 500
-      });
-    }
-  }
+	year_onlayout() {
+		if (this.state.year_array_views_index != -1) {
+			this.year_scroll.scrollTo({
+				x: 0,
+				y: (this.state.text_height + 20) * this.state.year_array_views_index,
+				duration: 500
+			});
+		}
+	}
 
-  month_onlayout() {
-    if (this.state.month_array_views_indexs != -1) {
-      this.month_scroll.scrollTo({
-        x: 0,
-        y: (this.state.text_height + 20) * this.state.month_array_views_indexs,
-        duration: 500
-      });
-    }
-  }
+	month_onlayout() {
+		if (this.state.month_array_views_indexs != -1) {
+			this.month_scroll.scrollTo({
+				x: 0,
+				y: (this.state.text_height + 20) * this.state.month_array_views_indexs,
+				duration: 500
+			});
+		}
+	}
 
-  day__onlayout() {
-    if (this.state.day_array_views_index != -1) {
-      this.day_scroll.scrollTo({
-        x: 0,
-        y: (this.state.text_height + 20) * this.state.day_array_views_index,
-        duration: 500
-      });
-    }
-  }
+	day__onlayout() {
+		if (this.state.day_array_views_index != -1) {
+			this.day_scroll.scrollTo({
+				x: 0,
+				y: (this.state.text_height + 20) * this.state.day_array_views_index,
+				duration: 500
+			});
+		}
+	}
 
-  create_year_item() {
-    this.state.year_array_views = [];
-    for (var i = 0; i < this.state.year_array.length; i++) {
-      let index = i;
-      let textstyle = null;
-      if (this.state.year_array_views_index == i) {
-        textstyle = styles.item_text_click;
-      } else {
-        textstyle = styles.item_text;
-      }
-      this.state.year_array_views.push(
-        <Text
-          style={textstyle}
-          key={i}
-          onPress={() => this.click_year_item(index)}
-          onLayout={event => this.text_onLayout(event)}
-        >
-          {this.state.year_array[i]}年
-        </Text>
-      );
-    }
-    return this.state.year_array_views;
-  }
+	create_year_item() {
+		this.state.year_array_views = [];
+		for (var i = 0; i < this.state.year_array.length; i++) {
+			let index = i;
+			let textstyle = null;
+			if (this.state.year_array_views_index == i) {
+				textstyle = styles.item_text_click;
+			} else {
+				textstyle = styles.item_text;
+			}
+			this.state.year_array_views.push(
+				<Text
+					style={textstyle}
+					key={i}
+					onPress={() => this.click_year_item(index)}
+					onLayout={(event) => this.text_onLayout(event)}
+				>
+					{this.state.year_array[i]}年
+				</Text>
+			);
+		}
+		return this.state.year_array_views;
+	}
 
-  click_year_item(index) {
-    this.setState({
-      year_array_views_index: index,
-      year_type: this.getRunYear(this.state.year_array[index])
-    });
-  }
+	click_year_item(index) {
+		this.setState({
+			year_array_views_index: index,
+			year_type: this.getRunYear(this.state.year_array[index])
+		});
+	}
 
-  create_month_item() {
-    this.state.month_array_views = [];
-    for (var i = 0; i < this.state.month_array.length; i++) {
-      let index = i;
-      let textstyle = null;
-      if (this.state.month_array_views_indexs == i) {
-        textstyle = styles.item_text_click;
-      } else {
-        textstyle = styles.item_text;
-      }
-      this.state.month_array_views.push(
-        <Text
-          style={textstyle}
-          key={i}
-          onPress={() => this.click_month_item(index)}
-        >
-          {this.state.month_array[i]}月
-        </Text>
-      );
-    }
-    return this.state.month_array_views;
-  }
+	create_month_item() {
+		this.state.month_array_views = [];
+		for (var i = 0; i < this.state.month_array.length; i++) {
+			let index = i;
+			let textstyle = null;
+			if (this.state.month_array_views_indexs == i) {
+				textstyle = styles.item_text_click;
+			} else {
+				textstyle = styles.item_text;
+			}
+			this.state.month_array_views.push(
+				<Text style={textstyle} key={i} onPress={() => this.click_month_item(index)}>
+					{this.state.month_array[i]}月
+				</Text>
+			);
+		}
+		return this.state.month_array_views;
+	}
 
-  click_month_item(index) {
-    this.setState({
-      month_array_views_indexs: index
-    });
-  }
+	click_month_item(index) {
+		this.setState({
+			month_array_views_indexs: index
+		});
+	}
 
-  create_day_item() {
-    this.state.day_array_views = [];
-    var forNum = 0;
-    //获取月份
-    var month_index = this.state.month_array_views_indexs;
-    switch (month_index + 1) {
-      case 1:
-      case 3:
-      case 5:
-      case 7:
-      case 8:
-      case 10:
-      case 12:
-        //31天
-        forNum = 31;
-        break;
-      case 4:
-      case 6:
-      case 9:
-      case 11:
-        //30天
-        forNum = 30;
-        break;
-      case 2:
-        //2月判断平年闰年
-        if (
-          this.getRunYear(
-            this.state.year_array[this.state.year_array_views_index]
-          )
-        ) {
-          //闰年2月29
-          forNum = 29;
-        } else {
-          //平年2月28
-          forNum = 28;
-        }
-        break;
-    }
+	create_day_item() {
+		this.state.day_array_views = [];
+		var forNum = 0;
+		//获取月份
+		var month_index = this.state.month_array_views_indexs;
+		switch (month_index + 1) {
+			case 1:
+			case 3:
+			case 5:
+			case 7:
+			case 8:
+			case 10:
+			case 12:
+				//31天
+				forNum = 31;
+				break;
+			case 4:
+			case 6:
+			case 9:
+			case 11:
+				//30天
+				forNum = 30;
+				break;
+			case 2:
+				//2月判断平年闰年
+				if (this.getRunYear(this.state.year_array[this.state.year_array_views_index])) {
+					//闰年2月29
+					forNum = 29;
+				} else {
+					//平年2月28
+					forNum = 28;
+				}
+				break;
+		}
 
-    for (var i = 0; i < forNum; i++) {
-      //console.log(i);
-      let index = i;
-      let textstyle = null;
-      if (this.state.day_array_views_index == i) {
-        textstyle = styles.item_text_click;
-      } else {
-        textstyle = styles.item_text;
-      }
-      this.state.day_array_views.push(
-        <Text
-          style={textstyle}
-          key={i}
-          onPress={() => this.click_day_item(index)}
-        >
-          {this.state.day_array[i]}日
-        </Text>
-      );
-    }
+		for (var i = 0; i < forNum; i++) {
+			//console.log(i);
+			let index = i;
+			let textstyle = null;
+			if (this.state.day_array_views_index == i) {
+				textstyle = styles.item_text_click;
+			} else {
+				textstyle = styles.item_text;
+			}
+			this.state.day_array_views.push(
+				<Text style={textstyle} key={i} onPress={() => this.click_day_item(index)}>
+					{this.state.day_array[i]}日
+				</Text>
+			);
+		}
 
-    return this.state.day_array_views;
-  }
-  click_day_item(index) {
-    this.setState({
-      day_array_views_index: index
-    });
-  }
+		return this.state.day_array_views;
+	}
+	click_day_item(index) {
+		this.setState({
+			day_array_views_index: index
+		});
+	}
 
-  text_onLayout = event => {
-    if (this.state.text_height == -1) {
-      this.setState({
-        text_height: event.nativeEvent.layout.height
-      });
-    } else {
-    }
-  };
+	text_onLayout = (event) => {
+		if (this.state.text_height == -1) {
+			this.setState({
+				text_height: event.nativeEvent.layout.height
+			});
+		} else {
+		}
+	};
 
-  commit() {
-    if (
-      this.state.year_array_views_index == -1 ||
-      this.state.month_array_views_indexs == -1 ||
-      this.state.day_array_views_index == -1
-    ) {
-      alert("请选择完整日期");
-    } else {
-      var year = this.state.year_array[this.state.year_array_views_index];
+	commit() {
+		if (
+			this.state.year_array_views_index == -1 ||
+			this.state.month_array_views_indexs == -1 ||
+			this.state.day_array_views_index == -1
+		) {
+			alert('请选择完整日期');
+		} else {
+			var year = this.state.year_array[this.state.year_array_views_index];
 
-      var month = this.state.month_array[this.state.month_array_views_indexs];
+			var month = this.state.month_array[this.state.month_array_views_indexs];
 
-      var day = this.state.day_array[this.state.day_array_views_index];
+			var day = this.state.day_array[this.state.day_array_views_index];
 
-      this.props.birthdaycommit(year, month, day);
-      this.setModalVisible(false);
-    }
-  }
+			this.props.birthdaycommit(year, month, day);
+			this.setModalVisible(false);
+		}
+	}
 
-  cancel() {
-    this.setModalVisible(false);
-    // alert(this.getmyDate());
-  }
+	cancel() {
+		this.setModalVisible(false);
+		// alert(this.getmyDate());
+	}
 
-  setModalVisible(visible) {
-    this.setState({
-      modalVisible: visible
-    });
-  }
-  getmyDate() {
-    var date = new Date();
-    var year = date.getFullYear().toString();
-    var month = (date.getMonth() + 1).toString();
-    var day = date.getDate().toString();
-    var hour = date.getHours().toString();
-    var minute = date.getMinutes().toString();
+	setModalVisible(visible) {
+		this.setState({
+			modalVisible: visible
+		});
+	}
+	getmyDate() {
+		var date = new Date();
+		var year = date.getFullYear().toString();
+		var month = (date.getMonth() + 1).toString();
+		var day = date.getDate().toString();
+		var hour = date.getHours().toString();
+		var minute = date.getMinutes().toString();
 
-    return year + "年" + month + "月" + day + "日" + " " + hour + ":" + minute;
-  }
+		return year + '年' + month + '月' + day + '日' + ' ' + hour + ':' + minute;
+	}
 
-  getRunYear(year) {
-    if ((year % 4 == 0 && year % 100 != 0) || year % 400 == 0) {
-      //闰年2月29
-      // console.log("闰年");
-      return true;
-    } else {
-      //平年2月28
-      // console.log("平年");
-      return false;
-    }
-  }
+	getRunYear(year) {
+		if ((year % 4 == 0 && year % 100 != 0) || year % 400 == 0) {
+			//闰年2月29
+			// console.log("闰年");
+			return true;
+		} else {
+			//平年2月28
+			// console.log("平年");
+			return false;
+		}
+	}
 }
 const styles = StyleSheet.create({
-  item_text: {
-    color: "rgba(77, 77, 77, 1)",
-    fontSize: 18,
-    justifyContent: "center",
-    alignItems: "center",
-    marginTop: 20,
-    width: "100%",
-    textAlignVertical: "center",
-    textAlign: "center"
-  },
-  item_text_click: {
-    color: "rgba(59, 149, 243, 1)",
-    fontSize: 18,
-    justifyContent: "center",
-    alignItems: "center",
-    marginTop: 20,
-    width: "100%",
-    textAlignVertical: "center",
-    textAlign: "center"
-  }
+	item_text: {
+		color: 'rgba(77, 77, 77, 1)',
+		fontSize: 18,
+		justifyContent: 'center',
+		alignItems: 'center',
+		marginTop: 20,
+		width: '100%',
+		textAlignVertical: 'center',
+		textAlign: 'center'
+	},
+	item_text_click: {
+		color: 'rgba(59, 149, 243, 1)',
+		fontSize: 18,
+		justifyContent: 'center',
+		alignItems: 'center',
+		marginTop: 20,
+		width: '100%',
+		textAlignVertical: 'center',
+		textAlign: 'center'
+	}
 });