PersonalInfo.js 22 KB

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