1 line
7.8 KiB
JavaScript
1 line
7.8 KiB
JavaScript
(global["webpackJsonp"]=global["webpackJsonp"]||[]).push([["pages/index/active"],{"1c4e":function(e,t,o){"use strict";(function(e,n){var a=o("4ea4");Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var i,c=a(o("2eee")),r=a(o("c973")),s=a(o("9523")),d=o("26cb");function u(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}var l={data:function(){return{token:"",macAddr:"",code:"",deviceId:"",popup:!1,devices:[]}},components:{userLogin:function(){o.e("components/userLogin").then(function(){return resolve(o("59a3"))}.bind(null,o)).catch(o.oe)}},computed:function(e){for(var t=1;t<arguments.length;t++){var o=null!=arguments[t]?arguments[t]:{};t%2?u(Object(o),!0).forEach((function(t){(0,s.default)(e,t,o[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(o)):u(Object(o)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(o,t))}))}return e}({},(0,d.mapState)(["user","isBluetoothTyle","appTheme"])),onLoad:function(t){var o=this;return(0,r.default)(c.default.mark((function n(){var a;return c.default.wrap((function(n){while(1)switch(n.prev=n.next){case 0:return a=o,e.setNavigationBarColor({frontColor:"#ffffff",backgroundColor:o.appTheme}),console.log("设备code码",t),t&&(a.code=t.code),a.token=e.getStorageSync("token"),e.onBluetoothAdapterStateChange((function(e){a.$store.commit("changeBluetooth",e.available)})),n.next=8,a.login();case 8:case"end":return n.stop()}}),n)})))()},methods:{login:function(){var t=this;e.login({success:function(o){o.code&&(o.errMsg="login:ok")&&t.$model.onlogin({code:o.code}).then((function(o){2==o.code?(e.clearStorageSync(),e.removeStorageSync("token"),e.removeStorageSync("changeUser"),e.setStorageSync("tenantid",o.data.tenantid),e.setStorageSync("sessionid",o.data.sessionid),e.setStorageSync("iswxphone",o.data.iswxphone),t.$store.dispatch("getConfig",{tenantId:e.getStorageSync("tenantid")})):(e.setStorageSync("userid",o.data.userid),e.setStorageSync("sessionid",o.data.sessionid),e.setStorageSync("token",o.data.token),e.setStorageSync("iswxphone",o.data.iswxphone),e.setStorageSync("tenantid",o.data.tenantid),e.setStorageSync("refreshtoken",o.data.refreshtoken),t.$store.dispatch("getConfig",{tenantId:e.getStorageSync("tenantid")}))})).catch((function(e){}))}})},handleWeight:function(){var t=this;t.devices=[],t.token?e.openBluetoothAdapter({success:function(e){t.$store.commit("changeBluetooth",!0),t.startBluetoothDeviceDiscovery()},fail:function(e){return console.log("openBluetoothAdapter失败",e),t.$tools.getBluetoothAdapter(e)}}):t.$store.commit("changeUserLogin",!0)},startBluetoothDeviceDiscovery:function(){var t=this;n.showLoading({title:"设备搜索中"}),e.startBluetoothDevicesDiscovery({allowDuplicatesKey:!0,success:function(e){n.hideLoading(),t.onBluetoothDeviceFound()},fail:function(e){n.hideLoading(),console.log("startBluetoothDeviceDiscovery失败",e)}})},onBluetoothDeviceFound:function(){var t=this;n.showLoading({title:"设备搜索中"}),e.onBluetoothDeviceFound((function(e){e.devices.forEach((function(e){if(e.advertisData=e.advertisData?e.advertisData:"",e.advertisServiceUUIDs=e.advertisServiceUUIDs?e.advertisServiceUUIDs:"",e.name||e.localName){if(-1!==e.name.indexOf("FitTrack")||-1!==e.name.indexOf("SWAN")){clearTimeout(i);var o=e.advertisData.slice(2,8);e.mac=new Uint8Array(o);var a=Array.from(e.mac);return a.reverse(),e.macAddr=t.$tools.ab2hex(a,":").toUpperCase(),void t.handleDevice(e)}if(-1!==e.name.indexOf("WSD")){clearTimeout(i),n.hideLoading();var c=e.advertisData.slice(3,9);e.mac=new Uint8Array(c);var r=Array.from(e.mac);return e.macAddr=t.$tools.ab2hex(r,":").toUpperCase(),void t.handleDevice(e)}if(-1!==e.name.indexOf("EL")&&""!=e.advertisServiceUUIDs){clearTimeout(i),n.hideLoading();var s=e.advertisData.slice(0,8);e.mac=new Uint8Array(s);var d=Array.from(e.mac);return d.reverse(),e.macAddr=t.$tools.ab2hex(d,":").toUpperCase(),void t.handleDevice(e)}if(-1!==e.name.indexOf("AiLink_")||e.localName&&-1!=e.localName.indexOf("AiLink_")){clearTimeout(i),n.hideLoading();var u=e.advertisData.slice(-6);e.mac=new Uint8Array(u);var l=Array.from(e.mac);return l.reverse(),e.macAddr=t.$tools.ab2hex(l,":").toUpperCase(),void t.handleDevice(e)}if(-1!=e.name.indexOf("My")){clearTimeout(i),n.hideLoading();var v=e.advertisData.slice(-6);e.mac=new Uint8Array(v);var f=Array.from(e.mac);return e.macAddr=t.$tools.ab2hex(f,":").toUpperCase(),void t.handleDevice(e)}}else{var h=t.$tools.ab2hex(e.advertisData,""),m=h.substring(12,16);if(-1!==h.indexOf("c0")&&"0a11"==m){n.hideLoading(),e.name="PC-B";var g=e.advertisData.slice(-6);e.mac=new Uint8Array(g);var p=Array.from(e.mac);return e.macAddr=t.$tools.ab2hex(p,":").toUpperCase(),void t.handleDevice(e)}if(-1!==h.indexOf("c0")&&"0002"==m){n.hideLoading(),e.name="PCL-体脂秤";var y=e.advertisData.slice(-6);e.mac=new Uint8Array(y);var D=Array.from(e.mac);return e.macAddr=t.$tools.ab2hex(D,":").toUpperCase(),void t.handleDevice(e)}}}))})),t.handleMyTime()},handleDevice:function(e,t){var o=this.devices,n=this.$tools.inArray(o,"deviceId",e.deviceId);this.deviceId=e.deviceId,-1===n?this.devices.push(e):this.devices[n]=e,this.popup=!0},handleMyTime:function(){var t=this;i=setTimeout((function(){t.devices.length?(clearTimeout(i),t.stopBluetoothDevicesDiscovery()):(clearTimeout(i),n.hideLoading(),t.stopBluetoothDevicesDiscovery(),e.showModal({title:"提示",content:"请确定蓝牙已打开!是否继续?",cancelText:"取消",confirmText:"继续",success:function(e){e.confirm?t.startBluetoothDeviceDiscovery():t.$tools.msg("您已取消操作")}}))}),3e4)},stopBluetoothDevicesDiscovery:function(){e.stopBluetoothDevicesDiscovery({success:function(e){console.log("停止搜索蓝牙设备",e)}})},createBLEConnection:function(e){this.stopBluetoothDevicesDiscovery(),this.macAddr=e.macAddr,this.getCode()},getCode:function(){var t=this;clearTimeout(i),e.showModal({title:"提示",content:"是否激活该设备?",cancelText:"取消",confirmText:"确定",success:function(e){e.confirm?t.getActive():t.$tools.msg("您已取消操作")}})},getActive:function(){var t=this;t.$model.getdevactive({code:t.code,sn:t.macAddr}).then((function(o){t.$tools.msg(o.message),t.closeBluetoothAdapter(),t.closeBLEConnection(),t.devices=[],0==o.code&&setTimeout((function(){e.reLaunch({url:"/pages/index/index"})}),500)}))},closeBluetoothAdapter:function(){e.closeBluetoothAdapter({success:function(e){console.log("蓝牙模块关闭成功")}})},closeBLEConnection:function(){e.closeBLEConnection({deviceId:this.deviceId,success:function(e){console.log("断开蓝牙连接成功")}})}}};t.default=l}).call(this,o("543d")["default"],o("bc2e")["default"])},"2de5":function(e,t,o){"use strict";o.d(t,"b",(function(){return n})),o.d(t,"c",(function(){return a})),o.d(t,"a",(function(){}));var n=function(){var e=this.$createElement,t=(this._self._c,this.devices.length);this.$mp.data=Object.assign({},{$root:{g0:t}})},a=[]},3993:function(e,t,o){"use strict";(function(e,t){var n=o("4ea4");o("6808");n(o("66fd"));var a=n(o("ef46"));e.__webpack_require_UNI_MP_PLUGIN__=o,t(a.default)}).call(this,o("bc2e")["default"],o("543d")["createPage"])},5366:function(e,t,o){},"7aa5":function(e,t,o){"use strict";o.r(t);var n=o("1c4e"),a=o.n(n);for(var i in n)["default"].indexOf(i)<0&&function(e){o.d(t,e,(function(){return n[e]}))}(i);t["default"]=a.a},e164:function(e,t,o){"use strict";var n=o("5366"),a=o.n(n);a.a},ef46:function(e,t,o){"use strict";o.r(t);var n=o("2de5"),a=o("7aa5");for(var i in a)["default"].indexOf(i)<0&&function(e){o.d(t,e,(function(){return a[e]}))}(i);o("e164");var c=o("f0c5"),r=Object(c["a"])(a["default"],n["b"],n["c"],!1,null,"0cae84c0",null,!1,n["a"],void 0);t["default"]=r.exports}},[["3993","common/runtime","common/vendor"]]]); |