Browse Source

1.2.3.9 21031502 版本
2.调整断开蓝牙设备提示,和流程修正
3.调整蓝牙频率为10ms
4.去掉跑步模式下的音效

slambb 5 years ago
parent
commit
ac44603004

+ 4 - 2
common/config.js

@@ -2,7 +2,8 @@
 //"2020-07-14"
 //************* ios 注意此时间设置,目前设置2021-01-24,暂时用于处理游戏显示 *************
 const endTime = "2021-03-01"
-
+//************* 默认的蓝牙设备刷新间隔 再config 设置 a:10ms,b:20ms*************
+const refreshRate = "a";
 
 //线上地址,腾讯云服务器
 const host="https://www.9527fun.cn/api_prd"
@@ -156,5 +157,6 @@ const URL = {
 
 export default {
 	URL,
-	endTime
+	endTime,
+	refreshRate
 }

+ 10 - 9
components/modal/boxing-hit/boxing-hit.vue

@@ -573,15 +573,16 @@
 			},
 			//平时击打的力量槽动画播放
 			onPlayPowerAnimation(bGreat) {
-				if (bGreat) {
-					this.hookAudioContext.stop();
-					this.hookAudioContext.src = this.greatTipUrl;
-					this.hookAudioContext.play();
-				} else {
-					this.hookAudioContext.stop();
-					this.hookAudioContext.src = this.hitUrl;
-					this.hookAudioContext.play();
-				}
+				// 暂时去掉 跑步声音
+				// if (bGreat) {
+				// 	this.hookAudioContext.stop();
+				// 	this.hookAudioContext.src = this.greatTipUrl;
+				// 	this.hookAudioContext.play();
+				// } else {
+				// 	this.hookAudioContext.stop();
+				// 	this.hookAudioContext.src = this.hitUrl;
+				// 	this.hookAudioContext.play();
+				// }
 				let _self = this;
 
 				if (_self.powerInterval) {

+ 2 - 2
manifest.json

@@ -2,8 +2,8 @@
     "name" : "哔蹦",
     "appid" : "__UNI__2635DF5",
     "description" : "",
-    "versionName" : "2.3.7",
-    "versionCode" : 21030102,
+    "versionName" : "2.3.9",
+    "versionCode" : 21031502,
     "transformPx" : false,
     /* 5+App特有相关 */
     "app-plus" : {

+ 6 - 2
pages/game-page/game-play-sub/subGame/subGame.nvue

@@ -160,8 +160,12 @@
 			plus.key.addEventListener('backbutton', () => {
 				this.navBack();
 			}, false);
+			
+			//设置store状态
+			_self.$store.state.bGamePlaying = true;
 		},
 		onUnload() {
+			this.$store.state.bGamePlaying = false;
 			console.log("subNVue子窗体 onUnload!");
 			//*****注释蓝牙操作******
 			// uni.$off('callbackCloseBLE', this.callbackCloseBLE);
@@ -592,9 +596,9 @@
 							value: "3"
 						});
 						setTimeout(()=>{
-							//设置加速计20ms
+							//设置加速计b:20ms a:10ms
 							this.onWriteBLEConnectionValue({
-								value: "b"
+								value: config.refreshRate
 							});
 							
 						},2000)

+ 13 - 0
pages/personal-page/devices-hardware/devices-hardware.vue

@@ -92,11 +92,15 @@
 					}
 				})
 			}
+			uni.$on('retryConnectBLESuccess', this.onRetryConnectBLESuccess);
 			uni.$on('callbackCloseBLE', this.hardCallbackCloseBLE);
 			uni.$on('listenerBLE', this.onListenerBLE);
+			
+			
 
 		},
 		onUnload() {
+			uni.$off('retryConnectBLESuccess', this.onRetryConnectBLESuccess);
 			uni.$off('callbackCloseBLE', this.hardCallbackCloseBLE);
 			uni.$off('listenerBLE', this.onListenerBLE);
 
@@ -339,7 +343,16 @@
 					uni.hideToast();
 				}
 			},
