PersonalInfo.js 21 KB

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