adultDeviceApp/unpackage/dist/build/mp-weixin/pages/index/active.js

1 line
7.8 KiB
JavaScript

(global["webpackJsonp"]=global["webpackJsonp"]||[]).push([["pages/index/active"],{"1e6c":function(e,t,o){"use strict";o.r(t);var n=o("5f0a"),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},"1f47":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=[]},"47ad":function(e,t,o){"use strict";o.r(t);var n=o("1f47"),a=o("1e6c");for(var i in a)["default"].indexOf(i)<0&&function(e){o.d(t,e,(function(){return a[e]}))}(i);o("bf85");var r=o("828b"),c=Object(r["a"])(a["default"],n["b"],n["c"],!1,null,"371aa73a",null,!1,n["a"],void 0);t["default"]=c.exports},"5a69":function(e,t,o){},"5dbe":function(e,t,o){"use strict";(function(e,t){var n=o("47a9");o("6846");n(o("3240"));var a=n(o("47ad"));e.__webpack_require_UNI_MP_PLUGIN__=o,t(a.default)}).call(this,o("3223")["default"],o("df3c")["createPage"])},"5f0a":function(e,t,o){"use strict";(function(e,n){var a=o("47a9");Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var i,r=a(o("7eb4")),c=a(o("ee10")),s=a(o("7ca3")),d=o("8f59");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("fbff"))}.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,c.default)(r.default.mark((function n(){var a;return r.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)}}):e.redirectTo({url:"/pageTwo/login/login?url=active&code="+t.code})},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 r=e.advertisData.slice(3,9);e.mac=new Uint8Array(r);var c=Array.from(e.mac);return e.macAddr=t.$tools.ab2hex(c,":").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.toLowerCase().indexOf("ailink")||e.localName&&-1!=e.localName.toLowerCase().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 f=e.advertisData.slice(-6);e.mac=new Uint8Array(f);var v=Array.from(e.mac);return e.macAddr=t.$tools.ab2hex(v,":").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("df3c")["default"],o("3223")["default"])},bf85:function(e,t,o){"use strict";var n=o("5a69"),a=o.n(n);a.a}},[["5dbe","common/runtime","common/vendor"]]]);