PersonalInfo.js 31 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037
  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. StyleSheet,
  11. Text,
  12. View,
  13. Image,
  14. TouchableOpacity,
  15. ImageBackground,
  16. ToastAndroid,
  17. BackHandler,
  18. StatusBar,
  19. DeviceEventEmitter
  20. } from "react-native";
  21. import BasePage from "./BasePage";
  22. import CourseTitle from "../pages/components/CourseTitle";
  23. import ChosePhoto from "../pages/components/ChosePhoto";
  24. import RegionModal from "../pages/components/RegionModal";
  25. import BirthdayModal from "../pages/components/BirthdayModal";
  26. import GradeSelectionModal from "../pages/components/GradeSelectionModal";
  27. import PersonalInfoDialog from "../pages/components/PersonalInfoDialog";
  28. import http_user from "./services/user";
  29. import wechat from "./utils/wechat";
  30. import commonutil from "./utils/commonutil";
  31. type Props = {};
  32. export default class PersonalInfo extends BasePage {
  33. state = {
  34. ready: false,
  35. file_user_data: new Map(),
  36. user_nickName: "未设置",
  37. schoolName: "未设置",
  38. provinceName: "未设置",
  39. citys: "",
  40. grade_text: "七年级",
  41. grade_index: 6,
  42. birthday_year: 0,
  43. birthday_month: 0,
  44. birthday_day: 0,
  45. birthday_time: 0,
  46. photo_uri: require("./images/userInfo/default_photo.png"),
  47. phone: "",
  48. phone_bind_result: false,
  49. phone_bind_type: 1, //1是绑定,2是修改
  50. phone_bind_color: "red",
  51. wechat_nickName: "",
  52. wechat_bind_color: "red",
  53. show_bind_phone: false
  54. };
  55. render() {
  56. if (!this.state.ready) {
  57. return null;
  58. }
  59. return (
  60. <View style={{ backgroundColor: "#F0F1F5", flex: 1 }}>
  61. <View style={{ width: "100%", height: this.getWindowHeight() }}>
  62. <PersonalInfoDialog
  63. ref={view => (this.dialog = view)}
  64. updateParentState={this.updateState.bind(this)}
  65. />
  66. <ChosePhoto
  67. ref={view => (this.chosephoto = view)}
  68. photoback={this.photoback.bind(this)}
  69. />
  70. <RegionModal
  71. ref={view => (this.regionmodal = view)}
  72. cityscommit={this.cityscommit.bind(this)}
  73. provinceName={this.state.provinceName}
  74. citys={this.state.citys}
  75. />
  76. <GradeSelectionModal
  77. ref={view => (this.gradeselectionModal = view)}
  78. commitGrade={this.commitGrade.bind(this)}
  79. grade_index={this.state.grade_index}
  80. />
  81. <BirthdayModal
  82. ref={view => (this.birthdaymodal = view)}
  83. birthdaycommit={this.birthdaycommit.bind(this)}
  84. year={this.state.birthday_year}
  85. month={this.state.birthday_month}
  86. day={this.state.birthday_day}
  87. />
  88. <StatusBar backgroundColor={"transparent"} translucent={true} />
  89. <View
  90. style={{
  91. flex: 1,
  92. flexDirection: "column"
  93. }}
  94. >
  95. <ImageBackground
  96. source={require("./images/userInfo/top.png")}
  97. style={{
  98. flex: 3,
  99. width: "100%",
  100. backgroundColor: "#F0F1F5",
  101. height: "75%"
  102. }}
  103. imageStyle={{ resizeMode: "cover" }}
  104. >
  105. <View
  106. style={{
  107. flex: 1,
  108. alignItems: "center",
  109. justifyContent: "center",
  110. flexDirection: "column"
  111. }}
  112. >
  113. <CourseTitle
  114. style={{ flex: 5 }}
  115. width={this.getWindowWidth()}
  116. title="个人信息"
  117. lefttype={2}
  118. righttype={0}
  119. textcolor={"white"}
  120. backPress={this.personinfoback.bind(this)}
  121. />
  122. <TouchableOpacity
  123. style={{
  124. flex: 1.3,
  125. backgroundColor: "white",
  126. width: "90%",
  127. bottom: 0,
  128. alignItems: "center",
  129. justifyContent: "flex-end",
  130. bottom: -30,
  131. borderRadius: 10,
  132. overflow: "hidden"
  133. }}
  134. activeOpacity={1}
  135. onPress={() => this.arrowpress(0)}
  136. >
  137. <View
  138. style={{
  139. flex: 1,
  140. borderRadius: 20,
  141. overflow: "hidden",
  142. alignItems: "center",
  143. justifyContent: "center",
  144. flexDirection: "row"
  145. }}
  146. >
  147. <View style={{ flex: 0.5 }} />
  148. <View
  149. style={{
  150. flex: 3,
  151. height: "100%",
  152. alignItems: "center",
  153. justifyContent: "center"
  154. }}
  155. >
  156. <Image
  157. style={{
  158. borderRadius: 50,
  159. width: "80%",
  160. height: "70%"
  161. // borderWidth: 3
  162. // borderColor: "red"
  163. }}
  164. source={this.state.photo_uri}
  165. />
  166. </View>
  167. <View
  168. style={{
  169. flex: 9,
  170. backgroundColor: "white",
  171. height: "100%",
  172. justifyContent: "center"
  173. }}
  174. >
  175. <Text style={{ left: 10, color: "black", fontSize: 16 }}>
  176. 修改头像
  177. </Text>
  178. </View>
  179. <View
  180. style={{
  181. flex: 1.5,
  182. height: "65%",
  183. alignItems: "center",
  184. justifyContent: "center"
  185. }}
  186. >
  187. {this.getArraowImg(0)}
  188. </View>
  189. </View>
  190. </TouchableOpacity>
  191. <View style={{ flex: 0.5 }} />
  192. </View>
  193. </ImageBackground>
  194. <View style={{ flex: 0.2 }} />
  195. <View
  196. style={{
  197. width: "100%",
  198. flex: 3.3,
  199. alignItems: "center",
  200. backgroundColor: "#F0F1F5"
  201. }}
  202. >
  203. <View
  204. style={{
  205. backgroundColor: "rgb(242, 242, 242)",
  206. width: "90%",
  207. alignItems: "center",
  208. justifyContent: "center",
  209. height: "100%",
  210. overflow: "hidden",
  211. borderRadius: 10
  212. }}
  213. >
  214. <View
  215. style={{
  216. width: "100%",
  217. alignItems: "center",
  218. justifyContent: "center",
  219. height: "100%"
  220. }}
  221. >
  222. <TouchableOpacity
  223. style={{
  224. flex: 1,
  225. marginVertical: 1,
  226. width: "100%",
  227. flexDirection: "row",
  228. backgroundColor: "white"
  229. }}
  230. activeOpacity={1}
  231. onPress={() => this.arrowpress(1)}
  232. >
  233. <View
  234. style={{
  235. flex: 2,
  236. alignItems: "center",
  237. justifyContent: "center"
  238. }}
  239. >
  240. {this.choseheadericon(1)}
  241. </View>
  242. <Text style={styles.item_text}>昵称</Text>
  243. <View
  244. style={{
  245. flex: 5,
  246. alignItems: "flex-end"
  247. }}
  248. >
  249. <Text
  250. style={{
  251. flex: 1,
  252. fontSize: 15,
  253. textAlignVertical: "center"
  254. }}
  255. numberOfLines={1}
  256. ellipsizeMode={"tail"}
  257. >
  258. {this.state.user_nickName}
  259. </Text>
  260. </View>
  261. <View
  262. style={{
  263. flex: 1.1,
  264. alignItems: "center",
  265. justifyContent: "center"
  266. }}
  267. >
  268. {this.getArraowImg(1)}
  269. </View>
  270. </TouchableOpacity>
  271. <TouchableOpacity
  272. style={{
  273. flex: 1,
  274. width: "100%",
  275. flexDirection: "row",
  276. backgroundColor: "white",
  277. marginVertical: 1
  278. }}
  279. activeOpacity={1}
  280. onPress={() => this.arrowpress(2)}
  281. >
  282. <View
  283. style={{
  284. flex: 2,
  285. alignItems: "center",
  286. justifyContent: "center"
  287. }}
  288. >
  289. {this.choseheadericon(2)}
  290. </View>
  291. <Text style={styles.item_text}>生日</Text>
  292. <View
  293. style={{
  294. flex: 5,
  295. alignItems: "flex-end"
  296. }}
  297. >
  298. <Text
  299. style={{
  300. flex: 1,
  301. fontSize: 15,
  302. textAlignVertical: "center"
  303. }}
  304. numberOfLines={1}
  305. ellipsizeMode={"tail"}
  306. >
  307. {this.state.birthday_time}
  308. </Text>
  309. </View>
  310. <View
  311. style={{
  312. flex: 1.1,
  313. alignItems: "center",
  314. justifyContent: "center"
  315. }}
  316. >
  317. {this.getArraowImg(2)}
  318. </View>
  319. </TouchableOpacity>
  320. <TouchableOpacity
  321. style={{
  322. flex: 1,
  323. width: "100%",
  324. flexDirection: "row",
  325. backgroundColor: "white",
  326. marginVertical: 1
  327. }}
  328. activeOpacity={1}
  329. onPress={() => this.arrowpress(3)}
  330. >
  331. <View
  332. style={{
  333. flex: 2,
  334. alignItems: "center",
  335. justifyContent: "center"
  336. }}
  337. >
  338. {this.choseheadericon(3)}
  339. </View>
  340. <Text style={styles.item_text}>所在地区</Text>
  341. <View
  342. style={{
  343. flex: 5,
  344. alignItems: "flex-end"
  345. }}
  346. >
  347. <Text
  348. style={{
  349. flex: 1,
  350. fontSize: 15,
  351. textAlignVertical: "center"
  352. }}
  353. numberOfLines={1}
  354. ellipsizeMode={"tail"}
  355. >
  356. {this.state.provinceName}-{this.state.citys}
  357. </Text>
  358. </View>
  359. <View
  360. style={{
  361. flex: 1.1,
  362. alignItems: "center",
  363. justifyContent: "center"
  364. }}
  365. >
  366. {this.getArraowImg(3)}
  367. </View>
  368. </TouchableOpacity>
  369. <TouchableOpacity
  370. style={{
  371. flex: 1,
  372. width: "100%",
  373. flexDirection: "row",
  374. backgroundColor: "white",
  375. marginVertical: 1
  376. }}
  377. activeOpacity={1}
  378. onPress={() => this.arrowpress(4)}
  379. >
  380. <View
  381. style={{
  382. flex: 2,
  383. alignItems: "center",
  384. justifyContent: "center"
  385. }}
  386. >
  387. {this.choseheadericon(4)}
  388. </View>
  389. <Text style={styles.item_text}>我的学校</Text>
  390. <View
  391. style={{
  392. flex: 5,
  393. alignItems: "flex-end"
  394. }}
  395. >
  396. <Text
  397. style={{
  398. flex: 1,
  399. fontSize: 15,
  400. textAlignVertical: "center"
  401. }}
  402. numberOfLines={1}
  403. ellipsizeMode={"tail"}
  404. >
  405. {this.state.schoolName}
  406. </Text>
  407. </View>
  408. <View
  409. style={{
  410. flex: 1.1,
  411. alignItems: "center",
  412. justifyContent: "center"
  413. }}
  414. >
  415. {this.getArraowImg(4)}
  416. </View>
  417. </TouchableOpacity>
  418. {/* <TouchableOpacity
  419. style={{
  420. flex: 1,
  421. marginTop: 1,
  422. width: '100%',
  423. flexDirection: 'row',
  424. backgroundColor: 'white',
  425. marginVertical: 1
  426. }}
  427. activeOpacity={1}
  428. onPress={() => this.arrowpress(5)}
  429. >
  430. <View
  431. style={{
  432. flex: 2,
  433. alignItems: 'center',
  434. justifyContent: 'center'
  435. }}
  436. >
  437. {this.choseheadericon(5)}
  438. </View>
  439. <Text style={styles.item_text}>我的年级</Text>
  440. <View
  441. style={{
  442. flex: 5,
  443. alignItems: 'flex-end'
  444. }}
  445. >
  446. <Text
  447. style={{
  448. flex: 1.1,
  449. fontSize: 15,
  450. textAlignVertical: 'center'
  451. }}
  452. numberOfLines={1}
  453. ellipsizeMode={'tail'}
  454. >
  455. {this.state.grade_text}
  456. </Text>
  457. </View>
  458. <View
  459. style={{
  460. flex: 1.1,
  461. alignItems: 'center',
  462. justifyContent: 'center'
  463. }}
  464. >
  465. {this.getArraowImg(5)}
  466. </View>
  467. </TouchableOpacity> */}
  468. </View>
  469. </View>
  470. </View>
  471. <View style={{ flex: 0.3, backgroundColor: "#F0F1F5" }} />
  472. <View
  473. style={{
  474. flex: 1.5,
  475. backgroundColor: "#F0F1F5",
  476. alignItems: "center",
  477. justifyContent: "center"
  478. }}
  479. >
  480. <View
  481. style={{
  482. width: "90%",
  483. alignItems: "center",
  484. justifyContent: "center",
  485. height: "100%",
  486. overflow: "hidden",
  487. borderRadius: 10
  488. }}
  489. >
  490. <TouchableOpacity
  491. style={{
  492. flex: 1,
  493. width: "100%",
  494. flexDirection: "row",
  495. backgroundColor: "white",
  496. marginVertical: 1
  497. }}
  498. activeOpacity={1}
  499. onPress={() => this.arrowpress(6)}
  500. >
  501. <View
  502. style={{
  503. flex: 2,
  504. alignItems: "center",
  505. justifyContent: "center"
  506. }}
  507. >
  508. {this.choseheadericon(6)}
  509. </View>
  510. <Text style={styles.item_text}>我的手机号</Text>
  511. <View
  512. style={{
  513. flex: 5,
  514. alignItems: "flex-end"
  515. }}
  516. >
  517. <Text
  518. style={{
  519. flex: 1,
  520. fontSize: 15,
  521. textAlignVertical: "center",
  522. color: this.state.phone_bind_color
  523. }}
  524. numberOfLines={1}
  525. ellipsizeMode={"tail"}
  526. >
  527. {this.state.phone}
  528. </Text>
  529. </View>
  530. <View
  531. style={{
  532. flex: 1.1,
  533. alignItems: "center",
  534. justifyContent: "center"
  535. }}
  536. >
  537. {this.getArraowImg(6)}
  538. </View>
  539. </TouchableOpacity>
  540. <TouchableOpacity
  541. style={{
  542. flex: 1,
  543. width: "100%",
  544. flexDirection: "row",
  545. backgroundColor: "white",
  546. marginVertical: 1
  547. }}
  548. activeOpacity={1}
  549. onPress={() => this.arrowpress(7)}
  550. >
  551. <View
  552. style={{
  553. flex: 2,
  554. alignItems: "center",
  555. justifyContent: "center"
  556. }}
  557. >
  558. {this.choseheadericon(7)}
  559. </View>
  560. <Text style={styles.item_text}>我的微信</Text>
  561. <View
  562. style={{
  563. flex: 5,
  564. alignItems: "flex-end"
  565. }}
  566. >
  567. <Text
  568. style={{
  569. flex: 1,
  570. fontSize: 15,
  571. textAlignVertical: "center",
  572. color: this.state.wechat_bind_color
  573. }}
  574. numberOfLines={1}
  575. ellipsizeMode={"tail"}
  576. >
  577. {this.state.wechat_nickName}
  578. </Text>
  579. </View>
  580. <View
  581. style={{
  582. flex: 1.1,
  583. alignItems: "center",
  584. justifyContent: "center"
  585. }}
  586. >
  587. {this.getArraowImg(4)}
  588. </View>
  589. </TouchableOpacity>
  590. </View>
  591. </View>
  592. <View
  593. style={{
  594. width: "100%",
  595. flex: 2.7,
  596. backgroundColor: "#F0F1F5",
  597. flexDirection: "column"
  598. }}
  599. >
  600. <View
  601. style={{
  602. flex: 1,
  603. flexDirection: "row",
  604. alignItems: "center",
  605. justifyContent: "center"
  606. }}
  607. >
  608. <View
  609. style={{
  610. alignItems: "center",
  611. width: "100%",
  612. height: "100%",
  613. backgroundColor: "#F0F1F5",
  614. justifyContent: "center"
  615. }}
  616. >
  617. <View
  618. style={{
  619. flex: 3
  620. }}
  621. />
  622. <TouchableOpacity
  623. activeOpacity={1}
  624. style={{
  625. flex: 2,
  626. width: "100%",
  627. alignItems: "center",
  628. justifyContent: "center",
  629. height: "100%"
  630. }}
  631. onPress={() => this.logout()}
  632. >
  633. <ImageBackground
  634. source={require("./images/userInfo/logoutbg1.png")}
  635. style={{
  636. flex: 1,
  637. width: "100%",
  638. alignItems: "center",
  639. justifyContent: "center",
  640. height: "100%"
  641. }}
  642. imageStyle={{ resizeMode: "contain" }}
  643. >
  644. <Text
  645. style={{
  646. fontSize: 22,
  647. color: "white",
  648. width: "100%",
  649. textAlign: "center"
  650. }}
  651. >
  652. 退出登录
  653. </Text>
  654. </ImageBackground>
  655. </TouchableOpacity>
  656. <View
  657. style={{
  658. flex: 1.5
  659. }}
  660. />
  661. </View>
  662. </View>
  663. </View>
  664. </View>
  665. </View>
  666. {/* <BindPhoneSuccess show={this.state.show_bind_phone} /> */}
  667. </View>
  668. );
  669. }
  670. componentWillMount() {
  671. //获取用户信息
  672. this.getUserInfo();
  673. BackHandler.addEventListener("hardwareBackPress", this.onBackAndroid);
  674. }
  675. componentWillUnmount() {
  676. BackHandler.removeEventListener("hardwareBackPress", this.onBackAndroid);
  677. }
  678. async getUserInfo() {
  679. let userinfo = await global.storage
  680. .load({
  681. key: "userInfo"
  682. })
  683. .then(result => {
  684. this.state.file_user_data = commonutil.jsonToMap(result);
  685. var time = this.formaterDate(this.state.file_user_data.get("birthday"));
  686. this.setState({
  687. schoolName:
  688. this.state.file_user_data.get("school") === ""
  689. ? "未设置"
  690. : this.state.file_user_data.get("school"),
  691. provinceName:
  692. this.state.file_user_data.get("province") === ""
  693. ? "未设置"
  694. : this.state.file_user_data.get("province"),
  695. citys:
  696. this.state.file_user_data.get("city") === ""
  697. ? "未设置"
  698. : this.state.file_user_data.get("city"),
  699. phone: this.state.file_user_data.get("mobile"),
  700. wechat_nickName: this.state.file_user_data.get("wechat_nickName"),
  701. user_nickName: this.state.file_user_data.get("nickName"),
  702. birthday_time: time
  703. });
  704. if (this.state.phone == null || this.state.phone === "") {
  705. this.setState({
  706. phone_bind_color: "red",
  707. phone_bind_type: 1,
  708. phone: "未绑定"
  709. });
  710. } else {
  711. this.setState({
  712. phone_bind_color: "rgba(113, 113, 113, 1)",
  713. phone_bind_type: 2
  714. });
  715. }
  716. if (
  717. this.state.wechat_nickName == null ||
  718. this.state.wechat_nickName === ""
  719. ) {
  720. this.setState({
  721. wechat_bind_color: "red",
  722. wechat_nickName: "未绑定"
  723. });
  724. } else {
  725. this.setState({
  726. wechat_bind_color: "rgba(113, 113, 113, 1)"
  727. });
  728. }
  729. this.setState({
  730. ready: true
  731. });
  732. })
  733. .catch(err => {
  734. console.log("PersonalInfo:ERROR" + err.message);
  735. });
  736. }
  737. onBackAndroid = () => {
  738. if (this.state.show_bind_phone) {
  739. this.setState({
  740. show_bind_phone: false
  741. });
  742. } else {
  743. this.goBack();
  744. }
  745. return true;
  746. };
  747. getArraowImg(type) {
  748. return (
  749. <View
  750. style={{
  751. width: "100%",
  752. height: "100%",
  753. alignItems: "center",
  754. resizeMode: "contain",
  755. justifyContent: "center"
  756. }}
  757. //onPress={() => this.arrowpress(type)}
  758. >
  759. <Image
  760. source={require("./images/userInfo/arrow.png")}
  761. style={{
  762. width: "20%",
  763. height: "30%"
  764. }}
  765. />
  766. </View>
  767. );
  768. }
  769. choseheadericon(type) {
  770. let headerpath;
  771. switch (type) {
  772. case 0:
  773. headerpath = require("./images/userInfo/headportrait.png");
  774. break;
  775. case 1:
  776. headerpath = require("./images/userInfo/nickname.png");
  777. break;
  778. case 2:
  779. headerpath = require("./images/userInfo/birthday.png");
  780. break;
  781. case 3:
  782. headerpath = require("./images/userInfo/location.png");
  783. break;
  784. case 4:
  785. headerpath = require("./images/userInfo/school.png");
  786. break;
  787. case 5:
  788. headerpath = require("./images/userInfo/grade.png");
  789. break;
  790. case 6:
  791. headerpath = require("./images/userInfo/phone.png");
  792. break;
  793. case 7:
  794. headerpath = require("./images/userInfo/wechat.png");
  795. break;
  796. }
  797. // alert(headerpath);
  798. return (
  799. <Image
  800. source={headerpath}
  801. style={{
  802. width: "60%",
  803. height: "60%",
  804. resizeMode: "contain"
  805. }}
  806. />
  807. );
  808. }
  809. arrowpress(type) {
  810. switch (type) {
  811. case 0:
  812. this.chosephoto.setModalVisible(true);
  813. break;
  814. case 1:
  815. this.dialog.setInfo("修改昵称", "昵称");
  816. this.dialog.setModalVisible(true, 1);
  817. break;
  818. case 2:
  819. // alert("生日");
  820. this.birthdaymodal.setModalVisible(true);
  821. break;
  822. case 3:
  823. this.regionmodal.setModalVisible(true);
  824. break;
  825. case 4:
  826. this.dialog.setInfo("我的学校", "学校名称");
  827. this.dialog.setModalVisible(true, 2);
  828. break;
  829. case 5:
  830. this.gradeselectionModal.setModalVisible(true);
  831. break;
  832. //手机号
  833. case 6:
  834. this.props.navigation.navigate("PhoneBind", {
  835. type: this.state.phone_bind_type,
  836. bind_phone_back: this.bind_phone_back.bind(this)
  837. });
  838. break;
  839. //微信
  840. case 7:
  841. wechat.wechatLogin(result => {
  842. console.log("openid:" + result["openid"]);
  843. console.log("unionid:" + result["unionid"]);
  844. console.log("nickname:" + result["nickname"]);
  845. console.log("sex:" + result["sex"]);
  846. console.log("avatar:" + result["province"] + result["city"]);
  847. let opts = {
  848. method: "PUT",
  849. body: {
  850. openId: result["openid"],
  851. unionId: result["unionid"],
  852. avatar: result["province"] + result["city"],
  853. sex: result["sex"],
  854. nickName: result["nickname"]
  855. }
  856. };
  857. http_user.bind_wechat(opts).then(res => {
  858. if (res.code == 200) {
  859. this.setState({
  860. wechat_nickName: res["nickname"],
  861. wechat_bind_color: "rgba(113, 113, 113, 1)"
  862. });
  863. } else {
  864. ToastAndroid.show(res.message, ToastAndroid.SHORT);
  865. }
  866. });
  867. });
  868. break;
  869. }
  870. }
  871. logout() {
  872. //清空存储的用户信息
  873. global.storage.remove({ key: "userInfo" });
  874. this.clearPageToNext("Login");
  875. }
  876. updateState(input_text, type) {
  877. if (type == 1) {
  878. this.setState({ user_nickName: input_text });
  879. this.updateUserInfo({ nickName: input_text });
  880. } else if (type == 2) {
  881. this.setState({ schoolName: input_text });
  882. this.updateUserInfo({ school: input_text });
  883. }
  884. }
  885. cityscommit(provinces_name, citys_name) {
  886. this.setState({
  887. provinceName: provinces_name,
  888. citys: citys_name
  889. });
  890. this.updateUserInfo({ province: provinces_name, city: citys_name });
  891. }
  892. commitGrade(text, index) {
  893. this.setState({
  894. grade_text: text,
  895. grade_index: index
  896. });
  897. this.updateUserInfo({ grade: index + 1 });
  898. }
  899. birthdaycommit(year, month, day) {
  900. this.setState({
  901. birthday_time: year + "年" + month + "月" + day + "日"
  902. });
  903. var date = new Date(year + "-" + month + "-" + day);
  904. this.updateUserInfo({ birthday: date });
  905. }
  906. photoback(photo_uri) {
  907. if (photo_uri == undefined || photo_uri === "" || photo_uri == null) {
  908. return;
  909. }
  910. this.setState({
  911. photo_uri: { uri: photo_uri }
  912. });
  913. }
  914. updateUserInfo(object) {
  915. let opts = {
  916. method: "PUT", //请求方法
  917. body: object //请求体
  918. };
  919. http_user.update_UserInfo(opts).then(res => {
  920. this.state.file_user_data.set("ageGroup", res.data.ageGroup);
  921. this.state.file_user_data.set("avatar", res.data.avatar);
  922. this.state.file_user_data.set("birthday", res.data.birthday);
  923. this.state.file_user_data.set("channel", res.data.channel);
  924. this.state.file_user_data.set("city", res.data.city);
  925. this.state.file_user_data.set("country", res.data.country);
  926. this.state.file_user_data.set("eid", res.data.eid);
  927. this.state.file_user_data.set("gmtCreated", res.data.gmtCreated);
  928. this.state.file_user_data.set("gmtModified", res.data.gmtModified);
  929. this.state.file_user_data.set("mobile", res.data.mobile);
  930. this.state.file_user_data.set("nickName", res.data.nickName);
  931. this.state.file_user_data.set("province", res.data.province);
  932. this.state.file_user_data.set("school", res.data.school);
  933. this.state.file_user_data.set("sex", res.data.sex);
  934. this.state.file_user_data.set("status", res.data.status);
  935. this.state.file_user_data.set("uid", res.data.uid);
  936. this.saveUserInfo(commonutil.mapToJson(this.state.file_user_data));
  937. });
  938. }
  939. bind_phone_back(phone_num, result) {
  940. if (result == true) {
  941. ToastAndroid.show("修改成功", ToastAndroid.SHORT);
  942. this.setState({
  943. phone: phone_num,
  944. phone_bind_result: result,
  945. show_bind_phone: true
  946. });
  947. } else {
  948. // ToastAndroid.show('修改失败', ToastAndroid.SHORT);
  949. }
  950. }
  951. personinfoback() {
  952. // this.props.navigation.state.params.infoback();
  953. DeviceEventEmitter.emit('infoback')
  954. this.props.navigation.goBack();
  955. }
  956. formaterDate(date) {
  957. var date = new Date(date);
  958. var Y = date.getFullYear() + "";
  959. var M =
  960. (date.getMonth() + 1 < 10
  961. ? "0" + (date.getMonth() + 1)
  962. : date.getMonth() + 1) + "";
  963. var D = (date.getDate() < 10 ? "0" + date.getDate() : date.getDate()) + " ";
  964. //影响选择出生年月日了。
  965. this.setState({
  966. birthday_year: Y,
  967. birthday_month: M,
  968. birthday_day: D
  969. });
  970. return Y + "-" + M + "-" + D;
  971. }
  972. }
  973. class BindPhoneSuccess extends BasePage {
  974. render() {
  975. if (this.props.show) {
  976. return (
  977. <View
  978. style={{
  979. position: "absolute",
  980. width: "100%",
  981. height: "100%",
  982. backgroundColor: "rgba(0, 0, 0, 0.5)"
  983. }}
  984. />
  985. );
  986. } else {
  987. return null;
  988. }
  989. }
  990. }
  991. const styles = StyleSheet.create({
  992. item: {
  993. flex: 1,
  994. width: "100%",
  995. flexDirection: "row",
  996. backgroundColor: "white",
  997. marginTop: 1,
  998. backgroundColor: "red"
  999. },
  1000. item_text: {
  1001. flex: 3,
  1002. textAlignVertical: "center",
  1003. color: "black",
  1004. fontSize: 16
  1005. }
  1006. });