1 line
6.3 KiB
JavaScript
1 line
6.3 KiB
JavaScript
(global["webpackJsonp"]=global["webpackJsonp"]||[]).push([["pageTwo/devices/G02"],{"0504":function(e,t,i){"use strict";i.d(t,"b",(function(){return n})),i.d(t,"c",(function(){return o})),i.d(t,"a",(function(){}));var n=function(){var e=this.$createElement;this._self._c},o=[]},"05db":function(e,t,i){},"18e5":function(e,t,i){"use strict";(function(e){var n=i("47a9");Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var o=n(i("7ca3")),c=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,o.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:"",height2:"",deviceId:"",macAddr:"",write:"",notify:"",unit:"cm",Unload:!1,isHeight:!1,isConnection:0,isdevice:!1,textLink:""}},computed:r(r({},(0,c.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 o=t[n];if(-1!=o.uuid.indexOf("FFF0")){i.serviceId=o.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 o=i.characteristics[n];-1!=o.uuid.indexOf("0000FFF1")?t.notify=o.uuid:-1!=o.uuid.indexOf("0000FFF2")&&(t.write=o.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),o=parseInt(i.substring(10,12)),c=parseInt(i.substring(12,14));if("1"==c&&(n/=10),"2"==c&&(n/=100),"0"==o&&(t.unit="cm"),"1"==o&&(t.unit="inch"),"2"==o&&(t.unit="ft"),Number(n)<20)t.text="操作错误,请重新测量";else{if("2"==o){var s=n/12,r=12*Number(s-Math.floor(s));t.height2=n,t.height=Math.floor(s)+"'"+r.toFixed(1)}else t.height2=n,t.height=n;t.text="您的身高是:"+t.height+t.unit,t.isHeight=!0}console.log("G02",i,o,n,t.height,t.height2)}))},fail:function(e){console.log("测量失败",e.value)}})},handleGetMeasure:function(){var t=this,i=0;t.weight?(i="ft"==t.unit?Number(2.54*t.height2).toFixed(2):t.height2,console.log("提交身高",i),t.$model.getmeasurefunit({adc:0,weight:t.weight,height:i,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)}))):t.$tools.msg("请输入体重")},handleHeight:function(){this.height="",this.text="",this.isHeight=!1},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"])},7750:function(e,t,i){"use strict";i.r(t);var n=i("0504"),o=i("95a9");for(var c in o)["default"].indexOf(c)<0&&function(e){i.d(t,e,(function(){return o[e]}))}(c);i("aaf4");var s=i("828b"),r=Object(s["a"])(o["default"],n["b"],n["c"],!1,null,"795603ae",null,!1,n["a"],void 0);t["default"]=r.exports},"95a9":function(e,t,i){"use strict";i.r(t);var n=i("18e5"),o=i.n(n);for(var c in n)["default"].indexOf(c)<0&&function(e){i.d(t,e,(function(){return n[e]}))}(c);t["default"]=o.a},aaf4:function(e,t,i){"use strict";var n=i("05db"),o=i.n(n);o.a},b8b2:function(e,t,i){"use strict";(function(e,t){var n=i("47a9");i("bad8");n(i("3240"));var o=n(i("7750"));e.__webpack_require_UNI_MP_PLUGIN__=i,t(o.default)}).call(this,i("3223")["default"],i("df3c")["createPage"])}},[["b8b2","common/runtime","common/vendor"]]]); |