zhangzengfei
2020-07-20 6efd5fd74bdaa5497968a2938a1dba984c8a4068
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
<template>
  <notice v-if="this.$store.state.desktop.weather">
    <template slot="notice-header-icon">
      <img class="notice-header-icon-img" src="images/weather.png"/>
    </template>
    <template slot="notice-header-title">
      天气
    </template>
    <template slot="notice-body">
      <div class="weather-item">
        <div class="weather-city">
          <span class="weather-city-time">{{currentTime()}}</span>
          <span class="weather-city-text">{{this.$store.state.desktop.weather.city}}</span>
        </div>
        <div class="weather-type">
          <img :src="this.$store.state.desktop.weather.icon"
               :alt="this.$store.state.desktop.weather.type"/>
        </div>
        <div class="weather-temperature">{{this.$store.state.desktop.weather.temperature}}</div>
      </div>
    </template>
  </notice>
</template>
 
<script>
  import Notice from './Notice';
 
  export default {
    name: "WeatherNotice",
    components: {
      Notice
    },
    methods: {
      currentTime: function () {
        let hour = this.$store.state.desktop.currentDate.getHours();
        let mins = this.$store.state.desktop.currentDate.getMinutes();
        let value = '上午';
        if (hour > 12) {
          value = '下午';
          hour -= 12;
        }
        value += hour + ":";
        if (mins < 10) {
          value += "0";
        }
        value += mins;
        return value;
      }
    }
  }
</script>
 
<style scoped>
  .weather-item {
    height: 50px;
  }
 
  .weather-item div {
    display: inline-block;
    text-align: center;
  }
 
  .weather-city {
    float: left;
  }
 
  .weather-city .weather-city-time {
    display: block;
    font-size: 10px;
    font-weight: 400;
    text-align: left;
    margin: 5px 0 2px 10px;
    color: #868585;
  }
 
  .weather-city .weather-city-text {
    font-size: 15px;
    font-weight: 400;
    display: block;
    text-align: left;
    margin: 0 0 5px 10px;
  }
 
  .weather-type {
    position: absolute;
    right: 70px;
  }
 
  .weather-type img {
    width: 30px;
    margin: 5px;
  }
 
  .weather-temperature {
    float: right;
    font-size: 35px;
    font-weight: 200;
    margin-right: 10px;
  }
</style>