+			onRetryConnectBLESuccess(){
+				this.ConnectionSuccess();
+			},
 			hardCallbackCloseBLE() {
+				
+				if(this.BLEConnectDevice == null && this.currentItem){
+					this.currentItem.bRatio = false;
+					this.currentItem = null;
+					this.saveObj = null;
+				}
 				//如果限制不走重连
 				if (this.bLimitClose) return;
 

+ 34 - 42
pages/personal-page/personal/personal.vue

@@ -874,10 +874,8 @@
 			if (canvaArcbar1)
 				_self.updateArcbarData();
 
-			// console.warn('this.BLEConnectDevice:',this.BLEConnectDevice);
 			//this.bConnection && 
 			if (this.bVerifiedConnection && this.BLEConnectDevice) {
-				// console.log('this.BLEConnectDevice:',this.BLEConnectDevice);
 				this.updateBLECIndex();
 
 				setTimeout(() => {
@@ -1375,38 +1373,38 @@
 
 			//蓝牙断开连接时候
 			callbackCloseBLE() {
-				this.$store.state.cIndex = -1;
+				// this.$store.state.cIndex = -1;
 				//蓝牙断开连接后,直接关闭
 				this.$refs.boxingPostRef.onCloseDevices();
 
-				if (!this.BLEConnectDevice) {
-					console.log('连接蓝牙对象为空,不进行重连!');
-					return;
-				}
-				//如果限制不走重连
-				if (this.bLimitReconnection) return;
-				//连接蓝牙
-				this.onCreateBLEConnection({
-					item: this.BLEConnectDevice,
-					initItem: false,
-					getSuccess: () => {
-						this.updateBLECIndex();
-
-						if (this.bHide) {
-							//弹出框时候,是隐藏状态
-							this.bGetBondTesting = true;
-						} else {
-							//没有弹出框时候,直接检测
-							setTimeout(() => {
-								this.onGetBondDevice();
-							}, 5000)
-						}
-					},
-					getinitAdapter: () => {
-						// this.onDevice(item, e);
-						// console.log("未开启蓝牙模块?");
-					}
-				});
+				// if (!this.BLEConnectDevice) {
+				// 	console.log('连接蓝牙对象为空,不进行重连!');
+				// 	return;
+				// }
+				// //如果限制不走重连
+				// if (this.bLimitReconnection) return;
+				// //连接蓝牙
+				// this.onCreateBLEConnection({
+				// 	item: this.BLEConnectDevice,
+				// 	initItem: false,
+				// 	getSuccess: () => {
+				// 		this.updateBLECIndex();
+
+				// 		if (this.bHide) {
+				// 			//弹出框时候,是隐藏状态
+				// 			this.bGetBondTesting = true;
+				// 		} else {
+				// 			//没有弹出框时候,直接检测
+				// 			setTimeout(() => {
+				// 				this.onGetBondDevice();
+				// 			}, 5000)
+				// 		}
+				// 	},
+				// 	getinitAdapter: () => {
+				// 		// this.onDevice(item, e);
+				// 		// console.log("未开启蓝牙模块?");
+				// 	}
+				// });
 			},
 			//蓝牙状态回调
 			callbackBLEState(res) {
@@ -1496,12 +1494,6 @@
 					})
 					return;
 				}
-				uni.showToast({
-					title: '连接设备中...',
-					icon: 'loading',
-					duration: 5000,
-					mask: true
-				})
 				//连接蓝牙
 				this.onCreateBLEConnection({
 					item: item,
@@ -1547,7 +1539,7 @@
 				this.B_GetBondedDevices({
 					deviceId: this.BLEConnectDevice.deviceId,
 					success: (bondedDevice) => {
-						console.error("===========", bondedDevice);
+						// console.error("===========", bondedDevice);
 						// uni.hideToast();
 						if (bondedDevice == null) {
 							// if (plus.os.name == 'Android') 
@@ -1815,9 +1807,9 @@
 						});
 
 						setTimeout(() => {
-							//设置加速计20ms
+							//设置加速计b:20ms a:10ms
 							this.onWriteBLEConnectionValue({
-								value: "b"
+								value: config.refreshRate
 							});
 
 						}, 1000)
@@ -2289,9 +2281,9 @@
 					});
 					
 					setTimeout(() => {
-						//设置加速计20ms
+						//设置加速计b:20ms a:10ms
 						this.onWriteBLEConnectionValue({
-							value: "b"
+							value: config.refreshRate
 						});
 					
 					}, 1000)

+ 78 - 41
util/util-js/store.js

@@ -279,7 +279,12 @@ const store = new Vuex.Store({
 		BluetoothAdapter: null,
 
 		//版本状态,用于区分部分特定的环境
-		versionCodeState: null
+		versionCodeState: null,
+
+		//显示蓝牙是否断开连接Modal
+		bShowBLEConnectModal: false,
+		bGamePlaying:false,
+
 	},
 	mutations: {
 
@@ -1058,12 +1063,12 @@ const store = new Vuex.Store({
 			// 		cityCode: 12345
 			// 	}
 			// });
-			
+
 			//进入此页面先设置平台参数
-			if(state.platform == "ios"){
-				uni.setStorageSync("platform",1);
-			}else if(state.platform == "android"){
-				uni.setStorageSync("platform",0);
+			if (state.platform == "ios") {
+				uni.setStorageSync("platform", 1);
+			} else if (state.platform == "android") {
+				uni.setStorageSync("platform", 0);
 			}
 			//获取版本信息
 			this.commit('getVersionCode');
@@ -1388,24 +1393,17 @@ const store = new Vuex.Store({
 				getSuccess = null,
 				getinitAdapter = null
 			} = context;
-
+			
+			uni.showToast({
+				title: '连接设备中...',
+				icon: 'loading',
+				duration: 10000,
+				mask: true
+			})
+			
 			let params = {
 				item: item,
 				success: (success) => {
-
-					// 	uni.getBluetoothDevices({
-					// 		success(res) {
-					// 			console.log("getBluetoothDevices:", res)
-					// 		}
-					// 	})
-
-					// 	uni.getConnectedBluetoothDevices({
-					// 		success(res) {
-					// 			console.log("getConnectedBluetoothDevices:", res)
-					// 		}
-					// 	})
-
-
 					state.bConnection = true;
 					if (state.getBLEDeviceServicesTimeout) {
 						clearTimeout(state.getBLEDeviceServicesTimeout);
@@ -1430,7 +1428,6 @@ const store = new Vuex.Store({
 									state.BLEConnectDevice = item;
 								}
 
-
 								if (getSuccess)
 									getSuccess();
 
@@ -1448,9 +1445,10 @@ const store = new Vuex.Store({
 								this.commit("B_CloseBLEConnection", {
 									deviceId: item.deviceId
 								})
-								state.cIndex = -1;
-								state.bConnection = false;
-								state.bVerifiedConnection = false;
+								// state.cIndex = -1;
+								// state.bConnection = false;
+								// state.bVerifiedConnection = false;
+								this.commit("onResetBLEConnection");
 							}
 						});
 
@@ -1462,7 +1460,7 @@ const store = new Vuex.Store({
 					if (fail.errCode === 10012) {
 						console.log("连接超时,请重试!");
 						uni.showToast({
-							title: '连接失败,设备无响应,请重试。',
+							title: '连接失败,开启设备后尝试重新连接!',
 							icon: 'none',
 							duration: 3000,
 							mask: true
@@ -1476,27 +1474,16 @@ const store = new Vuex.Store({
 							mask: true
 						})
 					} else if (fail.errCode === 10000) {
-						// console.log("连接失败,初始化 uni.openBluetoothAdapter 调用之后使用");
-						// uni.showToast({
-						// 	title: '连接失败,检查手机蓝牙是否开启',
-						// 	icon: 'none',
-						// 	duration: 2000,
-						// 	mask: true
-						// })
-
 						this.commit('initAdapter', () => {
 							if (getinitAdapter) {
 								getinitAdapter();
 							}
 						})
-						// this.initAdapter(() => {
-						// 	this.onDevice(item, e);
-						// });
 					} else {
 						// err.errCode10003原因多种:蓝牙设备未开启或异常导致无法连接;蓝牙设备被占用或者上次蓝牙连接未断开导致无法连接
-						console.log("连接失败,请重试!");
+						console.log("连接失败,请重试!",state.BLEConnectDevice);
 						uni.showToast({
-							title: '设备未开启或被占用异常导致无法连接。',
+							title: '请尝试开启设备和重启app。',
 							icon: 'none',
 							duration: 2000,
 							mask: true
@@ -1576,9 +1563,23 @@ const store = new Vuex.Store({
 				getServiceList: (serviceList) => {
 					state.BLEGetServices = serviceList;
 				},
-				getFail: () => {}
+				getFail: () => {
+					this.commit("B_CloseBLEConnection", {
+						deviceId: item.deviceId
+					})
+					this.commit("onResetBLEConnection");
+				}
 			})
 		},
+		//重置蓝牙连接参数
+		onResetBLEConnection(state) {
+			state.cIndex = -1;
+			state.BLEConnectDevice = null;
+			//蓝牙服务
+			state.BLEGetServices = null;
+			state.bConnection = false;
+			state.bVerifiedConnection = false;
+		},
 		onCloseBLEConnection(state, context) {
 
 			console.log("onCloseBLEConnection", state.BLEConnectDevice);
@@ -1751,7 +1752,7 @@ const store = new Vuex.Store({
 				gz
 			} = data.gyro;
 
-			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的函数
 		},
 		/**
 		 * 限制开始游戏
@@ -1921,6 +1922,7 @@ const store = new Vuex.Store({
 		},
 
 		B_OnBLEConnectionStateChange(state) {
+			let _self = this;
 			//#ifdef H5
 			console.warn('h5不加载蓝牙模块');
 			return;
@@ -1929,6 +1931,38 @@ const store = new Vuex.Store({
 				// 该方法回调中可以用于处理连接意外断开等异常情况
 				console.log(`蓝牙连接状态 -------------------------->`, JSON.stringify(res));
 				if (!res.connected) {
+
+					//要在连接的状态下 ,并且获取过匹配列表有参数的情况下,才提示重连
+					if (!state.bShowBLEConnectModal && state.bVerifiedConnection && state.bPhoneMatched) {
+						state.bShowBLEConnectModal = true;
+						let _connectItem = Object.assign({},state.BLEConnectDevice);
+						let _cIndex = state.cIndex;
+						//断开连接后reset一下参数
+						_self.commit("onResetBLEConnection");
+						
+						let _tip = state.bGamePlaying? "蓝牙已断开是否重新连接蓝牙?重连需要重启游戏!":"蓝牙已断开是否重新连接蓝牙";
+						uni.showModal({
+							title: _tip,
+							success: (sRes) => {
+								state.bShowBLEConnectModal = false;
+								if (sRes.confirm) {
+									console.log("重连的_cIndex:",_cIndex);
+									_self.commit("onCreateBLEConnection", {
+										item: _connectItem,
+										index: _cIndex,
+										initItem: true,
+										getSuccess: () => {
+											//此处不检查外部设备
+											uni.$emit('retryConnectBLESuccess');
+										},
+										getinitAdapter: () => {}
+									})
+								}
+							}
+						})
+					}
+
+
 					uni.$emit('callbackCloseBLE');
 				}
 			});
@@ -2024,6 +2058,9 @@ const store = new Vuex.Store({
 						title: '连接错误',
 						content: '请尝试重新连接设备。'
 					})
+					if (getFail) {
+						getFail();
+					}
 				}
 			});
 		},