Commit a1e3ff04 authored by xxx's avatar xxx

修改天气接口

parent 6605fa8e
...@@ -4,23 +4,23 @@ ...@@ -4,23 +4,23 @@
<div class="dataScrView_rightView_title">气象数据</div> <div class="dataScrView_rightView_title">气象数据</div>
<div class="dataScrView_rightView_content"> <div class="dataScrView_rightView_content">
<div class="todayWeather1"> <div class="todayWeather1">
<div style="font-size:40px;margin-right:30px;">{{(parseInt(weatherData.today.high.slice(3,5)) + parseInt(weatherData.today.low.slice(3,5))) / 2}}</div> <div style="font-size:40px;margin-right:30px;">{{weatherData.fengli.temp}}</div>
<img :src=" weatherData.today.type == '晴' ? weatherPic.sunnyPic : weatherData.today.type == '多云' ? weatherPic.cloudyPic : weatherPic.overcastPic " height="25"> <img :src=" weatherData.today.weather == '晴' ? weatherPic.sunnyPic : weatherData.today.weather == '多云' ? weatherPic.cloudyPic : weatherPic.overcastPic " height="25">
<div style="font-size:18px;">{{weatherData.today.type}} / {{currentTime.day}}</div> <div style="font-size:16px;">{{weatherData.today.weather}} / {{currentTime.day}}</div>
</div> </div>
<div class="todayWeather2"> <div class="todayWeather2">
<div v-for="(item,index) in weatherData.forecastData" :key="index"> <div v-for="(item,index) in weatherData.forecastData" :key="index">
<div style="color:#D0DAFF;font-size:13px;margin-bottom:5px;">{{item.date}}</div> <div style="color:#D0DAFF;font-size:13px;margin-bottom:5px;">{{item.week}}</div>
<img :src="item.type == '晴' ? weatherPic.sunnyPic : item.type == '多云' ? weatherPic.cloudyPic : weatherPic.overcastPic " height="25"> <img :src="item.weather == '晴' ? weatherPic.sunnyPic : item.weather == '多云' ? weatherPic.cloudyPic : weatherPic.overcastPic " height="25">
<div style="color:#D0DAFF;font-size:15px;margin-top:5px;">{{(item.low.slice(3,6)) + '-' +(item.high.slice(3,6))}}</div> <div style="color:#D0DAFF;font-size:13px;margin-top:5px;">{{item.temp_night_c + '℃-' + item.temp_day_c}}</div>
</div> </div>
</div> </div>
<div class="todayWeather3"> <div class="todayWeather3">
<img src="../../../../assets/images/cutGraph/fengli1.png" height="45"> <img src="../../../../assets/images/cutGraph/fengli1.png" height="45">
<div>风力:{{weatherData.today.fengli.slice(9,10)}}</div> <div>风力:{{weatherData.fengli.wD + weatherData.fengli.wS}}</div>
<div> <div>
<div>温度:{{(parseInt(weatherData.today.high.slice(3,5)) + parseInt(weatherData.today.low.slice(3,5))) / 2}}</div> <div>温度:{{weatherData.fengli.temp}}</div>
<div>湿度:{{(parseInt(weatherData.today.high.slice(3,5)) + parseInt(weatherData.today.low.slice(3,5))) / 2}}%</div> <div>湿度:{{weatherData.fengli.sD}}%</div>
</div> </div>
</div> </div>
</div> </div>
...@@ -37,7 +37,6 @@ import overcastPic from '../../../../assets/images/cutGraph/overcast.png' ...@@ -37,7 +37,6 @@ import overcastPic from '../../../../assets/images/cutGraph/overcast.png'
export default { export default {
data(){ data(){
return { return {
DPcomputer6BoxTimer:null,
//时间 //时间
currentTime:{ currentTime:{
day:'', day:'',
...@@ -53,12 +52,8 @@ export default { ...@@ -53,12 +52,8 @@ export default {
//天气数据 //天气数据
weatherData:{ weatherData:{
forecastData:[], forecastData:[],
today:{ today:{},
high:'高温 10℃', fengli:{},
low:'高温 10℃',
type:'多云',
fengli:'<![CDATA[0级]]>',
},
}, },
} }
}, },
...@@ -72,24 +67,20 @@ export default { ...@@ -72,24 +67,20 @@ export default {
this.yearCurrentTimeFn(); this.yearCurrentTimeFn();
//获取天气 //获取天气
HttpReq.truckDispatching.getWeatherInforQuery({cityName:'济南'}).then((res) => { HttpReq.truckDispatching.getWeatherInforQuery({ids:'101121301'}).then((res) => {
if(res.code == 200 && res.msg){ if(res.code == 200 && res.msg){
let data1 = JSON.parse(res.msg).data.forecast; let data1 = JSON.parse(res.msg).value[0].weathers;
this.weatherData.forecastData = data1; let data2 = [];
this.weatherData.today = data1[0]; for(let i = 0;i < 5;i++){
data2.push(data1[i])
} }
}) this.weatherData.forecastData = data2;
this.DPcomputer6BoxTimer = setInterval(() => {
//获取天气
HttpReq.truckDispatching.getWeatherInforQuery({cityName:'济南'}).then((res) => {
if(res.code == 200 && res.msg){
let data1 = JSON.parse(res.msg).data.forecast;
this.weatherData.forecastData = data1;
this.weatherData.today = data1[0]; this.weatherData.today = data1[0];
let data3 = JSON.parse(res.msg).value[0].realtime;
this.weatherData.fengli = data3;
} }
}) })
},10000)
}, },
//获取当前时间 //获取当前时间
...@@ -127,12 +118,7 @@ export default { ...@@ -127,12 +118,7 @@ export default {
this.currentTime.year = currentFormatDate; this.currentTime.year = currentFormatDate;
}, },
}, },
beforeDestroy(){ beforeDestroy(){}
if(this.DPcomputer6BoxTimer) {
clearInterval(this.DPcomputer6BoxTimer);
this.DPcomputer6BoxTimer = null;
}
}
} }
</script> </script>
......
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