Commit 0acf4300 authored by 小费同学阿's avatar 小费同学阿 💬

Merge remote-tracking branch 'origin/master'

parents c269efaa 16469e4a
import request from "@/utils/request-baidu"; import request from '@/utils/request-baidu'
export function getWeather() { export function getWeather() {
return request({ return request({
...@@ -110,3 +110,11 @@ export function walkingPlanning(origin, destination, origin_uid, destination_uid ...@@ -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 @@ ...@@ -33,6 +33,7 @@
import Cookies from 'js-cookie' import Cookies from 'js-cookie'
import logo from '@/assets/image/logo.png' import logo from '@/assets/image/logo.png'
import axios from 'axios' import axios from 'axios'
import { headerWeather } from '@/api/baidu'
export default { export default {
data() { data() {
...@@ -61,17 +62,20 @@ export default { ...@@ -61,17 +62,20 @@ export default {
data_type: 'all', data_type: 'all',
ak: 'bSlMW0ziNWrg8TjNzUKZpLE9iGcS3jc2' ak: 'bSlMW0ziNWrg8TjNzUKZpLE9iGcS3jc2'
} }
headerWeather(params).then(response => {
this.weatherCondition = response.result.forecasts
this.weatherNow = response.result.now
})
// 将 params 对象传递给 GET 请求 // 将 params 对象传递给 GET 请求
axios.get(`${process.env.VUE_APP_BAIDU_API}weather/v1/`, { params }) // axios.get(`${process.env.VUE_APP_BAIDU_API}weather/v1/`, { params })
.then(response => { // .then(response => {
console.log('11111', response) // console.log('11111', response)
this.weatherCondition = response.data.result.forecasts // this.weatherCondition = response.data.result.forecasts
this.weatherNow = response.data.result.now // this.weatherNow = response.data.result.now
}) // })
.catch(error => { // .catch(error => {
console.error(error) // console.error(error)
}) // })
}, },
toHome() { toHome() {
if (this.$route.path !== '/Home') { if (this.$route.path !== '/Home') {
......
...@@ -55,14 +55,14 @@ export function resetForm(refName) { ...@@ -55,14 +55,14 @@ export function resetForm(refName) {
// 添加日期范围 // 添加日期范围
export function addDateRange(params, dateRange, propName) { export function addDateRange(params, dateRange, propName) {
const search = params const search = params
search.params = typeof (search.params) === 'object' && search.params !== null && !Array.isArray(search.params) ? search.params : {} // search.params = typeof (search.params) === 'object' && search.params !== null && !Array.isArray(search.params) ? search.params : {};
dateRange = Array.isArray(dateRange) ? dateRange : [] dateRange = Array.isArray(dateRange) ? dateRange : []
if (typeof (propName) === 'undefined') { if (typeof (propName) === 'undefined') {
search.params['beginTime'] = dateRange[0] search['beginTime'] = dateRange[0]
search.params['endTime'] = dateRange[1] search['endTime'] = dateRange[1]
} else { } else {
search.params['begin' + propName] = dateRange[0] search['begin' + propName] = dateRange[0]
search.params['end' + propName] = dateRange[1] search['end' + propName] = dateRange[1]
} }
return search return search
} }
......
...@@ -299,6 +299,7 @@ import NavList from '@/views/Home/components/NavList/index.vue' ...@@ -299,6 +299,7 @@ import NavList from '@/views/Home/components/NavList/index.vue'
import { getTrafficInfoList, getroadConditions } from '@/views/trafficInformation/api' import { getTrafficInfoList, getroadConditions } from '@/views/trafficInformation/api'
import _ from 'lodash' import _ from 'lodash'
import { placeSuggestion } from '@/api/baidu' import { placeSuggestion } from '@/api/baidu'
import {getWeatherInfoList} from "@/views/weatherCondition/api";
export default { export default {
name: 'Home', name: 'Home',
components: { NavList }, 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