| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146 |
- <!--title-->
- <template>
- <div class="headComponent">
- <div class="center-title-box">
- <img class="logo-img" src="@/assets/ZDimages/logo.png">
- <p class="title-p">公共科教条件设施数据一张图</p>
- </div>
- <p class="time-p">{{timeData}}</p>
- <div class="weather-box">
- <img class="weather-img" src="@/assets/ZDimages/icon_bjsj_tk@1x.png">
- <p class="weather-p-1">{{weatherData.cityName}}</p>
- <svg-icon class="weather-svg" :icon-class="weatherData.iconUrl" v-if="weatherData.iconUrl"/>
- <p class="weather-p-2">{{weatherData.textDay}}</p>
- <p class="weather-p-3">{{weatherData.tempMin}}~{{weatherData.tempMax}}℃</p>
- </div>
- </div>
- </template>
- <script>
- import {
- laboratoryWsBigViewGetTimeData,
- laboratoryWsBigViewGetWeatherData
- } from "@/api/index";
- export default {
- name: 'headComponent',
- data () {
- return {
- title:'1区环境感知监测中心',
- timeData:'',
- timer:null,
- weatherData:'',
- weatherTimer:null,
- }
- },
- created(){
- },
- mounted(){
- this.timeFunction();
- this.weatherFunction();
- },
- methods:{
- //时间定时器
- timeFunction(){
- let self = this;
- this.laboratoryWsBigViewGetTimeData();
- this.timer = window.setInterval(self.laboratoryWsBigViewGetTimeData, 30000);
- },
- laboratoryWsBigViewGetTimeData(){
- laboratoryWsBigViewGetTimeData().then(res => {
- this.$set(this,'timeData',res.data)
- })
- },
- //天气定时器
- weatherFunction(){
- let self = this;
- this.laboratoryWsBigViewGetWeatherData();
- this.weatherTimer = window.setInterval(self.laboratoryWsBigViewGetWeatherData, 360000);
- },
- laboratoryWsBigViewGetWeatherData(){
- laboratoryWsBigViewGetWeatherData().then(res => {
- let data = JSON.parse(res.data);
- this.$set(this,'weatherData',data);
- })
- },
- },
- beforeDestroy() {
- //清除定时器
- window.clearInterval(this.timer);
- window.clearInterval(this.weatherTimer);
- },
- destroyed() {
- //清除定时器
- window.clearInterval(this.timer);
- window.clearInterval(this.weatherTimer);
- }
- }
- </script>
- <style scoped lang="scss">
- .headComponent{
- height:173px;
- display: flex;
- position: relative;
- background-image: url("../../assets/ZDimages/img_db@1x.png");
- background-size: 100% 100%;
- .center-title-box{
- display: flex;
- .logo-img{
- margin:35px 16px 0 1245px;
- width:64px;
- height:64px;
- }
- .title-p{
- flex:1;
- line-height:48px;
- height:48px;
- margin-top:40px;
- font-family: Alimama ShuHeiTi;
- font-size: 40px;
- font-weight: bold;
- background: -webkit-linear-gradient(#FFFFFF, #0095FF);
- -webkit-background-clip: text;
- color: transparent;
- }
- }
- .time-p{
- position: absolute;
- top:99px;
- left:44px;
- height:30px;
- line-height:30px;
- color:#fff;
- font-size:20px;
- }
- .weather-box{
- display: flex;
- position: absolute;
- top:99px;
- right:33px;
- height:30px;
- line-height:30px;
- color:#fff;
- font-size:20px;
- .weather-img{
- width:24px;
- height:24px;
- margin:3px 13px 0 0 ;
- }
- .weather-p-1{
- }
- .weather-svg{
- width:24px;
- height:24px;
- color:#fff;
- margin:3px 10px 0 40px;
- }
- .weather-p-2{
- margin-right:20px;
- }
- .weather-p-3{
- }
- }
- }
- </style>
|