React Native APP在执行多次数据提交后变卡



  • React Native APP在执行多次数据提交后变卡,扫描枪扫描数据后,数据载入很慢!

    submitForm()
    {
    let { status, user, token } = this.props;
    let data = {
    code: user.code,
    orderNo: this.state.pono
    }
    if (this.state.pono == '') {
    Alert.alert('错误!', '请扫描订单条码。', [{ text: 'OK', onPress: () => this.refs.textInput1.focus() }]);
    return;
    }
    this.setState({ submitLoading: true });
    that = this;
    HTTPPOST('/sm/execSSSM', data, token)
    .then((res) => {
    if (res.code == 1) {
    that.refs.toast.show('订单【' + that.state.pono + '】入库成功,继续下一个订单!');
    that.setState({ pono: '' });
    //that.setState({ pono_focused: true });
    that.refs.textInput1.focus();
    } else {
    Alert.alert('错误', res.msg);
    that.refs.textInput1.focus();
    }
    that.setState({ submitLoading: false });
    }).catch((error) => {
    Alert.alert('错误', error);
    that.refs.textInput1.focus();
    that.setState({ submitLoading: false });
    });
    }

    render()
    {
    return (
    <View style={styles.container}>
    <FormLabel containerStyle={{ alignSelf: 'flex-start' }}>采购订单号:</FormLabel>
    <View style={styles.textIconInput}>
    <FormInput ref="textInput1"
    type="text" value={this.state.pono}
    onChangeText={this.checkpono}
    onSubmitEditing={this.submitForm.bind(this)}
    autoFocus={this.state.pono_focused}
    style={styles.inputS}
    width={SCREEN_WIDTH - 70}
    keyboardType="email-address"
    />
    <Icon
    reverse
    name='md-qr-scanner'
    type='Ionicons'
    color='#333'
    size={24}
    style={{ width: 20, paddingTop: 10, paddingLeft: 0, marginLeft: 0, }}
    onPress={this.showCamera.bind(this)}
    />
    </View>
    < FormValidationMessage containerStyle={{ alignSelf: 'flex-start' }}>
    {this.state.pono_emessage}
    </FormValidationMessage>
    <View>
    <Button backgroundColor='#6495ed' activeOpacity={1}
    onPress={this.submitForm.bind(this)}
    loading={this.state.submitLoading}
    title='确认并入库' />
    </View>
    <Toast ref="toast" position="top" positionValue={170} opacity={0.6} />
    </View>
    );
    }