修改配置页面样式,修改首页增加关闭app功能,增加校准自动跳转配置项
This commit is contained in:
parent
6725c6a12d
commit
4bb9f8ba3c
173
html/config.html
173
html/config.html
|
@ -71,6 +71,14 @@
|
|||
text-align: justify;
|
||||
width: 100%;
|
||||
}
|
||||
.save{
|
||||
display: flex;
|
||||
/*实现垂直居中*/
|
||||
align-items: center;
|
||||
/*实现水平居中*/
|
||||
justify-content: flex-end;
|
||||
text-align: justify;
|
||||
}
|
||||
</style>
|
||||
<body>
|
||||
<div class="mui-row">
|
||||
|
@ -84,37 +92,52 @@
|
|||
</div>
|
||||
<!--中间内容开始-->
|
||||
<div class="mui-row content">
|
||||
<div class="mui-col-sm-4">
|
||||
<div class="mui-row form flex1">
|
||||
<button class="mui-btn-inline mui-btn-info" style="font-size: large;" type='button'>绑定设备</button>
|
||||
<button id='initsb' class="mui-btn-inline mui-btn-primary" style="font-size: large;" type='button'>
|
||||
请选择设备
|
||||
</button>
|
||||
<button class="mui-btn-inline mui-btn-success" style="font-size: large;" onclick="initsb()">保存
|
||||
</button>
|
||||
<div class="mui-col-sm-6">
|
||||
<div class="mui-row form">
|
||||
<div class="mui-col-xs-8" style="display:flex;justify-content: flex-start;">
|
||||
<text class="flex1" style="font-size: x-large;margin-left:15px;font-weight: 900;">绑定设备:</text>
|
||||
<button id='initsb' class="flex1 mui-btn-inline mui-btn-info" style="font-size: large;color: seagreen !important;">请选择</button>
|
||||
</div>
|
||||
<div class="mui-col-xs-4" style="display:flex;justify-content: flex-end;">
|
||||
<!-- <button class="save mui-btn-inline mui-btn-primary" style="font-size: large;" onclick="initsb()">保存</button>-->
|
||||
</div>
|
||||
</div>
|
||||
<div class="mui-row form flex1">
|
||||
<button class="mui-btn-inline mui-btn-info" style="font-size: large;" type='button'>默认页面</button>
|
||||
<button id='initpage' class="mui-btn-inline mui-btn-primary" style="font-size: large;" type='button'>
|
||||
请选择页面
|
||||
</button>
|
||||
<input id="indexPage" type="hidden" value="">
|
||||
<button class="mui-btn-inline mui-btn-success" style="font-size: large;" onclick="initpage()">保存
|
||||
</button>
|
||||
<div class="mui-row form">
|
||||
<div class="mui-col-xs-8" style="display:flex;justify-content: flex-start;">
|
||||
<text class="flex1" style="font-size: x-large;margin-left:15px;font-weight: 900;">默认页面:</text>
|
||||
<button id='initpage' class="flex1 mui-btn-inline mui-btn-info" style="font-size: large;color: seagreen !important;" >请选择</button>
|
||||
<input id="indexPage" type="hidden" value="">
|
||||
</div>
|
||||
<div class="mui-col-xs-4" style="display:flex;justify-content: flex-end;">
|
||||
<!-- <button class="save mui-btn-inline mui-btn-primary" style="font-size: large;" onclick="initpage()">保存</button>-->
|
||||
</div>
|
||||
</div>
|
||||
<div class="mui-row form flex1">
|
||||
<button class="mui-btn-inline mui-btn-info" style="font-size: large;" type='button'>跳转数据包数</button>
|
||||
<input id='weightSize' style="font-size: large;" value="" type="number" placeholder="请输入数字"/>
|
||||
<button class="mui-btn-inline mui-btn-success" style="font-size: large;" onclick="weightSizeSave()">保存
|
||||
</button>
|
||||
<div class="mui-row form">
|
||||
<div class="mui-col-xs-8" style="display:flex;justify-content: flex-start;">
|
||||
<text class="flex1" style="font-size: x-large;margin-left:15px;font-weight: 900;">装料校准:</text>
|
||||
<button id='fixbeforeload' class="flex1 mui-btn-inline mui-btn-info" style="font-size: large;color: seagreen !important;" >请选择</button>
|
||||
<input id="isfix" type="hidden" value="">
|
||||
</div>
|
||||
<div class="mui-col-xs-4" style="display:flex;justify-content: flex-end;">
|
||||
<!-- <button class="save mui-btn-inline mui-btn-primary" style="font-size: large;" onclick="fixbeforeload()">保存</button>-->
|
||||
</div>
|
||||
</div>
|
||||
<div class="mui-row form">
|
||||
<div class="mui-col-xs-8" style="display:flex;justify-content: flex-start;">
|
||||
<text class="flex1" style="font-size: x-large;margin-left:15px;font-weight: 900;">跳转数据:</text>
|
||||
<button id='weightSize' class="flex1 mui-btn-inline mui-btn-info" style="font-size: large;color: seagreen !important;" >请选择</button>
|
||||
</div>
|
||||
<div class="mui-col-xs-4" style="display:flex;justify-content: flex-end;">
|
||||
<!-- <button class="save mui-btn-inline mui-btn-primary" style="font-size: large;" onclick="weightSizeSave()">保存</button>-->
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="mui-col-sm-4">
|
||||
<div class="mui-col-sm-6">
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<div class="footer flex mui-row">
|
||||
<div class="mui-col-sm-12 flex"style="width:100%;height:8vh;white-space: nowrap !important;overflow-x: scroll;" id="list">
|
||||
<div class="mui-col-sm-12 flex" style="width:100%;height:8vh;white-space: nowrap !important;overflow-x: scroll;" id="list">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -122,16 +145,33 @@
|
|||
|
||||
var carListener = null;
|
||||
var pageListener = null;
|
||||
var fixListener = null;
|
||||
var weiListener = null;
|
||||
var userPicker;
|
||||
var pagePicker;
|
||||
var fixPicker;
|
||||
var weiPicker;
|
||||
var pickData = [];
|
||||
var btnArray = ['取消', '<b style="font-weight:900">确认</b>'];
|
||||
var pageData = []
|
||||
var fixData = []
|
||||
var weiData = []
|
||||
fixData.push({value: 0, text: "需要"})
|
||||
fixData.push({value: 1, text: "不需要"})
|
||||
|
||||
pageData.push({value: "index", text: "首页"})
|
||||
pageData.push({value: "index1", text: "装料页面"})
|
||||
pageData.push({value: "collection", text: "剩料收集页面"})
|
||||
pageData.push({value: "config", text: "设置页面"})
|
||||
|
||||
weiData.push({value: "20", text: "20"})
|
||||
weiData.push({value: "30", text: "30"})
|
||||
weiData.push({value: "40", text: "40"})
|
||||
weiData.push({value: "50", text: "50"})
|
||||
weiData.push({value: "60", text: "60"})
|
||||
weiData.push({value: "70", text: "70"})
|
||||
weiData.push({value: "80", text: "80"})
|
||||
|
||||
function init() {
|
||||
}
|
||||
|
||||
|
@ -139,6 +179,8 @@
|
|||
initSbList()
|
||||
init()
|
||||
muiInitPage()
|
||||
muiInitFix()
|
||||
muiInitWeightSize()
|
||||
var indexPage = api.getPrefs({
|
||||
sync: true,
|
||||
key: 'initpage'
|
||||
|
@ -227,6 +269,9 @@
|
|||
userPicker.show(function (items) {
|
||||
console.log('设备切换');
|
||||
showUserPickerButton.innerHTML = items[0].text;
|
||||
if (items[0].text){
|
||||
initsb()
|
||||
}
|
||||
});
|
||||
}, false);
|
||||
}
|
||||
|
@ -255,9 +300,11 @@
|
|||
pageListener = null;
|
||||
pageListener = showPagePickerButton.addEventListener('tap', function (event) {
|
||||
pagePicker.show(function (items) {
|
||||
console.log('设备切换');
|
||||
document.getElementById('indexPage').value = items[0].value;
|
||||
showPagePickerButton.innerHTML = items[0].text;
|
||||
if (items[0].text){
|
||||
initpage()
|
||||
}
|
||||
});
|
||||
}, false);
|
||||
}
|
||||
|
@ -266,6 +313,71 @@
|
|||
})(mui, document);
|
||||
}
|
||||
|
||||
function muiInitFix() {
|
||||
(function ($, doc) {
|
||||
$.init();
|
||||
$.ready(function () {
|
||||
/**
|
||||
* 获取对象属性的值
|
||||
* 主要用于过滤三级联动中,可能出现的最低级的数据不存在的情况,实际开发中需要注意这一点;
|
||||
* @param {Object} obj 对象
|
||||
* @param {String} param 属性名
|
||||
*/
|
||||
var _getParam = function _getParam(obj, param) {
|
||||
return obj[param] || '';
|
||||
};
|
||||
if (fixPicker) {
|
||||
} else {
|
||||
fixPicker = new $.PopPicker();
|
||||
var showFixPickerButton = doc.getElementById('fixbeforeload');
|
||||
fixListener = null;
|
||||
fixListener = showFixPickerButton.addEventListener('tap', function (event) {
|
||||
fixPicker.show(function (items) {
|
||||
document.getElementById('isfix').value = items[0].value;
|
||||
showFixPickerButton.innerHTML = items[0].text;
|
||||
if (items[0].text){
|
||||
fixbeforeload()
|
||||
}
|
||||
});
|
||||
}, false);
|
||||
}
|
||||
fixPicker.setData(fixData);
|
||||
});
|
||||
})(mui, document);
|
||||
}
|
||||
|
||||
function muiInitWeightSize() {
|
||||
(function ($, doc) {
|
||||
$.init();
|
||||
$.ready(function () {
|
||||
/**
|
||||
* 获取对象属性的值
|
||||
* 主要用于过滤三级联动中,可能出现的最低级的数据不存在的情况,实际开发中需要注意这一点;
|
||||
* @param {Object} obj 对象
|
||||
* @param {String} param 属性名
|
||||
*/
|
||||
var _getParam = function _getParam(obj, param) {
|
||||
return obj[param] || '';
|
||||
};
|
||||
if (weiPicker) {
|
||||
} else {
|
||||
weiPicker = new $.PopPicker();
|
||||
var showWeiPickerButton = doc.getElementById('weightSize');
|
||||
weiListener = null;
|
||||
weiListener = showWeiPickerButton.addEventListener('tap', function (event) {
|
||||
weiPicker.show(function (items) {
|
||||
showWeiPickerButton.innerHTML = items[0].text;
|
||||
if (items[0].text){
|
||||
weightSizeSave()
|
||||
}
|
||||
});
|
||||
}, false);
|
||||
}
|
||||
weiPicker.setData(weiData);
|
||||
});
|
||||
})(mui, document);
|
||||
}
|
||||
|
||||
function initsb() {
|
||||
// var value = document.getElementById('initsb').value;
|
||||
var value = document.getElementById('initsb').innerHTML
|
||||
|
@ -291,7 +403,7 @@
|
|||
}
|
||||
|
||||
function weightSizeSave(){
|
||||
var value = document.getElementById('weightSize').value;
|
||||
var value = document.getElementById('weightSize').innerHTML;
|
||||
if (value) {
|
||||
api.setPrefs({
|
||||
key: 'weightSize',
|
||||
|
@ -300,6 +412,17 @@
|
|||
mui.alert('自动跳转数据包"' + value + '"成功');
|
||||
}
|
||||
}
|
||||
function fixbeforeload(){
|
||||
var value = document.getElementById('isfix').value;
|
||||
if (value) {
|
||||
api.setPrefs({
|
||||
key: 'fixbeforeload',
|
||||
value: value
|
||||
});
|
||||
var name = document.getElementById('fixbeforeload').innerHTML;
|
||||
mui.alert('装料前校准"' + name + '"设置成功');
|
||||
}
|
||||
}
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
|
@ -20,6 +20,13 @@
|
|||
box-sizing: border-box;
|
||||
border: 1px solid #a3caef;
|
||||
}
|
||||
.btnc {
|
||||
margin-left: 15px;
|
||||
/* margin-right: 15px; */
|
||||
font-size: x-large;
|
||||
font-weight: 900;
|
||||
border-radius: 20px;
|
||||
}
|
||||
.flex{
|
||||
/*flex 布局*/
|
||||
display: flex;
|
||||
|
@ -29,15 +36,25 @@
|
|||
/*实现水平居中*/
|
||||
justify-content: center;
|
||||
text-align: justify;
|
||||
/* width:33%; */
|
||||
height: 100vh;
|
||||
/*
|
||||
margin: 5px 5px;
|
||||
padding: 5px 5px; */
|
||||
height: 90vh;
|
||||
}
|
||||
.flex1{
|
||||
/*flex 布局*/
|
||||
display: flex;
|
||||
background-color: #007aff;
|
||||
/*实现垂直居中*/
|
||||
align-items: center;
|
||||
/*实现水平居中*/
|
||||
justify-content: flex-end;
|
||||
text-align: justify;
|
||||
height: 10vh;
|
||||
}
|
||||
</style>
|
||||
<body>
|
||||
<div class="mui-row content">
|
||||
<div class="mui-col-sm-12 flex1">
|
||||
<button class="btnc mui-btn-inline mui-btn-danger" onclick="closeApp()" type='button'>关闭系统</button>
|
||||
</div>
|
||||
<div class="mui-col-sm-3 flex">
|
||||
<button class="mui-btn-success " style="font-size: 100px;font-weight: 900;border-radius: 50px;color: black;" onclick="startLoad()">装料</button>
|
||||
</div>
|
||||
|
@ -49,6 +66,18 @@
|
|||
</div>
|
||||
</div>
|
||||
<script>
|
||||
function closeApp() {
|
||||
mui.confirm('确认关闭TMR饲喂系统?', '提示', btnArray, function (e) {
|
||||
if (e.index == 0) {} else {
|
||||
api.closeWidget({
|
||||
id: api.appId, //应用ID
|
||||
retData: { name: 'closeWidget' },
|
||||
silent: false
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
var btnArray = ['取消', '<b style="font-weight:900">确认</b>'];
|
||||
var apiready = function apiready() {
|
||||
var initpage = api.getPrefs({sync: true,key: 'initpage'})
|
||||
|
|
1291
html/index1.html
1291
html/index1.html
File diff suppressed because it is too large
Load Diff
|
@ -54,6 +54,8 @@ function scan(param) {
|
|||
});
|
||||
}
|
||||
|
||||
var weightBeforefix = '1';
|
||||
|
||||
function stopScan(){
|
||||
ble.stopScan()
|
||||
}
|
||||
|
@ -256,7 +258,7 @@ function discoverService(param) {
|
|||
}, function (ret7) {
|
||||
});
|
||||
// 装料状态
|
||||
if(feedStatus && allowAuto){
|
||||
if((feedStatus && allowAuto) || weightBeforefix ==='1' ){
|
||||
if (first) {
|
||||
first = false;
|
||||
beforeWeight = nowWeight;
|
||||
|
@ -276,33 +278,21 @@ function discoverService(param) {
|
|||
}
|
||||
document.getElementById('feedNum').innerHTML = '<font style="color:blue">:' + _planSum + '</font>/<font style="color:green">已装:' + _feedNum + '</font>';
|
||||
}
|
||||
serviceUUID = ret4;
|
||||
characteristicUUID = ret5;
|
||||
// // 组装led报文
|
||||
// if (ledStatus && !isNaN(nowWeight)) {
|
||||
// // getMess({
|
||||
// // peripheralUUID: param.peripheralUUID,
|
||||
// // serviceUUID: ret4,
|
||||
// // characteristicUUID: ret5,
|
||||
// // value: ret6
|
||||
// // }, function (ret7) {
|
||||
// // });
|
||||
// }
|
||||
// 装料状态
|
||||
if(feedStatus && allowAuto){
|
||||
if((feedStatus && allowAuto) || weightBeforefix === '1'){
|
||||
// 计划-饲喂
|
||||
var feedErr = _planSum-_feedNum;
|
||||
if (isNaN(feedErr)) {
|
||||
return false
|
||||
}
|
||||
// 蜂鸣器校验基础值,大于500的饲料,取500为标准
|
||||
// 蜂鸣器校验基础值,大于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%(长鸣)
|
||||
|
@ -384,7 +374,7 @@ function discoverService(param) {
|
|||
}
|
||||
// console.log(weightStabilization("weightStabilization"+nowWeight))
|
||||
// 在误差范围内
|
||||
if (feedErr <= allow && allowAuto) {
|
||||
if (feedErr <= allow && (allowAuto || weightBeforefix === '1')) {
|
||||
// 重量稳定计数
|
||||
var filteredValue = weightDataFilter.filter(nowWeight);
|
||||
// 重量稳定自动跳转
|
||||
|
@ -533,7 +523,7 @@ 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)
|
||||
console.log(param1.msg)
|
||||
//组装字符卡LED报文
|
||||
zfk.getMsg(param1, function (ret, err) {
|
||||
var str = ret.sendMsg;
|
||||
|
@ -548,7 +538,7 @@ function getMess(param, callback) {
|
|||
// var num1 = ms.length / 2;
|
||||
// 同步刷新图表
|
||||
// 饲喂状态刷新实时状态,否则不刷新装料信息
|
||||
if(feedStatus && allowAuto){
|
||||
if(feedStatus && (allowAuto || weightBeforefix ==='1')){
|
||||
renderUnload();
|
||||
feedMyChart.setOption({
|
||||
dataset: {
|
||||
|
@ -620,13 +610,13 @@ function weightStabilization(weight) {
|
|||
var diff = weight - lastWeight;
|
||||
// 如果差值在一定范围内,则认为重量是稳定的
|
||||
if (Math.abs(diff) < 2) {
|
||||
weight = weight;
|
||||
lastWeight = weight;
|
||||
return true;
|
||||
weight = weight;
|
||||
lastWeight = weight;
|
||||
return true;
|
||||
} else {
|
||||
// 如果差值超过一定范围,则认为重量是不稳定的,重新开始计算
|
||||
weight = 0;
|
||||
lastWeight = weight;
|
||||
return false;
|
||||
// 如果差值超过一定范围,则认为重量是不稳定的,重新开始计算
|
||||
weight = 0;
|
||||
lastWeight = weight;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -3,7 +3,6 @@
|
|||
function updateApp() {
|
||||
mui.toast(document.getElementById('text').innerHTML);
|
||||
}
|
||||
|
||||
// 重量校准
|
||||
function weightFix() {
|
||||
if (!feedList.length > 0) {
|
||||
|
@ -17,6 +16,7 @@ function weightFix() {
|
|||
} else {
|
||||
beforeWeight = nowWeight;
|
||||
allowAuto = true
|
||||
document.getElementById('isfix').innerHTML = '已校准'
|
||||
mui.toast("校准完成");
|
||||
}
|
||||
});
|
||||
|
@ -127,7 +127,7 @@ function submitData() {
|
|||
newmsg = feedName + ttr;
|
||||
}
|
||||
param1.msg = newmsg + '饲喂完成';
|
||||
|
||||
// console.log(param1.msg)
|
||||
zfk.getMsg(param1, function (ret, err) {
|
||||
var str = ret.sendMsg;
|
||||
str = str.replace(/\s+/g, "");
|
||||
|
@ -136,6 +136,7 @@ function submitData() {
|
|||
msgList.push(param.value);
|
||||
})
|
||||
document.getElementById('submitData').setAttribute("class", 'btnc mui-btn-success dis');
|
||||
document.getElementById('feedNum').innerHTML = param1.msg;
|
||||
setTimeout(function(){
|
||||
console.log("停止蜂鸣");
|
||||
control("00", "00");
|
||||
|
@ -181,8 +182,10 @@ function submitData() {
|
|||
});
|
||||
// 误差小于100必须校准才能自动跳转
|
||||
allowAuto = false;
|
||||
document.getElementById('isfix').innerHTML = '未校准'
|
||||
text = feedName + _planSum;
|
||||
document.getElementById('nowFeed').innerHTML = '<font style="color:blue;margin-left:10px;">' + batchName + ',' + feedName + '</font>';
|
||||
document.getElementById('feedNum').innerHTML = '<font style="color:blue">:' + _planSum + '</font>/<font style="color:green">已装:' + _feedNum + '</font>';
|
||||
ledStatus = false;
|
||||
// setTimeout(() => {
|
||||
console.log("停止蜂鸣");
|
||||
|
|
Loading…
Reference in New Issue