Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
mingPayPc
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
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
fengzhaoyu
mingPayPc
Commits
3d68bb63
Commit
3d68bb63
authored
Dec 07, 2019
by
liang ce
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
router 判断
parent
22251945
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
22 additions
and
33 deletions
+22
-33
axios.js
src/api/axios.js
+22
-33
No files found.
src/api/axios.js
View file @
3d68bb63
...
...
@@ -28,13 +28,18 @@ axios.interceptors.request.use((config) => {
})
// 配置请求返回的拦截器,
axios
.
interceptors
.
response
.
use
(
res
=>
{
// if (res.data.code === 0 || res.data.resultCode === 0) {
// store.dispatch('setSpinning', false)
return
Promise
.
resolve
(
res
)
// } else if (res.data.code === 40003 || res.data.resultCode === 40003) {
// message.error('权限不足')
// if (res.data.resultCode === 0) {
// return Promise.resolve(res)
// } else {
// return Promise.reject()
// }
if
(
res
.
data
.
code
===
0
||
res
.
data
.
resultCode
===
0
)
{
store
.
dispatch
(
'setSpinning'
,
false
)
return
Promise
.
resolve
(
res
)
}
else
if
(
res
.
data
.
code
===
40003
||
res
.
data
.
resultCode
===
40003
)
{
message
.
error
(
'权限不足'
)
return
Promise
.
reject
(
'1'
)
}
},
err
=>
{
return
new
Promise
((
resolve
,
reject
)
=>
{
console
.
log
(
err
)
...
...
@@ -75,22 +80,22 @@ axios.interceptors.response.use(res => {
const
$http
=
{
post
:
(
url
,
data
)
=>
{
return
new
Promise
((
resolve
,
reject
)
=>
{
// let postData
// if (data === undefined) {
// postData = {
// orgId: localStorage.getItem('orgId')
// }
// } else {
// postData = data
// postData.orgId = localStorage.getItem('orgId')
// }
let
postData
=
data
===
undefined
?
''
:
data
axios
.
post
(
`
${
BASE_URL
}${
url
}
`
,
postData
,
{
headers
:
{
'Content-Type'
:
'application/json; charset=UTF-8'
}
}).
then
((
res
)
=>
{
console
.
log
(
res
.
data
,
res
.
data
.
code
,
res
.
data
.
resultCode
)
if
(
res
.
data
.
code
===
0
||
res
.
data
.
resultCode
===
0
)
{
store
.
dispatch
(
'setSpinning'
,
false
)
return
Promise
.
resolve
(
res
)
}
else
if
(
res
.
data
.
code
===
40003
||
res
.
data
.
resultCode
===
40003
)
{
message
.
error
(
'权限不足'
)
return
Promise
.
reject
()
}
}).
catch
((
err
)
=>
{
console
.
log
(
err
)
return
resolve
(
res
)
})
})
},
...
...
@@ -98,15 +103,7 @@ const $http = {
return
new
Promise
((
resolve
,
reject
)
=>
{
let
getData
=
data
===
undefined
?
''
:
qs
.
stringify
(
data
)
axios
.
get
(
`
${
BASE_URL
}${
url
}
?
${
getData
}
`
).
then
((
res
)
=>
{
if
(
res
.
data
.
code
===
0
||
res
.
data
.
resultCode
===
0
)
{
store
.
dispatch
(
'setSpinning'
,
false
)
return
Promise
.
resolve
(
res
)
}
else
if
(
res
.
data
.
code
===
40003
||
res
.
data
.
resultCode
===
40003
)
{
message
.
error
(
'权限不足'
)
return
Promise
.
reject
()
}
}).
catch
((
err
)
=>
{
console
.
log
(
err
)
return
resolve
(
res
)
})
})
},
...
...
@@ -114,15 +111,7 @@ const $http = {
return
new
Promise
((
resolve
,
reject
)
=>
{
let
getData
=
data
===
undefined
?
''
:
qs
.
stringify
(
data
)
axios
.
delete
(
`
${
BASE_URL
}${
url
}
?
${
getData
}
`
).
then
((
res
)
=>
{
if
(
res
.
data
.
code
===
0
||
res
.
data
.
resultCode
===
0
)
{
store
.
dispatch
(
'setSpinning'
,
false
)
return
Promise
.
resolve
(
res
)
}
else
if
(
res
.
data
.
code
===
40003
||
res
.
data
.
resultCode
===
40003
)
{
message
.
error
(
'权限不足'
)
return
Promise
.
reject
()
}
}).
catch
((
err
)
=>
{
console
.
log
(
err
)
return
resolve
(
res
)
})
})
}
...
...
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