Advertisement
Guest User

Untitled

a guest
Mar 5th, 2019
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Vue.component("webview-relation", {
  2.   template: `
  3.         <section class="webview-relation">
  4.             <div class="container">
  5.                 <div class="row">
  6.                     <div class="col-xs-12">
  7.                         <transition-group name="webview-relation">
  8.                             <div class="webview-relation-box"
  9.                                 v-for="(item, index) in relations"
  10.                                 :key="item.id"
  11.                                 :class="{'webview-relation-box--first webview-relation-box--first--animation' : index === 0}">
  12.                                 <span class="webview-relation-box--time">{{ item.release_date_hour }}</span>
  13.                                 <div class="webview-relation-box--text" v-html="item.content"></div>
  14.                             </div>
  15.                         </transition-group>
  16.                     </div>
  17.                 </div>
  18.             </div>
  19.         </section>
  20.         `,
  21.   data() {
  22.     return {
  23.       relations: window.__timelineData.items
  24.     };
  25.   },
  26.   methods: {
  27.     getLastItemUrl() {
  28.       const host = window.location.origin;
  29.       const _IDArticle = window.__newsData.id;
  30.            
  31.       return `http://rc.tvp.info/shared/details_obj.php?object_id=${_IDArticle}&template=json/timeline.html&last=${this.relations[0].release_date_long}`;
  32.    
  33.     },
  34.     uploadData() {
  35.       const url = this.getLastItemUrl();
  36.  
  37.       axios.get(url, {}, {
  38.         withCredentials: true,
  39.         auth: {
  40.           username: "tvprc",
  41.           password: "T20V18Prc+V0dQQ"
  42.         },
  43.         headers: {
  44.           'Content-Type': 'application/json',
  45.         }
  46.       })
  47.         .then(res => {
  48.           console.log(res.data)
  49.           if (res.data.items.length > 0) {
  50.             this.addRelation(res.data.items[0]);
  51.           }
  52.           this.refreshData();
  53.       })
  54.     },
  55.     addRelation(relation) {
  56.       return this.relations.splice(0, 0, relation);
  57.     },
  58.     loadTwitter() {
  59.       return twttr.widgets.load();
  60.     },
  61.     refreshData() {
  62.       return setTimeout(this.uploadData, 5000);
  63.     }
  64.   },
  65.   mounted() {
  66.     this.refreshData();
  67.     this.loadTwitter();
  68.   }
  69. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement