新增注册功能

This commit is contained in:
zjl 2024-12-16 15:36:38 +08:00
parent 5ce48fcdd2
commit 4d769a8dfb
3 changed files with 42 additions and 2 deletions

View File

@ -22,6 +22,17 @@ export function getUserInfo() {
}); });
} }
/**
* @description:
*/
export function register(params) {
return http.request({
url: `/register`,
method: 'POST',
params,
});
}
/** /**
* @description: * @description:
*/ */

View File

@ -107,7 +107,7 @@
// //
/** /**
* 定义表单参数 * 定义表单接口
*/ */
interface FormState { interface FormState {
username: string; username: string;

View File

@ -96,6 +96,8 @@
import { rule } from '@/utils/validate'; import { rule } from '@/utils/validate';
import { PersonOutline } from '@vicons/ionicons5'; import { PersonOutline } from '@vicons/ionicons5';
import { SafetyCertificateOutlined } from '@vicons/antd'; import { SafetyCertificateOutlined } from '@vicons/antd';
import { ResultEnum } from '@/enums/httpEnum';
import { register } from '@/api/system/user';
/** /**
* 定义参数 * 定义参数
@ -106,6 +108,18 @@
const isGetCode = ref(false); const isGetCode = ref(false);
const emit = defineEmits(['backLogin']); const emit = defineEmits(['backLogin']);
// /**
// *
// */
// interface FormState {
// username: string;
// password: string;
// retPassword: string;
// mobile: string;
// code: string;
// agreement: boolean;
// }
/** /**
* 定义表单参数 * 定义表单参数
*/ */
@ -146,7 +160,22 @@
loading.value = true; loading.value = true;
formRef.value.validate(async (valid) => { formRef.value.validate(async (valid) => {
if (valid) { if (valid) {
backLogin(); //
const params = {
username: formInline.username,
password: formInline.password,
retPassword: formInline.retPassword,
mobile: formInline.mobile,
code: formInline.code,
agreement: formInline.agreement,
};
const { code, msg } = await register(params);
if (code == ResultEnum.SUCCESS) {
ElMessage.success('注册成功,请登录');
backLogin();
} else {
ElMessage.error(msg || '登录失败');
}
loading.value = false; loading.value = false;
} else { } else {
loading.value = false; loading.value = false;