head.vue 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. <template>
  2. <div class="headview">
  3. <div class="asleft">
  4. <dv-scroll-board
  5. ref="scrollBoard"
  6. :config="config"
  7. style="width: 100%; height: 100%"
  8. />
  9. </div>
  10. <img :src="[img0, img1, img2][swindex]" alt="" srcset="" />
  11. <div class="asright">{{ timeStr }}</div>
  12. </div>
  13. </template>
  14. <script>
  15. import { dateFormat } from '@/utils/tool.js';
  16. import { tq } from '@/api/bigView.js';
  17. import img0 from '@/assets/head0.png';
  18. import img1 from '@/assets/head1.png';
  19. import img2 from '@/assets/head2.png';
  20. export default {
  21. props: {
  22. swindex: {
  23. type: Number,
  24. default: 0,
  25. },
  26. },
  27. data() {
  28. return {
  29. img0,
  30. img1,
  31. img2,
  32. timeStr: '',
  33. timeId: null,
  34. info: {},
  35. config: {
  36. rowNum: 1,
  37. carousel: 'page',
  38. data: [],
  39. waitTime: 3000,
  40. },
  41. };
  42. },
  43. mounted() {
  44. this.gettq();
  45. this.timeId2 = setInterval(this.gettq, 60000 * 60 * 8);
  46. this.timeId = setInterval(() => {
  47. let date = new Date();
  48. this.timeStr = dateFormat('YYYY-mm-dd HH:MM:SS WWW', date);
  49. }, 1000);
  50. },
  51. beforeUnmount() {
  52. this.timeId && clearInterval(this.timeId);
  53. this.timeId2 && clearInterval(this.timeId2);
  54. },
  55. methods: {
  56. gettq() {
  57. Promise.all([
  58. tq('广州市'),
  59. tq('清远市'),
  60. tq('韶关市'),
  61. tq('佛山市'),
  62. tq('肇庆市'),
  63. tq('云浮市'),
  64. ])
  65. .then((reslist) => {
  66. var atrlist = reslist.map((item2) => {
  67. var item = item2.data;
  68. return [
  69. `<div class="jajajaj">${
  70. item.result.city
  71. ? `${item.result.city} :${item.result.weather || ''} ${
  72. item.result.templow || ''
  73. }℃ ~${item.result.temphigh || ''}℃`
  74. : ''
  75. }</div>`,
  76. ];
  77. });
  78. this.$refs['scrollBoard'].updateRows(atrlist);
  79. })
  80. .catch((err) => {
  81. console.log(err);
  82. });
  83. },
  84. },
  85. };
  86. </script>
  87. <style scoped lang="scss">
  88. ::v-deep .jajajaj {
  89. height: 24px;
  90. line-height: 24px;
  91. font-size: 20px;
  92. font-family: Source Han Sans CN, Source Han Sans CN-Regular;
  93. font-weight: 400;
  94. text-align: left;
  95. color: #34c7ff;
  96. }
  97. ::v-deep .dv-scroll-board {
  98. background: none !important;
  99. .row,
  100. .row-item {
  101. background: none !important;
  102. height: 24px !important;
  103. }
  104. }
  105. .headview {
  106. width: 100%;
  107. height: 100%;
  108. position: relative;
  109. overflow: hidden;
  110. img {
  111. position: absolute;
  112. bottom: 0;
  113. width: 1920;
  114. height: 58px;
  115. }
  116. .asleft {
  117. width: 500px;
  118. height: 24px;
  119. overflow: hidden;
  120. position: absolute;
  121. bottom: 10px;
  122. left: 67px;
  123. }
  124. .asright {
  125. font-size: 20px;
  126. font-family: Source Han Sans CN, Source Han Sans CN-Regular;
  127. font-weight: 400;
  128. text-align: left;
  129. color: #34c7ff;
  130. position: absolute;
  131. bottom: 10px;
  132. right: 67px;
  133. }
  134. }
  135. </style>