提交 2c3c6371 作者: 翁进城

feat: 对接天气接口

上级 c38ee979
......@@ -3,4 +3,5 @@ export { default as AirLine } from './modules/airLine';
export { default as Map } from './modules/map';
export { default as AI_API} from './modules/ai';
export { default as ViewLibrary } from './modules/viewLibrary';
export { default as TaskInfo } from './modules/taskInfo';
\ No newline at end of file
export { default as TaskInfo } from './modules/taskInfo';
export { default as System } from './modules/system';
\ No newline at end of file
import request from "../request";
export default class System {
/**
* 获取天气数据
* @param {*} data
* @returns
*/
static getCoordinatesWeather(params) {
return request({
url: '/admin-api/system/weather/getCoordinatesWeather',
method: "get",
params
});
}
}
......@@ -5,7 +5,7 @@
<ControlBottom isHangar></ControlBottom>
<ControlRight></ControlRight>
<!-- 顶部信息 -->
<ControlTop></ControlTop>
<ControlTop isHangar></ControlTop>
</div>
</template>
......
......@@ -5,16 +5,16 @@
<div>{{week}} {{time}}</div>
</div>
<div class="ct-item ct-weather">
<img class="ctw-icon" src="./assets/images/weather/icon/day/00.png" />
<img class="ctw-icon" :src="weatherIcon" />
<div class="ctw-wind">
<div class="ctww-line1">
<img src="./assets/images/wind.png" />
<div>东北风</div>
<!-- <img :src="weatherIcon" /> -->
<div>{{weather.windDirection}}</div>
</div>
<div>0.2~0.6m/s</div>
<div>{{weather.windSpeed}}m/s</div>
</div>
</div>
<div class="ct-item ct-take-off">适宜起飞</div>
<div class="ct-item ct-take-off">{{weather.flyStatus ? '适宜起飞' : '不宜起飞'}}</div>
<div class="ct-item ct-info">
<!-- 避障雷达 -->
<el-tooltip
......@@ -112,12 +112,19 @@
import dayjs from "dayjs";
import { mapState } from "vuex";
import TakeOverRecords from "./components/takeOverRecords";
import { System } from "../../../../../../api";
export default {
name: "ControlTop",
components: {
TakeOverRecords,
},
props: {
isHangar: {
type: Boolean,
default: false,
},
},
data() {
return {
date: "",
......@@ -160,10 +167,23 @@ export default {
"-4": "航向偏左",
},
showTakeOverRecords: false, // 显示接管记录
timeWeather: null,
weather: {
windSpeed: 0,
minTemp: 0,
maxTemp: 0,
windDirection: "未知",
humidity: 0,
temp: 0,
windLevel: 0,
conditionDay: "未知",
},
weatherIcon: require(`./assets/images/weather/icon/iconfont/W0.png`)
};
},
computed: {
...mapState("MMCFlightControlCenter/uav", ["uavRealTimeData"]),
...mapState("MMCFlightControlCenter/hangar", ["hangar"]),
// 网络判断 公网|专网
network() {
let { uavRealTimeData } = this;
......@@ -310,12 +330,13 @@ export default {
},
created() {
this.updateTime();
this.timeHandler = setInterval(() => {
this.updateTime();
}, 1000);
this.timeHandler = setInterval(this.updateTime, 1000);
this.getWeather();
this.timeWeather = setInterval(this.getWeather, 60000);
},
beforeDestroy() {
clearInterval(this.timeHandler);
clearInterval(this.timeWeather);
},
methods: {
updateTime() {
......@@ -413,6 +434,35 @@ export default {
});
}
},
/**
* 获取天气数据
*/
async getWeather() {
let lat;
let lon;
if (this.isHangar) {
lat = this.hangar.latitude;
lon = this.hangar.longitude;
} else {
// 无人机需要通过实时数据获取经纬度
if (this.uavRealTimeData?.locationCoordinate3D?.latitude) {
lat = this.uavRealTimeData.locationCoordinate3D.latitude;
lon = this.uavRealTimeData.locationCoordinate3D.longitude;
}
}
if (lat) {
let res = await System.getCoordinatesWeather({
lat,
lon,
});
this.weather = res.data[0];
const date = new Date();
let time = date.getHours();
this.weatherIcon = require(`./assets/images/weather/icon/iconfont/W${
time >= 18 ? this.weather.nightIcon : this.weather.dayIcon
}.png`);
}
},
},
};
</script>
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论