pyt
2025-03-26 a60476b5a0f2b1016c08d299e84093f44dad8939
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
<template>
  <div class="header">
    <!-- 左侧天气 -->
    <div class="weather">
      <!-- <img :src="require(`@/assets/weather/${weatherInfo.icon}.png`)" alt="weather" class="weather-icon"> -->
      <span class="weather-text">{{ weatherInfo.text }}</span>
    </div>
 
    <!-- 中间标题 -->
    <div class="title">崇州市自主安置购房信息化大数据平台</div>
 
    <!-- 右侧时间 -->
    <div class="datetime">
      <img src="@/assets/027_日历@2x.png" alt="calendar" class="calendar-icon">
      <div class="time">{{ currentTime }}</div>
    </div>
  </div>
</template>
 
<script>
export default {
  name: 'HeaderPanel',
  data() {
    return {
      currentTime: '',
      weatherInfo: {
        text: '晴',
        icon: 'sunny'  // 对应天气图标文件名
      }
    };
  },
  mounted() {
    this.updateTime();
    this.timer = setInterval(this.updateTime, 1000);
    this.getWeather();
   
  },
  beforeDestroy() {
    if (this.timer) {
      clearInterval(this.timer);
    }
  },
  methods: {
    updateTime() {
      const now = new Date();
      const year = now.getFullYear();
      const month = String(now.getMonth() + 1).padStart(2, '0');
      const date = String(now.getDate()).padStart(2, '0');
      const weekDays = ['日', '一', '二', '三', '四', '五', '六'];
      const weekDay = weekDays[now.getDay()];
      this.currentTime = `${year}年${month}月${date}日 星期${weekDay}`;
    },
    getWeather() {
      // 这里可以接入实际的天气 API
      // 目前使用模拟数据
      this.weatherInfo = {
        text: '晴',
        icon: 'sunny'
      };
    }
  }
};
</script>
 
<style lang="less" scoped>
.header {
  height: 86px;
  background: url('@/assets/顶部@2x.png') no-repeat center center;
  background-size: 100% 100%;
  display: flex;
  justify-content: space-between;
  padding: 0 40px;
  position: relative;
 
  .weather {
    display: flex;
    margin-top: 61px;
 
    .weather-icon {
      width: 30px;
      height: 30px;
      margin-right: 10px;
    }
 
    .weather-text {
      color: #fff;
      font-size: 16px;
    }
  }
 
  .title {
    font-size: 38px;
    font-weight: bold;
    color: #FFFFFF;
    position: absolute;
    line-height: 86px;
    left: 50%;
    transform: translateX(-50%);
  }
 
  .datetime {
    display: flex;
    margin-top: 61px;
 
    .calendar-icon {
      width: 22px;
      height: 21px;
      margin-right: 10px;
    }
 
    .time {
      font-size: 16px;
      color: #fff;
    }
  }
}
</style>