_alias.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373
  1. <template>
  2. <div>
  3. <template v-if="$isAMP">
  4. <NewsAmp :news="newsItem"></NewsAmp>
  5. </template>
  6. <template v-else>
  7. <NewsArticle :news="newsItem" :data-io-article-url="this.url" />
  8. <section class="grid grid_mb section">
  9. <div class="grid__wrapper section-wrapper">
  10. <div class="grid__title grid__title_left">Новости партнеров</div>
  11. <div v-for="(ads, i) in adsList" :key="i" class="av__news">
  12. <div style="heght: 400px" :id="ads.ad_click_url"></div>
  13. <script>
  14. {{ ads ? ads.script.replace(/\\/g, ``) : ''}}
  15. </script>
  16. </div>
  17. </div>
  18. </section>
  19. <NewsArticle v-if="$device.isMobile" v-for="nextNewsItem in nextNews" :news="nextNewsItem" :isNextNews="true" />
  20. <div class="news-loading" v-if="loadNextNews"></div>
  21. </template>
  22. </div>
  23. </template>
  24. <script>
  25. import { mapGetters } from "vuex";
  26. import InfiniteLoading from 'vue-infinite-loading';
  27. export default {
  28. amp: 'hybrid',
  29. ampLayout: "amp",
  30. components:{
  31. InfiniteLoading
  32. },
  33. data() {
  34. return {
  35. adsList: [],
  36. list: [],
  37. count: 0,
  38. loadNextNews: false,
  39. nextNews: [],
  40. newsTime: null,
  41. iNextNews: 0
  42. }
  43. },
  44. jsonld() {
  45. var articleDate = new Date(this.newsItem.start_activity*1000).toISOString().substr(0,19) + '+07:00',
  46. author = this.newsItem.show_author ? this.newsItem.author ? this.newsItem.author.name : 'ИА Амител' : 'ИА Амител';
  47. return {
  48. '@context': 'https://schema.org',
  49. '@type': 'NewsArticle',
  50. mainEntityOfPage: {
  51. '@type': "WebPage",
  52. '@id': this.url
  53. },
  54. headline: this.newsItem.title.slice(0,110),
  55. description: this.newsItem.description,
  56. image: this.newsItem.image ? this.newsItem.image.url : '',
  57. datePublished: articleDate,
  58. author: {
  59. '@type': 'Person',
  60. name: author
  61. },
  62. publisher: {
  63. '@type': 'Organization',
  64. name: 'ИА "Амител"',
  65. logo: {
  66. '@type': 'ImageObject',
  67. url: require('~/static/svg/symbol/amic-logo.svg')
  68. }
  69. },
  70. };
  71. },
  72. computed: {
  73. ...mapGetters({
  74. newsItem: "modules/news/newsItem",
  75. partners1: "modules/ads/partners1",
  76. partners2: "modules/ads/partners2",
  77. partners3: "modules/ads/partners3",
  78. partners4: "modules/ads/partners4",
  79. partners5: "modules/ads/partners5"
  80. }),
  81. status() {
  82. if (!this.ads) {
  83. return false;
  84. } else {
  85. return true;
  86. }
  87. },
  88. },
  89. mounted () {
  90. this.adsList.push(this.partners5)
  91. this.adsList.push(this.partners3)
  92. this.adsList.push(this.partners1)
  93. this.adsList.push(this.partners2)
  94. this.adsList.push(this.partners4)
  95. this.newsTime = this.newsItem.start_activity
  96. this.scroll()
  97. const s = document.createElement('script')
  98. s.innerHTML = `
  99. let invoked = false;
  100. window.addEventListener('scroll', function () {
  101. if (window.pageYOffset > 500 && invoked == false) {
  102. invoked = true;
  103. adfoxCallOverlay = function () {
  104. window.Ya.adfoxCode.hbCallbacks.push(function() {
  105. window.yaContextCb.push(function() {
  106. Ya.adfoxCode.create({
  107. ownerId: 359693,
  108. containerId: 'adfox_16709195876369765',
  109. params: {
  110. pp: 'bqeb',
  111. ps: 'gduo',
  112. p2: 'hywv'
  113. },
  114. onLoad: function(data) {
  115. console.log(data);
  116. },
  117. onRender: function () {
  118. console.log('ads rendered');
  119. },
  120. onError: function (error) {
  121. console.log(error);
  122. },
  123. onStub: function () {
  124. console.log('Server return no ad');
  125. }
  126. }, ['tablet', 'phone'], {
  127. tabletWidth: 1023,
  128. phoneWidth: 768,
  129. isAutoReloads: false
  130. });
  131. });
  132. });
  133. };
  134. makeAdfinityOverlay(adfoxCallOverlay, 5, 0, "adfox_16709195876369765", 300, 180,
  135. false);
  136. }
  137. });
  138. `
  139. document.body.appendChild(s)
  140. },
  141. async fetch({ store, route, redirect, error }) {
  142. await store.dispatch("modules/news/setNewsItem", route.params);
  143. await store.dispatch("modules/ads/getAds");
  144. const newsItem = store.getters['modules/news/newsItem'];
  145. if(!newsItem) error({ statusCode: 404 });
  146. if(newsItem.category.parent){
  147. if(newsItem.category.parent.alias === 'video'){
  148. redirect ('/video/' + newsItem.category.alias + '/' + newsItem.alias);
  149. }
  150. if (newsItem.category.parent.alias === 'slushay'){
  151. redirect ('/podcasts/' + newsItem.category.alias + '/' + newsItem.alias);
  152. }
  153. }
  154. if(newsItem && newsItem.link) redirect (newsItem.link);
  155. },
  156. async asyncData(context) {
  157. const host = context.req ? context.req.headers.host : window.location.origin;
  158. const url = host + context.route.path;
  159. return { url }
  160. },
  161. head() {
  162. return {
  163. title: this.newsItem.title,
  164. meta: [
  165. {
  166. name: "author",
  167. content: this.newsItem.show_author ? this.newsItem.author ? this.newsItem.author.name : 'ИА Амител' : "ИА Амител",
  168. },
  169. {
  170. name: "copyright",
  171. content: "ИА Амител",
  172. },
  173. {
  174. name: "publisher",
  175. content: "https://g.page/amitel?gm",
  176. },
  177. {
  178. name: "mediator_author",
  179. content: "ИА Амител",
  180. },
  181. {
  182. name: "description",
  183. content: this.newsItem.description ? this.newsItem.description : '',
  184. },
  185. {
  186. name: "keys",
  187. content: this.newsItem.meta.key ? this.newsItem.meta.key : '',
  188. },
  189. {
  190. hid: 'twitter:title',
  191. name: 'twitter:title',
  192. content: this.newsItem.title
  193. },
  194. {
  195. hid: 'twitter:description',
  196. name: 'twitter:description',
  197. content: this.newsItem.description
  198. },
  199. {
  200. hid: 'twitter:image',
  201. name: 'twitter:image',
  202. // content: this.newsItem.image ? this.newsItem.image.url : ''
  203. },
  204. {
  205. hid: 'twitter:image:alt',
  206. name: 'twitter:image:alt',
  207. content: this.newsItem.title
  208. },
  209. {
  210. hid: 'og:title',
  211. property: 'og:title',
  212. content: this.newsItem.title
  213. },
  214. {
  215. hid: 'og:description',
  216. property: 'og:description',
  217. content: this.newsItem.description
  218. },
  219. {
  220. hid: 'og:image',
  221. property: 'og:image',
  222. content: this.newsItem.image ? this.newsItem.image.url : ''
  223. },
  224. {
  225. hid: 'og:image:secure_url',
  226. property: 'og:image:secure_url',
  227. content: this.newsItem.image ? this.newsItem.image.url : ''
  228. },
  229. {
  230. hid: 'og:image:alt',
  231. property: 'og:image:alt',
  232. content: this.newsItem.title
  233. },
  234. {
  235. hid: 'og:type',
  236. property: 'og:type',
  237. content: 'website'
  238. },
  239. {
  240. hid: 'og:site_name',
  241. property: 'og:site_name',
  242. content: 'amic'
  243. },
  244. {
  245. hid: 'og:url',
  246. property: 'og:url',
  247. content: this.url
  248. },
  249. {
  250. hid: 'fb:app_id',
  251. property: 'fb:app_id',
  252. content: '4369125136471767'
  253. },
  254. ],
  255. link: [
  256. {rel: 'canonical', href: this.newsItem.category ? 'https://www.amic.ru/news/' + this.newsItem.category.alias + '/' + this.newsItem.alias : ''},
  257. ],
  258. script: [
  259. {
  260. //src: 'https://cdn.onthe.io/io.js/d7T3K6DqlqQy',
  261. async: true
  262. },
  263. {
  264. body: true,
  265. innerHTML: `this._io_config = this._io_config || {};
  266. this._io_config["0.2.0"] = this._io_config["0.2.0"] || [];
  267. this._io_config["0.2.0"].push({
  268. page_url: "${this.url}",
  269. page_url_canonical: "${this.url}",
  270. page_title: '${this.newsItem.title}',
  271. page_type: "article",
  272. page_language: "ru",
  273. article_authors: ["${this.newsItem.author ? this.newsItem.author.name : 'ИА Амител'}"],
  274. article_categories: ["${this.newsItem.category.name}"],
  275. article_type: "Статья",
  276. article_publication_date: "${ new Date(this.newsItem.start_activity*1000).toUTCString() }"
  277. })`
  278. },
  279. {
  280. src: 'https://cdn.ampproject.org/v0/amp-analytics-0.1.js',
  281. async: true,
  282. 'custom-element': 'amp-analytics'
  283. },
  284. ],
  285. __dangerouslyDisableSanitizers: ['script']
  286. };
  287. },
  288. methods: {
  289. infiniteHandler($state) {
  290. console.log("handle");
  291. if (this.count < 4) {
  292. setTimeout(() => {
  293. this.count += 1;
  294. this.adsList.push(this.list[this.count]);
  295. $state.loaded();
  296. }, 1000);
  297. } else {
  298. $state.complete();
  299. }
  300. },
  301. scroll() {
  302. window.onscroll = () => {
  303. let isBottom = (document.documentElement.scrollTop + window.innerHeight) > document.documentElement.offsetHeight - 590;
  304. if (isBottom && !this.loadNextNews && this.newsTime && this.$device.isMobile && !this.$isAMP) {
  305. this.loadNextNews = true;
  306. this.$axios.$get("news/next/" + this.newsTime).then((res) => {
  307. if(res.success){
  308. this.nextNews.push(res.data);
  309. this.newsTime = res.data.start_activity;
  310. this.loadNextNews = false;
  311. }
  312. });
  313. }
  314. };
  315. }
  316. }
  317. };
  318. </script>
  319. <style lang="less">
  320. .detail-top__header {
  321. /*margin-bottom: 50px;*/
  322. }
  323. @media screen and (max-width: 900px) {
  324. .detail {
  325. &__wrapper {
  326. flex-direction: column-reverse;
  327. }
  328. &__side {
  329. margin-bottom: 20px;
  330. display: none;
  331. }
  332. }
  333. .detail-top {
  334. &__header {
  335. display: block;
  336. }
  337. &__footer {
  338. display: block;
  339. }
  340. &__footer-side {
  341. display: flex;
  342. margin-top: 20px;
  343. }
  344. }
  345. .detail-article-news__wrapper {
  346. display: block;
  347. }
  348. }
  349. .detail-article-news__side {
  350. display: flex;
  351. align-items: center;
  352. }
  353. .av__news {
  354. margin-bottom: 50px;
  355. }
  356. .news-loading{
  357. width: 25px;
  358. height: 25px;
  359. text-align: center;
  360. margin: 8px auto;
  361. background-image: url("data:image/svg+xml;charset=UTF-8,%3c?xml version='1.0' encoding='UTF-8' standalone='no'?%3e%3csvg xmlns:svg='http://www.w3.org/2000/svg' xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink' version='1.0' width='64px' height='64px' viewBox='0 0 128 128' xml:space='preserve'%3e%3cg%3e%3cpath d='M59.6 0h8v40h-8V0z' fill='%23000000'/%3e%3cpath d='M59.6 0h8v40h-8V0z' fill='%23cccccc' transform='rotate(30 64 64)'/%3e%3cpath d='M59.6 0h8v40h-8V0z' fill='%23cccccc' transform='rotate(60 64 64)'/%3e%3cpath d='M59.6 0h8v40h-8V0z' fill='%23cccccc' transform='rotate(90 64 64)'/%3e%3cpath d='M59.6 0h8v40h-8V0z' fill='%23cccccc' transform='rotate(120 64 64)'/%3e%3cpath d='M59.6 0h8v40h-8V0z' fill='%23b2b2b2' transform='rotate(150 64 64)'/%3e%3cpath d='M59.6 0h8v40h-8V0z' fill='%23999999' transform='rotate(180 64 64)'/%3e%3cpath d='M59.6 0h8v40h-8V0z' fill='%237f7f7f' transform='rotate(210 64 64)'/%3e%3cpath d='M59.6 0h8v40h-8V0z' fill='%23666666' transform='rotate(240 64 64)'/%3e%3cpath d='M59.6 0h8v40h-8V0z' fill='%234c4c4c' transform='rotate(270 64 64)'/%3e%3cpath d='M59.6 0h8v40h-8V0z' fill='%23333333' transform='rotate(300 64 64)'/%3e%3cpath d='M59.6 0h8v40h-8V0z' fill='%23191919' transform='rotate(330 64 64)'/%3e%3canimateTransform attributeName='transform' type='rotate' values='0 64 64;30 64 64;60 64 64;90 64 64;120 64 64;150 64 64;180 64 64;210 64 64;240 64 64;270 64 64;300 64 64;330 64 64' calcMode='discrete' dur='600ms' repeatCount='indefinite'%3e%3c/animateTransform%3e%3c/g%3e%3c/svg%3e");
  362. background-position: center;
  363. background-repeat: no-repeat;
  364. background-size: 100%;
  365. opacity: .4;
  366. }
  367. </style>