login.vue
6.1 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
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
<template>
<div class="login_wrap layout align_center justify_center">
<div class="login_box">
<div class="login_main">
<!-- logo -->
<div class="login_logo">
<img src="@/assets/img_41.png" alt />
</div>
<!-- 名称 -->
<div class="web_name">
全球移民与置业评估系统
<!-- International Immigration &
<br />Asset Allocation Assessed System -->
</div>
<!-- 账号输入 -->
<div class="login_input">
<el-input type="text" v-model="account" placeholder="输入用户名"></el-input>
<div class="input_icon">
<img src="@/assets/img_45.png" alt />
</div>
</div>
<!-- 密码输入 -->
<div class="login_input">
<el-input type="password" v-model="pwd" placeholder="输入密码"></el-input>
<div class="input_icon">
<img src="@/assets/img_43.png" alt />
</div>
</div>
<!-- 图形验证码 -->
<div class="verification_input layout align_center justify">
<div class="verification_input_l">
<el-input maxlength="4" type="text" v-model="code" placeholder="输入验证码"></el-input>
<div class="input_icon">
<img src="@/assets/img_44.png" alt />
</div>
</div>
<!-- 验证码 -->
<div class="verification_code" @click="getPicCode()">
<img :src="imgCode" alt />
</div>
</div>
<!-- 记住密码 -->
<div class="layout align_center justify_start remeber_pwd">
<el-checkbox v-model="checked" @change="changeCheck()">记住密码</el-checkbox>
</div>
<!-- 登录按钮 -->
<div class="login_btn" @click="toIndex()">登录</div>
</div>
</div>
</div>
</template>
<script>
import { post } from "../../api/http.js";
import { Message } from "element-ui";
export default {
data() {
return {
account: "",
pwd: "",
code: "",
checked: false,
imgCode: "",
sessionId: ""
};
},
methods: {
// 记住密码
changeCheck() {
if (this.checked) {
localStorage.setItem("account", this.account);
localStorage.setItem("pwd", this.pwd);
localStorage.setItem("checked", 1);
} else {
localStorage.removeItem("checked");
localStorage.removeItem("account");
localStorage.removeItem("pwd");
}
},
// 登录
toIndex() {
let url = "/api/user/login";
if(this.account&&this.pwd&&this.code){
if(localStorage.getItem("checked") == 1){
localStorage.setItem("account", this.account);
localStorage.setItem("pwd", this.pwd);
}
let params = {
username: this.account,
password: this.pwd,
code: this.code,
session_id: this.sessionId
};
post(url, params)
.then(res => {
localStorage.setItem("token", res.token);
this.$router.push({ path: "/index" });
})
.catch(err => {
this.code = "";
this.getPicCode();
});
}else{
this.$message({
showClose: true,
message: "请输入完整信息",
type: "warning"
});
}
},
// 获取图形验证码
getPicCode() {
let url = "/api/user/get_verify";
post(url).then(res => {
this.imgCode = res.get_code;
this.sessionId = res.session_id;
});
}
},
mounted() {
this.getPicCode();
this.account = localStorage.getItem("account");
this.pwd = localStorage.getItem("pwd");
if (localStorage.getItem("checked")) {
this.checked = true;
}
}
};
</script>
<style>
.login_input .el-input__inner {
background-color: rgba(0, 0, 0, 0);
color: #fff !important;
padding: 0 20px;
caret-color: #fff;
}
.login_input .el-input__inner::placeholder,
.verification_input_l .el-input__inner::placeholder {
color: #fff !important;
}
.verification_input_l .el-input__inner {
background-color: rgba(0, 0, 0, 0);
color: #fff !important;
padding: 0 20px;
caret-color: #fff;
}
.remeber_pwd .el-checkbox {
color: #fff;
font-size: 14px;
}
.remeber_pwd .el-checkbox__inner {
border-radius: 3px;
border: 1px solid #f9f9f9;
background-color: rgba(0, 0, 0, 0);
}
.remeber_pwd .el-checkbox__input.is-focus .el-checkbox__inner {
border-color: #f9f9f9;
}
.remeber_pwd .el-checkbox__input.is-checked .el-checkbox__inner,
.remeber_pwd .el-checkbox__input.is-indeterminate .el-checkbox__inner {
background-color: rgba(0, 0, 0, 0);
border-color: #f9f9f9;
}
.remeber_pwd .el-checkbox__input.is-checked + .el-checkbox__label {
color: #fff;
}
</style>
<style scoped>
.login_wrap {
width: 100%;
height: 100vh;
background-image: url("../../assets/img_42.png");
background-repeat: no-repeat;
background-size: 100% 100%;
background-position: 0 0;
}
.login_box {
width: 540px;
height: 620px;
background-color: rgba(0, 0, 0, 0.2);
border-radius: 5px;
}
.login_main {
margin: 0 70px;
padding: 40px 0 60px;
}
/* 头像 */
.login_logo {
width: 106px;
margin: 0 auto;
}
/* 名称 */
.web_name {
font-size: 24px;
color: #fff;
text-align: center;
margin-top: 20px;
margin-bottom: 56px;
}
/* 输入框 */
.login_input {
border: 1px solid #f9f9f9;
border-radius: 3px;
position: relative;
margin-bottom: 36px;
}
.input_icon {
position: absolute;
right: 20px;
top: 50%;
width: 16px;
transform: translateY(-50%);
-o-transform: translateY(-50%);
-moz-transform: translateY(-50%);
-webkit-transform: translateY(-50%);
}
/* 图形验证码 */
.verification_input_l {
width: 254px;
border: 1px solid #f9f9f9;
border-radius: 3px;
position: relative;
}
.verification_code {
width: 126px;
height: 42px;
border-radius: 3px;
background-color: #fff;
}
/* 记住密码 */
.remeber_pwd {
padding-left: 10px;
margin: 20px 0;
}
/* 登录按钮 */
.login_btn {
width: 100%;
height: 38px;
background-color: #526aa6;
border-radius: 3px;
text-align: center;
line-height: 38px;
color: #fff;
font-size: 18px;
}
</style>