增加是否自动跳转设置选项

This commit is contained in:
liuwu 2024-01-02 10:31:23 +08:00
parent 7c57c53048
commit cd1bab919a
3 changed files with 85 additions and 5 deletions

View File

@ -122,6 +122,18 @@
<!-- <button class="save mui-btn-inline mui-btn-primary" style="font-size: large;" onclick="fixbeforeload()">保存</button>-->
</div>
</div>
</div>
<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='jump' class="flex1 mui-btn-inline mui-btn-info" style="font-size: large;color: seagreen !important;" >请选择</button>
<input id="isJump" type="hidden" value="">
</div>
<div class="mui-col-xs-4" style="display:flex;justify-content: flex-end;">
</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>
@ -140,8 +152,6 @@
<!-- <button class="save mui-btn-inline mui-btn-primary" style="font-size: large;" onclick="weightSizeSave()">保存</button>-->
</div>
</div>
</div>
<div class="mui-col-sm-6">
<!-- <button class="flex1 mui-btn-inline mui-btn-info" style="font-size: large;color: seagreen !important;" onclick="downloadApp()">下载文件</button>-->
</div>
</div>
@ -155,22 +165,28 @@
var carListener = null;
var pageListener = null;
var fixListener = null;
var jumpListener = null;
var weiListener = null;
var btlListener = null;
var userPicker;
var pagePicker;
var fixPicker;
var jumpPicker;
var weiPicker;
var btlPicker;
var pickData = [];
var btnArray = ['取消', '<b style="font-weight:900">确认</b>'];
var pageData = []
var fixData = []
var jumpData = []
var weiData = []
var btlData = []
fixData.push({value: 0, text: "需要"})
fixData.push({value: 1, text: "不需要"})
jumpData.push({value: 0, text: "自动跳转"})
jumpData.push({value: 1, text: "不自动跳转"})
pageData.push({value: "index", text: "首页"})
pageData.push({value: "index1", text: "装料页面"})
pageData.push({value: "collection", text: "剩料收集页面"})
@ -274,6 +290,7 @@
muiInit();
muiInitPage()
muiInitFix()
muiInitJump()
muiInitWeightSize()
muiInitBtl()
var indexPage = api.getPrefs({
@ -301,6 +318,18 @@
})
}
var requireJump = api.getPrefs({
sync: true,
key: 'jump'
});
if (requireJump) {
jumpData.forEach(p => {
if (requireJump == p.value) {
document.getElementById('jump').innerHTML = p.text
}
})
}
var weightSize = api.getPrefs({
sync: true,
key: 'weightSize'
@ -436,6 +465,34 @@
})(mui, document);
}
function muiInitJump() {
(function ($, doc) {
$.init();
$.ready(function () {
var _getParam = function _getParam(obj, param) {
return obj[param] || '';
};
if (jumpPicker) {
} else {
jumpPicker = new $.PopPicker();
var showJumpPickerButton = doc.getElementById('jump');
jumpListener = null;
jumpListener = showJumpPickerButton.addEventListener('tap', function (event) {
jumpPicker.show(function (items) {
document.getElementById('isJump').value = items[0].value;
showJumpPickerButton.innerHTML = items[0].text;
if (items[0].text){
jump()
}
});
}, false);
}
jumpPicker.setData(jumpData);
});
})(mui, document);
}
function muiInitWeightSize() {
(function ($, doc) {
$.init();
@ -549,6 +606,18 @@
mui.alert('装料前校准"' + name + '"设置成功');
}
}
function jump(){
var value = document.getElementById('isJump').value;
if (value) {
console.log(value)
api.setPrefs({
key: 'jump',
value: value
});
var name = document.getElementById('jump').innerHTML;
mui.alert(name + '"设置成功');
}
}
</script>
</body>
</html>

View File

@ -282,11 +282,18 @@
if (fixbeforeload){
weightBeforefix = fixbeforeload;
}
var jump = api.getPrefs({
sync: true,
key: 'jump'
});
if (jump){
autoJump = jump;
}
var btl = api.getPrefs({sync: true,key: 'btl'})
if (btl && !isNaN(btl)){
shujubao = Number(btl)
}
console.log("weightBeforefix"+weightBeforefix)
ble = api.require('ble');
zfk = api.require("moduleDemo");
clearInterval(resultInterval);

View File

@ -55,6 +55,7 @@ function scan(param) {
}
var weightBeforefix = '1';
var autoJump = '1';
function stopScan(){
ble.stopScan()
@ -384,9 +385,12 @@ function discoverService(param) {
}, 500)
}
}
if (autoJump==='0'){
console.log("自动跳转")
}
// console.log(weightStabilization("weightStabilization"+nowWeight))
// 在误差范围内
if (feedErr <= allow && (allowAuto || weightBeforefix === '1')) {
if (autoJump==='0' && feedErr <= allow && (allowAuto || weightBeforefix === '1')) {
// 重量稳定计数
var filteredValue = weightDataFilter.filter(nowWeight);
// 重量稳定自动跳转
@ -396,7 +400,7 @@ function discoverService(param) {
remark = '自动跳转'
document.getElementById('submitData').click();
}
}else if(_feedNum > _planSum && (allowAuto || weightBeforefix === '1')){
}else if(autoJump==='0' && _feedNum > _planSum && (allowAuto || weightBeforefix === '1')){
// 重量稳定计数
var filteredValue = weightDataFilter.filter(nowWeight);
// 重量稳定自动跳转