From 6448cf693a9cb057e5afc78f6dd34dd7038fad1b Mon Sep 17 00:00:00 2001 From: liuwu <975499773@qq.com> Date: Thu, 21 Mar 2024 16:03:28 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E9=93=B2=E8=BD=A6=E4=B8=8B?= =?UTF-8?q?=E4=B8=80=E6=AD=A5=E9=9A=90=E8=97=8F=E5=8A=9F=E8=83=BD,?= =?UTF-8?q?=E8=B7=B3=E8=BD=AC=E6=8C=89=E9=92=AE=E5=A4=A7=E5=B0=8F=EF=BC=8C?= =?UTF-8?q?=E4=BF=AE=E6=94=B9=E4=B8=8D=E6=98=BE=E7=A4=BAkg?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/circle.stml | 47 ++++++++++++++++++++++------------------------- script/ble.js | 15 +++++++++------ script/util.js | 34 +++++++++++++++++----------------- 3 files changed, 48 insertions(+), 48 deletions(-) diff --git a/pages/circle.stml b/pages/circle.stml index 96666aa..9e9d59e 100644 --- a/pages/circle.stml +++ b/pages/circle.stml @@ -2,7 +2,7 @@ - {{carName}} + {{carName}} {{batch}}{{train}}{{total}} {{state}} @@ -49,24 +49,13 @@ 计划:{{plan}}kg,已装:{{feed}}kg - - - + - + - - - - @@ -83,6 +72,7 @@ export default { return { _feed: '0', showItems:false, + showOpt:false, total: '', bleName: '请选择蓝牙', state: '未连接', @@ -146,6 +136,9 @@ export default { handleBackMain() { api.closeWin(); }, + setOpt(){ + this.data.showOpt = !this.data.showOpt; + }, rescan(){ const that = this; api.confirm({ @@ -210,7 +203,8 @@ export default { const that = this; var sbIdHex = that.decimalToHex(that.data.sbId).replace(' ', ''); sbIdHex = sbIdHex.length < 4 ? '00' + sbIdHex : sbIdHex; - var msg = 'FF0A0002' + sbIdHex + var feedIndex = that.decimalToHex(that.data.feedIndex).replace(' ', ''); + var msg = 'FF0A0003' + sbIdHex + feedIndex let param = { peripheralUUID: this.data.peripheralUUID, serviceUUID: this.data.serviceUUID, @@ -239,6 +233,7 @@ export default { carChange(item) { this.data.sbId = item.sbId; this.data.carName = item.name; + this.data.showOpt = false; this.resetData() }, resetData(){ @@ -293,7 +288,7 @@ export default { }) }) - }, 3000); + }, 5000); }) }) }, @@ -342,8 +337,10 @@ export default { return false } that.data.showItems = true; - that.data.nowWeight = parseInt(res.substr(8, 4), 16) - that.data.beforeWeight = parseInt(res.substr(12, 4), 16) + var nowW = parseInt(res.substr(8, 4), 16); + var befW = parseInt(res.substr(12, 4), 16) + that.data.nowWeight = nowW>32578?nowW-65536:nowW; + that.data.beforeWeight = befW>32578?befW-65536:befW; that.data.feed = that.data.nowWeight - that.data.beforeWeight var _feed = that.data.plan - that.data.feed; that.data._feed = _feed > 0 ? '少' + Math.abs(_feed) : '多' + Math.abs(_feed); @@ -461,14 +458,14 @@ export default { border-radius: 10px; } .car_btnt { - margin: 5px; + margin-bottom: 10px; /* background-color: #407ae6; */ width: 100%; color: #000000; - font-size: 20px; - height: 50px; + font-size: 30px; + height: 60px; font-weight: 900; - border-radius: 10px; + border-radius: 20px; } .header_btn1 { background-color: #e60d0d; @@ -524,7 +521,7 @@ export default { margin-top: 40px; color: #ffffff; background-color: #407ae6; - font-size: 70px; + font-size: 60px; font-weight: 900; border-radius: 20%; } @@ -535,12 +532,12 @@ export default { border-radius: 10px; } .label_x { - font-size: 100px; + font-size: 90px; font-weight: 900; border-radius: 10px; } .label { - font-size: 60px; + font-size: 50px; font-weight: 900; border-radius: 10px; } diff --git a/script/ble.js b/script/ble.js index a3be81f..2359f4d 100644 --- a/script/ble.js +++ b/script/ble.js @@ -363,7 +363,7 @@ function discoverService(param) { serviceUUID: ret4, characteristicUUID: ret5 }, function (ret6) { - if (ret6 !== undefined&& ret6 !='') { + if (ret6 !== undefined && ret6 !=='') { if (isNaN(ret6)) { return false } @@ -619,11 +619,11 @@ function setNotify(param, callback) { res = Math.round(Number(StringToNum(wei))); } // 发送实时重量和校准重量到其他平板 - if(weiNum >= shujubao && res && sbId && beforeWeight){ + if(weiNum >= shujubao && undefined !== res && sbId && undefined !== beforeWeight){ weiNum = 0; - var weiHex = decimalToHex(res).replace(' ',''); + var weiHex = decimalToHex(res>0?res:res+65536).replace(' ',''); var sbIdHex = decimalToHex(sbId).replace(' ',''); - var beforeHex = decimalToHex(beforeWeight).replace(' ',''); + var beforeHex = decimalToHex(beforeWeight>0?beforeWeight:beforeWeight+65536).replace(' ',''); var banciHex = decimalToHex(classCode).replace(' ',''); var checiHex = decimalToHex(trainNumber).replace(' ',''); var feedInexHex = decimalToHex(feedIndex).replace(' ',''); @@ -633,6 +633,7 @@ function setNotify(param, callback) { if(feedStatus){ var bleStr = 'FF0A0009'+weiHex+beforeHex+sbIdHex+banciHex+checiHex+feedInexHex; // msgList.push(bleStr); + // console.log(bleStr) execute(db, "INSERT INTO t_ble_msg (id,text) VALUES ("+new Date().getTime()+",'"+bleStr+"');", function (ret, err) {}) } @@ -641,8 +642,9 @@ function setNotify(param, callback) { // 接收其他平板发来的校准重量和实时重量 if (feedStatus && ret && value.startsWith("ff0a") && sbId === parseInt(value.substr(8, 4),16)){ var sbId_now = parseInt(value.substr(8, 4),16); + var feedIdx = parseInt(value.substr(12, 2),16); console.log(sbId) - if(sbId != sbId_now){ + if(sbId !== sbId_now || feedIndex !== feedIdx || !load){ return false } weightDataFilter.dataBuffer = [] @@ -742,7 +744,8 @@ function getMess(param, callback) { } param1.msg = newmsg + '饲喂完成'; }else{ - param1.msg = newmsg + Math.abs(Number(_planSum - _feedNum)).toFixed(0) + 'kg'; + // param1.msg = newmsg + Math.abs(Number(_planSum - _feedNum)).toFixed(0) + 'kg'; + param1.msg = newmsg + Math.abs(Number(_planSum - _feedNum)).toFixed(0); } // param1.msg = newmsg + Math.abs(Number(param.value)).toFixed(0) + 'kg' // console.log(param1.msg) diff --git a/script/util.js b/script/util.js index 7ec9ef6..6f0afc0 100644 --- a/script/util.js +++ b/script/util.js @@ -1,6 +1,6 @@ var Util = { appOpen:function(){ - var phoneInfoMore = api.require('phoneInfoMore'); + // var phoneInfoMore = api.require('phoneInfoMore'); var data1 = { appDeviceid: api.deviceId, appId: api.appId, @@ -19,21 +19,21 @@ var Util = { screenheight: api.screenHeight, sourceCow: api.getPrefs({ sync: true, key: 'sourceCow' }), } - if(api.systemVersion<=10){ - phoneInfoMore.getBaseInfo(function(ret, err) { - if(ret){ - api.setGlobalData({ key: 'imei', value: ret.imei }); - data1.imei = ret.imei - POST('appOpen', data1, {}).then(ret => { - // console.log(JSON.stringify(ret)); - }).catch(err => { - api.toast({ - msg: JSON.stringify(err) - }) - }) - } - }); - }else{ + // if(api.systemVersion<=10){ + // phoneInfoMore.getBaseInfo(function(ret, err) { + // if(ret){ + // api.setGlobalData({ key: 'imei', value: ret.imei }); + // data1.imei = ret.imei + // POST('appOpen', data1, {}).then(ret => { + // // console.log(JSON.stringify(ret)); + // }).catch(err => { + // api.toast({ + // msg: JSON.stringify(err) + // }) + // }) + // } + // }); + // }else{ data1.imei = api.deviceId POST('appOpen', data1, {}).then(ret => { // console.log(JSON.stringify(ret)); @@ -42,7 +42,7 @@ var Util = { msg: JSON.stringify(err) }) }) - } + // } }, getDateStr:function(date){