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

1 line
6.9 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

(global["webpackJsonp"]=global["webpackJsonp"]||[]).push([["pages/index/active"],{"5bbc":function(e,t,o){"use strict";o.r(t);var n=o("bf9c"),c=o("d86c");for(var i in c)"default"!==i&&function(e){o.d(t,e,(function(){return c[e]}))}(i);o("be95");var r,a=o("f0c5"),s=Object(a["a"])(c["default"],n["b"],n["c"],!1,null,"fd4c6fd2",null,!1,n["a"],r);t["default"]=s.exports},abb6:function(e,t,o){},b15c:function(e,t,o){"use strict";(function(e){Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var n,c=r(o("a34a")),i=o("26cb");function r(e){return e&&e.__esModule?e:{default:e}}function a(e,t,o,n,c,i,r){try{var a=e[i](r),s=a.value}catch(d){return void o(d)}a.done?t(s):Promise.resolve(s).then(n,c)}function s(e){return function(){var t=this,o=arguments;return new Promise((function(n,c){var i=e.apply(t,o);function r(e){a(i,n,c,r,s,"next",e)}function s(e){a(i,n,c,r,s,"throw",e)}r(void 0)}))}}function d(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 u(e){for(var t=1;t<arguments.length;t++){var o=null!=arguments[t]?arguments[t]:{};t%2?d(Object(o),!0).forEach((function(t){l(e,t,o[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(o)):d(Object(o)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(o,t))}))}return e}function l(e,t,o){return t in e?Object.defineProperty(e,t,{value:o,enumerable:!0,configurable:!0,writable:!0}):e[t]=o,e}var f=function(){o.e("components/userLogin").then(function(){return resolve(o("d753"))}.bind(null,o)).catch(o.oe)},v={data:function(){return{token:"",macAddr:"",code:"",deviceId:"",popup:!1,devices:[]}},components:{userLogin:f},computed:u({},(0,i.mapState)(["user","isBluetoothTyle","appTheme"])),onLoad:function(t){var o=this;return s(c.default.mark((function n(){var i;return c.default.wrap((function(n){while(1)switch(n.prev=n.next){case 0:return i=o,e.setNavigationBarColor({frontColor:"#ffffff",backgroundColor:o.appTheme}),console.log("设备code码",t),t&&(i.code=t.code),i.token=e.getStorageSync("token"),e.onBluetoothAdapterStateChange((function(e){i.$store.commit("changeBluetooth",e.available)})),n.next=8,i.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){if(2==o.code)return 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),void 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 wx.hideLoading(),console.log("openBluetoothAdapter失败",e),t.$tools.getBluetoothAdapter(e)}}):t.$store.commit("changeUserLogin",!0)},startBluetoothDeviceDiscovery:function(){var t=this;wx.showLoading({title:"设备搜索中"}),e.startBluetoothDevicesDiscovery({allowDuplicatesKey:!0,success:function(e){t.onBluetoothDeviceFound()},fail:function(e){wx.hideLoading(),console.log("startBluetoothDeviceDiscovery失败",e)}})},onBluetoothDeviceFound:function(){var t=this;e.onBluetoothDeviceFound((function(e){e.devices.forEach((function(e){if(e.name||e.localName){if(-1!=e.name.indexOf("AiLink_")){var o=t.devices,n=t.$tools.inArray(o,"deviceId",e.deviceId),c=e.advertisData.slice(-6);e.mac=new Uint8Array(c);var i=Array.from(e.mac);return i.reverse(),e.macAddr=t.$tools.ab2hex(i,":").toUpperCase(),t.deviceId=e.deviceId,t.macAddr=e.macAddr,-1===n?t.devices.push(e):t.devices[n]=e,void(t.popup=!0)}if(-1!==e.name.indexOf("ELK")&&-1!==e.advertisServiceUUIDs[0].indexOf("F0A0")){var r=t.devices,a=t.$tools.inArray(r,"deviceId",e.deviceId),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(),t.deviceId=e.deviceId,t.macAddr=e.macAddr,console.log("device1",e.macAddr,t.deviceId),-1===a?t.devices.push(e):t.devices[a]=e,void(t.popup=!0)}}}))})),t.handleMyTime()},handleMyTime:function(){var t=this;n=setTimeout((function(){t.devices.length?(clearTimeout(n),t.stopBluetoothDevicesDiscovery()):(clearTimeout(n),wx.hideLoading(),t.stopBluetoothDevicesDiscovery(),e.showModal({title:"提示",content:"请确定蓝牙和手机位置信息已打开请确定设备已开机ios系统需打开设置——>应用——>微信里的蓝牙权限!是否继续?",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){var t=this;t.stopBluetoothDevicesDiscovery(),t.macAddr=e.macAddr,t.getCode()},getCode:function(){var t=this;clearTimeout(n),wx.hideLoading(),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?t="+t.devtype})}),500)}))},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=v}).call(this,o("543d")["default"])},bdca:function(e,t,o){"use strict";(function(e){o("e568");n(o("66fd"));var t=n(o("5bbc"));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"])},be95:function(e,t,o){"use strict";var n=o("abb6"),c=o.n(n);c.a},bf9c:function(e,t,o){"use strict";var n;o.d(t,"b",(function(){return c})),o.d(t,"c",(function(){return i})),o.d(t,"a",(function(){return n}));var c=function(){var e=this,t=e.$createElement;e._self._c},i=[]},d86c:function(e,t,o){"use strict";o.r(t);var n=o("b15c"),c=o.n(n);for(var i in n)"default"!==i&&function(e){o.d(t,e,(function(){return n[e]}))}(i);t["default"]=c.a}},[["bdca","common/runtime","common/vendor"]]]);