Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Sign in / Register
Toggle navigation
A
amap-road-edit
Project overview
Project overview
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
feng
amap-road-edit
Commits
02cc76ce
Commit
02cc76ce
authored
Jul 09, 2019
by
aoobao
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix axios
parent
f7ee02a5
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
37 additions
and
4 deletions
+37
-4
src/assets/js/axios.js
src/assets/js/axios.js
+31
-2
src/assets/js/importAMap.js
src/assets/js/importAMap.js
+4
-2
src/assets/setting.js
src/assets/setting.js
+2
-0
No files found.
src/assets/js/axios.js
View file @
02cc76ce
...
...
@@ -15,6 +15,7 @@ let baseAxios = axios.create({
})
let
__token
=
null
let
__http_one_only
=
false
// 发送信息钩子
baseAxios
.
interceptors
.
request
.
use
(
...
...
@@ -46,7 +47,9 @@ baseAxios.interceptors.response.use(
}
)
baseAxios
.
getUrl
=
(
url
,
params
=
{})
=>
{
baseAxios
.
getUrl
=
(
url
,
params
=
{},
{
showErrflag
=
true
})
=>
{
return
new
Promise
(
resolve
=>
{
baseAxios
.
get
(
url
,
{
...
...
@@ -55,6 +58,13 @@ baseAxios.getUrl = (url, params = {}) => {
.
then
(
response
=>
{
let
retData
=
response
.
data
if
(
retData
.
code
!==
0
)
{
console
.
warn
(
url
,
params
,
retData
)
}
retData
.
isok
=
(
retData
.
code
===
0
)
if
(
showErrflag
)
{
ifErr
(
retData
)
}
resolve
(
retData
)
},
error
=>
{
...
...
@@ -66,7 +76,10 @@ baseAxios.getUrl = (url, params = {}) => {
})
}
baseAxios
.
postUrl
=
(
url
,
data
=
{},
showErrflag
=
true
)
=>
{
baseAxios
.
postUrl
=
(
url
,
data
=
{},
{
showErrflag
=
true
,
postOne
=
false
})
=>
{
let
headers
=
{}
let
opts
=
data
if
(
Object
.
prototype
.
toString
.
call
(
data
)
!==
'
[object FormData]
'
)
{
...
...
@@ -76,6 +89,15 @@ baseAxios.postUrl = (url, data = {}, showErrflag = true) => {
headers
[
'
Content-Type
'
]
=
'
multipart/form-data
'
}
if
(
postOne
)
{
// 已经有请求存在
if
(
__http_one_only
)
{
errMessage
(
'
请求中,请稍后...
'
)
return
}
__http_one_only
=
true
}
return
new
Promise
(
resolve
=>
{
baseAxios
.
post
(
url
,
opts
,
{
...
...
@@ -83,16 +105,23 @@ baseAxios.postUrl = (url, data = {}, showErrflag = true) => {
})
.
then
(
response
=>
{
if
(
postOne
)
{
__http_one_only
=
false
}
let
retData
=
response
.
data
if
(
retData
.
code
!=
0
)
{
console
.
warn
(
url
,
data
,
retData
)
}
retData
.
isok
=
(
retData
.
code
===
0
)
if
(
showErrflag
)
{
ifErr
(
retData
)
}
resolve
(
retData
)
},
error
=>
{
if
(
postOne
)
{
__http_one_only
=
false
}
console
.
warn
(
error
)
let
errData
=
res
.
error
(
'
服务器错误
'
,
-
1
,
error
)
resolve
(
errData
)
...
...
src/assets/js/importAMap.js
View file @
02cc76ce
import
{
AMAP_KEY
,
AMAP_VERSION
AMAP_VERSION
,
AMAP_PLUGIN
}
from
'
@/assets/setting
'
let
_callback
=
[]
...
...
@@ -23,7 +24,8 @@ export default function requireAMap(callback) {
}
if
(
!
isLoad
)
{
isLoad
=
true
let
url
=
`https://webapi.amap.com/maps?v=
${
AMAP_VERSION
}
&key=
${
AMAP_KEY
}
&callback=__AMAP_CALLBACK`
;
let
url
=
`https://webapi.amap.com/maps?v=
${
AMAP_VERSION
}
&key=
${
AMAP_KEY
}
&plugin=
${
AMAP_PLUGIN
}
&callback=__AMAP_CALLBACK`
;
let
jsapi
=
document
.
createElement
(
'
script
'
);
jsapi
.
charset
=
'
utf-8
'
;
...
...
src/assets/setting.js
View file @
02cc76ce
...
...
@@ -2,6 +2,8 @@
export
const
AMAP_KEY
=
'
104a0cc0ce15a396dde189f4f7d438ff
'
// 高德地图版本号
export
const
AMAP_VERSION
=
'
1.4.14
'
// 高德地图插件
export
const
AMAP_PLUGIN
=
null
// 'AMap.MarkerClusterer'
// 适配rem (用到宽和html默认font-size) rem 1 = 100px
export
const
SCREEN_WIDTH
=
1920
export
const
SCREEN_HEIGHT
=
1080
...
...
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