浏览代码

1.算法计算

slambb 3 年之前
父节点
当前提交
d6ec82dc4a

+ 2 - 5
common/config.js

@@ -11,11 +11,7 @@ const active = "dev";
 //测试地址,阿里云服务器
 // const host = "https://www.9527fun.cn/api_dev"
 //本地测试地址
-const host = "http://192.168.1.12:9090/api_dev"
-// const host = "http://192.168.0.112:9090/api_dev"
-// const host = "http://47.104.216.192:9090/api_dev"
-// const host = "http://121.4.103.151:9090/api_prd"
-// const host = "http://121.4.59.141:9090/api_dev"
+const host = "http://192.168.0.108:9090/api_dev"
 
 const URL = {
 	//验证token,获取服务器返回的信息
@@ -152,6 +148,7 @@ const URL = {
 	 */
 	GAMELIST_FROM_CATEGORY: `${host}/game/list_from_category`,
 	GAMELIST_FROM_CATEGORY_PLATFORM: `${host}/game/list_from_category_platform`,
+	GAMELISTBYTAG: `${host}/game/listByTag`,
 
 	//根据游戏显示获取游戏列表
 	GAMELIST_BY_RANKING_SHOW: `${host}/game/list_by_ranking_show`,

+ 1 - 0
components/modal/action-hit/action-hit.vue

@@ -406,6 +406,7 @@
 			console.log("组件创建")
 		},
 		beforeDestroy() {
+			let _self = this;
 			if (_self.hookAudioContext)
 				_self.hookAudioContext.destroy();
 			

+ 11 - 5
components/modal/action-jump/action-jump.vue

@@ -148,7 +148,7 @@
 </template>
 
 <script>
-	import ActionJump from "@/util/util-js/action/jump-0.2.js"
+	import ActionJump from "@/util/util-js/action/jump-0.3.js"
 	import {
 		CONDITIONPASSED
 	} from "@/util/util-js/enum.js"
@@ -428,9 +428,11 @@
 				this.averageSpeed = this.tempHitCount;
 				this.tempHitCount = 0;
 			}, 3000)
+
 		},
+		beforeDestroy() {},
 		methods: {
-			...mapMutations(['onWriteBLEConnectionValue', 'onConvertDeviceData']),
+			...mapMutations(['onWriteBLEConnectionValue', 'onConvertDeviceData', "onSendSocketMessage"]),
 			//更新新手状态提示
 			onUpdateTipLevelValue(value) {
 				this.bTipLevel = value;
@@ -446,8 +448,6 @@
 					} else if (e.type == 'stop') {
 						console.log("stop");
 						this.onClearData();
-						this.actionJumpObj.resetAll();
-
 						if (this.canOnDraw) {
 							this.canOnDraw = false;
 							// //这里更新特效
@@ -473,6 +473,8 @@
 							console.error(e.data);
 						} else if (e.logType == 'warn') {
 							console.warn(e.data);
+						} else if (e.logType == 'socket') {
+							this.onSendSocketMessage(e.data);
 						}
 					}
 				})
@@ -1231,6 +1233,7 @@
 			//监听跳的状态数据
 			listenStateDataOfJump(data) {
 
+				console.log(JSON.stringify(data));
 				if (this.spawnArray.length < 3) return;
 				let _jumpType = this.getCurrentJumpType();
 				//初始全部默认状态
@@ -1274,7 +1277,7 @@
 					valleyOfWaveMinValue
 				} = data
 				// console.log('stateDataOfJump:');
-				// console.log(JSON.stringify(data));
+
 				this.onLogData = data;
 				let _rotateLimit = 4;
 				let _jumpLimit = 0;
@@ -1438,6 +1441,9 @@
 				let _ay = gameData.acc.ay * 10;
 				let _az = gameData.acc.az * 10;
 				//低通滤波分离重力
+				// alpha 由 t / (t + dT)得到
+				// t为滤波器时间常量,为传感器单次采样时间
+				// dT为采样频率
 				let alpha = 0.8;
 				this.xA = alpha * this.xA + (1 - alpha) * _ax;
 				this.yA = alpha * this.yA + (1 - alpha) * _ay;

+ 2 - 2
manifest.json

@@ -2,8 +2,8 @@
     "name" : "哔蹦",
     "appid" : "__UNI__2635DF5",
     "description" : "",
-    "versionName" : "2.5.35",
-    "versionCode" : 22080802,
+    "versionName" : "2.5.37",
+    "versionCode" : 22081801,
     "transformPx" : false,
     /* 5+App特有相关 */
     "app-plus" : {

+ 57 - 35
pages/game-page/game-list/game-list.vue

@@ -1,13 +1,12 @@
 <template>
 	<view>
 		<!--  rgba(116, 172, 240, 1) -->
-		<uni-nav-bar id="nav-bar" status-bar="true" backgroundColor="rgba(153, 150, 252, 255)"
-		<!-- #ifdef APP-PLUS -->
-		@clickLeft="showDrawer()" 
-		<!-- #endif -->
-		<!-- #ifdef H5 || MP-WEIXIN -->
-		@clickLeft="showClickEvent('DrawerModalL')"
-		<!-- #endif -->
+		<uni-nav-bar id="nav-bar" status-bar="true" backgroundColor="rgba(153, 150, 252, 255)" <!-- #ifdef APP-PLUS -->
+			@clickLeft="showDrawer()"
+			<!-- #endif -->
+			<!-- #ifdef H5 || MP-WEIXIN -->
+			@clickLeft="showClickEvent('DrawerModalL')"
+			<!-- #endif -->
 			@clickRight="onNavHome" title="游戏" color="#FFFFFF" fixed="true">
 			<view slot="left">
 				<view class=" flex align-center margin-left">
@@ -23,8 +22,7 @@
 
 		<!-- v-if="(cIndex != -1 && gameShow)||ConnectBindingDevice" -->
 		<scroll-view scroll-y="true" :style="{ height: scrollviewHight + 'px' }" @scrolltolower="lower">
-			<view  class="game-item card-view"
-				v-for="(item, index) in gameList" :key="index" :data-id="index">
+			<view class="game-item card-view" v-for="(item, index) in gameList" :key="index" :data-id="index">
 				<view @tap="onNavToWebviewGame(item)">
 					<view class="game-image-container">
 						<image mode="aspectFill" class="game-item-image" :src="item.gamePicture"></image>
@@ -65,8 +63,7 @@
 				</view>
 			</view>
 			<!-- (cIndex == -1 && !gameShow) ||gameList.length == 0 || ConnectBindingDevice == null-->
-			<view v-if="gameList.length == 0"
-				class="text-16px text-gray text-center margin">没有更多数据</view>
+			<view v-if="gameList.length == 0" class="text-16px text-gray text-center margin">没有更多数据</view>
 			<view style="height: 17px;"></view>
 		</scroll-view>
 
@@ -95,8 +92,9 @@
 			uniNavBar,
 			sideBar
 		},
