2025-08-29 12:06:02 +08:00
|
|
|
<template>
|
2025-08-29 12:28:33 +08:00
|
|
|
<a-config-provider
|
|
|
|
|
:theme="{
|
|
|
|
|
token: {
|
2025-08-29 14:57:13 +08:00
|
|
|
colorPrimary: '#143d7d'
|
|
|
|
|
}
|
2025-08-29 12:28:33 +08:00
|
|
|
}"
|
|
|
|
|
>
|
|
|
|
|
<div class="login">
|
|
|
|
|
<div class="main-title">能源站监控与运行管理系统</div>
|
|
|
|
|
<div class="login-content">
|
|
|
|
|
<div class="title" style="">账号登录</div>
|
2025-09-04 13:42:48 +08:00
|
|
|
<a-form ref="ruleForm" :model="form" :rules="rules" >
|
|
|
|
|
<a-form-item label="" name="account">
|
|
|
|
|
<a-input v-model:value="form.account" placeholder="请输入账号" autocomplete>
|
2025-08-29 12:28:33 +08:00
|
|
|
<template #prefix>
|
2025-08-29 14:57:13 +08:00
|
|
|
<user-outlined />
|
2025-08-29 12:28:33 +08:00
|
|
|
</template>
|
|
|
|
|
</a-input>
|
|
|
|
|
</a-form-item>
|
|
|
|
|
<a-form-item label="" name="passwd">
|
|
|
|
|
<a-input-password
|
|
|
|
|
v-model:value="form.passwd"
|
|
|
|
|
placeholder="请输入密码"
|
|
|
|
|
autocomplete
|
|
|
|
|
@pressEnter="login"
|
|
|
|
|
>
|
|
|
|
|
<template #prefix>
|
2025-08-29 14:57:13 +08:00
|
|
|
<LockOutlined />
|
2025-08-29 12:28:33 +08:00
|
|
|
</template>
|
|
|
|
|
</a-input-password>
|
|
|
|
|
</a-form-item>
|
|
|
|
|
</a-form>
|
|
|
|
|
|
2025-08-29 14:57:13 +08:00
|
|
|
<a-button class="login-btn" @click="login" :loading="loading">登录 </a-button>
|
2025-08-29 12:28:33 +08:00
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</a-config-provider>
|
2025-08-29 12:06:02 +08:00
|
|
|
</template>
|
2025-08-29 12:28:33 +08:00
|
|
|
<script>
|
2025-08-29 14:57:13 +08:00
|
|
|
import { UserOutlined, LockOutlined } from '@ant-design/icons-vue'
|
2025-09-04 13:42:48 +08:00
|
|
|
import { postReq,getReq } from '@/request/api.js'
|
2025-08-29 12:28:33 +08:00
|
|
|
export default {
|
2025-08-29 14:57:13 +08:00
|
|
|
name: 'LoginView',
|
|
|
|
|
components: {
|
|
|
|
|
UserOutlined,
|
|
|
|
|
LockOutlined
|
|
|
|
|
},
|
2025-08-29 12:28:33 +08:00
|
|
|
data() {
|
|
|
|
|
return {
|
2025-08-29 14:57:13 +08:00
|
|
|
form: {
|
2025-09-04 13:42:48 +08:00
|
|
|
account: 'admin',
|
2025-08-29 14:57:13 +08:00
|
|
|
passwd: '123456'
|
|
|
|
|
},
|
2025-08-29 12:28:33 +08:00
|
|
|
rules: {
|
2025-09-04 13:42:48 +08:00
|
|
|
account: [
|
2025-08-29 14:57:13 +08:00
|
|
|
{
|
|
|
|
|
required: true,
|
|
|
|
|
message: '请输入账号'
|
|
|
|
|
}
|
2025-08-29 12:28:33 +08:00
|
|
|
],
|
2025-08-29 14:57:13 +08:00
|
|
|
passwd: [
|
|
|
|
|
{
|
|
|
|
|
required: true,
|
|
|
|
|
message: '请输入密码'
|
|
|
|
|
}
|
|
|
|
|
]
|
2025-08-29 12:28:33 +08:00
|
|
|
},
|
2025-08-29 14:57:13 +08:00
|
|
|
loading: false
|
|
|
|
|
}
|
2025-08-29 12:28:33 +08:00
|
|
|
},
|
|
|
|
|
methods: {
|
|
|
|
|
async login() {
|
2025-09-04 13:42:48 +08:00
|
|
|
try {
|
|
|
|
|
const values = await this.$refs.ruleForm.validateFields()
|
|
|
|
|
const res = await getReq('/login',this.form )
|
|
|
|
|
this.loading = false
|
2025-09-09 09:33:14 +08:00
|
|
|
|
2025-09-04 13:42:48 +08:00
|
|
|
console.log(res);
|
|
|
|
|
|
2025-09-09 09:33:14 +08:00
|
|
|
if (res.errcode === 0) {
|
|
|
|
|
this.$message.success('登录成功')
|
|
|
|
|
localStorage.setItem('token', res.token)
|
2025-09-09 10:00:01 +08:00
|
|
|
localStorage.setItem('permission',JSON.stringify( res.permission) )
|
2025-09-11 16:14:55 +08:00
|
|
|
localStorage.setItem('account',JSON.stringify( res.account) )
|
|
|
|
|
|
2025-09-09 09:33:14 +08:00
|
|
|
this.$router.push('/')
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
// else {
|
2025-09-04 13:42:48 +08:00
|
|
|
// this.$message.error(res.message || '登录失败')
|
|
|
|
|
// }
|
|
|
|
|
} catch (error) {
|
|
|
|
|
console.log(error);
|
|
|
|
|
|
|
|
|
|
this.loading = false
|
|
|
|
|
this.$message.error('请求失败,请稍后重试')
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2025-08-29 14:57:13 +08:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2025-08-29 12:28:33 +08:00
|
|
|
</script>
|
|
|
|
|
<style lang="scss" scoped>
|
|
|
|
|
.login {
|
|
|
|
|
position: relative;
|
|
|
|
|
display: flex;
|
2025-08-29 14:57:13 +08:00
|
|
|
flex-direction: column;
|
2025-08-29 12:28:33 +08:00
|
|
|
justify-content: center;
|
|
|
|
|
align-items: center;
|
|
|
|
|
min-width: 1440px;
|
|
|
|
|
min-height: 900px;
|
|
|
|
|
width: 100%;
|
|
|
|
|
height: 100%;
|
2025-08-29 14:57:13 +08:00
|
|
|
background-image: url('@/assets/images/loginBg.png');
|
2025-08-29 12:28:33 +08:00
|
|
|
background-size: cover;
|
|
|
|
|
background-repeat: no-repeat;
|
|
|
|
|
background-position: center;
|
|
|
|
|
|
|
|
|
|
.main-title {
|
2025-08-29 14:57:13 +08:00
|
|
|
background: linear-gradient(180deg, rgba(255, 255, 255, 1) 0%, rgba(40, 235, 231, 1) 100%);
|
2025-08-29 12:28:33 +08:00
|
|
|
color: transparent;
|
|
|
|
|
-webkit-background-clip: text;
|
|
|
|
|
background-clip: text;
|
|
|
|
|
font-size: 50px;
|
2025-08-29 14:57:13 +08:00
|
|
|
font-weight: 600;
|
2025-08-29 12:28:33 +08:00
|
|
|
letter-spacing: 5px;
|
|
|
|
|
line-height: 53px;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.login-content {
|
2025-08-29 14:57:13 +08:00
|
|
|
width: 540px;
|
|
|
|
|
height: 370px;
|
2025-08-29 12:28:33 +08:00
|
|
|
display: flex;
|
|
|
|
|
flex-direction: column;
|
|
|
|
|
align-items: center;
|
|
|
|
|
padding: 0 40px;
|
2025-08-29 14:57:13 +08:00
|
|
|
margin-top: 120px;
|
|
|
|
|
background-image: url('@/assets/images/loginFrom.png');
|
|
|
|
|
background-size: cover;
|
|
|
|
|
background-repeat: no-repeat;
|
|
|
|
|
background-position: center;
|
|
|
|
|
.ant-form {
|
|
|
|
|
margin-top: 30px;
|
|
|
|
|
width: 330px;
|
|
|
|
|
}
|
2025-08-29 12:28:33 +08:00
|
|
|
|
|
|
|
|
.title {
|
2025-08-29 14:57:13 +08:00
|
|
|
// margin-bottom: 10px;
|
|
|
|
|
margin-top: 60px;
|
2025-08-29 12:28:33 +08:00
|
|
|
color: #fff;
|
|
|
|
|
font-size: 20px;
|
2025-08-29 14:57:13 +08:00
|
|
|
font-weight: 700;
|
2025-08-29 12:28:33 +08:00
|
|
|
}
|
|
|
|
|
:deep(.ant-input-prefix) {
|
2025-08-29 14:57:13 +08:00
|
|
|
color: #fff;
|
2025-08-29 12:28:33 +08:00
|
|
|
}
|
|
|
|
|
:deep(.ant-form-item) {
|
|
|
|
|
margin-bottom: 20px !important;
|
|
|
|
|
}
|
|
|
|
|
:deep(.ant-form-item-explain-error) {
|
|
|
|
|
font-size: 12px;
|
|
|
|
|
}
|
|
|
|
|
.iconfont {
|
|
|
|
|
margin: 0 10px 0 5px;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
.yanzhengma {
|
|
|
|
|
width: 60px;
|
|
|
|
|
font-family: yanzhengma;
|
|
|
|
|
font-size: 23px;
|
|
|
|
|
cursor: pointer;
|
|
|
|
|
}
|
|
|
|
|
.rememberPass {
|
|
|
|
|
font-size: 14px;
|
|
|
|
|
color: rgba(0, 0, 0, 0.5);
|
|
|
|
|
display: flex;
|
|
|
|
|
justify-content: space-around;
|
|
|
|
|
align-items: center;
|
|
|
|
|
width: 290px;
|
|
|
|
|
.ant-checkbox-wrapper,
|
|
|
|
|
span {
|
|
|
|
|
color: rgba(0, 0, 0, 0.5);
|
|
|
|
|
cursor: pointer;
|
|
|
|
|
}
|
|
|
|
|
.ant-checkbox-wrapper:hover {
|
2025-08-29 14:57:13 +08:00
|
|
|
color: #143d7d;
|
2025-08-29 12:28:33 +08:00
|
|
|
}
|
|
|
|
|
span:hover {
|
2025-08-29 14:57:13 +08:00
|
|
|
color: #143d7d;
|
2025-08-29 12:28:33 +08:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
.login-btn {
|
|
|
|
|
width: 335px;
|
2025-08-29 14:57:13 +08:00
|
|
|
height: 40px;
|
2025-08-29 12:28:33 +08:00
|
|
|
border-radius: 4px;
|
|
|
|
|
background: #2a82e4;
|
2025-08-29 14:57:13 +08:00
|
|
|
border: none !important;
|
2025-08-29 12:28:33 +08:00
|
|
|
font-size: 16px;
|
|
|
|
|
margin-top: 20px;
|
2025-08-29 14:57:13 +08:00
|
|
|
color: #fff;
|
2025-08-29 12:28:33 +08:00
|
|
|
}
|
|
|
|
|
.copyright {
|
|
|
|
|
position: absolute;
|
|
|
|
|
bottom: 5px;
|
|
|
|
|
left: 50%;
|
|
|
|
|
transform: translateX(-50%);
|
|
|
|
|
color: #fff;
|
|
|
|
|
font-weight: 700;
|
|
|
|
|
font-size: 20px;
|
|
|
|
|
}
|
|
|
|
|
}
|
2025-08-29 14:57:13 +08:00
|
|
|
.ant-input-affix-wrapper {
|
|
|
|
|
background: none !important;
|
|
|
|
|
height: 40px;
|
|
|
|
|
:deep(.ant-input) {
|
|
|
|
|
background: none !important;
|
|
|
|
|
color: #fff;
|
|
|
|
|
&::placeholder {
|
|
|
|
|
color: var(--theme-text6) !important;
|
2025-08-29 12:28:33 +08:00
|
|
|
}
|
|
|
|
|
}
|
2025-08-29 14:57:13 +08:00
|
|
|
:deep(.anticon){
|
|
|
|
|
color: #fff ;
|
2025-08-29 12:28:33 +08:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
</style>
|