登录判断

This commit is contained in:
13218645326 2023-12-11 17:24:59 +08:00
parent e9125881d2
commit 08430dfa62
1 changed files with 87 additions and 87 deletions

View File

@ -1,26 +1,25 @@
<script setup lang="ts">
import { loginApi } from 'http/api/login/index'
import { ElMessage } from 'element-plus'
import { useRoute, useRouter } from 'vue-router'
import { mainStore } from 'store/main'
const userStore = mainStore()
const router = useRouter()
const route = useRoute()
const loginForm = ref({
username: '',
password: ''
})
import { loginApi } from 'http/api/login/index'
import { ElMessage } from 'element-plus'
import { useRoute, useRouter } from 'vue-router'
import { mainStore } from 'store/main'
const userStore = mainStore()
const router = useRouter()
const route = useRoute()
const loginForm = ref({
username: '',
password: ''
})
const handlerLogin = async () => {
const res: any = await loginApi(loginForm.value)
console.log('登录成功**', res)
if (res.code === 200) {
ElMessage({
showClose: true,
message: '登录成功',
type: 'success'
})
}
const handlerLogin = async () => {
const res: any = await loginApi(loginForm.value)
console.log('登录成功**', res)
if (res.code === 200) {
ElMessage({
showClose: true,
message: '登录成功',
type: 'success'
})
userStore.setToken(res.data.access_token)
if (res.data.user) {
userStore.setUserInfo(res.data.user)
@ -32,15 +31,16 @@
'https://zlpt-1259760603.cos.ap-nanjing.myqcloud.com/2023/12/09/815629f192564db98ac55a643b46f853gouwu.png'
})
}
//
if (route.query && route.query.redirect) {
router.push(decodeURIComponent(route.query.redirect))
} else {
router.push('/home')
}
}
}
</script>
<template>
@ -59,12 +59,7 @@
<el-input v-model="loginForm.username" placeholder="账号" clearable />
</el-form-item>
<el-form-item>
<el-input
v-model="loginForm.password"
placeholder="密码"
clearable
type="password"
show-password />
<el-input v-model="loginForm.password" placeholder="密码" clearable type="password" show-password />
</el-form-item>
<el-form-item>
<el-button type="primary" @click="handlerLogin"> </el-button>
@ -80,77 +75,82 @@
</template>
<style lang="scss">
.login-container {
height: 100vh;
background-color: #125ab6;
display: flex;
align-items: center;
justify-content: center;
background: url('../assets/img/home/2023_12_01_beijing2/login_bgnew.png') no-repeat;
background-size: cover;
.login-container {
height: 100vh;
background-color: #125ab6;
display: flex;
align-items: center;
justify-content: center;
background: url('../assets/img/home/2023_12_01_beijing2/login_bgnew.png') no-repeat;
background-size: cover;
.login-form {
width: 500px;
height: 360px;
.login-form {
width: 500px;
height: 360px;
display: flex;
flex-direction: column;
h3 {
color: #fff;
font-size: 18px;
font-weight: bold;
text-align: center;
margin-bottom: 30px;
}
.form-container {
flex: 1;
display: flex;
flex-direction: column;
background-color: #c7dff4;
border-radius: 5px;
h3 {
color: #fff;
font-size: 18px;
font-weight: bold;
text-align: center;
margin-bottom: 30px;
}
.form-container {
flex: 1;
.login-type {
height: 40px;
margin-bottom: 40px;
display: flex;
flex-direction: column;
background-color: #c7dff4;
border-radius: 5px;
.login-type {
height: 40px;
margin-bottom: 40px;
display: flex;
color: #333;
div {
flex: 1;
height: 40px;
text-align: center;
line-height: 40px;
&:hover {
cursor: pointer;
}
}
color: #333;
.active {
color: #3498db;
border-bottom: 1px solid #3498db;
div {
flex: 1;
height: 40px;
text-align: center;
line-height: 40px;
&:hover {
cursor: pointer;
}
}
.el-form {
padding: 0 50px;
.el-input {
height: 37px;
}
.el-button {
width: 100%;
height: 37px;
}
.active {
color: #3498db;
border-bottom: 1px solid #3498db;
}
}
.forget-password {
margin-bottom: 0;
}
.el-form {
padding: 0 50px;
.forget-password .el-form-item__content {
display: flex;
align-items: center;
justify-content: space-between;
}
.el-input {
height: 37px;
}
.el-button {
width: 100%;
height: 37px;
}
.forget-password {
margin-bottom: 0;
}
.forget-password .el-form-item__content {
display: flex;
align-items: center;
justify-content: space-between;
}
}
}
}
}
</style>