PersonalInfo.js 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958
  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. BackHandler,
  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. show_bind_phone: false
  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. {/* <BindPhoneSuccess show={this.state.show_bind_phone} /> */}
  659. </View>
  660. );
  661. }
  662. componentWillMount() {
  663. var date = new Date();
  664. var year = date.getFullYear().toString();
  665. var month = (date.getMonth() + 1).toString();
  666. var day = date.getDate().toString();
  667. this.setState({
  668. birthday_year: year,
  669. birthday_month: month,
  670. birthday_day: day,
  671. birthday_time: year + '年' + month + '月' + day + '日'
  672. });
  673. if (this.state.phone == null || this.state.phone === '') {
  674. this.setState({
  675. phone_bind_color: 'red',
  676. phone_bind_type: 1,
  677. phone: '未绑定'
  678. });
  679. } else {
  680. this.setState({
  681. phone_bind_color: 'rgba(113, 113, 113, 1)',
  682. phone_bind_type: 2
  683. });
  684. }
  685. if (this.state.wechat_nickName == null || this.state.wechat_nickName === '') {
  686. this.setState({
  687. wechat_bind_color: 'red',
  688. wechat_nickName: '未绑定'
  689. });
  690. } else {
  691. this.setState({
  692. wechat_bind_color: 'rgba(113, 113, 113, 1)'
  693. });
  694. }
  695. BackHandler.addEventListener('hardwareBackPress', this.onBackAndroid);
  696. }
  697. componentWillUnmount() {
  698. BackHandler.removeEventListener('hardwareBackPress', this.onBackAndroid);
  699. }
  700. onBackAndroid = () => {
  701. if (this.state.show_bind_phone) {
  702. this.setState({
  703. show_bind_phone: false
  704. });
  705. } else {
  706. this.goBack();
  707. }
  708. return true;
  709. };
  710. getArraowImg(type) {
  711. return (
  712. <TouchableOpacity
  713. style={{
  714. width: '100%',
  715. height: '100%',
  716. alignItems: 'center',
  717. resizeMode: 'contain',
  718. justifyContent: 'center'
  719. }}
  720. //onPress={() => this.arrowpress(type)}
  721. >
  722. <Image
  723. source={require('./images/userInfo/arrow.png')}
  724. style={{
  725. width: '20%',
  726. height: '30%'
  727. }}
  728. />
  729. </TouchableOpacity>
  730. );
  731. }
  732. choseheadericon(type) {
  733. let headerpath;
  734. switch (type) {
  735. case 0:
  736. headerpath = require('./images/userInfo/headportrait.png');
  737. break;
  738. case 1:
  739. headerpath = require('./images/userInfo/nickname.png');
  740. break;
  741. case 2:
  742. headerpath = require('./images/userInfo/birthday.png');
  743. break;
  744. case 3:
  745. headerpath = require('./images/userInfo/location.png');
  746. break;
  747. case 4:
  748. headerpath = require('./images/userInfo/school.png');
  749. break;
  750. case 5:
  751. headerpath = require('./images/userInfo/grade.png');
  752. break;
  753. case 6:
  754. headerpath = require('./images/userInfo/phone.png');
  755. break;
  756. case 7:
  757. headerpath = require('./images/userInfo/wechat.png');
  758. break;
  759. }
  760. // alert(headerpath);
  761. return (
  762. <Image
  763. source={headerpath}
  764. style={{
  765. width: '60%',
  766. height: '60%',
  767. resizeMode: 'contain'
  768. }}
  769. />
  770. );
  771. }
  772. arrowpress(type) {
  773. switch (type) {
  774. case 0:
  775. this.chosephoto.setModalVisible(true);
  776. break;
  777. case 1:
  778. this.dialog.setInfo('修改昵称', '昵称');
  779. this.dialog.setModalVisible(true, 1);
  780. break;
  781. case 2:
  782. // alert("生日");
  783. this.birthdaymodal.setModalVisible(true);
  784. break;
  785. case 3:
  786. this.regionmodal.setModalVisible(true);
  787. break;
  788. case 4:
  789. this.dialog.setInfo('我的学校', '学校名称');
  790. this.dialog.setModalVisible(true, 2);
  791. break;
  792. case 5:
  793. this.gradeselectionModal.setModalVisible(true);
  794. break;
  795. //手机号
  796. case 6:
  797. this.props.navigation.navigate('PhoneBind', {
  798. type: this.state.phone_bind_type,
  799. bind_phone_back: this.bind_phone_back.bind(this)
  800. });
  801. break;
  802. //微信
  803. case 7:
  804. wechat.wechatLogin((result) => {
  805. console.log('openid:' + result['openid']);
  806. console.log('unionid:' + result['unionid']);
  807. console.log('nickname:' + result['nickname']);
  808. console.log('sex:' + result['sex']);
  809. console.log('avatar:' + result['province'] + result['city']);
  810. let opts = {
  811. method: 'PUT',
  812. body: {
  813. openId: result['openid'],
  814. unionId: result['unionid'],
  815. avatar: result['province'] + result['city'],
  816. sex: result['sex'],
  817. nickName: result['nickname']
  818. }
  819. };
  820. http_user.bind_wechat(opts).then((res) => {
  821. if (res.code == 200) {
  822. this.setState({
  823. wechat_nickName: res['nickname'],
  824. wechat_bind_color: 'rgba(113, 113, 113, 1)'
  825. });
  826. } else {
  827. ToastAndroid.show(res.message, ToastAndroid.SHORT);
  828. }
  829. });
  830. });
  831. break;
  832. }
  833. }
  834. logout() {
  835. const resetAction = StackActions.reset({
  836. index: 0,
  837. actions: [
  838. NavigationActions.navigate({ routeName: 'Login' }) //要跳转到的页面名字
  839. ]
  840. });
  841. this.props.navigation.dispatch(resetAction);
  842. }
  843. updateState(input_text, type) {
  844. if (type == 1) {
  845. this.setState({ nickName: input_text });
  846. this.updateUserInfo({ nickName: input_text });
  847. } else if (type == 2) {
  848. this.setState({ schoolName: input_text });
  849. this.updateUserInfo({ school: input_text });
  850. }
  851. }
  852. cityscommit(provinces_name, citys_name) {
  853. this.setState({
  854. provinceName: provinces_name,
  855. citys: citys_name
  856. });
  857. this.updateUserInfo({ province: provinces_name, city: citys_name });
  858. }
  859. commitGrade(text, index) {
  860. this.setState({
  861. grade_text: text,
  862. grade_index: index
  863. });
  864. this.updateUserInfo({ grade: index + 1 });
  865. }
  866. birthdaycommit(year, month, day) {
  867. this.setState({
  868. birthday_time: year + '年' + month + '月' + day + '日'
  869. });
  870. var date = new Date(year + '-' + month + '-' + day);
  871. this.updateUserInfo({ birthday: date });
  872. }
  873. photoback(photo_uri) {
  874. if (photo_uri == undefined || photo_uri === '' || photo_uri == null) {
  875. return;
  876. }
  877. this.setState({
  878. photo_uri: { uri: photo_uri }
  879. });
  880. }
  881. updateUserInfo(object) {
  882. let opts = {
  883. method: 'PUT', //请求方法
  884. body: object //请求体
  885. };
  886. http_user.update_UserInfo(opts).then((res) => {
  887. console.log(res);
  888. });
  889. }
  890. bind_phone_back(phone_num, result) {
  891. if (result == true) {
  892. ToastAndroid.show('修改成功', ToastAndroid.SHORT);
  893. this.setState({ phone: phone_num, phone_bind_result: result, show_bind_phone: true });
  894. } else {
  895. // ToastAndroid.show('修改失败', ToastAndroid.SHORT);
  896. }
  897. }
  898. }
  899. class BindPhoneSuccess extends BasePage {
  900. render() {
  901. if (this.props.show) {
  902. return (
  903. <View
  904. style={{
  905. position: 'absolute',
  906. width: '100%',
  907. height: '100%',
  908. backgroundColor: 'rgba(0, 0, 0, 0.5)'
  909. }}
  910. />
  911. );
  912. } else {
  913. return null;
  914. }
  915. }
  916. }
  917. const styles = StyleSheet.create({
  918. item: {
  919. flex: 1,
  920. width: '100%',
  921. flexDirection: 'row',
  922. backgroundColor: 'white',
  923. marginTop: 1,
  924. backgroundColor: 'red'
  925. },
  926. item_text: {
  927. flex: 3,
  928. textAlignVertical: 'center',
  929. color: 'black',
  930. fontSize: 16
  931. }
  932. });