1 line
8.6 KiB
JavaScript
1 line
8.6 KiB
JavaScript
(global["webpackJsonp"]=global["webpackJsonp"]||[]).push([["pageTwo/devices/PCT01"],{"0514":function(t,e,n){"use strict";(function(t){var o=n("47a9");Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0;var i=o(n("7ca3")),a=n("8f59");function s(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(t);e&&(o=o.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),n.push.apply(n,o)}return n}var c=null,r={data:function(){return{bpm:0,isend:!1,weight:0,Ycount:0,time_m:"",time_s:"",time:0,kcal:0,Bcount:0,continuous:0,info:{},isToggle:!1,isEnd:!1,iswrapper:!1,isStart:!1}},computed:function(t){for(var e=1;e<arguments.length;e++){var n=null!=arguments[e]?arguments[e]:{};e%2?s(Object(n),!0).forEach((function(e){(0,i.default)(t,e,n[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):s(Object(n)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e))}))}return t}({},(0,a.mapState)(["isConnected","isBluetoothTyle"])),onLoad:function(e){var n=this;if(c=t.createInnerAudioContext(),e&&e.info){var o=e.info;n.info=JSON.parse(o),n.notifyBLECharacteristicValue(),setTimeout((function(){n.handleStart("开始")}),900),setTimeout((function(){n.handleStart("连续")}),1200)}n.handleAudioStart(),n.$Bluetooth.onBLEConnectionStateChange(),t.onBluetoothAdapterStateChange((function(t){n.$store.commit("changeBluetooth",t.available)}))},onUnload:function(){c&&c.destroy(),this.handleEnd(),console.log("PCT01返回onUnload")},watch:{isConnected:function(){var e=this;e.isConnected||(t.showModal({title:"连接已断开",content:"训练过程中已与设备连接中断,请重新连接设备再开始训练",showCancel:!1,success:function(t){t.confirm&&e.handleTarget()}}),console.log("蓝牙是否连接",e.isConnected))},isBluetoothTyle:function(){this.isBluetoothTyle||console.log("蓝牙是否打开",this.isBluetoothTyle)},isStart:function(){this.isStart&&this.handleAudio()},isToggle:function(){var e=this;e.isToggle&&t.showModal({title:"友情提示",content:"训练过程中请勿切换训练,返回训练",showCancel:!1,success:function(t){t.confirm&&(setTimeout((function(){e.handleStart("结束")}),400),setTimeout((function(){e.handleTarget()}),600))}})},isEnd:function(){var t=this;t.isEnd&&(setTimeout((function(){t.handleStart("停止")}),200),setTimeout((function(){t.handleGetMeasure()}),400))},weight:function(){var t=this;if(1==t.info.active&&t.$video.video.forEach((function(e){Number(e.name)==t.weight&&(c.autoplay=!0,c.loop=!1,c.src=e.video,c.play(),setTimeout((function(){c.stop(),t.handleAudio()}),3e3))})),2==t.info.active){var e=60*t.time_m+t.time_s;t.$video.video.forEach((function(n){Number(n.name)==t.weight&&Number(e)>10&&(c.autoplay=!0,c.loop=!1,c.src=n.video,c.play(),setTimeout((function(){c.stop(),t.handleAudio()}),3e3))})),"00"==t.time_m&&"10"==t.time_s&&(c.autoplay=!0,c.loop=!1,c.src="/static/time.mp3",c.play(),setTimeout((function(){c.stop(),t.handleAudio()}),3e3))}3==t.info.active&&(t.$video.video.forEach((function(e){Number(e.name)==Number(t.Ycount)-Number(t.weight)&&0!=Number(t.weight)&&(c.autoplay=!0,c.loop=!1,c.src=e.video,c.play(),setTimeout((function(){c.stop(),t.handleAudio()}),3e3))})),10==Number(t.weight)&&(c.autoplay=!0,c.loop=!1,c.src="/static/number.mp3",c.play(),setTimeout((function(){c.stop(),t.handleAudio()}),3e3)))}},methods:{handleAudioStart:function(){var t=this;c.autoplay=!0,c.loop=!1,c.src="/static/Start.mp3",c.play(),setTimeout((function(){c.stop(),t.handleAudio()}),5e3)},handleAudio:function(){c.autoplay=!0,c.loop=!0,c.src="/static/flight.mp3",c.play()},notifyBLECharacteristicValue:function(){var e=this;t.notifyBLECharacteristicValueChange({state:!0,deviceId:e.info.deviceId,serviceId:e.info.serviceId,characteristicId:e.info.notify,success:function(n){t.onBLECharacteristicValueChange((function(t){var n=e.$tools.ab2hex(t.value,""),o=parseInt(n.substring(8,12),16),i=parseInt(n.substring(12,16),16),a=parseInt(n.substring(16,20),16),s=parseInt(n.substring(20,24),16),c=parseInt(n.substring(30,32),16),r=parseInt(n.substring(32,34),16),u=parseInt(n.substring(34,38),16),l=null,f=null;if(0==c||4==c){if(e.weight=o,e.Ycount=i,e.time=a,e.kcal=u/10,2!=e.info.active&&0!=o&&(l=Math.floor(a%3600/60),f=a%60,e.time_m=l>9?l:"0"+l,e.time_s=f>9?f:"0"+f),2==e.info.active){var d=Number(s)-Number(a);l=Math.floor(d%3600/60),f=d%60,e.time_m=l>9?l:"0"+l,e.time_s=f>9?f:"0"+f}e.Bcount=parseInt(n.substring(24,26),16),e.continuous=parseInt(n.substring(26,30),16),console.log("自由模式",o,u,a,e.time_m,e.time_s,r)}2!=c&&3!=c||e.isToggle||(setTimeout((function(){e.isToggle=!0,e.handleStart("停止")}),200),console.log("当前状态被切换")),4!=c||e.isEnd||(e.isEnd=!0,console.log("当前状态被结束"))}))},fail:function(t){console.log("测量失败",t.value)}})},SendData:function(e){var n=new Uint8Array(e.match(/[\da-f]{2}/gi).map((function(t){return parseInt(t,16)})));t.writeBLECharacteristicValue({deviceId:this.info.deviceId,serviceId:this.info.serviceId,characteristicId:this.info.write,value:n.buffer,success:function(t){console.log("下发指令成功",t.errMsg)},fail:function(t){console.log("下发指令失败",t)}})},onlongpress:function(){var e=this;t.vibrateLong({success:function(){console.log("短震动"),Number(e.time)<10?t.showModal({title:"友情提示",content:"本次跳绳时间低于10秒,记录将不会被保存?",confirmText:"继续",cancelText:"返回",success:function(n){n.cancel&&(e.isStart=!1,c.stop(),t.navigateBack({delta:1}))}}):(e.handleStart("停止"),setTimeout((function(){e.handleStart("结束")}),400),setTimeout((function(){e.handleGetMeasure()}),800))},fail:function(t){console.error("震动失败:",t)}})},handleGetMeasure:function(){var e=this;3==e.info.active&&0==e.weight&&0!=e.Ycount?(console.log("1",e.weight,e.Ycount),e.weight=e.Ycount):3==e.info.active&&0!=e.weight&&0!=e.Ycount&&(console.log("2",e.weight,e.Ycount),e.weight=Number(e.Ycount)-Number(e.weight)),2==e.info.active&&(e.time_m=Math.floor(e.time%3600/60),e.time_s=e.time%60),console.log("111111保存",e.weight,e.Ycount,e.time_m,e.time_s),e.$model.getskipResult({aud_id:t.getStorageSync("userid"),kcal:Math.floor(e.kcal),num:e.weight,time_m:Number(e.time_m),time_s:e.time_s,type:1==e.info.active?"free":2==e.info.active?"time":"num"}).then((function(n){console.log("保存",e.time,n),e.isStart=!1,c.stop(),0==n.code?(e.bpm=e.weight/(e.time/60),e.iswrapper=!0,e.info.isSuccessful=!0,e.$store.dispatch("getUserInfo",{aud_id:t.getStorageSync("userid")})):e.$tools.msg(n.msg)}))},handleStart:function(t){var e=null,n=null;"连续"==t&&(e=Number(173).toString(16),n="A5050300"+e.substr(e.length-2,2),console.log("连续连续",n)),"停止"==t&&(e=Number(178).toString(16),n="A5050305"+e.substr(e.length-2,2),console.log("停止连续",n)),"开始"==t&&(e=Number(175).toString(16),n="A5050500"+e.substr(e.length-2,2)),"结束"==t&&(e=Number(176).toString(16),n="A5050501"+e.substr(e.length-2,2),console.log("结束指令",n)),"继续"==t&&(e=Number(174).toString(16),n="A5050400"+e.substr(e.length-2,2),console.log("继续指令",n)),"暂停"==t&&(e=Number(175).toString(16),n="A5050401"+e.substr(e.length-2,2),console.log("暂停指令",n)),this.SendData(n)},handleTarget:function(){c.stop(),t.navigateBack({delta:1})},handleEnd:function(){var e=this;e.handleStart("停止"),setTimeout((function(){e.handleStart("结束")}),400),setTimeout((function(){t.$emit("updateData",JSON.stringify(e.info))}),600)}}};e.default=r}).call(this,n("df3c")["default"])},1307:function(t,e,n){"use strict";n.r(e);var o=n("a3db"),i=n("3b4a");for(var a in i)["default"].indexOf(a)<0&&function(t){n.d(e,t,(function(){return i[t]}))}(a);n("9975");var s=n("828b"),c=Object(s["a"])(i["default"],o["b"],o["c"],!1,null,"115fd8c8",null,!1,o["a"],void 0);e["default"]=c.exports},"3b4a":function(t,e,n){"use strict";n.r(e);var o=n("0514"),i=n.n(o);for(var a in o)["default"].indexOf(a)<0&&function(t){n.d(e,t,(function(){return o[t]}))}(a);e["default"]=i.a},"55e3":function(t,e,n){},9975:function(t,e,n){"use strict";var o=n("55e3"),i=n.n(o);i.a},"9cef":function(t,e,n){"use strict";(function(t,e){var o=n("47a9");n("30b7");o(n("3240"));var i=o(n("1307"));t.__webpack_require_UNI_MP_PLUGIN__=n,e(i.default)}).call(this,n("3223")["default"],n("df3c")["createPage"])},a3db:function(t,e,n){"use strict";n.d(e,"b",(function(){return o})),n.d(e,"c",(function(){return i})),n.d(e,"a",(function(){}));var o=function(){var t=this.$createElement,e=(this._self._c,Math.floor(this.kcal)),n=this.iswrapper?this.bpm.toFixed(1):null,o=this.iswrapper?Math.floor(this.kcal):null;this.$mp.data=Object.assign({},{$root:{g0:e,g1:n,g2:o}})},i=[]}},[["9cef","common/runtime","common/vendor"]]]); |