Lent.vue 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219
  1. <template>
  2. <div class="news-side__list">
  3. <client-only>
  4. <v-skeleton-loader v-if="!newsFeedList.length" type="list-item-two-line@9" class="mx-auto" min-width="385px"></v-skeleton-loader>
  5. </client-only>
  6. <div v-show="newsFeedList.length" class="news-side-list">
  7. <!-- <div class="vote-countdown news-side-list__item">-->
  8. <!-- <nuxt-link to="/news/novgod2023" class="news-side-list__link">-->
  9. <!-- <img src="/png/cabbit.png" style="height: 60px;margin-top: -10px;"/>-->
  10. <!-- <main class="news-side-list__item-main" >-->
  11. <!-- <h3 class="news-side-list__item-title">До нового года осталось</h3>-->
  12. <!-- </main>-->
  13. <!-- <aside class="news-side-list__item-side">-->
  14. <!-- <div class="news-side-list__item-time">-->
  15. <!-- <span v-html="countdown"></span>-->
  16. <!-- </div>-->
  17. <!-- </aside>-->
  18. <!-- </nuxt-link>-->
  19. <!-- </div>-->
  20. <div
  21. class="news-side-list__item"
  22. v-for="(newsItem,index) in newsFeedList"
  23. :key="newsItem.id"
  24. >
  25. <client-only>
  26. <div class="detail-side__banner" v-if="(index === 10 && params['showad'] === true)">
  27. <BannersW240H400 />
  28. </div>
  29. <div class="detail-side__banner" v-if="(index === 3 && params['showadMainPage'] === true && isMobile())">
  30. <BannersLentMobile />
  31. </div>
  32. <div class="detail-side__banner" v-if="(index === 20 && !isMobile())">
  33. <BannersLentPartner />
  34. </div>
  35. </client-only>
  36. <nuxt-link
  37. :to="getNewsItemLink(newsItem)"
  38. class="news-side-list__link"
  39. >
  40. <main class="news-side-list__item-main">
  41. <h3
  42. class="news-side-list__item-title"
  43. :class="{ lightning: newsItem.lightning }"
  44. v-html="newsItem.title"
  45. >
  46. </h3>
  47. </main>
  48. <aside class="news-side-list__item-side">
  49. <div class="news-side-list__item-time">
  50. {{ $convertDate(newsItem.start_activity) }}
  51. </div>
  52. <div class="news-side-list__item-comments" v-if="newsItem.comments_count && newsItem.comments_count > 0">
  53. <BaseIcon clear :name="'comments'" />
  54. <span> {{ newsItem.comments_count }}</span>
  55. </div>
  56. </aside></nuxt-link
  57. >
  58. </div>
  59. </div>
  60. </div>
  61. </template>
  62. <script>
  63. import { mapGetters, mapActions } from "vuex";
  64. import global from "@/mixins/global";
  65. export default {
  66. mixins: [global],
  67. props: ['params'],
  68. data: () => {
  69. function declOfNum (n, titles) {
  70. return titles[(n % 10 === 1 && n % 100 !== 11) ? 0 : n % 10 >= 2 && n % 10 <= 4 && (n % 100 < 10 || n % 100 >= 20) ? 1 : 2]
  71. }
  72. function calc_estimate () {
  73. const voteEndDate = new Date()
  74. voteEndDate.setDate(31)
  75. voteEndDate.setHours(23)
  76. voteEndDate.setMinutes(59)
  77. voteEndDate.setSeconds(59)
  78. voteEndDate.setMonth(11)
  79. let diff = voteEndDate.getTime() - (new Date()).getTime()
  80. diff = Math.ceil(diff / (1000))
  81. let estimate = 'С новым 2023 годом!'
  82. if (diff >= 1) {
  83. const days = Math.floor((diff / (3600 * 24)))
  84. estimate = '<b>' + days + '</b>' + ' ' + declOfNum(days, ['день', 'дня', 'дней'])
  85. const hoursEstimate = Math.floor((diff - (days * 3600 * 24)) / 3600)
  86. // estimate += '<br>' + hoursEstimate + ' ' + declOfNum(hoursEstimate, ['час', 'часа', 'часов'])
  87. estimate += '<br>' + '<b>' + hoursEstimate.toString().padStart(2, '0') + ':'
  88. const minutesEstimate = Math.floor((diff - (days * 3600 * 24) - (hoursEstimate * 3600)) / 60)
  89. // estimate += '<br>' + minutesEstimate + ' ' + declOfNum(minutesEstimate, ['минуту', 'минуты', 'минут'])
  90. estimate += minutesEstimate.toString().padStart(2, '0') + ':'
  91. const secondsEstimate = Math.floor((diff - (days * 3600 * 24) - (hoursEstimate * 3600) - (minutesEstimate * 60)))
  92. // estimate += '<br>' + secondsEstimate + ' ' + declOfNum(secondsEstimate, ['секунду', 'секунды', 'секунд'])
  93. estimate += secondsEstimate.toString().padStart(2, '0')
  94. estimate += '</b>'
  95. estimate += '<br>' + declOfNum(hoursEstimate, ['час', 'часа', 'часов'])
  96. }
  97. return estimate
  98. }
  99. let estimate = calc_estimate()
  100. setInterval(function () {
  101. estimate = calc_estimate()
  102. },1000)
  103. return {
  104. countdown: estimate
  105. }
  106. },
  107. created () {
  108. this.getNewsFeedList()
  109. },
  110. mounted () {
  111. setInterval(this.getNewsFeedList, 240000);
  112. setInterval(() => { this.countdown = this.calc_estimate((new Date())) }, 1000)
  113. },
  114. computed: {
  115. ...mapGetters({
  116. newsFeedList: "modules/news/newsFeedList",
  117. }),
  118. nzk_logo(){
  119. return require('~/static/png/nzk_logo.png');
  120. },
  121. },
  122. methods: {
  123. ...mapActions({
  124. getNewsFeedList: "modules/news/getNewsFeedList",
  125. }),
  126. isMobile () {
  127. if (typeof screen !== 'undefined' && screen.width <= 576) {
  128. return true
  129. } else {
  130. return false
  131. }
  132. },
  133. calc_estimate (date) {
  134. function declOfNum (n, titles) {
  135. return titles[(n % 10 === 1 && n % 100 !== 11) ? 0 : n % 10 >= 2 && n % 10 <= 4 && (n % 100 < 10 || n % 100 >= 20) ? 1 : 2]
  136. }
  137. const voteEndDate = new Date()
  138. voteEndDate.setDate(31)
  139. voteEndDate.setHours(23)
  140. voteEndDate.setMinutes(59)
  141. voteEndDate.setSeconds(59)
  142. voteEndDate.setMonth(11)
  143. let diff = voteEndDate.getTime() - date.getTime()
  144. diff = Math.ceil(diff / (1000))
  145. let estimate = 'С новым 2023 годом!'
  146. if (diff >= 1) {
  147. const days = Math.floor((diff / (3600 * 24)))
  148. estimate = '<b>' + days + '</b>' + ' ' + declOfNum(days, ['день', 'дня', 'дней'])
  149. const hoursEstimate = Math.floor((diff - (days * 3600 * 24)) / 3600)
  150. // estimate += '<br>' + hoursEstimate + ' ' + declOfNum(hoursEstimate, ['час', 'часа', 'часов'])
  151. estimate += '<br>' + '<b>' + hoursEstimate.toString().padStart(2, '0') + ':'
  152. const minutesEstimate = Math.floor((diff - (days * 3600 * 24) - (hoursEstimate * 3600)) / 60)
  153. // estimate += '<br>' + minutesEstimate + ' ' + declOfNum(minutesEstimate, ['минуту', 'минуты', 'минут'])
  154. estimate += minutesEstimate.toString().padStart(2, '0') + ':'
  155. const secondsEstimate = Math.floor((diff - (days * 3600 * 24) - (hoursEstimate * 3600) - (minutesEstimate * 60)))
  156. // estimate += '<br>' + secondsEstimate + ' ' + declOfNum(secondsEstimate, ['секунду', 'секунды', 'секунд'])
  157. estimate += secondsEstimate.toString().padStart(2, '0')
  158. estimate += '</b>'
  159. estimate += '<br>' + declOfNum(hoursEstimate, ['час', 'часа', 'часов'])
  160. }
  161. return estimate
  162. }
  163. },
  164. };
  165. </script>
  166. <style lang="less">
  167. .news-side-list {
  168. &__item-title {
  169. overflow: hidden;
  170. text-overflow: ellipsis;
  171. display: -moz-box;
  172. -moz-box-orient: vertical;
  173. display: -webkit-box;
  174. //-webkit-line-clamp: 2;
  175. -webkit-box-orient: vertical;
  176. //line-clamp: 2;
  177. box-orient: vertical;
  178. &.lightning {
  179. display: flex;
  180. align-items: center;
  181. }
  182. &.lightning::before {
  183. margin-right: 15px;
  184. flex: none;
  185. width: 14px;
  186. height: 23px;
  187. content: "";
  188. display: inline-block;
  189. background-size: cover;
  190. background-image: url("~/static/svg/styled/lightning.svg");
  191. }
  192. }
  193. &__item-comments {
  194. }
  195. }
  196. .detail-side__banner{
  197. background: white;
  198. width: 100%;
  199. min-height: 200px;
  200. padding: 20px 0;
  201. box-sizing: border-box;
  202. .test-banner{
  203. width: 240px;
  204. height: 400px;
  205. background: blue;
  206. margin: 0 auto;
  207. }
  208. div{
  209. margin: 0 auto;
  210. text-align: center;
  211. }
  212. }
  213. </style>