PersonalInfo.js 18 KB

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