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

1 line
7.2 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/B20"],{"093c":function(e,t,i){"use strict";(function(e){var n=i("47a9");Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var c=n(i("7ca3")),o=i("8f59");function s(e,t){var i=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),i.push.apply(i,n)}return i}function r(e){for(var t=1;t<arguments.length;t++){var i=null!=arguments[t]?arguments[t]:{};t%2?s(Object(i),!0).forEach((function(t){(0,c.default)(e,t,i[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(i)):s(Object(i)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(i,t))}))}return e}var a={data:function(){return{text:"",typeInfo:0,head:"",weight:"",height:"",unit:"kg",Unload:!1,isHeight:!1,isSave:!0,deviceId:"",serviceId:"",write:"",notify:"",islink:0,textLink:"",isFinished:!1,devicesList:[],IsLing:!1,IsNum:!1}},computed:r(r({},(0,o.mapState)(["user","isConnected","isBluetoothTyle"])),{},{userInfo:function(){return this.user}}),onUnload:function(){this.Unload||(clearTimeout(void 0),this.closeBLEConnection(),this.closeBluetoothAdapter(),console.log("页面返回onUnload"))},onLoad:function(t){var i=this;i.typeInfo=0,i.height=i.userInfo.height,i.head=i.userInfo.head_data,i.deviceId=t.deviceId,i.createBLEConnection(),i.$Bluetooth.onBLEConnectionStateChange(),e.onBluetoothAdapterStateChange((function(e){i.$store.commit("changeBluetooth",e.available)}))},watch:{isConnected:function(){if(!this.isConnected){this.$tools.showModal("测量过程中已与设备连接中断,请重新连接设备再开始测量")}},isBluetoothTyle:function(){if(!this.isBluetoothTyle){this.$tools.showModal("蓝牙已关闭,请重新打开蓝牙后再开始测量")}},isFinished:function(){var e=this;e.isFinished&&setTimeout((function(){e.isHeight=!0}),600)}},methods:{createBLEConnection:function(){var t=this;e.createBLEConnection({deviceId:t.deviceId,success:function(e){t.textLink="蓝牙连接中",setTimeout((function(){t.getBLEDeviceServices()}),1e3)},fail:function(e){t.textLink="设备连接失败,返回首页重新连接",console.log("设备连接失败,请重新连接",e,t.deviceId)}})},getBLEDeviceServices:function(){var t=[],i=this;e.getBLEDeviceServices({deviceId:i.deviceId,success:function(e){console.log("获取设备的UUID成功",e),t=e.services;for(var n=0;n<t.length;n++){var c=t[n];if(-1!=c.uuid.indexOf("FFF0")){i.serviceId=c.uuid,i.getBLEDeviceCharacteristics(),console.log("设备的FFF0的serviceId "+i.serviceId);break}}},fail:function(e){i.textLink="设备连接失败,返回首页重新连接",console.log("获取设备的UUID失败:",e)}})},getBLEDeviceCharacteristics:function(){var t=this;e.getBLEDeviceCharacteristics({deviceId:t.deviceId,serviceId:t.serviceId,success:function(i){for(var n=0;n<i.characteristics.length;n++){var c=i.characteristics[n];-1!=c.uuid.indexOf("0000FFF1")?t.notify=c.uuid:-1!=c.uuid.indexOf("0000FFF2")&&(t.write=c.uuid)}t.textLink="蓝牙连接成功,请开始测量",e.notifyBLECharacteristicValueChange({deviceId:t.deviceId,serviceId:t.serviceId,characteristicId:t.notify,state:!0}),e.notifyBLECharacteristicValueChange({deviceId:t.deviceId,serviceId:t.serviceId,characteristicId:t.write,state:!0});t.writeBLECharacteristicValue("A6020401076A"),t.notifyBLECharacteristicValue()},fail:function(e){console.log("获取特征值失败:",JSON.stringify(e))}})},notifyBLECharacteristicValue:function(){var t=this;e.notifyBLECharacteristicValueChange({state:!0,deviceId:t.deviceId,serviceId:t.serviceId,characteristicId:t.notify,success:function(i){t.isSave=!0,e.onBLECharacteristicValueChange((function(e){var i=t.$tools.ab2hex(e.value,""),n=i.substring(4,6),c=i.substring(6,8),o=parseInt(i.substring(8,14),16),s=i.substring(18,19),r=i.substring(19,20);"0"==r&&(t.unit="kg"),"1"==r&&(t.unit="斤"),"2"==r&&(t.unit="st:lb"),"3"==r&&(t.unit="lb"),"0"==s&&(o=o),"1"==s&&(o/=10),"2"==s&&(o/=100),"3"==s&&(o/=1e3),"01"==c&&(t.typeInfo=1,t.weight=o,t.IsLing=!1),"02"==c&&(t.typeInfo=2,t.weight=o,t.isFinished=!0),console.log("状态:",i,n,c,o,t.unit,t.isFinished)}))},fail:function(e){console.log("测量失败",e.value)}})},handleIsLing:function(){this.IsLing||(this.writeBLECharacteristicValue("A6020500076A"),this.IsLing=!0)},handleIsNum:function(){this.writeBLECharacteristicValue("A6020400066A")},writeBLECharacteristicValue:function(t){var i=new Uint8Array(t.match(/[\da-f]{2}/gi).map((function(e){return parseInt(e,16)})));console.log("buffer",t,i),e.writeBLECharacteristicValue({deviceId:this.deviceId,serviceId:this.serviceId,characteristicId:this.write,value:i.buffer,success:function(e){console.log("下发指令成功",e.errMsg)},fail:function(e){console.log("下发指令失败",e)}})},handleGetMeasure:function(){var t=this;t.height?t.$model.getmeasurefunit({adc:0,weight:t.weight,height:t.height,aud_id:t.userInfo.id,head_data:t.head?t.head:0}).then((function(i){t.isHeight=!1,t.isSave=!1,0==i.code?(t.$store.dispatch("getResult",{aud_id:e.getStorageSync("userid")}),t.$store.dispatch("getUserInfo",{aud_id:e.getStorageSync("userid")}),t.$tools.msg("测量成功")):t.$tools.msg("测量失败"),t.Unload=!0,e.switchTab({url:"/pages/home/home"}),setTimeout((function(){t.closeBLEConnection(),t.closeBluetoothAdapter()}),200)})):this.$tools.msg("请输入身高")},handleBack:function(){var e=this;e.typeInfo=0,e.isFinished=!1,e.writeBLECharacteristicValue("A6020500076A"),setTimeout((function(){e.isHeight=!1}),500)},stopBluetoothDevicesDiscovery:function(){e.stopBluetoothDevicesDiscovery({success:function(e){console.log("停止搜索蓝牙设备",e)}})},onBLEConnectionStateChange:function(){var t=this;e.onBLEConnectionStateChange((function(e){console.log("监听蓝牙连接状态",e.connected),t.$store.commit("changeConnected",e.connected)}))},closeBluetoothAdapter:function(){e.closeBluetoothAdapter({success:function(e){console.log("蓝牙模块关闭成功")}})},closeBLEConnection:function(){var t=this;e.closeBLEConnection({deviceId:t.deviceId,success:function(e){console.log("断开蓝牙连接成功"),t.$store.commit("changeConnected",!1)}})}}};t.default=a}).call(this,i("df3c")["default"])},"22b8":function(e,t,i){},"482d":function(e,t,i){"use strict";i.d(t,"b",(function(){return n})),i.d(t,"c",(function(){return c})),i.d(t,"a",(function(){}));var n=function(){var e=this.$createElement;this._self._c},c=[]},d72e:function(e,t,i){"use strict";i.r(t);var n=i("093c"),c=i.n(n);for(var o in n)["default"].indexOf(o)<0&&function(e){i.d(t,e,(function(){return n[e]}))}(o);t["default"]=c.a},ee99:function(e,t,i){"use strict";var n=i("22b8"),c=i.n(n);c.a},f24f:function(e,t,i){"use strict";(function(e,t){var n=i("47a9");i("30b7");n(i("3240"));var c=n(i("ff87"));e.__webpack_require_UNI_MP_PLUGIN__=i,t(c.default)}).call(this,i("3223")["default"],i("df3c")["createPage"])},ff87:function(e,t,i){"use strict";i.r(t);var n=i("482d"),c=i("d72e");for(var o in c)["default"].indexOf(o)<0&&function(e){i.d(t,e,(function(){return c[e]}))}(o);i("ee99");var s=i("828b"),r=Object(s["a"])(c["default"],n["b"],n["c"],!1,null,"4b742bda",null,!1,n["a"],void 0);t["default"]=r.exports}},[["f24f","common/runtime","common/vendor"]]]);