PersonalInfo.js 21 KB

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