headComponent.vue 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  1. <!--title-->
  2. <template>
  3. <div class="headComponent">
  4. <div class="center-title-box">
  5. <img class="logo-img" src="@/assets/ZDimages/logo.png">
  6. <p class="title-p">公共科教条件设施数据一张图</p>
  7. </div>
  8. <p class="time-p">{{timeData}}</p>
  9. <div class="weather-box">
  10. <img class="weather-img" src="@/assets/ZDimages/icon_bjsj_tk@1x.png">
  11. <p class="weather-p-1">{{weatherData.cityName}}</p>
  12. <svg-icon class="weather-svg" :icon-class="weatherData.iconUrl" v-if="weatherData.iconUrl"/>
  13. <p class="weather-p-2">{{weatherData.textDay}}</p>
  14. <p class="weather-p-3">{{weatherData.tempMin}}~{{weatherData.tempMax}}℃</p>
  15. </div>
  16. </div>
  17. </template>
  18. <script>
  19. import {
  20. laboratoryWsBigViewGetTimeData,
  21. laboratoryWsBigViewGetWeatherData
  22. } from "@/api/index";
  23. export default {
  24. name: 'headComponent',
  25. data () {
  26. return {
  27. title:'1区环境感知监测中心',
  28. timeData:'',
  29. timer:null,
  30. weatherData:'',
  31. weatherTimer:null,
  32. }
  33. },
  34. created(){
  35. },
  36. mounted(){
  37. this.timeFunction();
  38. this.weatherFunction();
  39. },
  40. methods:{
  41. //时间定时器
  42. timeFunction(){
  43. let self = this;
  44. this.laboratoryWsBigViewGetTimeData();
  45. this.timer = window.setInterval(() => {
  46. self.laboratoryWsBigViewGetTimeData();
  47. }, 30000);
  48. },
  49. laboratoryWsBigViewGetTimeData(){
  50. laboratoryWsBigViewGetTimeData().then(res => {
  51. this.$set(this,'timeData',res.data)
  52. })
  53. },
  54. //天气定时器
  55. weatherFunction(){
  56. let self = this;
  57. this.laboratoryWsBigViewGetWeatherData();
  58. this.weatherTimer = window.setInterval(() => {
  59. self.laboratoryWsBigViewGetWeatherData();
  60. }, 360000);
  61. },
  62. laboratoryWsBigViewGetWeatherData(){
  63. laboratoryWsBigViewGetWeatherData().then(res => {
  64. let data = JSON.parse(res.data);
  65. this.$set(this,'weatherData',data);
  66. })
  67. },
  68. },
  69. beforeDestroy() {
  70. //清除定时器
  71. window.clearInterval(this.timer);
  72. window.clearInterval(this.weatherTimer);
  73. },
  74. destroyed() {
  75. //清除定时器
  76. window.clearInterval(this.timer);
  77. window.clearInterval(this.weatherTimer);
  78. }
  79. }
  80. </script>
  81. <style scoped lang="scss">
  82. .headComponent{
  83. height:173px;
  84. display: flex;
  85. position: relative;
  86. background-image: url("../../assets/ZDimages/img_db@1x.png");
  87. background-size: 100% 100%;
  88. .center-title-box{
  89. display: flex;
  90. .logo-img{
  91. margin:35px 16px 0 1245px;
  92. width:64px;
  93. height:64px;
  94. }
  95. .title-p{
  96. flex:1;
  97. line-height:48px;
  98. height:48px;
  99. margin-top:40px;
  100. font-family: Alimama ShuHeiTi;
  101. font-size: 40px;
  102. font-weight: bold;
  103. background: -webkit-linear-gradient(#FFFFFF, #0095FF);
  104. -webkit-background-clip: text;
  105. color: transparent;
  106. }
  107. }
  108. .time-p{
  109. position: absolute;
  110. top:99px;
  111. left:44px;
  112. height:30px;
  113. line-height:30px;
  114. color:#fff;
  115. font-size:20px;
  116. }
  117. .weather-box{
  118. display: flex;
  119. position: absolute;
  120. top:99px;
  121. right:33px;
  122. height:30px;
  123. line-height:30px;
  124. color:#fff;
  125. font-size:20px;
  126. .weather-img{
  127. width:24px;
  128. height:24px;
  129. margin:3px 13px 0 0 ;
  130. }
  131. .weather-p-1{
  132. }
  133. .weather-svg{
  134. width:24px;
  135. height:24px;
  136. color:#fff;
  137. margin:3px 10px 0 40px;
  138. }
  139. .weather-p-2{
  140. margin-right:20px;
  141. }
  142. .weather-p-3{
  143. }
  144. }
  145. }
  146. </style>