Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
Y
yangpu
Project
Project
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
郭铭瑶
yangpu
Commits
490b471e
Commit
490b471e
authored
Jul 22, 2021
by
郭铭瑶
🤘
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
网格相关请求添加自定义headers
parent
83cbb3d5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
27 additions
and
20 deletions
+27
-20
main.js
src/main.js
+0
-1
ajax.js
src/server/ajax.js
+5
-1
api.js
src/server/api.js
+4
-0
actions.js
src/store/actions.js
+17
-17
main.vue
src/views/main.vue
+1
-1
No files found.
src/main.js
View file @
490b471e
// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import
'babel-polyfill'
import
Vue
from
'vue'
import
App
from
'./App'
import
router
from
'./router'
...
...
src/server/ajax.js
View file @
490b471e
...
...
@@ -32,7 +32,7 @@ Axios.interceptors.response.use(response => {
* @param {String} contentType [请求头,默认为'application/json;charset=UTF-8']
* @param {Boolean} showLoading [是否显示请求时的loading图,默认为false]
*/
const
request
=
({
method
,
url
,
params
=
{},
contentType
=
'application/json;charset=UTF-8'
,
showLoading
=
false
})
=>
{
const
request
=
({
method
,
url
,
params
=
{},
contentType
=
'application/json;charset=UTF-8'
,
showLoading
=
false
,
headers
=
{}
})
=>
{
if
(
!
url
||
typeof
(
url
)
!=
'string'
)
{
throw
new
Error
(
'接口URL不正确'
)
}
...
...
@@ -42,6 +42,7 @@ const request = ({ method, url, params = {}, contentType = 'application/json;cha
headers
:
{
'X-Requested-With'
:
'XMLHttpRequest'
,
'Content-Type'
:
contentType
,
...
headers
},
}
if
(
method
===
'GET'
)
{
...
...
@@ -60,6 +61,9 @@ const request = ({ method, url, params = {}, contentType = 'application/json;cha
}
export
default
{
fetch
(
args
)
{
// only for 网格相关请求需自定义headers(即api.DATA_URL开头的api)
return
request
({
method
:
'GET'
,
...
args
,
headers
:
api
.
GRID_OPTION
})
},
get
(
args
)
{
return
request
({
method
:
'GET'
,
...
args
})
},
...
...
src/server/api.js
View file @
490b471e
...
...
@@ -14,6 +14,10 @@ default:
// BASE_URL = 'http://yangpu.hm.omniview.pro/api' // 废弃
}
export
default
{
GRID_OPTION
:
{
// 网格相关请求需要添加的headers内容
user
:
'linkthings'
,
pwd
:
'2EBC694BBBA02355AA8B7FE0F03ECB52'
,
},
MAP_NET
,
BASE_URL
,
DATA_URL
,
...
...
src/store/actions.js
View file @
490b471e
...
...
@@ -29,9 +29,9 @@ export default {
},
async
getGreenInfo
({
commit
})
{
const
result
=
[
{
name
:
'环卫公厕'
,
value
:
await
ajax
.
get
({
url
:
api
.
DATA_URL
+
api
.
GET_TOILET_COUNT
,
params
:
{
street
:
curStreet
}})
||
0
},
{
name
:
'生活垃圾收集'
,
value
:
await
ajax
.
get
({
url
:
api
.
DATA_URL
+
api
.
GET_GARBAGE_COUNT
,
params
:
{
street
:
curStreet
}})
||
0
},
{
name
:
'小型压缩站'
,
value
:
await
ajax
.
get
({
url
:
api
.
DATA_URL
+
api
.
GET_COMPRESS_COUNT
,
params
:
{
street
:
curStreet
}})
||
0
},
{
name
:
'环卫公厕'
,
value
:
await
ajax
.
fetch
({
url
:
api
.
DATA_URL
+
api
.
GET_TOILET_COUNT
,
params
:
{
street
:
curStreet
}})
||
0
},
{
name
:
'生活垃圾收集'
,
value
:
await
ajax
.
fetch
({
url
:
api
.
DATA_URL
+
api
.
GET_GARBAGE_COUNT
,
params
:
{
street
:
curStreet
}})
||
0
},
{
name
:
'小型压缩站'
,
value
:
await
ajax
.
fetch
({
url
:
api
.
DATA_URL
+
api
.
GET_COMPRESS_COUNT
,
params
:
{
street
:
curStreet
}})
||
0
},
]
commit
(
'SET_GREEN_INFO'
,
result
)
},
...
...
@@ -80,24 +80,24 @@ export default {
async
getGridSum
({
commit
})
{
const
start
=
moment
().
format
(
'YYYY-MM-DD'
)
const
end
=
moment
().
add
(
1
,
'days'
).
format
(
'YYYY-MM-DD'
)
const
grid1
=
await
ajax
.
get
({
url
:
api
.
DATA_URL
+
api
.
GET_GRID1
,
params
:
{
street
:
curStreet
,
start
,
end
}})
const
grid2
=
await
ajax
.
get
({
url
:
api
.
DATA_URL
+
api
.
GET_GRID2
,
params
:
{
street
:
curStreet
,
start
,
end
}})
const
grid3
=
await
ajax
.
get
({
url
:
api
.
DATA_URL
+
api
.
GET_GRID3
,
params
:
{
street
:
curStreet
,
start
,
end
}})
const
grid4
=
await
ajax
.
get
({
url
:
api
.
DATA_URL
+
api
.
GET_GRID4
,
params
:
{
street
:
curStreet
,
start
,
end
}})
const
grid5
=
await
ajax
.
get
({
url
:
api
.
DATA_URL
+
api
.
GET_GRID5
,
params
:
{
street
:
curStreet
,
start
,
end
}})
const
grid6
=
await
ajax
.
get
({
url
:
api
.
DATA_URL
+
api
.
GET_GRID6
,
params
:
{
street
:
curStreet
,
start
,
end
}})
const
grid1
=
await
ajax
.
fetch
({
url
:
api
.
DATA_URL
+
api
.
GET_GRID1
,
params
:
{
street
:
curStreet
,
start
,
end
}})
const
grid2
=
await
ajax
.
fetch
({
url
:
api
.
DATA_URL
+
api
.
GET_GRID2
,
params
:
{
street
:
curStreet
,
start
,
end
}})
const
grid3
=
await
ajax
.
fetch
({
url
:
api
.
DATA_URL
+
api
.
GET_GRID3
,
params
:
{
street
:
curStreet
,
start
,
end
}})
const
grid4
=
await
ajax
.
fetch
({
url
:
api
.
DATA_URL
+
api
.
GET_GRID4
,
params
:
{
street
:
curStreet
,
start
,
end
}})
const
grid5
=
await
ajax
.
fetch
({
url
:
api
.
DATA_URL
+
api
.
GET_GRID5
,
params
:
{
street
:
curStreet
,
start
,
end
}})
const
grid6
=
await
ajax
.
fetch
({
url
:
api
.
DATA_URL
+
api
.
GET_GRID6
,
params
:
{
street
:
curStreet
,
start
,
end
}})
commit
(
'SET_GRID_SUM'
,
[
+
grid1
||
0
,
+
grid2
||
0
,
+
grid3
||
0
,
+
grid4
||
0
,
+
grid5
||
0
,
+
grid6
||
0
])
const
alert1
=
await
ajax
.
get
({
url
:
api
.
DATA_URL
+
api
.
GET_NOT_ALERT1
,
params
:
{
street
:
curStreet
,
start
,
end
}})
const
alert2
=
await
ajax
.
get
({
url
:
api
.
DATA_URL
+
api
.
GET_NOT_ALERT2
,
params
:
{
street
:
curStreet
,
start
,
end
}})
const
alert3
=
await
ajax
.
get
({
url
:
api
.
DATA_URL
+
api
.
GET_NOT_ALERT3
,
params
:
{
street
:
curStreet
,
start
,
end
}})
const
alert4
=
await
ajax
.
get
({
url
:
api
.
DATA_URL
+
api
.
GET_NOT_ALERT4
,
params
:
{
street
:
curStreet
,
start
,
end
}})
const
alert5
=
await
ajax
.
get
({
url
:
api
.
DATA_URL
+
api
.
GET_NOT_ALERT5
,
params
:
{
street
:
curStreet
,
start
,
end
}})
const
alert6
=
await
ajax
.
get
({
url
:
api
.
DATA_URL
+
api
.
GET_NOT_ALERT6
,
params
:
{
street
:
curStreet
,
start
,
end
}})
const
alert1
=
await
ajax
.
fetch
({
url
:
api
.
DATA_URL
+
api
.
GET_NOT_ALERT1
,
params
:
{
street
:
curStreet
,
start
,
end
}})
const
alert2
=
await
ajax
.
fetch
({
url
:
api
.
DATA_URL
+
api
.
GET_NOT_ALERT2
,
params
:
{
street
:
curStreet
,
start
,
end
}})
const
alert3
=
await
ajax
.
fetch
({
url
:
api
.
DATA_URL
+
api
.
GET_NOT_ALERT3
,
params
:
{
street
:
curStreet
,
start
,
end
}})
const
alert4
=
await
ajax
.
fetch
({
url
:
api
.
DATA_URL
+
api
.
GET_NOT_ALERT4
,
params
:
{
street
:
curStreet
,
start
,
end
}})
const
alert5
=
await
ajax
.
fetch
({
url
:
api
.
DATA_URL
+
api
.
GET_NOT_ALERT5
,
params
:
{
street
:
curStreet
,
start
,
end
}})
const
alert6
=
await
ajax
.
fetch
({
url
:
api
.
DATA_URL
+
api
.
GET_NOT_ALERT6
,
params
:
{
street
:
curStreet
,
start
,
end
}})
commit
(
'SET_NOT_ALERT_SUM'
,
[
+
alert1
||
0
,
+
alert2
||
0
,
+
alert3
||
0
,
+
alert4
||
0
,
+
alert5
||
0
,
+
alert6
||
0
])
},
async
getPopulationInfo
({
commit
})
{
const
year1
=
await
ajax
.
get
({
url
:
api
.
DATA_URL
+
api
.
GET_POPULATION_INFO
,
params
:
{
year
:
moment
().
add
(
-
2
,
'y'
).
format
(
'YYYY'
)}})
const
year2
=
await
ajax
.
get
({
url
:
api
.
DATA_URL
+
api
.
GET_POPULATION_INFO
,
params
:
{
year
:
moment
().
add
(
-
1
,
'y'
).
format
(
'YYYY'
)}})
const
year1
=
await
ajax
.
fetch
({
url
:
api
.
DATA_URL
+
api
.
GET_POPULATION_INFO
,
params
:
{
year
:
moment
().
add
(
-
2
,
'y'
).
format
(
'YYYY'
)}})
const
year2
=
await
ajax
.
fetch
({
url
:
api
.
DATA_URL
+
api
.
GET_POPULATION_INFO
,
params
:
{
year
:
moment
().
add
(
-
1
,
'y'
).
format
(
'YYYY'
)}})
if
(
year1
&&
year2
)
{
const
result
=
[
year1
,
year2
].
map
(
year
=>
year
.
find
(
item
=>
item
.
street
==
'总计'
))
commit
(
'SET_LAND_POPULATION_INFO'
,
result
)
...
...
src/views/main.vue
View file @
490b471e
...
...
@@ -268,7 +268,7 @@ export default {
this
.
removeSelectedGridLayer
()
const
[
paths
]
=
geometry
.
rings
this
.
selectedGridArea
=
map
.
addPolygon
({
paths
,
fillColor
:
'rgba(255,235,59,.15)'
})
this
.
$ajax
.
get
({
this
.
$ajax
.
fetch
({
url
:
this
.
$api
.
DATA_URL
+
this
.
$api
.
GET_GRID_PERSON
,
params
:
{
street
:
this
.
currentStreetInfo
.
name
,
gridId
:
+
attributes
[
'网格编'
]},
showLoading
:
true
,
...
...
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