PersonalInfo.js 18 KB

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