You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

177 lines
4.0 KiB

<template>
<el-dialog
class="mai-login-modal"
v-model="loginVisible"
footer=""
header=""
:show-close="false"
@close="onClose"
>
<template #header>
<h2 class="mb-3 text-2xl font-bold text-center xl:text-3xl enter-x xl:text-left">
欢迎来到
<p>{{ title }}</p>
</h2>
</template>
<el-form
class="p-4 enter-x"
:model="formData"
:rules="formRules"
ref="formRef"
>
<el-form-item name="account" class="enter-x">
<el-input
size="large"
v-model="formData.account"
placeholder="请输入账号"
class="fix-auto-fill"
/>
</el-form-item>
<el-form-item name="password" class="enter-x">
<el-input
type="password"
size="large"
v-model="formData.password"
placeholder="请输入密码"
/>
</el-form-item>
<el-form-item name="captcha" class="enter-x">
<el-input
size="large"
v-model="formData.captcha"
placeholder="请输入验证码"
>
<template #append>
<img src="~@/assets/images/testCode.jpg" alt="" />
</template>
</el-input>
</el-form-item>
<el-form-item class="enter-x">
<el-button type="primary" size="large" block @click="handleLogin(formRef)" :loading="loading">
</el-button>
<!-- <Button size="large" class="mt-4 enter-x" block @click="handleRegister">
{{ t('sys.login.registerButton') }}
</Button> -->
</el-form-item>
</el-form>
</el-dialog>
</template>
<script lang="ts" setup>
import { computed, reactive, ref, unref } from 'vue';
import {FormInstance} from "element-plus";
const userStore = useUserInfo();
const title = computed(()=> import.meta.env.VITE_GLOB_APP_TITLE)
const formRules = ref({
})
const formRef = ref<FormInstance>();
const loading = ref(false);
const formData = reactive({
account: 'test',
password: '123456',
// captcha: '123456',
});
const prefixCls = useDesign('login');
async function handleLogin(formEl: FormInstance | undefined) {
if (!formEl) return;
await formEl.validate(async (vail: boolean) => {
if (vail) {
loading.value = true;
try {
const userInfo = await userStore.login({
...formData
});
if (userInfo) {
ElNotification.success('登录成功')
}
} catch (e) {
loading.value = false;
} finally {
loading.value = false;
}
}else {
loading.value = false;
}
})
}
const loginVisible = ref(userStore.getLoginVisible);
watchEffect(()=>{
loginVisible.value = userStore.getLoginVisible;
console.log('loginStatus>>>', loginVisible.value)
})
const onClose = () => {
userStore.setLoginVisible(false);
};
</script>
<style lang="less">
//$elPrefix: 'el-dialog';
.el-dialog {
width: 1105px !important;
max-width: 1105px !important;
min-width: 1105px !important;
border-radius: 10px;
&__header {
h2 {
font-size: 48px;
line-height: 67px;
text-align: center;
padding-top: 54px;
p {
color: #999;
font-size: 28px;
line-height: 30px;
margin-top: 12px;
}
}
}
&__body {
padding: 0 105px;
border-radius: 16px;
box-sizing: border-box;
.el-input__wrapper {
height: 117px;
font-size: 32px;
border-radius: 8px;
padding: 0 60px;
}
.el-input-group--append {
height: 117px;
.el-input__wrapper {
border-radius: 8px 0 0 8px;
}
.el-input-group__append {
padding: 1px;
box-shadow: 0 0 0 1px var(--el-input-border-color, var(--el-border-color)) inset;
}
background-color: unset;
img {
width: 100%;
height: 100%;
}
}
.el-button {
font-size: 28px;
height: 106px;
margin-bottom: 107px;
background-color: #14417a;
border-radius: 8px;
@apply w-full;
}
}
}
</style>