DiscoverComponent.vue 3.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. <template>
  2. <div class="container">
  3. <section class="mb-5 section-people">
  4. <p class="lead text-muted font-weight-bold mb-0">Discover People</p>
  5. <div class="loader text-center">
  6. <div class="lds-ring"><div></div><div></div><div></div><div></div></div>
  7. </div>
  8. <div class="row d-none">
  9. <div class="col-4 p-0 p-sm-2 p-md-3" v-for="profile in people">
  10. <div class="card card-md-border-0">
  11. <div class="card-body p-4 text-center">
  12. <div class="avatar pb-3">
  13. <a :href="profile.url">
  14. <img :src="profile.avatar" class="img-thumbnail rounded-circle" width="64px">
  15. </a>
  16. </div>
  17. <p class="lead font-weight-bold mb-0 text-truncate"><a :href="profile.url" class="text-dark">{{profile.username}}</a></p>
  18. <p class="text-muted text-truncate">{{profile.name}}</p>
  19. <form class="follow-form" method="post" action="/i/follow" data-id="#" data-action="follow">
  20. <input type="hidden" name="item" value="#">
  21. <button class="btn btn-primary font-weight-bold px-4 py-0" type="submit">Follow</button>
  22. </form>
  23. </div>
  24. </div>
  25. </div>
  26. </div>
  27. </section>
  28. <section class="mb-5 section-explore">
  29. <p class="lead text-muted font-weight-bold mb-0">Explore</p>
  30. <div class="profile-timeline">
  31. <div class="loader text-center">
  32. <div class="lds-ring"><div></div><div></div><div></div><div></div></div>
  33. </div>
  34. <div class="row d-none">
  35. <div class="col-4 p-0 p-sm-2 p-md-3" v-for="post in posts">
  36. <a class="card info-overlay card-md-border-0" :href="post.url">
  37. <div class="square filter_class">
  38. <div class="square-content" v-bind:style="{ 'background-image': 'url(' + post.thumb + ')' }"></div>
  39. <div class="info-overlay-text">
  40. <h5 class="text-white m-auto font-weight-bold">
  41. <span class="pr-4">
  42. <span class="far fa-heart fa-lg pr-1"></span> {{post.likes_count}}
  43. </span>
  44. <span>
  45. <span class="far fa-comment fa-lg pr-1"></span> {{post.comments_count}}
  46. </span>
  47. </h5>
  48. </div>
  49. </div>
  50. </a>
  51. </div>
  52. </div>
  53. </div>
  54. </section>
  55. <section class="mb-5">
  56. <p class="lead text-center">To view more posts, check the <a href="#" class="font-weight-bold">home</a>, <a href="#" class="font-weight-bold">local</a> or <a href="#" class="font-weight-bold">federated</a> timelines.</p>
  57. </section>
  58. </div>
  59. </template>
  60. <script type="text/javascript">
  61. export default {
  62. data() {
  63. return {
  64. people: {},
  65. posts: {},
  66. trending: {}
  67. }
  68. },
  69. mounted() {
  70. this.fetchData();
  71. },
  72. methods: {
  73. fetchData() {
  74. axios.get('/api/v2/discover')
  75. .then((res) => {
  76. let data = res.data;
  77. this.people = data.people;
  78. this.posts = data.posts;
  79. if(this.people.length > 1) {
  80. $('.section-people .lds-ring').hide();
  81. $('.section-people .row.d-none').removeClass('d-none');
  82. }
  83. if(this.posts.length > 1) {
  84. $('.section-explore .lds-ring').hide();
  85. $('.section-explore .row.d-none').removeClass('d-none');
  86. }
  87. });
  88. }
  89. }
  90. }
  91. </script>