2016-10-13 11:11:10 +02:00
|
|
|
<template>
|
|
|
|
<main>
|
|
|
|
<div class="wrap-content" v-if=" ! loading">
|
2016-10-18 09:57:47 +02:00
|
|
|
<Item v-for="(item, index) in items"
|
|
|
|
:item="item"
|
|
|
|
:key="index"
|
|
|
|
:genre="true"
|
|
|
|
:date="true"
|
|
|
|
></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';
|
|
|
|
|
2016-11-23 11:59:22 +01:00
|
|
|
import http from 'axios';
|
|
|
|
|
2016-10-13 11:11:10 +02:00
|
|
|
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;
|
|
|
|
|
2016-11-23 11:59:22 +01:00
|
|
|
http(`${config.api}/suggestions/${tmdbID}`).then(value => {
|
|
|
|
this.items = value.data;
|
2016-10-14 12:50:05 +02:00
|
|
|
this.SET_LOADING(false);
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
|
|
|
initTrending() {
|
2016-11-23 11:59:22 +01:00
|
|
|
http(`${config.api}/trending`).then(value => {
|
|
|
|
this.items = value.data;
|
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() {
|
2016-11-23 11:59:22 +01:00
|
|
|
http(`${config.api}/upcoming`).then(value => {
|
|
|
|
this.items = value.data;
|
2016-10-14 13:25:52 +02:00
|
|
|
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>
|