Няма описание

MineViewController.js 28KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953
  1. /**
  2. * Created by zack on 2018/4/20.
  3. */
  4. import {
  5. View,
  6. Text,
  7. StyleSheet,
  8. Image,
  9. TouchableOpacity,
  10. FlatList,
  11. Modal,
  12. Animated,
  13. TextInput,
  14. Platform,
  15. Keyboard,
  16. Picker,
  17. DatePickerAndroid,
  18. DatePickerIOS,
  19. } from 'react-native'
  20. import React, {Component} from 'react'
  21. import {NavigationBarHeight, TabBarHeight, ScreenDimensions} from '../../utils/DimensionsTools'
  22. import HttpTools from '../../network/HttpTools'
  23. import {auth, getUserProfile, userProfile, userEmailCode, userSmsCode, userEmail,
  24. userMobile} from '../../network/API'
  25. import MineHeaderImageItem from './View/MineHeaderImageItem'
  26. import MineTextItem from './View/MineTextItem'
  27. import {GlobalUserStorageTool, UserStorageKey} from '../../utils/GlobalUserStorageTool'
  28. import ChinaRegionWheelPicker from 'rn-wheel-picker-china-region'
  29. import ToastMsg from '../../utils/ToastMsg'
  30. export default class MineViewController extends Component {
  31. constructor(props) {
  32. super(props)
  33. this.state = {
  34. avatar: props.UserInfo.avatar,
  35. nickName: props.UserInfo.nickname,
  36. gender: props.UserInfo.gender,
  37. birthday: props.UserInfo.birthday,
  38. introduction: '',
  39. address: '',
  40. email: '',
  41. phone: '',
  42. oldPhone: '',
  43. phoneCode: '',
  44. verificationCode: '',
  45. password: '',
  46. newPassword: '',
  47. isNickNameModalVisible: false,
  48. isIntroductionModalVisible: false,
  49. isUpdatePhoneModalVisible: false,
  50. isUpdateEmailModalVisible: false,
  51. isUpdatePasswordModalVisible: false,
  52. isDatePickerModalVisible: false,
  53. isGenderModalVisible: false,
  54. isPickerVisible: false
  55. }
  56. this.nickNameModalMarginTop = new Animated.Value((ScreenDimensions.height - 137))
  57. this.introductionModalMarginTop = new Animated.Value((ScreenDimensions.height - 175))
  58. this.updatePhoneModalMarginTop = new Animated.Value((ScreenDimensions.height - 166))
  59. this.updateEmailModalMarginTop = new Animated.Value((ScreenDimensions.height - 166))
  60. this.updatePasswordModalMarginTop = new Animated.Value((ScreenDimensions.height - 228))
  61. this.oldGender = '0'
  62. this.oldBirthday = ''
  63. }
  64. componentDidMount() {
  65. GlobalUserStorageTool.load(UserStorageKey.UserInfo, (ret) => {
  66. if (ret) {
  67. global.token = ret.token
  68. this.getUserProfile()
  69. }
  70. })
  71. // GlobalUserStorageTool.load(UserStorageKey.AccountAndPassword, (ret) => {
  72. // if (ret) {
  73. // this.setState({password: ret.password})
  74. // }
  75. // })
  76. if (Platform.OS === 'ios') {//keyboardDidShow
  77. this.keyboardWillShowSub = Keyboard.addListener('keyboardWillShow', this.keyboardWillShow.bind(this));
  78. this.keyboardWillHideSub = Keyboard.addListener('keyboardWillHide', this.keyboardWillHide.bind(this));
  79. }else {
  80. this.keyboardWillShowSub = Keyboard.addListener('keyboardDidShow', this.keyboardWillShow.bind(this));
  81. this.keyboardWillHideSub = Keyboard.addListener('keyboardDidHide', this.keyboardWillHide.bind(this));
  82. }
  83. }
  84. componentWillUnMount() {
  85. if (this.keyboardWillShowSub && this.keyboardWillHideSub) {
  86. this.keyboardWillShowSub.remove();
  87. this.keyboardWillHideSub.remove();
  88. }
  89. }
  90. getUserProfile() {
  91. const param = {
  92. }
  93. HttpTools.get(getUserProfile, param, (response) => {
  94. if (response) {
  95. this.setState({
  96. avatar: response.avatar,
  97. birthday: response.birthday,
  98. //email: response.email,
  99. gender: response.gender,
  100. introduction: response.introduction && response.introduction.length > 0 ? response.introduction : this.state.introduction,
  101. nickName: response.nickname,
  102. oldPhone: response.phone,
  103. phoneCode: response.phone_code,
  104. address: response.reside
  105. })
  106. this.oldGender = response.gender
  107. }
  108. }, (error) => {
  109. console.log(error)
  110. })
  111. }
  112. getVerificationCode(account) {
  113. this.setState({verificationCode: ''})
  114. let param
  115. let url = ''
  116. if (account.indexOf('@') !== -1) {
  117. url = userEmailCode
  118. param = JSON.stringify({
  119. email: account,
  120. purpose: "change_email"
  121. })
  122. }else {
  123. url = userSmsCode
  124. param = JSON.stringify({
  125. phone: account,
  126. phone_code: this.state.phoneCode,
  127. purpose: "change_phone"
  128. })
  129. }
  130. HttpTools.post(url, param, (response) => {
  131. ToastMsg.show('验证码已发送到你的' + (url === userSmsCode ? '手机' : '邮箱'))
  132. }, (error) => {
  133. ToastMsg.show('获取验证码失败')
  134. })
  135. }
  136. updatePhone(newPhone, verificationCode) {
  137. const param = JSON.stringify({
  138. code: verificationCode,
  139. phone: newPhone,
  140. phone_code: this.state.phoneCode
  141. })
  142. HttpTools.put(userMobile, param, (response) => {
  143. Keyboard.dismiss()
  144. ToastMsg.show('更改手机号成功')
  145. }, (error) => {
  146. ToastMsg.show('更改手机号失败')
  147. })
  148. }
  149. updateEmail(newEmail, verificationCode) {
  150. const param = JSON.stringify({
  151. code: verificationCode,
  152. email: newEmail
  153. })
  154. HttpTools.put(userEmail, param, (response) => {
  155. Keyboard.dismiss()
  156. ToastMsg.show('更改邮箱成功')
  157. }, (error) => {
  158. ToastMsg.show('更改邮箱失败')
  159. })
  160. }
  161. updateProfile(key, value) {
  162. let param = null
  163. if (key === 'nickname') {
  164. param = JSON.stringify({
  165. nickname: value
  166. })
  167. }else if (key === 'gender') {
  168. param = JSON.stringify({
  169. gender: value,
  170. })
  171. }else if (key === 'birthday') {
  172. param = JSON.stringify({
  173. birthday: value,
  174. })
  175. }else if (key === 'introduction') {
  176. param = JSON.stringify({
  177. introduction: value,
  178. })
  179. }else if (key === 'reside') {
  180. param = JSON.stringify({
  181. reside: value,
  182. })
  183. }
  184. HttpTools.put(userProfile, param, (response)=> {
  185. console.log(response)
  186. }, (error) => {
  187. console.log(error)
  188. })
  189. }
  190. showAndroidDatePicker = async () => {
  191. try {
  192. const {action, year, month, day} = await DatePickerAndroid.open({
  193. date: (new Date())
  194. });
  195. if (action !== DatePickerAndroid.dismissedAction) {
  196. let date = new Date(year, month, day);
  197. let year = date.getFullYear()
  198. let month = date.getMonth() + 1
  199. let day = date.getDate()
  200. if (month <= 9) {
  201. month = '0' + month
  202. }
  203. if (day <= 9) {
  204. day = '0' + day
  205. }
  206. let birthday = year + '-' + month + '-' + day
  207. this.setState({birthday: birthday})
  208. this.updateProfile('birthday', birthday)
  209. }
  210. } catch ({code, message}) {
  211. console.warn('Cannot open date picker', message);
  212. }
  213. };
  214. didSelectedItem(key) {
  215. if (key === 0) {
  216. this.props.navigator.push({
  217. screen: 'UserCenterViewController',
  218. title: '',
  219. backButtonTitle: '',
  220. navigatorStyle: {
  221. navBarHidden: true
  222. },
  223. passProps: {
  224. }
  225. })
  226. } else if (key === 1) {
  227. this.setState({isNickNameModalVisible: true})
  228. }else if (key === 2) {
  229. this.setState({isGenderModalVisible: true})
  230. } else if (key === 3) {
  231. if (Platform.OS === 'ios') {
  232. this.setState({isDatePickerModalVisible: true})
  233. }else {
  234. let date = this.showAndroidDatePicker()
  235. }
  236. } else if (key === 4) {
  237. this.setState({isIntroductionModalVisible: true})
  238. }else if (key === 5) {
  239. this.setState({isPickerVisible: true})
  240. }else if (key === 7) {
  241. this.setState({isUpdatePasswordModalVisible: true})
  242. } else if (key === 8) {
  243. this.setState({isUpdatePhoneModalVisible: true})
  244. }else if (key === 9) {
  245. this.setState({isUpdateEmailModalVisible: true})
  246. }
  247. }
  248. keyboardWillShow(event) {
  249. if (this.state.isNickNameModalVisible) {
  250. Animated.timing(this.nickNameModalMarginTop,{duration: event.duration,toValue: (ScreenDimensions.height - 137 - event.endCoordinates.height)}).start()
  251. } else if (this.state.isIntroductionModalVisible) {
  252. Animated.timing(this.introductionModalMarginTop,{duration: event.duration,toValue: (ScreenDimensions.height - 175 - event.endCoordinates.height)}).start()
  253. } else if (this.state.isUpdatePhoneModalVisible) {
  254. Animated.timing(this.updatePhoneModalMarginTop,{duration: event.duration,toValue: (ScreenDimensions.height - 166 - event.endCoordinates.height)}).start()
  255. } else if (this.state.isUpdateEmailModalVisible) {
  256. Animated.timing(this.updateEmailModalMarginTop,{duration: event.duration,toValue: (ScreenDimensions.height - 166 - event.endCoordinates.height)}).start()
  257. }else if (this.state.isUpdatePasswordModalVisible) {
  258. Animated.timing(this.updatePasswordModalMarginTop,{duration: event.duration,toValue: (ScreenDimensions.height - 228 - event.endCoordinates.height)}).start()
  259. }
  260. }
  261. keyboardWillHide(event) {
  262. if (this.state.isNickNameModalVisible) {
  263. Animated.timing(this.nickNameModalMarginTop,{duration: Platform.OS === 'ios' ? event.duration : 300,toValue: (ScreenDimensions.height - 137)}).start(() => {
  264. this.setState({isNickNameModalVisible: false})
  265. })
  266. }else if (this.state.isIntroductionModalVisible){
  267. Animated.timing(this.nickNameModalMarginTop,{duration: Platform.OS === 'ios' ? event.duration : 300,toValue: (ScreenDimensions.height - 175)}).start(() => {
  268. this.setState({isIntroductionModalVisible: false})
  269. })
  270. } else if (this.state.isUpdatePhoneModalVisible) {
  271. Animated.timing(this.updatePhoneModalMarginTop,{duration: Platform.OS === 'ios' ? event.duration : 300,toValue: (ScreenDimensions.height - 166)}).start(() => {
  272. this.setState({isUpdatePhoneModalVisible: false})
  273. })
  274. } else if (this.state.isUpdateEmailModalVisible) {
  275. Animated.timing(this.updateEmailModalMarginTop,{duration: Platform.OS === 'ios' ? event.duration : 300,toValue: (ScreenDimensions.height - 166)}).start(() => {
  276. this.setState({isUpdateEmailModalVisible: false})
  277. })
  278. }else if (this.state.isUpdatePasswordModalVisible) {
  279. Animated.timing(this.updatePasswordModalMarginTop,{duration: Platform.OS === 'ios' ? event.duration : 300,toValue: (ScreenDimensions.height - 228)}).start(() => {
  280. this.setState({isUpdatePasswordModalVisible: false})
  281. })
  282. }
  283. }
  284. renderDatePicker() {
  285. if (Platform.OS === 'ios') {
  286. return(
  287. <DatePickerIOS
  288. date={new Date()}
  289. onDateChange={(date) => {
  290. let year = date.getFullYear()
  291. let month = date.getMonth() + 1
  292. let day = date.getDate()
  293. if (month <= 9) {
  294. month = '0' + month
  295. }
  296. if (day <= 9) {
  297. day = '0' + day
  298. }
  299. let birthday = year + '-' + month + '-' + day
  300. this.setState({birthday: birthday})
  301. }}
  302. mode={'date'}
  303. />
  304. )
  305. }
  306. }
  307. renderItem(item) {
  308. const key = item.key
  309. let desc = ''
  310. if (key === 0) {
  311. desc = this.state.avatar
  312. return(
  313. <MineHeaderImageItem
  314. didSelectedItem = {() => {
  315. this.didSelectedItem(0)
  316. }}
  317. avatar = {this.state.avatar}
  318. />
  319. )
  320. }else if (key === 1) {
  321. desc = this.state.nickName
  322. }else if (key === 2) {
  323. desc = this.state.gender
  324. }else if (key === 3) {
  325. desc = this.state.birthday
  326. }else if (key === 4) {
  327. desc = this.state.introduction
  328. }else if (key === 5) {
  329. desc = this.state.address
  330. }else if (key === 6) {
  331. return(
  332. <View style={{width: ScreenDimensions.width, height: 8, backgroundColor: '#efeff4'}}/>
  333. )
  334. }else{
  335. desc = '******'
  336. }
  337. return(
  338. <MineTextItem
  339. title = {item.title}
  340. desc = {desc}
  341. didSelectedItem = {() => {
  342. this.didSelectedItem(key)
  343. }}
  344. />
  345. )
  346. }
  347. render() {
  348. return (
  349. <View style={styles.View}>
  350. <View style={styles.ListView}>
  351. <FlatList
  352. data = {[{key: 0, title: ''},{key: 1, title: '昵称'},{key: 2, title: '性别'},{key: 3, title: '生日'},
  353. {key: 4, title: '个性签名'},{key: 5, title: '我的地址'},{key: 6, title: '修改密码'},{key: 7, title: '修改密码'},{key: 8, title: '修改手机'}, {key: 9, title: '修改邮箱'}]}
  354. renderItem={({item}) => this.renderItem(item)}
  355. keyExtractor = {(item,index) =>{
  356. return 'key' + item.key + index
  357. }}
  358. ListFooterComponent = {() => {
  359. return(
  360. <View style={{width: ScreenDimensions.width, height: 44, backgroundColor: 'white'}} />
  361. )
  362. }}
  363. />
  364. </View>
  365. <Modal
  366. animationType={"fade"}
  367. transparent={true}
  368. visible={this.state.isNickNameModalVisible}
  369. onRequestClose={() => {}}
  370. onShow={() => {
  371. }}
  372. >
  373. <View
  374. onPress={() => {
  375. this.setState({isNickNameModalVisible: false})
  376. }}
  377. activeOpacity= {1}
  378. style={{width: ScreenDimensions.width, height: ScreenDimensions.height, backgroundColor: 'rgba(0,0,0,0.15)',}}
  379. >
  380. <Animated.View style={[styles.NickNameModalBgView, {marginTop: this.introductionModalMarginTop}]}>
  381. <View style={styles.ModalHeaderView}>
  382. <TouchableOpacity onPress={() => {
  383. Keyboard.dismiss()
  384. }}>
  385. <Text style={styles.CancelText}>{'取消'}</Text>
  386. </TouchableOpacity>
  387. <Text style={styles.TitleText}>{'修改昵称'}</Text>
  388. <TouchableOpacity onPress={() => {
  389. this.setState({isNickNameModalVisible: false})
  390. this.updateProfile('nickname', this.state.nickName)
  391. }}>
  392. <Text style={styles.ConfirmText}>{'确定'}</Text>
  393. </TouchableOpacity>
  394. <View style={{position: 'absolute', width: ScreenDimensions.width, height: 0.5, backgroundColor: '#efeff4', left: 0, bottom: 0}} />
  395. </View>
  396. <TextInput multiline={false} onChangeText={(text) => {
  397. this.setState({nickName: text})
  398. }} keyboardType={'numeric'} defaultValue={this.state.phone} style={styles.TextInput}/>
  399. <View style={{ width: ScreenDimensions.width - 60, height: 0.5, backgroundColor: '#efeff4', marginLeft: 30}} />
  400. </Animated.View>
  401. </View>
  402. </Modal>
  403. <Modal
  404. animationType={"fade"}
  405. transparent={true}
  406. visible={this.state.isIntroductionModalVisible}
  407. onRequestClose={() => {}}
  408. onShow={() => {
  409. }}
  410. >
  411. <View
  412. activeOpacity= {1}
  413. style={{width: ScreenDimensions.width, height: ScreenDimensions.height, backgroundColor: 'rgba(0,0,0,0.15)',}}
  414. >
  415. <Animated.View style={[styles.introductionBgModalView, {marginTop: this.introductionModalMarginTop}]}>
  416. <View style={styles.ModalHeaderView}>
  417. <TouchableOpacity onPress={() => {
  418. Keyboard.dismiss()
  419. }}>
  420. <Text style={styles.CancelText}>{'取消'}</Text>
  421. </TouchableOpacity>
  422. <Text style={styles.TitleText}>{'个人简介'}</Text>
  423. <TouchableOpacity onPress={() => {
  424. this.setState({isIntroductionModalVisible: false})
  425. this.updateProfile('introduction', this.state.introduction)
  426. }}>
  427. <Text style={styles.ConfirmText}>{'确定'}</Text>
  428. </TouchableOpacity>
  429. <View style={{position: 'absolute', width: ScreenDimensions.width, height: 0.5, backgroundColor: '#efeff4', left: 0, bottom: 0}} />
  430. </View>
  431. <TextInput multiline={true} onChangeText={(text) => {
  432. this.setState({introduction: text})
  433. }} defaultValue={this.state.introduction} style={styles.introductionTextInput}/>
  434. <View style={{ width: ScreenDimensions.width - 60, height: 0.5, backgroundColor: '#efeff4', marginLeft: 30}} />
  435. <Text style={styles.NumberText}>{'30'}</Text>
  436. </Animated.View>
  437. </View>
  438. </Modal>
  439. <Modal
  440. animationType={"fade"}
  441. transparent={true}
  442. visible={this.state.isUpdatePhoneModalVisible}
  443. onRequestClose={() => {}}
  444. onShow={() => {
  445. }}
  446. >
  447. <View
  448. activeOpacity= {1}
  449. style={{width: ScreenDimensions.width, height: ScreenDimensions.height, backgroundColor: 'rgba(0,0,0,0.15)',}}
  450. >
  451. <Animated.View style={[styles.UpdatePhoneModalBgView, {marginTop: this.updatePhoneModalMarginTop}]}>
  452. <View style={styles.ModalHeaderView}>
  453. <TouchableOpacity onPress={() => {
  454. Keyboard.dismiss()
  455. }}>
  456. <Text style={styles.CancelText}>{'取消'}</Text>
  457. </TouchableOpacity>
  458. <Text style={styles.TitleText}>{'修改手机'}</Text>
  459. <TouchableOpacity onPress={() => {
  460. this.updatePhone(this.state.phone, this.state.verificationCode)
  461. }}>
  462. <Text style={styles.ConfirmText}>{'确定'}</Text>
  463. </TouchableOpacity>
  464. <View style={{position: 'absolute', width: ScreenDimensions.width, height: 0.5, backgroundColor: '#efeff4', left: 0, bottom: 0}} />
  465. </View>
  466. <TextInput placeholder={'请输入您的新手机号'} placeholderTextColor={'#b8bcbf'} multiline={false} onChangeText={(text) => {
  467. this.setState({phone: text})
  468. }} style={styles.UpdateTextInput}/>
  469. <View style={{ width: ScreenDimensions.width - 60, height: 0.5, backgroundColor: '#efeff4', marginLeft: 30}} />
  470. <View style={styles.VerifyTextInputBgView}>
  471. <View style={styles.VerifyTextInputContainerView}>
  472. <TextInput onChangeText={(text) => {
  473. this.setState({verificationCode: text})
  474. }} keyboardType={'phone-pad'} placeholder={'请输入验证码'} placeholderTextColor={'#b8bcbf'} style={styles.VerifyTextInput}/>
  475. <TouchableOpacity onPress={() => {
  476. if (!this.state.phone && !this.state.phone.length) {
  477. ToastMsg.show('请输入您的新手机号')
  478. return
  479. }
  480. if (this.state.oldPhone === this.state.phone) {
  481. ToastMsg.show('不需要更新相同的手机号')
  482. return
  483. }
  484. this.getVerificationCode(this.state.phone)
  485. }} style={styles.VerifyButtonBgView}>
  486. <View style={styles.VerifyLineView}/>
  487. <Text style={styles.VerifyButtonText}>{'获取验证码'}</Text>
  488. </TouchableOpacity>
  489. </View>
  490. <View style={styles.LineView}/>
  491. </View>
  492. </Animated.View>
  493. </View>
  494. </Modal>
  495. <Modal
  496. animationType={"fade"}
  497. transparent={true}
  498. visible={this.state.isUpdateEmailModalVisible}
  499. onRequestClose={() => {}}
  500. onShow={() => {
  501. }}
  502. >
  503. <View
  504. activeOpacity= {1}
  505. style={{width: ScreenDimensions.width, height: ScreenDimensions.height, backgroundColor: 'rgba(0,0,0,0.15)',}}
  506. >
  507. <Animated.View style={[styles.UpdatePhoneModalBgView, {marginTop: this.updateEmailModalMarginTop}]}>
  508. <View style={styles.ModalHeaderView}>
  509. <TouchableOpacity onPress={() => {
  510. Keyboard.dismiss()
  511. }}>
  512. <Text style={styles.CancelText}>{'取消'}</Text>
  513. </TouchableOpacity>
  514. <Text style={styles.TitleText}>{'修改邮箱'}</Text>
  515. <TouchableOpacity onPress={() => {
  516. this.updateEmail(this.state.email, this.state.verificationCode)
  517. }}>
  518. <Text style={styles.ConfirmText}>{'确定'}</Text>
  519. </TouchableOpacity>
  520. <View style={{position: 'absolute', width: ScreenDimensions.width, height: 0.5, backgroundColor: '#efeff4', left: 0, bottom: 0}} />
  521. </View>
  522. <TextInput placeholder={'请输入您的新邮箱'} placeholderTextColor={'#b8bcbf'} multiline={false} onChangeText={(text) => {
  523. this.setState({email: text})
  524. }} style={styles.UpdateTextInput}/>
  525. <View style={{ width: ScreenDimensions.width - 60, height: 0.5, backgroundColor: '#efeff4', marginLeft: 30}} />
  526. <View style={styles.VerifyTextInputBgView}>
  527. <View style={styles.VerifyTextInputContainerView}>
  528. <TextInput onChangeText={(text) => {
  529. this.setState({verificationCode: text})
  530. }} keyboardType={'phone-pad'} placeholder={'请输入验证码'} placeholderTextColor={'#b8bcbf'} style={styles.VerifyTextInput}/>
  531. <TouchableOpacity onPress={() => {
  532. if (!this.state.email || !this.state.email.length) { //还要正则判断邮箱格式
  533. ToastMsg.show('请输入您的邮箱')
  534. return
  535. }
  536. this.getVerificationCode(this.state.email)
  537. }} style={styles.VerifyButtonBgView}>
  538. <View style={styles.VerifyLineView}/>
  539. <Text style={styles.VerifyButtonText}>{'获取验证码'}</Text>
  540. </TouchableOpacity>
  541. </View>
  542. <View style={styles.LineView}/>
  543. </View>
  544. </Animated.View>
  545. </View>
  546. </Modal>
  547. <Modal
  548. animationType={"fade"}
  549. transparent={true}
  550. visible={this.state.isUpdatePasswordModalVisible}
  551. onRequestClose={() => {}}
  552. onShow={() => {
  553. }}
  554. >
  555. <View
  556. activeOpacity= {1}
  557. style={{width: ScreenDimensions.width, height: ScreenDimensions.height, backgroundColor: 'rgba(0,0,0,0.15)',}}
  558. >
  559. <Animated.View style={[styles.UpdatePasswordModalBgView, {marginTop: this.updatePasswordModalMarginTop}]}>
  560. <View style={styles.ModalHeaderView}>
  561. <TouchableOpacity onPress={() => {
  562. Keyboard.dismiss()
  563. }}>
  564. <Text style={styles.CancelText}>{'取消'}</Text>
  565. </TouchableOpacity>
  566. <Text style={styles.TitleText}>{'修改密码'}</Text>
  567. <TouchableOpacity onPress={() => {
  568. this.setState({isUpdatePasswordModalVisible: false})
  569. }}>
  570. <Text style={styles.ConfirmText}>{'确定'}</Text>
  571. </TouchableOpacity>
  572. <View style={{position: 'absolute', width: ScreenDimensions.width, height: 0.5, backgroundColor: '#efeff4', left: 0, bottom: 0}} />
  573. </View>
  574. <TextInput placeholder={'请输入您的密码'} placeholderTextColor={'#b8bcbf'} multiline={false} onChangeText={(text) => {
  575. this.setState({password: text})
  576. }} style={styles.UpdatePasswordTextInput}/>
  577. <View style={styles.VerifyTextInputBgView}>
  578. <View style={styles.VerifyTextInputContainerView}>
  579. <TextInput onChangeText={(text) => {
  580. this.setState({verificationCode: text})
  581. }} keyboardType={'phone-pad'} placeholder={'请输入验证码'} placeholderTextColor={'#b8bcbf'} style={styles.VerifyTextInput}/>
  582. <TouchableOpacity onPress={() => {
  583. this.getVerificationCode()
  584. }} style={styles.VerifyButtonBgView}>
  585. <View style={styles.VerifyLineView}/>
  586. <Text style={styles.VerifyButtonText}>{'获取验证码'}</Text>
  587. </TouchableOpacity>
  588. </View>
  589. <View style={styles.LineView}/>
  590. </View>
  591. <View style={{ width: ScreenDimensions.width - 60, height: 0.5, backgroundColor: '#efeff4', marginLeft: 30}} />
  592. <TextInput placeholder={'请输入您的新密码'} placeholderTextColor={'#b8bcbf'} multiline={false} onChangeText={(text) => {
  593. this.setState({newPassword: text})
  594. }} style={styles.UpdatePasswordTextInput}/>
  595. </Animated.View>
  596. </View>
  597. </Modal>
  598. <Modal
  599. animationType={"fade"}
  600. transparent={true}
  601. visible={this.state.isDatePickerModalVisible}
  602. onRequestClose={() => {}}
  603. onShow={() => {
  604. }}
  605. >
  606. <View
  607. activeOpacity= {1}
  608. style={{width: ScreenDimensions.width, height: ScreenDimensions.height, backgroundColor: 'rgba(0,0,0,0.15)',}}
  609. >
  610. <Animated.View style={[styles.UpdatePasswordModalBgView, {marginTop: this.updatePasswordModalMarginTop}]}>
  611. <View style={styles.ModalHeaderView}>
  612. <TouchableOpacity onPress={() => {
  613. this.setState({isDatePickerModalVisible: false, birthday: this.oldBirthday})
  614. }}>
  615. <Text style={styles.CancelText}>{'取消'}</Text>
  616. </TouchableOpacity>
  617. <Text style={styles.TitleText}>{'修改生日'}</Text>
  618. <TouchableOpacity onPress={() => {
  619. this.setState({isDatePickerModalVisible: false})
  620. this.oldBirthday = this.state.birthday
  621. this.updateProfile('birthday', this.state.birthday)
  622. }}>
  623. <Text style={styles.ConfirmText}>{'确定'}</Text>
  624. </TouchableOpacity>
  625. <View style={{position: 'absolute', width: ScreenDimensions.width, height: 0.5, backgroundColor: '#efeff4', left: 0, bottom: 0}} />
  626. </View>
  627. {this.renderDatePicker()}
  628. </Animated.View>
  629. </View>
  630. </Modal>
  631. <Modal
  632. animationType={"fade"}
  633. transparent={true}
  634. visible={this.state.isGenderModalVisible}
  635. onRequestClose={() => {}}
  636. onShow={() => {
  637. }}
  638. >
  639. <View
  640. activeOpacity= {1}
  641. style={{width: ScreenDimensions.width, height: ScreenDimensions.height, backgroundColor: 'rgba(0,0,0,0.15)',}}
  642. >
  643. <Animated.View style={[styles.GenderModalBgView, {marginTop: ScreenDimensions.height - 208}]}>
  644. <View style={styles.ModalHeaderView}>
  645. <TouchableOpacity onPress={() => {
  646. this.setState({isGenderModalVisible: false})
  647. this.setState({gender: this.oldGender})
  648. }}>
  649. <Text style={styles.CancelText}>{'取消'}</Text>
  650. </TouchableOpacity>
  651. <Text style={styles.TitleText}>{'修改性别'}</Text>
  652. <TouchableOpacity onPress={() => {
  653. this.setState({isGenderModalVisible: false})
  654. this.oldGender = this.state.gender
  655. this.updateProfile('gender', parseInt(this.state.gender))
  656. }}>
  657. <Text style={styles.ConfirmText}>{'确定'}</Text>
  658. </TouchableOpacity>
  659. <View style={{position: 'absolute', width: ScreenDimensions.width, height: 0.5, backgroundColor: '#efeff4', left: 0, bottom: 0}} />
  660. </View>
  661. <Picker
  662. selectedValue={this.state.gender}
  663. style={{ height: 208 - 44, width: ScreenDimensions.width }}
  664. onValueChange={(itemValue, itemIndex) => this.setState({gender: itemValue})}>
  665. <Picker.Item label="男" value= '1' />
  666. <Picker.Item label="女" value= '2' />
  667. <Picker.Item label="保密" value= '0' />
  668. </Picker>
  669. </Animated.View>
  670. </View>
  671. </Modal>
  672. <ChinaRegionWheelPicker
  673. isVisible={this.state.isPickerVisible}
  674. navBtnColor={'#e66a6a'}
  675. selectedProvince={'广东'}
  676. selectedCity={'深圳'}
  677. selectedArea={'福田区'}
  678. transparent
  679. animationType={'fade'}
  680. onSubmit={(param) => {
  681. const region = param.province + '-' + param.city + '-' + param.area
  682. this.setState({address: region})
  683. this.updateProfile('reside', region)
  684. }}
  685. onCancel={() => {
  686. this.setState({isPickerVisible: false})
  687. }} // 点击取消_onPressCancel
  688. androidPickerHeight={100} // 安卓手机下可以设置picker区域的高度
  689. />
  690. </View>
  691. );
  692. }
  693. }
  694. const styles = StyleSheet.create({
  695. View: {
  696. width: ScreenDimensions.width,
  697. height: ScreenDimensions.height,
  698. justifyContent: 'center',
  699. alignItems: 'center',
  700. backgroundColor: 'white'
  701. },
  702. ListView: {
  703. marginTop: NavigationBarHeight.height,
  704. width: ScreenDimensions.width,
  705. height: ScreenDimensions.height - NavigationBarHeight.height,
  706. backgroundColor: 'white'
  707. },
  708. NickNameModalBgView: {
  709. width: ScreenDimensions.width,
  710. height: 137,
  711. backgroundColor: 'white'
  712. },
  713. ModalHeaderView: {
  714. width: ScreenDimensions.width,
  715. height: 44,
  716. flexDirection: 'row',
  717. alignItems: 'center',
  718. justifyContent: 'space-between'
  719. },
  720. CancelText: {
  721. fontSize: 15,
  722. marginLeft: 15,
  723. color: '#e66a6a'
  724. },
  725. ConfirmText: {
  726. fontSize: 15,
  727. marginRight: 15,
  728. color: '#e66a6a'
  729. },
  730. TitleText: {
  731. fontSize: 16,
  732. color: '#333333'
  733. },
  734. TextInput: {
  735. width: ScreenDimensions.width - 60,
  736. height: 44,
  737. fontSize: 14,
  738. color: '#b8bcbf',
  739. textAlign: 'left',
  740. marginLeft: 30,
  741. marginTop: 10
  742. },
  743. introductionBgModalView: {
  744. width: ScreenDimensions.width,
  745. height: 175,
  746. backgroundColor: 'white',
  747. },
  748. introductionTextInput: {
  749. width: ScreenDimensions.width - 60,
  750. height: 130,
  751. fontSize: 14,
  752. color: '#b8bcbf',
  753. textAlign: 'left',
  754. marginLeft: 30,
  755. paddingTop: 15,
  756. paddingBottom: 15,
  757. textAlignVertical: 'top'
  758. },
  759. NumberText: {
  760. fontSize: 14,
  761. color: '#b8bcbf',
  762. position: 'absolute',
  763. bottom: 5,
  764. right: 5,
  765. },
  766. UpdatePhoneModalBgView: {
  767. width: ScreenDimensions.width,
  768. height: 175,
  769. backgroundColor: 'white',
  770. },
  771. UpdateTextInput: {
  772. width: ScreenDimensions.width - 60,
  773. height: 55,
  774. fontSize: 14,
  775. color: '#b8bcbf',
  776. textAlign: 'left',
  777. marginLeft: 30,
  778. },
  779. UpdatePasswordModalBgView: {
  780. width: ScreenDimensions.width,
  781. height: 228,
  782. backgroundColor: 'white',
  783. },
  784. UpdatePasswordTextInput: {
  785. width: ScreenDimensions.width - 60,
  786. height: 60,
  787. fontSize: 14,
  788. color: '#b8bcbf',
  789. textAlign: 'left',
  790. marginLeft: 30,
  791. },
  792. VerifyTextInputBgView: {
  793. width: ScreenDimensions.width - 60,
  794. height: 50,
  795. marginLeft: 30,
  796. },
  797. VerifyTextInputContainerView: {
  798. width: ScreenDimensions.width - 60,
  799. height: 60,
  800. flexDirection: 'row',
  801. alignItems: 'center',
  802. justifyContent: 'space-between'
  803. },
  804. VerifyTextInput: {
  805. width: ScreenDimensions.width - 60 - 100,
  806. textAlign: 'left',
  807. fontSize: 14,
  808. color: '#4A4A4A',
  809. height:60,
  810. },
  811. VerifyButtonBgView: {
  812. width: 100,
  813. flexDirection: 'row',
  814. alignItems: 'center',
  815. justifyContent: 'space-between',
  816. },
  817. VerifyButtonText: {
  818. fontSize: 14,
  819. color: '#5a9cd9',
  820. },
  821. VerifyLineView: {
  822. width: 1,
  823. height: 21,
  824. backgroundColor: 'rgba(80, 80, 80, 0.36)'
  825. },
  826. GenderModalBgView: {
  827. width: ScreenDimensions.width,
  828. height: 208,
  829. backgroundColor: 'white'
  830. },
  831. GenderItemBgView: {
  832. width: ScreenDimensions.width,
  833. height: 50,
  834. backgroundColor: 'white',
  835. justifyContent: 'center',
  836. alignItems: 'center'
  837. },
  838. })