增加时间校准页面

This commit is contained in:
liuwu 2023-08-11 11:19:56 +08:00
parent b3ddc773f9
commit 8a2e9b1684
2 changed files with 146 additions and 39 deletions

View File

@ -20,6 +20,8 @@
<view class="index_footer">
<text class="footer_set" @click="handleToSet">设置</text>
<text class="footer_history" @click="handleToHistory">操作历史</text>
<text class="footer_history" @click="fixTime">时间校准</text>
<text class="currTime" >{{currTime}}</text>
</view>
</view>
</template>
@ -35,7 +37,7 @@ export default {
listData:[],
stopRead:true,
sendStatus:true,
dianliuInte:null,
// dianliuInte:null,
jidianqiInte:null,
dianliu1:null,
dianliu2:null,
@ -43,11 +45,17 @@ export default {
dianliu4:null,
map:new Map(),
mapBefore:new Map(),
currTime:null
};
},
//初始化
apiready(){
const vm = this
setInterval(function () {
setTimeout(function () {
vm.data.currTime = vm.currTimeFns(new Date());
}, 0)
}, 1000);
api.addEventListener({
name: 'myEvent'
}, function(ret, err) {
@ -68,7 +76,6 @@ export default {
initAll(){
const vm = this
clearInterval(vm.data.jidianqiInte)
clearInterval(vm.data.dianliuInte)
clearInterval(vm.data.dianliu1)
clearInterval(vm.data.dianliu2)
clearInterval(vm.data.dianliu3)
@ -98,12 +105,16 @@ export default {
url:'./main/history.stml'
})
},
// 时间校准
fixTime(){
api.openWin({
name: 'fixTime',
url:'./main/fixTime.stml'
})
},
//创建设备表
initSb(db) {
const vm = this;
// const uniqueId = 'id-' + new Date().getTime().toString(36) + '-' + Math.random().toString(36).substr(2, 9);
// dbUtils.execute(db, "INSERT INTO Sb (id,circuitName,current,typeName,isTypeOpen) VALUES ('"+uniqueId+"','test1','lw','"+vm.currTimeFn(new Date())+"','test');", function(ret, err) {
// })
dbUtils.select(db, 'SELECT * FROM Sb', function(ret, err) {
var data = ret.data;
if(undefined != data && data.length > 0){
@ -117,10 +128,10 @@ export default {
if (ret.status == false || err.status == false) {
dbUtils.execute(db, 'CREATE TABLE Sb(id varchar(50), sbId varchar(10), circuitName varchar(50), current varchar(20), typeName varchar(30),isTypeOpen int(10))', function(ret, err) {
if (ret.status == true) {
dbUtils.execute(db, "INSERT INTO Sb (Id,sbId,circuitName,current,typeName,isTypeOpen) VALUES ('1','0B','1','3.21','高压风冷',1);", function(ret, err) {})
dbUtils.execute(db, "INSERT INTO Sb (Id,sbId,circuitName,current,typeName,isTypeOpen) VALUES ('2','0C','2','3.21','中压风冷',1);", function(ret, err) {})
dbUtils.execute(db, "INSERT INTO Sb (Id,sbId,circuitName,current,typeName,isTypeOpen) VALUES ('3','0D','3','3.21','低压风冷',1);", function(ret, err) {})
dbUtils.execute(db, "INSERT INTO Sb (Id,sbId,circuitName,current,typeName,isTypeOpen) VALUES ('4','0E','4','3.21','闭锁调压',1);", function(ret, err) {})
dbUtils.execute(db, "INSERT INTO Sb (Id,sbId,circuitName,current,typeName,isTypeOpen) VALUES ('1','0B','1','3','高压风冷',1);", function(ret, err) {})
dbUtils.execute(db, "INSERT INTO Sb (Id,sbId,circuitName,current,typeName,isTypeOpen) VALUES ('2','0C','2','3','中压风冷',1);", function(ret, err) {})
dbUtils.execute(db, "INSERT INTO Sb (Id,sbId,circuitName,current,typeName,isTypeOpen) VALUES ('3','0D','3','3','低压风冷',1);", function(ret, err) {})
dbUtils.execute(db, "INSERT INTO Sb (Id,sbId,circuitName,current,typeName,isTypeOpen) VALUES ('4','0E','4','3','闭锁调压',1);", function(ret, err) {})
console.log('创建设备表成功');
vm.initAll()
}
@ -157,7 +168,6 @@ export default {
serialPortUtil.closeSerial({ index: 0 });
serialPortUtil.openSerial({ index: 0, port: '/dev/ttyS0', baudRate: '9600'}, function (ret, err) {})
serialPortUtil.addEventListener({ index: 0, revType: 'hex', stopBits:1, flowCon:2 }, function (ret, err) {
// console.log(JSON.stringify(ret));
var data = vm.data.listData;
var leng = data.length;
if (ret.dataHex.startsWith("FE0101") && ret.dataHex.length > 8) {
@ -166,7 +176,6 @@ export default {
jidianqi = parseInt(jidianqi, 16).toString(2);
vm.data.jidianqi = vm.forJidianqi(jidianqi);
jidianqi = vm.data.jidianqi;
// console.log("************main:"+jidianqi+"************");
vm.data.mapBefore.set("0B",jidianqi[3] === '1');
vm.data.mapBefore.set("0C",jidianqi[2] === '1');
@ -254,20 +263,12 @@ export default {
if(vm.data.stopRead){
vm.sendMsg('FE 01 00 00 00 08 29 C3');
}
},2000)
// var cmdArr = [];
// vm.data.listData.forEach(s=>{
// var cmd = s.sbId+" 03 00 48 00 02";
// cmd = cmd + " " + CrcUt.GetCrc(cmd);
// cmdArr.push(cmd);
// })
},1000)
api.showProgress({
title: '正在初始化...',
text: '请稍后...',
modal: true
});
vm.data.dianliu1=setInterval(function () {
if(vm.data.stopRead){
vm.data.stopRead = false
@ -278,7 +279,7 @@ export default {
}, 80);
}, 50);
}
},500)
},250)
vm.data.dianliu2=setInterval(function () {
if(vm.data.stopRead){
vm.data.stopRead = false
@ -289,7 +290,7 @@ export default {
}, 80);
}, 50);
}
},1000)
},500)
vm.data.dianliu3=setInterval(function () {
if(vm.data.stopRead){
vm.data.stopRead = false
@ -300,7 +301,7 @@ export default {
}, 80);
}, 50);
}
},1500)
},750)
vm.data.dianliu4=setInterval(function () {
if(vm.data.stopRead){
vm.data.stopRead = false
@ -311,22 +312,10 @@ export default {
}, 80);
}, 50);
}
},2000)
// vm.data.dianliuInte=setInterval(function () {
// vm.data.listData.forEach(s=>{
// var cmd = s.sbId+" 03 00 48 00 02";
// cmd = cmd + " " + CrcUt.GetCrc(cmd);
// if(vm.data.sendStatus && vm.data.stopRead){
// vm.data.sendStatus = false
// vm.sendMsg(cmd)
// console.log(cmd);
// }
// })
// }, 2000);
},1000)
setTimeout(() => {
api.hideProgress();
}, 3000);
}, 2000);
},
sendMsg(cmd){
let ret = serialPortUtil.send({
@ -419,6 +408,15 @@ export default {
let _seconds = _date.getSeconds() < 10 ? '0' + _date.getSeconds() : _date.getSeconds();
// return _year + "." + _month + "." + _day + " " + _hour + ":" + _minutes + ":" + _seconds;
return _year + "." + _month + "." + _day + " " + _hour + ":" + _minutes;
},
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;
}
}
};
@ -525,7 +523,7 @@ export default {
margin: 0 10px;
}
.index_footer{
width: 80%;
width: 100%;
margin: 50px auto 0;
display: flex;
flex-direction: row;
@ -534,6 +532,7 @@ export default {
.footer_set{
font-size: 40px;
font-weight: bold;
margin-left: 20px;
box-sizing: border-box;
padding: 10px 20px;
color: #ffffff;
@ -541,7 +540,15 @@ export default {
.footer_history{
font-size: 40px;
font-weight: bold;
margin-left: 50px;
margin-left: 20px;
box-sizing: border-box;
padding: 10px 20px;
color: #ffffff;
}
.currTime{
font-size: 30px;
font-weight: bold;
margin-left: 100px;
box-sizing: border-box;
padding: 10px 20px;
color: #ffffff;

100
pages/main/fixTime.stml Normal file
View File

@ -0,0 +1,100 @@
<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>
.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: 60px;
margin-top: 20px;
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>