electricControl/pages/main/fixTime.stml

105 lines
2.4 KiB
Plaintext

<template>
<view class="index_wrap">
<text class="set_back_text" @click="handleBackIndex">返回</text>
<text class="title">当前时间</text>
<text class="currTime">{{currTime}}</text>
<view class="btn"><button style="font-size: 40px;background-image: linear-gradient(to bottom, #00b, #006);">B码校时</button></view>
</view>
</template>
<script>
export default {
name: 'fixTime',
apiready(){//like created
const vm = this
vm.initTime()
},
data() {
return{
currTime:this.currTimeFns(new Date())
}
},
methods: {
//返回首页
handleBackIndex(){
api.closeWin();
api.sendEvent({
name: 'myEvent',
extra: {
close: 'close',
}
});
},
initTime(){
const vm = this;
setInterval(function () {
setTimeout(function () {
vm.data.currTime = vm.currTimeFns(new Date());
}, 0)
}, 1000);
},
currTimeFns(_date) {
let _year = _date.getFullYear();
let _month = _date.getMonth() + 1 < 10 ? '0' + (_date.getMonth() + 1) : _date.getMonth() + 1;
let _day = _date.getDate() < 10 ? '0' + _date.getDate() : _date.getDate();
let _hour = _date.getHours() < 10 ? '0' + _date.getHours() : _date.getHours();
let _minutes = _date.getMinutes() < 10 ? '0' + _date.getMinutes() : _date.getMinutes();
let _seconds = _date.getSeconds() < 10 ? '0' + _date.getSeconds() : _date.getSeconds();
return _year + "." + _month + "." + _day + " " + _hour + ":" + _minutes + ":" + _seconds;
}
}
}
</script>
<style>
@font-face {
font-family: "CustomFont";
src: url("../../css/led16segment2-b99v.ttf") format("truetype");
}
.index_wrap{
width: 100%;
height: 100%;
box-sizing: border-box;
padding: 20px;
background-image: url("../../image/login.png");
background-size: 120%;
background-repeat: no-repeat;
background-position: center;
}
.set_back_text{
font-size: 40px;
color: #ffffff;
font-weight: bold;
position: absolute;
top: 20px;
left: 20px;
}
.title{
width: 100%;
text-align: center;
font-size: 40px;
margin-top: 50px;
font-weight: bold;
box-sizing: border-box;
padding: 10px 20px;
color: #ffffff;
}
.currTime{
width: 100%;
text-align: center;
font-size: 80px;
font-family: 'CustomFont';
margin-top: 10px;
font-weight: bold;
box-sizing: border-box;
padding: 10px 20px;
color: #ffffff;
}
.btn{
width: 100%;
text-align: center;
margin-top: 80px;
font-weight: bold;
box-sizing: border-box;
padding: 10px 20px;
color: #ffffff;
}
</style>