PersonalInfo.js 22 KB

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