index.vue 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. <template>
  2. <section class="video section">
  3. <div class="video__wrapper section-wrapper">
  4. <template v-if="videos.length">
  5. <VideoSliderTop
  6. :list="sliderTopVideos"
  7. class="video-top"
  8. ></VideoSliderTop>
  9. <VideoList :videoCategory="videos[0]" class="video-list"></VideoList>
  10. <VideoSliderCenter
  11. :videoCategory="videos[1]"
  12. class="video-center"
  13. ></VideoSliderCenter>
  14. <VideoList
  15. v-for="video in videos.slice(2)"
  16. :key="video.id"
  17. :videoCategory="video"
  18. class="video-list"
  19. ></VideoList>
  20. <BannersW1254H100Or90 class="video-banner" />
  21. </template>
  22. </div>
  23. </section>
  24. </template>
  25. <script>
  26. import { mapGetters } from "vuex";
  27. export default {
  28. colorMode: "dark",
  29. data: () => ({
  30. videos: [],
  31. }),
  32. async asyncData({ store }) {
  33. await store.dispatch("modules/news/setCategoriesList");
  34. },
  35. async mounted() {
  36. const promises = this.categories.map(this.loadVideos);
  37. this.videos = await Promise.all(promises);
  38. },
  39. methods: {
  40. loadVideos(category) {
  41. return this.$axios
  42. .get(`/news/category/${category.alias}`)
  43. .then((res) => res.data.data);
  44. },
  45. },
  46. computed: {
  47. ...mapGetters({
  48. allCategories: "modules/news/categoriesList",
  49. }),
  50. categories() {
  51. return this.allCategories.data.find((cat) => cat.alias === "video").child;
  52. },
  53. //First three categories actual video
  54. sliderTopVideos() {
  55. if (!this.videos.length) return [];
  56. return this.videos
  57. .slice(0, 3)
  58. .map((video) => video.news[0])
  59. .filter((video) => video);
  60. },
  61. },
  62. head() {
  63. return {
  64. title: "Амик.Видео",
  65. meta: [
  66. {
  67. name: "description",
  68. content: "Видео-новости на Амик.ру — новости Барнаула и Алтайского края: интервью, репортажи",
  69. },
  70. {
  71. name: "keys",
  72. content: "Амик, видео, новости барнаула",
  73. },
  74. ],
  75. link: [
  76. {rel: 'canonical', href: 'https://www.amic.ru/video'}
  77. ]
  78. };
  79. },
  80. };
  81. </script>
  82. <style lang="less" scoped>
  83. .video {
  84. padding-bottom: 50px;
  85. color: white;
  86. &-top {
  87. margin-bottom: 50px;
  88. }
  89. &-center {
  90. margin-top: 50px;
  91. }
  92. &-list {
  93. margin-bottom: 25px;
  94. }
  95. &-banner {
  96. margin-top: 50px;
  97. }
  98. }
  99. </style>