examTeamApp/unpackage/dist/build/mp-weixin/pageTwo/devices/PCV02.js

1 line
9.2 KiB
JavaScript
Raw Permalink Normal View History

2025-08-06 15:49:20 +08:00
(global["webpackJsonp"]=global["webpackJsonp"]||[]).push([["pageTwo/devices/PCV02"],{"387b":function(e,t,n){"use strict";(function(e){var i=n("47a9");Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var o,c=i(n("7ca3")),s=n("8f59");function r(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);t&&(i=i.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,i)}return n}function a(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?r(Object(n),!0).forEach((function(t){(0,c.default)(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):r(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}var u=0,l=0,d=null,f={data:function(){return{isEnd:!1,isstart:!1,number1:0,number2:0,number3:0,level1:"",level2:"",level3:"",average:"",averageS:"",text:0,LiuS:"",macAddr:"",serviceId:"",deviceId:"",Unload:!1,notify:"",write:"",second:5,standard:"",offset:0,listS:[]}},computed:a(a({},(0,s.mapState)(["user","isConnected","isBluetoothTyle","lungLevel"])),{},{info:function(){return this.user},list:function(){var e="";return this.lungLevel.forEach((function(t){"及格"==t.text&&(e=t.min_val)})),this.standard=e,this.lungLevel}}),onUnload:function(){this.Unload||(clearTimeout(o),this.stopBluetoothDevicesDiscovery(),this.closeBLEConnection(),this.closeBluetoothAdapter(),console.log("页面返回onUnload"))},onLoad:function(t){var n=this;t&&t.deviceId&&(n.deviceId=t.deviceId,n.openBluetoothAdapter()),n.openBluetoothAdapter(),n.onBLEConnectionStateChange(),e.onBluetoothAdapterStateChange((function(e){n.$store.commit("changeBluetooth",e.available)}))},watch:{isConnected:function(){this.isConnected||this.handleBack()},isBluetoothTyle:function(){this.isBluetoothTyle||this.handleBack()},second:function(){this.second<=0&&(u++,this.isstart=!0,this.sendData("FA02A29E"),this.offset=0,this.text=0)},isEnd:function(){if(console.log("结束测量",this.isEnd),this.isEnd){console.log("结束测量2",this.isEnd),this.isstart=!1,this.sendData("FA02A39F"),this.level3=this.handlelenver(this.number2),this.average=(Number(this.number3)+Number(this.number2)+Number(this.number1))/3;for(var e=0,t=0;t<this.listS.length;t++)e+=Number(this.listS[t]);this.averageS=(e/this.listS.length).toFixed(2),console.log(e/this.listS.length)}}},methods:{openBluetoothAdapter:function(){var t=this;u=0,l=0,d=null,t.isEnd=!1,t.text=0,t.number1=0,t.number2=0,t.number3=0,t.level1="",t.level2="",t.level3="",t.average="",t.LiuS="",t.second=5,t.standard="",t.offset=0,e.openBluetoothAdapter({success:function(e){console.log("初始化设备"),t.startBluetoothDeviceDiscovery()},fail:function(e){t.$tools.msg("请确定设备是开机状态、手机蓝牙权限已打开!")}})},startBluetoothDeviceDiscovery:function(){var t=this;e.startBluetoothDevicesDiscovery({allowDuplicatesKey:!0,success:function(e){console.log("开始搜索"),t.onBluetoothDeviceFound()},fail:function(e){t.$tools.msg("请确定设备是开机状态、手机蓝牙权限已打开!")}})},onBluetoothDeviceFound:function(){var t=this;e.onBluetoothDeviceFound((function(e){e.devices.forEach((function(e){if(e.name||e.localName)return-1!=e.name.indexOf("Yihejia_Lung")&&(clearTimeout(o),e.macAddr=e.deviceId,-1!=e.deviceId.indexOf(t.deviceId))?(t.stopBluetoothDevicesDiscovery(),t.createBLEConnection(),void console.log("that.deviceId",t.deviceId,e.deviceId)):void 0}))})),t.handleMyTime()},createBLEConnection:function(){var t=this;e.createBLEConnection({deviceId:t.deviceId,success:function(e){t.countdown(),setTimeout((function(){t.getBLEDeviceServices()}),1500)},fail:function(e){console.log("设备连接失败,请重新连接",e)}})},getBLEDeviceServices:function(){var t=[],n=this;e.getBLEDeviceServices({deviceId:n.deviceId,success:function(e){console.log("获取设备的UUID成功",e),t=e.services;for(var i=0;i<t.length;i++){var o=t[i];if(-1!=o.uuid.indexOf("FFE0")){n.serviceId=o.uuid,n.getBLEDevi