cinema/app.riot

72 lines
2.4 KiB
Plaintext
Raw Permalink Normal View History

2022-04-02 12:00:24 +02:00
<app>
2022-04-03 01:58:58 +02:00
<filters currentPageNum="{state.currentMovieList.page}" maxPageNum="{state.currentMovieList.total_pages}"
getMovieList="{getMovieList}" updateMovieList="{updateMovieList}"></filters>
<movie-container getGenres="{movieUtils.getGenres()}" movieList="{state.currentMovieList.results}"></movie-container>
2022-04-02 12:00:24 +02:00
<script>
export default {
onBeforeMount(props, state) {
this.state = {
currentMovieList: [],
}
2022-04-03 01:58:58 +02:00
this.initGenres();
2022-04-02 12:00:24 +02:00
},
onMounted() {
this.updateMovieList();
},
async updateMovieList() {
2022-04-03 01:58:58 +02:00
currentPage = localStorage.getItem("curr_page");
localStorage.setItem('curr_page', 1);
2022-04-02 12:00:24 +02:00
switch(localStorage.getItem("currfilter")) {
case "popular":
console.log("loading popular")
this.update ({
2022-04-03 01:58:58 +02:00
currentMovieList : await movieUtils.getPopularMovies(currentPage)
2022-04-02 12:00:24 +02:00
})
break
case "top_rated":
console.log("loading top_rated")
this.update ({
2022-04-03 01:58:58 +02:00
currentMovieList : await movieUtils.getTopRatedMovies(currentPage)
2022-04-02 12:00:24 +02:00
})
break
case "coming_soon":
console.log("loading coming_soon")
this.update ({
2022-04-03 01:58:58 +02:00
currentMovieList : await movieUtils.getComingSoonMovies(currentPage)
2022-04-02 12:00:24 +02:00
})
break
case "new":
console.log("loading new")
this.update ({
2022-04-03 01:58:58 +02:00
currentMovieList : await movieUtils.getNewMovies(currentPage)
})
break
default:
console.log("loading new")
this.update ({
currentMovieList : await movieUtils.getNewMovies(currentPage)
2022-04-02 12:00:24 +02:00
})
break
}
},
2022-04-03 01:58:58 +02:00
getMovieList() {
this.updateMovieList();
return this.currentMovieList;
},
async initGenres() {
let genres = [];
console.log("genres")
genres = await movieUtils.getGenres().then(data => localStorage.setItem("genres", JSON.stringify(data)));
}
2022-04-02 12:00:24 +02:00
}
</script>
</app>