Explorar el Código

日期显示修改

dedsudiyu hace 18 horas
padre
commit
08bd8d372f
Se han modificado 2 ficheros con 25 adiciones y 6 borrados
  1. 20 4
      src/components/ScreenHeader.vue
  2. 5 2
      src/components/SecurityMonitor.vue

+ 20 - 4
src/components/ScreenHeader.vue

@@ -27,10 +27,10 @@
     <!-- Right: Weather -->
     <div class="nav-right">
       <div class="nav-weather">
-        <span class="icon">&#9925;</span>
+        <!--<span class="icon">&#9925;</span>-->
         <div>
-          <div class="weather-location">北京 &middot; 晴转多云</div>
-          <div class="weather-detail">12&deg;C / AQI 68</div>
+          <div class="weather-location">{{weather}}</div>
+          <div class="weather-detail">{{weatherA}}{{weatherB}}</div>
         </div>
       </div>
     </div>
@@ -38,18 +38,23 @@
 </template>
 
 <script>
+  import { getWeather } from '@/api/screen'
 export default {
   name: 'ScreenHeader',
   data() {
     return {
       currentTime: '',
       currentDate: '',
-      timer: null
+      timer: null,
+      weather:'',
+      weatherA:'',
+      weatherB:'',
     }
   },
   mounted() {
     this.updateTime()
     this.timer = setInterval(this.updateTime, 1000)
+    this.fetchWeather()
   },
   beforeDestroy() {
     if (this.timer) {
@@ -70,6 +75,17 @@ export default {
       const d = now.getDate()
       const weekDays = ['日', '一', '二', '三', '四', '五', '六']
       this.currentDate = `${y}年${mon}月${d}日 星期${weekDays[now.getDay()]}`
+    },
+    async fetchWeather() {
+      try {
+        const res = await getWeather()
+        const d = res.data
+        this.weather = ` 北京 · ${d.weekDay} `;
+        this.weatherA = ` ${d.weatherDesc} `;
+        this.weatherB = ` ${d.temperature}°C`;
+      } catch (e) {
+        this.weather = ''
+      }
     }
   }
 }

+ 5 - 2
src/components/SecurityMonitor.vue

@@ -267,6 +267,8 @@ export default {
     // this.fetchCameras()
   },
   mounted() {
+    this.getMonitorTree();
+    this.getDeptDropList();
     this.laboratoryLabScreenScreenConfigGet();
     this.pollTimer = setInterval(this.laboratoryLabScreenScreenConfigGet, 5 * 60 * 1000)
   },
@@ -276,6 +278,9 @@ export default {
   methods: {
     buttonClick(val){
       this.$set(this,'checkButton',val);
+      if(val == 2){
+        this.handleEnter();
+      }
     },
     handleEnter(){
       this.getMonitorTree();
@@ -537,8 +542,6 @@ export default {
             this.$set(this,'checkButton',1);
           }else{
             this.$set(this,'checkButton',2);
-            this.getMonitorTree();
-            this.getDeptDropList();
           }
         }
       } catch (e) {