headComponent.vue 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  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(self.laboratoryWsBigViewGetTimeData, 30000);
  46. },
  47. laboratoryWsBigViewGetTimeData(){
  48. laboratoryWsBigViewGetTimeData().then(res => {
  49. this.$set(this,'timeData',res.data)
  50. })
  51. },
  52. //天气定时器
  53. weatherFunction(){
  54. let self = this;
  55. this.laboratoryWsBigViewGetWeatherData();
  56. this.weatherTimer = window.setInterval(self.laboratoryWsBigViewGetWeatherData, 360000);
  57. },
  58. laboratoryWsBigViewGetWeatherData(){
  59. laboratoryWsBigViewGetWeatherData().then(res => {
  60. let data = JSON.parse(res.data);
  61. this.$set(this,'weatherData',data);
  62. })
  63. },
  64. },
  65. beforeDestroy() {
  66. //清除定时器
  67. window.clearInterval(this.timer);
  68. window.clearInterval(this.weatherTimer);
  69. },
  70. destroyed() {
  71. //清除定时器
  72. window.clearInterval(this.timer);
  73. window.clearInterval(this.weatherTimer);
  74. }
  75. }
  76. </script>
  77. <style scoped lang="scss">
  78. .headComponent{
  79. height:173px;
  80. display: flex;
  81. position: relative;
  82. background-image: url("../../assets/ZDimages/img_db@1x.png");
  83. background-size: 100% 100%;
  84. .center-title-box{
  85. display: flex;
  86. .logo-img{
  87. margin:35px 16px 0 1245px;
  88. width:64px;
  89. height:64px;
  90. }
  91. .title-p{
  92. flex:1;
  93. line-height:48px;
  94. height:48px;
  95. margin-top:40px;
  96. font-family: Alimama ShuHeiTi;
  97. font-size: 40px;
  98. font-weight: bold;
  99. background: -webkit-linear-gradient(#FFFFFF, #0095FF);
  100. -webkit-background-clip: text;
  101. color: transparent;
  102. }
  103. }
  104. .time-p{
  105. position: absolute;
  106. top:99px;
  107. left:44px;
  108. height:30px;
  109. line-height:30px;
  110. color:#fff;
  111. font-size:20px;
  112. }
  113. .weather-box{
  114. display: flex;
  115. position: absolute;
  116. top:99px;
  117. right:33px;
  118. height:30px;
  119. line-height:30px;
  120. color:#fff;
  121. font-size:20px;
  122. .weather-img{
  123. width:24px;
  124. height:24px;
  125. margin:3px 13px 0 0 ;
  126. }
  127. .weather-p-1{
  128. }
  129. .weather-svg{
  130. width:24px;
  131. height:24px;
  132. color:#fff;
  133. margin:3px 10px 0 40px;
  134. }
  135. .weather-p-2{
  136. margin-right:20px;
  137. }
  138. .weather-p-3{
  139. }
  140. }
  141. }
  142. </style>