password
This commit is contained in:
parent
a25572301d
commit
fbbf731322
|
@ -54,7 +54,9 @@
|
|||
import { MessagePlugin } from "tdesign-vue-next";
|
||||
import { reactive, ref, onMounted } from "vue";
|
||||
import { reqUser } from "@/api/login";
|
||||
import router from "@/router";
|
||||
// import router from "@/router";
|
||||
import { useRouter } from "vue-router";
|
||||
import axios from 'axios';
|
||||
// import { TForm, TFormItem, TInput, TButton } from "tdesign-vue-next";
|
||||
// import { DesktopIcon, LockOnIcon } from "tdesign-icons-vue";
|
||||
|
||||
|
@ -62,7 +64,9 @@ const INITIAL_DATA = {
|
|||
account: "",
|
||||
password: "",
|
||||
};
|
||||
const from = ref();
|
||||
|
||||
const from = ref(null);
|
||||
const router = useRouter();
|
||||
const formData = reactive({
|
||||
...INITIAL_DATA,
|
||||
});
|
||||
|
@ -94,15 +98,19 @@ const rules = reactive({
|
|||
],
|
||||
});
|
||||
|
||||
onMounted(() => {
|
||||
reqUser();
|
||||
});
|
||||
|
||||
const onSubmit = async () => {
|
||||
try {
|
||||
const validateResult = await this.$refs.form.validate();
|
||||
if (validateResult.result) {
|
||||
const validateResult = await from.value?.validate();
|
||||
if (validateResult?.result) {
|
||||
await reqUser(formData.account, formData.password);
|
||||
MessagePlugin.success("提交成功");
|
||||
await router.push("/");
|
||||
} else {
|
||||
const firstError = validateResult.errors[0]?.message || "未知错误";
|
||||
const firstError = validateResult?.errors[0]?.message || "未知错误";
|
||||
console.log("Errors: ", validateResult.errors);
|
||||
MessagePlugin.warning(firstError);
|
||||
}
|
||||
|
@ -112,10 +120,6 @@ const onSubmit = async () => {
|
|||
}
|
||||
};
|
||||
|
||||
onMounted(() => {
|
||||
reqUser();
|
||||
});
|
||||
|
||||
function handleForgotPasswordClick() {
|
||||
router.push("/password-reset");
|
||||
}
|
||||
|
|
|
@ -88,7 +88,7 @@ const rules = reactive({
|
|||
message: "请输入 8 位密码",
|
||||
},
|
||||
{
|
||||
pattern: /^(?=.*[A-Z])(?=.*\d)[A-Za-z\d]{8,}$/u,
|
||||
pattern: /^(?=.*[A-Z])(?=.*\d)[A-Za-z\d]{8,}$/u,
|
||||
message: "密码必须包含至少一个大写字母,并由字母和数字组成",
|
||||
},
|
||||
],
|
||||
|
@ -120,13 +120,13 @@ const onReset = () => {
|
|||
|
||||
const onSubmit = async () => {
|
||||
try {
|
||||
const validateResult = await this.$refs.form.validate();
|
||||
if (validateResult.result) {
|
||||
await reqUser(formData.account, formData.password, formData.rePassword);
|
||||
const validateResult = await from.value?.validate();
|
||||
if (validateResult?.result) {
|
||||
await reqUser(formData.account, formData.password,formData.rePassword);
|
||||
MessagePlugin.success("提交成功");
|
||||
await router.push("/login");
|
||||
await router.push("/");
|
||||
} else {
|
||||
const firstError = validateResult.errors[0]?.message || "未知错误";
|
||||
const firstError = validateResult?.errors[0]?.message || "未知错误";
|
||||
console.log("Errors: ", validateResult.errors);
|
||||
MessagePlugin.warning(firstError);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user