1 line
6.9 KiB
JavaScript
1 line
6.9 KiB
JavaScript
(global["webpackJsonp"]=global["webpackJsonp"]||[]).push([["BLEPages/child/B03B"],{"0304":function(e,t,o){"use strict";(function(e){var i=o("47a9");Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var n,c=i(o("7ca3")),s=o("8f59");function a(e,t){var o=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);t&&(i=i.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),o.push.apply(o,i)}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=0,l=0,d={data:function(){return{text:"",weight:"",unit:"kg",height:"",childWeight:"",isChild:!1,status:-1,imp:0,macAddr:"",deviceId:"",serviceId:"",Unload:!1,stopblue:!0,isHeight:!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(n),this.closeBLEConnection(),this.closeBluetoothAdapter(),console.log("测量页返回1"))},onLoad:function(t){var o=this;o.text="",o.height=o.info.height,t&&t.deviceId&&(o.deviceId=t.deviceId,o.openBluetoothAdapter()),e.setNavigationBarColor({frontColor:"#ffffff",backgroundColor:this.appTheme}),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)},stopblue:function(){this.stopblue||(this.isHeight=!0)}},methods:{openBluetoothAdapter:function(){var t=this;t.text="",u=0,l=0,t.childWeight="",t.isChild=!1,t.stopblue=!0,t.isHeight=!1,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("请确定设备是开机状态、手机蓝牙权限已打开!")}})},onBLEConnectionStateChange:function(){var t=this;e.onBLEConnectionStateChange((function(e){console.log("监听蓝牙连接状态",e.connected),e.connected||(clearTimeout(n),t.Unload=!0,t.text="",u=0,l=0,t.childWeight="",t.isChild=!1,t.stopblue=!0,t.isHeight=!1,t.isConnection=2,t.stopBluetoothDevicesDiscovery(),t.closeBLEConnection(),t.closeBluetoothAdapter()),t.$store.commit("changeConnected",e.connected)}))},stopBluetoothDevicesDiscovery:function(){e.stopBluetoothDevicesDiscovery({success:function(e){console.log("停止搜索蓝牙设备",e)}})},onBluetoothDeviceFound:function(){var t=this;function o(e,t){return(Array(t).join(0)+e).slice(-t)}e.onBluetoothDeviceFound((function(e){e.devices.forEach((function(e){if(e.advertisData=e.advertisData?e.advertisData:"",!e.name&&!e.localName){var i=t.$tools.ab2hex(e.advertisData,""),c=i.substring(12,16);if(-1!==i.indexOf("c0")&&"0a11"==c){clearTimeout(n);var s=e.advertisData.slice(-6);e.mac=new Uint8Array(s);var a=Array.from(e.mac);if(e.macAddr=t.$tools.ab2hex(a,":").toUpperCase(),-1!==e.deviceId.indexOf(t.deviceId)||-1!==e.macAddr.indexOf(t.deviceId)){t.isConnection=1;var r=parseInt(i.substring(16,18),16).toString(2),d=parseInt(i.substring(4,8),16),h=o(r,8).substring(7,8),f=o(r,8).substring(5,7),v=o(r,8).substring(3,5);t.status=o(r,8).substring(2,3);var g="kg";return console.log("value",t.status,d),"10"==v&&(t.unit="lb",g="lb"),"01"==v&&(t.unit="jin",g="斤"),"00"==f&&(d=parseInt(i.substring(4,8),16)/10),"10"==f&&(d="10"==v?parseInt(i.substring(4,8),16)/10:parseInt(i.substring(4,8),16)/100),0==h&&(0==u?t.text="您的实时体重是:"+d+g:(l++,t.childWeight="宝宝的实时体重是:"+d+g),console.log("实时realTime",u)),void(1==t.status?1==h&&(u++,0==l?(t.text="您的稳定体重是:"+d+g,t.isChild=!0):(t.childWeight="宝宝的稳定体重是:"+d+g,t.macAddr=e.macAddr,t.deviceId=e.deviceId,t.weight=d,t.stopblue=!1,t.stopBluetoothDevicesDiscovery()),console.log("稳定realTime",u,l)):1==h&&(t.text="您的稳定体重是:"+d+g,t.macAddr=e.macAddr,t.deviceId=e.deviceId,t.weight=d,t.stopblue=!1,t.stopBluetoothDevicesDiscovery(),console.log("测量完成",t.weight,t.unit)))}return}}}))})),t.handleMyTime()},handleMyTime:function(){var e=this;n=setTimeout((function(){e.macAddr||(clearTimeout(n),e.Unload=!0,e.isConnection=2,e.startBluetoothDeviceDiscovery(),e.closeBLEConnection(),e.closeBluetoothAdapter())}),3e4)},handleGetMeasure:function(){var t=this;t.$model.getmeasurefunit({weight:t.weight+t.unit,imp:0,ecode:t.macAddr,height:t.height,familyid:t.info.familyid}).then((function(o){t.isHeight=!1,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.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(t){this.Unload=!0,this.isHeight=!1,clearTimeout(n),this.stopBluetoothDevicesDiscovery(),this.closeBLEConnection(),this.closeBluetoothAdapter(),1==t&&e.switchTab({url:"/pages/index/index"})},closeBluetoothAdapter:function(){e.closeBluetoothAdapter({success:function(e){console.log("蓝牙模块关闭成功")}})},closeBLEConnection:function(){e.closeBLEConnection({deviceId:this.deviceId,success:function(e){console.log("断开蓝牙连接成功")}})}}};t.default=d}).call(this,o("df3c")["default"])},2477:function(e,t,o){"use strict";o.r(t);var i=o("9171"),n=o("6540");for(var c in n)["default"].indexOf(c)<0&&function(e){o.d(t,e,(function(){return n[e]}))}(c);o("94bd");var s=o("828b"),a=Object(s["a"])(n["default"],i["b"],i["c"],!1,null,"49658833",null,!1,i["a"],void 0);t["default"]=a.exports},"325c":function(e,t,o){},6540:function(e,t,o){"use strict";o.r(t);var i=o("0304"),n=o.n(i);for(var c in i)["default"].indexOf(c)<0&&function(e){o.d(t,e,(function(){return i[e]}))}(c);t["default"]=n.a},9171:function(e,t,o){"use strict";o.d(t,"b",(function(){return i})),o.d(t,"c",(function(){return n})),o.d(t,"a",(function(){}));var i=function(){var e=this.$createElement;this._self._c},n=[]},"94bd":function(e,t,o){"use strict";var i=o("325c"),n=o.n(i);n.a},fd4b:function(e,t,o){"use strict";(function(e,t){var i=o("47a9");o("6846");i(o("3240"));var n=i(o("2477"));e.__webpack_require_UNI_MP_PLUGIN__=o,t(n.default)}).call(this,o("3223")["default"],o("df3c")["createPage"])}},[["fd4b","common/runtime","common/vendor"]]]); |