From a7e6761ba0cfccdf33ed552eb2d3b783c8e4ab4a Mon Sep 17 00:00:00 2001
From: shuishen <1109946754@qq.com>
Date: Wed, 16 Apr 2025 20:49:12 +0800
Subject: [PATCH] feat:事件弹窗显示调整

---
 src/components/CommonWeather.vue |  134 ++++++++++++++++++++++++++++----------------
 1 files changed, 84 insertions(+), 50 deletions(-)

diff --git a/src/components/CommonWeather.vue b/src/components/CommonWeather.vue
index 5ff5314..96e48f4 100644
--- a/src/components/CommonWeather.vue
+++ b/src/components/CommonWeather.vue
@@ -1,63 +1,97 @@
 <template>
-  <div class="time-weather">
-    <div class="time">{{ time }}</div>
-    <div class="line"></div>
-    <div class="weather">
-      <img src="@/assets/images/home/homeLeft/tq.png" alt="" />
-      <span class="tq">阴天</span>
-      <span class="qk">适合飞行</span>
-    </div>
-  </div>
+	<div class="time-weather">
+		<div class="time">{{ time }}</div>
+		<div class="line"></div>
+		<div class="weather">
+			<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>
+		</div>
+	</div>
 </template>
 
 <script setup>
-import dayjs from 'dayjs';
+import dayjs from 'dayjs'
+import { getDroneSuggest } from '@/api/home/common'
 
-
-const time = ref('');
+const time = ref('')
 const updateTime = () => {
-    time.value = dayjs().format('YYYY.MM.DD HH:mm:ss');
-};
+	time.value = dayjs().format('YYYY.MM.DD HH:mm:ss')
+}
+
+// 天气
+const weather = ref('')
+// 是否适合飞行
+const isFly = ref('')
+// 风速
+const windVelocity = ref('')
+// 区县级
+const flylevel = ref('')
+// 获取天气建议
+const getWeatherSuggest = () => {
+	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(() => {
-    updateTime(); // 立即执行一次
-    time.value = setInterval(updateTime, 1000);
-});
+	getWeatherSuggest()
+	updateTime() // 立即执行一次
+	intervalTime = setInterval(updateTime, 1000)
+})
 onUnmounted(() => {
-    if (time.value) {
-        clearInterval(time.value);
-        time.value = null;
-    }
-});
+	if (intervalTime) {
+		clearInterval(intervalTime)
+		intervalTime = null
+	}
+})
 </script>
 
 <style scoped lang="scss">
 .time-weather {
-  margin-left: 45px;
-  width: 310px;
-  font-size: 14px;
-  height: 36px;
-  line-height: 36px;
-  display: flex;
-  justify-content: space-between;
-  align-items: center;
-  .line {
-    border: 1px solid #ffffff;
-    height: 10px;
-    opacity: 0.5;
-  }
-  .weather {
-    img {
-      width: 20px;
-      height: 20px;
-    }
-    .tq {
-      margin: 0 5px;
-      color: #e7f5ff;
-    }
-    .qk {
-      margin-left: 5px;
-      color: #04f043;
-    }
-  }
+	margin-left: 45px;
+	// width: 350px;
+	font-size: 14px;
+	height: 36px;
+	line-height: 36px;
+	display: flex;
+	align-items: center;
+	color: #e7f5ff;
+	.line {
+		border: 1px solid #ffffff;
+		height: 10px;
+		opacity: 0.5;
+		margin: 0 18px;
+	}
+	.weather {
+		display: flex;
+		align-items: center;
+		img {
+			width: 20px;
+			height: 20px;
+		}
+		.tq {
+			margin: 0 5px;
+		}
+		.qk {
+			margin-left: 5px;
+			color: #04f043;
+		}
+		.yellowqk {
+			margin-left: 5px;
+			color: yellow;
+		}
+		.redqk {
+			margin-left: 5px;
+			color: red;
+		}
+	}
 }
-</style>
\ No newline at end of file
+</style>

--
Gitblit v1.9.3