注册接口 调整

This commit is contained in:
joylink_cuiweidong 2022-12-13 17:12:19 +08:00
parent 4ec18c3731
commit 7c1691d774
3 changed files with 59 additions and 34 deletions

View File

@ -295,3 +295,12 @@ export function sendEmailVfcode(params) {
params
});
}
/** 新注册接口 */
export function registerUserNew(data) {
return request({
url: `/api/userinfo/register2`,
method: 'put',
data
});
}

View File

@ -40,7 +40,7 @@
<!-- 忘记密码 -->
<forget-password ref="forgetPassword" />
<!-- 注册用户 -->
<register-user ref="registerUser" />
<register-user ref="registerUser" :project="backProject" />
<!-- 选择组织 -->
<OrgSelect ref="orgSelect" @select="selectOrgnization" />
</div>

View File

@ -16,7 +16,7 @@
<span>注册途径</span>
</template>
<el-radio-group v-model="form.type" size="small" @change="changeType">
<el-radio label="phone" border>手机号注册</el-radio>
<el-radio label="mobile" border>手机号注册</el-radio>
<el-radio label="email" border>邮箱注册</el-radio>
</el-radio-group>
</el-form-item>
@ -26,11 +26,11 @@
</template>
<el-input v-model="form.email" size="small" style="width:260px" />
</el-form-item>
<el-form-item v-if="form.type === 'phone'" prop="phone">
<el-form-item v-if="form.type === 'mobile'" prop="mobile">
<template slot="label">
<span>手机号</span>
</template>
<el-input v-model="form.phone" size="small" style="width: 260px;" />
<el-input v-model="form.mobile" size="small" style="width: 260px;" />
</el-form-item>
<el-form-item prop="nickname">
<template slot="label">
@ -47,11 +47,11 @@
<el-form-item label="密码确认:" prop="repeatPassword">
<el-input v-model="form.repeatPassword" autocomplete="new-password" show-password size="small" style="width:260px" />
</el-form-item>
<el-form-item prop="vfCode">
<el-form-item prop="verificationCode">
<template slot="label">
<span>验证码</span>
</template>
<el-input v-model="form.vfCode" size="small" style="display: inline-block;width:140px" />
<el-input v-model="form.verificationCode" size="small" style="display: inline-block;width:140px" />
<el-button
size="small"
type="primary"
@ -74,10 +74,17 @@
</template>
<script>
import md5 from 'js-md5';
import { getSessionStorage } from '@/utils/auth';
import { registerUser } from '@/api/management/user';
import { registerUserNew, sendPhoneVfcode, sendEmailVfcode } from '@/api/management/user';
export default {
name: 'RegisterUser',
props: {
project: {
type: String,
default: () => {
return '';
}
}
},
data() {
var validateEmail = (rule, value, callback) => {
const regu = /^[a-zA-Z0-9_-]+@[a-zA-Z0-9_-]+(\.[a-zA-Z0-9_-]+)+$/;
@ -88,7 +95,7 @@ export default {
callback();
}
};
var validatePhone = (rule, value, callback) => {
var validateMobile = (rule, value, callback) => {
const regu = /^1(3[0-9]|4[5,7]|5[0,1,2,3,5,6,7,8,9]|6[2,5,6,7]|7[0,1,7,8]|8[0-9]|9[1,8,9])\d{8}$/;
const re = new RegExp(regu);
if (!re.test(value)) {
@ -111,7 +118,7 @@ export default {
}
};
var validateVfCode = (rule, value, callback) => {
if (this.form.vfCode.length !== 4) {
if (this.form.verificationCode.length !== 4) {
callback(new Error('验证码长度错误'));
} else {
callback();
@ -125,18 +132,18 @@ export default {
operation: '',
title: '账号注册',
form: {
type: 'phone',
phone: '',
type: 'mobile',
mobile: '',
email: '',
nickname: '',
password: '',
repeatPassword: '',
vfCode:''
verificationCode:''
},
rules: {
phone: [
mobile: [
{ required: true, message: '请输入手机号', trigger: 'blur' },
{ validator: validatePhone, trigger: 'blur' }
{ validator: validateMobile, trigger: 'blur' }
],
email: [
{ required: true, message: '请输入邮箱', trigger: 'blur' },
@ -156,7 +163,7 @@ export default {
{ validator: validateRepeatPassword, trigger: 'blur' },
{ min: 5, max: 20, message: '长度在 5 到 20 个字符', trigger: 'blur' }
],
vfCode: [
verificationCode: [
{ required: true, message: '请输入验证码', trigger: 'blur' },
{ validator: validateVfCode, trigger: 'blur' }
]
@ -171,26 +178,26 @@ export default {
methods: {
doShow() {
this.form = {
type: 'phone',
phone: '',
type: 'mobile',
mobile: '',
email: '',
nickname: '',
password: '',
repeatPassword: '',
vfCode: ''
verificationCode: ''
};
this.dialogShow = true;
},
doClose() {
this.dialogShow = false;
this.form = {
type: 'phone',
phone: '',
type: 'mobile',
mobile: '',
email: '',
nickname: '',
password: '',
repeatPassword: '',
vfCode: ''
verificationCode: ''
};
this.$refs.ruleForm.clearValidate();
},
@ -199,15 +206,15 @@ export default {
},
async sendVfcode() {
const reguEmail = /^[a-zA-Z0-9_-]+@[a-zA-Z0-9_-]+(\.[a-zA-Z0-9_-]+)+$/;
const reguPhone = /^1(3[0-9]|4[5,7]|5[0,1,2,3,5,6,7,8,9]|6[2,5,6,7]|7[0,1,7,8]|8[0-9]|9[1,8,9])\d{8}$/;
const rePhone = new RegExp(reguPhone);
const reguMobile = /^1(3[0-9]|4[5,7]|5[0,1,2,3,5,6,7,8,9]|6[2,5,6,7]|7[0,1,7,8]|8[0-9]|9[1,8,9])\d{8}$/;
const reMobile = new RegExp(reguMobile);
const reEmail = new RegExp(reguEmail);
if (this.form.type === 'phone' && this.form.phone && rePhone.test(this.form.phone)) {
if (this.form.type === 'mobile' && this.form.mobile && reMobile.test(this.form.mobile)) {
const random = Math.floor(Math.random() * 10000 + 1);
const timeCount = Date.parse(new Date()) / 1000;
const pass = `${timeCount}86${this.form.phone}${random}`;
const pass = `${timeCount}86${this.form.mobile}${random}`;
const param = {
mobile: this.form.phone,
mobile: this.form.mobile,
nationCode: '86',
rd: random + '',
time: timeCount + '',
@ -223,7 +230,7 @@ export default {
this.passWordTime = null;
}
}, 1000);
// await sendPhoneVfcode(param);
await sendPhoneVfcode(param);
} catch (error) {
this.$message.info(this.$t('global.codeFaile'));
}
@ -239,22 +246,31 @@ export default {
this.passWordTime = null;
}
}, 1000);
// await sendEmailVfcode(param);
await sendEmailVfcode(param);
} catch (error) {
this.$message.info(this.$t('global.codeFaile'));
}
} else {
this.$refs.ruleForm.validateField('email');
this.$refs.ruleForm.validateField('phone');
this.$refs.ruleForm.validateField('mobile');
}
},
submitForm() {
this.$refs.ruleForm.validate((valid) => {
if (valid) {
const project = getSessionStorage('project');
// ProjectCode[project] || ''
const data = { email: this.form.email, nickname: this.form.nickname, password: md5(this.form.password), source:project };
registerUser(data).then(resp => {
const data = {
nickname: this.form.nickname,
verificationCode:this.form.verificationCode,
password: md5(this.form.password),
source:this.project
};
if (this.form.type == 'mobile') {
data.mobile = this.form.mobile;
data.nationCode = '86';
} else {
data.email = this.form.email;
}
registerUserNew(data).then(resp => {
this.$message.success('账号注册成功!' );
this.doClose();
}).catch(error => {