From 2800fa4f32f3900509cb4d6eefaf2bfaf54efdd7 Mon Sep 17 00:00:00 2001
From: 罗广辉 <guanghui.luo@foxmail.com>
Date: Mon, 21 Apr 2025 18:29:09 +0800
Subject: [PATCH] fix: 天气显示
---
src/components/CommonWeather.vue | 22 ++++++++++++++--------
1 files changed, 14 insertions(+), 8 deletions(-)
diff --git a/src/components/CommonWeather.vue b/src/components/CommonWeather.vue
index 96e48f4..223fd64 100644
--- a/src/components/CommonWeather.vue
+++ b/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,13 @@
<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 selectedAreaCode = computed(() => store.state.user.selectedAreaCode)
+const useAreaCode = computed(() => store.state.user.userInfo.detail.areaCode)
const time = ref('')
const updateTime = () => {
@@ -24,22 +31,21 @@
// 天气
const weather = ref('')
-// 是否适合飞行
-const isFly = ref('')
+
// 风速
const windVelocity = ref('')
// 区县级
-const flylevel = ref('')
+const flightAdvice = computed(() => flySuggest.value?.flightAdvice)
+
// 获取天气建议
const getWeatherSuggest = () => {
- getDroneSuggest().then(res => {
+ getDroneSuggest({ areaCode: selectedAreaCode.value || useAreaCode.value }).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(() => {
getWeatherSuggest()
--
Gitblit v1.9.3