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

1 line
6.0 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/G02"],{2175:function(e,t,i){"use strict";var n=i("fe54"),c=i.n(n);c.a},4385:function(e,t,i){"use strict";i.r(t);var n=i("af4c"),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},"473e":function(e,t,i){"use strict";(function(e,t){var n=i("47a9");i("30b7");n(i("3240"));var c=n(i("8a6f"));e.__webpack_require_UNI_MP_PLUGIN__=i,t(c.default)}).call(this,i("3223")["default"],i("df3c")["createPage"])},"7a7f":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=[]},"8a6f":function(e,t,i){"use strict";i.r(t);var n=i("7a7f"),c=i("4385");for(var o in c)["default"].indexOf(o)<0&&function(e){i.d(t,e,(function(){return c[e]}))}(o);i("2175");var s=i("828b"),r=Object(s["a"])(c["default"],n["b"],n["c"],!1,null,"f038e658",null,!1,n["a"],void 0);t["default"]=r.exports},af4c: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:"",weight:"",height:"",deviceId:"",macAddr:"",unit:"cm",Unload:!1,isHeight:!1,isConnection:0,isdevice:!1,textLink:""}},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.weight=i.userInfo.weight,i.deviceId=t.deviceId,i.createBLEConnection(),i.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("蓝牙已关闭,请重新打开蓝牙后再开始测量")}}},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,i.deviceId),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("设备的FFE0的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.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){e.onBLECharacteristicValueChange((function(e){var i=t.$tools.ab2hex(e.value,""),n=parseInt(i.substring(7,10),16),c=parseInt(i.substring(10,12)),o=parseInt(i.substring(12,14));"1"==c&&(t.unit="inch"),"2"==c&&(t.unit="ftin"),"1"==o&&(n/=10),"2"==o&&(n/=100),Number(n)<20?t.text="操作错误,请重新测量":(t.height=n,t.text="您的身高是:"+n+t.unit,t.isHeight=!0),console.log("G02",i,n)}))},fail:function(e){console.log("测量失败",e.value)}})},handleGetMeasure:function(){var t=this;t.weight?t.$model.getmeasurefunit({adc:0,weight:t.weight,height:t.height,aud_id:t.userInfo.id}).then((function(i){t.isHeight=!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()}),500)})):this.$tools.msg("请输入体重")},handleHeight:function(){this.isHeight=!1,this.height="",this.text=""},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"])},fe54:function(e,t,i){}},[["473e","common/runtime","common/vendor"]]]);