change_company.js 2.5 KB

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