PersonalInfo.js 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666
  1. /**
  2. * Sample React Native App
  3. * https://github.com/facebook/react-native
  4. *
  5. * @format
  6. * @flow
  7. */
  8. import React, { Component } from "react";
  9. import {
  10. Platform,
  11. StyleSheet,
  12. Text,
  13. View,
  14. Image,
  15. TouchableOpacity,
  16. ImageBackground,
  17. Button,
  18. StatusBar,
  19. Modal,
  20. TouchableHighlight,
  21. DeviceEventEmitter
  22. } from "react-native";
  23. import AndroidUtil from "../../util/AndroidUtil";
  24. import BasePage from "../BasePage";
  25. import CourseTitle from "./CourseTitle";
  26. import ChosePhoto from "./ChosePhoto";
  27. import RegionModal from "./RegionModal";
  28. import BirthdayModal from "./BirthdayModal";
  29. import GradeSelectionModal from "./GradeSelectionModal";
  30. import Header from "./Header";
  31. import PersonalInfoDialog from "./PersonalInfoDialog";
  32. type Props = {};
  33. export default class PersonalInfo extends BasePage {
  34. state = {
  35. nickName: "初始昵称",
  36. schoolName: "未设置",
  37. cisys: "北京市",
  38. grade_text: "七年级",
  39. grade_index: 6,
  40. birthday_year: 0,
  41. birthday_month: 0,
  42. birthday_day: 0,
  43. birthday_time: 0
  44. };
  45. updateState(data) {
  46. this.setState(data);
  47. }
  48. render() {
  49. return (
  50. <View style={{backgroundColor: '#F0F1F5', flex : 1}}>
  51. <View style={{ width: "100%", height: this.getWindowHeight() }}>
  52. <PersonalInfoDialog
  53. ref={view => (this.dialog = view)}
  54. updateParentState={this.updateState.bind(this)}
  55. />
  56. <ChosePhoto ref={view => (this.chosephoto = view)} />
  57. <RegionModal
  58. ref={view => (this.regionmodal = view)}
  59. cityscommit={this.cityscommit.bind(this)}
  60. />
  61. <GradeSelectionModal
  62. ref={view => (this.gradeselectionModal = view)}
  63. commitGrade={this.commitGrade.bind(this)}
  64. grade_index={this.state.grade_index}
  65. />
  66. <BirthdayModal
  67. ref={view => (this.birthdaymodal = view)}
  68. birthdaycommit={this.birthdaycommit.bind(this)}
  69. year={this.state.birthday_year}
  70. month={this.state.birthday_month}
  71. day={this.state.birthday_day}
  72. />
  73. <StatusBar backgroundColor={"transparent"} translucent={true} />
  74. <View
  75. style={{
  76. flex: 1,
  77. flexDirection: "column"
  78. }}
  79. >
  80. <ImageBackground
  81. source={require("../images/userInfo/top.png")}
  82. style={{
  83. flex: 2.8,
  84. width: "100%",
  85. backgroundColor: "#F0F1F5",
  86. height: "75%"
  87. }}
  88. imageStyle={{ resizeMode: "cover" }}
  89. >
  90. <View
  91. style={{
  92. flex: 1,
  93. alignItems: "center",
  94. justifyContent: "center",
  95. flexDirection: "column"
  96. }}
  97. >
  98. <CourseTitle
  99. style={{ flex: 4 }}
  100. width={this.getWindowWidth()}
  101. title="个人信息"
  102. backPress={() => this.goBack()}
  103. lefttype={2}
  104. righttype={0}
  105. textcolor={"white"}
  106. backPress={() => this.goBack()}
  107. />
  108. <TouchableOpacity
  109. style={{
  110. flex: 1,
  111. backgroundColor: "white",
  112. width: "90%",
  113. bottom: 0,
  114. alignItems: "center",
  115. justifyContent: "center",
  116. borderRadius: 20,
  117. overflow: "hidden"
  118. }}
  119. activeOpacity={1}
  120. onPress={() => this.arrowpress(0)}
  121. >
  122. <View
  123. style={{
  124. flex: 1,
  125. borderRadius: 20,
  126. overflow: "hidden",
  127. alignItems: "center",
  128. justifyContent: "center",
  129. flexDirection: "row"
  130. }}
  131. >
  132. <View style={{ flex: 0.5 }} />
  133. <View
  134. style={{
  135. flex: 3,
  136. height: "100%",
  137. alignItems: "center",
  138. justifyContent: "center"
  139. }}
  140. >
  141. <Image
  142. style={{
  143. borderRadius: 50,
  144. width: "80%",
  145. height: "70%"
  146. // borderWidth: 3
  147. // borderColor: "red"
  148. }}
  149. source={{
  150. uri:
  151. "https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1556277324856&di=dc1548a0c5ba10481af922e174912937&imgtype=0&src=http%3A%2F%2Fwww.51pptmoban.com%2Fd%2Ffile%2F2012%2F05%2F12%2F82c4568a90055adcf8fbb896f0841c69.jpg"
  152. }}
  153. />
  154. </View>
  155. <View
  156. style={{
  157. flex: 9,
  158. backgroundColor: "white",
  159. height: "100%",
  160. justifyContent: "center"
  161. }}
  162. >
  163. <Text style={{ left: 10, color: "black", fontSize: 20 }}>
  164. 修改头像
  165. </Text>
  166. </View>
  167. <View
  168. style={{
  169. flex: 1.5,
  170. height: "65%",
  171. alignItems: "center",
  172. justifyContent: "center"
  173. }}
  174. >
  175. {this.getArraowImg(0)}
  176. </View>
  177. </View>
  178. </TouchableOpacity>
  179. </View>
  180. </ImageBackground>
  181. <View style={{ flex: 0.5, backgroundColor: "#F0F1F5" }} />
  182. <View
  183. style={{
  184. width: "100%",
  185. flex: 4.3,
  186. alignItems: "center",
  187. backgroundColor: "#F0F1F5"
  188. }}
  189. >
  190. <View
  191. style={{
  192. backgroundColor: "rgb(242, 242, 242)",
  193. width: "90%",
  194. alignItems: "center",
  195. justifyContent: "center",
  196. height: "100%",
  197. overflow: "hidden",
  198. borderRadius: 10
  199. }}
  200. >
  201. <View
  202. style={{
  203. width: "100%",
  204. alignItems: "center",
  205. justifyContent: "center",
  206. height: "100%"
  207. }}
  208. >
  209. <TouchableOpacity
  210. style={{
  211. flex: 1,
  212. marginVertical: 1,
  213. width: "100%",
  214. flexDirection: "row",
  215. backgroundColor: "white"
  216. }}
  217. activeOpacity={1}
  218. onPress={() => this.arrowpress(1)}
  219. >
  220. <View
  221. style={{
  222. flex: 2,
  223. alignItems: "center",
  224. justifyContent: "center"
  225. }}
  226. >
  227. {this.choseheadericon(1)}
  228. </View>
  229. <Text style={styles.item_text}>昵称</Text>
  230. <View
  231. style={{
  232. flex: 5,
  233. alignItems: "flex-end"
  234. }}
  235. >
  236. <Text
  237. style={{
  238. flex: 1,
  239. fontSize: 15,
  240. textAlignVertical: "center"
  241. }}
  242. numberOfLines={1}
  243. ellipsizeMode={"tail"}
  244. >
  245. {this.state.nickName}
  246. </Text>
  247. </View>
  248. <View
  249. style={{
  250. flex: 1.1,
  251. alignItems: "center",
  252. justifyContent: "center"
  253. }}
  254. >
  255. {this.getArraowImg(1)}
  256. </View>
  257. </TouchableOpacity>
  258. <TouchableOpacity
  259. style={{
  260. flex: 1,
  261. width: "100%",
  262. flexDirection: "row",
  263. backgroundColor: "white",
  264. marginVertical: 1
  265. }}
  266. activeOpacity={1}
  267. onPress={() => this.arrowpress(2)}
  268. >
  269. <View
  270. style={{
  271. flex: 2,
  272. alignItems: "center",
  273. justifyContent: "center"
  274. }}
  275. >
  276. {this.choseheadericon(2)}
  277. </View>
  278. <Text style={styles.item_text}>生日</Text>
  279. <View
  280. style={{
  281. flex: 5,
  282. alignItems: "flex-end"
  283. }}
  284. >
  285. <Text
  286. style={{
  287. flex: 1,
  288. fontSize: 15,
  289. textAlignVertical: "center"
  290. }}
  291. numberOfLines={1}
  292. ellipsizeMode={"tail"}
  293. >
  294. {this.state.birthday_time}
  295. </Text>
  296. </View>
  297. <View
  298. style={{
  299. flex: 1.1,
  300. alignItems: "center",
  301. justifyContent: "center"
  302. }}
  303. >
  304. {this.getArraowImg(2)}
  305. </View>
  306. </TouchableOpacity>
  307. <TouchableOpacity
  308. style={{
  309. flex: 1,
  310. width: "100%",
  311. flexDirection: "row",
  312. backgroundColor: "white",
  313. marginVertical: 1
  314. }}
  315. activeOpacity={1}
  316. onPress={() => this.arrowpress(3)}
  317. >
  318. <View
  319. style={{
  320. flex: 2,
  321. alignItems: "center",
  322. justifyContent: "center"
  323. }}
  324. >
  325. {this.choseheadericon(3)}
  326. </View>
  327. <Text style={styles.item_text}>所在地区</Text>
  328. <View
  329. style={{
  330. flex: 5,
  331. alignItems: "flex-end"
  332. }}
  333. >
  334. <Text
  335. style={{
  336. flex: 1,
  337. fontSize: 15,
  338. textAlignVertical: "center"
  339. }}
  340. numberOfLines={1}
  341. ellipsizeMode={"tail"}
  342. >
  343. {this.state.cisys}
  344. </Text>
  345. </View>
  346. <View
  347. style={{
  348. flex: 1.1,
  349. alignItems: "center",
  350. justifyContent: "center"
  351. }}
  352. >
  353. {this.getArraowImg(3)}
  354. </View>
  355. </TouchableOpacity>
  356. <TouchableOpacity
  357. style={{
  358. flex: 1,
  359. width: "100%",
  360. flexDirection: "row",
  361. backgroundColor: "white",
  362. marginVertical: 1
  363. }}
  364. activeOpacity={1}
  365. onPress={() => this.arrowpress(4)}
  366. >
  367. <View
  368. style={{
  369. flex: 2,
  370. alignItems: "center",
  371. justifyContent: "center"
  372. }}
  373. >
  374. {this.choseheadericon(4)}
  375. </View>
  376. <Text style={styles.item_text}>我的学校</Text>
  377. <View
  378. style={{
  379. flex: 5,
  380. alignItems: "flex-end"
  381. }}
  382. >
  383. <Text
  384. style={{
  385. flex: 1,
  386. fontSize: 15,
  387. textAlignVertical: "center"
  388. }}
  389. numberOfLines={1}
  390. ellipsizeMode={"tail"}
  391. >
  392. {this.state.schoolName}
  393. </Text>
  394. </View>
  395. <View
  396. style={{
  397. flex: 1.1,
  398. alignItems: "center",
  399. justifyContent: "center"
  400. }}
  401. >
  402. {this.getArraowImg(4)}
  403. </View>
  404. </TouchableOpacity>
  405. <TouchableOpacity
  406. style={{
  407. flex: 1,
  408. marginTop: 1,
  409. width: "100%",
  410. flexDirection: "row",
  411. backgroundColor: "white",
  412. marginVertical: 1
  413. }}
  414. activeOpacity={1}
  415. onPress={() => this.arrowpress(5)}
  416. >
  417. <View
  418. style={{
  419. flex: 2,
  420. alignItems: "center",
  421. justifyContent: "center"
  422. }}
  423. >
  424. {this.choseheadericon(5)}
  425. </View>
  426. <Text style={styles.item_text}>我的年级</Text>
  427. <View
  428. style={{
  429. flex: 5,
  430. alignItems: "flex-end"
  431. }}
  432. >
  433. <Text
  434. style={{
  435. flex: 1.1,
  436. fontSize: 15,
  437. textAlignVertical: "center"
  438. }}
  439. numberOfLines={1}
  440. ellipsizeMode={"tail"}
  441. >
  442. {this.state.grade_text}
  443. </Text>
  444. </View>
  445. <View
  446. style={{
  447. flex: 1.1,
  448. alignItems: "center",
  449. justifyContent: "center"
  450. }}
  451. >
  452. {this.getArraowImg(5)}
  453. </View>
  454. </TouchableOpacity>
  455. </View>
  456. </View>
  457. </View>
  458. <View
  459. style={{
  460. width: "100%",
  461. flex: 4,
  462. backgroundColor: "#F0F1F5",
  463. flexDirection: "column"
  464. }}
  465. >
  466. <View style={{ flex: 2.5 }} />
  467. <View style={{ flex: 2, flexDirection: "row" }}>
  468. <View style={{ flex: 1 }} />
  469. <View
  470. style={{
  471. flex: 7,
  472. width: "100%",
  473. height: "100%"
  474. }}
  475. >
  476. <TouchableOpacity
  477. activeOpacity={1}
  478. style={{
  479. flex: 2,
  480. width: "100%",
  481. alignItems: "center",
  482. justifyContent: "center",
  483. height: "100%"
  484. }}
  485. onPress={() => this.logout()}
  486. >
  487. <ImageBackground
  488. source={require("../images/userInfo/logoutbg1.png")}
  489. style={{
  490. flex: 1,
  491. width: "100%",
  492. alignItems: "center",
  493. justifyContent: "center",
  494. height: "100%"
  495. }}
  496. imageStyle={{ resizeMode: "contain" }}
  497. >
  498. <Text
  499. style={{
  500. fontSize: 30,
  501. color: "white",
  502. width: "100%",
  503. textAlign: "center"
  504. }}
  505. >
  506. 退出登录
  507. </Text>
  508. </ImageBackground>
  509. </TouchableOpacity>
  510. <View style={{ flex: 1 }} />
  511. </View>
  512. <View style={{ flex: 1 }} />
  513. </View>
  514. <View style={{ flex: 0.8 }} />
  515. </View>
  516. </View>
  517. </View>
  518. </View>
  519. );
  520. }
  521. componentWillMount() {
  522. var date = new Date();
  523. var year = date.getFullYear().toString();
  524. var month = (date.getMonth() + 1).toString();
  525. var day = date.getDate().toString();
  526. this.setState({
  527. birthday_year: year,
  528. birthday_month: month,
  529. birthday_day: day,
  530. birthday_time: year + "年" + month + "月" + day + "日"
  531. });
  532. }
  533. getArraowImg(type) {
  534. return (
  535. <TouchableOpacity
  536. style={{
  537. width: "100%",
  538. height: "100%",
  539. alignItems: "center",
  540. resizeMode: "contain",
  541. justifyContent: "center"
  542. }}
  543. onPress={() => this.arrowpress(type)}
  544. >
  545. <Image
  546. source={require("../images/userInfo/arrow.png")}
  547. style={{
  548. width: "20%",
  549. height: "30%"
  550. }}
  551. />
  552. </TouchableOpacity>
  553. );
  554. }
  555. choseheadericon(type) {
  556. let headerpath;
  557. switch (type) {
  558. case 0:
  559. headerpath = require("../images/userInfo/headportrait.png");
  560. break;
  561. case 1:
  562. headerpath = require("../images/userInfo/nickname.png");
  563. break;
  564. case 2:
  565. headerpath = require("../images/userInfo/birthday.png");
  566. break;
  567. case 3:
  568. headerpath = require("../images/userInfo/location.png");
  569. break;
  570. case 4:
  571. headerpath = require("../images/userInfo/school.png");
  572. break;
  573. case 5:
  574. headerpath = require("../images/userInfo/grade.png");
  575. break;
  576. }
  577. // alert(headerpath);
  578. return (
  579. <Image
  580. source={headerpath}
  581. style={{
  582. width: "60%",
  583. height: "60%",
  584. resizeMode: "contain"
  585. }}
  586. />
  587. );
  588. }
  589. arrowpress(type) {
  590. switch (type) {
  591. case 0:
  592. this.chosephoto.setModalVisible(true);
  593. break;
  594. case 1:
  595. this.dialog.setInfo("修改昵称", "昵称");
  596. this.dialog.setModalVisible(true, 1);
  597. break;
  598. case 2:
  599. // alert("生日");
  600. this.birthdaymodal.setModalVisible(true);
  601. break;
  602. case 3:
  603. this.regionmodal.setModalVisible(true);
  604. break;
  605. case 4:
  606. this.dialog.setInfo("我的学校", "学校名称");
  607. this.dialog.setModalVisible(true, 2);
  608. break;
  609. case 5:
  610. this.gradeselectionModal.setModalVisible(true);
  611. break;
  612. }
  613. }
  614. logout() {
  615. alert("点击退出了");
  616. }
  617. cityscommit(provinces_name, citys_name) {
  618. this.setState({
  619. cisys: provinces_name + "-" + citys_name
  620. });
  621. }
  622. commitGrade(text, index) {
  623. this.setState({
  624. grade_text: text,
  625. grade_index: index
  626. });
  627. }
  628. birthdaycommit(year, month, day) {
  629. this.setState({
  630. birthday_time: year + "年" + month + "月" + day + "日"
  631. });
  632. }
  633. }
  634. const styles = StyleSheet.create({
  635. item: {
  636. flex: 1,
  637. width: "100%",
  638. flexDirection: "row",
  639. backgroundColor: "white",
  640. marginTop: 1
  641. },
  642. item_text: {
  643. flex: 3,
  644. textAlignVertical: "center",
  645. color: "black",
  646. fontSize: 16
  647. }
  648. });