|
|
@@ -10,40 +10,90 @@
|
|
10
|
10
|
</div>
|
|
11
|
11
|
<!-- 右侧 -->
|
|
12
|
12
|
<div class="rightBox">
|
|
13
|
|
- <el-form ref="loginForm" :model="loginForm" :rules="loginRules" class="login-form">
|
|
|
13
|
+ <el-form
|
|
|
14
|
+ ref="loginForm"
|
|
|
15
|
+ :model="loginForm"
|
|
|
16
|
+ :rules="loginRules"
|
|
|
17
|
+ class="login-form"
|
|
|
18
|
+ >
|
|
14
|
19
|
<h2 class="title">用户登录</h2>
|
|
15
|
20
|
<el-form-item prop="username">
|
|
16
|
|
- <el-input v-model="loginForm.username" type="text" auto-complete="off" placeholder="账号">
|
|
17
|
|
- <svg-icon slot="prefix" icon-class="user" class="el-input__icon input-icon" />
|
|
|
21
|
+ <el-input
|
|
|
22
|
+ v-model="loginForm.username"
|
|
|
23
|
+ type="text"
|
|
|
24
|
+ auto-complete="off"
|
|
|
25
|
+ placeholder="账号"
|
|
|
26
|
+ >
|
|
|
27
|
+ <svg-icon
|
|
|
28
|
+ slot="prefix"
|
|
|
29
|
+ icon-class="user"
|
|
|
30
|
+ class="el-input__icon input-icon"
|
|
|
31
|
+ />
|
|
18
|
32
|
</el-input>
|
|
19
|
33
|
</el-form-item>
|
|
20
|
34
|
<el-form-item prop="password">
|
|
21
|
|
- <el-input v-model="loginForm.password" type="password" auto-complete="off" placeholder="密码"
|
|
22
|
|
- @keyup.enter.native="handleLogin">
|
|
23
|
|
- <svg-icon slot="prefix" icon-class="password" class="el-input__icon input-icon" />
|
|
|
35
|
+ <el-input
|
|
|
36
|
+ v-model="loginForm.password"
|
|
|
37
|
+ type="password"
|
|
|
38
|
+ auto-complete="off"
|
|
|
39
|
+ placeholder="密码"
|
|
|
40
|
+ @keyup.enter.native="handleLogin"
|
|
|
41
|
+ >
|
|
|
42
|
+ <svg-icon
|
|
|
43
|
+ slot="prefix"
|
|
|
44
|
+ icon-class="password"
|
|
|
45
|
+ class="el-input__icon input-icon"
|
|
|
46
|
+ />
|
|
24
|
47
|
</el-input>
|
|
25
|
48
|
</el-form-item>
|
|
26
|
49
|
<el-form-item prop="code" v-if="captchaEnabled">
|
|
27
|
|
- <el-input v-model="loginForm.code" auto-complete="off" placeholder="验证码" style="width: 63%"
|
|
28
|
|
- @keyup.enter.native="handleLogin">
|
|
29
|
|
- <svg-icon slot="prefix" icon-class="validCode" class="el-input__icon input-icon" />
|
|
|
50
|
+ <el-input
|
|
|
51
|
+ v-model="loginForm.code"
|
|
|
52
|
+ auto-complete="off"
|
|
|
53
|
+ placeholder="验证码"
|
|
|
54
|
+ style="width: 63%"
|
|
|
55
|
+ @keyup.enter.native="handleLogin"
|
|
|
56
|
+ >
|
|
|
57
|
+ <svg-icon
|
|
|
58
|
+ slot="prefix"
|
|
|
59
|
+ icon-class="validCode"
|
|
|
60
|
+ class="el-input__icon input-icon"
|
|
|
61
|
+ />
|
|
30
|
62
|
</el-input>
|
|
31
|
63
|
<div class="login-code">
|
|
32
|
64
|
<img :src="codeUrl" @click="getCode" class="login-code-img" />
|
|
33
|
65
|
</div>
|
|
34
|
66
|
</el-form-item>
|
|
35
|
|
- <el-checkbox v-model="loginForm.rememberMe" style="margin:0px 0px 25px 0px;">记住密码</el-checkbox>
|
|
36
|
|
- <el-form-item style="width:100%;">
|
|
37
|
|
- <el-button :loading="loading" size="medium" type="primary" style="width:100%;"
|
|
38
|
|
- @click.native.prevent="handleLogin">
|
|
|
67
|
+ <el-checkbox
|
|
|
68
|
+ v-model="loginForm.rememberMe"
|
|
|
69
|
+ style="margin: 0px 0px 25px 0px"
|
|
|
70
|
+ >记住密码</el-checkbox
|
|
|
71
|
+ >
|
|
|
72
|
+ <el-form-item style="width: 100%">
|
|
|
73
|
+ <el-button
|
|
|
74
|
+ :loading="loading"
|
|
|
75
|
+ size="medium"
|
|
|
76
|
+ type="primary"
|
|
|
77
|
+ style="width: 100%"
|
|
|
78
|
+ @click.native.prevent="handleLogin"
|
|
|
79
|
+ >
|
|
39
|
80
|
<span v-if="!loading">登 录</span>
|
|
40
|
81
|
<span v-else>登 录 中...</span>
|
|
41
|
82
|
</el-button>
|
|
42
|
|
- <div style="float: right;" v-if="register">
|
|
|
83
|
+ <div style="float: right" v-if="register">
|
|
43
|
84
|
<!-- <router-link class="link-type" :to="'/register'">立即注册</router-link> -->
|
|
44
|
|
- <el-button type="text" @click="registrationLink('/register')">立即注册</el-button>
|
|
|
85
|
+ <el-button type="text" @click="registrationLink('/register')"
|
|
|
86
|
+ >立即注册</el-button
|
|
|
87
|
+ >
|
|
45
|
88
|
</div>
|
|
46
|
|
- <div class="registerImg">
|
|
|
89
|
+ <div class="registerImg" v-if="closeImgs">
|
|
|
90
|
+ <div class="closeImg" @click="closeImg">
|
|
|
91
|
+ <img
|
|
|
92
|
+ style="width: 25px; height: 25px"
|
|
|
93
|
+ src="../assets/images/closed.png"
|
|
|
94
|
+ alt=""
|
|
|
95
|
+ />
|
|
|
96
|
+ </div>
|
|
47
|
97
|
<div id="qrcodeImg"></div>
|
|
48
|
98
|
</div>
|
|
49
|
99
|
</el-form-item>
|
|
|
@@ -59,38 +109,45 @@
|
|
59
|
109
|
</template>
|
|
60
|
110
|
|
|
61
|
111
|
<script>
|
|
62
|
|
-import { getCodeImg, selectIdentityAuthenticaEIDtoken } from "@/api/login";
|
|
|
112
|
+import {
|
|
|
113
|
+ getCodeImg,
|
|
|
114
|
+ selectIdentityAuthenticaEIDtoken,
|
|
|
115
|
+ selectPCEIDtokenStatus,
|
|
|
116
|
+} from "@/api/login";
|
|
63
|
117
|
import Cookies from "js-cookie";
|
|
64
|
118
|
import QRCode from "qrcodejs2";
|
|
65
|
|
-import { encrypt, decrypt } from '@/utils/jsencrypt'
|
|
|
119
|
+import { encrypt, decrypt } from "@/utils/jsencrypt";
|
|
66
|
120
|
|
|
67
|
121
|
export default {
|
|
68
|
122
|
name: "Login",
|
|
69
|
123
|
data() {
|
|
70
|
124
|
return {
|
|
71
|
125
|
codeUrl: "",
|
|
|
126
|
+ closeImgs: false,
|
|
|
127
|
+ timer: null,
|
|
|
128
|
+ pathVal:"",
|
|
72
|
129
|
loginForm: {
|
|
73
|
130
|
username: "admin",
|
|
74
|
131
|
password: "admin123",
|
|
75
|
132
|
rememberMe: false,
|
|
76
|
133
|
code: "",
|
|
77
|
|
- uuid: ""
|
|
|
134
|
+ uuid: "",
|
|
78
|
135
|
},
|
|
79
|
136
|
loginRules: {
|
|
80
|
137
|
username: [
|
|
81
|
|
- { required: true, trigger: "blur", message: "请输入您的账号" }
|
|
|
138
|
+ { required: true, trigger: "blur", message: "请输入您的账号" },
|
|
82
|
139
|
],
|
|
83
|
140
|
password: [
|
|
84
|
|
- { required: true, trigger: "blur", message: "请输入您的密码" }
|
|
|
141
|
+ { required: true, trigger: "blur", message: "请输入您的密码" },
|
|
85
|
142
|
],
|
|
86
|
|
- code: [{ required: true, trigger: "change", message: "请输入验证码" }]
|
|
|
143
|
+ code: [{ required: true, trigger: "change", message: "请输入验证码" }],
|
|
87
|
144
|
},
|
|
88
|
145
|
loading: false,
|
|
89
|
146
|
// 验证码开关
|
|
90
|
147
|
captchaEnabled: true,
|
|
91
|
148
|
// 注册开关
|
|
92
|
149
|
register: true,
|
|
93
|
|
- redirect: undefined
|
|
|
150
|
+ redirect: undefined,
|
|
94
|
151
|
};
|
|
95
|
152
|
},
|
|
96
|
153
|
watch: {
|
|
|
@@ -98,8 +155,8 @@ export default {
|
|
98
|
155
|
handler: function (route) {
|
|
99
|
156
|
this.redirect = route.query && route.query.redirect;
|
|
100
|
157
|
},
|
|
101
|
|
- immediate: true
|
|
102
|
|
- }
|
|
|
158
|
+ immediate: true,
|
|
|
159
|
+ },
|
|
103
|
160
|
},
|
|
104
|
161
|
created() {
|
|
105
|
162
|
this.getCode();
|
|
|
@@ -107,8 +164,9 @@ export default {
|
|
107
|
164
|
},
|
|
108
|
165
|
methods: {
|
|
109
|
166
|
getCode() {
|
|
110
|
|
- getCodeImg().then(res => {
|
|
111
|
|
- this.captchaEnabled = res.captchaEnabled === undefined ? true : res.captchaEnabled;
|
|
|
167
|
+ getCodeImg().then((res) => {
|
|
|
168
|
+ this.captchaEnabled =
|
|
|
169
|
+ res.captchaEnabled === undefined ? true : res.captchaEnabled;
|
|
112
|
170
|
if (this.captchaEnabled) {
|
|
113
|
171
|
this.codeUrl = "data:image/gif;base64," + res.img;
|
|
114
|
172
|
this.loginForm.uuid = res.uuid;
|
|
|
@@ -118,40 +176,54 @@ export default {
|
|
118
|
176
|
getCookie() {
|
|
119
|
177
|
const username = Cookies.get("username");
|
|
120
|
178
|
const password = Cookies.get("password");
|
|
121
|
|
- const rememberMe = Cookies.get('rememberMe')
|
|
|
179
|
+ const rememberMe = Cookies.get("rememberMe");
|
|
122
|
180
|
this.loginForm = {
|
|
123
|
181
|
username: username === undefined ? this.loginForm.username : username,
|
|
124
|
|
- password: password === undefined ? this.loginForm.password : decrypt(password),
|
|
125
|
|
- rememberMe: rememberMe === undefined ? false : Boolean(rememberMe)
|
|
|
182
|
+ password:
|
|
|
183
|
+ password === undefined ? this.loginForm.password : decrypt(password),
|
|
|
184
|
+ rememberMe: rememberMe === undefined ? false : Boolean(rememberMe),
|
|
126
|
185
|
};
|
|
127
|
186
|
},
|
|
128
|
187
|
handleLogin() {
|
|
129
|
|
- this.$refs.loginForm.validate(valid => {
|
|
|
188
|
+ this.$refs.loginForm.validate((valid) => {
|
|
130
|
189
|
if (valid) {
|
|
131
|
190
|
this.loading = true;
|
|
132
|
191
|
if (this.loginForm.rememberMe) {
|
|
133
|
192
|
Cookies.set("username", this.loginForm.username, { expires: 30 });
|
|
134
|
|
- Cookies.set("password", encrypt(this.loginForm.password), { expires: 30 });
|
|
135
|
|
- Cookies.set('rememberMe', this.loginForm.rememberMe, { expires: 30 });
|
|
|
193
|
+ Cookies.set("password", encrypt(this.loginForm.password), {
|
|
|
194
|
+ expires: 30,
|
|
|
195
|
+ });
|
|
|
196
|
+ Cookies.set("rememberMe", this.loginForm.rememberMe, {
|
|
|
197
|
+ expires: 30,
|
|
|
198
|
+ });
|
|
136
|
199
|
} else {
|
|
137
|
200
|
Cookies.remove("username");
|
|
138
|
201
|
Cookies.remove("password");
|
|
139
|
|
- Cookies.remove('rememberMe');
|
|
|
202
|
+ Cookies.remove("rememberMe");
|
|
140
|
203
|
}
|
|
141
|
|
- this.$store.dispatch("Login", this.loginForm).then(() => {
|
|
142
|
|
- this.$router.push({ path: this.redirect || "/" }).catch(() => { });
|
|
143
|
|
- }).catch(() => {
|
|
144
|
|
- this.loading = false;
|
|
145
|
|
- if (this.captchaEnabled) {
|
|
146
|
|
- this.getCode();
|
|
147
|
|
- }
|
|
148
|
|
- });
|
|
|
204
|
+ this.$store
|
|
|
205
|
+ .dispatch("Login", this.loginForm)
|
|
|
206
|
+ .then(() => {
|
|
|
207
|
+ this.$router.push({ path: this.redirect || "/" }).catch(() => {});
|
|
|
208
|
+ })
|
|
|
209
|
+ .catch(() => {
|
|
|
210
|
+ this.loading = false;
|
|
|
211
|
+ if (this.captchaEnabled) {
|
|
|
212
|
+ this.getCode();
|
|
|
213
|
+ }
|
|
|
214
|
+ });
|
|
149
|
215
|
}
|
|
150
|
216
|
});
|
|
151
|
217
|
},
|
|
152
|
218
|
registrationLink(path) {
|
|
153
|
|
- selectIdentityAuthenticaEIDtoken().then(res => {
|
|
154
|
|
- let url = res.data.eidToken
|
|
|
219
|
+ this.pathVal = path;
|
|
|
220
|
+ clearInterval(this.timer);
|
|
|
221
|
+ selectIdentityAuthenticaEIDtoken().then((res) => {
|
|
|
222
|
+ // this.timer = setInterval(() => {
|
|
|
223
|
+ // this.getSelectPCEIDtokenStatus(res.data.eidToken);
|
|
|
224
|
+ // }, 1000);
|
|
|
225
|
+ this.closeImgs = true;
|
|
|
226
|
+ let url = res.data.eidToken;
|
|
155
|
227
|
document.getElementById("qrcodeImg").innerHTML = "";
|
|
156
|
228
|
return new QRCode("qrcodeImg", {
|
|
157
|
229
|
width: 200,
|
|
|
@@ -160,9 +232,25 @@ export default {
|
|
160
|
232
|
colorDark: "#000",
|
|
161
|
233
|
colorLight: "#fff",
|
|
162
|
234
|
});
|
|
163
|
|
- })
|
|
|
235
|
+ });
|
|
164
|
236
|
// this.$router.push(path);
|
|
165
|
|
- console.log("注册链接")
|
|
|
237
|
+ },
|
|
|
238
|
+ // H5轮询获取E证通Token状态
|
|
|
239
|
+ getSelectPCEIDtokenStatus(data) {
|
|
|
240
|
+ selectPCEIDtokenStatus(data).then((res) => {
|
|
|
241
|
+ this.$router.push(this.pathVal);
|
|
|
242
|
+ });
|
|
|
243
|
+ },
|
|
|
244
|
+ // 关闭弹框
|
|
|
245
|
+ closeImg() {
|
|
|
246
|
+ clearInterval(this.timer)
|
|
|
247
|
+ this.closeImgs = false;
|
|
|
248
|
+ },
|
|
|
249
|
+ },
|
|
|
250
|
+ beforeDestroy() {
|
|
|
251
|
+ // 清除计时器
|
|
|
252
|
+ if (this.timer) {
|
|
|
253
|
+ clearInterval(this.timer);
|
|
166
|
254
|
}
|
|
167
|
255
|
}
|
|
168
|
256
|
};
|
|
|
@@ -279,11 +367,10 @@ export default {
|
|
279
|
367
|
}
|
|
280
|
368
|
|
|
281
|
369
|
.registerImg {
|
|
282
|
|
- border: 1px solid black;
|
|
|
370
|
+ border: 1px solid #c0c0c0;
|
|
283
|
371
|
width: 350px;
|
|
284
|
372
|
height: 250px;
|
|
285
|
373
|
}
|
|
286
|
|
-
|
|
287
|
374
|
.login-code-img {
|
|
288
|
375
|
height: 38px;
|
|
289
|
376
|
}
|