1
0
mirror of https://github.com/devfake/flox.git synced 2024-11-15 22:52:32 +01:00
flox/client/app/components/Content/TMDBContent.vue

87 lines
1.7 KiB
Vue
Raw Normal View History

2016-10-13 11:11:10 +02:00
<template>
<main>
<div class="wrap-content" v-if=" ! loading">
2016-10-14 12:50:05 +02:00
<Item v-for="(item, index) in items" :item="item" :key="index"></Item>
2016-10-13 11:11:10 +02:00
</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 { mapState, mapMutations } from 'vuex'
export default {
mixins: [Helper],
created() {
2016-10-14 12:50:05 +02:00
this.init();
2016-10-13 11:11:10 +02:00
},
data() {
return {
2016-10-14 12:50:05 +02:00
items: []
2016-10-13 11:11:10 +02:00
}
},
computed: {
...mapState({
loading: state => state.loading
})
},
methods: {
...mapMutations([ 'SET_LOADING' ]),
2016-10-14 12:50:05 +02:00
init() {
2016-10-13 11:11:10 +02:00
this.SET_LOADING(true);
2016-10-14 12:50:05 +02:00
const path = this.$route.path;
if(path == '/trending') {
this.initTrending();
} else if(path == '/suggestions') {
this.initSuggestions();
2016-10-14 13:25:52 +02:00
} else if(path == '/upcoming') {
this.initUpcoming();
2016-10-14 12:50:05 +02:00
}
},
initSuggestions() {
2016-10-13 11:11:10 +02:00
const tmdbID = this.$route.query.for;
this.$http.get(`${config.api}/suggestions/${tmdbID}`).then(value => {
2016-10-14 12:50:05 +02:00
this.items = value.body;
this.SET_LOADING(false);
});
},
initTrending() {
this.$http.get(`${config.api}/trending`).then(value => {
this.items = value.body;
2016-10-13 11:11:10 +02:00
this.SET_LOADING(false);
2016-10-14 12:50:05 +02:00
});
2016-10-14 13:25:52 +02:00
},
initUpcoming() {
this.$http.get(`${config.api}/upcoming`).then(value => {
this.items = value.body;
this.SET_LOADING(false);
});
2016-10-13 11:11:10 +02:00
}
},
components: {
Item
},
watch: {
$route() {
this.scrollToTop();
2016-10-14 12:50:05 +02:00
this.init();
2016-10-13 11:11:10 +02:00
}
}
}
</script>