PersonalInfo.js 16 KB

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