|
|
@@ -41,22 +41,25 @@ export default {
|
|
|
console.log(this.mobile);
|
|
|
if (this.time > 0) return;
|
|
|
if (!/^1\d{10}$/.test(this.mobile)) {
|
|
|
- wx.showToast({
|
|
|
- icon: 'none',
|
|
|
- title: '请输入正确的手机号'
|
|
|
- });
|
|
|
+ this.$toast('请输入正确的手机号');
|
|
|
return;
|
|
|
}
|
|
|
+ this.$loading('');
|
|
|
this.$http
|
|
|
.get('/applets/checkmobileexist', {
|
|
|
mobile: this.mobile
|
|
|
})
|
|
|
- .then(res => {});
|
|
|
- this.$http
|
|
|
- .get('/applets/sendmobilecode', {
|
|
|
- mobile: this.mobile
|
|
|
+ .then(res => {
|
|
|
+ if (res.code === 500) {
|
|
|
+ return Promise.reject(res.message);
|
|
|
+ } else {
|
|
|
+ return this.$http.get('/applets/sendmobilecode', {
|
|
|
+ mobile: this.mobile
|
|
|
+ });
|
|
|
+ }
|
|
|
})
|
|
|
.then(res => {
|
|
|
+ this.$loading.close();
|
|
|
this.time = 60;
|
|
|
this.i = setInterval(() => {
|
|
|
this.time--;
|
|
|
@@ -64,6 +67,14 @@ export default {
|
|
|
clearInterval(this.i);
|
|
|
}
|
|
|
}, 1000);
|
|
|
+ })
|
|
|
+ .catch(e => {
|
|
|
+ this.$loading.close();
|
|
|
+ if (typeof e === 'string') {
|
|
|
+ this.$toast(e);
|
|
|
+ } else {
|
|
|
+ this.$toast('短信发送失败,请稍后再试');
|
|
|
+ }
|
|
|
});
|
|
|
},
|
|
|
getUserInfo(e) {
|
|
|
@@ -71,37 +82,26 @@ export default {
|
|
|
return;
|
|
|
}
|
|
|
if (!/^1\d{10}$/.test(this.mobile)) {
|
|
|
- wx.showToast({
|
|
|
- icon: 'none',
|
|
|
- title: '请输入正确的手机号'
|
|
|
- });
|
|
|
+ this.$toast('请输入正确的手机号');
|
|
|
return;
|
|
|
}
|
|
|
if (!this.code) {
|
|
|
- wx.showToast({
|
|
|
- icon: 'none',
|
|
|
- title: '请输入验证码'
|
|
|
- });
|
|
|
+ this.$toast('请输入验证码');
|
|
|
return;
|
|
|
}
|
|
|
if (!this.password) {
|
|
|
- wx.showToast({
|
|
|
- icon: 'none',
|
|
|
- title: '请输入密码'
|
|
|
- });
|
|
|
+ this.$toast('请输入密码');
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if (this.password.length < 6) {
|
|
|
+ this.$toast('密码长度至少为6位');
|
|
|
return;
|
|
|
}
|
|
|
if (this.password !== this.password1) {
|
|
|
- wx.showToast({
|
|
|
- icon: 'none',
|
|
|
- title: '两次密码输入不一致'
|
|
|
- });
|
|
|
+ this.$toast('两次密码输入不一致');
|
|
|
return;
|
|
|
}
|
|
|
- wx.showLoading({
|
|
|
- title: '',
|
|
|
- mask: true
|
|
|
- });
|
|
|
+ this.$loading();
|
|
|
Promise.resolve()
|
|
|
.then(() => {
|
|
|
if (this.$store.state.loginInfo && this.$store.state.loginInfo.hasUnionId) {
|
|
|
@@ -115,7 +115,9 @@ export default {
|
|
|
}
|
|
|
})
|
|
|
.then(res => {
|
|
|
- return this.$http.get('/applets/checkmobileexist');
|
|
|
+ return this.$http.get('/applets/sendmobilecode', {
|
|
|
+ mobile: this.mobile
|
|
|
+ });
|
|
|
})
|
|
|
.then(res => {
|
|
|
if (res.code === 200) {
|
|
|
@@ -155,26 +157,17 @@ export default {
|
|
|
link: true
|
|
|
});
|
|
|
this.$store.dispatch('getUserInfo');
|
|
|
- wx.hideLoading();
|
|
|
- wx.showToast({
|
|
|
- icon: 'none',
|
|
|
- title: '登录成功'
|
|
|
- });
|
|
|
+ this.$loading.close();
|
|
|
+ this.$toast('登录成功');
|
|
|
wx.navigateBack();
|
|
|
})
|
|
|
.catch(e => {
|
|
|
console.log(e);
|
|
|
- wx.hideLoading();
|
|
|
+ this.$loading.close();
|
|
|
if (typeof e === 'string') {
|
|
|
- wx.showToast({
|
|
|
- icon: 'none',
|
|
|
- title: e
|
|
|
- });
|
|
|
+ this.$toast(e);
|
|
|
} else {
|
|
|
- wx.showToast({
|
|
|
- icon: 'none',
|
|
|
- title: '操作失败,请稍后再试'
|
|
|
- });
|
|
|
+ this.$toast('操作失败,请稍后再试');
|
|
|
}
|
|
|
});
|
|
|
},
|