Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
D
diseaseControlManage
Overview
Overview
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
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
diseaseControlManage-Develop
diseaseControlManage
Commits
95796231
Commit
95796231
authored
Nov 07, 2020
by
huqc
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
验证码功能
parent
6839c0dd
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
43 additions
and
31 deletions
+43
-31
src/api/userlogin.js
+17
-6
src/components/UserLogin.vue
+22
-21
src/utils/request.js
+4
-4
No files found.
src/api/userlogin.js
View file @
95796231
import
request
from
'@/utils/request'
import
request
from
'@/utils/request'
//登录、修改密码
//登录、修改密码
//
const webUrl = 'http://localhost:168/fyglAPP/';
const
webUrl
=
'http://localhost:168/fyglAPP/'
;
const
webUrl
=
'http://192.168.3.110:8999/diseaseControlManage/'
;
//
const webUrl = 'http://192.168.3.110:8999/diseaseControlManage/';
// const webUrl = 'http://195.1.3.38:8999/diseaseControlManage/';
// const webUrl = 'http://195.1.3.38:8999/diseaseControlManage/';
export
function
login
(
loginID
,
loginPas
)
{
export
function
login
(
loginID
,
loginPas
)
{
return
request
({
return
request
({
...
@@ -18,12 +18,17 @@ export function login(loginID, loginPas) {
...
@@ -18,12 +18,17 @@ export function login(loginID, loginPas) {
})
})
}
}
//图形码验证
//图形码验证
export
function
getCode
(
yzm
){
export
function
getCode
(
yzm
,
t
){
var
t
=
(
new
Date
).
getTime
();
//每次点击重新取个随机数
return
request
({
return
request
({
url
:
'http://192.168.3.110:8999/diseaseControlManage/
api/login/verify?t='
+
t
+
'&code='
+
yzm
,
url
:
webUrl
+
'
api/login/verify?t='
+
t
+
'&code='
+
yzm
,
method
:
'post'
,
method
:
'post'
,
async
:
false
,
//同步
headers
:{
'Content-Type'
:
'application/json'
,
"Accept"
:
"*/*"
},
data
:
JSON
.
stringify
({
})
})
})
}
}
...
@@ -44,3 +49,9 @@ export function updatePassword(uid,pwdold,pwdnew) {
...
@@ -44,3 +49,9 @@ export function updatePassword(uid,pwdold,pwdnew) {
})
})
})
})
}
}
//更换验证码
export
function
changeCode
(
data
)
{
let
imgUrl
=
webUrl
+
`api/login/captcha?t=
${
data
}
`
;
return
imgUrl
}
src/components/UserLogin.vue
View file @
95796231
...
@@ -18,7 +18,7 @@
...
@@ -18,7 +18,7 @@
maxlength=
"8"
maxlength=
"8"
style=
"width: 130px;display: inline-block;margin: 0px 12px 0px 0px;"
style=
"width: 130px;display: inline-block;margin: 0px 12px 0px 0px;"
></el-input>
></el-input>
<img
src=
""
ref=
"code"
@
click=
"changeCode
"
height=
"40"
>
<img
:src=
"imgUrl"
@
click=
"changeImg()
"
height=
"40"
>
</div>
</div>
<div
class=
"PassAbout"
>
<div
class=
"PassAbout"
>
...
@@ -36,7 +36,7 @@
...
@@ -36,7 +36,7 @@
</
template
>
</
template
>
<
script
>
<
script
>
import
{
getCode
,
login
}
from
'@/api/userlogin.js'
import
{
getCode
,
login
,
changeCode
}
from
'@/api/userlogin.js'
export
default
{
export
default
{
data
()
{
data
()
{
...
@@ -48,7 +48,10 @@
...
@@ -48,7 +48,10 @@
checked
:
false
,
checked
:
false
,
captcha_key
:
""
,
captcha_key
:
""
,
captcha_code
:
""
,
captcha_code
:
""
,
value2
:
''
value2
:
''
,
t
:(
new
Date
).
getTime
(),
imgUrl
:
''
,
imgData
:
''
}
}
},
},
methods
:
{
methods
:
{
...
@@ -69,14 +72,14 @@
...
@@ -69,14 +72,14 @@
let
_this
=
this
let
_this
=
this
getCode
(
this
.
captcha_code
).
then
(
res
=>
{
getCode
(
this
.
captcha_code
,
this
.
imgData
).
then
(
res
=>
{
console
.
log
(
res
)
if
(
res
==
undefined
){
console
.
log
(
"登录报错!"
);
this
.
$message
.
error
(
'验证码错误'
);
}).
catch
(
err
=>
{
return
false
// console.log("登录报错!");
}
})
// 用户登录
// 用户登录
login
(
this
.
loginID
,
this
.
$md5
(
this
.
loginPas
)).
then
(
res
=>
{
login
(
this
.
loginID
,
this
.
$md5
(
this
.
loginPas
)).
then
(
res
=>
{
console
.
log
(
res
)
//login(this.loginID,this.loginPas).then( res=>{
//login(this.loginID,this.loginPas).then( res=>{
if
(
res
.
code
==
1
)
{
if
(
res
.
code
==
1
)
{
...
@@ -118,22 +121,20 @@
...
@@ -118,22 +121,20 @@
}).
catch
(
err
=>
{
}).
catch
(
err
=>
{
console
.
log
(
"登录报错!"
);
console
.
log
(
"登录报错!"
);
})
})
},
return
false
}).
catch
(
err
=>
{
console
.
log
(
"登录报错!"
);
//更换验证码
})
changeCode
()
{
this
.
$refs
.
code
.
setAttribute
(
"src"
,
'http://192.168.3.110:8999/diseaseControlManage/api/login/captcha'
+
'?t='
+
(
new
Date
).
getTime
()
);
},
changeImg
(){
this
.
imgData
=
(
new
Date
).
getTime
();
this
.
imgUrl
=
changeCode
(
this
.
imgData
);
}
}
},
},
mounted
()
{
mounted
()
{
this
.
$refs
.
code
.
setAttribute
(
this
.
imgData
=
(
new
Date
).
getTime
()
"src"
,
'http://192.168.3.110:8999/diseaseControlManage/api/login/captcha'
this
.
imgUrl
=
changeCode
(
this
.
imgData
);
);
if
(
sessionStorage
.
getItem
(
'userID'
)
&&
sessionStorage
.
getItem
(
'userPas'
))
{
if
(
sessionStorage
.
getItem
(
'userID'
)
&&
sessionStorage
.
getItem
(
'userPas'
))
{
// 若 local 存在即自动跳转
// 若 local 存在即自动跳转
...
...
src/utils/request.js
View file @
95796231
...
@@ -61,10 +61,10 @@ service.interceptors.response.use(
...
@@ -61,10 +61,10 @@ service.interceptors.response.use(
}
}
}
}
}
else
{
}
else
{
Notification
.
error
({
//
Notification.error({
title
:
'接口请求失败'
,
//
title: '接口请求失败',
duration
:
5000
//
duration: 5000
})
//
})
}
}
...
...
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