Created
February 16, 2021 22:29
-
-
Save fabioebner/e696b82beefeff4c80073604b1cdfe13 to your computer and use it in GitHub Desktop.
Nuxt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<template> | |
<v-container fluid> | |
<v-btn @click="proximo">va</v-btn> | |
<v-row> | |
<v-col | |
v-for="sessao in sessoes" | |
:key="sessao.id" | |
xs="12" | |
sm="12" | |
md="6" | |
lg="4" | |
> | |
<FotografoSessao :sessao="sessao" :is-mostrar-titulo="true" /> | |
</v-col> | |
</v-row> | |
<v-row> | |
<v-container class="max-width"> | |
<v-pagination | |
v-model="paginaAtual" | |
:length="totalPages" | |
:total-visible="10" | |
@input="proximo" | |
></v-pagination> | |
</v-container> | |
</v-row> | |
</v-container> | |
</template> | |
<script> | |
export default { | |
async asyncData({ $api, store, route }) { | |
let url = "/sessao/ultimas"; | |
if (store.state.auth.isLogged) { | |
url = "/sessao/praias/usuario"; | |
} | |
const page = parseInt(route.query.page); | |
const retorno = await $api.get(`${url}?page=${page - 1}`); | |
return { | |
sessoes: retorno.data.content, | |
totalPages: retorno.data.totalPages, | |
totalItems: retorno.data.content.totalItems, | |
paginaAtual: parseInt(page), | |
}; | |
}, | |
data() { | |
return {}; | |
}, | |
watchQuery: ["page"], | |
methods: { | |
proximo(val) { | |
const page = parseInt(val); | |
this.$router.push({ path: this.$route.path, query: { page: page } }); | |
}, | |
recuperarImagem(prop) { | |
return "data:image/png;base64," + prop; | |
}, | |
}, | |
}; | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment