List.vue 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. <template >
  2. <div class="catalog-list" ref="catalogList">
  3. <ul class="catalog-list__news" v-if="categoryNewsList">
  4. <CatalogItem
  5. v-for="(categoryNews, i) in categoryNewsList"
  6. :key="categoryNews.id"
  7. :categoryNews="categoryNews"
  8. :i="i"
  9. />
  10. </ul>
  11. <div class="catalog-list__actions">
  12. <button
  13. class="catalog-list__action button button_grey-load"
  14. :class="{ button_disabled: loadNewsCounter == pages }"
  15. @click="loadNews"
  16. >
  17. <span class="button__icon"> <BaseIcon :name="'refresh'" /></span>
  18. <span class="button__text">Показать еще</span>
  19. </button>
  20. </div>
  21. </div>
  22. </template>
  23. <script>
  24. export default {
  25. props: {
  26. categoryNewsList: {
  27. type: Array,
  28. },
  29. pages: {
  30. type: Number,
  31. },
  32. },
  33. watch: {
  34. "$route.query.pagination": {
  35. handler(value) {
  36. this.counter = Number(value);
  37. this.loadNewsCounter = Number(value);
  38. }
  39. }
  40. },
  41. data() {
  42. return {
  43. list: [],
  44. counter: 1,
  45. loadNewsCounter: 1,
  46. filter: {},
  47. };
  48. },
  49. created() {
  50. this.counter = Number(this.$route.query.pagination) || 1;
  51. this.filter = this.$route.query.date_start ?
  52. {
  53. "date_start": this.$route.query.date_start,
  54. "date_end": this.$route.query.date_end,
  55. } : {};
  56. },
  57. computed: {
  58. count() {
  59. return Number(this.counter);
  60. },
  61. },
  62. methods: {
  63. loadNews() {
  64. this.filter = this.$route.query.date_start ?
  65. {
  66. "date_start": this.$route.query.date_start,
  67. "date_end": this.$route.query.date_end,
  68. } : {};
  69. this.loadNewsCounter++;
  70. this.$emit('loadMore', this.loadNewsCounter,this.filter);
  71. },
  72. async nextPage(page) {
  73. this.counter = page;
  74. window.scrollTo(0, 0);
  75. this.$router.push({
  76. name: this.$route.name,
  77. query: {
  78. pagination: this.counter.toString(),
  79. date_start: this.$route.query.date_start,
  80. date_end: this.$route.query.date_end,
  81. },
  82. });
  83. },
  84. },
  85. };
  86. </script>
  87. <style lang="less">
  88. @media screen and (max-width: 576px) {
  89. .catalog {
  90. &__container {
  91. padding: 15px 64px 56px 15px;
  92. @media (max-width: 576px) {
  93. padding: 15px;
  94. }
  95. }
  96. &__side {
  97. display: none;
  98. }
  99. }
  100. .catalog-item {
  101. &__side {
  102. max-width: 100%;
  103. margin-bottom: 15px;
  104. }
  105. &__figure {
  106. height: auto;
  107. }
  108. }
  109. .catalog-main {
  110. &__header {
  111. flex-wrap: wrap;
  112. margin-bottom: 10px;
  113. h1 {
  114. margin-bottom: 10px;
  115. }
  116. }
  117. &__filter {
  118. }
  119. &__subscribe {
  120. margin-left: 0;
  121. }
  122. &__title {
  123. margin-bottom: 10px;
  124. }
  125. }
  126. }
  127. </style>