注册代码调整

This commit is contained in:
joylink_cuiweidong 2022-12-14 16:23:39 +08:00
parent c2b9c3c2aa
commit 43120ef0a9
2 changed files with 44 additions and 3 deletions

View File

@ -304,3 +304,22 @@ export function registerUserNew(data) {
data
});
}
// 手机号是否已经注册
export function isExistMobile(params) {
return request({
url: `/api/userinfo/isExist/mobile`,
method: 'get',
params
});
}
// 手机号是否已经注册
export function isExistEmail(params) {
return request({
url: `/api/userinfo/isExist/email`,
method: 'get',
params
});
}

View File

@ -56,6 +56,7 @@
size="small"
type="primary"
style="margin-top: 10px; margin-right: 10px;"
:loading="sendVfcodeLoading"
:disabled="passWordCodeTime != 0"
@click="sendVfcodeFunc"
>
@ -80,7 +81,7 @@
<script>
import md5 from 'js-md5';
import Vcode from '@/components/VCode/index';
import { registerUserNew, sendPhoneVfcode, sendEmailVfcode } from '@/api/management/user';
import { registerUserNew, sendPhoneVfcode, sendEmailVfcode, isExistMobile, isExistEmail } from '@/api/management/user';
export default {
name: 'RegisterUser',
components:{
@ -139,6 +140,7 @@ export default {
passWordTime: null,
message: '',
loading:false,
sendVfcodeLoading:false,
isShow: false, //
operation: '',
title: '账号注册',
@ -223,9 +225,29 @@ export default {
const reMobile = new RegExp(reguMobile);
const reEmail = new RegExp(reguEmail);
if (this.form.type === 'mobile' && this.form.mobile && reMobile.test(this.form.mobile)) {
this.isShow = true;
this.sendVfcodeLoading = true;
isExistMobile({mobile:this.form.mobile}).then(response=>{
this.sendVfcodeLoading = false;
if (response.data) {
this.$message.error('该账号已存在');
} else {
this.isShow = true;
}
}).catch(()=>{
this.sendVfcodeLoading = false;
});
} else if (this.form.type === 'email' && this.form.email && reEmail.test(this.form.email)) {
this.isShow = true;
this.sendVfcodeLoading = true;
isExistEmail({email:this.form.email}).then(response=>{
this.sendVfcodeLoading = false;
if (response.data) {
this.$message.error('该账号已存在');
} else {
this.isShow = true;
}
}).catch(()=>{
this.sendVfcodeLoading = false;
});
} else {
this.$refs.ruleForm.validateField('email');
this.$refs.ruleForm.validateField('mobile');