|
@@ -98,7 +98,10 @@
|
|
|
*/
|
|
*/
|
|
|
//跳绳数据判断对象
|
|
//跳绳数据判断对象
|
|
|
actionJumpObj: null,
|
|
actionJumpObj: null,
|
|
|
- BLEAccIndex: 0
|
|
|
|
|
|
|
+ BLEAccIndex: 0,
|
|
|
|
|
+
|
|
|
|
|
+ //定义事件映射表
|
|
|
|
|
+ handlers: new Map()
|
|
|
}
|
|
}
|
|
|
},
|
|
},
|
|
|
onLoad() {
|
|
onLoad() {
|
|
@@ -150,10 +153,14 @@
|
|
|
if (_self.bMyAttitudeListen) {
|
|
if (_self.bMyAttitudeListen) {
|
|
|
_self.gStopSimulateBLEUpdate();
|
|
_self.gStopSimulateBLEUpdate();
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
|
|
+ //停止脸部检测
|
|
|
|
|
+ _self.handleFaceStopDetect();
|
|
|
|
|
+
|
|
|
// console.log(_self.BLEConnectDevice);
|
|
// console.log(_self.BLEConnectDevice);
|
|
|
//如果连接了蓝牙设备是手柄
|
|
//如果连接了蓝牙设备是手柄
|
|
|
- if (_self.BLEConnectDevice && ( _self.BLEConnectDevice.deviceType == "BLEHandle" || _self.BLEConnectDevice.deviceType == "BLEIntelligent")) {
|
|
|
|
|
|
|
+ if (_self.BLEConnectDevice && (_self.BLEConnectDevice.deviceType == "BLEHandle" || _self
|
|
|
|
|
+ .BLEConnectDevice.deviceType == "BLEIntelligent")) {
|
|
|
//开启设备回调 3/4关闭
|
|
//开启设备回调 3/4关闭
|
|
|
_self.onWriteBLEConnectionValue({
|
|
_self.onWriteBLEConnectionValue({
|
|
|
value: "4"
|
|
value: "4"
|
|
@@ -169,7 +176,7 @@
|
|
|
//拳击柱
|
|
//拳击柱
|
|
|
_self.uploadUserData_hitCount();
|
|
_self.uploadUserData_hitCount();
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
} //关闭跳绳模式指令
|
|
} //关闭跳绳模式指令
|
|
|
else if (_self.BLEConnectDevice && _self.BLEConnectDevice.deviceType == "BLERope") {
|
|
else if (_self.BLEConnectDevice && _self.BLEConnectDevice.deviceType == "BLERope") {
|
|
|
console.warn("还没设置关闭跳绳模式")
|
|
console.warn("还没设置关闭跳绳模式")
|
|
@@ -197,6 +204,9 @@
|
|
|
|
|
|
|
|
//设置store状态
|
|
//设置store状态
|
|
|
_self.$store.state.bGamePlaying = true;
|
|
_self.$store.state.bGamePlaying = true;
|
|
|
|
|
+
|
|
|
|
|
+ // 注册事件
|
|
|
|
|
+ _self.registerHandlers();
|
|
|
},
|
|
},
|
|
|
onUnload() {
|
|
onUnload() {
|
|
|
this.$store.state.bGamePlaying = false;
|
|
this.$store.state.bGamePlaying = false;
|
|
@@ -213,11 +223,17 @@
|
|
|
uni.$emit("game-unload");
|
|
uni.$emit("game-unload");
|
|
|
},
|
|
},
|
|
|
methods: {
|
|
methods: {
|
|
|
- ...mapMutations(['addlocalCalorie', 'syncRequestEvent', 'onWriteBLEConnectionValue', 'B_WriteHexToBLECharacteristic',
|
|
|
|
|
|
|
+ ...mapMutations(['addlocalCalorie', 'syncRequestEvent', 'onWriteBLEConnectionValue',
|
|
|
|
|
+ 'B_WriteHexToBLECharacteristic',
|
|
|
'gCreateFilterObj', 'gUpdateFilter', 'B_OpenRopeSkipping', 'B_CloseRopeSkipping',
|
|
'gCreateFilterObj', 'gUpdateFilter', 'B_OpenRopeSkipping', 'B_CloseRopeSkipping',
|
|
|
- 'gStopSimulateBLEUpdate', 'gStartSimulateBLEUpdate', 'gIntelligentUpdateSandbagAlgorithm', 'gUpdateSandbagAlgorithm',
|
|
|
|
|
- 'gCreateSandbagAlgorithm','gIntelligentCreateSandbagAlgorithm', 'onConvertDeviceData', 'addSandbagHitCount', 'uploadUserData_hitCount',
|
|
|
|
|
- 'jumpIdenModule_onJump6AxisDataUpdate'
|
|
|
|
|
|
|
+ 'gStopSimulateBLEUpdate', 'gStartSimulateBLEUpdate', 'gIntelligentUpdateSandbagAlgorithm',
|
|
|
|
|
+ 'gUpdateSandbagAlgorithm',
|
|
|
|
|
+ 'gCreateSandbagAlgorithm', 'gIntelligentCreateSandbagAlgorithm', 'onConvertDeviceData',
|
|
|
|
|
+ 'addSandbagHitCount', 'uploadUserData_hitCount',
|
|
|
|
|
+ 'jumpIdenModule_onJump6AxisDataUpdate',
|
|
|
|
|
+ //面部识别START
|
|
|
|
|
+ 'faceModule_startDetect', 'faceModule_stopDetect', 'faceModule_setPreview'
|
|
|
|
|
+ //面部识别END
|
|
|
]),
|
|
]),
|
|
|
navBack() {
|
|
navBack() {
|
|
|
|
|
|
|
@@ -364,7 +380,8 @@
|
|
|
avatarBase64Url: toBase64Url,
|
|
avatarBase64Url: toBase64Url,
|
|
|
userName: this.userName,
|
|
userName: this.userName,
|
|
|
gender: this.gender,
|
|
gender: this.gender,
|
|
|
- caloriUnit: 10,
|
|
|
|
|
|
|
+ caloriUnit: 10,//废弃字段
|
|
|
|
|
+ calorieUnit: 10,
|
|
|
calorieParams: calorieParams,
|
|
calorieParams: calorieParams,
|
|
|
//蓝牙连接的设备
|
|
//蓝牙连接的设备
|
|
|
device: device,
|
|
device: device,
|
|
@@ -414,364 +431,465 @@
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
},
|
|
},
|
|
|
- handlePostMessage: function(postData) {
|
|
|
|
|
- console.log("handlePostMessage得到参数", postData.detail);
|
|
|
|
|
- let temp = postData.detail.data[0];
|
|
|
|
|
- let gameData = temp.gameData;
|
|
|
|
|
- if (temp.funName == "uploadInfo") {
|
|
|
|
|
-
|
|
|
|
|
- //TODO:写入排行榜分数,后面需要在游戏完结里面调用
|
|
|
|
|
- //TODO: 后面游戏时间,卡路里的需要写入数据库,目前只是处理了分数
|
|
|
|
|
- // let num = Math.round(Math.random() * 10000);
|
|
|
|
|
- //1. gameScore 处理上传的分数
|
|
|
|
|
- // let _temp = {
|
|
|
|
|
- // gameId: '1595755153789139696',
|
|
|
|
|
- // score: 1230,
|
|
|
|
|
- // cityCode: '110101',
|
|
|
|
|
- // };
|
|
|
|
|
- //2. calorieBurned 处理卡路里
|
|
|
|
|
- // 记录卡路里到本地
|
|
|
|
|
- this.addlocalCalorie(gameData.calorieBurned);
|
|
|
|
|
- console.log("gameData.calorieBurned", gameData.calorieBurned);
|
|
|
|
|
- //然后更新上服务器
|
|
|
|
|
- this.syncRequestEvent({
|
|
|
|
|
- success: () => {
|
|
|
|
|
- // uni.$emit('updateArcbarData', '');
|
|
|
|
|
-
|
|
|
|
|
- let _temp = {
|
|
|
|
|
- //假如排行id 为空,排行榜就是游戏自己的id
|
|
|
|
|
- gameId: this.decodeItem.gameRankingId == null ? this.decodeItem
|
|
|
|
|
- .gameId : this.decodeItem.gameRankingId,
|
|
|
|
|
- score: gameData.gameScore,
|
|
|
|
|
- cityCode: this.city.cityCode,
|
|
|
|
|
- bMaxLimit: true
|
|
|
|
|
- }
|
|
|
|
|
- console.log('_temp =====', _temp);
|
|
|
|
|
-
|
|
|
|
|
- reqUtil.requestData(config.URL.UPLOADRANKING, _temp, "POST").then(res => {
|
|
|
|
|
- console.log('UPLOADRANKING =====', res);
|
|
|
|
|
- if (res.code == 0) {
|
|
|
|
|
- //TODO 后续游戏数据处理
|
|
|
|
|
- this.sendMessage("onUploadInfo", {
|
|
|
|
|
- code: 0,
|
|
|
|
|
- msg: '上传成功'
|
|
|
|
|
- });
|
|
|
|
|
- } else {
|
|
|
|
|
- //TODO 后续游戏数据处理
|
|
|
|
|
- this.sendMessage("onUploadInfo", {
|
|
|
|
|
- code: 400,
|
|
|
|
|
- msg: '上传失败'
|
|
|
|
|
- });
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- },
|
|
|
|
|
- e => {
|
|
|
|
|
- console.log(e)
|
|
|
|
|
- });
|
|
|
|
|
- },
|
|
|
|
|
- fail: () => {
|
|
|
|
|
- this.sendMessage("onUploadInfo", {
|
|
|
|
|
- code: 400,
|
|
|
|
|
- msg: '上传失败'
|
|
|
|
|
- });
|
|
|
|
|
|
|
+ // 注册所有事件
|
|
|
|
|
+ registerHandlers() {
|
|
|
|
|
+ this.handlers.set("uploadInfo", (gameData) => this.handleUploadInfo(gameData)); //上传分数
|
|
|
|
|
+ this.handlers.set("gameInit", () => this.sendGameInit()); //获取游戏信息
|
|
|
|
|
+ this.handlers.set("aiRandomInfo", (gameData) => this.handleAiRandomInfo(gameData));
|
|
|
|
|
+ this.handlers.set("fruitInfo", (gameData) => this.handleFruitInfo(gameData));
|
|
|
|
|
+ this.handlers.set("urlToBase64", (gameData) => this.handleUrlToBase64(gameData));
|
|
|
|
|
+ this.handlers.set("openAccelerometer", () => this.handleOpenAccelerometer());
|
|
|
|
|
+ this.handlers.set("closeAccelerometer", () => this.handleCloseAccelerometer());
|
|
|
|
|
+ this.handlers.set("openOrientation", () => this.handleOpenOrientation());
|
|
|
|
|
+ this.handlers.set("closeOrientation", () => this.handleCloseOrientation());
|
|
|
|
|
+
|
|
|
|
|
+ this.handlers.set("bindBoxingPost", () => this.handleBindBoxingPost());
|
|
|
|
|
+ this.handlers.set("unbindBoxingPost", () => this.handleUnbindBoxingPost());
|
|
|
|
|
+ this.handlers.set("setAngleRatio", (gameData) => this.handleSetAngleRatio(gameData));
|
|
|
|
|
+ this.handlers.set("bindHitBoxingPost", () => this.handleBindHitBoxingPost());
|
|
|
|
|
+ this.handlers.set("unbindHitBoxingPost", () => this.handleUnbindHitBoxingPost());
|
|
|
|
|
+
|
|
|
|
|
+ this.handlers.set("closeGame", () => this.handleCloseGame());
|
|
|
|
|
+ this.handlers.set("addQuitModal", () => this.handleAddQuitModal());
|
|
|
|
|
+ this.handlers.set("removeQuitModal", () => this.handleRemoveQuitModal());
|
|
|
|
|
+ this.handlers.set("writeBLEConnectionValue", (gameData) => this.handleWriteBLEConnectionValue(gameData));
|
|
|
|
|
+ this.handlers.set("writeHexToBLEDevice", (gameData) => this.handleWriteHexToBLEDevice(gameData));
|
|
|
|
|
+ this.handlers.set("log", (gameData) => console.log(gameData));
|
|
|
|
|
+ this.handlers.set("addDeviceUpdateListener", () => this.handleAddDeviceUpdateListener());
|
|
|
|
|
+ this.handlers.set("closeDeviceUpdateListener", () => this.handleCloseDeviceUpdateListener());
|
|
|
|
|
+ this.handlers.set("addDeviceJsonUpdateListener", () => this.handleAddDeviceJsonUpdateListener());
|
|
|
|
|
+ this.handlers.set("closeDeviceJsonUpdateListener", () => this.handleCloseDeviceJsonUpdateListener());
|
|
|
|
|
+ //用手机的加速计和陀螺仪触发onBoxingPostHit?
|
|
|
|
|
+ this.handlers.set("onStartAccAndGyro", () => this.handleStartAccAndGyro());
|
|
|
|
|
+ this.handlers.set("onStopAccAndGyro", () => this.handleStopAccAndGyro());
|
|
|
|
|
+ //检测脸部函数
|
|
|
|
|
+ this.handlers.set("faceStartDetect", (gameData) => this.handleFaceStartDetect(gameData));
|
|
|
|
|
+ this.handlers.set("faceStopDetect", () => this.handleFaceStopDetect());
|
|
|
|
|
+ this.handlers.set("faceSetPreview", (gameData) => this.handleFaceSetPreview(gameData));
|
|
|
|
|
+ },
|
|
|
|
|
+ handleUploadInfo(gameData) {
|
|
|
|
|
+ //TODO:写入排行榜分数,后面需要在游戏完结里面调用
|
|
|
|
|
+ //TODO: 后面游戏时间,卡路里的需要写入数据库,目前只是处理了分数
|
|
|
|
|
+ // let num = Math.round(Math.random() * 10000);
|
|
|
|
|
+ //1. gameScore 处理上传的分数
|
|
|
|
|
+ // let _temp = {
|
|
|
|
|
+ // gameId: '1595755153789139696',
|
|
|
|
|
+ // score: 1230,
|
|
|
|
|
+ // cityCode: '110101',
|
|
|
|
|
+ // };
|
|
|
|
|
+ //2. calorieBurned 处理卡路里
|
|
|
|
|
+ // 记录卡路里到本地
|
|
|
|
|
+ this.addlocalCalorie(gameData.calorieBurned);
|
|
|
|
|
+ console.log("gameData.calorieBurned", gameData.calorieBurned);
|
|
|
|
|
+ //然后更新上服务器
|
|
|
|
|
+ this.syncRequestEvent({
|
|
|
|
|
+ success: () => {
|
|
|
|
|
+ // uni.$emit('updateArcbarData', '');
|
|
|
|
|
+
|
|
|
|
|
+ let _temp = {
|
|
|
|
|
+ //假如排行id 为空,排行榜就是游戏自己的id
|
|
|
|
|
+ gameId: this.decodeItem.gameRankingId == null ? this.decodeItem
|
|
|
|
|
+ .gameId : this.decodeItem.gameRankingId,
|
|
|
|
|
+ score: gameData.gameScore,
|
|
|
|
|
+ cityCode: this.city.cityCode,
|
|
|
|
|
+ bMaxLimit: true
|
|
|
}
|
|
}
|
|
|
- });
|
|
|
|
|
-
|
|
|
|
|
- //3. gameTime 游戏时间
|
|
|
|
|
- //TODO 后面处理游戏时长
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
- } else if (temp.funName == "gameInit") {
|
|
|
|
|
- // 获取游戏信息
|
|
|
|
|
- this.sendGameInit();
|
|
|
|
|
- } else if (temp.funName == "aiRandomInfo") {
|
|
|
|
|
- // 获取aiRandomInfo
|
|
|
|
|
- reqUtil.requestData(config.URL.AIRANDOMINFO, {}).then(res => {
|
|
|
|
|
- console.log('AIRANDOMINFO =====', res);
|
|
|
|
|
- if (res.code == 0) {
|
|
|
|
|
- let data = res.data;
|
|
|
|
|
- this.urlToBase64(data.aiAvatar, (toBase64Url) => {
|
|
|
|
|
- let sendData = {
|
|
|
|
|
- aiId: data.aiId,
|
|
|
|
|
- aiName: data.aiName,
|
|
|
|
|
- aiGender: data.aiGender,
|
|
|
|
|
- aiType: data.aiType,
|
|
|
|
|
- aiAvatarBase64Url: toBase64Url
|
|
|
|
|
- }
|
|
|
|
|
- this.sendMessage("onAiRandomInfo", sendData);
|
|
|
|
|
- })
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ console.log('_temp =====', _temp);
|
|
|
|
|
+
|
|
|
|
|
+ reqUtil.requestData(config.URL.UPLOADRANKING, _temp, "POST").then(res => {
|
|
|
|
|
+ console.log('UPLOADRANKING =====', res);
|
|
|
|
|
+ if (res.code == 0) {
|
|
|
|
|
+ //TODO 后续游戏数据处理
|
|
|
|
|
+ this.sendMessage("onUploadInfo", {
|
|
|
|
|
+ code: 0,
|
|
|
|
|
+ msg: '上传成功'
|
|
|
|
|
+ });
|
|
|
|
|
+ } else {
|
|
|
|
|
+ //TODO 后续游戏数据处理
|
|
|
|
|
+ this.sendMessage("onUploadInfo", {
|
|
|
|
|
+ code: 400,
|
|
|
|
|
+ msg: '上传失败'
|
|
|
|
|
+ });
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
- },
|
|
|
|
|
- e => {
|
|
|
|
|
- console.log(e)
|
|
|
|
|
|
|
+ },
|
|
|
|
|
+ e => {
|
|
|
|
|
+ console.log(e)
|
|
|
|
|
+ });
|
|
|
|
|
+ },
|
|
|
|
|
+ fail: () => {
|
|
|
|
|
+ this.sendMessage("onUploadInfo", {
|
|
|
|
|
+ code: 400,
|
|
|
|
|
+ msg: '上传失败'
|
|
|
});
|
|
});
|
|
|
- } else if (temp.funName == "fruitInfo") {
|
|
|
|
|
- let fruitIndexArray = [0, 0, 0];
|
|
|
|
|
- if (gameData.hasOwnProperty("calorie")) {
|
|
|
|
|
- fruitIndexArray = fruit.getFruitIndex(gameData.calorie);
|
|
|
|
|
}
|
|
}
|
|
|
|
|
+ });
|
|
|
|
|
|
|
|
- this.urlToBase64("https://bbeng-bucket.oss-cn-beijing.aliyuncs.com/cocos/fruitMachine.png", (
|
|
|
|
|
- toBase64Url) => {
|
|
|
|
|
- this.sendMessage("onFruitInfo", {
|
|
|
|
|
- // 水果雪碧图
|
|
|
|
|
- fruitBase64Url: toBase64Url,
|
|
|
|
|
- // 雪碧图 单张图片宽高
|
|
|
|
|
- unitWidth: 100,
|
|
|
|
|
- unitHeight: 100,
|
|
|
|
|
- unit: "px",
|
|
|
|
|
- imageStartPosY: 0,
|
|
|
|
|
- imageEndPosY: -1200,
|
|
|
|
|
- fruitIndexArray: fruitIndexArray
|
|
|
|
|
- });
|
|
|
|
|
- })
|
|
|
|
|
|
|
+ //3. gameTime 游戏时间
|
|
|
|
|
+ //TODO 后面处理游戏时长
|
|
|
|
|
+ },
|
|
|
|
|
+ handleAiRandomInfo(gameData) {
|
|
|
|
|
+ // 获取aiRandomInfo
|
|
|
|
|
+ reqUtil.requestData(config.URL.AIRANDOMINFO, {}).then(res => {
|
|
|
|
|
+ console.log('AIRANDOMINFO =====', res);
|
|
|
|
|
+ if (res.code == 0) {
|
|
|
|
|
+ let data = res.data;
|
|
|
|
|
+ this.urlToBase64(data.aiAvatar, (toBase64Url) => {
|
|
|
|
|
+ let sendData = {
|
|
|
|
|
+ aiId: data.aiId,
|
|
|
|
|
+ aiName: data.aiName,
|
|
|
|
|
+ aiGender: data.aiGender,
|
|
|
|
|
+ aiType: data.aiType,
|
|
|
|
|
+ aiAvatarBase64Url: toBase64Url
|
|
|
|
|
+ }
|
|
|
|
|
+ this.sendMessage("onAiRandomInfo", sendData);
|
|
|
|
|
+ })
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
|
|
+ },
|
|
|
|
|
+ e => {
|
|
|
|
|
+ console.log(e)
|
|
|
|
|
+ });
|
|
|
|
|
+ },
|
|
|
|
|
+ handleFruitInfo(gameData) {
|
|
|
|
|
+ let fruitIndexArray = [0, 0, 0];
|
|
|
|
|
+ if (gameData.hasOwnProperty("calorie")) {
|
|
|
|
|
+ fruitIndexArray = fruit.getFruitIndex(gameData.calorie);
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
|
|
+ this.urlToBase64("https://bbeng-bucket.oss-cn-beijing.aliyuncs.com/cocos/fruitMachine.png", (
|
|
|
|
|
+ toBase64Url) => {
|
|
|
|
|
+ this.sendMessage("onFruitInfo", {
|
|
|
|
|
+ // 水果雪碧图
|
|
|
|
|
+ fruitBase64Url: toBase64Url,
|
|
|
|
|
+ // 雪碧图 单张图片宽高
|
|
|
|
|
+ unitWidth: 100,
|
|
|
|
|
+ unitHeight: 100,
|
|
|
|
|
+ unit: "px",
|
|
|
|
|
+ imageStartPosY: 0,
|
|
|
|
|
+ imageEndPosY: -1200,
|
|
|
|
|
+ fruitIndexArray: fruitIndexArray
|
|
|
|
|
+ });
|
|
|
|
|
+ })
|
|
|
|
|
|
|
|
- } else if (temp.funName == "urlToBase64") {
|
|
|
|
|
- if (gameData.url) {
|
|
|
|
|
- this.urlToBase64(gameData.url, (toBase64Url) => {
|
|
|
|
|
- this.sendMessage("onUrlToBase64", {
|
|
|
|
|
- base64: toBase64Url,
|
|
|
|
|
- });
|
|
|
|
|
- })
|
|
|
|
|
- } else {
|
|
|
|
|
|
|
+ },
|
|
|
|
|
+ handleUrlToBase64(gameData) {
|
|
|
|
|
+ if (gameData.url) {
|
|
|
|
|
+ this.urlToBase64(gameData.url, (toBase64Url) => {
|
|
|
this.sendMessage("onUrlToBase64", {
|
|
this.sendMessage("onUrlToBase64", {
|
|
|
- base64: {},
|
|
|
|
|
|
|
+ base64: toBase64Url,
|
|
|
});
|
|
});
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- } else if (temp.funName == "openAccelerometer") {
|
|
|
|
|
- if (this.globalAcc) {
|
|
|
|
|
- uni.$off('watchAcceleration', this.gWatchAcceleration);
|
|
|
|
|
- uni.$on('watchAcceleration', this.gWatchAcceleration);
|
|
|
|
|
- } else {
|
|
|
|
|
- uni.$emit("bindAcc", {
|
|
|
|
|
- callback: (accId) => {
|
|
|
|
|
- console.log("开启的:globalAcc=", accId);
|
|
|
|
|
- this.bGameOpenListen = true;
|
|
|
|
|
- this.$store.state.globalAcc = accId;
|
|
|
|
|
- uni.$off('watchAcceleration', this.gWatchAcceleration);
|
|
|
|
|
- uni.$on('watchAcceleration', this.gWatchAcceleration);
|
|
|
|
|
- }
|
|
|
|
|
- });
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ })
|
|
|
|
|
+ } else {
|
|
|
|
|
+ this.sendMessage("onUrlToBase64", {
|
|
|
|
|
+ base64: {},
|
|
|
|
|
+ });
|
|
|
|
|
+ }
|
|
|
|
|
+ },
|
|
|
|
|
+ handleOpenAccelerometer() {
|
|
|
|
|
+ if (this.globalAcc) {
|
|
|
|
|
+ uni.$off('watchAcceleration', this.gWatchAcceleration);
|
|
|
|
|
+ uni.$on('watchAcceleration', this.gWatchAcceleration);
|
|
|
|
|
+ } else {
|
|
|
|
|
+ uni.$emit("bindAcc", {
|
|
|
|
|
+ callback: (accId) => {
|
|
|
|
|
+ console.log("开启的:globalAcc=", accId);
|
|
|
|
|
+ this.bGameOpenListen = true;
|
|
|
|
|
+ this.$store.state.globalAcc = accId;
|
|
|
|
|
+ uni.$off('watchAcceleration', this.gWatchAcceleration);
|
|
|
|
|
+ uni.$on('watchAcceleration', this.gWatchAcceleration);
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+ }
|
|
|
|
|
+ },
|
|
|
|
|
+ handleCloseAccelerometer() {
|
|
|
|
|
+ uni.$off('watchAcceleration', this.gWatchAcceleration);
|
|
|
|
|
+ uni.$emit("unBindAcc", this.globalAcc);
|
|
|
|
|
+ this.$store.state.globalAcc = null;
|
|
|
|
|
+ },
|
|
|
|
|
+ handleOpenOrientation() {
|
|
|
|
|
+ //打开陀螺仪
|
|
|
|
|
+ if (this.globalOri) {
|
|
|
|
|
+ uni.$off('watchOrientation', this.gWatchOrientation);
|
|
|
|
|
+ uni.$on('watchOrientation', this.gWatchOrientation);
|
|
|
|
|
+ s } else {
|
|
|
|
|
+ uni.$emit("bindOri", {
|
|
|
|
|
+ callback: (oriId) => {
|
|
|
|
|
+ console.log("开启的:globalOri=", oriId);
|
|
|
|
|
+ this.bGameOpenListen = true;
|
|
|
|
|
+ this.$store.state.globalOri = oriId;
|
|
|
|
|
+ uni.$off('watchOrientation', this.gWatchOrientation);
|
|
|
|
|
+ uni.$on('watchOrientation', this.gWatchOrientation);
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+ }
|
|
|
|
|
+ },
|
|
|
|
|
+ handleCloseOrientation() {
|
|
|
|
|
+ uni.$off('watchOrientation', this.gWatchOrientation);
|
|
|
|
|
+ uni.$emit("unBindOri", this.globalOri);
|
|
|
|
|
+ this.$store.state.globalOri = null;
|
|
|
|
|
+ },
|
|
|
|
|
+ handleBindBoxingPost() {
|
|
|
|
|
+ if (this.globalAcc) {
|
|
|
|
|
+ uni.$off('watchAcceleration', this.gWatchBoxingAcc);
|
|
|
|
|
+ uni.$on('watchAcceleration', this.gWatchBoxingAcc);
|
|
|
|
|
+ } else {
|
|
|
|
|
+ uni.$emit("bindAcc", {
|
|
|
|
|
+ callback: (accId) => {
|
|
|
|
|
+ console.log("bindBoxingPost开启的:globalAcc=", accId);
|
|
|
|
|
+ this.bGameOpenListen = true;
|
|
|
|
|
+ this.$store.state.globalAcc = accId;
|
|
|
|
|
+ uni.$off('watchAcceleration', this.gWatchBoxingAcc);
|
|
|
|
|
+ uni.$on('watchAcceleration', this.gWatchBoxingAcc);
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+ }
|
|
|
|
|
+ },
|
|
|
|
|
+ handleUnbindBoxingPost() {
|
|
|
|
|
+ uni.$off('watchAcceleration', this.gWatchBoxingAcc);
|
|
|
|
|
+ uni.$emit("unBindAcc", this.globalAcc);
|
|
|
|
|
+ this.$store.state.globalAcc = null;
|
|
|
|
|
+ },
|
|
|
|
|
+ handleSetAngleRatio(gameData) {
|
|
|
|
|
+ if (gameData) {
|
|
|
|
|
+ this.angleRatio = Number(gameData.angleRatio);
|
|
|
|
|
+ console.log("this.angleRatio:", this.angleRatio);
|
|
|
|
|
+ this.sendMessage("onSetAngleRatio", {
|
|
|
|
|
+ angleRatio: this.angleRatio
|
|
|
|
|
+ });
|
|
|
|
|
+ }
|
|
|
|
|
+ },
|
|
|
|
|
+ handleBindHitBoxingPost() {
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 返回拳击柱的绑定状态
|
|
|
|
|
+ */
|
|
|
|
|
+ console.log("bindHitBoxingPost");
|
|
|
|
|
+ if (this.ConnectBindingDevice) {
|
|
|
|
|
+ uni.$off('updateBLEDeviceData', this.gWatchBLEUpdate);
|
|
|
|
|
+ uni.$on('updateBLEDeviceData', this.gWatchBLEUpdate);
|
|
|
|
|
+ //hotman 沙袋情景
|
|
|
|
|
+ this.gCreateSandbagAlgorithm();
|
|
|
|
|
+ this.gStartSimulateBLEUpdate();
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
|
|
+ if (!this.BLEConnectDevice) return;
|
|
|
|
|
+ //用设备来区分,开启什么加速计;
|
|
|
|
|
+ if (this.BLEConnectDevice.deviceType == "BLEHandle" || this.BLEConnectDevice.deviceType ==
|
|
|
|
|
+ "BLEIntelligent") {
|
|
|
|
|
+ //处理蓝牙设备情况下
|
|
|
|
|
+ //开启设备回调 3/4关闭
|
|
|
|
|
+ this.onWriteBLEConnectionValue({
|
|
|
|
|
+ value: "3"
|
|
|
|
|
+ });
|
|
|
|
|
+ // setTimeout(() => {
|
|
|
|
|
+ // //设置加速计b:20ms a:10ms
|
|
|
|
|
+ // this.onWriteBLEConnectionValue({
|
|
|
|
|
+ // value: config.refreshRate
|
|
|
|
|
+ // });
|
|
|
|
|
|
|
|
- } else if (temp.funName == "closeAccelerometer") {
|
|
|
|
|
- uni.$off('watchAcceleration', this.gWatchAcceleration);
|
|
|
|
|
- uni.$emit("unBindAcc", this.globalAcc);
|
|
|
|
|
- this.$store.state.globalAcc = null;
|
|
|
|
|
|
|
+ // }, 2000)
|
|
|
|
|
+ uni.$off('updateBLEDeviceData', this.gWatchBLEUpdate);
|
|
|
|
|
+ uni.$on('updateBLEDeviceData', this.gWatchBLEUpdate);
|
|
|
|
|
|
|
|
- } else if (temp.funName == "openOrientation") {
|
|
|
|
|
- //打开陀螺仪
|
|
|
|
|
- if (this.globalOri) {
|
|
|
|
|
- uni.$off('watchOrientation', this.gWatchOrientation);
|
|
|
|
|
- uni.$on('watchOrientation', this.gWatchOrientation);
|
|
|
|
|
- } else {
|
|
|
|
|
- uni.$emit("bindOri", {
|
|
|
|
|
- callback: (oriId) => {
|
|
|
|
|
- console.log("开启的:globalOri=", oriId);
|
|
|
|
|
- this.bGameOpenListen = true;
|
|
|
|
|
- this.$store.state.globalOri = oriId;
|
|
|
|
|
- uni.$off('watchOrientation', this.gWatchOrientation);
|
|
|
|
|
- uni.$on('watchOrientation', this.gWatchOrientation);
|
|
|
|
|
- }
|
|
|
|
|
- });
|
|
|
|
|
|
|
+ if (this.BLEConnectDevice.usageMode == "phone" || this.BLEConnectDevice.usageMode ==
|
|
|
|
|
+ "general") {
|
|
|
|
|
+ //手机情景或者自由模式
|
|
|
|
|
+ this._createEquipmentBasedOnBoxingPostHit();
|
|
|
|
|
+ } else if (this.BLEConnectDevice.usageMode == "hotman") {
|
|
|
|
|
+ //hotman 沙袋情景
|
|
|
|
|
+ // this.gCreateSandbagAlgorithm();
|
|
|
|
|
+ if (this.BLEConnectDevice.deviceType == "BLEIntelligent") {
|
|
|
|
|
+ this.gIntelligentCreateSandbagAlgorithm();
|
|
|
|
|
+ } else {
|
|
|
|
|
+ this.gCreateSandbagAlgorithm();
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
- } else if (temp.funName == "closeOrientation") {
|
|
|
|
|
- uni.$off('watchOrientation', this.gWatchOrientation);
|
|
|
|
|
- uni.$emit("unBindOri", this.globalOri);
|
|
|
|
|
- this.$store.state.globalOri = null;
|
|
|
|
|
-
|
|
|
|
|
- } else if (temp.funName == "bindBoxingPost") {
|
|
|
|
|
|
|
+ } else if (this.BLEConnectDevice.deviceType == "mySelf") {
|
|
|
|
|
+ //处理手机本身情况下
|
|
|
if (this.globalAcc) {
|
|
if (this.globalAcc) {
|
|
|
- uni.$off('watchAcceleration', this.gWatchBoxingAcc);
|
|
|
|
|
- uni.$on('watchAcceleration', this.gWatchBoxingAcc);
|
|
|
|
|
|
|
+ uni.$off('watchAcceleration', this.gWatchHitBoxingAcc);
|
|
|
|
|
+ uni.$on('watchAcceleration', this.gWatchHitBoxingAcc);
|
|
|
} else {
|
|
} else {
|
|
|
|
|
+ //开启手机加速计
|
|
|
uni.$emit("bindAcc", {
|
|
uni.$emit("bindAcc", {
|
|
|
callback: (accId) => {
|
|
callback: (accId) => {
|
|
|
- console.log("bindBoxingPost开启的:globalAcc=", accId);
|
|
|
|
|
|
|
+ console.log("bindHitBoxingPost开启的:globalAcc=", accId);
|
|
|
this.bGameOpenListen = true;
|
|
this.bGameOpenListen = true;
|
|
|
this.$store.state.globalAcc = accId;
|
|
this.$store.state.globalAcc = accId;
|
|
|
- uni.$off('watchAcceleration', this.gWatchBoxingAcc);
|
|
|
|
|
- uni.$on('watchAcceleration', this.gWatchBoxingAcc);
|
|
|
|
|
|
|
+ uni.$off('watchAcceleration', this.gWatchHitBoxingAcc);
|
|
|
|
|
+ uni.$on('watchAcceleration', this.gWatchHitBoxingAcc);
|
|
|
|
|
+ if (this.BLEConnectDevice.usageMode == "phone" || this.BLEConnectDevice
|
|
|
|
|
+ .usageMode == "general") {
|
|
|
|
|
+ //手机情景或者自由模式
|
|
|
|
|
+ this._createEquipmentBasedOnBoxingPostHit();
|
|
|
|
|
+ } else if (this.BLEConnectDevice.usageMode == "hotman") {
|
|
|
|
|
+ //hotman 沙袋情景 todo
|
|
|
|
|
+ console.warn("没有处理手机加速计的 gCreateFilterObj");
|
|
|
|
|
+ // this.gCreateFilterObj();
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
});
|
|
});
|
|
|
}
|
|
}
|
|
|
- } else if (temp.funName == "unbindBoxingPost") {
|
|
|
|
|
- uni.$off('watchAcceleration', this.gWatchBoxingAcc);
|
|
|
|
|
|
|
+ } else if (this.BLEConnectDevice.deviceType == "BLERope") {
|
|
|
|
|
+ //todo 开启跳绳模式
|
|
|
|
|
+ this.B_OpenRopeSkipping();
|
|
|
|
|
+ // this._createActionJumpOnBoxingPostHit();
|
|
|
|
|
+ //监听蓝牙回调
|
|
|
|
|
+ uni.$off('updateBLEDeviceData', this.gWatchBLEUpdate);
|
|
|
|
|
+ uni.$on('updateBLEDeviceData', this.gWatchBLEUpdate);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ },
|
|
|
|
|
+ handleUnbindHitBoxingPost() {
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 解绑拳击柱的绑定状态
|
|
|
|
|
+ */
|
|
|
|
|
+ if (this.ConnectBindingDevice) {
|
|
|
|
|
+ uni.$off('updateBLEDeviceData', this.gWatchBLEUpdate);
|
|
|
|
|
+ this.gStopSimulateBLEUpdate();
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if (this.BLEConnectDevice && (this.BLEConnectDevice.deviceType == "BLEHandle" || this
|
|
|
|
|
+ .BLEConnectDevice.deviceType == "BLEIntelligent")) {
|
|
|
|
|
+ //开启设备回调 3/4关闭
|
|
|
|
|
+ this.onWriteBLEConnectionValue({
|
|
|
|
|
+ value: "4"
|
|
|
|
|
+ });
|
|
|
|
|
+ uni.$off('updateBLEDeviceData', this.gWatchBLEUpdate);
|
|
|
|
|
+ } else if (this.BLEConnectDevice && this.BLEConnectDevice.deviceType == "BLERope") {
|
|
|
|
|
+ console.warn("unbindHitBoxingPost 还没设置关闭跳绳模式")
|
|
|
|
|
+ this.onClearData();
|
|
|
|
|
+ this.B_CloseRopeSkipping();
|
|
|
|
|
+ uni.$off('updateBLEDeviceData', this.gWatchBLEUpdate);
|
|
|
|
|
+ } else {
|
|
|
|
|
+ uni.$off('watchAcceleration', this.gWatchHitBoxingAcc);
|
|
|
uni.$emit("unBindAcc", this.globalAcc);
|
|
uni.$emit("unBindAcc", this.globalAcc);
|
|
|
this.$store.state.globalAcc = null;
|
|
this.$store.state.globalAcc = null;
|
|
|
|
|
+ }
|
|
|
|
|
+ },
|
|
|
|
|
+ handleCloseGame() {
|
|
|
|
|
+ uni.getCurrentSubNVue().hide('auto');
|
|
|
|
|
+ },
|
|
|
|
|
+ handleAddQuitModal() {
|
|
|
|
|
+ this.gameQuitListener = true;
|
|
|
|
|
+ this.sendMessage("onQuitModalListener", {
|
|
|
|
|
+ bListener: this.gameQuitListener
|
|
|
|
|
+ });
|
|
|
|
|
+ },
|
|
|
|
|
+ handleRemoveQuitModal() {
|
|
|
|
|
+ this.gameQuitListener = false;
|
|
|
|
|
+ this.sendMessage("onQuitModalListener", {
|
|
|
|
|
+ bListener: this.gameQuitListener
|
|
|
|
|
+ });
|
|
|
|
|
+ },
|
|
|
|
|
+ handleWriteBLEConnectionValue(gameData) {
|
|
|
|
|
+ if (!gameData.value || gameData.value == "") return;
|
|
|
|
|
|
|
|
- } else if (temp.funName == "setAngleRatio") {
|
|
|
|
|
- if (gameData) {
|
|
|
|
|
- this.angleRatio = Number(gameData.angleRatio);
|
|
|
|
|
- console.log("this.angleRatio:", this.angleRatio);
|
|
|
|
|
- this.sendMessage("onSetAngleRatio", {
|
|
|
|
|
- angleRatio: this.angleRatio
|
|
|
|
|
- });
|
|
|
|
|
- }
|
|
|
|
|
- } else if (temp.funName == "bindHitBoxingPost") {
|
|
|
|
|
- /**
|
|
|
|
|
- * 返回拳击柱的绑定状态
|
|
|
|
|
- */
|
|
|
|
|
- console.log("bindHitBoxingPost");
|
|
|
|
|
- if (this.ConnectBindingDevice) {
|
|
|
|
|
- uni.$off('updateBLEDeviceData', this.gWatchBLEUpdate);
|
|
|
|
|
- uni.$on('updateBLEDeviceData', this.gWatchBLEUpdate);
|
|
|
|
|
- //hotman 沙袋情景
|
|
|
|
|
- this.gCreateSandbagAlgorithm();
|
|
|
|
|
- this.gStartSimulateBLEUpdate();
|
|
|
|
|
- return;
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ if (!this.BLEConnectDevice) return;
|
|
|
|
|
+ //蓝牙写入数据
|
|
|
|
|
+ this.onWriteBLEConnectionValue(gameData);
|
|
|
|
|
+ },
|
|
|
|
|
+ handleWriteHexToBLEDevice(gameData) {
|
|
|
|
|
+ if (!gameData.value || gameData.value == "") return;
|
|
|
|
|
|
|
|
- if (!this.BLEConnectDevice) return;
|
|
|
|
|
- //用设备来区分,开启什么加速计;
|
|
|
|
|
- if (this.BLEConnectDevice.deviceType == "BLEHandle" || this.BLEConnectDevice.deviceType ==
|
|
|
|
|
- "BLEIntelligent") {
|
|
|
|
|
- //处理蓝牙设备情况下
|
|
|
|
|
- //开启设备回调 3/4关闭
|
|
|
|
|
- this.onWriteBLEConnectionValue({
|
|
|
|
|
- value: "3"
|
|
|
|
|
- });
|
|
|
|
|
- // setTimeout(() => {
|
|
|
|
|
- // //设置加速计b:20ms a:10ms
|
|
|
|
|
- // this.onWriteBLEConnectionValue({
|
|
|
|
|
- // value: config.refreshRate
|
|
|
|
|
- // });
|
|
|
|
|
-
|
|
|
|
|
- // }, 2000)
|
|
|
|
|
- uni.$off('updateBLEDeviceData', this.gWatchBLEUpdate);
|
|
|
|
|
- uni.$on('updateBLEDeviceData', this.gWatchBLEUpdate);
|
|
|
|
|
-
|
|
|
|
|
- if (this.BLEConnectDevice.usageMode == "phone" || this.BLEConnectDevice.usageMode ==
|
|
|
|
|
- "general") {
|
|
|
|
|
- //手机情景或者自由模式
|
|
|
|
|
- this._createEquipmentBasedOnBoxingPostHit();
|
|
|
|
|
- } else if (this.BLEConnectDevice.usageMode == "hotman") {
|
|
|
|
|
- //hotman 沙袋情景
|
|
|
|
|
- // this.gCreateSandbagAlgorithm();
|
|
|
|
|
- if (this.BLEConnectDevice.deviceType == "BLEIntelligent") {
|
|
|
|
|
- this.gIntelligentCreateSandbagAlgorithm();
|
|
|
|
|
- } else {
|
|
|
|
|
- this.gCreateSandbagAlgorithm();
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- } else if (this.BLEConnectDevice.deviceType == "mySelf") {
|
|
|
|
|
- //处理手机本身情况下
|
|
|
|
|
- if (this.globalAcc) {
|
|
|
|
|
- uni.$off('watchAcceleration', this.gWatchHitBoxingAcc);
|
|
|
|
|
- uni.$on('watchAcceleration', this.gWatchHitBoxingAcc);
|
|
|
|
|
- } else {
|
|
|
|
|
- //开启手机加速计
|
|
|
|
|
- uni.$emit("bindAcc", {
|
|
|
|
|
- callback: (accId) => {
|
|
|
|
|
- console.log("bindHitBoxingPost开启的:globalAcc=", accId);
|
|
|
|
|
- this.bGameOpenListen = true;
|
|
|
|
|
- this.$store.state.globalAcc = accId;
|
|
|
|
|
- uni.$off('watchAcceleration', this.gWatchHitBoxingAcc);
|
|
|
|
|
- uni.$on('watchAcceleration', this.gWatchHitBoxingAcc);
|
|
|
|
|
- if (this.BLEConnectDevice.usageMode == "phone" || this.BLEConnectDevice
|
|
|
|
|
- .usageMode == "general") {
|
|
|
|
|
- //手机情景或者自由模式
|
|
|
|
|
- this._createEquipmentBasedOnBoxingPostHit();
|
|
|
|
|
- } else if (this.BLEConnectDevice.usageMode == "hotman") {
|
|
|
|
|
- //hotman 沙袋情景 todo
|
|
|
|
|
- console.warn("没有处理手机加速计的 gCreateFilterObj");
|
|
|
|
|
- // this.gCreateFilterObj();
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- });
|
|
|
|
|
- }
|
|
|
|
|
- } else if (this.BLEConnectDevice.deviceType == "BLERope") {
|
|
|
|
|
- //todo 开启跳绳模式
|
|
|
|
|
- this.B_OpenRopeSkipping();
|
|
|
|
|
- // this._createActionJumpOnBoxingPostHit();
|
|
|
|
|
- //监听蓝牙回调
|
|
|
|
|
- uni.$off('updateBLEDeviceData', this.gWatchBLEUpdate);
|
|
|
|
|
- uni.$on('updateBLEDeviceData', this.gWatchBLEUpdate);
|
|
|
|
|
|
|
+ if (!this.BLEConnectDevice) return;
|
|
|
|
|
+ //蓝牙写入数据
|
|
|
|
|
+ this.B_WriteHexToBLECharacteristic(gameData);
|
|
|
|
|
+ },
|
|
|
|
|
+ handleAddDeviceUpdateListener() {
|
|
|
|
|
+ uni.$off('updateBLEDeviceData', this.BLECallback);
|
|
|
|
|
+ uni.$on('updateBLEDeviceData', this.BLECallback);
|
|
|
|
|
+ },
|
|
|
|
|
+ handleCloseDeviceUpdateListener() {
|
|
|
|
|
+ uni.$off('updateBLEDeviceData', this.BLECallback);
|
|
|
|
|
+ },
|
|
|
|
|
+ handleAddDeviceJsonUpdateListener() {
|
|
|
|
|
+ uni.$off('updateBLEDeviceJson', this.BLEJsonCallback);
|
|
|
|
|
+ uni.$on('updateBLEDeviceJson', this.BLEJsonCallback);
|
|
|
|
|
+ },
|
|
|
|
|
+ handleCloseDeviceJsonUpdateListener() {
|
|
|
|
|
+ uni.$off('updateBLEDeviceJson', this.BLEJsonCallback);
|
|
|
|
|
+ },
|
|
|
|
|
+ //获取手机原始陀螺仪和加速计数据
|
|
|
|
|
+ handleStartAccAndGyro() {
|
|
|
|
|
+ this.bMyAttitudeListen = true;
|
|
|
|
|
+ this.gStartSimulateBLEUpdate();
|
|
|
|
|
+ //监听蓝牙回调
|
|
|
|
|
+ uni.$off('updateBLEDeviceData', this.gWatchBLEUpdate);
|
|
|
|
|
+ uni.$on('updateBLEDeviceData', this.gWatchBLEUpdate);
|
|
|
|
|
+ },
|
|
|
|
|
+ handleStopAccAndGyro() {
|
|
|
|
|
+ this.bMyAttitudeListen = false;
|
|
|
|
|
+ this.gStopSimulateBLEUpdate();
|
|
|
|
|
+ //监听蓝牙回调
|
|
|
|
|
+ uni.$off('updateBLEDeviceData', this.gWatchBLEUpdate);
|
|
|
|
|
+ },
|
|
|
|
|
+ handleFaceStartDetect(gameData) {
|
|
|
|
|
+ this.faceModule_startDetect({
|
|
|
|
|
+ options: gameData,
|
|
|
|
|
+ callback: (data) => {
|
|
|
|
|
+ //回调识别数据
|
|
|
|
|
+ this.sendMessage("onFaceDetectUpdate", data);
|
|
|
}
|
|
}
|
|
|
|
|
+ });
|
|
|
|
|
+ },
|
|
|
|
|
+ handleFaceStopDetect() {
|
|
|
|
|
+ this.faceModule_stopDetect();
|
|
|
|
|
+ },
|
|
|
|
|
+ handleFaceSetPreview(gameData) {
|
|
|
|
|
+ // 提取配置,提供默认值
|
|
|
|
|
+ const {
|
|
|
|
|
+ preview = true,
|
|
|
|
|
+ overlay = true,
|
|
|
|
|
+ closeButton = true
|
|
|
|
|
+ } = gameData;
|
|
|
|
|
+ this.faceModule_setPreview({
|
|
|
|
|
+ preview,
|
|
|
|
|
+ overlay,
|
|
|
|
|
+ closeButton
|
|
|
|
|
+ })
|
|
|
|
|
+ },
|
|
|
|
|
|
|
|
|
|
+ handlePostMessage: function(postData) {
|
|
|
|
|
+ console.log("handlePostMessage得到参数", postData.detail);
|
|
|
|
|
+ let temp = postData.detail.data[0];
|
|
|
|
|
+ let gameData = temp.gameData;
|
|
|
|
|
|
|
|
- } else if (temp.funName == "unbindHitBoxingPost") {
|
|
|
|
|
- /**
|
|
|
|
|
- * 解绑拳击柱的绑定状态
|
|
|
|
|
- */
|
|
|
|
|
- if (this.ConnectBindingDevice) {
|
|
|
|
|
- uni.$off('updateBLEDeviceData', this.gWatchBLEUpdate);
|
|
|
|
|
- this.gStopSimulateBLEUpdate();
|
|
|
|
|
- return;
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- if (this.BLEConnectDevice && (this.BLEConnectDevice.deviceType == "BLEHandle" || this
|
|
|
|
|
- .BLEConnectDevice.deviceType == "BLEIntelligent")) {
|
|
|
|
|
- //开启设备回调 3/4关闭
|
|
|
|
|
- this.onWriteBLEConnectionValue({
|
|
|
|
|
- value: "4"
|
|
|
|
|
- });
|
|
|
|
|
- uni.$off('updateBLEDeviceData', this.gWatchBLEUpdate);
|
|
|
|
|
- } else if (this.BLEConnectDevice && this.BLEConnectDevice.deviceType == "BLERope") {
|
|
|
|
|
- console.warn("unbindHitBoxingPost 还没设置关闭跳绳模式")
|
|
|
|
|
- this.onClearData();
|
|
|
|
|
- this.B_CloseRopeSkipping();
|
|
|
|
|
- uni.$off('updateBLEDeviceData', this.gWatchBLEUpdate);
|
|
|
|
|
- } else {
|
|
|
|
|
- uni.$off('watchAcceleration', this.gWatchHitBoxingAcc);
|
|
|
|
|
- uni.$emit("unBindAcc", this.globalAcc);
|
|
|
|
|
- this.$store.state.globalAcc = null;
|
|
|
|
|
- }
|
|
|
|
|
- } else if (temp.funName == "closeGame") {
|
|
|
|
|
- uni.getCurrentSubNVue().hide('auto');
|
|
|
|
|
- } else if (temp.funName == "addQuitModal") {
|
|
|
|
|
- this.gameQuitListener = true;
|
|
|
|
|
- this.sendMessage("onQuitModalListener", {
|
|
|
|
|
- bListener: this.gameQuitListener
|
|
|
|
|
- });
|
|
|
|
|
- } else if (temp.funName == "removeQuitModal") {
|
|
|
|
|
- this.gameQuitListener = false;
|
|
|
|
|
- this.sendMessage("onQuitModalListener", {
|
|
|
|
|
- bListener: this.gameQuitListener
|
|
|
|
|
- });
|
|
|
|
|
- } else if (temp.funName == "writeBLEConnectionValue") {
|
|
|
|
|
- if (!gameData.value || gameData.value == "") return;
|
|
|
|
|
-
|
|
|
|
|
- if (!this.BLEConnectDevice) return;
|
|
|
|
|
- //蓝牙写入数据
|
|
|
|
|
- this.onWriteBLEConnectionValue(gameData);
|
|
|
|
|
- } else if(temp.funName == "writeHexToBLEDevice"){
|
|
|
|
|
- if (!gameData.value || gameData.value == "") return;
|
|
|
|
|
-
|
|
|
|
|
- if (!this.BLEConnectDevice) return;
|
|
|
|
|
- //蓝牙写入数据
|
|
|
|
|
- this.B_WriteHexToBLECharacteristic(gameData);
|
|
|
|
|
- } else if (temp.funName == "log") {
|
|
|
|
|
- console.log(gameData);
|
|
|
|
|
- } else if (temp.funName == "addDeviceUpdateListener") {
|
|
|
|
|
- uni.$off('updateBLEDeviceData', this.BLECallback);
|
|
|
|
|
- uni.$on('updateBLEDeviceData', this.BLECallback);
|
|
|
|
|
- } else if (temp.funName == "closeDeviceUpdateListener") {
|
|
|
|
|
- uni.$off('updateBLEDeviceData', this.BLECallback);
|
|
|
|
|
- } else if (temp.funName == "addDeviceJsonUpdateListener") {
|
|
|
|
|
- uni.$off('updateBLEDeviceJson', this.BLEJsonCallback);
|
|
|
|
|
- uni.$on('updateBLEDeviceJson', this.BLEJsonCallback);
|
|
|
|
|
- } else if (temp.funName == "closeDeviceJsonUpdateListener") {
|
|
|
|
|
- uni.$off('updateBLEDeviceJson', this.BLEJsonCallback);
|
|
|
|
|
- }
|
|
|
|
|
- //获取手机原始陀螺仪和加速计数据
|
|
|
|
|
- else if (temp.funName == "onStartAccAndGyro") {
|
|
|
|
|
- this.bMyAttitudeListen = true;
|
|
|
|
|
- this.gStartSimulateBLEUpdate();
|
|
|
|
|
- //监听蓝牙回调
|
|
|
|
|
- uni.$off('updateBLEDeviceData', this.gWatchBLEUpdate);
|
|
|
|
|
- uni.$on('updateBLEDeviceData', this.gWatchBLEUpdate);
|
|
|
|
|
- } else if (temp.funName == "onStopAccAndGyro") {
|
|
|
|
|
- this.bMyAttitudeListen = false;
|
|
|
|
|
- this.gStopSimulateBLEUpdate();
|
|
|
|
|
- //监听蓝牙回调
|
|
|
|
|
- uni.$off('updateBLEDeviceData', this.gWatchBLEUpdate);
|
|
|
|
|
|
|
+ let handler = this.handlers.get(temp.funName);
|
|
|
|
|
+ if (handler) {
|
|
|
|
|
+ handler(gameData);
|
|
|
|
|
+ } else {
|
|
|
|
|
+ console.warn("未知的 funName:", temp.funName);
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ // if (temp.funName == "uploadInfo") {}
|
|
|
|
|
+ // else if (temp.funName == "gameInit") {}
|
|
|
|
|
+ // else if (temp.funName == "aiRandomInfo") {}
|
|
|
|
|
+ // else if (temp.funName == "fruitInfo") {}
|
|
|
|
|
+ // else if (temp.funName == "urlToBase64") {}
|
|
|
|
|
+ // else if (temp.funName == "openAccelerometer") {}
|
|
|
|
|
+ // else if (temp.funName == "closeAccelerometer") {}
|
|
|
|
|
+ // else if (temp.funName == "openOrientation") {}
|
|
|
|
|
+ // else if (temp.funName == "closeOrientation") {}
|
|
|
|
|
+ // else if (temp.funName == "bindBoxingPost") {}
|
|
|
|
|
+ // else if (temp.funName == "unbindBoxingPost") {}
|
|
|
|
|
+ // else if (temp.funName == "setAngleRatio") {}
|
|
|
|
|
+ // else if (temp.funName == "bindHitBoxingPost") {}
|
|
|
|
|
+ // else if (temp.funName == "unbindHitBoxingPost") {}
|
|
|
|
|
+ // else if (temp.funName == "closeGame") {}
|
|
|
|
|
+ // else if (temp.funName == "addQuitModal") {}
|
|
|
|
|
+ // else if (temp.funName == "removeQuitModal") {}
|
|
|
|
|
+ // else if (temp.funName == "writeBLEConnectionValue") {}
|
|
|
|
|
+ // else if (temp.funName == "writeHexToBLEDevice") {}
|
|
|
|
|
+ // else if (temp.funName == "log") {}
|
|
|
|
|
+ // else if (temp.funName == "addDeviceUpdateListener") {}
|
|
|
|
|
+ // else if (temp.funName == "closeDeviceUpdateListener") {}
|
|
|
|
|
+ // else if (temp.funName == "addDeviceJsonUpdateListener") {}
|
|
|
|
|
+ // else if (temp.funName == "closeDeviceJsonUpdateListener") {}
|
|
|
|
|
+ // else if (temp.funName == "onStartAccAndGyro") {}
|
|
|
|
|
+ // else if (temp.funName == "onStopAccAndGyro") {}
|
|
|
},
|
|
},
|
|
|
onPageStart: function(e) {
|
|
onPageStart: function(e) {
|
|
|
// 监听页面加载成功
|
|
// 监听页面加载成功
|
|
@@ -898,8 +1016,8 @@
|
|
|
bLimitRebound: false
|
|
bLimitRebound: false
|
|
|
})
|
|
})
|
|
|
} else if (this.BLEConnectDevice.usageMode == "hotman") {
|
|
} else if (this.BLEConnectDevice.usageMode == "hotman") {
|
|
|
-
|
|
|
|
|
- if(this.BLEConnectDevice.deviceType == "BLEIntelligent"){
|
|
|
|
|
|
|
+
|
|
|
|
|
+ if (this.BLEConnectDevice.deviceType == "BLEIntelligent") {
|
|
|
//智能hotman 沙袋情景
|
|
//智能hotman 沙袋情景
|
|
|
this.gIntelligentUpdateSandbagAlgorithm({
|
|
this.gIntelligentUpdateSandbagAlgorithm({
|
|
|
data: data,
|
|
data: data,
|
|
@@ -927,7 +1045,7 @@
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
});
|
|
});
|
|
|
- }else{
|
|
|
|
|
|
|
+ } else {
|
|
|
//hotman 沙袋情景 todo
|
|
//hotman 沙袋情景 todo
|
|
|
this.gUpdateSandbagAlgorithm({
|
|
this.gUpdateSandbagAlgorithm({
|
|
|
data: data,
|
|
data: data,
|
|
@@ -956,7 +1074,7 @@
|
|
|
}
|
|
}
|
|
|
});
|
|
});
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
} else if (this.BLEConnectDevice.usageMode == "ropeSkipping") {
|
|
} else if (this.BLEConnectDevice.usageMode == "ropeSkipping") {
|
|
|
//跳绳蓝牙反馈
|
|
//跳绳蓝牙反馈
|
|
|
this.onBLERopeUpdate(data);
|
|
this.onBLERopeUpdate(data);
|
|
@@ -1287,4 +1405,4 @@
|
|
|
justify-content: center;
|
|
justify-content: center;
|
|
|
align-items: center;
|
|
align-items: center;
|
|
|
}
|
|
}
|
|
|
-</style>
|
|
|
|
|
|
|
+</style>
|