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

1 line
6.2 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"],{2291:function(e,t,o){"use strict";o.r(t);var n=o("719c"),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},"28ee":function(e,t,o){},4695: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=[]},"4a13":function(e,t,o){"use strict";var n=o("28ee"),c=o.n(n);c.a},"6ff8":function(e,t,o){"use strict";o.r(t);var n=o("4695"),c=o("2291");for(var i in c)"default"!==i&&function(e){o.d(t,e,(function(){return c[e]}))}(i);o("4a13");var r,s=o("f0c5"),a=Object(s["a"])(c["default"],n["b"],n["c"],!1,null,"784a4d14",null,!1,n["a"],r);t["default"]=a.exports},"719c":function(e,t,o){"use strict";(function(e){Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var n,c=o("26cb");function i(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 r(e){for(var t=1;t<arguments.length;t++){var o=null!=arguments[t]?arguments[t]:{};t%2?i(Object(o),!0).forEach((function(t){s(e,t,o[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(o)):i(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 a=function(){o.e("components/userLogin").then(function(){return resolve(o("b06c"))}.bind(null,o)).catch(o.oe)},d={data:function(){return{token:"",macAddr:"",code:"",deviceId:"",popup:!1,devices:[]}},components:{userLogin:a},computed:r({},(0,c.mapState)(["user","isBluetoothTyle"])),onLoad:function(t){var o=this;console.log("设备code码",t),t&&(o.code=t.code),o.token=e.getStorageSync("token"),o.login(),e.onBluetoothAdapterStateChange((function(e){o.$store.commit("changeBluetooth",e.available)}))},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.commit("changeUserLogin",!0);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)})).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.advertisServiceUUIDs[0].indexOf("F0A0")){var r=t.devices,s=t.$tools.inArray(r,"deviceId",e.deviceId),a=e.advertisData.slice(0,8);e.mac=new Uint8Array(a);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===s?t.devices.push(e):t.devices[s]=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=d}).call(this,o("543d")["default"])},e60c:function(e,t,o){"use strict";(function(e){o("0d2f");n(o("66fd"));var t=n(o("6ff8"));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"])}},[["e60c","common/runtime","common/vendor"]]]);