Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gassafety-progress
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
耿迪迪
gassafety-progress
Commits
414d5665
Commit
414d5665
authored
Feb 14, 2022
by
王晓倩
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote-tracking branch 'origin/master'
parents
48a83927
794299a3
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
82 additions
and
36 deletions
+82
-36
login.vue
gassafetyprogress-web/src/views/login.vue
+82
-36
No files found.
gassafetyprogress-web/src/views/login.vue
View file @
414d5665
<
template
>
<div
class=
"login"
>
<el-form
ref=
"loginForm"
:model=
"loginForm"
:rules=
"loginRules"
class=
"login-form"
>
<el-form
ref=
"loginForm"
:model=
"loginForm"
:rules=
"loginRules"
class=
"login-form"
>
<h3
class=
"title"
>
泽宏后台管理系统
</h3>
<el-form-item
prop=
"username"
>
<el-input
v-model=
"loginForm.username"
type=
"text"
auto-complete=
"off"
placeholder=
"账号"
>
<svg-icon
slot=
"prefix"
icon-class=
"user"
class=
"el-input__icon input-icon"
/>
<el-input
v-model=
"loginForm.username"
type=
"text"
auto-complete=
"off"
placeholder=
"账号"
>
<svg-icon
slot=
"prefix"
icon-class=
"user"
class=
"el-input__icon input-icon"
/>
</el-input>
</el-form-item>
<el-form-item
prop=
"password"
>
...
...
@@ -15,7 +29,11 @@
placeholder=
"密码"
@
keyup
.
enter
.
native=
"handleLogin"
>
<svg-icon
slot=
"prefix"
icon-class=
"password"
class=
"el-input__icon input-icon"
/>
<svg-icon
slot=
"prefix"
icon-class=
"password"
class=
"el-input__icon input-icon"
/>
</el-input>
</el-form-item>
<el-form-item
prop=
"code"
>
...
...
@@ -26,19 +44,27 @@
style=
"width: 63%"
@
keyup
.
enter
.
native=
"handleLogin"
>
<svg-icon
slot=
"prefix"
icon-class=
"validCode"
class=
"el-input__icon input-icon"
/>
<svg-icon
slot=
"prefix"
icon-class=
"validCode"
class=
"el-input__icon input-icon"
/>
</el-input>
<div
class=
"login-code"
>
<img
:src=
"codeUrl"
@
click=
"getCode"
class=
"login-code-img"
/>
<img
:src=
"codeUrl"
@
click=
"getCode"
class=
"login-code-img"
/>
</div>
</el-form-item>
<el-checkbox
v-model=
"loginForm.rememberMe"
style=
"margin:0px 0px 25px 0px;"
>
记住密码
</el-checkbox>
<el-form-item
style=
"width:100%;"
>
<el-checkbox
v-model=
"loginForm.rememberMe"
style=
"margin: 0px 0px 25px 0px"
>
记住密码
</el-checkbox
>
<el-form-item
style=
"width: 100%"
>
<el-button
:loading=
"loading"
size=
"medium"
type=
"primary"
style=
"width:
100%;
"
style=
"width:
100%
"
@
click
.
native
.
prevent=
"handleLogin"
>
<span
v-if=
"!loading"
>
登 录
</span>
...
...
@@ -54,9 +80,9 @@
</
template
>
<
script
>
import
{
getCodeImg
}
from
"@/api/login"
;
import
{
getCodeImg
,
getInfo
}
from
"@/api/login"
;
import
Cookies
from
"js-cookie"
;
import
{
encrypt
,
decrypt
}
from
'@/utils/jsencrypt'
import
{
encrypt
,
decrypt
}
from
"@/utils/jsencrypt"
;
export
default
{
name
:
"Login"
,
...
...
@@ -69,29 +95,30 @@ export default {
password
:
"admin123"
,
rememberMe
:
false
,
code
:
""
,
uuid
:
""
uuid
:
""
,
},
loginRules
:
{
username
:
[
{
required
:
true
,
trigger
:
"blur"
,
message
:
"用户名不能为空"
}
{
required
:
true
,
trigger
:
"blur"
,
message
:
"用户名不能为空"
}
,
],
password
:
[
{
required
:
true
,
trigger
:
"blur"
,
message
:
"密码不能为空"
}
{
required
:
true
,
trigger
:
"blur"
,
message
:
"密码不能为空"
},
],
code
:
[
{
required
:
true
,
trigger
:
"change"
,
message
:
"验证码不能为空"
},
],
code
:
[{
required
:
true
,
trigger
:
"change"
,
message
:
"验证码不能为空"
}]
},
loading
:
false
,
redirect
:
undefined
redirect
:
undefined
,
};
},
watch
:
{
$route
:
{
handler
:
function
(
route
)
{
handler
:
function
(
route
)
{
this
.
redirect
=
route
.
query
&&
route
.
query
.
redirect
;
},
immediate
:
true
}
immediate
:
true
,
}
,
},
created
()
{
this
.
getCode
();
...
...
@@ -99,7 +126,7 @@ export default {
},
methods
:
{
getCode
()
{
getCodeImg
().
then
(
res
=>
{
getCodeImg
().
then
(
(
res
)
=>
{
this
.
codeUrl
=
"data:image/gif;base64,"
+
res
.
img
;
this
.
loginForm
.
uuid
=
res
.
uuid
;
});
...
...
@@ -107,36 +134,55 @@ export default {
getCookie
()
{
const
username
=
Cookies
.
get
(
"username"
);
const
password
=
Cookies
.
get
(
"password"
);
const
rememberMe
=
Cookies
.
get
(
'rememberMe'
)
const
rememberMe
=
Cookies
.
get
(
"rememberMe"
);
this
.
loginForm
=
{
username
:
username
===
undefined
?
this
.
loginForm
.
username
:
username
,
password
:
password
===
undefined
?
this
.
loginForm
.
password
:
decrypt
(
password
),
rememberMe
:
rememberMe
===
undefined
?
false
:
Boolean
(
rememberMe
)
password
:
password
===
undefined
?
this
.
loginForm
.
password
:
decrypt
(
password
),
rememberMe
:
rememberMe
===
undefined
?
false
:
Boolean
(
rememberMe
),
};
},
handleLogin
()
{
this
.
$refs
.
loginForm
.
validate
(
valid
=>
{
this
.
$refs
.
loginForm
.
validate
(
(
valid
)
=>
{
if
(
valid
)
{
this
.
loading
=
true
;
if
(
this
.
loginForm
.
rememberMe
)
{
Cookies
.
set
(
"username"
,
this
.
loginForm
.
username
,
{
expires
:
30
});
Cookies
.
set
(
"password"
,
encrypt
(
this
.
loginForm
.
password
),
{
expires
:
30
});
Cookies
.
set
(
'rememberMe'
,
this
.
loginForm
.
rememberMe
,
{
expires
:
30
});
Cookies
.
set
(
"password"
,
encrypt
(
this
.
loginForm
.
password
),
{
expires
:
30
,
});
Cookies
.
set
(
"rememberMe"
,
this
.
loginForm
.
rememberMe
,
{
expires
:
30
,
});
}
else
{
Cookies
.
remove
(
"username"
);
Cookies
.
remove
(
"password"
);
Cookies
.
remove
(
'rememberMe'
);
Cookies
.
remove
(
"rememberMe"
);
}
this
.
$store
.
dispatch
(
"Login"
,
this
.
loginForm
)
.
then
((
res
)
=>
{
console
.
log
(
"登录"
,
res
);
// 获取权限
return
getInfo
();
})
.
then
((
res
)
=>
{
const
roles
=
res
.
user
.
deptId
;
let
path
=
"/"
;
// 如果是最高权限,就进入大屏
if
(
roles
==
-
2
)
{
path
=
"/bigWindow"
;
}
this
.
$store
.
dispatch
(
"Login"
,
this
.
loginForm
).
then
(()
=>
{
this
.
$router
.
push
({
path
:
"/bigWindow"
||
"/"
}).
catch
(()
=>
{});
})
.
catch
(()
=>
{
this
.
$router
.
push
({
path
}).
catch
(()
=>
{});
})
.
catch
(()
=>
{
this
.
loading
=
false
;
this
.
getCode
();
});
}
});
}
}
}
,
}
,
};
</
script
>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment