index.vue 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  1. <template>
  2. <section class="catalog section">
  3. <div class="catalog__wrapper section-wrapper">
  4. <div class="catalog__container">
  5. <CatalogMenu />
  6. <main class="catalog__main">
  7. <div class="catalog-main">
  8. <div class="catalog-main__wrapper">
  9. <div class="catalog-main__topic">
  10. <ul class="catalog-main__topic-list">
  11. <li class="catalog-main__topic-item">
  12. <a
  13. class="catalog-main__topic-link"
  14. href="javascript:void(0)"
  15. >Новости</a
  16. >
  17. </li>
  18. <li class="catalog-main__topic-item">
  19. <nuxt-link
  20. to="/news?page=1"
  21. class="catalog-main__topic-link"
  22. href="javascript:void(0)"
  23. ></nuxt-link>
  24. </li>
  25. </ul>
  26. </div>
  27. <div class="catalog-main__header">
  28. <h1 class="catalog-main__title">Новости</h1>
  29. <div
  30. class="catalog-main__filter"
  31. @click="$modal.show('filter-modal')"
  32. >
  33. <BaseIcon name="filter"></BaseIcon>
  34. </div>
  35. <!-- <a
  36. class="
  37. catalog-main__subscribe
  38. button button_grey-dark button_grey-dark-short
  39. "
  40. ><span class="button__text">Подписаться</span></a
  41. > -->
  42. </div>
  43. <div class="catalog-main__list">
  44. <div class="catalog-list">
  45. <CatalogList
  46. :categoryNewsList="categoryNewsList.news"
  47. :pages="categoryNewsList.total_pages"
  48. @loadMore="onLoadMore"
  49. />
  50. </div>
  51. </div>
  52. </div>
  53. </div>
  54. </main>
  55. </div>
  56. </div>
  57. <CatalogFilter @apply="onApplyFilter" :filter="filter"></CatalogFilter>
  58. </section>
  59. </template>
  60. <script>
  61. import { mapGetters } from "vuex";
  62. export default {
  63. watchQuery: ["pagination", "date_start", "date_end"],
  64. data: () => ({
  65. filter: {
  66. date: null,
  67. },
  68. }),
  69. computed: {
  70. ...mapGetters({
  71. newsItem: "modules/news/newsItem",
  72. categoryNewsList: "modules/news/categoryNewsList",
  73. }),
  74. },
  75. props: {
  76. category: {
  77. type: Object,
  78. },
  79. },
  80. head() {
  81. return {
  82. title: "Лента новостей",
  83. meta: [
  84. {
  85. name: "description",
  86. content:
  87. "Все основные новости Алтайского края, Барнаула, России и мира подобранные для вас вопросы и ответы.",
  88. },
  89. {
  90. name: "keys",
  91. content:
  92. "Все основные новости Алтайского края, Барнаула, России и мира подобранные для вас вопросы и ответы.",
  93. },
  94. ],
  95. link: [
  96. {rel: 'canonical', href: 'https://www.amic.ru/news'}
  97. ]
  98. };
  99. },
  100. beforeRouteEnter(to, from, next) {
  101. next();
  102. },
  103. methods: {
  104. onApplyFilter() {
  105. const [date_start = "", date_end = ""] = this.filter.activity;
  106. this.$router.push({
  107. name: this.$route.name,
  108. query: { pagination: 1, date_start, date_end },
  109. });
  110. this.$modal.hide("filter-modal");
  111. },
  112. async onLoadMore(loadMoreCounter,filter = {}) {
  113. var payload = Object.assign({
  114. category: false,
  115. pagination: loadMoreCounter,
  116. filter: filter
  117. });
  118. await this.$store.dispatch("modules/news/loadCategoryNews", payload);
  119. },
  120. },
  121. async fetch({ store, route }) {
  122. await store.dispatch("modules/news/setCategoryNewsList", {
  123. category: false,
  124. pagination: route.query.pagination || 1,
  125. filter: {
  126. date_start: route.query.date_start || null,
  127. date_end: route.query.date_end || null,
  128. },
  129. });
  130. await store.dispatch("modules/news/setCategoriesList");
  131. },
  132. async asyncData({ store }) {
  133. await store.dispatch("modules/ads/getAds");
  134. },
  135. };
  136. </script>
  137. <style>
  138. </style>