-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathCityView.vue
61 lines (57 loc) · 1.54 KB
/
CityView.vue
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
<script setup>
import { onMounted, ref } from 'vue'
import LMap from '../components/LMap.vue'
import { getCityTodayWeather } from '../api/weather.api'
import { useCitiesStore } from '../store/cities.store'
const props = defineProps({
cityName: {
type: String,
required: true
}
})
const store = useCitiesStore()
const { latitude, longitude } = store.getCityByName(props.cityName)
const weather = ref(null)
onMounted(async () => {
weather.value = await getCityTodayWeather(longitude, latitude)
})
</script>
<template>
<h1 class="title">Cities weather</h1>
<article class="panel is-primary">
<div class="panel-heading"><h2>{{ props.cityName }}</h2></div>
<div class="panel-block">
<l-map :zoom="13" :lat="latitude" :long="longitude" />
</div>
<div class="panel-block">
<table class="table is-flex-grow-1">
<thead>
<tr>
<th>Date</th>
<th>Weather</th>
<th>Min</th>
<th>Max</th>
</tr>
</thead>
<tbody>
<tr>
<td>{{ weather?.date }}</td>
<td><img :src="`http://www.7timer.info/img/misc/about_civil_${weather?.weather}.png`" alt="" width="80" /></td>
<td>{{ weather?.temp2m.min }} °C</td>
<td>{{ weather?.temp2m.max }} °C</td>
</tr>
</tbody>
</table>
</div>
<div class="panel-block">
<router-link to="/" class="button is-rounded">
Go back home
</router-link>
</div>
</article>
</template>
<style scoped>
td {
vertical-align: middle;
}
</style>