password
This commit is contained in:
parent
a25572301d
commit
fbbf731322
|
@ -54,7 +54,9 @@
|
||||||
import { MessagePlugin } from "tdesign-vue-next";
|
import { MessagePlugin } from "tdesign-vue-next";
|
||||||
import { reactive, ref, onMounted } from "vue";
|
import { reactive, ref, onMounted } from "vue";
|
||||||
import { reqUser } from "@/api/login";
|
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 { TForm, TFormItem, TInput, TButton } from "tdesign-vue-next";
|
||||||
// import { DesktopIcon, LockOnIcon } from "tdesign-icons-vue";
|
// import { DesktopIcon, LockOnIcon } from "tdesign-icons-vue";
|
||||||
|
|
||||||
|
@ -62,7 +64,9 @@ const INITIAL_DATA = {
|
||||||
account: "",
|
account: "",
|
||||||
password: "",
|
password: "",
|
||||||
};
|
};
|
||||||
const from = ref();
|
|
||||||
|
const from = ref(null);
|
||||||
|
const router = useRouter();
|
||||||
const formData = reactive({
|
const formData = reactive({
|
||||||
...INITIAL_DATA,
|
...INITIAL_DATA,
|
||||||
});
|
});
|
||||||
|
@ -94,15 +98,19 @@ const rules = reactive({
|
||||||
],
|
],
|
||||||
});
|
});
|
||||||
|
|
||||||
|
onMounted(() => {
|
||||||
|
reqUser();
|
||||||
|
});
|
||||||
|
|
||||||
const onSubmit = async () => {
|
const onSubmit = async () => {
|
||||||
try {
|
try {
|
||||||
const validateResult = await this.$refs.form.validate();
|
const validateResult = await from.value?.validate();
|
||||||
if (validateResult.result) {
|
if (validateResult?.result) {
|
||||||
await reqUser(formData.account, formData.password);
|
await reqUser(formData.account, formData.password);
|
||||||
MessagePlugin.success("提交成功");
|
MessagePlugin.success("提交成功");
|
||||||
await router.push("/");
|
await router.push("/");
|
||||||
} else {
|
} else {
|
||||||
const firstError = validateResult.errors[0]?.message || "未知错误";
|
const firstError = validateResult?.errors[0]?.message || "未知错误";
|
||||||
console.log("Errors: ", validateResult.errors);
|
console.log("Errors: ", validateResult.errors);
|
||||||
MessagePlugin.warning(firstError);
|
MessagePlugin.warning(firstError);
|
||||||
}
|
}
|
||||||
|
@ -112,10 +120,6 @@ const onSubmit = async () => {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
onMounted(() => {
|
|
||||||
reqUser();
|
|
||||||
});
|
|
||||||
|
|
||||||
function handleForgotPasswordClick() {
|
function handleForgotPasswordClick() {
|
||||||
router.push("/password-reset");
|
router.push("/password-reset");
|
||||||
}
|
}
|
||||||
|
|
|
@ -120,13 +120,13 @@ const onReset = () => {
|
||||||
|
|
||||||
const onSubmit = async () => {
|
const onSubmit = async () => {
|
||||||
try {
|
try {
|
||||||
const validateResult = await this.$refs.form.validate();
|
const validateResult = await from.value?.validate();
|
||||||
if (validateResult.result) {
|
if (validateResult?.result) {
|
||||||
await reqUser(formData.account, formData.password,formData.rePassword);
|
await reqUser(formData.account, formData.password,formData.rePassword);
|
||||||
MessagePlugin.success("提交成功");
|
MessagePlugin.success("提交成功");
|
||||||
await router.push("/login");
|
await router.push("/");
|
||||||
} else {
|
} else {
|
||||||
const firstError = validateResult.errors[0]?.message || "未知错误";
|
const firstError = validateResult?.errors[0]?.message || "未知错误";
|
||||||
console.log("Errors: ", validateResult.errors);
|
console.log("Errors: ", validateResult.errors);
|
||||||
MessagePlugin.warning(firstError);
|
MessagePlugin.warning(firstError);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user