Commit c4a8963b by 姜雷

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

parent bf7ee6c4
...@@ -133,7 +133,7 @@ class BarCode extends Component { ...@@ -133,7 +133,7 @@ class BarCode extends Component {
this.fetchOrder(res.data[0].id); this.fetchOrder(res.data[0].id);
this.setState({ showPayOrder: true }); this.setState({ showPayOrder: true });
} else { } else {
this.drawBarCode(false); this.drawBarCode();
} }
}) })
.catch(err => { .catch(err => {
......
...@@ -66,7 +66,11 @@ class Login extends Component { ...@@ -66,7 +66,11 @@ class Login extends Component {
} }
loginHandle(): void { loginHandle(): void {
if (this.state.fetching) return;
if (this.validataLoginData()) { if (this.validataLoginData()) {
this.setState({
fetching: true,
});
const { updateUserInfo, userinfo } = this.props; const { updateUserInfo, userinfo } = this.props;
const { account, pwd } = this.state; const { account, pwd } = this.state;
console.log('in loginHandle'); console.log('in loginHandle');
...@@ -85,13 +89,23 @@ class Login extends Component { ...@@ -85,13 +89,23 @@ class Login extends Component {
}) })
.catch(err => { .catch(err => {
console.log(err); console.log(err);
if (err.code && err.code === NotRegisterCode) { if (err.code && err.code === NotRegisterCode) {
updateUserInfo({ updateUserInfo({
customerPhone: account, customerPhone: account,
}); });
setTimeout(() => {
this.setState({
fetching: false,
});
Taro.navigateTo({ Taro.navigateTo({
url: '/pages/Register/Register', url: '/pages/Register/Register',
}); });
}, 2000);
} else {
this.setState({
fetching: false,
});
} }
}); });
} }
......
...@@ -28,6 +28,7 @@ type PageDispatchProps = { ...@@ -28,6 +28,7 @@ type PageDispatchProps = {
}; };
type PageState = { type PageState = {
fetching: boolean;
name: string; name: string;
cellphone: string; cellphone: string;
vcode: string; vcode: string;
...@@ -64,6 +65,7 @@ class Register extends Component { ...@@ -64,6 +65,7 @@ class Register extends Component {
super(props); super(props);
const { customerPhone } = props.userinfo; const { customerPhone } = props.userinfo;
this.state = { this.state = {
fetching: false,
name: '', name: '',
cellphone: customerPhone, cellphone: customerPhone,
vcode: '', vcode: '',
...@@ -148,7 +150,11 @@ class Register extends Component { ...@@ -148,7 +150,11 @@ class Register extends Component {
} }
getRegister() { getRegister() {
if (this.state.fetching) return;
if (this.validateRegisterEntity()) { if (this.validateRegisterEntity()) {
this.setState({
fetching: true,
});
const { name, cellphone, pwd, sex, vcode } = this.state; const { name, cellphone, pwd, sex, vcode } = this.state;
const { const {
userinfo: { areaId, areaName }, userinfo: { areaId, areaName },
...@@ -179,7 +185,12 @@ class Register extends Component { ...@@ -179,7 +185,12 @@ class Register extends Component {
}); });
}, 2000); }, 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