pyt
2025-03-26 03cd344a15bf63bf7968dc77a026c77c78c304f4
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
118
119
120
121
122
123
124
125
126
127
128
<template>
  <div class="header">
    <!-- 左侧天气 -->
    <div class="weather">
      <div class="mask"></div>
      <div class="box"></div>
      <iframe allowtransparency="true" frameborder="0" width="180" height="36" scrolling="no"
        src="//tianqi.2345.com/plugin/widget/index.htm?s=3&z=3&t=1&v=0&d=3&bd=0&k=000000&f=ffffff&ltf=ffffff&htf=ffffff&q=1&e=1&a=1&c=60910&w=103&h=36&align=left" />
    </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;
 
 
    .mask {
      position: absolute;
      width: 180px;
      height: 36px;
      z-index: 1;
      filter: alpha(opacity=0);
      opacity: 0;
      background: #040A56
    }
 
    .box {
      position: absolute;
      width: 20px;
      height: 36px;
      left: 140px;
      z-index: 1;
      background: #040A56
    }
  }
 
  .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>