Przeglądaj źródła

测试环境调整

slambb 4 lat temu
rodzic
commit
fe73db6ca7

+ 3 - 1
common/config.js

@@ -4,7 +4,8 @@
 const endTime = "2021-03-01"
 const endTime = "2021-03-01"
 //************* 默认的蓝牙设备刷新间隔 再config 设置 a:10ms,b:20ms*************
 //************* 默认的蓝牙设备刷新间隔 再config 设置 a:10ms,b:20ms*************
 const refreshRate = "a";
 const refreshRate = "a";
-
+//*******当前活动环境,需要和根据地址设置!!环境 dev,prd
+const active = "dev";
 //线上地址,腾讯云服务器
 //线上地址,腾讯云服务器
 // const host="https://www.9527fun.cn/api_prd"
 // const host="https://www.9527fun.cn/api_prd"
 //测试地址,阿里云服务器
 //测试地址,阿里云服务器
@@ -156,6 +157,7 @@ const URL = {
 
 
 
 
 export default {
 export default {
+	active,
 	URL,
 	URL,
 	endTime,
 	endTime,
 	refreshRate
 	refreshRate

+ 2 - 0
components/modal/boxing-hit/boxing-hit.vue

@@ -724,8 +724,10 @@
 
 
 
 
 			},
 			},
+			
 			//hotman 情景下刷新
 			//hotman 情景下刷新
 			onBLEHotmanUpdate(data) {
 			onBLEHotmanUpdate(data) {
+				console.log("onBLEHotmanUpdate:",data ,this.bUpdate,this.bPlay);
 				if (!this.bUpdate || !this.bPlay) return;
 				if (!this.bUpdate || !this.bPlay) return;
 
 
 				let {
 				let {

+ 2 - 2
manifest.json

@@ -2,8 +2,8 @@
     "name" : "哔蹦",
     "name" : "哔蹦",
     "appid" : "__UNI__2635DF5",
     "appid" : "__UNI__2635DF5",
     "description" : "",
     "description" : "",
-    "versionName" : "2.3.13",
-    "versionCode" : 21041301,
+    "versionName" : "2.3.14",
+    "versionCode" : 21042302,
     "transformPx" : false,
     "transformPx" : false,
     /* 5+App特有相关 */
     /* 5+App特有相关 */
     "app-plus" : {
     "app-plus" : {

+ 74 - 3
pages/game-page/game-play-sub/subGame/subGame.nvue

@@ -2,7 +2,7 @@
 	<view class="web-view">
 	<view class="web-view">
 		<!-- :src="url" src = 'http://192.168.0.112:7456/build/index.html' :src="LocationGameUrl" -->
 		<!-- :src="url" src = 'http://192.168.0.112:7456/build/index.html' :src="LocationGameUrl" -->
 		<!-- @receivedtitle="onReceivedTitle"   @pagefinish="onPageFinish"-->
 		<!-- @receivedtitle="onReceivedTitle"   @pagefinish="onPageFinish"-->
-		<web-view class="web-view-child" :src="url" ref="webview" @pagestart="onPageStart" @onPostMessage="handlePostMessage"
+		<web-view class="web-view-child" src = 'http://192.168.0.112:7456/build/index.html' ref="webview" @pagestart="onPageStart" @onPostMessage="handlePostMessage"
 		 @error="onError"></web-view>
 		 @error="onError"></web-view>
 		<view class="web-back" @click="navBack">
 		<view class="web-back" @click="navBack">
 			<image style="width: 40rpx;height: 40rpx;" src="/static/gameCloseW.png"></image>
 			<image style="width: 40rpx;height: 40rpx;" src="/static/gameCloseW.png"></image>
@@ -84,6 +84,8 @@
 
 
 				//是否是游戏里面开启的监听,如果是的话,退出游戏界面时候需要关闭相应的监听,如加速计和陀螺仪
 				//是否是游戏里面开启的监听,如果是的话,退出游戏界面时候需要关闭相应的监听,如加速计和陀螺仪
 				bGameOpenListen: false,
 				bGameOpenListen: false,
+				//手机陀螺仪和加速计android模块
+				bMyAttitudeListen:false,
 			}
 			}
 		},
 		},
 		onLoad() {
 		onLoad() {
@@ -130,6 +132,12 @@
 				uni.$off('updateBLEDeviceData', _self.BLECallback);
 				uni.$off('updateBLEDeviceData', _self.BLECallback);
 				//json
 				//json
 				uni.$off('updateBLEDeviceJson', _self.BLEJsonCallback);
 				uni.$off('updateBLEDeviceJson', _self.BLEJsonCallback);
+				
+				//去掉监听
+				if(_self.bMyAttitudeListen){
+					_self.gStopSimulateBLEUpdate();
+				}
+				
 				// console.log(_self.BLEConnectDevice);
 				// console.log(_self.BLEConnectDevice);
 				//如果连接了蓝牙设备是手柄
 				//如果连接了蓝牙设备是手柄
 				if (_self.BLEConnectDevice && _self.BLEConnectDevice.deviceType == "BLEHandle") {
 				if (_self.BLEConnectDevice && _self.BLEConnectDevice.deviceType == "BLEHandle") {
@@ -154,6 +162,8 @@
 					globalOri: _self.globalOri,
 					globalOri: _self.globalOri,
 					bGameOpenListen: _self.bGameOpenListen
 					bGameOpenListen: _self.bGameOpenListen
 				});
 				});
+				
+				
 			});
 			});
 			//*****注释蓝牙操作******
 			//*****注释蓝牙操作******
 			// 监听事件    
 			// 监听事件    
