Advertisement
Guest User

Untitled

a guest
Mar 23rd, 2019
299
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.32 KB | None | 0 0
  1. <template>
  2. <div>
  3. // fiter component
  4. <div class="flex flex-col flex-wrap md:flex-row items-start justify-start">
  5. <template v-if="loading">
  6. <loading-tile v-for="(item, index) in 6"
  7. :key="index"></loading-tile>
  8. </template>
  9. <a :href="item.url"
  10. target="_blank"
  11. v-else
  12. v-for="item in data" :key="item.id"
  13. class="w-full md:w-1/2 lg:w-1/3 group max-w-md text-left md:px-4 lazy-item mb-8 md:mb-16">
  14. <div class="h-48 lg:h-64 overflow-hidden relative rounded-t-sm">
  15. <div class="group-hover:hover-scale transition w-full h-full bg-cover bg-center bg-no-repeat flex items-end"
  16. :style="{ 'background-image': 'url(' + item.small_url + ')' }">
  17. </div>
  18. <i :class="getIconClass(item.type)"
  19. class="absolute pin-l pin-b ml-8 mb-4 text-2xl text-white"></i>
  20. </div>
  21. <div class="border border-grey-border group-hover:translate-5 transition group-hover:shadow-lg p-8 md:p-4 rounded-b-lg lg:p-8 bg-white">
  22. <h3 class="mb-4 md:mb-2 font-black tracking-wide lg:mb-4 text-xl">
  23. {{ item.title }}
  24. </h3>
  25. <p class="leading-normal font-normal">
  26. {{ item.summary }}
  27. </p>
  28. </div>
  29. </a>
  30. </div>
  31. <div v-show="data && data.length === 0"
  32. class="mx-auto px-4 flex items-center justify-center h-64">
  33. <h2>
  34. {{ $t('general.no-results') }}
  35. </h2>
  36. </div>
  37. // pagination component
  38. </div>
  39. </template>
  40.  
  41. <script>
  42. export default {
  43. props: ['apiUrl'],
  44. data() {
  45. return {
  46. data: null,
  47. pagination: {
  48. 'current_page': 1
  49. },
  50. loading: false,
  51. limit: 15,
  52. selectOptions: [
  53. {
  54. label: 'Facebook',
  55. value: 'facebook'
  56. },
  57. {
  58. label: 'Instagram',
  59. value: 'instagram'
  60. },
  61. {
  62. label: 'Forum',
  63. value: 'forum'
  64. }
  65. ]
  66. }
  67. },
  68. methods: {
  69. getData() {
  70. this.loading = true;
  71. axios.get(`${this.apiUrl}?page=${this.pagination.current_page}`, {
  72. params: this.params,
  73. })
  74. .then(result => {
  75. this.data = result.data.data.data;
  76. this.pagination = {
  77. total: parseInt(result.data.data.total),
  78. per_page: parseInt(result.data.data.per_page),
  79. current_page: parseInt(result.data.data.current_page),
  80. last_page: parseInt(result.data.data.last_page),
  81. from: parseInt(result.data.data.from),
  82. to: parseInt(result.data.data.to)
  83. };
  84. this.loading = false;
  85. })
  86. .catch(error => {
  87. this.$notify({
  88. type: 'error',
  89. group: 'errors',
  90. duration: 10000,
  91. text: this.$t('general.response-error'),
  92. });
  93. });
  94. },
  95. getIconClass(type) {
  96. switch (type) {
  97. case 'facebook':
  98. return 'icon-facebook-full';
  99. case 'instagram':
  100. return 'icon-instagram';
  101. case 'forum':
  102. return 'icon-messages';
  103. default:
  104. return 'icon-newspaper-full'
  105. }
  106. }
  107. },
  108. computed: {
  109. params: function () {
  110. return {limit: this.limit}
  111. },
  112. },
  113. mounted() {
  114. this.getData();
  115. },
  116. }
  117. </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement