Storie.vue 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403
  1. <template>
  2. <div class="storie__wrapper" v-if="storie.image">
  3. <div class="storie__close" @click="close()">×</div>
  4. <div class="storie__prev" @click="prev()"></div>
  5. <div class="storie__next" @click="nextStorie()"></div>
  6. <div
  7. class="storie__bg-image"
  8. :style="'background-image:url(' + storie.image.url + ')'"
  9. ></div>
  10. <div
  11. class="storie__progress"
  12. role="progressbar"
  13. :aria-valuenow="progress"
  14. aria-valuemin="0"
  15. aria-valuemax="100"
  16. :style="{ width: `${progress}%` }"
  17. ></div>
  18. <div class="storie__progress-line"></div>
  19. <div class="storie__info">
  20. <div class="storie__logo">
  21. <BaseIcon :name="'amic-logo'" />
  22. </div>
  23. <div class="storie__title">
  24. <span><a @click="read" v-html="storie.title"></a></span>
  25. <button @click="read" class="storie__news-link">
  26. Читать полностью
  27. </button>
  28. </div>
  29. </div>
  30. <NewsBackgroundImage class="storie__content" :news="storie" />
  31. <div class="storie__comments">
  32. <div class="storie__comments-wrapper">
  33. <div
  34. v-for="comment in comments.comments"
  35. :key="comment.id"
  36. class="storie__comment"
  37. >
  38. <div class="detail-comments__item">
  39. <div class="detail-comments-item">
  40. <div class="detail-comments-item__text">
  41. {{ comment.text }}
  42. </div>
  43. <span> {{ $convertDate(comment.create) }} </span>
  44. </div>
  45. </div>
  46. </div>
  47. </div>
  48. </div>
  49. </div>
  50. </template>
  51. <script>
  52. import { mapGetters } from "vuex";
  53. export default {
  54. props: {
  55. num: {
  56. type: Number,
  57. },
  58. },
  59. data() {
  60. return {
  61. storie: {},
  62. comments: [],
  63. progress: 0,
  64. completed: false,
  65. tempo: 50,
  66. storieIndex: this.num,
  67. };
  68. },
  69. computed: {
  70. ...mapGetters({
  71. stories: "modules/news/stories",
  72. }),
  73. id() {
  74. return this.stories[this.num].id;
  75. },
  76. },
  77. methods: {
  78. close() {
  79. this.progress = 0;
  80. this.completed = true;
  81. this.$modal.hide('storie')
  82. },
  83. read() {
  84. this.progress = 0;
  85. this.completed = true;
  86. this.$modal.hide("storie");
  87. this.$router.push({
  88. name: "news-category-alias",
  89. params: {
  90. category: this.storie.category.alias,
  91. alias: this.storie.alias,
  92. },
  93. });
  94. },
  95. convertDate(dateTampstamp) {
  96. const date = new Date(dateTampstamp * 1000);
  97. const dateString =
  98. ("0" + date.getHours()).slice(-2) +
  99. ":" +
  100. ("0" + date.getMinutes()).slice(-2) +
  101. ", " +
  102. ("0" + date.getDate()).slice(-2) +
  103. " " +
  104. date.toLocaleString("ru", { month: "long" }) +
  105. " " +
  106. date.getFullYear();
  107. return dateString;
  108. },
  109. timer(tempo) {
  110. let setIntervalRef = setInterval(() => {
  111. if (!this.completed) {
  112. this.progress++;
  113. }
  114. if (this.progress == 100) {
  115. clearInterval(setIntervalRef);
  116. this.completed = true;
  117. if (this.storieIndex + 1 < this.stories.length) {
  118. this.nextStorie(true);
  119. }
  120. }
  121. }, tempo);
  122. },
  123. prev() {
  124. if (this.storieIndex !== 0){
  125. this.progress = 0;
  126. this.storieIndex--;
  127. this.storie = this.stories[this.storieIndex];
  128. this.$axios
  129. .get("comments/pull_" + this.storie.comment_pull_id)
  130. .then((res) => {
  131. this.comments = res.data.data;
  132. if (this.completed) {
  133. this.completed = false;
  134. this.timer(this.tempo);
  135. }
  136. });
  137. }
  138. },
  139. nextStorie(repeat) {
  140. if (this.storieIndex + 1 < this.stories.length) {
  141. this.progress = 0;
  142. this.completed = false;
  143. if (this.storieIndex + 1 < this.stories.length) {
  144. this.storieIndex++;
  145. }
  146. this.storie = this.stories[this.storieIndex];
  147. this.$axios
  148. .get("comments/pull_" + this.storie.comment_pull_id)
  149. .then((res) => {
  150. this.comments = res.data.data;
  151. if (repeat) {
  152. this.timer(this.tempo);
  153. }
  154. });
  155. }},
  156. },
  157. async fetch() {
  158. this.storie = this.stories[this.storieIndex];
  159. await this.$axios
  160. .get("comments/pull_" + this.storie.comment_pull_id)
  161. .then((res) => {
  162. this.comments = res.data.data;
  163. this.timer(this.tempo);
  164. });
  165. },
  166. updated() {},
  167. };
  168. </script>
  169. <style lang="less">
  170. .storie {
  171. &__prev {
  172. position: absolute;
  173. left: 0;
  174. top: 0;
  175. bottom: 0;
  176. width: 200px;
  177. content: "";
  178. z-index: 44;
  179. }
  180. &__next {
  181. position: absolute;
  182. right: 0;
  183. top: 0;
  184. bottom: 0;
  185. width: 200px;
  186. content: "";
  187. z-index: 44;
  188. }
  189. }
  190. .vm--modal {
  191. border-radius: none;
  192. }
  193. .storie {
  194. &__logo {
  195. position: absolute;
  196. left: 10%;
  197. top: 5%;
  198. width: 100px;
  199. height: 100px;
  200. border-radius: 50%;
  201. background: white;
  202. text-align: center;
  203. padding-top: 35px;
  204. z-index:1;
  205. @media (max-width: 576px) {
  206. display: none;
  207. }
  208. }
  209. &__modal {
  210. background: grey;
  211. }
  212. &__news-link {
  213. display: block;
  214. font-size: 16px;
  215. color: white;
  216. padding: 20px 0;
  217. }
  218. &__wrapper {
  219. max-height: 100vh;
  220. overflow: hidden;
  221. height: 100%;
  222. display: flex;
  223. &::before {
  224. position: absolute;
  225. left: 0;
  226. right: 0;
  227. bottom: 0;
  228. top: 0;
  229. content: "";
  230. background-color: rgba(0, 0, 0, 0.5);
  231. z-index: 1;
  232. }
  233. @media (max-width: 576px) {
  234. flex-direction: column;
  235. }
  236. }
  237. &__bg-image {
  238. filter: blur(8px);
  239. background-size: cover;
  240. position: absolute;
  241. left: 0;
  242. right: 0;
  243. bottom: 0;
  244. top: 0;
  245. content: "";
  246. z-index: 0;
  247. background-color: black;
  248. }
  249. &__content {
  250. max-height: 100%;
  251. height: 90%;
  252. flex: 0 1 40%;
  253. background-size: contain;
  254. background-position: 50%;
  255. z-index: 3;
  256. position: relative;
  257. margin: auto 0;
  258. background-color: black;
  259. border-radius: 20px;
  260. @media (max-width: 576px) {
  261. border-radius: 0;
  262. background-color: transparent;
  263. background-size: cover;
  264. }
  265. }
  266. &__info {
  267. flex: 0 1 30%;
  268. position: relative;
  269. color: white;
  270. }
  271. &__title {
  272. position: relative;
  273. z-index: 99999;
  274. }
  275. &__comment {
  276. margin-bottom: 20px;
  277. }
  278. &__comments {
  279. flex: 0 1 30%;
  280. z-index: 3;
  281. position: relative;
  282. max-width: 80%;
  283. display: flex;
  284. flex-direction: column;
  285. justify-content: center;
  286. font-size: 16px;
  287. padding: 0 5%;
  288. &-wrapper {
  289. overflow-y: scroll;
  290. &::-webkit-scrollbar {
  291. width: 0px;
  292. background: transparent;
  293. }
  294. }
  295. .detail-comments-item__text {
  296. color: white;
  297. font-size: 14px;
  298. }
  299. .detail-comments-item span {
  300. font-size: 12px;
  301. color: white;
  302. opacity: 0.5;
  303. }
  304. .detail-comments__item::marker {
  305. display: none;
  306. }
  307. @media (max-width: 576px) {
  308. overflow-y: scroll;
  309. z-index: 45;
  310. &-wrapper {
  311. overflow-y: unset;
  312. }
  313. }
  314. }
  315. &__info {
  316. display: flex;
  317. align-items: center;
  318. @media (max-width: 576px) {
  319. display: block;
  320. max-height: 20%;
  321. }
  322. }
  323. &__title {
  324. font-size: 28px;
  325. font-weight: bold;
  326. max-width: 85%;
  327. display: block;
  328. margin: 20px auto;
  329. padding-bottom: 30%;
  330. line-height: 130%;
  331. span {
  332. background: #000;
  333. padding: 2px;
  334. box-shadow: 10px 0 0 black, -10px 0 0 black;
  335. a{
  336. color: white;
  337. cursor: pointer;
  338. }
  339. }
  340. }
  341. @media (max-width: 576px) {
  342. &__title {
  343. font-size: 18px;
  344. margin: 20px 60px 20px 20px;
  345. }
  346. }
  347. &__comments {
  348. font-size: 20px;
  349. max-width: 80%;
  350. margin: auto;
  351. height: 90%;
  352. max-height: 100%;
  353. }
  354. &__progress {
  355. position: absolute;
  356. top: 0;
  357. left: 0;
  358. width: 0%;
  359. height: 5px;
  360. content: "";
  361. background-color: #f6911f;
  362. z-index: 11;
  363. border-radius: 0 4px 4px 0;
  364. }
  365. &__progress-line {
  366. position: absolute;
  367. top: 0;
  368. left: 0;
  369. width: 100%;
  370. height: 5px;
  371. content: "";
  372. background-color: transparent;
  373. z-index: 10;
  374. border-radius: 0 4px 4px 0;
  375. }
  376. &__close {
  377. position: absolute;
  378. content: "×";
  379. font-weight: 100;
  380. width: 55px;
  381. z-index: 523455435345;
  382. height: 55px;
  383. text-align: center;
  384. font-size: 55px;
  385. font-family: Arial, sans-serif;
  386. right: 3%;
  387. color: white;
  388. top: 5%;
  389. cursor: pointer;
  390. opacity: .2;
  391. &:hover {
  392. opacity: .4;
  393. }
  394. @media (max-width: 576px) {
  395. top: 0;
  396. right: 0;
  397. }
  398. }
  399. }
  400. </style>