Compare commits
No commits in common. "ba541e0e64b8e53087623eb22d1460fc36b0990d" and "683973bd4fa30c66629d583168262e3fe3f9f708" have entirely different histories.
ba541e0e64
...
683973bd4f
@ -21,7 +21,7 @@
|
|||||||
|
|
||||||
<v-card-text class="text-center">
|
<v-card-text class="text-center">
|
||||||
<a class="text-red text-decoration-none"
|
<a class="text-red text-decoration-none"
|
||||||
@click="dialog('忘记密码', '学生请请联系老师重置密码,老师请联系管理员重置密码。')">
|
@click="dialog('忘记密码', '请联系老师或管理员重置密码。')">
|
||||||
忘记密码<v-icon icon="mdi-chevron-right"></v-icon>
|
忘记密码<v-icon icon="mdi-chevron-right"></v-icon>
|
||||||
</a>
|
</a>
|
||||||
</v-card-text>
|
</v-card-text>
|
||||||
|
@ -16,7 +16,7 @@
|
|||||||
|
|
||||||
<v-divider :thickness="10" class="border-opacity-0"></v-divider>
|
<v-divider :thickness="10" class="border-opacity-0"></v-divider>
|
||||||
|
|
||||||
<v-text-field :rules="passwordRules2" label="重复输入密码" :append-inner-icon="visible ? 'mdi-eye' : 'mdi-eye-off'"
|
<v-text-field :rules="passwordRules2" label="重复输入密码" :append-inner-icon="visible ? 'mdi-eye-off' : 'mdi-eye'"
|
||||||
:type="visible ? 'text' : 'password'" @click:append-inner="visible = !visible"
|
:type="visible ? 'text' : 'password'" @click:append-inner="visible = !visible"
|
||||||
prepend-inner-icon="mdi-lock-outline"></v-text-field>
|
prepend-inner-icon="mdi-lock-outline"></v-text-field>
|
||||||
|
|
||||||
|
@ -1,112 +0,0 @@
|
|||||||
<template>
|
|
||||||
<v-dialog v-model="dialogRepasswdShow" max-width="448">
|
|
||||||
<v-card class="mx-auto pa-12 pb-8" elevation="8" width="100%" rounded="lg">
|
|
||||||
<v-form fast-fail @submit.prevent="submit">
|
|
||||||
|
|
||||||
<v-text-field v-model="userId" prepend-inner-icon="mdi-account-circle" :rules="userIdRules"
|
|
||||||
label="账号"></v-text-field>
|
|
||||||
|
|
||||||
<v-divider :thickness="10" class="border-opacity-0"></v-divider>
|
|
||||||
|
|
||||||
<v-text-field v-model="password" :rules="passwordRules" label="新密码"
|
|
||||||
:append-inner-icon="visible ? 'mdi-eye' : 'mdi-eye-off'" :type="visible ? 'text' : 'password'"
|
|
||||||
@click:append-inner="visible = !visible" prepend-inner-icon="mdi-lock-outline"></v-text-field>
|
|
||||||
|
|
||||||
<v-divider :thickness="10" class="border-opacity-0"></v-divider>
|
|
||||||
|
|
||||||
<v-btn :loading="loading" class="mb-8" color="blue" size="large" type="submit" variant="tonal" block>
|
|
||||||
修改密码1
|
|
||||||
</v-btn>
|
|
||||||
|
|
||||||
</v-form>
|
|
||||||
</v-card>
|
|
||||||
</v-dialog>
|
|
||||||
<v-dialog v-model="dialogShow" width="auto">
|
|
||||||
<v-card max-width="400" prepend-icon="mdi-update" :text="dialogText" :title="dialogTitle">
|
|
||||||
<template v-slot:actions>
|
|
||||||
<v-btn class="ms-auto" text="Ok" @click="dialogShow = false, dialogClose()"></v-btn>
|
|
||||||
</template>
|
|
||||||
</v-card>
|
|
||||||
</v-dialog>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<script setup lang="ts">
|
|
||||||
import { ref } from 'vue';
|
|
||||||
import { useAuthStore } from '@/store/auth';
|
|
||||||
import axios, { AxiosError } from 'axios';
|
|
||||||
|
|
||||||
const dialogShow = ref(false);
|
|
||||||
const dialogTitle = ref('');
|
|
||||||
const dialogText = ref('');
|
|
||||||
const dialogClose = ref(() => { });
|
|
||||||
|
|
||||||
const dialog = (title: string, text: string) => {
|
|
||||||
dialogTitle.value = title;
|
|
||||||
dialogText.value = text;
|
|
||||||
dialogShow.value = true;
|
|
||||||
return new Promise(res => {
|
|
||||||
dialogClose.value = res as () => void;
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
const dialogRepasswdShow = defineModel({ default: true });
|
|
||||||
|
|
||||||
const loading = ref(false);
|
|
||||||
const userId = ref('');
|
|
||||||
const password = ref('');
|
|
||||||
const authStore = useAuthStore();
|
|
||||||
const storedToken = ref(authStore.token);
|
|
||||||
const visible = ref(false);
|
|
||||||
|
|
||||||
type RepasswdResponse = { success?: string, error?: string };
|
|
||||||
|
|
||||||
const requestRepasswd = async () => {
|
|
||||||
try {
|
|
||||||
const formData = new FormData;
|
|
||||||
formData.append("token", storedToken.value);
|
|
||||||
formData.append("user_id", userId.value);
|
|
||||||
formData.append("new_passwd", password.value);
|
|
||||||
let res = await axios.post('/api/auth/repasswd', formData);
|
|
||||||
console.log(res.data);
|
|
||||||
return res.data as RepasswdResponse;
|
|
||||||
} catch (e) {
|
|
||||||
let ex = e as AxiosError;
|
|
||||||
if (ex.response?.data) {
|
|
||||||
console.log(ex.response?.data);
|
|
||||||
return ex.response?.data as RepasswdResponse;
|
|
||||||
} {
|
|
||||||
return { error: ex.message };
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const repasswd = async () => {
|
|
||||||
loading.value = true;
|
|
||||||
let res = await requestRepasswd();
|
|
||||||
loading.value = false;
|
|
||||||
if (res?.error) {
|
|
||||||
await dialog('错误', `修改密码失败:${res.error}`);
|
|
||||||
} else {
|
|
||||||
await dialog('信息', `修改密码成功。`);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const submit = async (event: SubmitEvent) => {
|
|
||||||
const results: any = await event;
|
|
||||||
if (results.valid) {
|
|
||||||
await repasswd();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
const userIdRules: any = [(value: string) => {
|
|
||||||
if (value?.length > 0) return true;
|
|
||||||
return '账号不能为空';
|
|
||||||
}];
|
|
||||||
|
|
||||||
const passwordRules: any = [(value: string) => {
|
|
||||||
if (value?.length > 0) return true;
|
|
||||||
return '密码不能为空';
|
|
||||||
}];
|
|
||||||
|
|
||||||
|
|
||||||
</script>
|
|
Loading…
Reference in New Issue
Block a user