examTeamApp/unpackage/dist/build/mp-weixin/pages/skiping/skip.js

1 line
11 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/skiping/skip"],{"115c":function(e,t,i){"use strict";i.r(t);var n=i("ac7d"),o=i("6a7a");for(var c in o)["default"].indexOf(c)<0&&function(e){i.d(t,e,(function(){return o[e]}))}(c);i("c3fb");var s=i("828b"),r=Object(s["a"])(o["default"],n["b"],n["c"],!1,null,"eaae2774",null,!1,n["a"],void 0);t["default"]=r.exports},"46f7":function(e,t,i){"use strict";(function(e,t){var n=i("47a9");i("30b7");n(i("3240"));var o=n(i("115c"));e.__webpack_require_UNI_MP_PLUGIN__=i,t(o.default)}).call(this,i("3223")["default"],i("df3c")["createPage"])},"49a5":function(e,t,i){"use strict";(function(e){var n=i("47a9");Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var o,c=n(i("7ca3")),s=i("8f59");function r(e,t){var i=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),i.push.apply(i,n)}return i}function a(e){for(var t=1;t<arguments.length;t++){var i=null!=arguments[t]?arguments[t]:{};t%2?r(Object(i),!0).forEach((function(t){(0,c.default)(e,t,i[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(i)):r(Object(i)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(i,t))}))}return e}var u={data:function(){return{active:1,acd_id:6,weight:50,disabled:!1,isDevice:0,isConnection:!1,time_m:"",time_s:"",timeList:[],devicesList:[],timesTndex:[1,0],deviceId:"",serviceId:"",write:"",notify:"",islink:0,textLink:""}},components:{record:function(){i.e("element/manuallyAdd/record").then(function(){return resolve(i("e472"))}.bind(null,i)).catch(i.oe)}},computed:a(a({},(0,s.mapState)(["user","MeasureSkip","isConnected","isBluetoothTyle"])),{},{info:function(){return this.MeasureSkip}}),mounted:function(){this.timeList=this.$tools.gethms(),this.time_m=this.timeList[0][1].substring(0,2),this.time_s=this.timeList[1][0].substring(0,2)},onLoad:function(t){var i=this;t&&t.deviceId&&(i.deviceId=t.deviceId,setTimeout((function(){i.createBLEConnection()}),500)),t&&t.acd_id&&(i.$Bluetooth.stopBluetoothDevicesDiscovery(),setTimeout((function(){i.handleisSdevice()}),500)),i.$store.dispatch("getSkipResult",{aud_id:e.getStorageSync("userid")}),i.isConnection=i.isConnected,i.onBLEConnectionStateChange(),e.onBluetoothAdapterStateChange((function(e){i.$store.commit("changeBluetooth",e.available)}))},onPullDownRefresh:function(){setTimeout((function(){e.stopPullDownRefresh()}),1e3)},onShow:function(){var t=this;e.$on("updateData",(function(i){var n=JSON.parse(i);t.acd_id=n.acd_id,t.isDevice=n.device,t.active=n.active,t.deviceId=n.deviceId,t.serviceId=n.serviceId,t.write=n.write,t.notify=n.notify,t.islink=t.isConnected?1:-1,t.isConnection=t.isConnected,t.notifyBLECharacteristicValue(),n.isSuccessful&&t.$store.dispatch("getSkipResult",{aud_id:e.getStorageSync("userid")}),t.onBLEConnectionStateChange(),e.onBluetoothAdapterStateChange((function(e){t.$store.commit("changeBluetooth",e.available)})),console.log("监听到事件来自 updateData",n)}))},onUnload:function(){clearTimeout(o),this.islink=-1,this.isConnection=!1,this.closeBLEConnection(),this.closeBluetoothAdapter(),e.$off("updateData"),setTimeout((function(){e.switchTab({url:"/pages/home/home"})}),300),console.log("返回首页onUnload")},watch:{isConnected:function(){this.isConnected||(this.islink=-1,this.textLink="重新连接"),this.isConnection=this.isConnected,console.log("蓝牙是否连接",this.isConnected)},isBluetoothTyle:function(){this.isBluetoothTyle||(this.isConnection=!1,this.textLink="请打开手机蓝牙",this.islink=-1),console.log("蓝牙是否打开",this.isBluetoothTyle)}},methods:{handleisSdevice:function(){var t=this;t.isConnected||(t.devicesList=[],t.$Bluetooth.stopBluetoothDevicesDiscovery(),e.openBluetoothAdapter({success:function(e){t.islink=0,t.handleMyTime(),t.textLink="蓝牙搜索中",t.startBluetoothDeviceDiscovery(),t.$store.commit("changeBluetooth",!0),console.log("初始化蓝牙成功:"+e.errMsg)},fail:function(e){t.islink=-1,t.textLink=t.$tools.getBluetoothAdapter(e)}}))},startBluetoothDeviceDiscovery:function(){var t=this;e.startBluetoothDevicesDiscovery({allowDuplicatesKey:!0,interval:200,services:[],success:function(e){t.onBluetoothDeviceFound()},fail:function(e){}})},onBluetoothDeviceFound:function(){var t=this;e.onBluetoothDeviceFound((function(e){e.devices.forEach((function(e){if(e.name||e.localName)return-1!=e.name.indexOf("YPC")?(e.deviceId=e.deviceId,t.deviceId=e.deviceId,t.$Bluetooth.stopBluetoothDevicesDiscovery(),void t.handleDevice(e)):void 0}))})),t.handleMyTime()},handleDevice:function(e){var t=this.devicesList,i=this.$tools.inArray(t,"deviceId",e.deviceId);-1===i&&(this.devicesList.push(e),this.createBLEConnection())},createBLEConnection:function(){var t=this;e.createBLEConnection({deviceId:t.deviceId,success:function(e){t.textLink="蓝牙连接中",setTimeout((function(){t.islink=1,t.getBLEDeviceServices()}),1e3)},fail:function(e){t.textLink="重新连接",console.log("设备连接失败,请重新连接",e,t.deviceId)}})},getBLEDeviceServices:function(){var t=[],i=this;e.getBLEDeviceServices({deviceId:i.deviceId,success:function(e){console.log("获取设备的UUID成功",e),t=e.services;for(var n=0;n<t.length;n++){var o=t[n];if(-1!=o.uuid.indexOf("FFE0")){i.serviceId=o.uuid,i.isConnection=!0,i.textLink="连接成功",i.getBLEDeviceCharacteristics(),console.log("设备的FFE0的serviceId "+i.serviceId);break}}},fail:function(e){console.log("获取设备的UUID失败:",e),i.islink=-1,i.textLink="重新连接",clearTimeout(o),i.isConnection=!1}})},getBLEDeviceCharacteristics:function(){var t=this;e.getBLEDeviceCharacteristics({deviceId:t.deviceId,serviceId:t.serviceId,success:function(i){console.log("服务的特征值成功",i);for(var n=0;n<i.characteristics.length;n++){var o=i.characteristics[n];-1!=o.uuid.indexOf("0000FF12")?t.write=o.uuid:-1!=o.uuid.indexOf("0000FFE4")&&(t.notify=o.uuid)}setTimeout((function(){var e=Number(224).toString(16),i="A50A01080808080808"+e.substr(e.length-2,2);t.SendData(i)}),300),setTimeout((function(){t.handleStart(4)}),600),e.notifyBLECharacteristicValueChange({deviceId:t.deviceId,serviceId:t.serviceId,characteristicId:t.notify,state:!0}),e.notifyBLECharacteristicValueChange({deviceId:t.deviceId,serviceId:t.serviceId,characteristicId:t.write,state:!0}),t.notifyBLECharacteristicValue()},fail:function(e){console.log("获取特征值失败:",JSON.stringify(e))}})},notifyBLECharacteristicValue:function(){var t=this;e.notifyBLECharacteristicValueChange({state:!0,deviceId:t.deviceId,serviceId:t.serviceId,characteristicId:t.notify,success:function(i){e.onBLECharacteristicValueChange((function(i){var n=t.$tools.ab2hex(i.value,"");if("5a05090169"==n){var o={active:t.active,deviceId:t.deviceId,serviceId:t.serviceId,notify:t.notify,write:t.write,acd_id:t.acd_id,isDevice:t.isDevice,isSuccessful:!1};setTimeout((function(){e.$off("updateData"),e.navigateTo({url:"/pageTwo/devices/PCT01?info="+JSON.stringify(o)})}),200)}console.log("value",n,t.active)}))}})},SendData:function(t){var i=new Uint8Array(t.match(/[\da-f]{2}/gi).map((function(e){return parseInt(e,16)})));console.log("xiafa",t),e.writeBLECharacteristicValue({deviceId:this.deviceId,serviceId:this.serviceId,characteristicId:this.write,value:i.buffer,success:function(e){console.log("下发指令成功",e.errMsg)},fail:function(e){console.log("下发指令失败",e)}})},handleStart:function(e){var t=null,i=null;if(this.isConnected){if(1==e&&(t=Number(182).toString(16),i="A5080900000000"+t.substr(t.length-2,2)),2==e){var n=60*Number(this.time_m)+Number(this.time_s);t=Number(182+n).toString(16),i="A508090000"+this.$tools.toHex(n,4)+t.substr(t.length-2,2)}if(3==e){var o=this.$tools.toHex(this.weight,4);t=Number(182+this.weight).toString(16),i="A50809"+o+"0000"+t.substr(t.length-2,2)}if(4==e){var c=2*Number(this.user.weight),s=parseInt(c).toString();t=Number(178+Number(s)).toString(16),i="A50508"+Number(s).toString(16)+t.substr(t.length-2,2)}this.SendData(i),this.$Bluetooth.stopBluetoothDevicesDiscovery()}else this.$tools.msg("请先连接设备!")},reload:function(){var t=this;this.$nextTick((function(){t.$store.dispatch("getSkipResult",{aud_id:e.getStorageSync("userid")})}))},bindTimeChange:function(e){var t=e.target.value[0],i=e.target.value[1];this.timesTndex=e.target.value;var n=60*Number(this.timeList[0][t].substring(0,2)),o=Number(this.timeList[1][i].substring(0,2));Number(n+o)<30?(this.time_m="00",this.time_s="30"):(this.time_m=this.timeList[0][t].substring(0,2),this.time_s=this.timeList[1][i].substring(0,2))},handleTimeEdit:function(e){var t=60*Number(this.time_m),i=Number(this.time_s),n=null,o=null;return Number(t+i)>=3570&&"加"==e?(this.time_m="59",void(this.time_s="59")):Number(t+i)<=30&&"减"==e?(this.time_m="00",void(this.time_s="30")):("减"==e&&(n=Math.floor(Number(t+i-30)%3600/60),o=Number(t+i-30)%60),"加"==e&&(n=Math.floor(Number(t+i+30)%3600/60),o=Number(t+i+30)%60),this.time_m=n>9?n:"0"+n,this.time_s=o>9?o:"0"+o,void(this.timesTndex=[Number(this.time_m),Number(this.time_s)]))},handleWeightEdit:function(e){"减"==e&&(this.weight=Number(this.weight)-50>50?Number(this.weight)-50:50),"加"==e&&(this.weight=Number(this.weight)+50)},handleMyTime:function(){var e=this;o=setTimeout((function(){e.devicesList.length||(e.islink=-1,e.textLink="重新搜索",e.$tools.showModal("没有查找到设备")),clearTimeout(o),e.$Bluetooth.stopBluetoothDevicesDiscovery()}),2e4)},onBLEConnectionStateChange:function(){var t=this;e.onBLEConnectionStateChange((function(e){console.log("监听蓝牙连接状态",e.connected),t.$store.commit("changeConnected",e.connected)}))},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.$store.commit("changeConnected",!1)}})},navTo:function(t){this.isConnected||(this.islink=-1,clearTimeout(o),this.$Bluetooth.closeBluetoothAdapter(),this.$Bluetooth.closeBLEConnection(this.deviceId),this.$Bluetooth.stopBluetoothDevicesDiscovery(),console.log("蓝牙没有连接")),e.navigateTo({url:t})}}};t.default=u}).call(this,i("df3c")["default"])},"6a7a":function(e,t,i){"use strict";i.r(t);var n=i("49a5"),o=i.n(n);for(var c in n)["default"].indexOf(c)<0&&function(e){i.d(t,e,(function(){return n[e]}))}(c);t["default"]=o.a},ac7d:function(e,t,i){"use strict";i.d(t,"b",(function(){return n})),i.d(t,"c",(function(){return o})),i.d(t,"a",(function(){}));var n=function(){var e=this,t=e.$createElement;e._self._c;e._isMounted||(e.e0=function(t){e.active=1},e.e1=function(t){e.active=3},e.e2=function(t){e.active=2},e.e3=function(t){e.disabled=!1},e.e4=function(t){e.disabled=!0},e.e5=function(t){return e.$store.commit("changeRecord",!0)})},o=[]},c3fb:function(e,t,i){"use strict";var n=i("c842"),o=i.n(n);o.a},c842:function(e,t,i){}},[["46f7","common/runtime","common/vendor"]]]);