Commit 09cad903 authored by 高滢's avatar 高滢

首页天气

parent adb50d16
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
})
}
......@@ -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') {
......
......@@ -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 },
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment