cálculo
This commit is contained in:
@@ -1,29 +1,58 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="flex flex-center">
|
<div class="flex flex-center">
|
||||||
|
<h5 class="q-py-xl">{{ fecha }}</h5>
|
||||||
<q-btn
|
<q-btn
|
||||||
class="fixed-center"
|
class="fixed-center"
|
||||||
color="deep-orange"
|
color="deep-orange"
|
||||||
glossy
|
glossy
|
||||||
label="Calcular"
|
label="Calcular"
|
||||||
|
@click="calcular()"
|
||||||
></q-btn>
|
></q-btn>
|
||||||
{{ data }}
|
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
import { ref, onMounted } from "vue";
|
import { ref, onMounted } from "vue";
|
||||||
import axios from "axios";
|
import axios from "axios";
|
||||||
|
import { date } from "quasar";
|
||||||
|
|
||||||
const data = ref(null);
|
const humedad_relativa = ref(0);
|
||||||
|
const temp_max = ref(0);
|
||||||
|
const fecha = ref("");
|
||||||
|
|
||||||
|
const calcular = () => {
|
||||||
|
let valor = 0;
|
||||||
|
valor = temp_max.value - humedad_relativa.value * 0.2;
|
||||||
|
//console.log(Math.round(valor));
|
||||||
|
let hoy = new Date();
|
||||||
|
let newDate = date.addToDate(hoy, { days: Math.round(valor) });
|
||||||
|
fecha.value = newDate.toLocaleDateString("es-es", {
|
||||||
|
weekday: "long",
|
||||||
|
year: "numeric",
|
||||||
|
month: "long",
|
||||||
|
day: "numeric",
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
console.log("gooooo");
|
|
||||||
axios
|
axios
|
||||||
.get(
|
.get(
|
||||||
`https://api.openweathermap.org/data/2.5/forecast/daily?lat=44.34&lon=10.99&cnt=7&appid=1ce95ef35a6852cecee421a923fe4400`
|
`https://api.open-meteo.com/v1/forecast?latitude=39.55&longitude=-0.57&hourly=relativehumidity_2m&models=gfs_global&daily=temperature_2m_max,temperature_2m_min&timezone=Europe%2FLondon`
|
||||||
)
|
)
|
||||||
.then((res) => {
|
.then((res) => {
|
||||||
console.log(res);
|
//console.log("humedad relativa", res.data.hourly.relativehumidity_2m);
|
||||||
|
let suma_humedad = 0;
|
||||||
|
res.data.hourly.relativehumidity_2m.forEach((element) => {
|
||||||
|
suma_humedad += element;
|
||||||
|
});
|
||||||
|
humedad_relativa.value =
|
||||||
|
suma_humedad / res.data.hourly.relativehumidity_2m.length;
|
||||||
|
//console.log("temp máxima", res.data.daily.temperature_2m_max);
|
||||||
|
let suma_temp_max = 0;
|
||||||
|
res.data.daily.temperature_2m_max.forEach((element) => {
|
||||||
|
suma_temp_max += element;
|
||||||
|
});
|
||||||
|
temp_max.value = suma_temp_max / res.data.daily.temperature_2m_max.length;
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
Reference in New Issue
Block a user