Commit c4a8963b by 姜雷

修改登录注册环节多次点击问题

parent bf7ee6c4
......@@ -133,7 +133,7 @@ class BarCode extends Component {
this.fetchOrder(res.data[0].id);
this.setState({ showPayOrder: true });
} else {
this.drawBarCode(false);
this.drawBarCode();
}
})
.catch(err => {
......
......@@ -66,7 +66,11 @@ class Login extends Component {
}
loginHandle(): void {
if (this.state.fetching) return;
if (this.validataLoginData()) {
this.setState({
fetching: true,
});
const { updateUserInfo, userinfo } = this.props;
const { account, pwd } = this.state;
console.log('in loginHandle');
......@@ -85,13 +89,23 @@ class Login extends Component {
})
.catch(err => {
console.log(err);
if (err.code && err.code === NotRegisterCode) {
updateUserInfo({
customerPhone: account,
});
setTimeout(() => {
this.setState({
fetching: false,
});
Taro.navigateTo({
url: '/pages/Register/Register',
});
}, 2000);
} else {
this.setState({
fetching: false,
});
}
});
}
......
......@@ -28,6 +28,7 @@ type PageDispatchProps = {
};
type PageState = {
fetching: boolean;
name: string;
cellphone: string;
vcode: string;
......@@ -64,6 +65,7 @@ class Register extends Component {
super(props);
const { customerPhone } = props.userinfo;
this.state = {
fetching: false,
name: '',
cellphone: customerPhone,
vcode: '',
......@@ -148,7 +150,11 @@ class Register extends Component {
}
getRegister() {
if (this.state.fetching) return;
if (this.validateRegisterEntity()) {
this.setState({
fetching: true,
});
const { name, cellphone, pwd, sex, vcode } = this.state;
const {
userinfo: { areaId, areaName },
......@@ -179,7 +185,12 @@ class Register extends Component {
});
}, 2000);
})
.catch(console.log);
.catch(err => {
console.log(err);
this.setState({
fetching: false,
});
});
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment