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

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>--> <!-- <button class="save mui-btn-inline mui-btn-primary" style="font-size: large;" onclick="fixbeforeload()">保存</button>-->
</div> </div>
</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-row form">
<div class="mui-col-xs-8" style="display:flex;justify-content: flex-start;"> <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> <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>--> <!-- <button class="save mui-btn-inline mui-btn-primary" style="font-size: large;" onclick="weightSizeSave()">保存</button>-->
</div> </div>
</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>--> <!-- <button class="flex1 mui-btn-inline mui-btn-info" style="font-size: large;color: seagreen !important;" onclick="downloadApp()">下载文件</button>-->
</div> </div>
</div> </div>
@ -155,22 +165,28 @@
var carListener = null; var carListener = null;
var pageListener = null; var pageListener = null;
var fixListener = null; var fixListener = null;
var jumpListener = null;
var weiListener = null; var weiListener = null;
var btlListener = null; var btlListener = null;
var userPicker; var userPicker;
var pagePicker; var pagePicker;
var fixPicker; var fixPicker;
var jumpPicker;
var weiPicker; var weiPicker;
var btlPicker; var btlPicker;
var pickData = []; var pickData = [];
var btnArray = ['取消', '<b style="font-weight:900">确认</b>']; var btnArray = ['取消', '<b style="font-weight:900">确认</b>'];
var pageData = [] var pageData = []
var fixData = [] var fixData = []
var jumpData = []
var weiData = [] var weiData = []
var btlData = [] var btlData = []
fixData.push({value: 0, text: "需要"}) fixData.push({value: 0, text: "需要"})
fixData.push({value: 1, text: "不需要"}) fixData.push({value: 1, text: "不需要"})
jumpData.push({value: 0, text: "自动跳转"})
jumpData.push({value: 1, text: "不自动跳转"})
pageData.push({value: "index", text: "首页"}) pageData.push({value: "index", text: "首页"})
pageData.push({value: "index1", text: "装料页面"}) pageData.push({value: "index1", text: "装料页面"})
pageData.push({value: "collection", text: "剩料收集页面"}) pageData.push({value: "collection", text: "剩料收集页面"})
@ -274,6 +290,7 @@
muiInit(); muiInit();
muiInitPage() muiInitPage()
muiInitFix() muiInitFix()
muiInitJump()
muiInitWeightSize() muiInitWeightSize()
muiInitBtl() muiInitBtl()
var indexPage = api.getPrefs({ 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({ var weightSize = api.getPrefs({
sync: true, sync: true,
key: 'weightSize' key: 'weightSize'
@ -436,6 +465,34 @@
})(mui, document); })(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 muiInitWeightSize() {
(function ($, doc) { (function ($, doc) {
$.init(); $.init();
@ -549,6 +606,18 @@
mui.alert('装料前校准"' + name + '"设置成功'); 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> </script>
</body> </body>
</html> </html>

View File

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

View File

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