@@ -185,7 +195,8 @@
 		},
 		},
 		methods: {
 		methods: {
 			...mapMutations(['addlocalCalorie', 'syncRequestEvent', 'onWriteBLEConnectionValue',
 			...mapMutations(['addlocalCalorie', 'syncRequestEvent', 'onWriteBLEConnectionValue',
-				'gCreateFilterObj', 'gUpdateFilter' ,'B_OpenRopeSkipping','B_CloseRopeSkipping'
+				'gCreateFilterObj', 'gUpdateFilter' ,'B_OpenRopeSkipping','B_CloseRopeSkipping',
+				'gStopSimulateBLEUpdate','gStartSimulateBLEUpdate','gUpdateSandbagAlgorithm','gCreateSandbagAlgorithm'
 			]),
 			]),
 			navBack() {
 			navBack() {
 
 
@@ -592,6 +603,15 @@
 					}
 					}
 				} else if (temp.funName == "bindHitBoxingPost") {
 				} else if (temp.funName == "bindHitBoxingPost") {
 					console.log("bindHitBoxingPost");
 					console.log("bindHitBoxingPost");
+					
+					if(this.ConnectBindingDevice){
+						uni.$on('updateBLEDeviceData', this.gWatchBLEUpdate);
+						//hotman 沙袋情景
+						this.gCreateSandbagAlgorithm();
+						this.gStartSimulateBLEUpdate();
+						return;
+					}
+					
 					if(!this.BLEConnectDevice)return;
 					if(!this.BLEConnectDevice)return;
 					//用设备来区分,开启什么加速计;
 					//用设备来区分,开启什么加速计;
 					if (this.BLEConnectDevice.deviceType == "BLEHandle") {
 					if (this.BLEConnectDevice.deviceType == "BLEHandle") {
@@ -649,6 +669,13 @@
 
 
 
 
 				} else if (temp.funName == "unbindHitBoxingPost") {
 				} else if (temp.funName == "unbindHitBoxingPost") {
+					
+					if(this.ConnectBindingDevice){
+						uni.$off('updateBLEDeviceData', this.gWatchBLEUpdate);
+						this.gStopSimulateBLEUpdate();
+						return;
+					}
+					
 					if (this.BLEConnectDevice&&this.BLEConnectDevice.deviceType == "BLEHandle") {
 					if (this.BLEConnectDevice&&this.BLEConnectDevice.deviceType == "BLEHandle") {
 						//开启设备回调 3/4关闭
 						//开启设备回调 3/4关闭
 						this.onWriteBLEConnectionValue({
 						this.onWriteBLEConnectionValue({
@@ -693,6 +720,19 @@
 				} else if (temp.funName == "closeDeviceJsonUpdateListener") {
 				} else if (temp.funName == "closeDeviceJsonUpdateListener") {
 					uni.$off('updateBLEDeviceJson', this.BLEJsonCallback);
 					uni.$off('updateBLEDeviceJson', this.BLEJsonCallback);
 				}
 				}
+				//获取手机原始陀螺仪和加速计数据
+				else if(temp.funName == "onStartAccAndGyro"){
+					this.bMyAttitudeListen = true;
+					this.gStartSimulateBLEUpdate();
+					//监听蓝牙回调
+					uni.$on('updateBLEDeviceData', this.gWatchBLEUpdate);
+				}
+				else if(temp.funName == "onStopAccAndGyro"){
+					this.bMyAttitudeListen = false;
+					this.gStopSimulateBLEUpdate();
+					//监听蓝牙回调
+					uni.$off('updateBLEDeviceData', this.gWatchBLEUpdate);
+				}
 			},
 			},
 			onPageStart: function(e) {
 			onPageStart: function(e) {
 				// 监听页面加载成功
 				// 监听页面加载成功
@@ -765,7 +805,38 @@
 				}
 				}
 			},
 			},
 			gWatchBLEUpdate: function(data) {
 			gWatchBLEUpdate: function(data) {
-
+				
+				//如果是模块外面触发,需要离线打包
+				if(this.bMyAttitudeListen){
+					this.sendMessage("updateAccAndGyro", data);
+					return;
+				}
+				
+				if(this.ConnectBindingDevice){
+					//hotman 沙袋情景 todo
+					this.gUpdateSandbagAlgorithm({
+						data: data,
+						callback: (res) => {
+							// console.log(res);
+							if (res.type == 'hit') {
+								// console.log('gUpdateFilter callback:',res)
+					
+								let temp = {
+									direction: res.direction,
+									angle:res.angle,
+									name: res.name,
+									ename: res.ename,
+									value: res.hit,
+									mass: 10, //质量
+									hitPower: res.hit //计算的力
+								}
+								this.sendMessage("onBoxingPostHit", temp);
+							}
+						}
+					});
+					return;
+				}
+				
 				if (this.BLEConnectDevice.usageMode == "phone" || this.BLEConnectDevice.usageMode == "general") {
 				if (this.BLEConnectDevice.usageMode == "phone" || this.BLEConnectDevice.usageMode == "general") {
 					//手机情景或者自由模式
 					//手机情景或者自由模式
 					let {
 					let {

+ 2 - 2
pages/game-page/game/game.vue

@@ -28,7 +28,7 @@
 		</view>
 		</view>
 
 
 		<scroll-view scroll-y="true" :style="{ height: scrollviewHigh + 'px' }" @scrolltolower="lower">
 		<scroll-view scroll-y="true" :style="{ height: scrollviewHigh + 'px' }" @scrolltolower="lower">
-			<view v-if="cIndex != -1 && gameShow" class="game-item card-view" v-for="(item, index) in gameList" :key="index" :data-id="index">
+			<view v-if="(cIndex != -1 && gameShow)||ConnectBindingDevice" class="game-item card-view" v-for="(item, index) in gameList" :key="index" :data-id="index">
 				<view @tap="onNavToWebviewGame(item)">
 				<view @tap="onNavToWebviewGame(item)">
 					<view class="game-image-container">
 					<view class="game-image-container">
 						<image mode="aspectFill" class="game-item-image" :src="item.gamePicture"></image>
 						<image mode="aspectFill" class="game-item-image" :src="item.gamePicture"></image>
@@ -65,7 +65,7 @@
 					</view>
 					</view>
 				</view>
 				</view>
 			</view>
 			</view>
-			<view v-if="(cIndex == -1 && !gameShow) || gameList.length == 0" class="text-16px text-gray text-center margin">没有更多数据</view>
+			<view v-if="(cIndex == -1 && !gameShow) || gameList.length == 0 || ConnectBindingDevice == null" class="text-16px text-gray text-center margin">没有更多数据</view>
 			<view style="height: 17px;"></view>
 			<view style="height: 17px;"></view>
 		</scroll-view>
 		</scroll-view>
 
 

+ 212 - 71
pages/personal-page/personal/personal.vue

@@ -99,8 +99,9 @@
 							<!-- 用于定位 -->
 							<!-- 用于定位 -->
 							<!-- <view id="boxingHitID" style="position: absolute;top: 180rpx; pointer-events: none;" ></view> -->
 							<!-- <view id="boxingHitID" style="position: absolute;top: 180rpx; pointer-events: none;" ></view> -->
 							<view id="boxingHitID" v-if="currentModeIndex == 0" class="charts-pring-bottom">
 							<view id="boxingHitID" v-if="currentModeIndex == 0" class="charts-pring-bottom">
-								<boxing-hit ref="boxingPostRef" :bUpdate="!bHide && cIndex!=-1 && BLEConnectDevice!=null &&
-								 (BLEConnectDevice.deviceType == 'mySelf'||BLEConnectDevice.deviceType == 'BLEHandle' || BLEConnectDevice.deviceType == 'BLERope' )"
+								<!-- 添加一个 ConnectBindingDevice 测试 -->
+								<boxing-hit ref="boxingPostRef" :bUpdate="!bHide&&(ConnectBindingDevice!=null)||(cIndex!=-1 && BLEConnectDevice!=null &&
+								 (BLEConnectDevice.deviceType == 'mySelf'||BLEConnectDevice.deviceType == 'BLEHandle' || BLEConnectDevice.deviceType == 'BLERope' ))"
 								 :showTime="localSportTime" :bRebound="BLEConnectDevice&&BLEConnectDevice.limitType == 'rebound'"
 								 :showTime="localSportTime" :bRebound="BLEConnectDevice&&BLEConnectDevice.limitType == 'rebound'"
 								 @updateCalorie="boxingUpdateCalorie" @boxingPostCheck="onPersonalCheck" @shake="onScreenShake"
 								 @updateCalorie="boxingUpdateCalorie" @boxingPostCheck="onPersonalCheck" @shake="onScreenShake"
 								 @updateSportTime="onUpdateSportTime" @boxingGuideFinish="onBoxingGuideFinish" @boxingPostControlPlay="onBoxingPostControlPlay"
 								 @updateSportTime="onUpdateSportTime" @boxingGuideFinish="onBoxingGuideFinish" @boxingPostControlPlay="onBoxingPostControlPlay"
@@ -224,11 +225,27 @@
 									</view>
 									</view>
 								</view>
 								</view>
 							</view> -->
 							</view> -->
+							<!-- 开启手机加速计和陀螺仪数据 -->
+							<!-- <view class="container-device" id="openAccGyroView">
+								<view class="width-device flex align-center" v-for="(item, index) in DeviceBindingList" @tap="onBindingDevice(item, 0)"
+								 :key="'key-'+index" :id="'bing-'+item.ename">
+
+									<view style="position: relative; height: 100%;">
+										<image :src="ConnectBindingDevice? '/static/deviceBg.png' : '/static/deviceBg_off.png'" class="data-png-64"
+										 mode="aspectFit"></image>
+										<image :src="ConnectBindingDevice?item.icon:item.mIcon" class="data-png-add" mode="aspectFit"></image>
+									</view>
+
+									<view class="flex-sub text-center">
+										<image :src="ConnectBindingDevice? '/static/wifi_on.png' : '/static/wifi_off.png'" class="data-png-32" mode="aspectFit"></image>
+										<view class="text-gray">{{ item.cname }}</view>
+									</view>
+								</view>
+							</view> -->
 							<!-- 隐藏设备处 -->
 							<!-- 隐藏设备处 -->
 							<view class="container-device">
 							<view class="container-device">
 								<view class="width-device flex align-center" v-for="(item, index) in BLEDeviceShowList" :key="index" @tap="onDevice(item, $event)"
 								<view class="width-device flex align-center" v-for="(item, index) in BLEDeviceShowList" :key="index" @tap="onDevice(item, $event)"
 								 :data-index="index">
 								 :data-index="index">
-									<!-- "/static/trampolineS.png" -->
 									<view style="position: relative; height: 100%;">
 									<view style="position: relative; height: 100%;">
 										<image :src="index == cIndex ? '/static/deviceBg.png' : '/static/deviceBg_off.png'" class="data-png-64" mode="aspectFit"></image>
 										<image :src="index == cIndex ? '/static/deviceBg.png' : '/static/deviceBg_off.png'" class="data-png-64" mode="aspectFit"></image>
 										<image :src="item.mIcon" class="data-png-add" mode="aspectFit"></image>
 										<image :src="item.mIcon" class="data-png-add" mode="aspectFit"></image>
@@ -255,11 +272,10 @@
 								</view>
 								</view>
 							</view>
 							</view>
 
 
-
 						</view>
 						</view>
 
 
 						<!-- 游戏推荐 -->
 						<!-- 游戏推荐 -->
-						<view class="card-view" v-if="cIndex != -1 && versionCodeState&&versionCodeState.showGame && gameList.length !== 0">
+						<view class="card-view" v-if="ConnectBindingDevice || (cIndex != -1 && versionCodeState&&versionCodeState.showGame && gameList.length !== 0)">
 							<view class="text-left padding margin-xs flex justify-between">
 							<view class="text-left padding margin-xs flex justify-between">
 								<text class="text-black text-15px margin-left">游戏推荐</text>
 								<text class="text-black text-15px margin-left">游戏推荐</text>
 								<view data-type="game" @tap="onNavToGameMore" class="flex text-center justify-center align-center margin-right">
 								<view data-type="game" @tap="onNavToGameMore" class="flex text-center justify-center align-center margin-right">
@@ -291,8 +307,11 @@
 						<!-- <button class="margin" @click="getBLEDeviceServices">getBLEDeviceServices</button> -->
 						<!-- <button class="margin" @click="getBLEDeviceServices">getBLEDeviceServices</button> -->
 
 
 						<!-- <keyboard-listener @keydown="onKeyDown"></keyboard-listener> -->
 						<!-- <keyboard-listener @keydown="onKeyDown"></keyboard-listener> -->
+						<!-- 	<button type="primary" @click="testAsyncFunc">testAsyncFunc</button>
+						<button type="primary" @click="startSyncFunc">startSyncFunc</button>
+						<button type="primary" @click="stopSyncFunc">stopSyncFunc</button> -->
 						<!-- 视频推荐 -->
 						<!-- 视频推荐 -->
-						<view class="card-view" v-if="cIndex != -1 && versionCodeState&&versionCodeState.showVideo && videoList.length !== 0">
+						<view class="card-view" v-if="ConnectBindingDevice || (cIndex != -1 && versionCodeState&&versionCodeState.showVideo && videoList.length !== 0)">
 							<view class="text-left padding margin-xs flex justify-between">
 							<view class="text-left padding margin-xs flex justify-between">
 								<text class="text-black text-15px margin-left">视频推荐</text>
 								<text class="text-black text-15px margin-left">视频推荐</text>
 								<view data-type="video" @tap="onNavToGameMore" class="flex text-center justify-center align-center margin-right">
 								<view data-type="video" @tap="onNavToGameMore" class="flex text-center justify-center align-center margin-right">
@@ -463,6 +482,10 @@
 
 
 	import keyboardListener from '@/components/keyboard-listener/keyboard-listener.vue'
 	import keyboardListener from '@/components/keyboard-listener/keyboard-listener.vue'
 
 
+	// 获取 module 
+	// var testModule = uni.requireNativePlugin("MyAttitude")
+	// const modal = uni.requireNativePlugin('modal');
+
 
 
 	import {
 	import {
 		mapState,
 		mapState,
@@ -890,11 +913,41 @@
 				// }, 5000)
 				// }, 5000)
 
 
 			}
 			}
+			//如果是测试数据
+			if (this.ConnectBindingDevice) {
+				if (this.$refs.boxingPostRef) {
+					this.$refs.boxingPostRef.onSetMode('pkMode');
+				} else {
+					setTimeout(() => {
+						this.$refs.boxingPostRef.onSetMode('pkMode');
+					}, 500)
+				}
+			}
 
 
 			console.log('personal show');
 			console.log('personal show');
 
 
 			this.bLimitReconnection = false;
 			this.bLimitReconnection = false;
 
 
+			//测试环境检测,给个modal提示 active
+			if (config.active == 'dev') {
+				function thanDate(date2) {
+					var oDate1 = new Date();
+					console.log("检测日期", oDate1);
+					var oDate2 = new Date(date2);
+					if (oDate1.getTime() > oDate2.getTime()) {
+						return true;
+					} else {
+						return false;
+					}
+				}
+				if (thanDate('2021-05-31 13:10:36')) {
+					uni.showModal({
+						title: "提示",
+						content: "此版本为测试版本,有需要请和开发者联系。微信 sweetdontcry"
+					})
+				}
+			}
+
 		},
 		},
 		onReady() {
 		onReady() {
 			// 计算屏幕剩余高度  填补剩余高度
 			// 计算屏幕剩余高度  填补剩余高度
@@ -955,7 +1008,9 @@
 				'syncLocalDataToServer', 'syncRequestEvent', 'setLocalSportTime',
 				'syncLocalDataToServer', 'syncRequestEvent', 'setLocalSportTime',
 				'initAdapter', 'onCreateBLEConnection', 'onUnloadCreateBLEConnectionTimeout', 'onCloseBLEConnection',
 				'initAdapter', 'onCreateBLEConnection', 'onUnloadCreateBLEConnectionTimeout', 'onCloseBLEConnection',
 				'gOnAddClientInfo', 'onWriteBLEConnectionValue',
 				'gOnAddClientInfo', 'onWriteBLEConnectionValue',
-				'gCreateFilterObj', 'gUpdateFilter', 'B_GetBondedDevices', 'B_OpenBLESetting','B_OpenRopeSkipping','B_CloseRopeSkipping'
+				'gCreateFilterObj', 'gUpdateFilter', 'B_GetBondedDevices', 'B_OpenBLESetting', 'B_OpenRopeSkipping',
+				'B_CloseRopeSkipping',
+				'gCreateSandbagAlgorithm', 'gUpdateSandbagAlgorithm', 'gStartSimulateBLEUpdate', 'gStopSimulateBLEUpdate'
 			]),
 			]),
 			onKeyDown(e) {
 			onKeyDown(e) {
 				console.log(e);
 				console.log(e);
@@ -1427,6 +1482,19 @@
 				//如果在监听状态时候隐藏页面,返回
 				//如果在监听状态时候隐藏页面,返回
 				if (_self.bHide) return;
 				if (_self.bHide) return;
 				// console.log("callbackDeviceState==", data);
 				// console.log("callbackDeviceState==", data);
+
+				if (this.ConnectBindingDevice) {
+					this.gUpdateSandbagAlgorithm({
+						data: data,
+						callback: (res) => {
+							if (res.type == 'hit') {
+								this.$refs.boxingPostRef.onBLEHotmanUpdate(res);
+							}
+						}
+					});
+					return;
+				}
+
 				//连接了手柄模式
 				//连接了手柄模式
 				//没有开启指令不刷新
 				//没有开启指令不刷新
 				if (!this.instructionState.bOpen) return;
 				if (!this.instructionState.bOpen) return;
@@ -1456,12 +1524,20 @@
 			},
 			},
 			//绑定设备函数
 			//绑定设备函数
 			onBindingDevice(item, index) {
 			onBindingDevice(item, index) {
-				// console.log(item,index);
-				// e.currentTarget.dataset.index $event
-				if (index == this.cIndex) {
-					this.$store.state.cIndex = -1;
-					this.$store.state.ConnectBindingDevice = null;
+				if (item == null) {
+					item = this.DeviceBindingList[0];
+				}
+				if (this.BLEConnectDevice) {
+					uni.showToast({
+						icon: "none",
+						title: "已连接硬件设备",
+						duration: 1000
+					})
+					return;
+				}
 
 
+				if (this.ConnectBindingDevice) {
+					this.$store.state.ConnectBindingDevice = null;
 					setTimeout(() => {
 					setTimeout(() => {
 						uni.showToast({
 						uni.showToast({
 							icon: "none",
 							icon: "none",
@@ -1469,9 +1545,7 @@
 							duration: 1000
 							duration: 1000
 						})
 						})
 					}, 300)
 					}, 300)
-
 				} else {
 				} else {
-					this.$store.state.cIndex = index;
 					this.$store.state.ConnectBindingDevice = item;
 					this.$store.state.ConnectBindingDevice = item;
 					setTimeout(() => {
 					setTimeout(() => {
 						uni.showToast({
 						uni.showToast({
@@ -1483,6 +1557,9 @@
 					//连接后保存最近连接的设备
 					//连接后保存最近连接的设备
 				}
 				}
 
 
+				//刷新状态
+				this.$refs.boxingPostRef.onSetMode('pkMode');
+
 			},
 			},
 			//关闭设备函数
 			//关闭设备函数
 			onCloseBindingDevice(item, e) {
 			onCloseBindingDevice(item, e) {
@@ -1504,6 +1581,14 @@
 				this.toView = "addDeviceView";
 				this.toView = "addDeviceView";
 			},
 			},
 			onDevice(item, e) {
 			onDevice(item, e) {
+				if (this.ConnectBindingDevice) {
+					uni.showToast({
+						title: '当前已开启数据',
+						icon: 'none',
+						mask: true
+					})
+					return;
+				}
 				if (this.cIndex !== -1) {
 				if (this.cIndex !== -1) {
 					uni.showToast({
 					uni.showToast({
 						title: '当前已连接设备',
 						title: '当前已连接设备',
@@ -1589,6 +1674,16 @@
 			},
 			},
 
 
 			openDeviceList(e) {
 			openDeviceList(e) {
+
+				if (this.ConnectBindingDevice) {
+					uni.showToast({
+						title: '当前已开启数据',
+						icon: 'none',
+						mask: true
+					})
+					return;
+				}
+
 				//先判断蓝牙是否初始化
 				//先判断蓝牙是否初始化
 				/**
 				/**
 				 * 蓝牙部分操作,转全局变量操作
 				 * 蓝牙部分操作,转全局变量操作
@@ -1740,44 +1835,39 @@
 				//分类型判断
 				//分类型判断
 				if (0 === this.currentModeIndex) {
 				if (0 === this.currentModeIndex) {
 					//拳击运动类型
 					//拳击运动类型
-					// 1.检测是否有对应设备,
-					// if (0 === this.DeviceBindingList.length) {
-					// 	//如果没有绑定二维码设备,需要扫码绑定
+					// 1.检测是否有对应设备,没有ConnectBindingDevice,再进行下一步
+					if (this.ConnectBindingDevice == null) {
+						uni.showToast({
+							title: '开启连接数据',
+							icon: 'none'
+						})
+						this.toView = "openAccGyroView";
+						return;
+
+					}
+					// TODO,目前去掉蓝牙设备
+					// //2.检测是否有设备
+					// if (this.BLEDeviceShowList.length == 0) {
 					// 	this.$store.state.bGuidePages = true;
 					// 	this.$store.state.bGuidePages = true;
 					// 	this.guideCurrent = 3;
 					// 	this.guideCurrent = 3;
-					// 	this.toView = "QRDeviceView";
+					// 	uni.showToast({
+					// 		title: '请添加蓝牙设备',
+					// 		icon: 'none'
+					// 	})
+					// 	this.toView = "addDeviceView";
 					// 	return;
 					// 	return;
 					// }
 					// }
-					// // 2.检测是否连接设备
+					// //2.检测是否连接设备 || this.BLEConnectDevice.ename !== 'BT04'
 					// if (this.cIndex == -1) {
 					// if (this.cIndex == -1) {
 					// 	//没有连接设备,提示去连接设备
 					// 	//没有连接设备,提示去连接设备
-					// 	this.$store.state.bGuidePages = true;
-					// 	this.guideCurrent = 4;
-					// 	this.toView = "bing-boxingPost";
-					// 	console.log("bing-boxingPost");
+					// 	uni.showToast({
+					// 		title: '请连接蓝牙设备',
+					// 		icon: 'none'
+					// 	})
+					// 	this.toView = "addDeviceView";
 					// 	return;
 					// 	return;
 					// }
 					// }
-					//2.检测是否有设备
-					if (this.BLEDeviceShowList.length == 0) {
-						this.$store.state.bGuidePages = true;
-						this.guideCurrent = 3;
-						uni.showToast({
-							title: '请添加蓝牙设备',
-							icon: 'none'
-						})
-						this.toView = "addDeviceView";
-						return;
-					}
-					//2.检测是否连接设备 || this.BLEConnectDevice.ename !== 'BT04'
-					if (this.cIndex == -1) {
-						//没有连接设备,提示去连接设备
-						uni.showToast({
-							title: '请连接蓝牙设备',
-							icon: 'none'
-						})
-						this.toView = "addDeviceView";
-						return;
-					}
+
 				}
 				}
 
 
 
 
@@ -1816,27 +1906,34 @@
 						this.toView = "boxingHitID";
 						this.toView = "boxingHitID";
 						this.$store.state.bNewGuide = false;
 						this.$store.state.bNewGuide = false;
 					} else {
 					} else {
-						//todo 跳绳模式 发送开启指令
-						if (this.BLEConnectDevice.usageMode == "ropeSkipping") {
-							//打开跳绳模式
-							this.B_OpenRopeSkipping();
+						if (this.ConnectBindingDevice) {
+							//假如有连接bingding设备
+							this.gCreateSandbagAlgorithm();
+							this.gStartSimulateBLEUpdate();
 						} else {
 						} else {
-							//初始化filter快速打击对象
-							if (this.BLEConnectDevice.usageMode == "hotman") {
-								this.gCreateFilterObj();
-							}
-							//打开加速计
-							this.onWriteBLEConnectionValue({
-								value: "3"
-							});
-
-							setTimeout(() => {
-								//设置加速计b:20ms a:10ms
+							//todo 跳绳模式 发送开启指令
+							if (this.BLEConnectDevice.usageMode == "ropeSkipping") {
+								//打开跳绳模式
+								this.B_OpenRopeSkipping();
+							} else {
+								//初始化filter快速打击对象
+								if (this.BLEConnectDevice.usageMode == "hotman") {
+									this.gCreateFilterObj();
+								}
+								//打开加速计
 								this.onWriteBLEConnectionValue({
 								this.onWriteBLEConnectionValue({
-									value: config.refreshRate
+									value: "3"
 								});
 								});
 
 
-							}, 1000)
+								setTimeout(() => {
+									//设置加速计b:20ms a:10ms
+									this.onWriteBLEConnectionValue({
+										value: config.refreshRate
+									});
+
+								}, 1000)
+							}
+
 						}
 						}
 
 
 						//监听蓝牙回调
 						//监听蓝牙回调
@@ -2223,15 +2320,22 @@
 			//弹出目标提示后,进行下一步
 			//弹出目标提示后,进行下一步
 			onBoxingPause(bFinish) {
 			onBoxingPause(bFinish) {
 				if (bFinish) {
 				if (bFinish) {
-					if(this.BLEConnectDevice.usageMode == "ropeSkipping"){
-						this.B_CloseRopeSkipping();
-					}else{
-						//停止蓝牙加速计
-						this.onWriteBLEConnectionValue({
-							value: "4"
-						});
+
+					if (this.ConnectBindingDevice) {
+						this.gStopSimulateBLEUpdate();
+					} else {
+						if (this.BLEConnectDevice.usageMode == "ropeSkipping") {
+							this.B_CloseRopeSkipping();
+						} else {
+							//停止蓝牙加速计
+							this.onWriteBLEConnectionValue({
+								value: "4"
+							});
+						}
+
 					}
 					}
-					
+
+
 
 
 					uni.$off('updateBLEDeviceData', this.callbackUpdateBLEData);
 					uni.$off('updateBLEDeviceData', this.callbackUpdateBLEData);
 
 
@@ -2365,6 +2469,8 @@
 
 
 					// 	console.log(data);
 					// 	console.log(data);
 					// }).exec();
 					// }).exec();
+				} else if (_self.toView == "openAccGyroView") {
+					_self.toView = "";
 				}
 				}
 			},
 			},
 
 
@@ -2529,9 +2635,44 @@
 
 
 				// 	}
 				// 	}
 				// });
 				// });
-			}
-
+			},
 
 
+			// testAsyncFunc() {
+			// 	// 调用异步方法
+			// 	testModule.testAsyncFunc({
+			// 			'name': 'unimp',
+			// 			'age': 1
+			// 		},
+			// 		(ret) => {
+			// 			modal.toast({
+			// 				message: ret,
+			// 				duration: 1.5
+			// 			});
+			// 		})
+			// },
+			// startSyncFunc() {
+			// 	// 调用同步方法
+			// 	var ret = testModule.onStartAccAndGyro({
+			// 		'name': 'unimp',
+			// 		'age': 1
+			// 	})
+			// 	modal.toast({
+			// 		message: ret,
+			// 		duration: 1.5
+			// 	});
+			// },
+
+			// stopSyncFunc() {
+			// 	// 调用同步方法
+			// 	var ret = testModule.onStopAccAndGyro({
+			// 		'name': 'unimp',
+			// 		'age': 1
+			// 	})
+			// 	modal.toast({
+			// 		message: ret,
+			// 		duration: 1.5
+			// 	});
+			// },
 
 
 		}
 		}
 	};
 	};

+ 8 - 2
util/util-js/AccAndOri.js

@@ -1,11 +1,14 @@
 /**
 /**
  * 绑定加速计
  * 绑定加速计
  */
  */
-function bindAcc(callback) {
+function bindAcc(callback,callbackValue) {
 	let id = null;
 	let id = null;
 	console.log("监听加速计");
 	console.log("监听加速计");
 	id = plus.accelerometer.watchAcceleration((a) => {
 	id = plus.accelerometer.watchAcceleration((a) => {
 		uni.$emit('watchAcceleration', a);
 		uni.$emit('watchAcceleration', a);
+		if(callbackValue){
+			callbackValue(a);
+		}
 		// console.log(a);
 		// console.log(a);
 	}, function(e) {
 	}, function(e) {
 		console.log("监听失败:" + e.message);
 		console.log("监听失败:" + e.message);
@@ -23,11 +26,14 @@ function bindAcc(callback) {
 /**
 /**
  * 绑定陀螺仪
  * 绑定陀螺仪
  */
  */
-function bindOri(callback) {
+function bindOri(callback,callbackValue) {
 	let id = null;
 	let id = null;
 	console.log("监听陀螺仪");
 	console.log("监听陀螺仪");
 	id = plus.orientation.watchOrientation(function(o) {
 	id = plus.orientation.watchOrientation(function(o) {
 		uni.$emit('watchOrientation', o);
 		uni.$emit('watchOrientation', o);
+		if(callbackValue){
+			callbackValue(o);
+		}
 	}, function(e) {
 	}, function(e) {
 		console.log("监听失败:" + e.message);
 		console.log("监听失败:" + e.message);
 		if (id) {
 		if (id) {

+ 164 - 0
util/util-js/o0ProjectRelease.js

@@ -0,0 +1,164 @@
+import o0 from "./o0.js"
+
+module.exports = {
+    SandbagAlgorithm: class{
+        constructor() {
+
+			this.stableAcc = new o0.Vector2(0,0);
+			this.stableGyr = new o0.Vector2(0,0);
+			this.stableCount = 0;
+			this.stableCountMax = 3000;
+
+			this.frameCapacity = 6;
+			this.frame = [];
+			this.frameLength = 5;
+			this.frameOffset = 0;
+
+			this.frameHitCapacity = 11;
+			this.frameHit = [];//打击后的n帧
+
+			for(var i = 0;i<this.frameCapacity;++i){
+				var o = new Object();
+				o.acc = new o0.Vector2(0,0);
+				o.gyr = new o0.Vector2(0,0);
+				
+				o.timeGap = 20;
+				o.accFixed = 0;
+				o.accSlope = 0;
+
+				o.pos = new o0.Vector2(0,0);
+				o.predict = new o0.Vector2(0,0);
+
+				o.shake = 0;
+				o.shakeFixed = 0;
+				o.shakeSlope = 0;
+
+				o.hit = 0;
+				this.frame.push(o);
+			}
+		}
+		//这个函数不建议外部调用
+		GetDirection(){
+            var direction = new o0.Vector2(0,0);
+			var directionDistance = 0.0;
+			for (var fi = 0;fi < this.frameHit.length - 1;++fi) {
+				for (var li = fi + 1;li < this.frameHit.length;++li) {
+					var newDirection = this.frameHit[li].gyr - this.frameHit[fi].gyr;
+					var newDirectionDistance = newDirection.length;
+					if (directionDistance < newDirectionDistance) {
+						directionDistance = newDirectionDistance;
+						direction = newDirection.multiply(this.frameHit[this.frameHit.length -1].time - this.frameHit[0].time);
+					}
+					else {
+						//cout << "false" << endl;
+					}
+				}
+			}
+			return direction;
+		}
+		// 输入俯视的平面坐标系下的xy轴坐标 的 加速计向量/陀螺仪向量。
+		// timeGap 代表当前帧读取传感器与上一帧读取传感器 之间的时间差
+		Update(accX, accY, gyrX,gyrY,timeGap,callback){
+			var rawAcc = new o0.Vector2(accX,accY);
+			var rawGyr = new o0.Vector2(gyrX,gyrY);
+
+			let lastFrame = this.frame[(this.frameOffset + this.frameLength - 1) % this.frameCapacity];
+			let last2Frame = this.frame[(this.frameOffset + this.frameLength - 2) % this.frameCapacity];
+			let last3Frame = this.frame[(this.frameOffset + this.frameLength - 3) % this.frameCapacity];
+			let last4Frame = this.frame[(this.frameOffset + this.frameLength - 4) % this.frameCapacity];
+			let last5Frame = this.frame[(this.frameOffset + this.frameLength - 5) % this.frameCapacity];
+			var newFrame = this.frame[(this.frameOffset + this.frameLength) % this.frameCapacity];
+
+			newFrame.timeGap = timeGap;
+
+			newFrame.acc = rawAcc.minus(this.stableAcc);
+			newFrame.gyr = rawGyr.minus(this.stableGyr);
+
+			if (this.stableCount < this.stableCountMax){
+				this.stableCount += 1;
+			}
+			this.stableAcc = this.stableAcc.multiply((this.stableCount - 1.0) / this.stableCount).plus(rawAcc.multiply(1/this.stableCount));
+			this.stableGyr = this.stableGyr.multiply((this.stableCount - 1.0) / this.stableCount).plus(rawGyr.multiply(1/this.stableCount));
+			//////////////////////////////////////////////////////////////////////////////////
+			newFrame.accFixed = newFrame.acc.length * 100;
+
+			if(newFrame.accFixed < lastFrame.accFixed * 0.85){
+				newFrame.accFixed = lastFrame.accFixed * 0.85;
+			}
+			lastFrame.accFixed = Math.max(lastFrame.accFixed, Math.min(newFrame.accFixed,last2Frame.accFixed), Math.min(newFrame.accFixed,last3Frame.accFixed));
+			///////////////////////////////////////////////////////////////////////
+			//newFrame.pos = lastFrame.pos.plus(lastFrame.acc.plus(newFrame.acc).multiply(timeGap/60)).multiply(Math.max(1-timeGap/200,0));
+			newFrame.pos = lastFrame.pos.plus(newFrame.acc.multiply(timeGap/30)).multiply(Math.max(1-timeGap/1000,0));
+			////////////////////////////////////////////
+			newFrame.accSlope = Math.max(newFrame.accFixed-lastFrame.accFixed,0);
+
+
+			var lastI = this.frame.length-1;
+			var t2 = this.frame[lastI-1].timeGap;
+			var t3 = this.frame[lastI].timeGap + t2;
+			var t4 = newFrame.timeGap + t3;
+			
+			newFrame.predict = new o0.Vector2(
+				new o0.QuadraticEquation(0,this.frame[lastI-2].pos.x,t2,this.frame[lastI-1].pos.x,t3,this.frame[lastI].pos.x).y(t4),
+				new o0.QuadraticEquation(0,this.frame[lastI-2].pos.y,t2,this.frame[lastI-1].pos.y,t3,this.frame[lastI].pos.y).y(t4));/** */
+
+			newFrame.shake = o0.distance2(newFrame.predict,newFrame.pos) * 100;
+
+
+			if(isNaN(newFrame.shake)){
+				newFrame.shake = 0.0;
+			}
+			
+			newFrame.shakeFixed = lastFrame.shakeFixed * 0.85;
+			if(newFrame.shake > newFrame.shakeFixed){
+				newFrame.shakeFixed = newFrame.shake;
+			}/* */
+			lastFrame.shakeFixed = Math.max(lastFrame.shakeFixed, Math.min(newFrame.shakeFixed,last2Frame.shakeFixed), Math.min(newFrame.shakeFixed,last3Frame.shakeFixed));
+			////////////////////////////////////////////////////////////////
+			newFrame.shakeSlope = Math.max(newFrame.shakeFixed-lastFrame.shakeFixed,0);
+			///////////////////////////////////////////////////////////////
+
+			var direction = new o0.Vector2(0,0);
+
+			if(lastFrame.hit==0
+				&& last2Frame.hit==0
+				&& last3Frame.hit==0
+				&& last4Frame.hit==0
+				&& last5Frame.hit==0
+				&& (newFrame.accSlope >= 15 || lastFrame.accSlope >= 20)
+				&& (newFrame.shakeSlope >= 20 || lastFrame.shakeSlope >= 40)){
+				newFrame.hit = 1;
+				if (this.frameHit.length < this.frameHitCapacity) {
+					direction = this.GetDirection();
+				}/**/
+				this.frameHit = [];
+				var o = new Object();
+				o.time = 0;
+				o.gyr = lastFrame.gyr;
+				this.frameHit.push(o);
+			}else{
+				newFrame.hit = 0;
+			}
+
+			if (this.frameHit.length < this.frameHitCapacity) {
+				var o = new Object();
+				o.time = this.frameHit[this.frameHit.length - 1].time + newFrame.timeGap;
+				o.gyr = newFrame.gyr; 
+				if (this.frameHit.length == this.frameHitCapacity) {
+					direction =  this.GetDirection();
+				}
+			}
+			if ((this.frameOffset+=1) >= this.frameCapacity){
+				this.frameOffset -= this.frameCapacity;
+			}
+			
+			if(newFrame.hit != 0){
+				console.log(newFrame.hit, direction);
+			}
+			return (newFrame.hit, direction);
+		}
+        test(){
+            return "123123131";
+        }
+    }
+};

+ 232 - 0
util/util-js/o0ProjectRelease0.1.js

@@ -0,0 +1,232 @@
+import o0 from "./o0.js"
+
+module.exports = {
+	SandbagAlgorithm: class {
+		constructor() {
+
+			this.stableAcc = new o0.Vector2(0, 0);
+			this.stableGyr = new o0.Vector2(0, 0);
+			this.stableCount = 0;
+			this.stableCountMax = 3000;
+
+			this.frameCapacity = 6;
+			this.frame = [];
+			this.frameLength = 5;
+			this.frameOffset = 0;
+
+			this.frameHitCapacity = 11;
+			this.frameHit = [];//打击后的n帧
+
+			for (var i = 0; i < this.frameCapacity; ++i) {
+				var o = new Object();
+				o.acc = new o0.Vector2(0, 0);
+				o.gyr = new o0.Vector2(0, 0);
+
+				o.timeGap = 20;
+				o.accFixed = 0;
+				o.accSlope = 0;
+
+				o.pos = new o0.Vector2(0, 0);
+				o.predict = new o0.Vector2(0, 0);
+
+				o.shake = 0;
+				o.shakeFixed = 0;
+				o.shakeSlope = 0;
+
+				o.hit = 0;
+				this.frame.push(o);
+			}
+
+			this.quitHitCount = 0;
+		}
+		//这个函数不建议外部调用
+		GetDirection() {
+			var direction = new o0.Vector2(0, 0);
+			var directionDistance = 0.0;
+			for (var fi = 0; fi < this.frameHit.length - 1; ++fi) {
+				for (var li = fi + 1; li < this.frameHit.length; ++li) {
+					var newDirection = this.frameHit[li].gyr.minus(this.frameHit[fi].gyr);
+					var newDirectionDistance = newDirection.length;
+					if (directionDistance < newDirectionDistance) {
+						directionDistance = newDirectionDistance;
+						direction = newDirection.multiply(this.frameHit[this.frameHit.length - 1].time - this.frameHit[0].time);
+					}
+					else {
+						//cout << "false" << endl;
+					}
+				}
+			}
+			return direction;
+		}
+		// 输入俯视的平面坐标系下的xy轴坐标 的 加速计向量/陀螺仪向量。
+		// timeGap 代表当前帧读取传感器与上一帧读取传感器 之间的时间差
+		Update(accX, accY, gyrX, gyrY, timeGap) {
+			var rawAcc = new o0.Vector2(accX, accY);
+			var rawGyr = new o0.Vector2(gyrX, gyrY);
+
+			let lastFrame = this.frame[(this.frameOffset + this.frameLength - 1) % this.frameCapacity];
+			let last2Frame = this.frame[(this.frameOffset + this.frameLength - 2) % this.frameCapacity];
+			let last3Frame = this.frame[(this.frameOffset + this.frameLength - 3) % this.frameCapacity];
+			let last4Frame = this.frame[(this.frameOffset + this.frameLength - 4) % this.frameCapacity];
+			let last5Frame = this.frame[(this.frameOffset + this.frameLength - 5) % this.frameCapacity];
+			var newFrame = this.frame[(this.frameOffset + this.frameLength) % this.frameCapacity];
+
+			newFrame.timeGap = timeGap;
+
+			newFrame.acc = rawAcc.minus(this.stableAcc);
+			newFrame.gyr = rawGyr.minus(this.stableGyr);
+
+			if (this.stableCount < this.stableCountMax) {
+				this.stableCount += 1;
+			}
+			this.stableAcc = this.stableAcc.multiply((this.stableCount - 1.0) / this.stableCount).plus(rawAcc.multiply(1 / this.stableCount));
+			this.stableGyr = this.stableGyr.multiply((this.stableCount - 1.0) / this.stableCount).plus(rawGyr.multiply(1 / this.stableCount));
+			//////////////////////////////////////////////////////////////////////////////////
+			newFrame.accFixed = newFrame.acc.length * 100;
+
+			if (newFrame.accFixed < lastFrame.accFixed * 0.85) {
+				newFrame.accFixed = lastFrame.accFixed * 0.85;
+			}
+			lastFrame.accFixed = Math.max(lastFrame.accFixed, Math.min(newFrame.accFixed, last2Frame.accFixed), Math.min(newFrame.accFixed, last3Frame.accFixed));
+			///////////////////////////////////////////////////////////////////////
+			//newFrame.pos = lastFrame.pos.plus(lastFrame.acc.plus(newFrame.acc).multiply(timeGap/60)).multiply(Math.max(1-timeGap/200,0));
+			newFrame.pos = lastFrame.pos.plus(newFrame.acc.multiply(timeGap / 30)).multiply(Math.max(1 - timeGap / 1000, 0));
+			////////////////////////////////////////////
+			newFrame.accSlope = Math.max(newFrame.accFixed - lastFrame.accFixed, 0);
+
+
+			var lastI = this.frame.length - 1;
+			var t2 = this.frame[lastI - 1].timeGap;
+			var t3 = this.frame[lastI].timeGap + t2;
+			var t4 = newFrame.timeGap + t3;
+
+			newFrame.predict = new o0.Vector2(
+				new o0.QuadraticEquation(0, this.frame[lastI - 2].pos.x, t2, this.frame[lastI - 1].pos.x, t3, this.frame[lastI].pos.x).y(t4),
+				new o0.QuadraticEquation(0, this.frame[lastI - 2].pos.y, t2, this.frame[lastI - 1].pos.y, t3, this.frame[lastI].pos.y).y(t4));/** */
+
+			newFrame.shake = o0.distance2(newFrame.predict, newFrame.pos) * 100;
+
+
+			if (isNaN(newFrame.shake)) {
+				newFrame.shake = 0.0;
+			}
+
+			newFrame.shakeFixed = lastFrame.shakeFixed * 0.85;
+			if (newFrame.shake > newFrame.shakeFixed) {
+				newFrame.shakeFixed = newFrame.shake;
+			}/* */
+			lastFrame.shakeFixed = Math.max(lastFrame.shakeFixed, Math.min(newFrame.shakeFixed, last2Frame.shakeFixed), Math.min(newFrame.shakeFixed, last3Frame.shakeFixed));
+			////////////////////////////////////////////////////////////////
+			newFrame.shakeSlope = Math.max(newFrame.shakeFixed - lastFrame.shakeFixed, 0);
+			///////////////////////////////////////////////////////////////
+
+			var direction = undefined;
+
+			if (lastFrame.hit == 0
+				&& last2Frame.hit == 0
+				&& last3Frame.hit == 0
+				&& last4Frame.hit == 0
+				&& last5Frame.hit == 0
+				&& (newFrame.accSlope >= 15 || lastFrame.accSlope >= 20)
+				&& (newFrame.shakeSlope >= 20 || lastFrame.shakeSlope >= 40)) {
+				newFrame.hit = 1;
+				if (this.frameHit.length < this.frameHitCapacity && this.frameHit.length != 0) {//判断到第二次hit,但还未输出第一次hit的方向,强制输出方向
+					direction = this.GetDirection();
+				}/**/
+				this.frameHit = [];
+
+				/*
+				var o3 = new Object();
+				o3.time = 0;
+				o3.gyr = lastFrame3.gyr;
+				this.frameHit.push(o3);/* */
+
+				var o2 = new Object();
+				o2.time = last2Frame.timeGap;
+				o2.gyr = last2Frame.gyr;
+				this.frameHit.push(o2);
+
+				var o = new Object();
+				o.time = last2Frame.timeGap + lastFrame.timeGap;
+				o.gyr = lastFrame.gyr;
+				this.frameHit.push(o);
+			} else {
+				newFrame.hit = 0;
+			}
+
+			if (this.frameHit.length < this.frameHitCapacity && this.frameHit.length != 0) {
+				var o = new Object();
+				o.time = this.frameHit[this.frameHit.length - 1].time + newFrame.timeGap;
+				//o.gyr = this.frameHit[this.frameHit.length-1].gyr.plus(newFrame.gyr);
+				o.gyr = newFrame.gyr;
+				this.frameHit.push(o);
+				if (this.frameHit.length == this.frameHitCapacity) {//累计达到设定的延迟帧数,输出方向
+					direction = this.GetDirection();
+				}
+			}
+			if ((this.frameOffset += 1) >= this.frameCapacity) {
+				this.frameOffset -= this.frameCapacity;
+			}
+			return [newFrame.hit, direction];
+		}
+
+		getTempValue(curDirection) {
+            let result = Math.atan2(curDirection.y,curDirection.x) * 180 / (Math.PI);
+            result = Math.round(result);
+			let curAngle = result > 0 ? result:(360 + result);
+			
+			let directionPunch = "all",
+				name = "击中",
+				ename = "hit";
+
+			if (curAngle < 110 && curAngle >= 70) {
+				directionPunch = "straightPunch";
+				name = "正向的直拳";
+				ename = "front-straight";
+			} else if (curAngle < 70 && curAngle >= 0) {
+				directionPunch = "rightPunch";
+				name = "正向的右拳";
+				ename = "front-right";
+			} else if (curAngle >= 110 && curAngle <= 180) {
+				directionPunch = "leftPunch";
+				name = "正向的左拳";
+				ename = "front-left";
+			}
+			//相反方向击打
+			//正方向
+			else if (curAngle > 180 && curAngle <= 250) {
+				directionPunch = "rightPunch";
+				name = "负向的右拳";
+				ename = "back-right";
+			}
+			else if (curAngle > 250 && curAngle <= 290) {
+				directionPunch = "straightPunch";
+				name = "负向的直拳";
+				ename = "back-straight";
+			} else if (curAngle > 290 && curAngle <= 360) {
+				directionPunch = "leftPunch";
+				name = "负向的左拳";
+				ename = "back-left";
+			}
+
+
+			this.quitHitCount++;
+
+			let temp = {
+				type: 'hit',
+				hit: curDirection.length,
+				hitCount: this.quitHitCount,
+				direction: directionPunch,
+				directionVect: {
+					'x': curDirection.x,
+					'y': curDirection.y
+				},
+				angle: curAngle,
+				name: name,
+				ename: ename
+			}
+			return temp;
+
+		}
+	}
+};

+ 244 - 8
util/util-js/store.js

@@ -8,6 +8,7 @@ import BLE from 'util/util-js/BLE.js';
 //快速打击部分
 //快速打击部分
 import o0 from "@/util/util-js/o0.js"
 import o0 from "@/util/util-js/o0.js"
 import o0Project from "@/util/util-js/o0Project.js"
 import o0Project from "@/util/util-js/o0Project.js"
+import o0ProjectRelease from "@/util/util-js/o0ProjectRelease0.1.js"
 
 
 import deviceData from "@/util/util-js/devices.js"
 import deviceData from "@/util/util-js/devices.js"
 
 
@@ -152,7 +153,20 @@ const store = new Vuex.Store({
 
 
 
 
 		//绑定的设备
 		//绑定的设备
-		DeviceBindingList: [],
+		DeviceBindingList: [{
+			id: 0,
+			cname: "开启手机数据",
+			ename: "bindMobilePhoneBandage",
+			icon: "/static/devicesIcon/bandage.png",
+			mIcon: "/static/devicesIcon/bandage.png",
+			bRatio: false,
+			usageMode: 'bindPhone',
+			describe: '手机情景下使用',
+			limitType: 'rebound', //限制回弹版本
+			deviceType: 'mySelf', //指的是使用手机本身加速计计算
+			deviceName: 'PHONE', //连接硬件名称
+
+		}],
 		ConnectBindingDevice: null,
 		ConnectBindingDevice: null,
 
 
 		cIndex: -1,
 		cIndex: -1,
@@ -214,6 +228,22 @@ const store = new Vuex.Store({
 
 
 		globalAcc: null,
 		globalAcc: null,
 		globalOri: null,
 		globalOri: null,
+		globalAccData: {
+			ax: 0,
+			ay: 0,
+			az: 0
+		},
+		globalGyroData: {
+			gx: 0,
+			gy: 0,
+			gz: 0
+		},
+		globalLastGyroData: {
+			gx: 0,
+			gy: 0,
+			gz: 0
+		},
+		globalMyAttitude: null,
 
 
 		//当前显示的模式下标
 		//当前显示的模式下标
 		currentModeIndex: 0,
 		currentModeIndex: 0,
@@ -258,6 +288,10 @@ const store = new Vuex.Store({
 		filter: null,
 		filter: null,
 		deviceMs: 1,
 		deviceMs: 1,
 
 
+		//改进版的沙袋打击对象
+		sandbagAlgorithm: null,
+		sandbagAlgorithmLastTime: new Date().getTime(),
+
 
 
 		/**
 		/**
 		 * 蓝牙参数对象
 		 * 蓝牙参数对象
@@ -274,6 +308,7 @@ const store = new Vuex.Store({
 		bListenerUpdate: false,
 		bListenerUpdate: false,
 		bListenerJson: false,
 		bListenerJson: false,
 		bListenerMac: false,
 		bListenerMac: false,
+		bListenerAccArray: false,
 
 
 		/**
 		/**
 		 * 发送16进制时候,返回的刷新数据
 		 * 发送16进制时候,返回的刷新数据
@@ -1391,6 +1426,8 @@ const store = new Vuex.Store({
 			state.bListenerJson = false;
 			state.bListenerJson = false;
 
 
 			state.bListenerMac = false;
 			state.bListenerMac = false;
+
+			state.bListenerAccArray = false;
 			//更新二进制的
 			//更新二进制的
 			state.bListenerHexUpdate = false;
 			state.bListenerHexUpdate = false;
 
 
@@ -1772,6 +1809,107 @@ const store = new Vuex.Store({
 
 
 			state.filter.Update(new o0.Vector3(ax, ay, az), msGap, new o0.Vector3(gx, gy, gz), callback); //我自己的更新acc的函数
 			state.filter.Update(new o0.Vector3(ax, ay, az), msGap, new o0.Vector3(gx, gy, gz), callback); //我自己的更新acc的函数
 		},
 		},
+
+		/**
+		 * 创建一个沙袋打击对象
+		 * @param {Object} state
+		 */
+		gCreateSandbagAlgorithm(state) {
+			state.sandbagAlgorithm = null;
+			state.sandbagAlgorithmLastTime = new Date().getTime();
+			state.sandbagAlgorithm = new o0ProjectRelease.SandbagAlgorithm();
+			console.log("gCreateSandbagAlgorithm");
+		},
+		/**
+		 * 更新 沙袋打击对象 数据
+		 * @param {Object} state
+		 * @param {Object} context
+		 */
+		gUpdateSandbagAlgorithm(state, context) {
+
+			let {
+				data,
+				callback = null
+			} = context;
+
+			let {
+				ax,
+				ay,
+				az
+			} = data.acc;
+
+			let {
+				gx,
+				gy,
+				gz
+			} = data.gyro;
+			let [hit, dir] = state.sandbagAlgorithm.Update(ax / 10, az / 10, gz, -gx, data.ms);
+			if (dir != undefined) {
+				let temp = state.sandbagAlgorithm.getTempValue(dir);
+				if (callback) {
+					callback(temp);
+				}
+			}
+		},
+
+		/**
+		 * 开启加速计,陀螺仪,并且模拟ble发送
+		 * @param {Object} state
+		 */
+		gStartSimulateBLEUpdate(state) {
+
+			//todo 区分平台,目前是android 模块
+
+			if (state.globalMyAttitude == null) {
+				state.globalMyAttitude = uni.requireNativePlugin("MyAttitude");
+
+				let globalEvent = uni.requireNativePlugin('globalEvent');
+				globalEvent.addEventListener('updateAccAndGyro', function(e) {
+					//updateAccAndGyro{"accelerometer":[-0.178375244140625,9.327804565429688,2.6168670654296875],"gyroscope":[0.0018310546875,-0.0019989013671875,0.0027923583984375]}
+					//console.log('updateAccAndGyro' + JSON.stringify(e));
+					let _accArray = e.accelerometer;
+					let _gyroArray = e.gyroscope;
+
+					state.globalAccData.ax = _accArray[0];
+					state.globalAccData.ay = _accArray[1];
+					state.globalAccData.az = _accArray[2];
+
+					state.globalGyroData.gx = _gyroArray[0];
+					state.globalGyroData.gy = _gyroArray[1];
+					state.globalGyroData.gz = _gyroArray[2];
+
+					let box = {};
+					box["acc"] = state.globalAccData;
+					box["gyro"] = state.globalGyroData;
+					box["ms"] = e.ms;
+					//更新数据给webview,在game-play-web||game-play-sub绑定
+					//后面更新数据都用此接口
+					uni.$emit('updateBLEDeviceData', box);
+				});
+			}
+
+			var ret = state.globalMyAttitude.onStartAccAndGyro();
+			if (!ret.accelerometer || !ret.gyroscope) {
+				uni.showModal({
+					title: '提示',
+					content: '是否初始化,加速计:' + ret.accelerometer + ',陀螺仪:' + ret.gyroscope
+				})
+			}
+			console.log('gStartSimulateBLEUpdate:', ret);
+
+		},
+		/**
+		 * 停止加速计,陀螺仪
+		 * @param {Object} state
+		 */
+		gStopSimulateBLEUpdate(state) {
+			//todo 区分平台,目前是android 模块
+			let globalEvent = uni.requireNativePlugin('globalEvent');
+			globalEvent.removeEventListener('updateAccAndGyro');
+			var ret = state.globalMyAttitude.onStopAccAndGyro();
+			console.log('gStopSimulateBLEUpdate:', ret);
+			state.globalMyAttitude = null;
+		},
 		/**
 		/**
 		 * 限制开始游戏
 		 * 限制开始游戏
 		 */
 		 */
@@ -2187,6 +2325,96 @@ const store = new Vuex.Store({
 					box["Json"] = resValueStr;
 					box["Json"] = resValueStr;
 					uni.$emit('updateBLEDeviceJson', box);
 					uni.$emit('updateBLEDeviceJson', box);
 				}
 				}
+
+				//解析4组加速计数据
+				if (state.bListenerAccArray) {
+					let ms1 = BLE.hex2int(resValue.substr(2, 4));
+					let min1 = BLE.hex2int(resValue.substr(6, 2));
+					let s1 = BLE.hex2int(resValue.substr(8, 2));
+					let ax1Str = resValue.substr(10, 4);
+					let ay1Str = resValue.substr(14, 4);
+					let az1Str = resValue.substr(18, 4);
+					let ax1 = BLE.hexToSignedInt(ax1Str) / 32768 * 16;
+					let ay1 = BLE.hexToSignedInt(ay1Str) / 32768 * 16;
+					let az1 = BLE.hexToSignedInt(az1Str) / 32768 * 16;
+
+					let ms2 = BLE.hex2int(resValue.substr(22, 4));
+					let min2 = BLE.hex2int(resValue.substr(26, 2));
+					let s2 = BLE.hex2int(resValue.substr(28, 2));
+					let ax2Str = resValue.substr(30, 4);
+					let ay2Str = resValue.substr(34, 4);
+					let az2Str = resValue.substr(38, 4);
+					let ax2 = BLE.hexToSignedInt(ax2Str) / 32768 * 16;
+					let ay2 = BLE.hexToSignedInt(ay2Str) / 32768 * 16;
+					let az2 = BLE.hexToSignedInt(az2Str) / 32768 * 16;
+
+					let ms3 = BLE.hex2int(resValue.substr(42, 4));
+					let min3 = BLE.hex2int(resValue.substr(46, 2));
+					let s3 = BLE.hex2int(resValue.substr(48, 2));
+					let ax3Str = resValue.substr(50, 4);
+					let ay3Str = resValue.substr(54, 4);
+					let az3Str = resValue.substr(58, 4);
+					let ax3 = BLE.hexToSignedInt(ax3Str) / 32768 * 16;
+					let ay3 = BLE.hexToSignedInt(ay3Str) / 32768 * 16;
+					let az3 = BLE.hexToSignedInt(az3Str) / 32768 * 16;
+
+					let ms4 = BLE.hex2int(resValue.substr(62, 4));
+					let min4 = BLE.hex2int(resValue.substr(66, 2));
+					let s4 = BLE.hex2int(resValue.substr(68, 2));
+					let ax4Str = resValue.substr(70, 4);
+					let ay4Str = resValue.substr(74, 4);
+					let az4Str = resValue.substr(78, 4);
+					let ax4 = BLE.hexToSignedInt(ax4Str) / 32768 * 16;
+					let ay4 = BLE.hexToSignedInt(ay4Str) / 32768 * 16;
+					let az4 = BLE.hexToSignedInt(az4Str) / 32768 * 16;
+
+					let accArray= [{
+						ax: ax1,
+						ay: ay1,
+						az: az1,
+						ms: ms1,
+						min: min1,
+						s: s1
+					}, {
+						ax: ax2,
+						ay: ay2,
+						az: az2,
+						ms: ms2,
+						min: min2,
+						s: s2
+					}, {
+						ax: ax3,
+						ay: ay3,
+						az: az3,
+						ms: ms3,
+						min: min3,
+						s: s3
+					}, {
+						ax: ax4,
+						ay: ay4,
+						az: az4,
+						ms: ms4,
+						min: min4,
+						s: s4
+					}]
+					
+					for(let i=0 ;i<accArray.length;i++){
+						let _temp = accArray[i];
+						box["acc"] = {
+							ax:_temp.ax,
+							ay:_temp.ay,
+							az:_temp.az,
+						};
+						box["min"] = _temp.min;
+						box["s"] = _temp.s;
+						box["ms"] = _temp.ms;
+						
+						uni.$emit('updateBLEDeviceData', box);
+					}
+					
+				}
+
+
 				//原始数据解析
 				//原始数据解析
 				if (state.bListenerUpdate) {
 				if (state.bListenerUpdate) {
 					//R/L 左手还是右手
 					//R/L 左手还是右手
@@ -2261,7 +2489,7 @@ const store = new Vuex.Store({
 						if (byteArray[0] == '00') {
 						if (byteArray[0] == '00') {
 
 
 							state.bRopeKeyOne = 1;
 							state.bRopeKeyOne = 1;
-						}else {
+						} else {
 							//'01'
 							//'01'
 							state.bRopeKeyTwo = 1;
 							state.bRopeKeyTwo = 1;
 
 
@@ -2318,10 +2546,10 @@ const store = new Vuex.Store({
 			}
 			}
 			let _sendData;
 			let _sendData;
 			if (bSendHex) {
 			if (bSendHex) {
-				
+
 				state.bRopeKeyTwo = 0;
 				state.bRopeKeyTwo = 0;
 				state.bRopeKeyOne = 0;
 				state.bRopeKeyOne = 0;
-				
+
 				//如果是发送16进制
 				//如果是发送16进制
 				state.bListenerHexUpdate = true;
 				state.bListenerHexUpdate = true;
 
 
@@ -2358,16 +2586,24 @@ const store = new Vuex.Store({
 				}
 				}
 
 
 				if (value == "6") {
 				if (value == "6") {
-					state.bListenerJson = false;
+					// state.bListenerJson = false;
+					state.bListenerAccArray = false;
 				}
 				}
 				if (value == "5") {
 				if (value == "5") {
-					if (state.bListenerJson) {
+					// if (state.bListenerJson) {
+					// 	uni.showToast({
+					// 		title: "步数数据已开启"
+					// 	})
+					// 	return;
+					// }
+					// state.bListenerJson = true;
+					if (state.bListenerAccArray) {
 						uni.showToast({
 						uni.showToast({
-							title: "步数数据已开启"
+							title: "加速计组数据已开启"
 						})
 						})
 						return;
 						return;
 					}
 					}
-					state.bListenerJson = true;
+					state.bListenerAccArray = true;
 				}
 				}
 
 
 				_sendData = BLE.str2ab(value);
 				_sendData = BLE.str2ab(value);