change_address.js 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  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_nick_name extends Component {
  18. constructor(props) {
  19. super(props);
  20. this.state = {
  21. address: 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. placeholder="请输入地址信息"
  37. clearButtonMode="while-editing"
  38. secureTextEntry={false}
  39. autoFocus={true}
  40. value={this.state.address}
  41. onChangeText={(text) => {
  42. this.setState({
  43. address: text,
  44. });
  45. }}
  46. />
  47. </ScrollView>
  48. <WingBlank>
  49. <View style={[public_css.bottomStatus]}>
  50. <TouchableOpacity
  51. style={[public_css.statusBtn, public_css.statusRBtn]}
  52. onPress={() => this.submitData()}>
  53. <Image
  54. source={require('../../source/img/productImg/confirm.png')}
  55. style={{width: 32, height: 32}}
  56. />
  57. <Text style={{color: '#fff'}}>确认</Text>
  58. </TouchableOpacity>
  59. </View>
  60. </WingBlank>
  61. <WhiteSpace />
  62. </SafeAreaView>
  63. );
  64. }
  65. //提交信息
  66. submitData = async () => {
  67. let account = await RetrieveData('account');
  68. let token = await RetrieveData('token');
  69. if (token && account) {
  70. const url = '/auth/comm/user/personalInfo/save';
  71. let response = await RequestNetwork(
  72. url,
  73. token,
  74. {
  75. mobile: account,
  76. address: this.state.address,
  77. reqChannel: 3,
  78. ip: '',
  79. },
  80. false,
  81. 1,
  82. );
  83. if (response) {
  84. if (response.code === 0) {
  85. ToastShow(1, '编辑成功!');
  86. this.props.route.params.isRefresh();
  87. this.props.navigation.goBack();
  88. } else {
  89. ToastShow(1, '编辑失败!');
  90. }
  91. }
  92. }
  93. };
  94. }