index.vue 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. <template>
  2. <section class="video-category section">
  3. <div class="video-category__wrapper section-wrapper">
  4. <div class="video-category-title">{{ videos.category.name }}</div>
  5. <div class="video-category-loader" v-if="!videos.news">
  6. <v-progress-circular indeterminate></v-progress-circular>
  7. </div>
  8. <div class="video-category-list" v-else>
  9. <VideoItem
  10. class="video-category-item"
  11. v-for="video in videos.news"
  12. :key="video.id"
  13. :item="video"
  14. ></VideoItem>
  15. </div>
  16. <div class="video-category-pagination">
  17. <Pagination
  18. :length="videos.total_pages"
  19. v-if="videos.news"
  20. :visible="10"
  21. v-model="pagination"
  22. dark
  23. @input="changePage"
  24. ></Pagination>
  25. </div>
  26. </div>
  27. </section>
  28. </template>
  29. <script>
  30. import { mapGetters } from "vuex";
  31. export default {
  32. colorMode: "dark",
  33. watchQuery: ["pagination"],
  34. created() {
  35. this.pagination = Number(this.$route.query.pagination) || 1;
  36. },
  37. async fetch({ store, route }) {
  38. await store.dispatch("modules/news/setCategoryNewsList", {
  39. category: route.params.category,
  40. pagination: route.query.pagination || 1,
  41. });
  42. },
  43. methods: {
  44. async changePage() {
  45. window.scrollTo({ top: 0, behavior: "smooth" });
  46. this.$router.push({
  47. name: this.$route.name,
  48. query: { pagination: this.pagination }
  49. })
  50. }
  51. },
  52. computed: {
  53. ...mapGetters({
  54. videos: "modules/news/categoryNewsList",
  55. }),
  56. },
  57. head() {
  58. return {
  59. title: "Амик - " + this.videos.category.name,
  60. meta: [
  61. {
  62. name: "description",
  63. content: this.videos.category.meta.description,
  64. },
  65. {
  66. name: "keys",
  67. content: this.videos.category.meta.key,
  68. },
  69. ],
  70. link: [
  71. {rel: 'canonical', href: this.videos.category ? 'https://www.amic.ru/video/' + this.videos.category.alias : ''}
  72. ]
  73. };
  74. },
  75. };
  76. </script>
  77. <style lang="less" scoped>
  78. .video-category {
  79. padding-top: 30px;
  80. color: white;
  81. &-title {
  82. font-size: 30px;
  83. color: white;
  84. margin-bottom: 20px;
  85. }
  86. &-loader {
  87. text-align: center;
  88. }
  89. &-list {
  90. display: flex;
  91. flex-wrap: wrap;
  92. margin: 0 -10px;
  93. @media screen and(max-width: 1300px) {
  94. justify-content: space-around;
  95. }
  96. }
  97. &-pagination {
  98. padding: 20px 0;
  99. }
  100. &-item {
  101. flex: 100%;
  102. max-width: 417px;
  103. margin: 10px;
  104. }
  105. }
  106. </style>