-		computed: mapState(['ConnectBindingDevice', 'BLEConnectDevice', 'cIndex', 'versionCodeState', 'platform',
-			'gamePlatform','systemInfo','navHeight','tabbarHeight'
+		computed: mapState(['ConnectBindingDevice', 'BLEConnectDevice', 'currentModeIndex', 'cIndex', 'versionCodeState',
+			'platform',
+			'gamePlatform', 'systemInfo', 'navHeight', 'tabbarHeight'
 		]),
 		data() {
 			return {
@@ -123,22 +121,7 @@
 		},
 		onLoad(option) {
 			let _this = this;
-			let _index = 1;
-			//获得游戏类目
-			reqUtil.requestData(config.URL.GAMECATEGORY).then(
-				res => {
-					console.log('GAMECATEGORY =====', res);
-					if (res.code == 0) {
-						this.tabList = res.data;
-						this.TabCur = _index; //game
-						this.categoryType = this.tabList[_index].categoryType;
-						this.getGameList(this.categoryType);
-					}
-				},
-				e => {
-					console.log(e);
-				}
-			);
+
 
 		},
 		onReady() {
@@ -146,8 +129,35 @@
 			// 计算组件的高度
 			this.scrollviewHight = phoneHeight - this.navHeight - this.tabbarHeight - this.systemInfo.statusBarHeight;
 		},
+		onShow() {
+			let _index = 1;
+			this.bDontUpdate = false;
+			this.gameList = [];
+			this.gamePage = 1;
+			if (this.tabList.length == 0) {
+				//获得游戏类目
+				reqUtil.requestData(config.URL.GAMECATEGORY).then(
+					res => {
+						console.log('GAMECATEGORY =====', res);
+						if (res.code == 0) {
+							this.tabList = res.data;
+							this.TabCur = _index; //game
+							this.categoryType = this.tabList[_index].categoryType;
+							this.getGameList(this.categoryType);
+						}
+					},
+					e => {
+						console.log(e);
+					}
+				);
+			} else {
+				//如果存在分类
+				this.getGameList(this.categoryType);
+			}
+
+		},
 		methods: {
-			...mapMutations(['glimitPlayGame','showDrawerById']),
+			...mapMutations(['glimitPlayGame', 'showDrawerById']),
 			// 跳转转换页面
 			onNavConver() {
 				uni.reLaunch({
@@ -271,7 +281,7 @@
 								console.log('GAMEDETAIL =====', res);
 								if (res.code == 0) {
 									this.encodeItem = encodeURIComponent(JSON.stringify(res.data
-									.gameInfo));
+										.gameInfo));
 
 									// #ifdef APP-PLUS
 									uni.navigateTo({
@@ -310,17 +320,29 @@
 					mask: true,
 					duration: 10000
 				})
+				let tagId = 3; //默认是普通模式,普通模式可以用手机直接玩
+				if (this.BLEConnectDevice != null) {
+					if (1 === this.currentModeIndex) {
+						//关卡是跳绳
+						tagId = 4; // rope 标签
+					} else if (0 === this.currentModeIndex) {
+						//关卡是拳击
+						tagId = 1; //hotman模式 标签
+
+					}
+				}
 				//获得游戏列表
 				reqUtil.requestData(
-					config.URL.GAMELIST_FROM_CATEGORY_PLATFORM, {
+					config.URL.GAMELISTBYTAG, {
 						categoryType: categoryType,
 						//endTime 可以不设置,服务器默认设置一个值
-						endTime: config.endTime,
+						// endTime: config.endTime,
+						tagId: tagId,
 						page: this.gamePage,
 						size: this.gameSize
-					}
+					}, "POST"
 				).then(res => {
-						console.log('GAMELIST_FROM_CATEGORY_PLATFORM =====', res);
+						console.log('GAMELISTBYTAG =====', res);
 						if (res.code == 0) {
 							uni.hideToast();
 

+ 28 - 19
pages/game-page/game-play-sub/subGame/subGame.nvue

@@ -3,7 +3,7 @@
 		<!-- :src="url" src = 'http://192.168.0.112:7456/build/index.html' :src="LocationGameUrl" -->
 		<!-- @receivedtitle="onReceivedTitle"   @pagefinish="onPageFinish" http://192.168.31.223:7456/-->
 		<view class="web-view">
-			<web-view class="web-view-child" src='http://192.168.1.12:7456/' ref="webview" @pagestart="onPageStart"
+			<web-view class="web-view-child" :src="url" ref="webview" @pagestart="onPageStart"
 				@onPostMessage="handlePostMessage" @error="onError"></web-view>
 		</view>
 
@@ -164,12 +164,12 @@
 					});
 
 					uni.$off('updateBLEDeviceData', _self.gWatchBLEUpdate);
-					
+
 					if (0 === _self.currentModeIndex) {
 						//拳击柱
 						_self.uploadUserData_hitCount();
-					} 
-					
+					}
+
 				} //关闭跳绳模式指令
 				else if (_self.BLEConnectDevice && _self.BLEConnectDevice.deviceType == "BLERope") {
 					console.warn("还没设置关闭跳绳模式")
@@ -216,7 +216,7 @@
 			...mapMutations(['addlocalCalorie', 'syncRequestEvent', 'onWriteBLEConnectionValue',
 				'gCreateFilterObj', 'gUpdateFilter', 'B_OpenRopeSkipping', 'B_CloseRopeSkipping',
 				'gStopSimulateBLEUpdate', 'gStartSimulateBLEUpdate', 'gUpdateSandbagAlgorithm',
-				'gCreateSandbagAlgorithm', 'onConvertDeviceData','addSandbagHitCount','uploadUserData_hitCount'
+				'gCreateSandbagAlgorithm', 'onConvertDeviceData', 'addSandbagHitCount', 'uploadUserData_hitCount'
 			]),
 			navBack() {
 
@@ -313,7 +313,7 @@
 			 * 初始化发送数据给游戏
 			 */
 			sendGameInit() {
-				console.log("this.avatarUrl:",this.avatarUrl);
+				console.log("this.avatarUrl:", this.avatarUrl);
 				this.urlToBase64(this.avatarUrl, (toBase64Url) => {
 					let device = null;
 					/**
@@ -447,7 +447,7 @@
 								bMaxLimit: true
 							}
 							console.log('_temp =====', _temp);
-							
+
 							reqUtil.requestData(config.URL.UPLOADRANKING, _temp, "POST").then(res => {
 									console.log('UPLOADRANKING =====', res);
 									if (res.code == 0) {
@@ -848,7 +848,9 @@
 							if (res.type == 'hit') {
 								// console.log('gUpdateFilter callback:',res)
 								//记录打击次数
-								this.addSandbagHitCount({count:1});
+								this.addSandbagHitCount({
+									count: 1
+								});
 								let temp = {
 									direction: res.direction,
 									angle: res.angle,
@@ -909,7 +911,9 @@
 							if (res.type == 'hit') {
 								// console.log('gUpdateFilter callback:',res)
 								//记录打击次数
-								this.addSandbagHitCount({count:1});
+								this.addSandbagHitCount({
+									count: 1
+								});
 								let temp = {
 									direction: res.direction,
 									angle: res.angle,
@@ -936,15 +940,20 @@
 					// 	hitPower: 10 //计算的力
 					// }
 					// this.sendMessage("onBoxingPostHit", temp);
-					this.onConvertDeviceData({
-						data: data,
-						callback: (outData) => {
-							data.acc = outData.convertAcc;
-							data.gyro = outData.convertGyro;
-							//跳绳蓝牙反馈
-							this.onBLERopeUpdate(data);
-						}
-					});
+
+					//转换*********
+					// this.onConvertDeviceData({
+					// 	data: data,
+					// 	callback: (outData) => {
+					// 		data.acc = outData.convertAcc;
+					// 		data.gyro = outData.convertGyro;
+					// 		//跳绳蓝牙反馈
+					// 		this.onBLERopeUpdate(data);
+					// 	}
+					// });
+
+					//跳绳蓝牙反馈
+					this.onBLERopeUpdate(data);
 				}
 			},
 
@@ -1124,7 +1133,7 @@
 						oGyroZ: gz
 					},
 					//输入当前轴,旧设备使用Y轴,即为true
-					bYAxis: this.bOldDeviceType?true:false,
+					bYAxis: this.bOldDeviceType ? true : false,
 				};
 				this.actionJumpObj.updateJump(_temp);
 				this.BLEAccIndex++;

+ 44 - 23
pages/game-page/game-video/game-video.vue

@@ -89,7 +89,7 @@
 			uniNavBar,
 			sideBar
 		},
-		computed: mapState(['ConnectBindingDevice', 'BLEConnectDevice', 'cIndex','versionCodeState','platform','gamePlatform',
+		computed: mapState(['ConnectBindingDevice', 'BLEConnectDevice','currentModeIndex', 'cIndex','versionCodeState','platform','gamePlatform',
 		'systemInfo','navHeight','tabbarHeight']),
 		data() {
 			return {
@@ -115,31 +115,40 @@
 			};
 		},
 		onLoad(option) {
-		
 			let _this = this;
-			let _index = 2;
-			//获得游戏类目
-			reqUtil.requestData(config.URL.GAMECATEGORY).then(
-				res => {
-					console.log('GAMECATEGORY =====', res);
-					if (res.code == 0) {
-						this.tabList = res.data;
-						this.TabCur = _index;	//video
-						this.categoryType = this.tabList[_index].categoryType;
-						this.getGameList(this.categoryType);
-					}
-				},
-				e => {
-					console.log(e);
-				}
-			);
-
 		},
 		onReady() {
 			let phoneHeight = this.systemInfo.windowHeight;
 			// 计算组件的高度
 			this.scrollviewHight = phoneHeight - this.navHeight - this.tabbarHeight - this.systemInfo.statusBarHeight;
 		},
+		onShow() {
+			let _index = 2;
+			this.bDontUpdate = false;
+			this.gameList = [];
+			this.gamePage = 1;
+			if (this.tabList.length == 0) {
+				//获得游戏类目
+				reqUtil.requestData(config.URL.GAMECATEGORY).then(
+					res => {
+						console.log('GAMECATEGORY =====', res);
+						if (res.code == 0) {
+							this.tabList = res.data;
+							this.TabCur = _index;	//video
+							this.categoryType = this.tabList[_index].categoryType;
+							this.getGameList(this.categoryType);
+						}
+					},
+					e => {
+						console.log(e);
+					}
+				);
+			} else {
+				//如果存在分类
+				this.getGameList(this.categoryType);
+			}
+		
+		},
 		methods: {
 			...mapMutations(['glimitPlayGame','showDrawerById']),
 			// 跳转转换页面
@@ -302,17 +311,29 @@
 					mask: true,
 					duration: 10000
 				})
+				let tagId = 3; //默认是普通模式,普通模式可以用手机直接玩
+				if (this.BLEConnectDevice != null) {
+					if (1 === this.currentModeIndex) {
+						//关卡是跳绳
+						tagId = 4; // rope 标签
+					} else if (0 === this.currentModeIndex) {
+						//关卡是拳击
+						tagId = 1; //hotman模式 标签
+				
+					}
+				}
 				//获得游戏列表
 				reqUtil.requestData(
-					config.URL.GAMELIST_FROM_CATEGORY_PLATFORM, {
+					config.URL.GAMELISTBYTAG, {
 						categoryType: categoryType,
 						//endTime 可以不设置,服务器默认设置一个值
-						endTime: config.endTime,
+						// endTime: config.endTime,
+						tagId:tagId,
 						page: this.gamePage,
 						size: this.gameSize
-					}
+					},"POST"
 				).then(res => {
-						console.log('GAMELIST_FROM_CATEGORY_PLATFORM =====', res);
+						console.log('GAMELISTBYTAG =====', res);
 						if (res.code == 0) {
 							uni.hideToast();
 

+ 240 - 31
pages/personal-page/personal/personal.vue

@@ -38,17 +38,19 @@
 					<!-- 计划显示 区域 topScrollHight :style="{ height: + '100%' }"-->
 					<scroll-view scroll-y="true" style="height: 100%; width: 100%;">
 						<view class="plan-view">
-							<view class="text-white text-center" style="background-color: RGBA(30, 30, 85, 1);  z-index: 10;">今日击打次数:{{sandbagHitCount}}</view>
-							
+							<view class="text-white text-center"
+								style="background-color: RGBA(30, 30, 85, 1);  z-index: 10;">今日击打次数:{{sandbagHitCount}}
+							</view>
+
 							<!-- #ifdef H5 -->
 							<button @click="onAddSandbagHitCount()">add</button>
 							<button @click="onReset()">onReset</button>
 							<button @click="getUserData_hitCount()">getUserData_hitCount</button>
 							<button @click="uploadUserData_hitCount()">uploadUserData_hitCount</button>
-							
+							<button @click="onSendMsg()">onSendMsg</button>
 							<!-- #endif -->
-							
-							
+
+
 							<!-- pk模式下的跳绳 v-if="1 === currentModeIndex"-->
 							<view v-if="currentMode == 'pkMode'" class="position-relative"
 								style="height: 128rpx; background-color: RGBA(30, 30, 85, 1);  z-index: 10;">
@@ -189,7 +191,7 @@
 												hiddenType: 'firstInstallation'
 											})">计划</button>
 			</view> -->
-			
+
 			<view style="height: 50rpx;"></view>
 		</scroll-view>
 
@@ -874,7 +876,7 @@
 			uni.$on("onLog", this.onLog);
 			//人物列表变化处理监听
 			uni.$on("onSwitchTaskList", this.onSwitchTaskList);
-			
+
 			//获取对应的用户数据,并且设置记录的打击数据
 			this.getUserData_hitCount();
 		},
@@ -966,6 +968,8 @@
 			}
 
 			// #endif
+			
+			this.onConnectSocket();
 		},
 		onUnload() {
 			console.log("personal ********* onUnload *********");
@@ -989,6 +993,7 @@
 
 			uni.$off("onShowFirstInstallation", this.onShowFirstInstallation);
 
+			this.onCloseSocket();
 		},
 		onHide() {
 			_self.bHide = true;
@@ -1020,8 +1025,9 @@
 				'setGuideUnlockState',
 				'resetActionJumpTask',
 				'getUserData_hitCount',
-				'uploadUserData_hitCount','getUserData_hitCount',
+				'uploadUserData_hitCount', 'getUserData_hitCount',
 				'addSandbagHitCount',
+				,'onConnectSocket','onCloseSocket','onSendSocketMessage'
 			]),
 			BasicsSteps() {
 				this.basics = this.basics == this.basicsList.length - 1 ? 0 : this.basics + 1
@@ -1416,22 +1422,23 @@
 					//这个是普通打击模式
 					this.$refs.boxingPostRef.onBLEHandleUpdate(data);
 				} else if (this.BLEConnectDevice.usageMode == "ropeSkipping") {
+					
+					this.$refs.actionJumpRef.onBLERopeUpdate(data);
+					// this.onConvertDeviceData({
+					// 	data: data,
+					// 	callback: (outData) => {
+					// 		// this.outBLEData = {
+					// 		// 	acc: outData.convertAcc,
+					// 		// 	gyro: outData.convertGyro
+					// 		// }
+					// 		// console.log(JSON.stringify(outData),JSON.stringify(data));
+					// 		data.acc = outData.convertAcc;
+					// 		data.gyro = outData.convertGyro;
+					// 		//跳绳蓝牙反馈
+					// 		this.$refs.actionJumpRef.onBLERopeUpdate(data);
 
-					this.onConvertDeviceData({
-						data: data,
-						callback: (outData) => {
-							// this.outBLEData = {
-							// 	acc: outData.convertAcc,
-							// 	gyro: outData.convertGyro
-							// }
-							// console.log(JSON.stringify(outData),JSON.stringify(data));
-							data.acc = outData.convertAcc;
-							data.gyro = outData.convertGyro;
-							//跳绳蓝牙反馈
-							this.$refs.actionJumpRef.onBLERopeUpdate(data);
-
-						}
-					});
+					// 	}
+					// });
 
 				}
 
@@ -2524,7 +2531,7 @@
 				if (0 === this.currentModeIndex) {
 					//拳击柱
 					this.onAddSandbagHitCount();
-				} 
+				}
 				// else if (1 === this.currentModeIndex) {
 				// 	//跳
 				// }
@@ -2608,12 +2615,12 @@
 					console.log('onActionJumpGameOver 任务结束');
 
 					this.bGamePlaying = false;
-					
+
 					//同步到数据库
 					if (0 === this.currentModeIndex) {
 						//拳击柱
 						this.uploadUserData_hitCount();
-					} 
+					}
 				}
 
 
@@ -3184,13 +3191,215 @@
 				});
 				this.setGuideUnlockState(guideUnlockState);
 			},
-			
-			
-			onAddSandbagHitCount(){
-				this.addSandbagHitCount({count:1});
+
+
+			onAddSandbagHitCount() {
+				this.addSandbagHitCount({
+					count: 1
+				});
 			},
-			onReset(){
+			onReset() {
 				this.$store.state.sandbagHitCount = 0;
+			},
+			
+			onSendMsg(){
+				let msg = [{
+					"maxValue": 19.267578125,
+					"gyroValue": -1172.607421875,
+					"resultant": 23.36043492594914,
+					"index": 98,
+					"acc": {
+						"oAccX": 10.2587890625,
+						"oAccY": -8.3203125,
+						"oAccZ": -19.267578125
+					},
+					"gyro": {
+						"oGyroX": -13.0615234375,
+						"oGyroY": -1172.607421875,
+						"oGyroZ": -42.66357421875
+					}
+				}, {
+					"maxValue": 19.267578125,
+					"gyroValue": -1172.607421875,
+					"resultant": 23.36043492594914,
+					"index": 99,
+					"acc": {
+						"oAccX": 10.2587890625,
+						"oAccY": -8.3203125,
+						"oAccZ": -19.267578125
+					},
+					"gyro": {
+						"oGyroX": -13.0615234375,
+						"oGyroY": -1172.607421875,
+						"oGyroZ": -42.66357421875
+					}
+				}, {
+					"maxValue": 6.58203125,
+					"gyroValue": -1144.59228515625,
+					"resultant": 8.733990874058362,
+					"index": 100,
+					"acc": {
+						"oAccX": 3.740234375,
+						"oAccY": -4.35546875,
+						"oAccZ": -6.58203125
+					},
+					"gyro": {
+						"oGyroX": -26.91650390625,
+						"oGyroY": -1144.59228515625,
+						"oGyroZ": -45.10498046875
+					}
+				}, {
+					"maxValue": 6.58203125,
+					"gyroValue": -1144.59228515625,
+					"resultant": 8.733990874058362,
+					"index": 101,
+					"acc": {
+						"oAccX": 3.740234375,
+						"oAccY": -4.35546875,
+						"oAccZ": -6.58203125
+					},
+					"gyro": {
+						"oGyroX": -26.91650390625,
+						"oGyroY": -1144.59228515625,
+						"oGyroZ": -45.10498046875
+					}
+				}, {
+					"maxValue": -1.1376953125,
+					"gyroValue": -1038.87939453125,
+					"resultant": 3.372542722981424,
+					"index": 102,
+					"acc": {
+						"oAccX": -1.5966796875,
+						"oAccY": -2.744140625,
+						"oAccZ": 1.1376953125
+					},
+					"gyro": {
+						"oGyroX": -46.93603515625,
+						"oGyroY": -1038.87939453125,
+						"oGyroZ": -66.162109375
+					}
+				}, {
+					"maxValue": -1.30859375,
+					"gyroValue": -951.2939453125,
+					"resultant": 10.222525689439594,
+					"index": 103,
+					"acc": {
+						"oAccX": 1.23046875,
+						"oAccY": -10.0634765625,
+						"oAccZ": 1.30859375
+					},
+					"gyro": {
+						"oGyroX": -54.0771484375,
+						"oGyroY": -951.2939453125,
+						"oGyroZ": -85.205078125
+					}
+				}, {
+					"maxValue": -1.30859375,
+					"gyroValue": -951.2939453125,
+					"resultant": 10.222525689439594,
+					"index": 104,
+					"acc": {
+						"oAccX": 1.23046875,
+						"oAccY": -10.0634765625,
+						"oAccZ": 1.30859375
+					},
+					"gyro": {
+						"oGyroX": -54.0771484375,
+						"oGyroY": -951.2939453125,
+						"oGyroZ": -85.205078125
+					}
+				}, {
+					"maxValue": 0,
+					"gyroValue": -890.2587890625,
+					"resultant": 16.96604926042062,
+					"index": 105,
+					"acc": {
+						"oAccX": 4.4384765625,
+						"oAccY": -16.3623046875,
+						"oAccZ": 0.6494140625
+					},
+					"gyro": {
+						"oGyroX": -47.36328125,
+						"oGyroY": -890.2587890625,
+						"oGyroZ": -100.15869140625
+					}
+				}, {
+					"maxValue": 0,
+					"gyroValue": -890.2587890625,
+					"resultant": 16.96604926042062,
+					"index": 106,
+					"acc": {
+						"oAccX": 4.4384765625,
+						"oAccY": -16.3623046875,
+						"oAccZ": 0.6494140625
+					},
+					"gyro": {
+						"oGyroX": -47.36328125,
+						"oGyroY": -890.2587890625,
+						"oGyroZ": -100.15869140625
+					}
+				}, {
+					"maxValue": 1.6455078125,
+					"gyroValue": -826.47705078125,
+					"resultant": 19.088619035995112,
+					"index": 107,
+					"acc": {
+						"oAccX": 6.8798828125,
+						"oAccY": -17.7294921875,
+						"oAccZ": -1.6455078125
+					},
+					"gyro": {
+						"oGyroX": -32.04345703125,
+						"oGyroY": -826.47705078125,
+						"oGyroZ": -116.2109375
+					}
+				}, {
+					"maxValue": 0,
+					"gyroValue": -754.7607421875,
+					"resultant": 12.858333021663745,
+					"index": 108,
+					"acc": {
+						"oAccX": 4.4580078125,
+						"oAccY": -12.060546875,
+						"oAccZ": -0.078125
+					},
+					"gyro": {
+						"oGyroX": -20.751953125,
+						"oGyroY": -754.7607421875,
+						"oGyroZ": -133.544921875
+					}
+				}, {
+					"maxValue": 0,
+					"gyroValue": -754.7607421875,
+					"resultant": 12.858333021663745,
+					"index": 109,
+					"acc": {
+						"oAccX": 4.4580078125,
+						"oAccY": -12.060546875,
+						"oAccZ": -0.078125
+					},
+					"gyro": {
+						"oGyroX": -20.751953125,
+						"oGyroY": -754.7607421875,
+						"oGyroZ": -133.544921875
+					}
+				}, {
+					"maxValue": 4.0087890625,
+					"gyroValue": -700.1953125,
+					"resultant": 4.438586679567735,
+					"index": 110,
+					"acc": {
+						"oAccX": 1.5869140625,
+						"oAccY": -1.0546875,
+						"oAccZ": -4.0087890625
+					},
+					"gyro": {
+						"oGyroX": -10.43701171875,
+						"oGyroY": -700.1953125,
+						"oGyroZ": -149.35302734375
+					}
+				}];
+				this.onSendSocketMessage(msg);
 			}
 		}
 	};

+ 18 - 2
util/util-js/action/jump-0.2.js

@@ -92,7 +92,21 @@ ActionJump.prototype.addEventListener = function(type, listener) {
 ActionJump.prototype.updateJump = function() {
 	let data = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
 	//使用三个轴的数据,计算重力轴的加速度。最后减去重力的加速度值
+	/**
+	 * 纠正后使用的轴向
+	 * 	box["acc"] = {
+				ax: -ay,
+				ay: -ax,
+				az: az
+			};
+			box["gyro"] = {
+				gx: -gy,
+				gy: -gx,
+				gz: gz
+			};
+	 */
 	//********加速计********
+	
 	let {
 		lAccX,
 		lAccY,
@@ -112,8 +126,10 @@ ActionJump.prototype.updateJump = function() {
 		bYAxis
 	} = data;
 	//oGyroX 在用的过程中方向相反,所以添加负号
-	let _tempAxisData = bYAxis ? oGyroY : -oGyroY;//-oGyroX; 直接解析数据时候,调整
-	this.detectorNewStep(data.resultant, lAccX, lAccY, lAccZ, oAccX, oAccY, oAccZ, data.runIndex, _tempAxisData);
+	let _tempAxisData = bYAxis ? -oGyroX : oGyroY; //新设备直接使用oGyroY
+	// this.detectorNewStep(data.resultant, lAccX, lAccY, lAccZ, oAccX, oAccY, oAccZ, data.runIndex, _tempAxisData);
+	// oAccZ
+	this.detectorNewStep(data.resultant, -lAccY, -lAccX, lAccZ, -oAccY, -oAccX, -oAccZ, data.runIndex, _tempAxisData);
 };
 
 

+ 362 - 0
util/util-js/action/jump-0.3.js

@@ -0,0 +1,362 @@
+/**
+ * 跳判断相关脚本代码
+ */
+
+function Event() {
+	this.events = {};
+}
+Event.prototype.addEventListener = function(type, listener) {
+	this.events[type] = this.events[type] || [];
+	this.events[type].push(listener);
+};
+Event.prototype.trigger = function() {
+	for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
+		args[_key] = arguments[_key];
+	}
+
+	var type = args[0];
+	var params = args.slice(1);
+	if (!!this.events[type]) {
+		// console.log("type:",type);
+		this.events[type].forEach(function(listener) {
+			try {
+				listener.apply(null, params);
+			} catch (e) {
+				console.error(e);
+			}
+		});
+	}
+};
+var jumpOpts = {
+	//是否上升的标志位
+	isDirectionUp: false,
+	//持续上升次数
+	continueUpCount: 0,
+	//上一点的持续上升的次数,为了记录波峰的上升次数
+	continueUpFormerCount: 0,
+
+	continueDownCount: 0,
+	continueDownFormerCount: 0,
+
+	//上一点的状态,上升还是下降
+	lastStatus: false,
+	//波峰值
+	peakOfWave: 0,
+	//波谷值
+	valleyOfWave: 0,
+	//检测到极快的波动的次数
+	timeOfPeakCount: 0,
+	//开始添加
+	bUpdateTimeOfPeakCount: false,
+	//开始更新的次数
+	startCount: 0,
+	//停止跳
+	bStopJump: false,
+	//上次传感器的值
+	gravityOld: 0,
+
+	bUpState: false,
+
+	//开始时间
+	startTime: 0,
+	endTime: 0
+}
+var ActionJump = function ActionJump() {
+
+	this.jumpOpts = jumpOpts;
+	this.peakOfWaveMaxValue = 0;
+	this.peakOfWaveMaxValueCount = 0;
+	this.valleyOfWaveMinValue = 0;
+	this.valleyOfWaveMinValueCount = 0;
+	this.highestCount = 0;
+	//陀螺仪
+	this.oriGyroYArray = [];
+	this.event = new Event();
+	this.frameCapacity = 10;
+	this.frame = [];
+	this.frameLength = 5;
+	this.frameOffset = 0;
+	for (var i = 0; i < this.frameCapacity; ++i) {
+		var o = new Object();
+		o.maxValue = 0;
+		o.gyroValue = 0;
+		o.resultant = 0;
+		o.index = -1;
+		o.acc = null;
+		o.gyro = null;
+		this.frame.push(o);
+	}
+
+	this.frameLog = [];
+}
+ActionJump.prototype.addEventListener = function(type, listener) {
+	this.event.addEventListener(type, listener);
+};
+
+/**
+ * 更新数据
+ */
+ActionJump.prototype.updateJump = function() {
+	let data = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
+	//使用三个轴的数据,计算重力轴的加速度。最后减去重力的加速度值
+	/**
+	 * 纠正后使用的轴向
+	 * 	box["acc"] = {
+				ax: -ay,
+				ay: -ax,
+				az: az
+			};
+			box["gyro"] = {
+				gx: -gy,
+				gy: -gx,
+				gz: gz
+			};
+	 */
+	//********加速计********
+
+	// let {
+	// 	lAccX,
+	// 	lAccY,
+	// 	lAccZ
+	// } = data.linearAcc;
+	// let {
+	// 	oAccX,
+	// 	oAccY,
+	// 	oAccZ
+	// } = data.oriAcc;
+	// let {
+	// 	oGyroX,
+	// 	oGyroY,
+	// 	oGyroZ
+	// } = data.oriGyro;
+	// let {
+	// 	bYAxis
+	// } = data;
+	// //oGyroX 在用的过程中方向相反,所以添加负号
+	// let _tempAxisData = bYAxis ? -oGyroX : oGyroY; //新设备直接使用oGyroY
+	// this.detectorNewStep(data.resultant, lAccX, lAccY, lAccZ, oAccX, oAccY, oAccZ, data.runIndex, _tempAxisData);
+	// oAccZ
+	// this.detectorNewStep(data.resultant, -lAccY, -lAccX, -lAccZ, -oAccY, -oAccX, -oAccZ, data.runIndex,
+	// 	_tempAxisData);
+	this.detectorNewStep(data);
+};
+
+
+
+/*
+ *计算跳逻辑
+ */
+// ActionJump.prototype.detectorNewStep = function(resultant, linearX, linearY, linearZ, oriX, oriY, oriZ, _runIndex,
+// 	_oGyroY) 
+ActionJump.prototype.detectorNewStep = function(data) {
+	let {
+		oAccX,
+		oAccY,
+		oAccZ
+	} = data.oriAcc;
+	let {
+		oGyroX,
+		oGyroY,
+		oGyroZ
+	} = data.oriGyro;
+	let {
+		bYAxis
+	} = data;
+	//oGyroX 在用的过程中方向相反,所以添加负号
+	let _oGyroY = bYAxis ? -oGyroX : oGyroY; //新设备直接使用oGyroY
+	let _judgmentValue = -oAccZ; //判断左右方向用z
+	let resultant = data.resultant; //合加速度
+	let _runIndex = data.runIndex; //下标
+
+	//判断resultant 一个阀值
+	let limitResultant = 12;
+	if (!this.jumpOpts.bStopJump) {
+		if (resultant > limitResultant && !this.jumpOpts.bUpState) {
+			//陀螺仪部分
+			// this.oriGyroYArray = [];
+			//开始更新。加入时间判断
+			this.jumpOpts.startTime = new Date().getTime();
+			let _diffTime = this.jumpOpts.startTime - this.jumpOpts.endTime; //开始时间和结束时间太小的话,不能开始
+			if (_diffTime < 150) {
+				return;
+			}
+			this.jumpOpts.bUpState = true;
+			this.event.trigger('resultant', {
+				type: "log",
+				logType: 'normal',
+				data: "开始时间:" + this.jumpOpts.startTime + ",resultant:" + resultant + ",bYAxis:" + bYAxis
+			});
+			this.highestCount = 0;
+			for (let i = 0; i < this.frame.length; i++) {
+				this.frame[i].maxValue = 0;
+				this.frame[i].gyroValue = 0;
+				this.frame[i].resultant = 0;
+				this.frame[i].index = -1;
+				this.frame[i].acc = null;
+				this.frame[i].gyro = null;
+			}
+			this.frameLog = [];
+		}
+		if (this.jumpOpts.bUpState) {
+			let currTime = new Date().getTime(); //当前时间
+			let diffTime = currTime - this.jumpOpts.startTime; //当前时间减最初时间,得到当前时间差
+			if (diffTime > 500) {
+				/**
+				 * 获取500毫秒内的数据
+				 * 如果超过限定时间,重置一下数据
+				 */
+				this.jumpOpts.startTime = currTime;
+				this.highestCount = 0;
+				for (let i = 0; i < this.frame.length; i++) {
+					this.frame[i].maxValue = 0;
+					this.frame[i].gyroValue = 0;
+					this.frame[i].resultant = 0;
+					this.frame[i].index = -1;
+					this.frame[i].acc = null;
+					this.frame[i].gyro = null;
+				}
+				this.frameLog = [];
+				// console.error("1************************************************************");
+				// console.log(this.frame);
+				// console.error("2************************************************************");
+			}
+			// (this.frameOffset + this.frameLength) % this.frameCapacity
+			let newFrame = this.frame[this.frameOffset];
+			newFrame.index = _runIndex;
+			newFrame.acc = data.oriAcc;
+			newFrame.gyro = data.oriGyro;
+			if (_judgmentValue > 1) {
+				newFrame.maxValue = _judgmentValue;
+				if (_judgmentValue > this.peakOfWaveMaxValue) {
+					this.peakOfWaveMaxValue += _judgmentValue;
+					this.peakOfWaveMaxValueCount++;
+				}
+			} else if (_judgmentValue < -1) {
+				newFrame.maxValue = _judgmentValue;
+				if (_judgmentValue < this.valleyOfWaveMinValue) {
+					this.valleyOfWaveMinValue += _judgmentValue;
+					this.valleyOfWaveMinValueCount++;
+				}
+			} else {
+				/**
+				 * 不符合条件设置为0
+				 */
+				newFrame.maxValue = 0;
+			}
+			if (Math.abs(_oGyroY) > 5) {
+				// this.oriGyroYArray.push(_oGyroY);
+				newFrame.gyroValue = _oGyroY;
+			} else {
+				/**
+				 * 不符合条件设置为0
+				 */
+				newFrame.gyroValue = 0;
+			}
+			newFrame.resultant = resultant;
+
+			//拷贝一个数据
+			this.frameLog.push(JSON.parse(JSON.stringify(newFrame)));
+			// console.log(JSON.parse(JSON.stringify(newFrame)));
+
+			//出现极值后
+			// Math.abs(linearZ) < 7 &&
+			if (Math.abs(resultant) < 7) {
+				this.highestCount++;
+				if (this.highestCount >= 2) {
+					//达到最高点,
+					this.jumpOpts.bStopJump = true;
+					this.jumpOpts.bUpdateTimeOfPeakCount = true;
+					let _frameMaxValue = 0,
+						_frameGyroValue = 0;
+					// let isPlus = false;
+					// if (this.peakOfWaveMaxValueCount >= this.valleyOfWaveMinValueCount) {
+					// 	isPlus = true;
+					// }
+					console.log(this.frame);
+					console.log(this.frameLog);
+					this.sendLog(this.frameLog,'socket');
+					for (let i = 0; i < this.frame.length; i++) {
+						_frameMaxValue += this.frame[i].maxValue;
+						_frameGyroValue += this.frame[i].gyroValue;
+						// if (isPlus && this.frame[i].maxValue > 0) {
+						// 	_frameMaxValue += this.frame[i].maxValue;
+						// 	_frameGyroValue += this.frame[i].gyroValue;
+						// } else if (!isPlus && this.frame[i].maxValue < 0) {
+						// 	_frameMaxValue += this.frame[i].maxValue;
+						// 	_frameGyroValue += this.frame[i].gyroValue;
+						// }
+					}
+					// console.log("frame:" + _frameMaxValue + " == " + _frameGyroValue);
+
+					//后面通用使用这个类型传输数据
+					this.event.trigger('resultant', {
+						type: "stateDataOfJump",
+						currentMaxValue: _frameMaxValue,
+						peakOfWaveMaxValue: this.peakOfWaveMaxValue,
+						valleyOfWaveMinValue: this.valleyOfWaveMinValue,
+						oGyroValue: _frameGyroValue ,
+						resultant: resultant,
+						name: "highestCountEnd"
+					});
+					// this.jumpOpts.bUpState = false;
+					// this.jumpOpts.bStopJump = false;
+					this.event.trigger('resultant', {
+						type: "stop"
+					});
+					this.resetAll();
+				}
+			}
+			if ((this.frameOffset += 1) >= this.frameCapacity) {
+				this.frameOffset -= this.frameCapacity;
+			}
+		}
+	} else if (this.jumpOpts.bUpdateTimeOfPeakCount) {
+		// console.log("结束判断时候:" + resultant);
+		this.jumpOpts.timeOfPeakCount++;
+		//todo 如果直跳,可以调节更小的 limitTimeOfPeakCount 30
+		let limitTimeOfPeakCount = 10;
+		if (this.jumpOpts.timeOfPeakCount >= limitTimeOfPeakCount) {
+			this.jumpOpts.timeOfPeakCount = 0;
+			this.jumpOpts.bStopJump = false;
+			this.jumpOpts.bUpState = false;
+			// this.event.trigger('resultant', {
+			// 	type: "stop"
+			// });
+			// this.resetAll();
+			this.jumpOpts.bUpdateTimeOfPeakCount = false;
+			this.jumpOpts.endTime = new Date().getTime();
+		}
+	}
+}
+
+ActionJump.prototype.setBUpState = function(value) {
+	this.jumpOpts.bUpState = value;
+}
+
+
+//重置对应的参数
+ActionJump.prototype.resetAll = function() {
+	console.log("resetAll");
+	this.peakOfWaveMaxValue = 0;
+	this.peakOfWaveMaxValueCount = 0;
+	this.valleyOfWaveMinValue = 0;
+	this.valleyOfWaveMinValueCount = 0;
+	this.highestCount = 0;
+}
+
+/**
+ * 日志
+ * @param {Object} data
+ * @param {Object} logType
+ */
+ActionJump.prototype.sendLog = function(data,logType){
+	this.event.trigger('resultant', {
+		type: "log",
+		logType: logType,
+		data: data
+	});
+}
+
+if (typeof module === "object" && typeof module.exports === "object") {
+	module.exports = ActionJump;
+}

+ 2 - 2
util/util-js/o0ProjectRelease0.1.js

@@ -188,8 +188,8 @@ module.exports = {
 			let directionPunch = "all",
 				name = "击中",
 				ename = "hit";
-			let positiveMidSlope = [72.5,107.5];//min max
-			let negativeMidSlope = [252.5,287.5];//min max
+			let positiveMidSlope = [70,110];//min max
+			let negativeMidSlope = [250,290];//min max
 			if (curAngle < positiveMidSlope[1] && curAngle >= positiveMidSlope[0]) {
 				directionPunch = "straightPunch";
 				name = "正向的直拳";

+ 93 - 17
util/util-js/store.js

@@ -511,6 +511,32 @@ const store = new Vuex.Store({
 			//重置一下数据保存
 			this.commit('onAccAndGyroConvertDataSave');
 		},
+		/**
+		 * 保存一份本地数据,加速计和陀螺仪
+		 * @param {Object} data
+		 * @param {Object} state
+		 */
+		setOutAccAndGyroData(state, data) {
+			uni.setStorageSync('OutAccAndGyroData', data);
+		},
+		getOutAccAndGyroData(state) {
+			const value = uni.getStorageSync('OutAccAndGyroData');
+			return value;
+		},
+		copyOutAccANdGyroData() {
+			const value = uni.getStorageSync('OutAccAndGyroData');
+			uni.setClipboardData({
+				data: value,
+				success: () => {
+					uni.showToast({
+						icon: 'none',
+						title: '复制成功'
+					});
+				}
+			});
+		},
+
+
 
 		setGuideUnlockState(state, _guideUnlockState) {
 			uni.setStorageSync('guideUnlockState', _guideUnlockState);
@@ -2105,10 +2131,32 @@ const store = new Vuex.Store({
 				gy,
 				gz
 			} = data.gyro;
-			// ax / 10, az / 10, gz, -gx, data.ms ----- old
-			// ay / 10, -az / 10, gy, gz, data.ms
-			// let [hit, dir] = state.sandbagAlgorithm.Update(-ay, az, -gz, -gy, data.ms);
-			let [hit, dir] = state.sandbagAlgorithm.Update(ax, az, gz, -gx, data.ms);
+
+			/**
+			 * ax / 10, az / 10, gz, -gx, data.ms ----- old
+			 * ay / 10, -az / 10, gy, gz, data.msK
+			 * let [hit, dir] = state.sandbagAlgorithm.Update(-ay, az, -gz, -gy, data.ms);
+			 * 纠正后使用的轴向
+			 * 	box["acc"] = {
+						ax: -ay,
+						ay: -ax,
+						az: az
+					};
+					box["gyro"] = {
+						gx: -gy,
+						gy: -gx,
+						gz: gz
+					};
+			 */
+			let {
+				ms
+			} = data;
+			let msGap = ms - state.deviceMs;
+			state.deviceMs = ms;
+			while (msGap < 0) {
+				msGap += 1000;
+			}
+			let [hit, dir] = state.sandbagAlgorithm.Update(ax, az, -gz, gx, msGap);
 			if (dir != undefined) {
 				let temp = state.sandbagAlgorithm.getTempValue(dir);
 				if (callback) {
@@ -2721,28 +2769,24 @@ const store = new Vuex.Store({
 					//秒
 					let s = BLE.hex2int(resValue.substr(34, 2));
 
-
-
 					// ax / 10, az / 10, gz, -gx, data.ms ----- old
 					// let [hit, dir] = state.sandbagAlgorithm.Update(-ay, az, -gz, -gy, data.ms);
-
 					box["handle"] = BLE.hexToString(handle);
+					/**
+					 * 纠正手柄传感器轴向。
+					 * 以方向键向上为 -g = y ,左右按钮向上 -g = x, 按键面向上 -g = z;
+					 * 陀螺仪旋转方向:逆时针为负-,顺时针为正+;
+					 */
 					box["acc"] = {
 						ax: -ay,
 						ay: -ax,
 						az: az
 					};
-					// box["acc"] = {
-					// 	-ay,
-					// 	-ax, //ay,
-					// 	az
-					// };
 					box["gyro"] = {
-						gx: gy,
-						gy: gx,
-						gz: -gz
+						gx: -gy,
+						gy: -gx,
+						gz: gz
 					};
-
 					box["min"] = min;
 					box["s"] = s;
 					box["ms"] = ms;
@@ -3321,7 +3365,7 @@ const store = new Vuex.Store({
 						if (res.code == 0) {
 							// state.singlePersonList = res.data.singlePerson;
 							// state.multiPersonList = res.data.multiPerson;
-							console.log(res.data);
+							// console.log(res.data);
 							let levels = res.data;
 							state.levels = levels;
 
@@ -3714,6 +3758,38 @@ const store = new Vuex.Store({
 						console.log(e);
 					}
 				);
+		},
+		onConnectSocket(state) {
+			let self = this;
+			uni.connectSocket({
+				// #ifdef APP-PLUS
+				url: 'wss://www.9527fun.cn/api_dev/websocket/APPLog/123'
+				// #endif
+				// #ifdef H5
+				// url:'wss://www.9527fun.cn/api_dev/websocket/APPLog/123'
+				url: 'ws://192.168.0.108:9090/api_dev/websocket/APPLog/123'
+				// #endif
+			});
+			uni.onSocketMessage(function(res) {
+				console.log('收到服务器内容:' + res.data);
+			});
+			uni.onSocketOpen(function(res) {
+				console.log('WebSocket连接已打开!');
+			});
+			uni.onSocketError(function(res) {
+				console.log('WebSocket连接打开失败,请检查!');
+			});
+		},
+		onCloseSocket(state) {
+			uni.onSocketClose(function(res) {
+				console.log('WebSocket 已关闭!');
+			});
+		},
+		onSendSocketMessage(state, msg) {
+			console.log("发送数据", msg);
+			uni.sendSocketMessage({
+				data: JSON.stringify(msg)
+			});
 		}
 
 	}