forked from drone/command-center-dashboard

罗广辉
2025-04-21 22a23b05b25e4b5c616f65989ac0ca16324f4c29
src/components/CommonWeather.vue
@@ -6,8 +6,8 @@
         <img src="@/assets/images/home/homeLeft/tq.png" alt="" />
         <span class="tq">{{ weather }}</span>
         <span class="tq">风速:{{ windVelocity }} </span>
         <span v-if="flylevel >= 5" :class="[isFly === '适合飞行' ? 'qk' : isFly === '禁止飞行' ? 'redqk' : 'yellowqk']">{{
            isFly
         <span v-if="flightAdvice" :class="[flightAdvice === '适合飞行' ? 'qk' : flightAdvice === '禁止飞行' ? 'redqk' : 'yellowqk']">{{
               flightAdvice
         }}</span>
      </div>
   </div>
@@ -16,6 +16,11 @@
<script setup>
import dayjs from 'dayjs'
import { getDroneSuggest } from '@/api/home/common'
import { useStore } from 'vuex'
import { ElMessage } from 'element-plus'
const store = useStore()
const flySuggest = computed(() => store.state.home.flySuggest)
const time = ref('')
const updateTime = () => {
@@ -24,26 +29,21 @@
// 天气
const weather = ref('')
// 是否适合飞行
const isFly = ref('')
// 风速
const windVelocity = ref('')
// 区县级
const flylevel = ref('')
const flightAdvice = computed(() => flySuggest.value?.flightAdvice)
// 获取天气建议
const getWeatherSuggest = () => {
   // ElMessage.success('wobeichonghzil')
   getDroneSuggest().then(res => {
      if (res.data.code !== 0) return
      weather.value = res.data.data.weather
      isFly.value = res.data.data.flightAdvice
      windVelocity.value = res.data.data.windPower
      flylevel.value = res.data.data.adcode.replace(/0+$/, "").length
   })
}
let intervalTime
onMounted(() => {