Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
B
binhai-people
Project
Project
Details
Activity
Releases
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
binhai-jiaoguan
binhai-people
Commits
09cad903
Commit
09cad903
authored
Nov 21, 2023
by
高滢
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
首页天气
parent
adb50d16
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
24 additions
and
11 deletions
+24
-11
baidu.js
src/api/baidu.js
+9
-1
header.vue
src/layout/components/header.vue
+14
-10
index.vue
src/views/Home/index.vue
+1
-0
No files found.
src/api/baidu.js
View file @
09cad903
import
request
from
"@/utils/request-baidu"
;
import
request
from
'@/utils/request-baidu'
export
function
getWeather
()
{
return
request
({
...
...
@@ -110,3 +110,11 @@ export function walkingPlanning(origin, destination, origin_uid, destination_uid
}
})
}
export
function
headerWeather
(
params
)
{
return
request
({
url
:
'/weather/v1/'
,
method
:
'get'
,
params
:
params
})
}
src/layout/components/header.vue
View file @
09cad903
...
...
@@ -33,6 +33,7 @@
import
Cookies
from
'js-cookie'
import
logo
from
'@/assets/image/logo.png'
import
axios
from
'axios'
import
{
headerWeather
}
from
'@/api/baidu'
export
default
{
data
()
{
...
...
@@ -61,17 +62,20 @@ export default {
data_type
:
'all'
,
ak
:
'bSlMW0ziNWrg8TjNzUKZpLE9iGcS3jc2'
}
headerWeather
(
params
).
then
(
response
=>
{
this
.
weatherCondition
=
response
.
result
.
forecasts
this
.
weatherNow
=
response
.
result
.
now
})
// 将 params 对象传递给 GET 请求
axios
.
get
(
`
${
process
.
env
.
VUE_APP_BAIDU_API
}
weather/v1/`
,
{
params
})
.
then
(
response
=>
{
console
.
log
(
'11111'
,
response
)
this
.
weatherCondition
=
response
.
data
.
result
.
forecasts
this
.
weatherNow
=
response
.
data
.
result
.
now
})
.
catch
(
error
=>
{
console
.
error
(
error
)
})
//
axios.get(`${process.env.VUE_APP_BAIDU_API}weather/v1/`, { params })
//
.then(response => {
//
console.log('11111', response)
//
this.weatherCondition = response.data.result.forecasts
//
this.weatherNow = response.data.result.now
//
})
//
.catch(error => {
//
console.error(error)
//
})
},
toHome
()
{
if
(
this
.
$route
.
path
!==
'/Home'
)
{
...
...
src/views/Home/index.vue
View file @
09cad903
...
...
@@ -299,6 +299,7 @@ import NavList from '@/views/Home/components/NavList/index.vue'
import
{
getTrafficInfoList
,
getroadConditions
}
from
'@/views/trafficInformation/api'
import
_
from
'lodash'
import
{
placeSuggestion
}
from
'@/api/baidu'
import
{
getWeatherInfoList
}
from
"@/views/weatherCondition/api"
;
export
default
{
name
:
'Home'
,
components
:
{
NavList
},
...
...
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