Item.vue 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. <template>
  2. <li class="catalog-list__item">
  3. <div class="catalog-item">
  4. <component v-bind="linkProps(categoryNews)" class="catalog-item__link">
  5. <aside class="catalog-item__side">
  6. <div class="catalog-item__figure">
  7. <img
  8. class="catalog-item__img"
  9. :src="categoryNews.image ? categoryNews.image.url : ''"
  10. :alt="categoryNews.image ? categoryNews.image.title : ''"
  11. />
  12. </div>
  13. </aside>
  14. <main class="catalog-item__main">
  15. <div class="catalog-item__main-top">
  16. <div class="catalog-item__main-title">
  17. <img
  18. v-if="categoryNews.lightning"
  19. :src="require('~/static/svg/styled/lightning.svg')"
  20. />
  21. <span v-html="categoryNews.title"></span>
  22. </div>
  23. </div>
  24. <div class="catalog-item__main-bottom">
  25. <div class="catalog-item__main-info">
  26. <div class="catalog-item__main-info-element">
  27. {{
  28. categoryNews.start_activity
  29. ? convertDate(categoryNews.start_activity)
  30. : ""
  31. }}
  32. </div>
  33. <!-- <div class="catalog-item__main-info-element">
  34. <span> <BaseIcon :name="'views'" /></span>
  35. <span> {{ categoryNews.views_counter? categoryNews.views_counter : '' }} </span>
  36. </div> -->
  37. <div
  38. class="catalog-item__main-info-element"
  39. v-if="categoryNews.comments_count"
  40. >
  41. <span> <BaseIcon :name="'comments'" clear /></span>
  42. <span>
  43. {{
  44. categoryNews.comments_count
  45. ? categoryNews.comments_count
  46. : ""
  47. }}
  48. </span>
  49. </div>
  50. </div>
  51. </div>
  52. </main></component
  53. >
  54. <div class="catalog-item__banner" v-if="i == 5">
  55. <BannersW640H360 />
  56. </div>
  57. </div>
  58. </li>
  59. </template>
  60. <script>
  61. export default {
  62. components: {},
  63. props: {
  64. categoryNews: {
  65. type: Object,
  66. },
  67. i: {
  68. type: Number,
  69. },
  70. },
  71. methods: {
  72. linkProps(news) {
  73. if(news.link) return {
  74. is: 'a',
  75. href: news.link,
  76. target: '_blank',
  77. }
  78. else return {
  79. is: 'nuxt-link',
  80. to: this.params(news)
  81. }
  82. },
  83. params(news) {
  84. if (news.category.alias == "articles") {
  85. return {
  86. name: "articles-alias",
  87. params: {
  88. category: "articles",
  89. alias: news.alias,
  90. },
  91. };
  92. } else {
  93. return {
  94. name: "news-category-alias",
  95. params: {
  96. category: news.category.alias,
  97. alias: news.alias,
  98. },
  99. };
  100. }
  101. },
  102. convertDate(dateTampstamp) {
  103. const date = new Date(dateTampstamp * 1000);
  104. const dateString =
  105. date.toLocaleString("ru", {
  106. day: "numeric",
  107. month: "long",
  108. }) +
  109. " " +
  110. date.getFullYear() +
  111. ", " +
  112. ("0" + date.getHours()).slice(-2) +
  113. ":" +
  114. ("0" + date.getMinutes()).slice(-2);
  115. return dateString;
  116. },
  117. },
  118. };
  119. </script>
  120. <style>
  121. </style>