change_sex.js 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. import React, {Component} from 'react';
  2. import {View, Text, TouchableOpacity, Image} from 'react-native';
  3. import {List, Radio, WhiteSpace} from '@ant-design/react-native';
  4. import {ShowToast} from '../../components/rootToast/root_toast';
  5. import {GetDataPost} from '../../data/encryption';
  6. import {RetrieveData} from '../../data/storage';
  7. import public_css from '../../source/css/public_css';
  8. const RadioItem = Radio.RadioItem;
  9. export default class change_sex extends Component {
  10. constructor(props) {
  11. super(props);
  12. this.state = {
  13. sex: this.props.route.params.data.state.sex,
  14. };
  15. }
  16. render() {
  17. return (
  18. <View style={public_css.body}>
  19. <View style={{flex: 1}}>
  20. <List>
  21. <RadioItem
  22. checked={this.state.sex === 'M'}
  23. onChange={event => {
  24. if (event.target.checked) {
  25. this.setState({sex: 'M'});
  26. }
  27. }}>
  28. </RadioItem>
  29. <RadioItem
  30. checked={this.state.sex === 'F'}
  31. onChange={event => {
  32. if (event.target.checked) {
  33. this.setState({sex: 'F'});
  34. }
  35. }}>
  36. </RadioItem>
  37. </List>
  38. </View>
  39. <View style={[public_css.bottomStaus]}>
  40. <TouchableOpacity
  41. style={[public_css.statusBtn, public_css.statusRBtn]}
  42. onPress={() => this.submitData()}>
  43. <Image
  44. source={require('../../source/img/productImg/confirm.png')}
  45. style={{width: 32, height: 32}}
  46. />
  47. <Text style={{color: '#fff'}}>确认</Text>
  48. </TouchableOpacity>
  49. </View>
  50. </View>
  51. );
  52. }
  53. //提交信息
  54. submitData = async () => {
  55. let account = await RetrieveData('account');
  56. let token = await RetrieveData('token');
  57. if (token && account) {
  58. account = account.substring(1, account.length - 1);
  59. token = token.substring(1, token.length - 1);
  60. const url = 'https://app.taxbk.cn:9443/auth/comm/user/personalInfo/save';
  61. let response = await GetDataPost(
  62. url,
  63. token,
  64. {
  65. mobile: account,
  66. sex: this.state.sex,
  67. reqChannel: 3,
  68. ip: '',
  69. },
  70. false,
  71. 1,
  72. );
  73. if (response) {
  74. if (response.code == 0) {
  75. ShowToast('修改成功!');
  76. await this.props.route.params.data.getUserInformation();
  77. this.props.navigation.goBack();
  78. }
  79. } else {
  80. ShowToast('服务器故障!');
  81. }
  82. }
  83. };
  84. }