Toggle navigation
Toggle navigation
This project
Loading...
Sign in
Hooke
/
tswj
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Builds
Commits
Issue Boards
Authored by
hookehuyr
2022-06-29 22:37:54 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
83e58a87ddfba6afaa233401401de45d0718c8db
83e58a87
1 parent
a945bf1c
写法优化
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
6 additions
and
15 deletions
src/utils/axios.js
src/utils/tools.js
src/utils/axios.js
View file @
83e58a8
...
...
@@ -2,13 +2,12 @@
* @Author: hookehuyr hookehuyr@gmail.com
* @Date: 2022-05-28 10:17:40
* @LastEditors: hookehuyr hookehuyr@gmail.com
* @LastEditTime: 2022-06-2
2 09:22:56
* @LastEditTime: 2022-06-2
9 22:32:15
* @FilePath: /tswj/src/utils/axios.js
* @Description:
*/
import
axios
from
'axios'
;
import
router
from
'@/router'
;
import
_
from
'lodash'
import
qs
from
'Qs'
// import { parseQueryString } from '@/utils/tools'
...
...
@@ -25,20 +24,13 @@ axios.interceptors.request.use(
// GET请求默认打上时间戳,避免从缓存中拿数据。
const
timestamp
=
config
.
method
===
'get'
?
(
new
Date
()).
valueOf
()
:
''
;
// 上传相关接口需要屏蔽掉封装, 不能序列化数据会报错。
if
(
config
.
method
===
'post'
&&
(
config
.
url
.
indexOf
(
'a=upload'
)
===
-
1
&&
config
.
url
.
indexOf
(
'upload.qiniup.com'
)
===
-
1
)
)
{
const
excludeUrl
=
[
'a=upload'
,
'upload.qiniup.com'
];
if
(
config
.
method
===
'post'
&&
!
excludeUrl
.
includes
(
config
.
url
))
{
// POST PHP需要修改数据格式
config
.
data
=
qs
.
stringify
(
config
.
data
)
}
// 绑定默认请求头
config
.
params
=
_
.
merge
(
config
.
params
,
{
timestamp
,
})
config
.
params
=
{
...
config
.
params
,
timestamp
}
return
config
;
},
error
=>
{
...
...
@@ -55,7 +47,7 @@ axios.interceptors.response.use(
response
.
data
.
show
=
true
;
// 判断微信授权状态,进入页面时未授权需要授权跳转
// C/B 授权拼接头特殊标识,openid_x
let
prefixAPI
=
router
&&
router
.
currentRoute
.
value
.
href
?.
indexOf
(
'business'
)
>
0
?
'b'
:
'c'
;
let
prefixAPI
=
router
?
.
currentRoute
.
value
.
href
?.
indexOf
(
'business'
)
>
0
?
'b'
:
'c'
;
if
(
response
.
data
.
code
===
401
)
{
// 特殊标识-带此标识报错不显示
response
.
data
.
show
=
false
;
...
...
src/utils/tools.js
View file @
83e58a8
/*
* @Date: 2022-04-18 15:59:42
* @LastEditors: hookehuyr hookehuyr@gmail.com
* @LastEditTime: 2022-06-
15 18:29:40
* @LastEditTime: 2022-06-
29 22:35:51
* @FilePath: /tswj/src/utils/tools.js
* @Description: 文件描述
*/
import
moment
from
'moment'
;
import
{
ref
}
from
'vue'
// 格式化时间
const
formatDate
=
(
date
)
=>
{
...
...
Please
register
or
login
to post a comment