修改样式

This commit is contained in:
liuwu 2023-10-30 18:06:37 +08:00
parent c7ec831768
commit 7824fefaa0
5 changed files with 151 additions and 155 deletions

View File

@ -74,7 +74,7 @@
.btnc {
margin-left: 15px;
/* margin-right: 15px; */
font-size: larger;
font-size: x-large;
font-weight: 900;
border-radius: 20px;
}
@ -97,29 +97,30 @@
}
.mui-toast-message {
/* background: url(/app/themes/default/images/toast.png) no-repeat center 10px #407ae6; */
background: url(/app/themes/default/images/toast.png) no-repeat center 10px #407ae6;
opacity: 1;
/* color: #fff; */
font-size: xx-large;
color: #fff;
width: 100%;
padding: 10px 5px 10px 5px;
padding: 20px 10px 20px 10px;
}
</style>
<body>
<div class="mui-row">
<!--头部信息开始-->
<div class="head flex mui-row">
<div class="mui-col-xs-7" style="display:flex;align-items: center;">
<div class="mui-col-xs-5" style="display:flex;align-items: center;">
<button id='showUserPicker' class="btnc mui-btn-inline mui-btn-primary" type='button'>请选择设备</button>
<text id='batchName' style="font-size: larger;margin-left:15px;font-weight: 900;"></text>
<text id='batchName' style="font-size: x-large;margin-left:15px;font-weight: 900;"></text>
<button class="btnc mui-btn-inline mui-btn-primary" type='button' onclick="refreshDayPlan()">更新计划</button>
<button class="btnc mui-btn-inline mui-btn-primary" type='button' onclick="reloadPage()">刷新页面</button>
<!-- <button class="btnc mui-btn-inline mui-btn-primary" type='button' onclick="reloadPage()">刷新页面</button> -->
</div>
<div class="mui-col-xs-5" style="display:flex;justify-content: flex-end;">
<div class="mui-col-xs-7" style="display:flex;justify-content: flex-end;">
<button class="btnc mui-btn-inline mui-btn-danger" onclick="closeApp()" type='button'>关闭系统</button>
<button id="driveName" class="btnc mui-btn-info" type="button" onclick="handleBackSys()">机车手</button>
<button id='wifiDom' class="btnc mui-btn-inline mui-btn-info"
style="color: seagreen !important;" type='button'>暂未连接</button>
<button id='showBlePicker' class="btnc mui-btn-inline mui-btn-primary" type='button'>选择蓝牙</button>
style="color: seagreen !important;" type='button' onclick="rescan()"></button>
<button id='showBlePicker' class="btnc mui-btn-inline mui-btn-primary dis" type='button'>连接蓝牙</button>
</div>
</div>
<!--中间内容开始-->
@ -127,7 +128,7 @@
<!--中间左边开始-->
<div class="mui-col-xs-3 centerLeft">
<ul class="mui-table-view" id="train"
style="text-align: left;line-height: 40px;font-size: larger;font-weight: 900;">
style="text-align: left;line-height: 60px;font-size: xx-large;font-weight: 900;">
</ul>
</div>
<!--中间右边开始-->
@ -139,12 +140,12 @@
<div id="echarts_main_one" class="mui-col-sm-6 echarts_item"></div>
<div id="echarts_main_two" class="mui-col-sm-6 echarts_item"></div>
<div class="mui-col-sm-12 flex2">
<button class="btnc mui-btn-success" style="font-size: x-large;" type="button" id="fix" onclick="weightFix()">校准计划</button>
<button class="btnc mui-btn-success" style="font-size: xx-large;" type="button" id="fix" onclick="weightFix()">校准计划</button>
<text id='nowFeed' style="font-size:x-large;font-weight: 900;margin-left:10px; "></text>
<text id='feedNum' style="font-size: x-large;font-weight: 900;"></text>
<button class="btnc mui-btn-success" id="startLoad" style="font-size: x-large;width: 20%;;"
<button class="btnc mui-btn-success" id="startLoad" style="font-size: xx-large;width: 20%;;"
onclick="startLoad()">开始装料</button>
<button class="btnc mui-btn-success dis" id="submitData" style="font-size: x-large;"
<button class="btnc mui-btn-success dis" id="submitData" style="font-size: xx-large;"
onclick="submitData()">上传</button>
</div>
@ -154,7 +155,7 @@
<!--尾部信息开始-->
<div class="footer flex mui-row">
<div class="mui-col-xs-2" >
<text id="text" style="margin-left: 20px;font-weight: 900;font-size: larger;" onclick="updateApp()"></text>
<text id="text" style="margin-left: 20px;font-weight: 900;font-size: x-large;" onclick="updateApp()"></text>
</div>
<div class="mui-col-xs-10" id="timeList" >
@ -177,14 +178,14 @@
var weightMyChart = echarts.init(weightChartDom);
var feedChartDom = document.getElementById('echarts_main_one');
var feedMyChart = echarts.init(feedChartDom);
var _outerRadius = 165;
var _innerRadius = 135;
var _outerRadius = 215;
var _innerRadius = 185;
var feedName;
var templateName;
var templetType;
var _pointerInnerRadius = 70;
var _insidePanelRadius = 130;
var fontsize = 50;
var _pointerInnerRadius = 120;
var _insidePanelRadius = 180;
var fontsize = 80;
var feedList = [];
var feedIndex = 0;
var classCode = 1;
@ -282,6 +283,16 @@
});
};
function rescan(){
if(!connetcedStatus){
if(bleData.length>0){
connect({peripheralUUID: bleData[0].value});
}else{
scan()
}
}
}
function initService() {
initManager({single: true});
}
@ -313,7 +324,7 @@ function getDateStr(date) {
x: '65%',
y: '70%',
textStyle: {
fontSize: 28,
fontSize: 60,
fontWeight: '100',
color: '#5dc3ea',
lineHeight: 16,
@ -325,7 +336,7 @@ function getDateStr(date) {
x: '15%',
y: '70%',
textStyle: {
fontSize: 28,
fontSize: 60,
fontWeight: '100',
color: '#5dc3ea',
lineHeight: 16,
@ -360,7 +371,7 @@ function getDateStr(date) {
label: {
normal: {
textStyle: {
fontSize: 56,
fontSize: 86,
color: '#fff'
}
}
@ -401,7 +412,7 @@ function getDateStr(date) {
label: {
normal: {
textStyle: {
fontSize: 56,
fontSize: 86,
color: '#fff'
}
}
@ -560,9 +571,9 @@ function getDateStr(date) {
ret.data.forEach(function (e, index) {
trainArr.push(e.trainNumber);
if (index == 0) {
html += '<li id="classeCode_' + e.classCode + 'train_' + index + '" class="mui-table-view-cell trains" onclick="handleCarClick(this,' + '\'' + e.classCode + '\',\'' + e.trainNumber + '\')">' + e.trainNumber + '(' + e.templetName + ')</li>';
html += '<li id="classeCode_' + e.classCode + 'train_' + index + '" class="mui-table-view-cell trains" onclick="handleCarClick(this,' + '\'' + e.classCode + '\',\'' + e.trainNumber + '\')">'+e.className + e.trainNumber + '(' + e.templetName + ')</li>';
} else {
html += '<li id="classeCode_' + e.classCode + 'train_' + index + '" class="mui-table-view-cell" onclick="handleCarClick(this,' + '\'' + e.classCode + '\',\'' + e.trainNumber + '\')">' + e.trainNumber + '(' + e.templetName + ')</li>';
html += '<li id="classeCode_' + e.classCode + 'train_' + index + '" class="mui-table-view-cell" onclick="handleCarClick(this,' + '\'' + e.classCode + '\',\'' + e.trainNumber + '\')">'+e.className + e.trainNumber + '(' + e.templetName + ')</li>';
}
});
document.getElementById('train').innerHTML = html;
@ -611,9 +622,9 @@ function getDateStr(date) {
feedList = json;
json.forEach(function (j, index) {
if (index == 0) {
html += '<span id="feed_' + index + '" class="mui-badge mui-badge-purple" style="font-size: large;font-weight: 900;">' + UNICODE_CHARS[index + 1] + j.name + ':' + Number(j.weight).toFixed(0) + '</span>';
html += '<span id="feed_' + index + '" class="mui-badge mui-badge-purple" style="font-size: xx-large;font-weight: 900;">' + UNICODE_CHARS[index + 1] + j.name + ':' + Number(j.weight).toFixed(0) + '</span>';
} else {
html += '<span id="feed_' + index + '" class="mui-badge" style="font-size: large;font-weight: 900;">' + UNICODE_CHARS[index + 1] + j.name + ':' + Number(j.weight).toFixed(0) + '</span>';
html += '<span id="feed_' + index + '" class="mui-badge" style="font-size: xx-large;font-weight: 900;">' + UNICODE_CHARS[index + 1] + j.name + ':' + Number(j.weight).toFixed(0) + '</span>';
}
});
document.getElementById('feedList').innerHTML = html;
@ -630,7 +641,7 @@ function getDateStr(date) {
allow = json[0].allow;
// 计划
_planSum = json[0].weight.toFixed(0);
document.getElementById('feedNum').innerHTML = '<font style="color:blue">计划:' + _planSum + '</font>/<font style="color:green">已装:' + _feedNum + '</font>';
document.getElementById('feedNum').innerHTML = '<font style="color:blue">:' + _planSum + '</font>/<font style="color:green">已装:' + _feedNum + '</font>';
text = feedName + _planSum;
batchName = e.className + e.trainNumber;
templateName = e.templetName;

View File

@ -42,7 +42,7 @@ export default {
phone:null,
code:null,
resCode:null,
codeSwitch:false,
codeSwitch:true,
isLoading:false,
isLogin:true
}

View File

@ -1,4 +1,5 @@
"use strict";
/*初始化蓝牙适配器*/
function initManager(param) {
ble.initManager(param, function (ret) {
if (ret.state === "poweredOn") {
@ -15,20 +16,22 @@ function initManager(param) {
var times = 5;
var sta = true;
var scanInter;
/*开始扫描*/
function scan(param) {
// if (!uuid){
// uuid = api.getPrefs({
// sync: true,
// key: 'uuid'
// });
// }
// if (uuid){
// disconnect({peripheralUUID: uuid});
// connect({peripheralUUID: uuid});
// return false
// }
sta = true
if (!uuid){
uuid = api.getPrefs({
sync: true,
key: 'uuid'
});
}
if (uuid){
isConnected({peripheralUUID: uuid},function(ret){
console.log("isConnected"+ret);
if(ret){
disconnect({peripheralUUID: uuid});
}
})
}
clearInterval(scanInter)
times = 5;
ble.scan(param, function (ret) {
@ -36,83 +39,76 @@ function scan(param) {
scanInter = setInterval(function (){
if (times>0){
times --;
var wifiDom = document.getElementById('wifiDom');
wifiDom.innerHTML = "扫描中"+times;
api.showProgress({
title: '扫描中'+times+'...',
modal: true
});
}else {
if (sta){
getPeripheral();
sta = false;
}
clearInterval(scanInter)
getPeripheral();
}
},1000)
}
});
}
/*获取扫描结果*/
function getPeripheral() {
ble.getPeripheral(function (ret) {
bleData = []
var ret2 = {};
var wifiDom = document.getElementById('wifiDom');
if (ret.peripherals.length > 0) {
ret.peripherals.forEach(function (p) {
if (undefined !== p.name) {
console.log(p.name);
if (p.name.indexOf("TMR_BLE") === -1){
return false
}else{
mui.toast("已扫描到" +p.name,{duration:3500,type:'div'});
wifiDom.innerHTML = p.name+'(未连接)';
document.getElementById('showBlePicker').setAttribute("class", 'btnc mui-btn-inline mui-btn-primary');
var json = { value: p.uuid, text: p.name };
bleData.push(json);
if (!uuid){
uuid = api.getPrefs({
sync: true,
key: 'uuid'
});
}
if (uuid && uuid === p.uuid){
document.getElementById('showBlePicker').innerHTML = p.name
isConnected({peripheralUUID: uuid},function(ret){
console.log("isConnected"+ret);
if(ret){
disconnect({peripheralUUID: uuid});
connect({peripheralUUID: uuid});
}else{
connect({peripheralUUID: uuid});
}
})
}
}
var json = { value: p.uuid, text: p.name };
bleData.push(json);
if (!uuid){
uuid = api.getPrefs({
sync: true,
key: 'uuid'
});
}
if (uuid && uuid === p.uuid){
disconnect({peripheralUUID: uuid});
connect({peripheralUUID: uuid});
}
// if (p.name.indexOf("BLUE2USART") !== -1) {
// uuid = p.uuid;
// api.setPrefs({
// key: 'uuid',
// value: uuid
// });
// ret2 = p;
// if (ret2 !== {}) {
// var wifiDom = document.getElementById('wifiDom');
// wifiDom.innerHTML = "设备:" + ret2.name;
// api.hideProgress();
// api.showProgress({
// title: '设备连接中...',
// modal: true
// });
// document.getElementById('text').innerHTML = '设备连接中';
// connect({peripheralUUID: ret2.uuid});
// }
// }
}
});
bleInit()
// if (undefined === ret2.uuid){
// mui.confirm('没有扫描到设备信息,继续扫描?', '提示', btnArray, function (e) {
// if (e.index === 0) {} else {
// scan({clean: true});
// }
// });
// }
if(!bleData.length>0){
mui.toast("暂未扫描到蓝牙设备",{duration:3500,type:'div'});
document.getElementById('showBlePicker').setAttribute("class", 'btnc mui-btn-inline mui-btn-primary dis');
wifiDom.innerHTML = "重新扫描";
}else{
bleInit()
}
}
api.hideProgress();
});
}
// 连接失败次数
var connectTimes=0;
/*开始连接*/
function connect(param) {
var wifiDom = document.getElementById('wifiDom');
wifiDom.innerHTML = "暂未连接";
wifiDom.innerHTML = "";
api.showProgress({
title: '蓝牙连接中...',
modal: true
@ -120,8 +116,8 @@ function connect(param) {
ble.connect(param, function (ret, err) {
if (ret.status) {
connetcedStatus = true
connectTimes = 0;
wifiDom.innerHTML = '已连接';
connectTimes = 0;
document.getElementById('text').innerHTML = '设备已连接';
text = '设备已连接';
console.log('主机端连接成功')
@ -134,7 +130,7 @@ function connect(param) {
wifiDom.innerHTML = '连接失败';
api.hideProgress();
setTimeout(function (){
if (connectTimes < 5 && !connetcedStatus && uuid){
if (!connetcedStatus && uuid){
console.log("连接失败!尝试重连" + uuid);
wifiDom.innerHTML = '尝试重连';
connect({peripheralUUID: uuid});
@ -143,7 +139,7 @@ function connect(param) {
}
});
}
/*断开连接*/
function disconnect(param) {
ble.disconnect(param, function (ret, err) {
if (ret.status) {
@ -153,22 +149,29 @@ function disconnect(param) {
}
});
}
/*判断是否已连接*/
function isConnected(param,callback){
ble.isConnected(param, function(ret) {
if (ret) {
console.log('已连接');
}
callback(ret.status)
});
}
var i;
// 蓝牙uuid
var peripheralUUID =''
// 蓝牙服务id
var serviceUUID =''
// 蓝牙特征id
var characteristicUUID =''
var msgLed = '';
var msgChan = '';
var msgVoice = '';
var sendStatus = true;
// 蓝牙待发送消息列表
var msgList = [];
var timerLed = null;
clearInterval(timerssss)
var timerssss = setInterval(function(){
// 清除消息定时任务
clearInterval(timerMsgList)
/*蓝牙消息发送定时任务150ms*/
var timerMsgList = setInterval(function(){
// console.log(new Date().getSeconds()+ ' ' + new Date().getMilliseconds() +' ' + msgList.length)
if (msgList.length > 0) {
// 发送报文
@ -185,41 +188,11 @@ var timerssss = setInterval(function(){
// console.log(ret.status)
});
}
}
},150)
// clearInterval(timerLed)
// timerLed = setInterval(function(){
// if (sendStatus && connetcedStatus && peripheralUUID && serviceUUID && characteristicUUID) {
// sendStatus = false;
// var param1 = {
// peripheralUUID: peripheralUUID,
// serviceUUID: serviceUUID,
// characteristicUUID: characteristicUUID,
// value: msgLed
// };
// // console.log("msgLed"+new Date().getMilliseconds())
// writeValueForCharacteristic(param1, function (ret) {});
// setTimeout(function () {
// param1.value = msgVoice
// // console.log("msgVoice"+new Date().getMilliseconds())
// writeValueForCharacteristic(param1, function (ret) {});
// setTimeout(function () {
// param1.value = msgChan
// // console.log("msgChan"+new Date().getMilliseconds())
// writeValueForCharacteristic(param1, function (ret) {});
// setTimeout(function () {
// // console.log("sendStatus"+new Date().getMilliseconds())
// sendStatus = true
// }, 30);
// }, 50);
// }, 50);
// }
// },150)
// 未装料状态计数采集达到10次发送一次停止蜂鸣指令
var bleConunt=0;
/*扫描蓝牙服务*/
function discoverService(param) {
ble.discoverService(param, function (ret) {
if (ret.services.length > 0) {
@ -227,6 +200,7 @@ function discoverService(param) {
ret.services.forEach(function (ret4) {
if (ret4.indexOf("0000ffe") !== -1) {
if (ret4 && ret4.length > 0) {
//发现特征
discoverCharacteristics({
serviceUUID: ret4,
peripheralUUID: param.peripheralUUID
@ -234,6 +208,7 @@ function discoverService(param) {
peripheralUUID = param.peripheralUUID;
serviceUUID =ret4;
characteristicUUID =ret5;
//监听消息
setNotify({
peripheralUUID: param.peripheralUUID,
serviceUUID: ret4,
@ -268,7 +243,8 @@ function discoverService(param) {
serviceUUID = ret4;
characteristicUUID = ret5;
// console.log(_feedNum,_weightSum,_planSum);
document.getElementById('feedNum').innerHTML = '<font style="color:blue">计划:' + _planSum + '</font>/<font style="color:green">已装:' + _feedNum + '</font>';
document.getElementById('feedNum').innerHTML = '<font style="color:blue">:' + _planSum + '</font>/<font style="color:green">已装:' + _feedNum + '</font>';
// 组装led报文
if (ledStatus && !isNaN(nowWeight)) {
getMess({
peripheralUUID: param.peripheralUUID,
@ -284,18 +260,20 @@ function discoverService(param) {
if (isNaN(feedErr)) {
return false
}
// 蜂鸣器校验基础值大于500的饲料取500为标准
var count;
if (_planSum >= 500) {
count = 500
} else {
count = _planSum
}
// 计算饲料装料量与基础值的误差比例
var ration = feedErr / count;
// console.log("ration" + ration.toFixed(2));
// 误差分为100%-20%(停止蜂鸣)10%-20%(间隔05)5%-10%(间隔03),2%-5%(间隔01),-100%-2%(长鸣)
if (ration > 0.2) {
bleConunt ++;
if (statusEle || (bleConunt >= 10)===true) {
console.log("停止蜂鸣"+statusEle+' '+(bleConunt));
if (statusEle || (bleConunt >= 10)) {
bleConunt=0;
ledStatus = false;
status = '';
@ -373,9 +351,12 @@ function discoverService(param) {
}, 500)
}
}
// 在误差范围内
if (feedErr <= allow) {
// 重量稳定计数
var filteredValue = weightDataFilter.filter(nowWeight);
if (weightDataFilter.dataBuffer.length == 40) {
// 重量稳定自动跳转
if (weightDataFilter.dataBuffer.length === 40) {
console.log("重量稳定", currTimeFn(new Date()));
weightDataFilter.dataBuffer = []
document.getElementById('submitData').click();
@ -393,7 +374,7 @@ function discoverService(param) {
}
});
}
/*扫描特征*/
function discoverCharacteristics(param, callback) {
ble.discoverCharacteristics(param, function (ret) {
var res = '';
@ -410,27 +391,27 @@ function discoverCharacteristics(param, callback) {
}
});
}
/*适配两种称数据解析*/
function StringToNum(hexx){
var hex = hexx.toString(); //force conversion
var str = '';
var num = '';
for (var i = 0; i < hex.length; i += 2) {
num = String.fromCharCode(parseInt(hex.substr(i, 2), 16));
if((num >= '0' && num <= '9') || (num == '-'))
if((num >= '0' && num <= '9') || (num === '-'))
{
str += num;
}
else
{
if(str.length != 0)
if(str.length !== 0)
{
return str
}
}
}return str;
}
/*监听蓝牙数据,转换重量数据*/
function setNotify(param, callback) {
ble.setNotify(param, function (ret) {
// console.log(JSON.stringify(ret))
@ -445,7 +426,7 @@ function setNotify(param, callback) {
callback(wei);
});
}
/*发送消息到蓝牙*/
function writeValueForCharacteristic(param, callback) {
if (param.value && connetcedStatus){
ble.writeValueForCharacteristic(param, function (ret) {
@ -459,8 +440,8 @@ function writeValueForCharacteristic(param, callback) {
});
}
}
var lastCmd = "";
var lastTime = new Date().getSeconds()*1000+ new Date().getMilliseconds();
// 接收重量数据计数
var count = 0;
/*组装报文并发数*/
function getMess(param, callback) {
@ -482,6 +463,9 @@ function getMess(param, callback) {
msg: ''
};
var newmsg = feedName;
if(!newmsg.length>0){
return false
}
var msglen = newmsg.getByteLen();
var ttr = '';
if (Number(_planSum - _feedNum) >= 0) {
@ -502,19 +486,19 @@ function getMess(param, callback) {
param1.msg = newmsg + Math.abs(Number(_planSum - _feedNum)).toFixed(0) + 'kg';
// param1.msg = newmsg + Math.abs(Number(param.value)).toFixed(0) + 'kg'
// console.log(param1.msg)
//组装字符卡LED报文
zfk.getMsg(param1, function (ret, err) {
var str = ret.sendMsg;
str = str.replace(/\s+/g, "");
var num = str.length / 2;
param.value = "FF0500" + num.toString(16) + str;
count ++;
// 称重量数据3包取1包
if (count >= 3){
msgList.push(param.value);
msgLed = param.value;
// var ms = strToHex(sbId,4)+strToHex(classCode,2)+strToHex(trainNumber,2)+strToHex(feedIndex,2)+strToHex(_planSum,4)+strToHex(_feedNum,4)+strToHex(nowWeight,4);
// var num1 = ms.length / 2;
// msgChan = "FF0a00"+strToHex(num1,2) + ms
// 同步刷新图表
renderUnload();
renderLoad();
feedMyChart.setOption({
@ -531,7 +515,7 @@ function getMess(param, callback) {
}
});
}
/*字符串转16进制hex*/
function strToHex(str,length){
var hex = Number(str).toString(16);
var append = '';
@ -542,6 +526,7 @@ function strToHex(str,length){
}
return append+hex;
}
/*初始化重量图表*/
function initWeight() {
api.showProgress({
title: '图表数据加装中...',

View File

@ -1,5 +1,5 @@
"use strict";
/*CRC16Modbus crc算法*/
function calculateCRC16Modbus(dataHexString) {
var dataBytes = [];
for (var i = 0; i < dataHexString.length; i += 2) {
@ -43,16 +43,16 @@ function calculateCRC16Modbus(dataHexString) {
return crc.toString(16).toUpperCase();
}
/*组装蜂鸣器控制报文*/
function getControlCmd(status, time) {
var cmd = "FE1003F6000204" + status + "0000" + time;
var crc = calculateCRC16Modbus(cmd);
return cmd + crc.substring(2, 4) + crc.substring(0, 2);
}
var lastMsg = '';
/*发送控制消息到蓝牙*/
function control(status, time) {
var msg = "FFFF000D" + getControlCmd(status, time);
msgVoice = msg;
msgList=[]
msgList.push(msg);
}

View File

@ -72,7 +72,7 @@ function submitData() {
}
}, function (ret, err) {
if (ret && ret.code == 200) {
mui.toast(param.name + " 已上传 " + param.feedWeight);
mui.toast(param.name + " 已上传 " + param.feedWeight,{duration:3500,type:'div'});
beforeWeight = nowWeight;
// document.getElementById('beforeWeight').innerHTML = '称实时/装料前:' + nowWeight + '/' + beforeWeight;
feedIndex = feedIndex + 1;