feat:对接首页数据

This commit is contained in:
zjc
2024-12-27 14:50:53 +08:00
parent f7e15899a4
commit 88eb805c46
4 changed files with 84 additions and 29 deletions

View File

@@ -27,11 +27,11 @@
</li>
</ul>
<div class="weather">
<span>25˚C-</span>
<span>{{ weatherData?.temperature }}-{{ weatherData?.skycon }}</span>
<span class="line">|</span>
<span>风速A2-4</span>
<span>风速{{ weatherData?.windSpeed }}</span>
<span class="line">|</span>
<span>空气质量A2-</span>
<span>空气质量{{ weatherData?.airQuality }}</span>
<span class="ml-20">{{ currentDate }}</span>
</div>
<div v-if="isBack" class="back" @click="handleBack">
@@ -45,6 +45,8 @@
import title2 from '@/assets/images/title-2.png'
import title2Select from '@/assets/images/title-2-select.png'
import { getWeatherApi } from '@/api/home'
let props = defineProps({
title: {
type: String,
@@ -74,6 +76,7 @@
const emit = defineEmits(['change'])
const router = useRouter()
let currentDate = ref('')
let weatherData = ref({})
const name = computed(() => {
if (!props.isSkip && props.navLeft.length > 0) {
@@ -108,7 +111,13 @@
emit('on-change', index)
}
}
const getWeather = async () => {
let res = await getWeatherApi()
weatherData.value = res.data
console.log(res, '====')
}
onMounted(() => {
getWeather()
getCurrentDate()
setInterval(() => {
getCurrentDate()