1
0
mirror of https://github.com/devfake/flox.git synced 2024-11-15 14:42:31 +01:00
flox/client/app/components/Content/TMDBContent.vue
2016-11-23 11:59:22 +01:00

94 lines
1.8 KiB
Vue

<template>
<main>
<div class="wrap-content" v-if=" ! loading">
<Item v-for="(item, index) in items"
:item="item"
:key="index"
:genre="true"
:date="true"
></Item>
</div>
<span class="loader fullsize-loader" v-if="loading"><i></i></span>
</main>
</template>
<script>
import Item from './Item.vue';
import Helper from '../../helper';
import http from 'axios';
import { mapState, mapMutations } from 'vuex'
export default {
mixins: [Helper],
created() {
this.init();
},
data() {
return {
items: []
}
},
computed: {
...mapState({
loading: state => state.loading
})
},
methods: {
...mapMutations([ 'SET_LOADING' ]),
init() {
this.SET_LOADING(true);
const path = this.$route.path;
if(path == '/trending') {
this.initTrending();
} else if(path == '/suggestions') {
this.initSuggestions();
} else if(path == '/upcoming') {
this.initUpcoming();
}
},
initSuggestions() {
const tmdbID = this.$route.query.for;
http(`${config.api}/suggestions/${tmdbID}`).then(value => {
this.items = value.data;
this.SET_LOADING(false);
});
},
initTrending() {
http(`${config.api}/trending`).then(value => {
this.items = value.data;
this.SET_LOADING(false);
});
},
initUpcoming() {
http(`${config.api}/upcoming`).then(value => {
this.items = value.data;
this.SET_LOADING(false);
});
}
},
components: {
Item
},
watch: {
$route() {
this.scrollToTop();
this.init();
}
}
}
</script>