Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
B
BCDH-APP
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
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
首开风险隐患双控平台
BCDH-APP
Commits
f9adf94c
Commit
f9adf94c
authored
Oct 21, 2021
by
13841799530
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
token接口联调
解润东 20211021
parent
79930953
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
26 additions
and
42 deletions
+26
-42
src/utils/axios.js
src/utils/axios.js
+7
-18
src/views/Login2.vue
src/views/Login2.vue
+11
-23
src/views/checked/index.vue
src/views/checked/index.vue
+8
-1
No files found.
src/utils/axios.js
View file @
f9adf94c
...
...
@@ -7,8 +7,9 @@
* 版权所有,侵权必究!
*/
import
axios
from
'
axios
'
import
{
Toast
}
from
'
vant
'
import
router
from
'
../router
'
import
{
Notify
}
from
'
vant
'
;
import
{
getToken
}
from
'
@/utils/auth
'
// get token from cookie
const
service
=
axios
.
create
({
baseURL
:
'
/hse/app-api
'
,
//前缀路径
...
...
@@ -21,7 +22,7 @@ const service = axios.create({
//拦截接口请求
service
.
interceptors
.
request
.
use
(
config
=>
{
if
(
getToken
())
{
config
.
headers
[
'
X-T
oken
'
]
=
getToken
()
config
.
headers
[
'
t
oken
'
]
=
getToken
()
}
return
config
},
error
=>
{
...
...
@@ -34,27 +35,15 @@ service.interceptors.response.use(response => {
if
(
code
==
200
)
{
//请求响应码200 代表已经请求到接口
if
(
res
.
code
===
0
)
{
//接口响应码0 代表接口代码运行正常
return
res
}
else
{
this
.
$notify
({
message
:
'
失败
'
,
background
:
'
red
'
,
duration
:
1000
})
}
else
if
(
res
.
code
===
301
){
Notify
({
type
:
'
danger
'
,
message
:
res
.
msg
});
}
}
else
{
this
.
$notify
({
message
:
'
失败
'
,
background
:
'
red
'
,
duration
:
1000
})
Notify
({
type
:
'
danger
'
,
message
:
'
失败
'
});
Promise
.
reject
(
new
Error
(
'
Error
'
))
}
},
err
=>
{
this
.
$notify
({
message
:
'
失败
'
,
background
:
'
red
'
,
duration
:
1000
})
Notify
({
type
:
'
danger
'
,
message
:
'
失败
'
});
return
Promise
.
reject
(
err
)
})
...
...
src/views/Login2.vue
View file @
f9adf94c
...
...
@@ -65,29 +65,17 @@ export default {
},
methods
:
{
onSubmit
(
values
)
{
if
(
values
.
username
==
'
admin
'
&&
values
.
password
==
'
123456
'
){
getFun
(
'
check/token
'
,{
a
:
122
}).
then
((
Response
)
=>
{
if
(
Response
.
code
==
0
){
this
.
$notify
({
message
:
'
登录成功
'
,
background
:
'
green
'
,
duration
:
1000
})
setToken
(
Response
.
data
)
this
.
$router
.
push
(
'
/message-center
'
)
}
})
// localStorage.setItem('admin_token','2dsfewr')
// this.$router.push('/MessageCenter')
// location.reload();
}
else
{
this
.
$notify
({
message
:
'
账号或密码不正确
'
,
background
:
'
red
'
,
duration
:
1000
})
}
getFun
(
'
check/token
'
,
values
).
then
((
Response
)
=>
{
if
(
Response
.
code
==
0
){
this
.
$notify
({
message
:
'
登录成功
'
,
background
:
'
green
'
,
duration
:
1000
})
setToken
(
Response
.
data
)
this
.
$router
.
push
(
'
/message-center
'
)
}
})
}
}
};
...
...
src/views/checked/index.vue
View file @
f9adf94c
...
...
@@ -38,6 +38,7 @@
<
script
>
import
LHeader
from
'
@/components/header.vue
'
import
{
getFun
,
postFun
}
from
'
@/service/table
'
export
default
{
name
:
'
checked
'
,
components
:
{
...
...
@@ -50,9 +51,15 @@ export default {
}
},
mounted
()
{
this
.
list
()
},
methods
:
{
list
(){
getFun
(
'
check/carry/user/list
'
).
then
((
Response
)
=>
{
console
.
log
(
Response
)
})
},
onSearch
(){
this
.
$toast
(
'
提示内容
'
)
},
...
...
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