Login.vue
5.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
<template>
<div class="Login">
<div class="login-wrap">
<div class="login-wrap_header">内部系统</div>
<div class="login-wrap_container">
<div class="welcome-text">欢迎登录!</div>
<el-form
ref="form"
:model="form"
:rules="rules"
class="login-wrap_container-form"
>
<el-form-item label="账号" prop="account">
<el-input
v-model="form.account"
placeholder="请输入账号"
></el-input>
</el-form-item>
<el-form-item label="密码" prop="password">
<el-input
type="password"
v-model="form.password"
placeholder="请输入密码"
autocomplete="off"
>
</el-input>
</el-form-item>
<div class="password-remind">
<!-- <registerForm>
<div class="user-register">账户注册</div>
</registerForm> -->
<div class="forget-password">
<!-- 忘记密码? -->
</div>
</div>
<el-button class="login-button" @click="toHome" :loading="loading">登录</el-button>
<!-- <div class="login-button" @click="toHome">
{{ loading ? "登录中。。。" : "登录" }}
</div> -->
</el-form>
</div>
</div>
</div>
</template>
<script>
import { login } from "@/api/index";
import { setToken } from "@/utils/auth";
export default {
name: "Login",
components: {
loginLoading() {
return this.$store.state.user.loginLoading;
},
},
data() {
return {
form: {
account: "", // cdoffice, xin
password: "", // 123456
},
rules: {
account: { required: true, message: "用户名不能为空", trigger: "blur" },
password: { required: true, message: "密码不能为空", trigger: "blur" },
},
loading: false,
};
},
watch: {
loginLoading(val) {
if (!val) this.loading = false;
},
},
created() {
},
mounted() {},
methods: {
toHome() {
if (this.loading) return;
this.$refs["form"].validate((valid) => {
if (valid) {
this.loading = true;
this.$store.commit("SET_LOGIN_LOADING", true);
this.$store
.dispatch("Login", this.form)
.then(() => {
this.$router.push({ path: "/homePage" });
})
.catch(() => {
this.loading = false;
this.$store.commit("SET_LOGIN_LOADING", false);
});
}
});
},
},
};
</script>
<style scoped lang="scss">
.Login {
width: 100%;
height: 100%;
background-image: url("@/assets/images/login_bg.png"); /* 替换为你的图片路径 */
background-size: cover; /* 背景图片覆盖整个元素 */
background-position: center; /* 背景图片居中 */
background-repeat: no-repeat; /* 不重复背景图片 */
.login-wrap {
width: 626px;
position: absolute;
top: 50%;
right: 8%;
transform: translateY(-50%);
.login-wrap_header {
width: 510px;
margin: 0 auto;
color: #5ed0fa;
font-size: 40px;
text-align: center;
}
.login-wrap_container {
width: 100%;
height: 520px;
padding: 64px 67px 67px;
box-sizing: border-box;
background-image: url("@/assets/images/login-box-container.png");
background-size: 100% 100%;
background-repeat: no-repeat;
text-align: left;
position: relative;
.welcome-text {
width: 392px;
margin: 0 auto 20px;
font-size: 20px;
font-weight: 700;
color: #5ed0fa;
}
.login-wrap_container-form {
width: 392px;
margin: 0 auto;
:deep(.el-form-item__label) {
font-size: 16px;
font-weight: 700;
color: #5ed0fa;
padding: 0;
}
:deep(.el-input__inner) {
background: none;
border: none;
border-bottom: 1px solid #5ed0fa;
padding: 0;
border-radius: 0;
color: #5ed0fa;
}
.password-remind {
width: 100%;
margin-bottom: 30px;
display: flex;
-webkit-box-pack: justify;
-ms-flex-pack: justify;
-webkit-box-align: center;
align-items: center;
justify-content: space-between;
.user-register {
color: #5ed0fa;
font-weight: 700;
cursor: pointer;
}
.forget-password {
color: #5ed0fa;
font-weight: 700;
cursor: pointer;
}
}
.login-button {
width: 100%;
height: 46px;
// line-height: 46px;
// text-align: center;
background-image: url("@/assets/images/login-btn.png");
background-size: 100%;
background-repeat: no-repeat;
border-radius: 25px;
border: unset;
// cursor: pointer;
color: #5ed0fa;
font-size: 18px;
}
}
}
}
}
</style>