Преглед изворни кода

1.添加跳绳模式
2.修改部分功能

slambb пре 4 година
родитељ
комит
42024f3d05

+ 2 - 2
common/config.js

@@ -6,9 +6,9 @@ const endTime = "2021-03-01"
 const refreshRate = "a";
 
 //线上地址,腾讯云服务器
-const host="https://www.9527fun.cn/api_prd"
+// const host="https://www.9527fun.cn/api_prd"
 //测试地址,阿里云服务器
-// const host="https://www.9527fun.cn/api_dev"
+const host="https://www.9527fun.cn/api_dev"
 //本地测试地址
 // const host = "http://192.168.0.112:9090/api_dev"
 // const host = "http://47.104.216.192:9090/api_dev"

+ 36 - 5
components/modal/boxing-hit/boxing-hit.vue

@@ -152,13 +152,13 @@
 			<view class="flex align-center">
 				<view class="flex justify-start flex-direction align-center">
 					<image src="/static/mileageIcon-w.png" class="data-png-26 margin-sm" mode="aspectFit"></image>
-					<text style="text-align: start; line-height: 24px; font-weight: 400;color: #FFFFFF;">里程</text>
+					<text style="text-align: start; line-height: 24px; font-weight: 400;color: #FFFFFF;">{{mode == 'calorieMode'?'里程':'计数'}}</text>
 				</view>
 				<view class="flex justify-start flex-direction">
 					<view style="height: 26px;" class="margin-top-sm margin-bottom-sm">
 						<view class="cu-progress" style="height: 6rpx; width: 140rpx; border-radius: 45rpx;"></view>
 					</view>
-					<text style="text-align: start; line-height: 24px; font-weight: 400;color: #FFFFFF;">{{runMileage}}km</text>
+					<text style="text-align: start; line-height: 24px; font-weight: 400;color: #FFFFFF;">{{mode == 'calorieMode'?runMileage+'km':ropeJumpCount}}</text>
 				</view>
 			</view>
 			<view style="width: 40rpx;"></view>
@@ -457,6 +457,11 @@
 				runTempCount:0,
 				runAllTempCount:0,
 				runAllCount:0,
+				
+				/**
+				 * 跳绳参数
+				 */
+				ropeJumpCount:0
 
 			}
 		},
@@ -762,6 +767,23 @@
 					bLimitRebound: true
 				})
 			},
+			//rope 情景下刷新
+			onBLERopeUpdate(data) {
+				if (!this.bUpdate || !this.bPlay) return;
+			
+				let {
+					jump
+				} = data;
+				let power = parseInt(jump);
+				let acc = power * 0.1;
+				
+				console.log(jump,this.mode,acc,power);
+				if (this.mode == "pkMode") {
+					this._pkHitOnly(acc, power);
+				} else {
+					this._HitOnly(acc, power);
+				}
+			},
 
 			updateOri(ori) {
 				this.xO = ori.beta;
@@ -960,9 +982,15 @@
 				this.runTempCount ++;
 				
 				this.runAllCount = this.allShowHitCount;
-				//里面转换千米
-				//175公分的bai成人一般两步间距du为70厘米,zhi170公分为65厘米,180公分为75厘米。
-				this.runMileage =  this.runAllCount*70 / 100000;
+				
+				if(this.mode == 'calorieMode'){
+					//里面转换千米
+					//175公分的bai成人一般两步间距du为70厘米,zhi170公分为65厘米,180公分为75厘米。
+					this.runMileage =  this.runAllCount*70 / 100000;
+				}else {
+					this.ropeJumpCount = this.runAllCount;
+				}
+				
 
 				this.currentHitStrength = power;
 				if (this.maxStrength < power) {
@@ -1156,6 +1184,9 @@
 				} else if (modeValue == 'pkMode') {
 					this.mode = 'pkMode';
 					_name = 'pk模式';
+				} else if(modeValue == 'ropeMode'){
+					this.mode = 'ropeMode';
+					_name = '跳绳模式'
 				}
 				let _data = {
 					mode: this.mode,

+ 4 - 3
manifest.json

@@ -2,8 +2,8 @@
     "name" : "哔蹦",
     "appid" : "__UNI__2635DF5",
     "description" : "",
-    "versionName" : "2.3.11",
-    "versionCode" : 21032202,
+    "versionName" : "2.3.13",
+    "versionCode" : 21041301,
     "transformPx" : false,
     /* 5+App特有相关 */
     "app-plus" : {
@@ -32,6 +32,8 @@
                     "<uses-permission android:name=\"android.permission.ACCESS_FINE_LOCATION\"/>",
                     "<uses-permission android:name=\"android.permission.ACCESS_NETWORK_STATE\"/>",
                     "<uses-permission android:name=\"android.permission.ACCESS_WIFI_STATE\"/>",
+                    "<uses-permission android:name=\"android.permission.BLUETOOTH\"/>",
+                    "<uses-permission android:name=\"android.permission.BLUETOOTH_ADMIN\"/>",
                     "<uses-permission android:name=\"android.permission.CALL_PHONE\"/>",
                     "<uses-permission android:name=\"android.permission.CAMERA\"/>",
                     "<uses-permission android:name=\"android.permission.CHANGE_NETWORK_STATE\"/>",
@@ -40,7 +42,6 @@
                     "<uses-permission android:name=\"android.permission.GET_ACCOUNTS\"/>",
                     "<uses-permission android:name=\"android.permission.MODIFY_AUDIO_SETTINGS\"/>",
                     "<uses-permission android:name=\"android.permission.MOUNT_UNMOUNT_FILESYSTEMS\"/>",
-                    "<uses-permission android:name=\"android.permission.READ_CONTACTS\"/>",
                     "<uses-permission android:name=\"android.permission.READ_LOGS\"/>",
                     "<uses-permission android:name=\"android.permission.READ_PHONE_STATE\"/>",
                     "<uses-permission android:name=\"android.permission.RECORD_AUDIO\"/>",

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

@@ -142,6 +142,11 @@
 						value: "6"
 					});
 				
+					uni.$off('updateBLEDeviceData', _self.gWatchBLEUpdate);
+				}//关闭跳绳模式指令
+				else if (_self.BLEConnectDevice && _self.BLEConnectDevice.deviceType == "BLERope") {
+					console.warn("还没设置关闭跳绳模式")
+					_self.B_CloseRopeSkipping();
 					uni.$off('updateBLEDeviceData', _self.gWatchBLEUpdate);
 				}
 				uni.$emit("game-unload", {
@@ -180,7 +185,7 @@
 		},
 		methods: {
 			...mapMutations(['addlocalCalorie', 'syncRequestEvent', 'onWriteBLEConnectionValue',
-				'gCreateFilterObj', 'gUpdateFilter'
+				'gCreateFilterObj', 'gUpdateFilter' ,'B_OpenRopeSkipping','B_CloseRopeSkipping'
 			]),
 			navBack() {
 
@@ -612,7 +617,6 @@
 							//hotman 沙袋情景  
 							this.gCreateFilterObj();
 						}
-						console.log("BLEHandle");
 					} else if (this.BLEConnectDevice.deviceType == "mySelf") {
 						//处理手机本身情况下
 						if (this.globalAcc) {
@@ -636,6 +640,11 @@
 								}
 							});
 						}
