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
794299a3
Commit
794299a3
authored
Feb 14, 2022
by
纪泽龙
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
根据权限展示大屏
parent
d2426e87
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 @
794299a3
<
template
>
<
template
>
<div
class=
"login"
>
<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>
<h3
class=
"title"
>
泽宏后台管理系统
</h3>
<el-form-item
prop=
"username"
>
<el-form-item
prop=
"username"
>
<el-input
v-model=
"loginForm.username"
type=
"text"
auto-complete=
"off"
placeholder=
"账号"
>
<el-input
<svg-icon
slot=
"prefix"
icon-class=
"user"
class=
"el-input__icon input-icon"
/>
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-input>
</el-form-item>
</el-form-item>
<el-form-item
prop=
"password"
>
<el-form-item
prop=
"password"
>
...
@@ -15,7 +29,11 @@
...
@@ -15,7 +29,11 @@
placeholder=
"密码"
placeholder=
"密码"
@
keyup
.
enter
.
native=
"handleLogin"
@
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-input>
</el-form-item>
</el-form-item>
<el-form-item
prop=
"code"
>
<el-form-item
prop=
"code"
>
...
@@ -26,19 +44,27 @@
...
@@ -26,19 +44,27 @@
style=
"width: 63%"
style=
"width: 63%"
@
keyup
.
enter
.
native=
"handleLogin"
@
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>
</el-input>
<div
class=
"login-code"
>
<div
class=
"login-code"
>
<img
:src=
"codeUrl"
@
click=
"getCode"
class=
"login-code-img"
/>
<img
:src=
"codeUrl"
@
click=
"getCode"
class=
"login-code-img"
/>
</div>
</div>
</el-form-item>
</el-form-item>
<el-checkbox
v-model=
"loginForm.rememberMe"
style=
"margin:0px 0px 25px 0px;"
>
记住密码
</el-checkbox>
<el-checkbox
<el-form-item
style=
"width:100%;"
>
v-model=
"loginForm.rememberMe"
style=
"margin: 0px 0px 25px 0px"
>
记住密码
</el-checkbox
>
<el-form-item
style=
"width: 100%"
>
<el-button
<el-button
:loading=
"loading"
:loading=
"loading"
size=
"medium"
size=
"medium"
type=
"primary"
type=
"primary"
style=
"width:
100%;
"
style=
"width:
100%
"
@
click
.
native
.
prevent=
"handleLogin"
@
click
.
native
.
prevent=
"handleLogin"
>
>
<span
v-if=
"!loading"
>
登 录
</span>
<span
v-if=
"!loading"
>
登 录
</span>
...
@@ -54,9 +80,9 @@
...
@@ -54,9 +80,9 @@
</
template
>
</
template
>
<
script
>
<
script
>
import
{
getCodeImg
}
from
"@/api/login"
;
import
{
getCodeImg
,
getInfo
}
from
"@/api/login"
;
import
Cookies
from
"js-cookie"
;
import
Cookies
from
"js-cookie"
;
import
{
encrypt
,
decrypt
}
from
'@/utils/jsencrypt'
import
{
encrypt
,
decrypt
}
from
"@/utils/jsencrypt"
;
export
default
{
export
default
{
name
:
"Login"
,
name
:
"Login"
,
...
@@ -69,29 +95,30 @@ export default {
...
@@ -69,29 +95,30 @@ export default {
password
:
"admin123"
,
password
:
"admin123"
,
rememberMe
:
false
,
rememberMe
:
false
,
code
:
""
,
code
:
""
,
uuid
:
""
uuid
:
""
,
},
},
loginRules
:
{
loginRules
:
{
username
:
[
username
:
[
{
required
:
true
,
trigger
:
"blur"
,
message
:
"用户名不能为空"
}
{
required
:
true
,
trigger
:
"blur"
,
message
:
"用户名不能为空"
}
,
],
],
password
:
[
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
,
loading
:
false
,
redirect
:
undefined
redirect
:
undefined
,
};
};
},
},
watch
:
{
watch
:
{
$route
:
{
$route
:
{
handler
:
function
(
route
)
{
handler
:
function
(
route
)
{
this
.
redirect
=
route
.
query
&&
route
.
query
.
redirect
;
this
.
redirect
=
route
.
query
&&
route
.
query
.
redirect
;
},
},
immediate
:
true
immediate
:
true
,
}
}
,
},
},
created
()
{
created
()
{
this
.
getCode
();
this
.
getCode
();
...
@@ -99,7 +126,7 @@ export default {
...
@@ -99,7 +126,7 @@ export default {
},
},
methods
:
{
methods
:
{
getCode
()
{
getCode
()
{
getCodeImg
().
then
(
res
=>
{
getCodeImg
().
then
(
(
res
)
=>
{
this
.
codeUrl
=
"data:image/gif;base64,"
+
res
.
img
;
this
.
codeUrl
=
"data:image/gif;base64,"
+
res
.
img
;
this
.
loginForm
.
uuid
=
res
.
uuid
;
this
.
loginForm
.
uuid
=
res
.
uuid
;
});
});
...
@@ -107,36 +134,55 @@ export default {
...
@@ -107,36 +134,55 @@ export default {
getCookie
()
{
getCookie
()
{
const
username
=
Cookies
.
get
(
"username"
);
const
username
=
Cookies
.
get
(
"username"
);
const
password
=
Cookies
.
get
(
"password"
);
const
password
=
Cookies
.
get
(
"password"
);
const
rememberMe
=
Cookies
.
get
(
'rememberMe'
)
const
rememberMe
=
Cookies
.
get
(
"rememberMe"
);
this
.
loginForm
=
{
this
.
loginForm
=
{
username
:
username
===
undefined
?
this
.
loginForm
.
username
:
username
,
username
:
username
===
undefined
?
this
.
loginForm
.
username
:
username
,
password
:
password
===
undefined
?
this
.
loginForm
.
password
:
decrypt
(
password
),
password
:
rememberMe
:
rememberMe
===
undefined
?
false
:
Boolean
(
rememberMe
)
password
===
undefined
?
this
.
loginForm
.
password
:
decrypt
(
password
),
rememberMe
:
rememberMe
===
undefined
?
false
:
Boolean
(
rememberMe
),
};
};
},
},
handleLogin
()
{
handleLogin
()
{
this
.
$refs
.
loginForm
.
validate
(
valid
=>
{
this
.
$refs
.
loginForm
.
validate
(
(
valid
)
=>
{
if
(
valid
)
{
if
(
valid
)
{
this
.
loading
=
true
;
this
.
loading
=
true
;
if
(
this
.
loginForm
.
rememberMe
)
{
if
(
this
.
loginForm
.
rememberMe
)
{
Cookies
.
set
(
"username"
,
this
.
loginForm
.
username
,
{
expires
:
30
});
Cookies
.
set
(
"username"
,
this
.
loginForm
.
username
,
{
expires
:
30
});
Cookies
.
set
(
"password"
,
encrypt
(
this
.
loginForm
.
password
),
{
expires
:
30
});
Cookies
.
set
(
"password"
,
encrypt
(
this
.
loginForm
.
password
),
{
Cookies
.
set
(
'rememberMe'
,
this
.
loginForm
.
rememberMe
,
{
expires
:
30
});
expires
:
30
,
});
Cookies
.
set
(
"rememberMe"
,
this
.
loginForm
.
rememberMe
,
{
expires
:
30
,
});
}
else
{
}
else
{
Cookies
.
remove
(
"username"
);
Cookies
.
remove
(
"username"
);
Cookies
.
remove
(
"password"
);
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
}).
catch
(()
=>
{});
this
.
$router
.
push
({
path
:
"/bigWindow"
||
"/"
}).
catch
(()
=>
{});
})
})
.
catch
(()
=>
{
.
catch
(()
=>
{
this
.
loading
=
false
;
this
.
loading
=
false
;
this
.
getCode
();
this
.
getCode
();
});
});
}
}
});
});
}
}
,
}
}
,
};
};
</
script
>
</
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