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

1 line
9.7 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

(global["webpackJsonp"]=global["webpackJsonp"]||[]).push([["pageTwo/devices/F01PRO"],{"5f23":function(e,t,n){"use strict";n.d(t,"b",(function(){return o})),n.d(t,"c",(function(){return i})),n.d(t,"a",(function(){}));var o=function(){var e=this.$createElement;this._self._c},i=[]},"65dc":function(e,t,n){"use strict";n.r(t);var o=n("e9d1"),i=n.n(o);for(var s in o)["default"].indexOf(s)<0&&function(e){n.d(t,e,(function(){return o[e]}))}(s);t["default"]=i.a},ad58:function(e,t,n){"use strict";n.r(t);var o=n("5f23"),i=n("65dc");for(var s in i)["default"].indexOf(s)<0&&function(e){n.d(t,e,(function(){return i[e]}))}(s);var c=n("828b"),r=Object(c["a"])(i["default"],o["b"],o["c"],!1,null,"4c084893",null,!1,o["a"],void 0);t["default"]=r.exports},ccd9:function(e,t,n){"use strict";(function(e,t){var o=n("47a9");n("bad8");o(n("3240"));var i=o(n("ad58"));e.__webpack_require_UNI_MP_PLUGIN__=n,t(i.default)}).call(this,n("3223")["default"],n("df3c")["createPage"])},e9d1:function(e,t,n){"use strict";(function(e){var o=n("47a9");Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var i=o(n("7eb4")),s=o(n("ee10")),c=o(n("7ca3")),r=n("8f59");function a(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);t&&(o=o.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,o)}return n}function u(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?a(Object(n),!0).forEach((function(t){(0,c.default)(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):a(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}var l=requirePlugin("sdkPlugin").AiLink,d={data:function(){return{textW:"",textH:"",textImp:"",height:"",weight:"",imp:0,macAddr:"",deviceId:"",serviceId:"",readId:"",writeId:"",notifyId:"",isSend:!0,Unload:!1,isConnection:0,data01:{},data02:{},BLEResult:{}}},computed:u(u({},(0,r.mapState)(["user","isConnected","isBluetoothTyle"])),{},{userInfo:function(){return this.user}}),onUnload:function(){var e=(0,s.default)(i.default.mark((function e(){var t,n;return i.default.wrap((function(e){while(1)switch(e.prev=e.next){case 0:t=this,t.Unload||(clearTimeout(void 0),t.$store.state.devicesList2=[],t.closeBLEConnection(),t.closeBluetoothAdapter(),1!=t.isConnection&&(n=getCurrentPages(),n[n.length-2].$vm.islink=-1,n[n.length-2].$vm.textLink="开始连接"));case 2:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}(),watch:{isConnected:function(){this.isConnected||(console.log("F01PROisConnected-"+this.isConnected),this.handleBack(),this.isConnection=2)},isBluetoothTyle:function(){this.isBluetoothTyle||(console.log("F01PROisBluetoothTyle-"+this.isBluetoothTyle),this.handleBack(),this.isConnection=2)}},onLoad:function(t){var n=this;n.textW="",n.textH="",console.log("options",t),t&&t.deviceId&&(n.deviceId=t.deviceId,n.createBLEConnection()),n.onBLEConnectionStateChange(),e.onBluetoothAdapterStateChange((function(e){n.$store.commit("changeBluetooth",e.available)}))},methods:{openBluetoothAdapter:function(){var t=this;t.textW="",t.textH="",t.isSend=!0,t.Unload=!1,e.openBluetoothAdapter({success:function(e){t.isConnection=0,t.startBluetoothDeviceDiscovery(),console.log("初始化蓝牙成功:"+e.errMsg)},fail:function(e){t.isConnection=2,t.$tools.msg("请确定设备是开机状态、手机蓝牙权限已打开!")}})},onBLEConnectionStateChange:function(){var t=this;e.onBLEConnectionStateChange((function(e){console.log("F01PROonBLEConnectionStateChange-"+e.connected),e.connected||(t.Unload=!0,t.isConnection=2,clearTimeout(void 0),t.closeBLEConnection(),t.closeBluetoothAdapter()),t.$store.commit("changeConnected",e.connected)}))},startBluetoothDeviceDiscovery:function(){var t=this;e.startBluetoothDevicesDiscovery({allowDuplicatesKey:!1,interval:500,success:function(e){t.isConnection=0,t.onBluetoothDeviceFound()},fail:function(e){t.isConnection=2,t.$tools.msg("请确定设备是开机状态、手机蓝牙权限已打开!")}})},onBluetoothDeviceFound:function(){var t=this;t.isConnection=0,e.onBluetoothDeviceFound((function(e){e.devices.forEach((function(e){if((e.name||e.localName)&&(-1!=e.name.indexOf("AiLink_")||-1!=e.name.indexOf("PCF01")||e.localName&&(-1!=e.localName.indexOf("AiLink_")||-1!=e.localName.indexOf("PCF01")))&&(clearTimeout(void 0),-1!=e.deviceId.indexOf(t.deviceId))){t.stopBluetoothDevicesDiscovery(),t.deviceId=e.deviceId;var n=t.$store.state.devicesList2,o=t.$tools.inArray(n,"deviceId",e.deviceId);return-1===o?t.$store.state.devicesList2.push(e):t.$store.state.devicesList2[o]=e,void t.createBLEConnection()}}))}))},stopBluetoothDevicesDiscovery:function(){e.stopBluetoothDevicesDiscovery({success:function(e){console.log("停止搜索蓝牙设备",e)}})},createBLEConnection:function(){var t=this;e.createBLEConnection({deviceId:t.deviceId,success:function(e){console.log("设备连接成功获取设备的services",e),t.isConnection=0,t.getBLEDeviceServices()},fail:function(e){t.isConnection=2,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 o=0;o<t.length;o++){var i=t[o];if(-1!=i.uuid.indexOf("FFE0")){n.serviceId=i.uuid,n.isConnection=1,n.getBLEDeviceCharacteristics(n.deviceId,i.uuid),console.log("设备的FFE0的serviceId ",n.serviceId);break}}},fail:function(e){console.log("获取设备的UUID失败:",e)}})},getBLEDeviceCharacteristics:function(t,n){var o=[],i=this;e.getBLEDeviceCharacteristics({deviceId:t,serviceId:n,success:function(s){console.log("服务的特征值成功",s),o=s.characteristics;for(var c=0;c<o.length;c++){var r=o[c];-1!=r.uuid.indexOf("0000FFE1")?i.uuid1=r.uuid:-1!=r.uuid.indexOf("0000FFE2")?i.uuid2=r.uuid:-1!=r.uuid.indexOf("0000FFE3")&&(i.uuid3=r.uuid)}e.notifyBLECharacteristicValueChange({deviceId:t,serviceId:n,characteristicId:i.uuid2,state:!0}),e.notifyBLECharacteristicValueChange({deviceId:t,serviceId:n,characteristicId:i.uuid3,state:!0}),console.log("初始化插件",i.$store.state.devicesList2),i.$store.state.devicesList2[0].serviceId=i.serviceId,l.initPlugin(s.characteristics,i.$store.state.devicesList2[0]),e.onBLECharacteristicValueChange((function(e){var t=l.parseBleData(e.value);if(console.log("bleData",t),0==t.status){var n=1==i.userInfo.gender?1:0,o="0x0"+n.toString(16),s="0x"+i.userInfo.age.toString(16),c="0x"+i.userInfo.height.toString(16),r=[1,parseInt(o),parseInt(s),parseInt(c),0];l.sendDataOfA7(r),console.log("握手成功",r)}else if(1==t.status){var a=i.$tools.ab2hex(t.data,""),u=a.substring(4,6),d=a.substring(0,2);if(console.log("开始测量",a),"03"==d){console.log("MCU主动请求用户数据");var f=1==i.userInfo.gender?1:0,h="0x0"+f.toString(16),v="0x"+i.userInfo.age.toString(16),g="0x"+i.userInfo.height.toString(16),p=[1,parseInt(h),parseInt(v),parseInt(g),0];l.sendDataOfA7(p)}if("10"==d||"30"==d||"40"==d){var I=parseInt(a.substring(6,12),16),B=parseInt(a.substring(12,14),16).toString(2),b=i.$tools.PrefixZero(B,8).substring(4,8),m=i.$tools.PrefixZero(B,8).substring(0,4),C="kg";"0001"==b&&(C="斤"),"0110"==b&&(C="lb"),"0001"==m&&(I/=10),"0010"==m&&(I/=100),"0011"==m&&(I/=1e3),"01"==u&&(i.textW="您的实时体重是:"+I+C),"02"==u&&(i.textW="您的体重是:"+I+C,i.weight=I+C)}if("14"==d||"41"==d){var L=parseInt(a.substring(4,8),16),O=parseInt(a.substring(10,12),16);"1"==O&&(L/=10),"2"==O&&(L/=100),i.textH="您的身高是:"+L+"cm",i.height=L,console.log("身高模式:",i.height)}"11"==d&&("01"==u&&(i.textImp="正在测量体脂:请双手紧握扶手"),"02"==u&&(i.imp=0,i.textImp=""),"04"==u&&(i.textImp="",i.imp=parseInt(a.substring(8,12),16)),console.log("阻抗:",i.imp)),"15"==d&&("01"==u&&(i.data01={bodyage:parseInt(a.substring(26,28),16),fat_r:parseInt(a.substring(6,10),16)/10,muscle:parseInt(a.substring(18,22),16)/10,kcal:parseInt(a.substring(22,26),16),visceral:parseInt(a.substring(14,18),16),sfr:parseInt(a.substring(10,14),16)/10}),"02"==u&&(i.data02={water:parseInt(a.substring(10,14),16)/10,bone:parseInt(a.substring(6,10),16)/10,fatlevlval:parseInt(a.substring(24,26),16)/10,protein:parseInt(a.substring(14,18),16)/10,bmi:parseInt(a.substring(18,22),16)/10}),console.log("体脂数据",i.data01,i.data02),i.BLEResult.info=Object.assign(i.data01,i.data02)),"80"==d&&(i.BLEResult.weight=i.weight,i.BLEResult.adc=i.imp?i.imp:0,i.BLEResult.height=(i.height?i.height:i.userInfo.height)+"cm",i.BLEResult.aud_id=i.userInfo.id,console.log("体脂成功:",i.BLEResult),i.handleGetMeasure(i.BLEResult))}}))},fail:function(e){console.log("获取特征值失败:",JSON.stringify(e))}})},handleGetMeasure:function(t){console.log("保存结果");var n=this;n.$model.getmeasurefunit(t).then((function(t){0==t.code?(n.$store.dispatch("getUserInfo",{aud_id:e.getStorageSync("userid")}),n.$store.dispatch("getResult",{aud_id:e.getStorageSync("userid")}),setTimeout((function(){e.showToast({title:"测量成功"})}),500)):e.showToast({title:t.message,icon:"error"}),n.Unload=!0,setTimeout((function(){n.closeBLEConnection(),n.closeBluetoothAdapter(),n.$store.state.devicesList2=[],e.switchTab({url:"/pages/home/home"})}),1e3)}))},closeBluetoothAdapter:function(){e.closeBluetoothAdapter({success:function(e){console.log("F01PRO蓝牙模块关闭成功")}})},handleBack:function(){this.Unload=!0,console.log("F01PROhandleBack"),this.stopBluetoothDevicesDiscovery(),this.closeBLEConnection(),this.closeBluetoothAdapter(),this.$store.state.devicesList2=[]},closeBLEConnection:function(){e.closeBLEConnection({deviceId:this.deviceId,success:function(e){console.log("F01PRO断开蓝牙连接成功")}})}}};t.default=d}).call(this,n("df3c")["default"])}},[["ccd9","common/runtime","common/vendor"]]]);