adultDeviceApp/unpackage/dist/build/mp-weixin/BLEPages/child/B03B.js

1 line
6.9 KiB
JavaScript
Raw Permalink Normal View History

(global["webpackJsonp"]=global["webpackJsonp"]||[]).push([["BLEPages/child/B03B"],{"0304":function(e,t,o){"use strict";(function(e){var i=o("47a9");Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var n,c=i(o("7ca3")),s=o("8f59");function a(e,t){var o=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);t&&(i=i.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),o.push.apply(o,i)}return o}function r(e){for(var t=1;t<arguments.length;t++){var o=null!=arguments[t]?arguments[t]:{};t%2?a(Object(o),!0).forEach((function(t){(0,c.default)(e,t,o[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(o)):a(Object(o)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(o,t))}))}return e}var u=0,l=0,d={data:function(){return{text:"",weight:"",unit:"kg",height:"",childWeight:"",isChild:!1,status:-1,imp:0,macAddr:"",deviceId:"",serviceId:"",Unload:!1,stopblue:!0,isHeight:!1,isConnection:0}},computed:r(r({},(0,s.mapState)(["user","isConnected","isBluetoothTyle","appTheme"])),{},{info:function(){return this.user}}),onUnload:function(){this.Unload||(this.stopBluetoothDevicesDiscovery(),clearTimeout(n),this.closeBLEConnection(),this.closeBluetoothAdapter(),console.log("测量页返回1"))},onLoad:function(t){var o=this;o.text="",o.height=o.info.height,t&&t.deviceId&&(o.deviceId=t.deviceId,o.openBluetoothAdapter()),e.setNavigationBarColor({frontColor:"#ffffff",backgroundColor:this.appTheme}),e.onBluetoothAdapterStateChange((function(e){o.$store.commit("changeBluetooth",e.available)}))},watch:{isConnected:function(){this.isConnected||(this.handleBack(),this.isConnection=2)},isBluetoothTyle:function(){this.isBluetoothTyle||(this.handleBack(),this.isConnection=2)},stopblue:function(){this.stopblue||(this.isHeight=!0)}},methods:{openBluetoothAdapter:function(){var t=this;t.text="",u=0,l=0,t.childWeight="",t.isChild=!1,t.stopblue=!0,t.isHeight=!1,e.openBluetoothAdapter({success:function(e){t.isConnection=0,t.startBluetoothDeviceDiscovery()},fail:function(e){t.isConnection=2,t.$tools.msg("请确定设备是开机状态、手机蓝牙权限已打开!")}})},startBluetoothDeviceDiscovery:function(){var t=this;e.startBluetoothDevicesDiscovery({allowDuplicatesKey:!0,success:function(e){t.isConnection=0,t.onBluetoothDeviceFound()},fail:function(e){t.isConnection=2,t.$tools.msg("请确定设备是开机状态、手机蓝牙权限已打开!")}})},onBLEConnectionStateChange:function(){var t=this;e.onBLEConnectionStateChange((function(e){console.log("监听蓝牙连接状态",e.connected),e.connected||(clearTimeout(n),t.Unload=!0,t.text="",u=0,l=0,t.childWeight="",t.isChild=!1,t.stopblue=!0,t.isHeight=!1,t.isConnection=2,t.stopBluetoothDevicesDiscovery(),t.closeBLEConnection(),t.closeBluetoothAdapter()),t.$store.commit("changeConnected",e.connected)}))},stopBluetoothDevicesDiscovery:function(){e.stopBluetoothDevicesDiscovery({success:function(e){console.log("停止搜索蓝牙设备",e)}})},onBluetoothDeviceFound:function(){var t=this;function o(e,t){return(Array(t).join(0)+e).slice(-t)}e.onBluetoothDeviceFound((function(e){e.devices.forEach((function(e){if(e.advertisData=e.advertisData?e.advertisData:"",!e.name&&!e.localName){var i=t.$tools.ab2hex(e.advertisData,""),c=i.substring(12,16);if(-1!==i.indexOf("c0")&&"0a11"==c){clearTimeout(n);var s=e.advertisData.slice(-6);e.mac=new Uint8Array(s);var a=Array.from(e.mac);if(e.macAddr=t.$tools.ab2hex(a,":").toUpperCase(),-1!==e.deviceId.indexOf(t.deviceId)||-1!==e.macAddr.indexOf(t.deviceId)){t.isConnection=1;var r=parseInt(i.substring(16,18),16).toString(2),d=parseInt(i.substring(4,8),16),h=o(r,8).substring(7,8),f=o(r,8).substring(5,7),v=o(r,8).substring(3,5);t.status=o(r,8).substring(2,3);var g="kg";return console.log("value",t.status,d),"10"==v&&(t.unit="lb",g="lb"),"01"==v&&(t.unit="jin",g="斤"),"00"==f&&(d=parseInt(i.substring(4,8),16)/10),"10"==f&&(d="10"==v?parseInt(i.substring(4,8),16)/10:parseInt(i.substring(4,8),16)/100),0==h&&(0==u?t.text="您的<EFBFBD><EFBFBD>