Merge pull request '时钟' (#136) from lukeyan into master

Reviewed-on: #136
guomingxin
lukeyan 1 year ago
commit 07d7a7d7d2

@ -45,9 +45,10 @@
> >
<div class="shu"></div> <div class="shu"></div>
</el-menu> </el-menu>
<!-- <div class="time_box"> <div class="time_box">
<div class="time_item">{{ this.get_time }}</div> <div class="time_item">{{ this.new_time }}</div>
</div> --> <div class="day_item">{{ this.new_day }}</div>
</div>
<div class="jingGuan"> <div class="jingGuan">
<div class="jgtx" @click="check_user"> <div class="jgtx" @click="check_user">
<img src="../assets/companyFile/12110.png" /> <img src="../assets/companyFile/12110.png" />
@ -68,6 +69,9 @@
</template> </template>
<script> <script>
const days = ["天", "一", "二", "三", "四", "五", "六"]; //
let icnow = new Date(); //
let interval;
export default { export default {
name: "Head", name: "Head",
data() { data() {
@ -75,14 +79,42 @@ export default {
activeIndex: "1", activeIndex: "1",
activeIndex2: "1", activeIndex2: "1",
user_show: false, user_show: false,
year: icnow.getFullYear(),
month: icnow.getMonth() + 1,
date: icnow.getDate(),
day: days[icnow.getDay() - 1],
time: icnow.toTimeString().substring(0, 8),
}; };
}, },
created() { created() {
this.activeIndex = sessionStorage.getItem("activeIndex") this.activeIndex = sessionStorage.getItem("activeIndex")
? sessionStorage.getItem("activeIndex") ? sessionStorage.getItem("activeIndex")
: "1"; : "1";
interval = setInterval(() => {
let icnow = new Date();
this.year = icnow.getFullYear();
this.month = icnow.getMonth() + 1;
this.date = icnow.getDate();
this.day = days[icnow.getDay()];
this.time = icnow.toTimeString().substring(0, 8);
}, 1000);
}, },
computed: { computed: {
//
new_time: function () {
return (
this.time
);
},
//
new_day() {
return (
this.year + '年' + this.month + '月' + this.date + '日 星期' + this.day
)
}
},
beforeDestroy() {
clearInterval(interval);
}, },
methods: { methods: {
handleSelect(key) { handleSelect(key) {
@ -104,21 +136,21 @@ export default {
this.$router.push("/login"); this.$router.push("/login");
}, },
get_time() { get_time() {
setInterval(() => {
let date = new Date(); let date = new Date();
let sign = ":"; this.hour = date.getHours(); //
let hour = date.getHours(); // this.minutes = date.getMinutes(); //
let minutes = date.getMinutes(); // this.seconds = date.getSeconds(); //
let seconds = date.getSeconds(); // if (this.hour >= 0 && this.hour <= 9) {
if (hour >= 0 && hour <= 9) { this.hour = "0" + this.hour;
hour = "0" + hour;
} }
if (minutes >= 0 && minutes <= 9) { if (this.minutes >= 0 && this.minutes <= 9) {
minutes = "0" + minutes; this.minutes = "0" + this.minutes;
} }
if (seconds >= 0 && seconds <= 9) { if (this.seconds >= 0 && this.seconds <= 9) {
seconds = "0" + seconds; this.seconds = "0" + this.seconds;
} }
return hour + sign + minutes + sign + seconds; }, 1000);
}, },
}, },
}; };
@ -137,10 +169,9 @@ export default {
background-size: 100% 100%; background-size: 100% 100%;
display: flex; display: flex;
align-items: center; align-items: center;
.iconbg { .iconbg {
height: 35px; height: 35px;
width: 50px; width: 3vw;
margin: 0 25px; margin: 0 25px;
// background: url("~@/assets/companyFile/2111.png") no-repeat; // background: url("~@/assets/companyFile/2111.png") no-repeat;
// background-size: 100% 100%; // background-size: 100% 100%;
@ -161,25 +192,32 @@ export default {
letter-spacing: 4px; letter-spacing: 4px;
text-shadow: 0 8px 8px rgba(0, 0, 0, 0.3); text-shadow: 0 8px 8px rgba(0, 0, 0, 0.3);
font-weight: 400; font-weight: 400;
margin-right: 30px; width: 22vw;
} }
.time_box { .time_box {
width: 8.5vw; width: 12vw;
height: 6vh; height: 5vh;
border: 0.1px solid #33cccc; margin-left: 1vw;
.time_item { .time_item {
width: 8.5vw; width: 12vw;
height: 3.5vh; height: 3vh;
text-align: center; text-align: center;
line-height: 3.5vh; color: #37fdc7;
color: #37FDC7 ;
font-size: 24px; font-size: 24px;
font-weight: 600; font-weight: 600;
} }
.day_item {
width: 12vw;
height: 1.5vh;
color: #d9e7ff;
text-align: center;
font-size: 14px;
font-weight: 500;
}
} }
.jingGuan { .jingGuan {
position: absolute; position: absolute;
right: 30px; right: 3vw;
display: flex; display: flex;
color: #edf6ff; color: #edf6ff;
align-items: center; align-items: center;
@ -245,7 +283,7 @@ export default {
align-items: center; align-items: center;
.el-menu-item { .el-menu-item {
width: 130px; width: 6vw;
height: 35px; height: 35px;
display: flex; display: flex;
justify-content: center; justify-content: center;

Loading…
Cancel
Save