+					} else if(this.BLEConnectDevice.deviceType == "BLERope"){
+						//todo 开启跳绳模式
+						this.B_OpenRopeSkipping();
+						//监听蓝牙回调
+						uni.$on('updateBLEDeviceData', this.gWatchBLEUpdate);
 					}
 
 
@@ -646,6 +655,10 @@
 							value: "4"
 						});
 						uni.$off('updateBLEDeviceData', this.gWatchBLEUpdate);
+					}else if (this.BLEConnectDevice && this.BLEConnectDevice.deviceType == "BLERope") {
+					 	console.warn("unbindHitBoxingPost 还没设置关闭跳绳模式")
+						this.B_CloseRopeSkipping();
+						uni.$off('updateBLEDeviceData', this.gWatchBLEUpdate);
 					} else {
 						uni.$off('watchAcceleration', this.gWatchHitBoxingAcc);
 						uni.$emit("unBindAcc", this.globalAcc);
@@ -790,6 +803,19 @@
 							}
 						}
 					});
+				} else if(this.BLEConnectDevice.usageMode == "ropeSkipping"){
+					//跳绳模式场景,简单更新触发
+					//看看是否反馈一个角度,180 ,360
+					let temp = {
+						direction: "all",
+						angle: 0,
+						name: "击中",// this.BLEConnectDevice.name,
+						ename: "hit",//this.BLEConnectDevice.ename,
+						value: 10,
+						mass: 10, //质量
+						hitPower: 10 //计算的力
+					}
+					this.sendMessage("onBoxingPostHit", temp);
 				}
 			},
 

+ 84 - 74
pages/personal-page/devices-hardware/devices-hardware.vue

@@ -71,9 +71,9 @@
 				//是否需要检测发起的连接蓝牙是否匹配上
 				bTestBondConnect: true,
 				//是否显示
-				bShow:true,
+				bShow: true,
 				//切换连接
