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

1 line
6.3 KiB
JavaScript

(global["webpackJsonp"]=global["webpackJsonp"]||[]).push([["BLEPages/child/J02"],{2756:function(e,t,o){"use strict";o.r(t);var i=o("8125"),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},"346d":function(e,t,o){"use strict";o.r(t);var i=o("391f"),n=o("2756");for(var c in n)["default"].indexOf(c)<0&&function(e){o.d(t,e,(function(){return n[e]}))}(c);var s=o("f0c5"),a=Object(s["a"])(n["default"],i["b"],i["c"],!1,null,"7d3a8094",null,!1,i["a"],void 0);t["default"]=a.exports},"391f":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=[]},"5d4f":function(e,t,o){"use strict";(function(e,t){var i=o("4ea4");o("6808");i(o("66fd"));var n=i(o("346d"));e.__webpack_require_UNI_MP_PLUGIN__=o,t(n.default)}).call(this,o("bc2e")["default"],o("543d")["createPage"])},8125:function(e,t,o){"use strict";(function(e){var i=o("4ea4");Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var n,c=i(o("9523")),s=o("26cb");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 l=requirePlugin("sdkPlugin").AiLink,u={data:function(){return{text:"",height:"",weight:"",imp:0,macAddr:"",deviceId:"",serviceId:"",Unload:!1,stopblue:!0,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(),e.switchTab({url:"/pages/index/index"}),console.log("测量页返回1"))},onLoad:function(t){var o=this;e.setNavigationBarColor({frontColor:"#ffffff",backgroundColor:this.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)},stopblue:function(){var t=this;t.stopblue||(console.log("停止成功",t.weight,t.imp),0==t.imp?e.showModal({title:"提示",content:"体脂测量失败,是否保存本次测量结果?",cancelText:"放弃",confirmText:"保存",success:function(o){o.confirm?(t.imp=0,t.handleGetMeasure()):(t.Unload=!0,t.startBluetoothDeviceDiscovery(),t.closeBLEConnection(),t.closeBluetoothAdapter(),e.switchTab({url:"/pages/index/index"}))}}):t.handleGetMeasure())}},methods:{openBluetoothAdapter:function(){var t=this;t.text="",t.stopblue=!0,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,services:["F0A0"],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)}})},onBluetoothDeviceFound:function(){var t=this;t.isConnection=1,e.onBluetoothDeviceFound((function(o){o.devices.forEach((function(o){if(o.advertisData=o.advertisData?o.advertisData:"",o.advertisServiceUUIDs=o.advertisServiceUUIDs?o.advertisServiceUUIDs:"",(o.name||o.localName)&&-1!==o.name.indexOf("EL")&&""!=o.advertisServiceUUIDs){clearTimeout(n);var i=o.advertisData.slice(0,8);o.mac=new Uint8Array(i);var c=Array.from(o.mac);if(c.reverse(),o.macAddr=t.$tools.ab2hex(c,":").toUpperCase(),-1!=o.deviceId.indexOf(t.deviceId)||-1!=o.macAddr.indexOf(t.deviceId)){t.$tools.ab2hex(o.advertisData);var s=l.parseBroadcastData(o.advertisData),a=l.analyzeBroadcastScaleData(s),r=a.text,u=a.data;if(console.log("device",o,a,r,u),1==s.status){var d="kg",f="kg";if("1"==u.weightUnit&&(d="斤",f="jin"),"4"==u.weightUnit&&(d="st:lb",f="st",u=1*u+5),"6"==u.weightUnit&&(d="lb",f="lb"),"1"==u.weightDecimal&&(u.weight=u.weight/10),"2"==u.weightDecimal&&(u.weight=u.weight/100),"3"==u.weightDecimal&&(u.weight=u.weight/1e3),t.text="您的体重是:"+u.weight+d,-1!=r.indexOf("测量结束")||-1!=r.indexOf("阻抗测量失败"))return t.macAddr=o.macAddr,t.deviceId=o.deviceId,t.weight=u.weight+f,t.imp=u.adc,void e.stopBluetoothDevicesDiscovery({success:function(e){return t.stopblue=!1}})}}}}))})),t.handleMyTime()},handleMyTime:function(){var e=this;n=setTimeout((function(){e.macAddr||(clearTimeout(n),e.Unload=!0,e.isConnection=2,e.closeBLEConnection(),e.closeBluetoothAdapter())}),2e4)},handleGetMeasure:function(){var t=this;t.$model.getmeasure({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(){this.Unload=!0,clearTimeout(n),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"])}},[["5d4f","common/runtime","common/vendor"]]]);