adultDeviceApp/unpackage/dist/build/mp-weixin/BLEPages/child/PCL10.js

1 line
5.9 KiB
JavaScript

(global["webpackJsonp"]=global["webpackJsonp"]||[]).push([["BLEPages/child/PCL10"],{"34e3":function(e,t,o){"use strict";o.d(t,"b",(function(){return n})),o.d(t,"c",(function(){return i})),o.d(t,"a",(function(){}));var n=function(){var e=this.$createElement;this._self._c},i=[]},"3b38":function(e,t,o){"use strict";(function(e,t){var n=o("4ea4");o("6808");n(o("66fd"));var i=n(o("cd5e"));e.__webpack_require_UNI_MP_PLUGIN__=o,t(i.default)}).call(this,o("bc2e")["default"],o("543d")["createPage"])},"43b7":function(e,t,o){},4761:function(e,t,o){"use strict";var n=o("43b7"),i=o.n(n);i.a},c115:function(e,t,o){"use strict";(function(e){var n=o("4ea4");Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var i,c=n(o("9523")),s=o("26cb");function a(e,t){var o=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),o.push.apply(o,n)}return o}function r(e){for(var t=1;t<arguments.length;t++){var o=null!=arguments[t]?arguments[t]:{};t%2?a(Object(o),!0).forEach((function(t){(0,c.default)(e,t,o[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(o)):a(Object(o)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(o,t))}))}return e}var u={data:function(){return{text:"",weight:"",height:"",imp:550,macAddr:"",deviceId:"",Unload:!1,isConnection:0}},computed:r(r({},(0,s.mapState)(["user","isConnected","isBluetoothTyle","appTheme"])),{},{info:function(){return this.user}}),onUnload:function(){this.Unload||(this.stopBluetoothDevicesDiscovery(),clearTimeout(i),this.closeBLEConnection(),this.closeBluetoothAdapter())},onLoad:function(t){var o=this;e.setNavigationBarColor({frontColor:"#ffffff",backgroundColor:o.appTheme}),o.text="",t&&t.deviceId&&(o.deviceId=t.deviceId,o.openBluetoothAdapter()),e.onBluetoothAdapterStateChange((function(e){o.$store.commit("changeBluetooth",e.available)}))},watch:{isConnected:function(){this.isConnected||(this.handleBack(),this.isConnection=2)},isBluetoothTyle:function(){this.isBluetoothTyle||(this.handleBack(),this.isConnection=2)}},methods:{openBluetoothAdapter:function(){var t=this;t.text="",e.openBluetoothAdapter({success:function(e){t.isConnection=0,t.startBluetoothDeviceDiscovery()},fail:function(e){t.isConnection=2,t.$tools.msg("请确定设备是开机状态、手机蓝牙权限已打开!")}})},startBluetoothDeviceDiscovery:function(){var t=this;e.startBluetoothDevicesDiscovery({allowDuplicatesKey:!0,success:function(e){t.isConnection=0,t.onBluetoothDeviceFound()},fail:function(e){t.isConnection=2,t.$tools.msg("请确定设备是开机状态、手机蓝牙权限已打开!")}})},stopBluetoothDevicesDiscovery:function(){e.stopBluetoothDevicesDiscovery({success:function(e){console.log("停止搜索蓝牙设备",e)}})},onBLEConnectionStateChange:function(){var t=this;e.onBLEConnectionStateChange((function(e){console.log("监听蓝牙连接状态",e.connected),e.connected||(clearTimeout(i),t.text="",t.Unload=!0,t.isConnection=2,t.stopBluetoothDevicesDiscovery(),t.closeBLEConnection(),t.closeBluetoothAdapter()),t.$store.commit("changeConnected",e.connected)}))},onBluetoothDeviceFound:function(){var t=this;e.onBluetoothDeviceFound((function(o){o.devices.forEach((function(o){if(o.advertisData=o.advertisData?o.advertisData:"",o.name||o.localName);else{var n=t.$tools.ab2hex(o.advertisData,""),i=n.substring(12,16);if(-1!==n.indexOf("c0")&&"0002"==i){t.isConnection=1;var c=o.advertisData.slice(-6);o.mac=new Uint8Array(c);var s=Array.from(o.mac);if(o.macAddr=t.$tools.ab2hex(s,":").toUpperCase(),-1!==o.deviceId.indexOf(t.deviceId)||-1!==o.macAddr.indexOf(t.deviceId)){var a=parseInt(n.substring(16,18),16).toString(2),r=parseInt(n.substring(4,8),16),u=a.substring(5,6),l=a.substring(3,5),d=a.substring(1,3),f="kg";"10"==d&&(f="lb"),"00"==l&&(r=parseInt(n.substring(4,8),16)/10),"10"==l&&(r="10"==d?parseInt(n.substring(4,8),16)/10:parseInt(n.substring(4,8),16)/100),t.text="您的体重是:"+r+f,"1"==u&&(t.macAddr=o.macAddr,t.deviceId=o.deviceId,t.weight=r+f,e.stopBluetoothDevicesDiscovery({success:function(e){return t.handleGetMeasure()}}),console.log("测量完成",t.weight))}return}}}))})),t.handleMyTime()},handleMyTime:function(){var e=this;i=setTimeout((function(){e.macAddr||(clearTimeout(i),e.Unload=!0,e.isConnection=2,e.startBluetoothDeviceDiscovery(),e.closeBLEConnection(),e.closeBluetoothAdapter())}),3e4)},handleGetMeasure:function(){var t=this;t.$model.getmeasurefunit({weight:t.weight,imp:t.imp,ecode:t.macAddr,height:t.info.height,familyid:t.info.familyid}).then((function(o){0==o.code?(t.$tools.msg("测量成功"),t.$store.dispatch("getUserInfo",{familyid:t.info.familyid}),t.$store.dispatch("getResult",{birthday:t.info.birthday,familyid:t.info.familyid,height:t.info.height,sex:t.info.sex})):(console.log("测量失败",o.message),t.$tools.msg(o.message)),t.Unload=!0,setTimeout((function(){t.closeBLEConnection(),t.closeBluetoothAdapter(),e.switchTab({url:"/pages/index/index"})}),200)}))},handleBack:function(){clearTimeout(i),this.Unload=!0,this.stopBluetoothDevicesDiscovery(),this.closeBLEConnection(),this.closeBluetoothAdapter()},closeBluetoothAdapter:function(){e.closeBluetoothAdapter({success:function(e){console.log("蓝牙模块关闭成功")}})},closeBLEConnection:function(){e.closeBLEConnection({deviceId:this.deviceId,success:function(e){console.log("断开蓝牙连接成功")}})}}};t.default=u}).call(this,o("543d")["default"])},cd5e:function(e,t,o){"use strict";o.r(t);var n=o("34e3"),i=o("da91");for(var c in i)["default"].indexOf(c)<0&&function(e){o.d(t,e,(function(){return i[e]}))}(c);o("4761");var s=o("f0c5"),a=Object(s["a"])(i["default"],n["b"],n["c"],!1,null,"2fde5ade",null,!1,n["a"],void 0);t["default"]=a.exports},da91:function(e,t,o){"use strict";o.r(t);var n=o("c115"),i=o.n(n);for(var c in n)["default"].indexOf(c)<0&&function(e){o.d(t,e,(function(){return n[e]}))}(c);t["default"]=i.a}},[["3b38","common/runtime","common/vendor"]]]);