|
@@ -1,64 +1,90 @@
|
|
|
<template>
|
|
|
<el-form size="large" class="login-content-form" ref="ruleFormRef" :model="state.ruleForm" @submit.native.prevent>
|
|
|
- <el-form-item class="login-animation1 mb30" prop="username" :rules="[{ required: true, message: '请输入账号', trigger: 'blur' }]">
|
|
|
- <el-input
|
|
|
- type="text"
|
|
|
- class="inputDeep"
|
|
|
- placeholder="请输入账号"
|
|
|
- v-model="state.ruleForm.username"
|
|
|
- clearable
|
|
|
- @keyup.enter="onSignIn(ruleFormRef)"
|
|
|
- autocomplete="off"
|
|
|
- >
|
|
|
- <template #prefix>
|
|
|
- <SvgIcon name="ele-User" class="el-input__icon" />
|
|
|
- </template>
|
|
|
- </el-input>
|
|
|
- </el-form-item>
|
|
|
- <el-form-item class="login-animation2 mb30" prop="password" :rules="[{ required: true, message: '请输入密码', trigger: 'blur' }]">
|
|
|
- <el-input
|
|
|
- class="inputDeep"
|
|
|
- clearable
|
|
|
- show-password
|
|
|
- placeholder="请输入密码"
|
|
|
- v-model="state.ruleForm.password"
|
|
|
- @keyup.enter="onSignIn(ruleFormRef)"
|
|
|
- autocomplete="off"
|
|
|
- >
|
|
|
- <template #prefix>
|
|
|
- <SvgIcon name="ele-Unlock" class="el-input__icon" />
|
|
|
- </template>
|
|
|
- </el-input>
|
|
|
- </el-form-item>
|
|
|
- <!-- <el-form-item class="login-animation3">
|
|
|
- <el-col :span="15">
|
|
|
- <el-input type="text" maxlength="4" class="inputDeep" placeholder="请输入验证码" v-model="state.ruleForm.code" @keyup.enter="onSignIn(ruleFormRef)" clearable autocomplete="off">
|
|
|
+ <motion :delay="100">
|
|
|
+ <el-form-item class="mb30" prop="username" :rules="[{ required: true, message: '请输入账号', trigger: 'blur' }]">
|
|
|
+ <el-input
|
|
|
+ type="text"
|
|
|
+ class="inputDeep"
|
|
|
+ placeholder="请输入账号"
|
|
|
+ v-model="state.ruleForm.username"
|
|
|
+ clearable
|
|
|
+ @keyup.enter="onSignIn(ruleFormRef)"
|
|
|
+ autocomplete="off"
|
|
|
+ >
|
|
|
+ <template #prefix>
|
|
|
+ <SvgIcon name="ele-User" class="el-input__icon" />
|
|
|
+ </template>
|
|
|
+ </el-input>
|
|
|
+ </el-form-item>
|
|
|
+ </motion>
|
|
|
+ <motion :delay="200">
|
|
|
+ <el-form-item class="mb30" prop="password" :rules="[{ required: true, message: '请输入密码', trigger: 'blur' }]">
|
|
|
+ <el-input
|
|
|
+ class="inputDeep"
|
|
|
+ clearable
|
|
|
+ show-password
|
|
|
+ placeholder="请输入密码"
|
|
|
+ v-model="state.ruleForm.password"
|
|
|
+ @keyup.enter="onSignIn(ruleFormRef)"
|
|
|
+ autocomplete="off"
|
|
|
+ >
|
|
|
<template #prefix>
|
|
|
- <SvgIcon name="ele-Position" class="el-input__icon"/>
|
|
|
+ <SvgIcon name="ele-Unlock" class="el-input__icon" />
|
|
|
</template>
|
|
|
</el-input>
|
|
|
- </el-col>
|
|
|
- <el-col :span="8" :offset=1>
|
|
|
- <el-button class="login-content-code">1234</el-button>
|
|
|
- </el-col>
|
|
|
- </el-form-item>-->
|
|
|
- <el-form-item class="login-animation4">
|
|
|
- <el-button type="primary" class="login-content-submit" round @click="onSignIn(ruleFormRef)" v-waves="'light'" :loading="state.loading"
|
|
|
- >登录</el-button
|
|
|
+ </el-form-item>
|
|
|
+ </motion>
|
|
|
+ <motion :delay="300">
|
|
|
+ <el-form-item
|
|
|
+ prop="verifyCode"
|
|
|
+ :rules="[
|
|
|
+ { required: true, message: '请输入验证码', trigger: 'blur' },
|
|
|
+ {
|
|
|
+ validator: validatePass,
|
|
|
+ trigger: 'blur',
|
|
|
+ },
|
|
|
+ ]"
|
|
|
>
|
|
|
- </el-form-item>
|
|
|
- <!-- <div class="font12 mt30 login-animation4 login-msg">
|
|
|
+ <el-col :span="15">
|
|
|
+ <el-input
|
|
|
+ type="text"
|
|
|
+ maxlength="4"
|
|
|
+ class="inputDeep"
|
|
|
+ placeholder="请输入验证码"
|
|
|
+ v-model="state.ruleForm.verifyCode"
|
|
|
+ @keyup.enter="onSignIn(ruleFormRef)"
|
|
|
+ clearable
|
|
|
+ autocomplete="off"
|
|
|
+ >
|
|
|
+ <template #prefix>
|
|
|
+ <SvgIcon name="iconfont icon-quanxian" class="el-input__icon" />
|
|
|
+ </template>
|
|
|
+ </el-input>
|
|
|
+ </el-col>
|
|
|
+ <el-col :span="8" :offset="1" class="flex">
|
|
|
+ <ReImageVerify v-model:code="verifyCode" />
|
|
|
+ </el-col>
|
|
|
+ </el-form-item>
|
|
|
+ </motion>
|
|
|
+ <motion :delay="400">
|
|
|
+ <el-form-item>
|
|
|
+ <el-button type="primary" class="login-content-submit" round @click="onSignIn(ruleFormRef)" :loading="state.loading">登录</el-button>
|
|
|
+ </el-form-item>
|
|
|
+ </motion>
|
|
|
+ <!-- <div class="font12 mt30 login-msg">
|
|
|
* 温馨提示:建议使用谷歌、Microsoft Edge,版本 79.0.1072.62 及以上浏览器,360浏览器请使用极速模式
|
|
|
</div> -->
|
|
|
- <div class="login-msg login-animation4">
|
|
|
- <div>联系管理员<b>重置密码</b></div>
|
|
|
- <!-- <el-button link type="primary" class="font16" @click="forgetPwd">忘记密码</el-button> -->
|
|
|
- </div>
|
|
|
+ <motion :delay="500">
|
|
|
+ <div class="login-msg">
|
|
|
+ <div>联系管理员<b>重置密码</b></div>
|
|
|
+ <!-- <el-button link type="primary" class="font16" @click="forgetPwd">忘记密码</el-button> -->
|
|
|
+ </div>
|
|
|
+ </motion>
|
|
|
</el-form>
|
|
|
</template>
|
|
|
|
|
|
<script setup lang="ts" name="loginAccount">
|
|
|
-import { reactive, computed, ref } from 'vue';
|
|
|
+import { reactive, computed, ref, defineAsyncComponent } from 'vue';
|
|
|
import { useRoute, useRouter } from 'vue-router';
|
|
|
import { ElNotification } from 'element-plus';
|
|
|
import { storeToRefs } from 'pinia';
|
|
@@ -72,6 +98,10 @@ import type { FormInstance } from 'element-plus';
|
|
|
import { signIn } from '@/api/login';
|
|
|
import { JSEncrypt } from 'jsencrypt'; // rsa加密
|
|
|
import { throttle } from '@/utils/tools';
|
|
|
+import Motion from '@/utils/motion';
|
|
|
+
|
|
|
+const ReImageVerify = defineAsyncComponent(() => import('@/components/ImgVerify/index.vue'));
|
|
|
+
|
|
|
// 定义变量内容
|
|
|
const storesThemeConfig = useThemeConfig(); // 主题配置
|
|
|
const { themeConfig } = storeToRefs(storesThemeConfig); // 主题配置
|
|
@@ -81,6 +111,7 @@ const state = reactive<any>({
|
|
|
ruleForm: {
|
|
|
username: '', // 账号
|
|
|
password: '', // 密码
|
|
|
+ verifyCode: '', // 验证码
|
|
|
},
|
|
|
loading: false, // 加载
|
|
|
});
|
|
@@ -89,6 +120,20 @@ const ruleFormRef = ref<FormInstance>(); // 表单ref
|
|
|
const currentTime = computed(() => {
|
|
|
return formatAxis(new Date());
|
|
|
});
|
|
|
+const validatePass = (rule: any, value: any, callback: any) => {
|
|
|
+ if (value === '') {
|
|
|
+ callback(new Error('请输入验证码'));
|
|
|
+ } else {
|
|
|
+ if (state.ruleForm.verifyCode !== '') {
|
|
|
+ if (state.ruleForm.verifyCode !== verifyCode.value) {
|
|
|
+ callback(new Error('验证码错误,请重新输入'));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ callback();
|
|
|
+ }
|
|
|
+};
|
|
|
+// 验证码
|
|
|
+const verifyCode = ref<string>(''); // 验证码
|
|
|
// 登录
|
|
|
const onSignIn = throttle(async (formEl: FormInstance | undefined) => {
|
|
|
if (!formEl) return;
|
|
@@ -177,6 +222,9 @@ const signInSuccess = (isNoPower: boolean | undefined) => {
|
|
|
border-radius: 0;
|
|
|
border-bottom: 1px solid var(--el-input-border-color, var(--el-border-color));
|
|
|
}
|
|
|
+ :deep(.el-form-item.is-error .el-input__wrapper.is-focus) {
|
|
|
+ box-shadow: 0 0 0 0 var(--el-input-border-color, var(--el-border-color)) inset;
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
.login-content-form {
|
|
@@ -191,16 +239,6 @@ const signInSuccess = (isNoPower: boolean | undefined) => {
|
|
|
font-size: 14px;
|
|
|
}
|
|
|
|
|
|
- @for $i from 1 through 4 {
|
|
|
- .login-animation#{$i} {
|
|
|
- opacity: 0;
|
|
|
- animation-name: error-num;
|
|
|
- animation-duration: 0.5s;
|
|
|
- animation-fill-mode: forwards;
|
|
|
- animation-delay: calc($i/10) + s;
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
.login-content-password {
|
|
|
display: inline-block;
|
|
|
width: 20px;
|