-				bSwitch:false
+				bSwitch: false
 			}
 		},
 		onLoad(op) {
@@ -82,23 +82,29 @@
 			// 	this.option = op;
 			// }
 			//目前是固定这个值,去掉了一级页面
-			this.option = {
-				cname: "手柄盒子",
-				deviceType: 'BLEHandle'
-			};
-			if (this.option.deviceType == 'BLEHandle') {
-				this.BLEInfoList.forEach((item, index, selfarr) => {
-					if (item.deviceType == 'BLEHandle') {
-						let item = Object.assign({}, selfarr[index]);
-						this.devicesList.push(item);
-					}
-				})
-			}
+			// this.option = {
+			// 	cname: "手柄盒子",
+			// 	deviceType: 'BLEHandle'
+			// };
+			// if (this.option.deviceType == 'BLEHandle') {
+			// 	this.BLEInfoList.forEach((item, index, selfarr) => {
+			// 		if (item.deviceType == 'BLEHandle' || item.deviceType == 'BLERope') {
+			// 			let item = Object.assign({}, selfarr[index]);
+			// 			this.devicesList.push(item);
+			// 		}
+			// 	})
+			// }
+			this.BLEInfoList.forEach((item, index, selfarr) => {
+				if (item.deviceType == 'BLEHandle' || item.deviceType == 'BLERope') {
+					let item = Object.assign({}, selfarr[index]);
+					this.devicesList.push(item);
+				}
+			})
 			uni.$on('retryConnectBLESuccess', this.onRetryConnectBLESuccess);
 			uni.$on('callbackCloseBLE', this.hardCallbackCloseBLE);
 			uni.$on('listenerBLE', this.onListenerBLE);
-			
-			
+
+
 
 		},
 		onUnload() {
@@ -120,15 +126,16 @@
 					if (
 						(eq.ename.indexOf("mobilePhoneBandage") > -1 && this.BLEConnectDevice.id == 0) ||
 						(eq.ename.indexOf("hotman") > -1 && this.BLEConnectDevice.id == 1) ||
-						(eq.ename.indexOf("BLEHandle") > -1 && this.BLEConnectDevice.id == 2)) {
+						(eq.ename.indexOf("BLEHandle") > -1 && this.BLEConnectDevice.id == 2)||
+						(eq.ename.indexOf("rope") > -1 && this.BLEConnectDevice.id == 3)) {
 						eq.bRatio = true;
 						this.currentItem = eq;
 
-						setTimeout(() => {
-							this.onCheckBondDevice();
-						}, 5000)
-						
-						
+						// setTimeout(() => {
+						// 	this.onCheckBondDevice();
+						// }, 5000)
+
+
 					}
 				}
 			} else {
@@ -193,12 +200,11 @@
 				// mac="较è¾";
 				//判断mac地址是否是合理的格式
 				var tempMacRegExp = /[A-Fa-f0-9]{2}:[A-Fa-f0-9]{2}:[A-Fa-f0-9]{2}:[A-Fa-f0-9]{2}:[A-Fa-f0-9]{2}:[A-Fa-f0-9]{2}/;
-				if (!tempMacRegExp.test(mac))
-				{
+				if (!tempMacRegExp.test(mac)) {
 					uni.hideToast();
 					uni.showModal({
 						title: '验证信息',
-						content:'获取Mac地址失败,请重新连接。'
+						content: '获取Mac地址失败,请重新连接。'
 					})
 					//关闭当前连接
 					_self.onOnlyCloseBLEConnection({
@@ -207,7 +213,7 @@
 							_self.saveObj = null;
 						}
 					});
-				    return;
+					return;
 				}
 
 				reqUtil.requestData(config.URL.BLEFINDHASBIND, {
@@ -257,7 +263,7 @@
 							uni.hideToast();
 							uni.showModal({
 								title: '连接失败',
-								content:'当前手柄已经被其它账号绑定。'
+								content: '当前手柄已经被其它账号绑定。'
 							})
 							//关闭当前连接
 							_self.onOnlyCloseBLEConnection({
@@ -285,7 +291,8 @@
 					if (
 						(eq.ename.indexOf("mobilePhoneBandage") > -1 && this.BLEConnectDevice.id == 0) ||
 						(eq.ename.indexOf("hotman") > -1 && this.BLEConnectDevice.id == 1) ||
-						(eq.ename.indexOf("BLEHandle") > -1 && this.BLEConnectDevice.id == 2)) {
+						(eq.ename.indexOf("BLEHandle") > -1 && this.BLEConnectDevice.id == 2)||
+						(eq.ename.indexOf("rope") > -1 && this.BLEConnectDevice.id == 3)) {
 
 						eq.bRatio = true;
 						this.currentItem = eq;
@@ -294,22 +301,22 @@
 						 */
 						this.$store.state.bVerifiedConnection = true;
 
-						setTimeout(() => {
-							this.onCheckBondDevice();
-						}, 5000)
-						
+						// setTimeout(() => {
+						// 	this.onCheckBondDevice();
+						// }, 5000)
+
 					}
 				}
 			},
 			onCheckBondDevice() {
-				console.log("onCheckBondDevice",this.bTestBondConnect);
+				console.log("onCheckBondDevice", this.bTestBondConnect);
 				if (this.bTestBondConnect && this.bShow) {
 					/**
 					 * 假如手机没有匹配,断开连接
 					 */
-					console.log(2,this.finallyUseDevice);
+					console.log(2, this.finallyUseDevice);
 					this.B_GetBondedDevices({
-						deviceId:this.finallyUseDevice.deviceId,
+						deviceId: this.finallyUseDevice.deviceId,
 						success: (bondedDevice) => {
 							uni.hideToast();
 							if (bondedDevice == null) {
@@ -341,16 +348,16 @@
 						}
 					});
 					this.bTestBondConnect = false;
-				}else{
+				} else {
 					uni.hideToast();
 				}
 			},
-			onRetryConnectBLESuccess(){
+			onRetryConnectBLESuccess() {
 				this.ConnectionSuccess();
 			},
 			hardCallbackCloseBLE() {
-				
-				if(this.BLEConnectDevice == null && this.currentItem && !this.bSwitch){
+
+				if (this.BLEConnectDevice == null && this.currentItem && !this.bSwitch) {
 					this.currentItem.bRatio = false;
 					this.currentItem = null;
 					this.saveObj = null;
@@ -422,13 +429,13 @@
 				// 	"localName": "BGBox_20201",
 				// 	"advertisServiceUUIDs": ["00001812-0000-1000-8000-00805F9B34FB", "0000FFF0-0000-1000-8000-00805F9B34FB"]
 				// }
-				
-				console.log("onBoded ***************:",_self.finallyUseDevice);
-				
+
+				console.log("onBoded ***************:", _self.finallyUseDevice);
+
 				_self.B_GetBondedDevices({
-					deviceId:_self.finallyUseDevice == null?null:_self.finallyUseDevice.deviceId,
+					deviceId: _self.finallyUseDevice == null ? null : _self.finallyUseDevice.deviceId,
 					success: (bondedDevice) => {
-						console.log("bondedDevice:",bondedDevice);
+						console.log("bondedDevice:", bondedDevice);
 						//获取已和蓝牙连接的设备
 						if (bondedDevice != null) {
 							//如果用户匹配了对应的设备,直接用对应的设备来连接
@@ -439,7 +446,7 @@
 								"localName": "",
 								"advertisServiceUUIDs": ["00001812-0000-1000-8000-00805F9B34FB", "0000FFF0-0000-1000-8000-00805F9B34FB"]
 							}
-							
+
 							let obj = Object.assign({}, setDevice, _self.currentItem);
 							//finallyUserDevice 就是最后一次使用搜索到的设备信息
 							_self.saveObj = Object.assign({}, setDevice, {
@@ -451,7 +458,7 @@
 								duration: 10000,
 								mask: true
 							})
-							console.log("GetBondedDevices:::===",setDevice,_self.currentItem, obj);
+							console.log("GetBondedDevices:::===", setDevice, _self.currentItem, obj);
 							// 先直连,然后判断版本
 							_self._onConnectDevice(obj);
 
@@ -460,9 +467,9 @@
 						} else {
 							console.log("没有获取到绑定的设备");
 							uni.showToast({
-								title:'获取匹配设备失败',
-								icon:'none',
-								mask:true
+								title: '获取匹配设备失败',
+								icon: 'none',
+								mask: true
 							})
 						}
 					}
@@ -482,7 +489,7 @@
 					allowDuplicatesKey: true,
 					success: res => {
 						console.log("startBluetoothDevicesDiscovery:", res);
-						
+
 						_self.bSwitch = false;
 						_self.onBluetoothDeviceFound();
 					},
@@ -502,8 +509,8 @@
 					//1.搜索12秒钟之后,停止搜索
 					_self.stopBluetoothDevicesDiscovery();
 					//搜索失败后,再检查是否和手机配对的设备连接
-					_self.onBondedDeviceConnect();
-					
+					// _self.onBondedDeviceConnect();
+
 				}, 8000)
 			},
 			/**
@@ -531,11 +538,13 @@
 					 */
 					// console.log("onBluetoothDeviceFound:", res);
 					res.devices.forEach(device => {
-						if (device.name.indexOf('PBox') > -1 || device.name.indexOf('BGBox') > -1) {
+						if (device.name.indexOf('PBox') > -1 || device.name.indexOf('BGBox') > -1 || device.name.indexOf('Rope') > -1) {
 							//如果搜索的设备名 不是对应当前设备类型,过滤
 							// if (device.name.indexOf(_self.currentItem.deviceName) == -1) return;
-							if (_self.currentItem.deviceName.indexOf('PBox') == -1 && _self.currentItem.deviceName.indexOf('BGBox') == -
-								1) return;
+							if (_self.currentItem.deviceName.indexOf('PBox') == -1 
+							&& _self.currentItem.deviceName.indexOf('BGBox') == -1
+							&& _self.currentItem.deviceName.indexOf('Rope') == -1
+							) return;
 							//寻找到对应设备时候,其余的返回
 							if (_self.searchObj) return;
 							_self.searchObj = device;
@@ -715,13 +724,13 @@
 			//跳转进入升级页面,
 			onNavUpdateDevice() {
 				// console.log('onNavUpdateDevice');
-				if (!this.option) {
-					uni.showToast({
-						title: 'option null',
-						icon: 'none'
-					})
-					return;
-				}
+				// if (!this.option) {
+				// 	uni.showToast({
+				// 		title: 'option null',
+				// 		icon: 'none'
+				// 	})
+				// 	return;
+				// }
 				//需要连接设备后,才能进入升级
 				if (!this.currentItem || !this.currentItem.bRatio || !this.BLEConnectDevice) {
 					uni.showToast({
@@ -731,33 +740,34 @@
 					return;
 				}
 
-				if (this.BLEConnectDevice.deviceType != this.option.deviceType) {
-					uni.showToast({
-						title: '设备类型不对',
-						icon: 'none'
-					})
-					return;
-				}
+				// if (this.BLEConnectDevice.deviceType != this.option.deviceType) {
+				// 	uni.showToast({
+				// 		title: '设备类型不对',
+				// 		icon: 'none'
+				// 	})
+				// 	return;
+				// }
 
 				this.bLimitClose = true;
 				uni.navigateTo({
-					url: "../devices-update/devices-update?deviceType=" + this.option.deviceType
+					// url: "../devices-update/devices-update?deviceType=" + this.option.deviceType
+					url: "../devices-update/devices-update"
 				})
 			},
-			onGetDevice(){
+			onGetDevice() {
 				uni.getBluetoothDevices({
 					success(res) {
 						console.log("getBluetoothDevices:", res)
 					}
 				})
-				
+
 				uni.getConnectedBluetoothDevices({
 					success(res) {
 						console.log("getConnectedBluetoothDevices:", res)
 					}
 				})
-				
-				
+
+
 			}
 		}
 

+ 119 - 86
pages/personal-page/personal/personal.vue

@@ -100,7 +100,7 @@
 							<!-- <view id="boxingHitID" style="position: absolute;top: 180rpx; pointer-events: none;" ></view> -->
 							<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 == 'mySelf'||BLEConnectDevice.deviceType == 'BLEHandle' || BLEConnectDevice.deviceType == 'BLERope' )"
 								 :showTime="localSportTime" :bRebound="BLEConnectDevice&&BLEConnectDevice.limitType == 'rebound'"
 								 @updateCalorie="boxingUpdateCalorie" @boxingPostCheck="onPersonalCheck" @shake="onScreenShake"
 								 @updateSportTime="onUpdateSportTime" @boxingGuideFinish="onBoxingGuideFinish" @boxingPostControlPlay="onBoxingPostControlPlay"
@@ -289,7 +289,7 @@
 						<!-- <button class="margin" @click="openGyro">开启手机加速计和方向传感器</button> -->
 						<!-- <button class="margin" @click="stopGyro">关闭手机加速计和方向传感器</button> -->
 						<!-- <button class="margin" @click="getBLEDeviceServices">getBLEDeviceServices</button> -->
-						
+
 						<!-- <keyboard-listener @keydown="onKeyDown"></keyboard-listener> -->
 						<!-- 视频推荐 -->
 						<view class="card-view" v-if="cIndex != -1 && versionCodeState&&versionCodeState.showVideo && videoList.length !== 0">
@@ -390,7 +390,8 @@
 		</view>
 
 		<!-- 引导蒙层 bGuidePages guideCurrent-->
-		<code-elf-guide ref="codeElfGuide" v-if="bGuidePages" @hide="guideHide" @change="onGuideChange" :current="guideCurrent" :currentMode="currentMode"></code-elf-guide>
+		<code-elf-guide ref="codeElfGuide" v-if="bGuidePages" @hide="guideHide" @change="onGuideChange" :current="guideCurrent"
+		 :currentMode="currentMode"></code-elf-guide>
 
 		<!-- <view v-if="bStartBoxingPost" class="CountDownMask">
 			{{BoxingPostCountDownText}}
@@ -740,7 +741,7 @@
 					avatar: '/static/defaultAvatar.png'
 				},
 				currentMode: 'calorieMode', //pkMode calorieMode
-				
+
 				bHitShake: false,
 
 				bAiHitShake: false,
@@ -878,15 +879,15 @@
 			if (this.bVerifiedConnection && this.BLEConnectDevice) {
 				this.updateBLECIndex();
 
-				setTimeout(() => {
-					/**
-					 * 如果是首页连接,则检测
-					 */
-					if (this.bGetBondTesting) {
-						this.onGetBondDevice();
-						this.bGetBondTesting = false;
-					}
-				}, 5000)
+				// setTimeout(() => {
+				// 	/**
+				// 	 * 如果是首页连接,则检测
+				// 	 */
+				// 	if (this.bGetBondTesting) {
+				// 		this.onGetBondDevice();
+				// 		this.bGetBondTesting = false;
+				// 	}
+				// }, 5000)
 
 			}
 
@@ -954,7 +955,7 @@
 				'syncLocalDataToServer', 'syncRequestEvent', 'setLocalSportTime',
 				'initAdapter', 'onCreateBLEConnection', 'onUnloadCreateBLEConnectionTimeout', 'onCloseBLEConnection',
 				'gOnAddClientInfo', 'onWriteBLEConnectionValue',
-				'gCreateFilterObj', 'gUpdateFilter', 'B_GetBondedDevices', 'B_OpenBLESetting'
+				'gCreateFilterObj', 'gUpdateFilter', 'B_GetBondedDevices', 'B_OpenBLESetting','B_OpenRopeSkipping','B_CloseRopeSkipping'
 			]),
 			onKeyDown(e) {
 				console.log(e);
@@ -1343,31 +1344,41 @@
 					let eq = this.BLEDeviceShowList[i];
 					if ((eq.ename.indexOf("mobilePhoneBandage") > -1 && this.BLEConnectDevice.id == 0) ||
 						(eq.ename.indexOf("hotman") > -1 && this.BLEConnectDevice.id == 1) ||
-						(eq.ename.indexOf("BLEHandle") > -1 && this.BLEConnectDevice.id == 2)) {
+						(eq.ename.indexOf("BLEHandle") > -1 && this.BLEConnectDevice.id == 2) ||
+						(eq.ename.indexOf("rope") > -1 && this.BLEConnectDevice.id == 3)) {
 
 						eq.bRatio = true;
 						this.$store.state.cIndex = i;
 
 					}
-					
-					if(eq.ename.indexOf("hotman") > -1 && this.BLEConnectDevice.id == 1){
-						if(this.$refs.boxingPostRef){
+
+					if (eq.ename.indexOf("hotman") > -1 && this.BLEConnectDevice.id == 1) {
+						if (this.$refs.boxingPostRef) {
 							this.$refs.boxingPostRef.onSetMode('pkMode');
-						}else{
-							setTimeout(()=>{
+						} else {
+							setTimeout(() => {
 								this.$refs.boxingPostRef.onSetMode('pkMode');
-							},500)
+							}, 500)
 						}
-						
-					}else if(eq.ename.indexOf("BLEHandle") > -1 && this.BLEConnectDevice.id == 2){
-						if(this.$refs.boxingPostRef){
+
+					} else if (eq.ename.indexOf("BLEHandle") > -1 && this.BLEConnectDevice.id == 2) {
+						if (this.$refs.boxingPostRef) {
 							this.$refs.boxingPostRef.onSetMode('calorieMode');
-						}else{
-							setTimeout(()=>{
+						} else {
+							setTimeout(() => {
 								this.$refs.boxingPostRef.onSetMode('calorieMode');
-							},500)
+							}, 500)
+						}
+					} else if (eq.ename.indexOf("rope") > -1 && this.BLEConnectDevice.id == 3) {
+						//todo 暂时设置兼容跑步模式
+						if (this.$refs.boxingPostRef) {
+							this.$refs.boxingPostRef.onSetMode('ropeMode');
+						} else {
+							setTimeout(() => {
+								this.$refs.boxingPostRef.onSetMode('ropeMode');
+							}, 500)
 						}
-					} 
+					}
 				}
 			},
 
@@ -1432,6 +1443,13 @@
 				} else if (this.BLEConnectDevice.usageMode == "general") {
 					//这个是普通打击模式
 					this.$refs.boxingPostRef.onBLEHandleUpdate(data);
+				} else if (this.BLEConnectDevice.usageMode == "ropeSkipping") {
+					//跳绳蓝牙反馈
+					let _data = {
+						jump: 1
+					}
+					this.$refs.boxingPostRef.onBLERopeUpdate(_data);
+
 				}
 
 
@@ -1490,7 +1508,7 @@
 					uni.showToast({
 						title: '当前已连接设备',
 						icon: 'none',
-						mask:true
+						mask: true
 					})
 					return;
 				}
@@ -1508,20 +1526,22 @@
 							this.bGetBondTesting = true;
 						} else {
 							//没有弹出框时候,直接检测
-							setTimeout(() => {
-								this.onGetBondDevice();
-							}, 5000)
+							// setTimeout(() => {
+							// 	this.onGetBondDevice();
+							// }, 5000)
 						}
-						
+
 						//刷新状态
-						if(this.cIndex != -1){
+						if (this.cIndex != -1) {
 							let eq = this.BLEDeviceShowList[this.cIndex];
 							// console.log(eq,this.BLEConnectDevice);
-							if(eq.ename.indexOf("hotman") > -1 && this.BLEConnectDevice.id == 1){
+							if (eq.ename.indexOf("hotman") > -1 && this.BLEConnectDevice.id == 1) {
 								this.$refs.boxingPostRef.onSetMode('pkMode');
-							}else if(eq.ename.indexOf("BLEHandle") > -1 && this.BLEConnectDevice.id == 2){
+							} else if (eq.ename.indexOf("BLEHandle") > -1 && this.BLEConnectDevice.id == 2) {
 								this.$refs.boxingPostRef.onSetMode('calorieMode');
-							} 
+							} else if (eq.ename.indexOf("rope") > -1 && this.BLEConnectDevice.id == 3) {
+								this.$refs.boxingPostRef.onSetMode('ropeMode');
+							}
 						}
 					}
 				});
@@ -1533,9 +1553,9 @@
 				/**
 				 * 假如手机没有匹配,断开连接
 				 */
-				console.log("****",this.BLEConnectDevice);
-				if(!this.BLEConnectDevice)return;
-				
+				console.log("****", this.BLEConnectDevice);
+				if (!this.BLEConnectDevice) return;
+
 				this.B_GetBondedDevices({
 					deviceId: this.BLEConnectDevice.deviceId,
 					success: (bondedDevice) => {
@@ -1623,12 +1643,12 @@
 			onCloseDevice(item, e) {
 				//如果不是连接状态,则删除
 				if (e.currentTarget.dataset.index != this.cIndex) {
-					if(this.cIndex !=-1){
+					if (this.cIndex != -1) {
 						uni.showToast({
-							icon:'none',
-							title:"请先断开已连接设备",
-							duration:2000,
-							mask:true
+							icon: 'none',
+							title: "请先断开已连接设备",
+							duration: 2000,
+							mask: true
 						})
 						return;
 					}
@@ -1796,24 +1816,28 @@
 						this.toView = "boxingHitID";
 						this.$store.state.bNewGuide = false;
 					} 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({
-								value: config.refreshRate
+								value: "3"
 							});
 
-						}, 1000)
+							setTimeout(() => {
+								//设置加速计b:20ms a:10ms
+								this.onWriteBLEConnectionValue({
+									value: config.refreshRate
+								});
 
+							}, 1000)
+						}
 
 						//监听蓝牙回调
 						uni.$on('updateBLEDeviceData', this.callbackUpdateBLEData);
@@ -1851,7 +1875,7 @@
 				}
 
 
-				if (this.currentMode == 'calorieMode') {
+				if (this.currentMode == 'calorieMode' || this.currentMode == 'ropeMode') {
 					this.personalAudioContext.stop();
 					this.personalAudioContext.play();
 
@@ -2143,7 +2167,7 @@
 				this.currentMode = data.mode;
 				this.title = data.name;
 
-				if (this.currentMode == 'calorieMode') {
+				if (this.currentMode == 'calorieMode' || this.currentMode == 'ropeMode') {
 					setTimeout(() => {
 						this.updateNoLimit();
 					}, 0)
@@ -2199,10 +2223,15 @@
 			//弹出目标提示后,进行下一步
 			onBoxingPause(bFinish) {
 				if (bFinish) {
-					//停止蓝牙加速计
-					this.onWriteBLEConnectionValue({
-						value: "4"
-					});
+					if(this.BLEConnectDevice.usageMode == "ropeSkipping"){
+						this.B_CloseRopeSkipping();
+					}else{
+						//停止蓝牙加速计
+						this.onWriteBLEConnectionValue({
+							value: "4"
+						});
+					}
+					
 
 					uni.$off('updateBLEDeviceData', this.callbackUpdateBLEData);
 
@@ -2245,7 +2274,7 @@
 					//跳转计划页面
 					this.openPlan();
 				} else if (e.current == 1 && !e.onlyHide) {
-					console.log('guideHide:',e.current);
+					console.log('guideHide:', e.current);
 					//跳转搜索设备页面
 					// this.openDeviceList();
 				} else if (e.current == 3 && !e.onlyHide) {
@@ -2271,24 +2300,28 @@
 					}, 200);
 				} else if (e.current == 5 && !e.onlyHide) {
 					console.log("==:", e);
-					//初始化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({
-							value: config.refreshRate
+							value: "3"
 						});
-					
-					}, 1000)
-					
-					
+
+						setTimeout(() => {
+							//设置加速计b:20ms a:10ms
+							this.onWriteBLEConnectionValue({
+								value: config.refreshRate
+							});
+
+						}, 1000)
+					}
+
 					//监听蓝牙回调
 					uni.$on('updateBLEDeviceData', this.callbackUpdateBLEData);
 					this.onBoxingGuideFinish();
@@ -2482,10 +2515,10 @@
 					url: '../../info-page/app-info/app-info'
 				})
 			},
-			
-			getBLEDeviceServices(){
+
+			getBLEDeviceServices() {
 				console.log("getBLEDeviceServices");
-				
+
 				// uni.getBLEDeviceServices({
 				// 	deviceId: "C5:5C:19:04:00:30",
 				// 	success: res => {
@@ -2493,7 +2526,7 @@
 				// 	},
 				// 	fail: failRes => {
 				// 		console.log('device services:', failRes)
-						
+
 				// 	}
 				// });
 			}

BIN
static/devicesIcon/rope.png


BIN
static/devicesIconSimple/rope_icon@2x.png


+ 24 - 17
util/util-js/devices.js

@@ -74,23 +74,30 @@ const getDeviceList = function() {
 				currentVersion: '1.2.0', //当前固件版本
 				latestVersion: '1.2.0' //服务器最新固件版本
 			},
-			// {
-			// 	id: 3,
-			// 	cname: "蓝牙手柄",
-			// 	ename: "BLEHandle",
-			// 	icon: "/static/devicesIcon/handle.png",
-			// 	mIcon: "/static/devicesIconSimple/handle.png",
-			// 	bRatio: false,
-			// 	usageMode: "jump", //跳
-			// 	describe: '跳的情景下使用,不限制回弹。',
-			// 	limitType: 'noRebound', //app处理蓝牙发送的数据
-			// 	deviceType: 'BLEHandle', //指的是外部蓝牙,目前定义为BLEHandle
-			// 	deviceName: 'PBox', //连接的设备名称
-			// 	limitDis: 100, //
-			// 	primaryUUID: 'FFF0', //蓝牙主服务id
-			// 	currentVersion: '1.2.0', //当前固件版本
-			// 	latestVersion: '1.2.0' //服务器最新固件版本
-			// }
+			{
+				id: 3,
+				cname: "跳绳模式",
+				ename: "rope",
+				icon: "/static/devicesIcon/rope.png",
+				mIcon: "/static/devicesIconSimple/rope_icon@2x.png",
+				bRatio: false,
+				usageMode: "ropeSkipping", //通用情况,根据需求处理
+				describe: '跳绳模式下使用',
+				limitType: 'rebound', //app处理蓝牙发送的数据
+				deviceType: 'BLERope', //指的是外部蓝牙,目前定义为BLERope
+				deviceName: 'Rope', //连接的设备名称
+				limitDis: 100, //
+				/**
+				 * 主服务的 uuid Cofing
+				 */
+				primaryUUID: 'FFF0', //蓝牙主服务id
+				PRIMARY_SERVICE: '0000FFF0-0000-1000-8000-00805F9B34FB',
+				PRIMARY_WRITE: '0000FFF2-0000-1000-8000-00805F9B34FB',
+				PRIMARY_NOTIFY: '0000FFF1-0000-1000-8000-00805F9B34FB',
+				/***********/
+				currentVersion: '1.2.0', //当前固件版本
+				latestVersion: '1.2.0' //服务器最新固件版本
+			}
 		];
 
 	return deviceList;

+ 149 - 48
util/util-js/store.js

@@ -269,12 +269,17 @@ const store = new Vuex.Store({
 		serviceId: "",
 		notifyCharacteristicId: "",
 		writeCharacteristicId: "",
-		currentInstruction: "",
+
 		showToast: false,
 		bListenerUpdate: false,
 		bListenerJson: false,
 		bListenerMac: false,
 
+		/**
+		 * 发送16进制时候,返回的刷新数据
+		 */
+		bListenerHexUpdate: false,
+
 
 		BluetoothAdapter: null,
 
@@ -283,7 +288,11 @@ const store = new Vuex.Store({
 
 		//显示蓝牙是否断开连接Modal
 		bShowBLEConnectModal: false,
-		bGamePlaying:false,
+		bGamePlaying: false,
+
+		//跳绳条件下计数
+		bRopeKeyOne: 0,
+		bRopeKeyTwo: 0
 
 	},
 	mutations: {
@@ -1382,6 +1391,8 @@ const store = new Vuex.Store({
 			state.bListenerJson = false;
 
 			state.bListenerMac = false;
+			//更新二进制的
+			state.bListenerHexUpdate = false;
 
 		},
 		//连接蓝牙
@@ -1393,14 +1404,14 @@ 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) => {
@@ -1481,7 +1492,7 @@ const store = new Vuex.Store({
 						})
 					} else {
 						// err.errCode10003原因多种:蓝牙设备未开启或异常导致无法连接;蓝牙设备被占用或者上次蓝牙连接未断开导致无法连接
-						console.log("连接失败,请重试!",state.BLEConnectDevice);
+						console.log("连接失败,请重试!", state.BLEConnectDevice);
 						uni.showToast({
 							title: '请尝试开启设备和重启app。',
 							icon: 'none',
@@ -1648,7 +1659,9 @@ const store = new Vuex.Store({
 			let {
 				getSuccess = null,
 					getFail = null,
-					value
+					value,
+					bSendHex = false,
+					bOpen = false,
 			} = context;
 
 			if (!state.BLEConnectDevice && state.cIndex == -1) {
@@ -1659,7 +1672,7 @@ const store = new Vuex.Store({
 			}
 			// console.log(22);
 			//记录蓝牙盒子当前的指令
-			state.currentInstruction = value;
+			// state.currentInstruction = value;
 			// 发送 3 :开启原始数据
 			// 发送4 :关闭原始数据
 			// 发送 5 :开启步数
@@ -1672,13 +1685,18 @@ const store = new Vuex.Store({
 				state.instructionState.bSteps = true;
 			} else if (value == "6") {
 				state.instructionState.bSteps = false;
+			} else if (bSendHex && bOpen) {
+				state.instructionState.bOpen = true;
+			} else if (bSendHex && !bOpen) {
+				state.instructionState.bOpen = false;
 			}
 			let retryCount = 5;
 			this.commit("B_WriteBLECharacteristicValue", {
 				value,
 				retryCount,
 				getSuccess,
-				getFail
+				getFail,
+				bSendHex
 			});
 		},
 		//获取距离
@@ -1935,18 +1953,18 @@ const store = new Vuex.Store({
 					//要在连接的状态下 ,并且获取过匹配列表有参数的情况下,才提示重连
 					if (!state.bShowBLEConnectModal && state.bVerifiedConnection && state.bPhoneMatched) {
 						state.bShowBLEConnectModal = true;
-						let _connectItem = Object.assign({},state.BLEConnectDevice);
+						let _connectItem = Object.assign({}, state.BLEConnectDevice);
 						let _cIndex = state.cIndex;
 						//断开连接后reset一下参数
 						_self.commit("onResetBLEConnection");
-						
-						let _tip = state.bGamePlaying? "蓝牙已断开是否重新连接蓝牙?重连需要重启游戏!":"蓝牙已断开是否重新连接蓝牙";
+
+						let _tip = state.bGamePlaying ? "蓝牙已断开是否重新连接蓝牙?重连需要重启游戏!" : "蓝牙已断开是否重新连接蓝牙";
 						uni.showModal({
 							title: _tip,
 							success: (sRes) => {
 								state.bShowBLEConnectModal = false;
 								if (sRes.confirm) {
-									console.log("重连的_cIndex:",_cIndex);
+									console.log("重连的_cIndex:", _cIndex);
 									_self.commit("onCreateBLEConnection", {
 										item: _connectItem,
 										index: _cIndex,
@@ -2217,18 +2235,80 @@ const store = new Vuex.Store({
 					uni.$emit('updateBLEDeviceData', box);
 				}
 
+				//todo 解析跳绳模式
+				if (state.bListenerHexUpdate) {
+					//报头,固定
+					let byte1 = resValue.substr(0, 2);
+					//功能码,todo 
+					let byte2 = resValue.substr(2, 2);
 
-			});
-		},
+					// 报文类型,后续区分在这里,目前是跳绳模式类型
+					let byte3 = resValue.substr(4, 2);
+
+					//报文内容,长度以 2为单位 动态变化
+					let byteData = resValue.substr(6, resValue.length - 10)
+					//报文按照长度2切割
+					let byteArray = byteData.replace(/(\d{2})(?=(?:\d{2})+(?!\d))/g, '$1,').split(',');
+					console.log("byteArray:", byteArray);
+					// 校验
+					let byteVerify = resValue.substr(resValue.length - 4, 2);
+					// 报尾,结束
+					let byteEnd = resValue.substr(resValue.length - 2, 2);
+
+					//todo 暂时先这样触发
+					if (byteArray.length == 2 && byteArray[0] != byteArray[1]) {
+
+						if (byteArray[0] == '00') {
 
+							state.bRopeKeyOne = 1;
+						}else {
+							//'01'
+							state.bRopeKeyTwo = 1;
 
+						}
+
+						if (state.bRopeKeyOne == 1 && state.bRopeKeyTwo == 1) {
+
+							state.bRopeKeyOne = 0;
+							state.bRopeKeyTwo = 0;
+
+							box["Rope"] = 1;
+							uni.$emit('updateBLEDeviceData', box);
+						}
+					}
+
+				}
+
+			});
+		},
+		/**
+		 * 开启跳绳模式
+		 */
+		B_OpenRopeSkipping() {
+			this.commit('onWriteBLEConnectionValue', {
+				value: "5B310101FE5D",
+				bSendHex: true,
+				bOpen: true
+			});
+		},
+		/**
+		 * 关闭跳绳模式
+		 */
+		B_CloseRopeSkipping() {
+			this.commit('onWriteBLEConnectionValue', {
+				value: "5B210100FF5D",
+				bSendHex: true,
+				bOpen: false
+			});
+		},
 		//向低功耗蓝牙设备特征值中写入二进制数据。注意:必须设备的特征值支持 write 才可以成功调用。
 		B_WriteBLECharacteristicValue(state, context) {
 			let {
 				value,
 				retryCount,
 				success,
-				getFail
+				getFail,
+				bSendHex,
 			} = context;
 			if (!value && value === '') {
 				uni.showToast({
@@ -2236,44 +2316,65 @@ const store = new Vuex.Store({
 				})
 				return;
 			}
-			//记录一下指令
-			state.currentInstruction = value;
-			//V 获取版本,M 获取mac 地址
-			if (value == "V")
-				state.showToast = true;
-
-			if (value == "M") {
-				state.showToast = true;
-				state.bListenerMac = true;
-			}
-			if (value == "4") {
+			let _sendData;
+			if (bSendHex) {
+				
+				state.bRopeKeyTwo = 0;
+				state.bRopeKeyOne = 0;
+				
+				//如果是发送16进制
+				state.bListenerHexUpdate = true;
+
+				//重置原 update
 				state.bListenerUpdate = false;
-			}
-			if (value == "3") {
-				if (state.bListenerUpdate) {
-					uni.showToast({
-						title: "原始数据已开启"
-					})
-					return;
+
+				let typedArray = new Uint8Array(value.match(/[\da-f]{2}/gi).map(function(h) {
+					return parseInt(h, 16)
+				}))
+				_sendData = typedArray.buffer;
+			} else {
+				state.bListenerHexUpdate = false;
+				//记录一下指令
+				state.currentInstruction = value;
+				//V 获取版本,M 获取mac 地址
+				if (value == "V")
+					state.showToast = true;
+
+				if (value == "M") {
+					state.showToast = true;
+					state.bListenerMac = true;
+				}
+				if (value == "4") {
+					state.bListenerUpdate = false;
+				}
+				if (value == "3") {
+					if (state.bListenerUpdate) {
+						uni.showToast({
+							title: "原始数据已开启"
+						})
+						return;
+					}
+					state.bListenerUpdate = true;
 				}
-				state.bListenerUpdate = true;
-			}
 
-			if (value == "6") {
-				state.bListenerJson = false;
-			}
-			if (value == "5") {
-				if (state.bListenerJson) {
-					uni.showToast({
-						title: "步数数据已开启"
-					})
-					return;
+				if (value == "6") {
+					state.bListenerJson = false;
+				}
+				if (value == "5") {
+					if (state.bListenerJson) {
+						uni.showToast({
+							title: "步数数据已开启"
+						})
+						return;
+					}
+					state.bListenerJson = true;
 				}
-				state.bListenerJson = true;
-			}
 
+				_sendData = BLE.str2ab(value);
+			}
 
-			console.log("currentInstruction:", state.currentInstruction, value, state.bListenerUpdate, state.bListenerMac);
+			console.log("currentInstruction:", state.currentInstruction, value, state.bListenerUpdate, state.bListenerMac,
+				state.bListenerHexUpdate);
 			console.log("state.deviceId:", state.deviceId, state.serviceId, state.writeCharacteristicId);
 			uni.writeBLECharacteristicValue({
 				deviceId: state.deviceId,
@@ -2281,7 +2382,7 @@ const store = new Vuex.Store({
 				// 这里的 characteristicId 需要在 getBLEDeviceCharacteristics 接口中获取
 				characteristicId: state.writeCharacteristicId,
 				// 这里的value是ArrayBuffer类型
-				value: BLE.str2ab(value),
+				value: _sendData,
 				success: (res) => {
 					console.log('writeBLECharacteristicValue success', res.errMsg, value, retryCount);
 					if (success) {