|
@@ -39,9 +39,8 @@
|
|
|
|
|
|
<script setup lang="ts">
|
|
|
// 基础
|
|
|
-
|
|
|
import type { Ref } from 'vue';
|
|
|
-import { onMounted, ref, reactive } from 'vue';
|
|
|
+import { ref, reactive } from 'vue';
|
|
|
import type { FormInstance, FormRules } from 'element-plus';
|
|
|
import { ElMessage } from 'element-plus';
|
|
|
import { Lock } from '@element-plus/icons-vue';
|
|
@@ -50,13 +49,9 @@ import { useRouter } from 'vue-router';
|
|
|
import { siteInfo } from '@/layout/site';
|
|
|
|
|
|
// 接口
|
|
|
-import { AdminStore } from '@/stores/users/admin'; // 管理员
|
|
|
-import { DoctorStore } from '@/stores/users/doctor'; //医生
|
|
|
-import { NurseStore } from '@/stores/users/nurse'; //护士
|
|
|
+import { LoginStore } from '@/stores/users/login'; // 登录
|
|
|
import type { IQueryResult } from '@/util/types.util';
|
|
|
-const adminAxios = AdminStore();
|
|
|
-const doctorAxios = DoctorStore();
|
|
|
-const nurseAxios = NurseStore();
|
|
|
+const loginAxios = LoginStore();
|
|
|
// 路由
|
|
|
const router = useRouter();
|
|
|
// 表单
|
|
@@ -78,8 +73,7 @@ const validCode: Ref<String> = ref('');
|
|
|
const code: Ref<String> = ref('');
|
|
|
// 加载中
|
|
|
const loading: Ref<Boolean> = ref(false);
|
|
|
-// 请求
|
|
|
-onMounted(async () => { });
|
|
|
+
|
|
|
//接收验证码组件提交的4位验证码
|
|
|
const createValidCode = (data) => {
|
|
|
validCode.value = data;
|
|
@@ -107,9 +101,9 @@ const toSave = async (formEl: FormInstance) => {
|
|
|
const toLogin = async (data: formData) => {
|
|
|
let res: IQueryResult;
|
|
|
const form = { account: data.account, password: data.password };
|
|
|
- if (data.type == '0') res = await adminAxios.login(form); //管理员
|
|
|
- else if (data.type == '1') res = await doctorAxios.login(form); //医生
|
|
|
- else res = await nurseAxios.login(form); //护士
|
|
|
+ if (data.type == '0') res = await loginAxios.admin(form); //管理员
|
|
|
+ else if (data.type == '1') res = await loginAxios.doctor(form); //医生
|
|
|
+ else res = await loginAxios.nurse(form); //护士
|
|
|
if (res.errcode == '0') {
|
|
|
loading.value = true;
|
|
|
ElMessage({ message: `登录成功`, type: 'success' });
|