Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
mancheng_code
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
hanxiao
mancheng_code
Commits
5b8b032a
Commit
5b8b032a
authored
Apr 01, 2024
by
heshihao
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: 修改接口信息
parent
5756fbc0
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
22 additions
and
18 deletions
+22
-18
src/utils/http.js
+22
-18
No files found.
src/utils/http.js
View file @
5b8b032a
...
...
@@ -8,7 +8,7 @@ const service = axios.create({
// baseURL: '',
timeout
:
2000
*
1000
,
});
let
url
=
""
;
let
url
=
"
/api
"
;
// url = 'http://192.168.31.154:5000'
url
=
"https://mancheng.industrychain.online"
;
let
baseURL
=
url
;
...
...
@@ -17,6 +17,8 @@ let baseURL2 = "https://zysf-store.oss-cn-beijing.aliyuncs.com";
let
baseURL3
=
url
;
let
baseURL4
=
"http://39.100.39.50:8006"
;
export
const
baseURL5
=
"/prod-api"
;
// 2.请求拦截器
service
.
interceptors
.
request
.
use
(
(
config
)
=>
{
...
...
@@ -33,9 +35,9 @@ service.interceptors.request.use(
case
"api4"
:
config
.
url
=
baseURL4
+
config
.
url
;
break
;
//
case "api5":
// config.url =
baseURL5 + config.url;
//
break;
case
"api5"
:
config
.
url
=
baseURL
+
baseURL5
+
config
.
url
;
break
;
default
:
config
.
url
=
baseURL
+
config
.
url
;
}
...
...
@@ -51,13 +53,15 @@ service.interceptors.request.use(
// config.params = { 'token': token } //如果要求携带在参数中
config
.
headers
.
token
=
token
;
//如果要求携带在请求头中
}
// if (config.url == `${baseURL5}/common/upload`) {
// config.headers = {
// token: localStorage.getItem("token"),
// "Content-Type": "multipart/form-data",
// };
// return config;
// }
if
(
config
.
url
==
"/api/user/login_bypwd"
)
{
return
config
;
}
else
if
(
config
.
url
==
`
${
baseURL5
}
/common/upload`
)
{
config
.
headers
=
{
token
:
localStorage
.
getItem
(
"token"
),
"Content-Type"
:
"multipart/form-data"
,
};
return
config
;
}
return
config
;
},
(
error
)
=>
{
...
...
@@ -74,7 +78,7 @@ service.interceptors.response.use(
return
response
.
data
;
}
if
(
response
.
data
.
code
==
0
)
{
return
response
.
data
.
data
||
{
success
:
1
,
data
:
response
.
data
};
return
response
.
data
.
data
||
response
.
data
||
{
success
:
1
,
data
:
response
.
data
};
}
if
(
response
.
data
.
code
==
4101
)
{
router
.
replace
({
path
:
"/login"
});
...
...
@@ -82,7 +86,7 @@ service.interceptors.response.use(
return
""
;
}
if
(
response
.
data
.
code
==
200
)
{
return
response
.
data
.
data
||
{
success
:
1
};
return
response
.
data
.
data
||
response
.
data
||
{
success
:
1
};
}
// if (response.data.code == 4002) {
// return response.data.data || { status: 2, msg: '请先登录' }
...
...
@@ -148,11 +152,11 @@ service.interceptors.response.use(
/**
* 暂时屏蔽报错
*/
if
(
JSON
.
stringify
(
error
).
includes
(
"timeout"
))
{
error
.
message
=
"服务器响应超时,请刷新当前页"
;
// Message.error('服务器响应超时,请刷新当前页')
return
Promise
.
resolve
(
error
.
response
);
}
//
if (JSON.stringify(error).includes("timeout")) {
//
error.message = "服务器响应超时,请刷新当前页";
//
// Message.error('服务器响应超时,请刷新当前页')
//
return Promise.resolve(error.response);
//
}
}
Message
.
error
(
error
.
message
);
...
...
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