adultDeviceApp/unpackage/dist/build/mp-weixin/BLEPages/adult/PCL01.js

1 line
6.1 KiB
JavaScript

(global["webpackJsonp"]=global["webpackJsonp"]||[]).push([["BLEPages/adult/PCL01"],{"0620":function(e,t,o){"use strict";o.r(t);var n=o("25fd"),i=o("8c86");for(var c in i)"default"!==c&&function(e){o.d(t,e,(function(){return i[e]}))}(c);var a,s=o("f0c5"),r=Object(s["a"])(i["default"],n["b"],n["c"],!1,null,"28821ab9",null,!1,n["a"],a);t["default"]=r.exports},"25fd":function(e,t,o){"use strict";var n;o.d(t,"b",(function(){return i})),o.d(t,"c",(function(){return c})),o.d(t,"a",(function(){return n}));var i=function(){var e=this,t=e.$createElement;e._self._c},c=[]},"7d8c":function(e,t,o){"use strict";(function(e){Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var n,i=o("26cb");function c(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 a(e){for(var t=1;t<arguments.length;t++){var o=null!=arguments[t]?arguments[t]:{};t%2?c(Object(o),!0).forEach((function(t){s(e,t,o[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(o)):c(Object(o)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(o,t))}))}return e}function s(e,t,o){return t in e?Object.defineProperty(e,t,{value:o,enumerable:!0,configurable:!0,writable:!0}):e[t]=o,e}var r=requirePlugin("sdkPlugin").AiLink,l={data:function(){return{text:"",height:"",weight:"",imp:0,macAddr:"",deviceId:"",serviceId:"",Unload:!1,stopblue:!0,isConnection:0}},computed:a(a({},(0,i.mapState)(["user","isConnected","isBluetoothTyle"])),{},{info:function(){return this.user}}),onUnload:function(){var e=this;e.Unload||(e.stopBluetoothDevicesDiscovery(),clearTimeout(n),e.closeBLEConnection(),e.closeBluetoothAdapter(),console.log("测量页返回1"))},onLoad:function(t){var o=this;o.text="",t&&t.deviceId&&(o.deviceId=t.deviceId,console.log(0),o.openBluetoothAdapter()),e.onBluetoothAdapterStateChange((function(e){o.$store.commit("changeBluetooth",e.available)}))},watch:{isConnected:function(){var e=this;e.isConnected||(e.handleBack(),e.isConnection=2)},isBluetoothTyle:function(){var e=this;e.isBluetoothTyle||(e.handleBack(),e.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.navigateBack({delta:1}))}}):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.name||o.localName)&&-1!==o.advertisServiceUUIDs[0].indexOf("F0A0")){clearTimeout(n);t.$tools.ab2hex(o.advertisData);var i=r.parseBroadcastData(o.advertisData),c=r.analyzeBroadcastScaleData(i),a=c.text,s=c.data;if(console.log("analyzeData",i,c),1==i.status){var l="kg",u="kg";if("1"==s.weightUnit&&(l="斤",u="jin"),"4"==s.weightUnit&&(l="st:lb",u="st",s=1*s+5),"6"==s.weightUnit&&(l="lb",u="lb"),"1"==s.weightDecimal&&(s.weight=s.weight/10),"2"==s.weightDecimal&&(s.weight=s.weight/100),"3"==s.weightDecimal&&(s.weight=s.weight/1e3),t.text="您的体重是:"+s.weight+l,1==s.weightStatus||-1!=a.indexOf("阻抗测量失败")){var d=o.advertisData.slice(0,8);o.mac=new Uint8Array(d);var f=Array.from(o.mac);return f.reverse(),o.macAddr=t.$tools.ab2hex(f,":").toUpperCase(),t.macAddr=o.macAddr,t.deviceId=o.deviceId,t.weight=s.weight+u,t.imp=s.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(){var e=this;e.Unload=!0,clearTimeout(n),e.stopBluetoothDevicesDiscovery(),e.closeBLEConnection(),e.closeBluetoothAdapter()},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.default=l}).call(this,o("543d")["default"])},"8c86":function(e,t,o){"use strict";o.r(t);var n=o("7d8c"),i=o.n(n);for(var c in n)"default"!==c&&function(e){o.d(t,e,(function(){return n[e]}))}(c);t["default"]=i.a},dc10:function(e,t,o){"use strict";(function(e){o("0d2f");n(o("66fd"));var t=n(o("0620"));function n(e){return e&&e.__esModule?e:{default:e}}wx.__webpack_require_UNI_MP_PLUGIN__=o,e(t.default)}).call(this,o("543d")["createPage"])}},[["dc10","common/runtime","common/vendor"]]]);