Head.vue
1.92 KB
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
<template>
<div class="top_head">
<!-- logo 开始 -->
<div class="logo">
<img src="@/assets/images/top_logo.png" class="img" alt="" />
</div>
<!-- logo end -->
<!-- 标题 开始 -->
<div class="title_box">
<span class="title">{{ title }}</span>
</div>
<!-- 标题 end -->
<!-- 欢迎词 开始 -->
<div class="right_box">
<!-- 日期、时间 开始 -->
<div class="time_box">
<span class="date">{{ month }}月{{ day }}日 {{ week }}</span>
<span class="time">{{ time }}</span>
</div>
<!-- 日期、时间 end -->
<div class="welcome">
<span>欢迎回来!</span>
</div>
</div>
<!-- 欢迎词 end -->
</div>
</template>
<script>
export default {
name: 'TopHead',
props: {
title: {
type: String,
default: '广联数科运营看板'
}
},
data() {
return {
month: '',
day: '',
week: '',
time: '',
timeInterval: ''
}
},
mounted() {
let weekList = {
1: '周一',
2: '周二',
3: '周三',
4: '周四',
5: '周五',
6: '周六',
7: '周日'
}
let m = new Date()
this.month = m.getMonth() + 1
this.day = m.getDate()
this.week = weekList[m.getDay()]
this.initTime()
},
methods: {
// 定时获取时间
initTime() {
let _this = this
if (this.timeInterval) {
clearInterval(this.timeInterval)
}
_this.timeInterval = setInterval(function () {
_this.time = _this.getTime()
}, 1000)
},
// 获取时间
getTime() {
let time = ''
let o = new Date()
let h = o.getHours()
let m = o.getMinutes()
let s = o.getSeconds()
time = `${h < 10 ? '0' + h : h}:${m < 10 ? '0' + m : m}:${s < 10 ? '0' + s : s}`
return time
}
}
}
</script>
<style lang="scss" scoped>
@import '@/assets/css/topHead.scss';
</style>