13693261870
2023-06-21 cdf12fc9e88b1af69f5c85165eb9fef4e23bf57a
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="box">
    <div class="title">
      <div class="dateTime">
        <div class="time1">{{ dateTime }}</div>
        <div class="time2">{{ calendarTime }}</div>
        <div class="time3">{{ weekTime }}</div>
        <div class="time4">{{ hourTime }}</div>
      </div>
    </div>
  </div>
</template>
 
<script>
import { getLunar } from 'chinese-lunar-calendar'
export default {
  //import引入的组件需要注入到对象中才能使用
  components: {},
  data() {
    //这里存放数据
    return {
      timer: null, //定时器
      dateTime: '',
      calendarTime: '',
      weekTime: '',
      hourTime: ''
    }
  },
  //方法集合
  methods: {},
  created() {},
  mounted() {
    this.timer = setInterval(() => {
      var nowDate = new Date()
      var year = nowDate.getFullYear()
      var month =
        nowDate.getMonth() + 1 > 10
          ? nowDate.getMonth() + 1
          : '0' + (nowDate.getMonth() + 1)
      var date =
        nowDate.getDate() > 10 ? nowDate.getDate() : '0' + nowDate.getDate()
      var hours =
        nowDate.getHours() < 10 ? '0' + nowDate.getHours() : nowDate.getHours()
      var minutes =
        nowDate.getMinutes() < 10
          ? '0' + nowDate.getMinutes()
          : nowDate.getMinutes()
      var seconds =
        nowDate.getSeconds() < 10
          ? '0' + nowDate.getSeconds()
          : nowDate.getSeconds()
      let wk = nowDate.getDay()
      let weeks = [
        '星期日',
        '星期一',
        '星期二',
        '星期三',
        '星期四',
        '星期五',
        '星期六'
      ]
      this.weekTime = weeks[wk]
      this.calendarTime = getLunar(year, month, date).dateStr
      this.dateTime = year + '年' + month + '月' + date + '日'
      this.hourTime = hours + ':' + minutes + ':' + seconds
    }, 1000)
  },
  beforeDestroy() {
    if (this.timer) {
      clearInterval(this.timer)
    }
  }
}
</script>
<style lang="less" scoped>
//@import url(); 引入公共css类
.box {
  // display: flex;
  width: 100%;
  height: 100%;
  position: relative;
  background: url('../../../assets/img/Rectangle 871.png') no-repeat center;
  background-size: 100% 100%;
  .title {
    width: 100%;
    height: 116px;
    position: absolute;
    background: url('../../../assets/img/Mask Group.png') no-repeat center;
    background-size: 100% 100%;
    padding-top: 10px;
 
    .dateTime {
      margin-right: 24px;
 
     font-family: SourceHanSansCN;
      font-style: normal;
      font-weight: 400;
      font-size: 16px;
      line-height: 20px;
 
      float: right;
 
      color: #ffffff;
 
      flex: none;
      order: 0;
      flex-grow: 0;
 
      .time1 {
        float: left;
        margin-right: 16px;
      }
      .time2 {
        float: left;
        margin-right: 16px;
      }
      .time3 {
        float: left;
        margin-right: 16px;
      }
      .time4 {
        float: left;
      }
    }
  }
}
</style>