1 line
7.6 KiB
JavaScript
1 line
7.6 KiB
JavaScript
|
|
(global["webpackJsonp"]=global["webpackJsonp"]||[]).push([["BLEPages/child/PCD01pro"],{"44cf":function(e,t,o){"use strict";o.r(t);var n=o("ea61"),i=o.n(n);for(var c in n)"default"!==c&&function(e){o.d(t,e,(function(){return n[e]}))}(c);t["default"]=i.a},b6dd:function(e,t,o){"use strict";var n;o.d(t,"b",(function(){return i})),o.d(t,"c",(function(){return c})),o.d(t,"a",(function(){return n}));var i=function(){var e=this,t=e.$createElement;e._self._c},c=[]},ea61:function(e,t,o){"use strict";(function(e){Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var n,i=o("26cb");function c(e,t){var o=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),o.push.apply(o,n)}return o}function s(e){for(var t=1;t<arguments.length;t++){var o=null!=arguments[t]?arguments[t]:{};t%2?c(Object(o),!0).forEach((function(t){r(e,t,o[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(o)):c(Object(o)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(o,t))}))}return e}function r(e,t,o){return t in e?Object.defineProperty(e,t,{value:o,enumerable:!0,configurable:!0,writable:!0}):e[t]=o,e}var a=0,u={data:function(){return{Id:"",text:"",height:"",weight:"",imp:0,uuid1:"",uuid2:"",uuid3:"",macAddr:"",deviceId:"",serviceId:"",Unload:!1,pageNav:!1,isConnection:0}},computed:s(s({},(0,i.mapState)(["user","isConnected","isBluetoothTyle"])),{},{info:function(){return this.user}}),onUnload:function(){var e=this;e.Unload||(e.stopBluetoothDevicesDiscovery(),clearTimeout(n),e.closeBLEConnection(),e.closeBluetoothAdapter(),console.log("返回上一个页面"))},onLoad:function(t){var o=this;a=0,o.text="",t&&t.deviceId&&(o.Id=t.deviceId,o.closeBLEConnection(),o.closeBluetoothAdapter(),o.openBluetoothAdapter()),o.onBLEConnectionStateChange(),e.onBluetoothAdapterStateChange((function(e){o.$store.commit("changeBluetooth",e.available)}))},watch:{isConnected:function(){var e=this;e.isConnected||(e.handleBack(),e.isConnection=2)},isBluetoothTyle:function(){var e=this;e.isBluetoothTyle||(e.handleBack(),e.isConnection=2)}},methods:{openBluetoothAdapter:function(){var t=this;e.openBluetoothAdapter({success:function(e){t.startBluetoothDeviceDiscovery()},fail:function(e){t.isConnection=2,t.$tools.msg("请确定设备是开机状态、手机蓝牙权限已打开!")}})},startBluetoothDeviceDiscovery:function(){var t=this;e.startBluetoothDevicesDiscovery({allowDuplicatesKey:!1,interval:1e3,services:["FFE0"],success:function(e){t.onBluetoothDeviceFound()},fail:function(e){t.isConnection=2,t.$tools.msg("请确定设备是开机状态、手机蓝牙权限已打开!")}})},onBluetoothDeviceFound:function(){var t=this;e.onBluetoothDeviceFound((function(e){e.devices.forEach((function(e){if((e.name||e.localName)&&-1!=e.deviceId.indexOf(t.Id)){t.stopBluetoothDevicesDiscovery(),clearTimeout(n);var o=e.advertisData.slice(-6);e.mac=new Uint8Array(o);var i=Array.from(e.mac);return i.reverse(),e.macAddr=t.$tools.ab2hex(i,":").toUpperCase(),t.macAddr=e.macAddr,t.deviceId=e.deviceId,void t.createBLEConnection()}}))})),t.handleMyTime()},handleMyTime:function(){var e=this;n=setTimeout((function(){e.macAddr||(clearTimeout(n),e.Unload=!0,e.isConnection=2,e.closeBLEConnection(),e.closeBluetoothAdapter())}),2e4)},stopBluetoothDevicesDiscovery:function(){e.stopBluetoothDevicesDiscovery({success:function(e){console.log("停止搜索蓝牙设备",e)}})},onBLEConnectionStateChange:function(){var t=this;e.onBLEConnectionStateChange((function(e){console.log("监听蓝牙连接状态",e.connected),e.connected||(t.Unload=!0,t.isConnection=2,clearTimeout(n),t.closeBLEConnection(),t.closeBluetoothAdapter()),t.$store.commit("changeConnected",e.connected)}))},createBLEConnection:function(){var t=this;e.createBLEConnection({deviceId:t.deviceId,success:function(e){t.isConnection=1,t.getBLEDeviceServices()},fail:function(e){t.isConnection=2,console.log("设备连接失败,请重新连接",e)}})},getB
|