change_company.js 2.5 KB

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