3
3
<vue-particle-line ></vue-particle-line >
4
4
<el-main class =" login-box" >
5
5
<h1 class =" title-1" >
6
- <img class =" logo" :src =" require('@/assets/logo.png')" alt =" " srcset =" " >
6
+ <img
7
+ class =" logo"
8
+ :src =" require('@/assets/logo.png')"
9
+ alt =" "
10
+ srcset =" "
11
+ />
7
12
</h1 >
8
- <el-form :model =" loginForm" :rules =" rules" ref =" loginForm" >
13
+ <el-form :model =" loginForm" :rules =" rules" ref =" loginForm" @keyup.enter.native = " submitForm " >
9
14
<el-form-item prop =" username" >
10
- <el-input placeholder =" 请输入用户名" v-model =" loginForm.username" ></el-input >
15
+ <el-input
16
+ placeholder =" 请输入用户名"
17
+ v-model =" loginForm.username"
18
+ ></el-input >
11
19
</el-form-item >
12
20
<el-form-item prop =" password" >
13
21
<el-input
14
- :type =" lock==='lock'? 'password': 'text'"
22
+ :type =" lock === 'lock' ? 'password' : 'text'"
15
23
placeholder =" 请输入密码"
16
24
v-model =" loginForm.password"
17
25
>
18
- <i :class =" 'el-input__icon el-icon-' + lock" @click =" changeLock" slot =" suffix" ></i >
26
+ <i
27
+ :class =" 'el-input__icon el-icon-' + lock"
28
+ @click =" changeLock"
29
+ slot =" suffix"
30
+ ></i >
19
31
</el-input >
20
32
</el-form-item >
21
33
<el-form-item style =" position :relative " >
25
37
placeholder =" 请输入验证码"
26
38
maxlength =" 10"
27
39
/>
28
- <img v-if =" picPath" :src =" path + picPath" alt =" 请输入验证码" @click =" loginVefify()" class =" vPic" >
40
+ <img
41
+ v-if =" picPath"
42
+ :src =" path + picPath"
43
+ alt =" 请输入验证码"
44
+ @click =" loginVefify()"
45
+ class =" vPic"
46
+ />
29
47
</el-form-item >
30
48
<el-form-item >
31
49
<el-button @click =" submitForm" style =" width :100% " >登 录</el-button >
37
55
</template >
38
56
39
57
<script >
40
- import { mapActions } from ' vuex'
41
- import { captcha } from ' @/api/user'
42
- const path = process .env .VUE_APP_BASE_API
58
+ import { mapActions } from " vuex" ;
59
+ import { captcha } from " @/api/user" ;
60
+ const path = process .env .VUE_APP_BASE_API ;
43
61
export default {
44
- name: ' Login' ,
62
+ name: " Login" ,
45
63
data () {
46
64
const checkUsername = (rule , value , callback ) => {
47
65
if (value .length < 5 || value .length > 12 ) {
48
- return callback (new Error (' 请输入正确的用户名' ))
66
+ return callback (new Error (" 请输入正确的用户名" ));
49
67
} else {
50
- callback ()
68
+ callback ();
51
69
}
52
- }
70
+ };
53
71
const checkPassword = (rule , value , callback ) => {
54
72
if (value .length < 6 || value .length > 12 ) {
55
- return callback (new Error (' 请输入正确的密码' ))
73
+ return callback (new Error (" 请输入正确的密码" ));
56
74
} else {
57
- callback ()
75
+ callback ();
58
76
}
59
- }
77
+ };
60
78
61
79
return {
62
- lock: ' lock' ,
80
+ lock: " lock" ,
63
81
loginForm: {
64
- username: ' ' ,
65
- password: ' ' ,
66
- captcha: ' ' ,
67
- captchaId: ' ' ,
82
+ username: " " ,
83
+ password: " " ,
84
+ captcha: " " ,
85
+ captchaId: " " ,
68
86
},
69
87
rules: {
70
- username: [{ validator: checkUsername, trigger: ' blur' }],
71
- password: [{ validator: checkPassword, trigger: ' blur' }]
88
+ username: [{ validator: checkUsername, trigger: " blur" }],
89
+ password: [{ validator: checkPassword, trigger: " blur" }],
72
90
},
73
- path: path,
74
- logVerify: ' ' ,
75
- picPath: ' '
76
- }
91
+ path: path,
92
+ logVerify: " " ,
93
+ picPath: " " ,
94
+ };
77
95
},
78
96
created () {
79
- this .loginVefify ()
97
+ this .loginVefify ();
80
98
},
81
99
methods: {
82
- ... mapActions (' user' , [' LoginIn' ]),
100
+ ... mapActions (" user" , [" LoginIn" ]),
83
101
async login () {
84
- await this .LoginIn (this .loginForm )
102
+ await this .LoginIn (this .loginForm );
85
103
},
86
104
async submitForm () {
87
- this .$refs .loginForm .validate (async v => {
105
+ this .$refs .loginForm .validate (async ( v ) => {
88
106
if (v) {
89
- this .login ()
90
- this .loginVefify ()
107
+ this .login ();
108
+ this .loginVefify ();
91
109
} else {
92
110
this .$message ({
93
- type: ' error' ,
94
- message: ' 请正确填写登录信息' ,
95
- showClose: true
96
- })
97
- this .loginVefify ()
98
- return false
111
+ type: " error" ,
112
+ message: " 请正确填写登录信息" ,
113
+ showClose: true ,
114
+ });
115
+ this .loginVefify ();
116
+ return false ;
99
117
}
100
- })
118
+ });
101
119
},
102
120
changeLock () {
103
- this .lock === ' lock' ? (this .lock = ' unlock' ) : (this .lock = ' lock' )
121
+ this .lock === " lock" ? (this .lock = " unlock" ) : (this .lock = " lock" );
104
122
},
105
123
loginVefify () {
106
- captcha ({}).then (ele => {
107
- this .picPath = ele .data .picPath
108
- this .loginForm .captchaId = ele .data .captchaId
109
- })
110
- }
111
- }
112
- }
124
+ captcha ({}).then (( ele ) => {
125
+ this .picPath = ele .data .picPath ;
126
+ this .loginForm .captchaId = ele .data .captchaId ;
127
+ });
128
+ },
129
+ },
130
+ };
113
131
</script >
114
132
115
133
<style scoped lang="scss">
@@ -121,16 +139,16 @@ export default {
121
139
position : absolute ;
122
140
left : 50% ;
123
141
margin-left : -22vw ;
124
- top :5vh ;
125
- .logo {
142
+ top : 5vh ;
143
+ .logo {
126
144
height : 35vh ;
127
145
width : 35vh ;
128
146
}
129
147
}
130
- .vPic {
148
+ .vPic {
131
149
position : absolute ;
132
150
right : 10px ;
133
- bottom : 0px ; // 适配ie
151
+ bottom : 0px ; // 适配ie
134
152
}
135
153
}
136
154
</style >
0 commit comments