Article.vue 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283
  1. <template>
  2. <div>
  3. <section class="detail section longread" :style="'background-image: url(' + (this.news.image ? this.news.image.url : '') + ')'">
  4. <div class="admin-button-in-news" style="margin-bottom: 0;padding-top: 26px;" v-if="userPermissionGroup == 3 || userPermissionGroup == 5">
  5. <a class="copy" :href="'/admin/publications/' + news.id" target="_blank">Редактирование новости</a>
  6. <a class="inject" @click="inject(news)">Инжект</a>
  7. </div>
  8. <div class="detail__wrapper section-wrapper section-wrapper_extra">
  9. <div class="detail-main">
  10. <div class="detail-main__wrapper">
  11. <!--<div class="detail-main__topic">
  12. <ul class="detail-main__topic-list">
  13. <li class="detail-main__topic-item">
  14. <nuxt-link
  15. :to="{ name: 'articles' }"
  16. class="detail-main__topic-link"
  17. >Статьи</nuxt-link
  18. >
  19. </li>
  20. <li class="detail-main__topic-item">
  21. <nuxt-link
  22. :to="{
  23. name: 'news-category',
  24. params: { category: news.category.alias },
  25. }"
  26. class="detail-main__topic-link"
  27. href="javascript:void(0)"
  28. >{{ news.category ? news.category.name : "" }}</nuxt-link
  29. >
  30. </li>
  31. </ul>
  32. </div>-->
  33. <div class="detail-main__top">
  34. <h1 class="detail-top__title title_h1" v-html="news.title"></h1>
  35. <div class="detail-top__date">
  36. {{ convertDate(news.start_activity) }}
  37. </div>
  38. <div class="detail-top__actions">
  39. <div class="detail-top__share">
  40. <div class="socials-share">
  41. <ul class="socials-share__list">
  42. <li class="socials-share__item">
  43. <ShareNetwork
  44. network="Odnoklassniki"
  45. :url="'https://www.amic.ru'+$route.fullPath"
  46. :title="news.title"
  47. class="socials-share__link"
  48. :hashtags="news.hash_tags.length ? news.hash_tags.join(' ') : ''"
  49. >
  50. <BaseIcon :name="'ok'" clear
  51. /></ShareNetwork>
  52. </li>
  53. <li class="socials-share__item">
  54. <ShareNetwork
  55. network="twitter"
  56. :url="'https://www.amic.ru'+$route.fullPath"
  57. :title="news.title"
  58. class="socials-share__link"
  59. :hashtags="news.hash_tags.length ? news.hash_tags.join(' ') : ''"
  60. >
  61. <BaseIcon :name="'tw'" clear
  62. /></ShareNetwork>
  63. </li>
  64. <li class="socials-share__item">
  65. <ShareNetwork
  66. network="vk"
  67. :url="'https://www.amic.ru'+$route.fullPath"
  68. :title="news.title"
  69. :description="news.description"
  70. class="socials-share__link"
  71. :hashtags="news.hash_tags.length ? news.hash_tags.join(' ') : ''"
  72. >
  73. <BaseIcon :name="'vk'" clear
  74. /></ShareNetwork>
  75. </li>
  76. </ul>
  77. </div>
  78. </div>
  79. </div>
  80. <!--<div class="detail-top__footer">
  81. <aside class="detail-top__footer-side">
  82. <div class="detail-top__author">
  83. <div class="news-author news-author_article">
  84. <NewsAuthor :news="news" />
  85. <p>{{ news.image ? news.image.title : ''}}</p>
  86. </div>
  87. </div>
  88. <div class="detail-top__info">
  89. <p>{{ news.source }}</p>
  90. <p>{{ news.image ? news.image.title : ''}}</p>
  91. </div>
  92. <div class="detail-top__tags">
  93. <ul class="detail-top__tags-list">
  94. <li class="detail-top__tags-item"
  95. v-for="tag in news.hash_tags"
  96. :key="tag">
  97. <a class="detail-top__tags-link" href="javascript:void(0)" >
  98. {{ tag }}</a>
  99. </li>
  100. </ul>
  101. </div>
  102. </aside>
  103. </div>-->
  104. </div>
  105. <div class="detail-main__description" v-html="news.description"></div>
  106. <NewsContent :rawHtml="news.content" />
  107. <div v-if="news.show_pull">
  108. <ArticleCommentsList :pull_id="news.comment_pull_id" @commentResponse="commentResponseData" :newCommentsList="commentsList" />
  109. <ArticleCommentsForm :pull_id="news.comment_pull_id" :response_user_name="this.comment.response_user_name" :response_user_id="this.comment.response_user_id" @clearCommentResponse="clearCommentResponse" @commentsResponseData="commentsResponseData" />
  110. </div>
  111. </div>
  112. </div>
  113. </div>
  114. </section>
  115. </div>
  116. </template>
  117. <script>
  118. export default {
  119. props: {
  120. news: {
  121. type: Object,
  122. },
  123. },
  124. data() {
  125. return {
  126. userPermissionGroup: null,
  127. comment: {
  128. text: "",
  129. response_user_id: "",
  130. response_user_name: "",
  131. pullId: this.news.comment_pull_id
  132. },
  133. commentsList: {}
  134. }
  135. },
  136. mounted() {
  137. if(this.$store.state.auth.user){
  138. this.userPermissionGroup = this.$store.state.auth.user.user_permission_group;
  139. }
  140. },
  141. methods: {
  142. convertDate(dateTampstamp) {
  143. const date = new Date(dateTampstamp * 1000);
  144. const dateString =
  145. date.toLocaleString("ru", {
  146. day: 'numeric',
  147. month: 'long'
  148. }) +
  149. " " +
  150. date.getFullYear()
  151. + ", " +
  152. ("0" + date.getHours()).slice(-2) +
  153. ":" +
  154. ("0" + date.getMinutes()).slice(-2);
  155. return dateString;
  156. },
  157. commentResponseData(data){
  158. this.comment.response_user_id = data.user_id;
  159. this.comment.response_user_name = data.user_name;
  160. },
  161. clearCommentResponse(){
  162. this.comment.response_user_id = "";
  163. this.comment.response_user_name = "";
  164. },
  165. inject(item) {
  166. let res = "##news_" + item.id + "##";
  167. this.$clipboard(res);
  168. alert('Инжект скопирован в буфер обмена');
  169. },
  170. commentsResponseData(data){
  171. this.commentsList = data;
  172. },
  173. },
  174. };
  175. </script>
  176. <style lang="less">
  177. .longread{
  178. background-size: contain;
  179. .detail-main{
  180. background: linear-gradient(90deg, rgba(255,255,255,0.3) 0%, rgba(255,255,255,1) 52%, rgba(255,255,255,0.3) 100%);
  181. border-radius: 30px;
  182. margin-top: 100px;
  183. @media screen and(max-width: 768px) {
  184. margin-top: 0px;
  185. }
  186. &__wrapper{
  187. padding: 0 30px;
  188. @media screen and(max-width: 768px) {
  189. padding: 0;
  190. }
  191. }
  192. &__topic-list{
  193. justify-content: center;
  194. margin: 20px 0;
  195. }
  196. &__top{
  197. text-align: center;
  198. h1{
  199. max-width: 700px;
  200. margin: 150px auto 50px;
  201. font-size: 52px;
  202. line-height: 120%;
  203. @media screen and(max-width: 768px) {
  204. font-size: 20px;
  205. margin: 30px auto 20px;
  206. padding: 0 10px;
  207. }
  208. }
  209. .socials-share{
  210. &__list{
  211. justify-content: center;
  212. }
  213. }
  214. .detail-top{
  215. &__author{
  216. margin: 50px 0 20px;
  217. }
  218. &__footer{
  219. justify-content: center;
  220. }
  221. }
  222. }
  223. &__description {
  224. text-align: center;
  225. font-size: 20px;
  226. margin-bottom: 30px;
  227. @media screen and(max-width: 768px) {
  228. font-size: 16px;
  229. margin-bottom: 30px;
  230. padding: 0 10px;
  231. }
  232. }
  233. &__article{
  234. background: white;
  235. padding: 50px;
  236. box-sizing: border-box;
  237. border-radius: 20px;
  238. @media screen and(max-width: 768px) {
  239. padding: 1px 15px;
  240. }
  241. h1,h2,h3,h4{
  242. margin: 30px 0 20px;
  243. }
  244. p,h1,h2,h3{
  245. max-width: 700px;
  246. margin-left: auto;
  247. margin-right: auto;
  248. color: #222;
  249. }
  250. blockquote{
  251. margin: 60px 0;
  252. padding: 30px 0;
  253. border-top: 1px solid #ccc;
  254. border-bottom: 1px solid #ccc;
  255. @media screen and(max-width: 768px) {
  256. margin: 20px 0;
  257. padding: 10px 0;
  258. }
  259. p{
  260. font-size: 38px;
  261. max-width: 90%;
  262. line-height: 140%;
  263. @media screen and(max-width: 768px) {
  264. font-size: 18px;
  265. }
  266. }
  267. }
  268. }
  269. }
  270. }
  271. .news-author__figure {
  272. flex: none;
  273. width: 50px;
  274. height: 50px;
  275. }
  276. .news-author__img {
  277. max-width: 100%;
  278. }
  279. </style>