fix : 修复loading加载

This commit is contained in:
2024-03-05 21:58:53 +08:00
parent bfbc77847a
commit 25bcededa0

View File

@@ -15,7 +15,8 @@
</el-form-item>
<el-form-item prop="code" label="验证码">
<div class="code">
<el-input v-model="loginForm.code" :prefix-icon="key" @keyup.enter.native="handleLogin(formInstance)"></el-input>
<el-input v-model="loginForm.code" :prefix-icon="key"
@keyup.enter.native="handleLogin(formInstance)"></el-input>
<img :src="codeImg" alt="" @click="getCode">
</div>
</el-form-item>
@@ -32,6 +33,7 @@ import { getCodeImg } from '../../api/login';
import {useAuthStore} from '@/stores/userstore'
import {ElLoading} from 'element-plus'
import {User, Lock, Key} from '@element-plus/icons-vue'
const router = useRouter()
const authStore = useAuthStore()
const loginForm = reactive({
@@ -66,18 +68,19 @@ const handleLogin = (instance) => {
if (!instance) return
instance.validate(async (valid, fields) => {
if (!valid) return
ElLoading.service({
const loading = ElLoading.service({
lock: true,
text: '登录中...',
background: 'rgba(0, 0, 0, 0.7)',
})
// 发送请求
await authStore.userLogin(loginForm).then(res => {
if(res) {
if (res.code === 1000) {
router.push('/')
} else {
getCode()
}
loading.close()
})
})
}
@@ -115,15 +118,18 @@ onBeforeUnmount(() => {
}
}
}
.code {
display: flex;
justify-content: space-between;
align-items: center;
width: 100%;
.el-input {
// width: ;
flex: 2;
}
img {
height: 32px;
flex: 1;