InfoVidget.vue 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. <template>
  2. <ul class="header-center__info-list">
  3. <li v-if="value.weather" class="header-center__info-item">
  4. <nuxt-link to="/news/weather" title="Погода в Алтайском крае">
  5. <span class="header-center__info-link">{{value.weather}}°, Барнаул</span>
  6. </nuxt-link>
  7. </li>
  8. <v-skeleton-loader
  9. v-else
  10. class="mx-auto"
  11. width="80"
  12. type="text"
  13. ></v-skeleton-loader>
  14. <li v-if="value.USD" class="header-center__info-item">
  15. <span class="header-center__info-link" :class="(value.USD_dynamics === 'down' ? 'header-center__info-link_down' : '')"
  16. id="USD">$&nbsp;{{value.USD}}</span>
  17. </li>
  18. <v-skeleton-loader
  19. v-else
  20. class="mx-auto"
  21. width="50"
  22. type="text"
  23. ></v-skeleton-loader>
  24. <li v-if="value.EUR" class="header-center__info-item">
  25. <span class="header-center__info-link" :class="(value.EUR_dynamics === 'down' ? 'header-center__info-link_down' : '')"
  26. id="EUR">€&nbsp; {{value.EUR}}</span>
  27. </li>
  28. <v-skeleton-loader
  29. v-else
  30. class="mx-auto"
  31. width="50"
  32. type="text"
  33. ></v-skeleton-loader>
  34. <li v-if="value.CNY" class="header-center__info-item">
  35. <span class="header-center__info-link" :class="(value.CNY_dynamics === 'down' ? 'header-center__info-link_down' : '')"
  36. id="CNY">Ұ&nbsp; {{value.CNY}}</span>
  37. </li>
  38. <v-skeleton-loader
  39. v-else
  40. class="mx-auto"
  41. width="50"
  42. type="text"
  43. ></v-skeleton-loader>
  44. </ul>
  45. </template>
  46. <script>
  47. export default {
  48. data() {
  49. return {
  50. value: {
  51. EUR: '',
  52. EUR_dynamics: '',
  53. USD: '',
  54. USD_dynamics: '',
  55. CNY: '',
  56. CNY_dynamics: '',
  57. weather: '',
  58. wind: ''
  59. }
  60. }
  61. },
  62. created() {
  63. let weather = this.$axios.get('https://api.amic.ru/api/v1/informer/weather')
  64. .then(res => {
  65. this.value.weather = res.data.data.current_temp_c;
  66. return res
  67. });
  68. let currencies = this.$axios.get('https://api.amic.ru/api/v1/informer/currencies')
  69. .then(res => {
  70. this.value.USD = res.data.data.USD.value;
  71. this.value.EUR = res.data.data.EUR.value;
  72. this.value.CNY = res.data.data.CNY.value;
  73. this.value.USD_dynamics = res.data.data.USD.dynamics;
  74. this.value.EUR_dynamics = res.data.data.EUR.dynamics;
  75. this.value.CNY_dynamics = res.data.data.CNY.dynamics;
  76. return true
  77. })
  78. }
  79. };
  80. </script>
  81. <style>
  82. </style>