|
@@ -1,7 +1,7 @@
|
|
|
<template>
|
|
|
<view>
|
|
|
<!-- :src="url" src = 'http://192.168.0.112:7456/build/index.html' :src="LocationGameUrl" -->
|
|
|
- <!-- @receivedtitle="onReceivedTitle" @pagefinish="onPageFinish"-->
|
|
|
+ <!-- @receivedtitle="onReceivedTitle" @pagefinish="onPageFinish" http://192.168.31.223:7456/-->
|
|
|
<view class="web-view">
|
|
|
<web-view class="web-view-child" :src="url" ref="webview" @pagestart="onPageStart"
|
|
|
@onPostMessage="handlePostMessage" @error="onError"></web-view>
|
|
@@ -164,6 +164,12 @@
|
|
|
});
|
|
|
|
|
|
uni.$off('updateBLEDeviceData', _self.gWatchBLEUpdate);
|
|
|
+
|
|
|
+ if (0 === _self.currentModeIndex) {
|
|
|
+ //拳击柱
|
|
|
+ _self.uploadUserData_hitCount();
|
|
|
+ }
|
|
|
+
|
|
|
} //关闭跳绳模式指令
|
|
|
else if (_self.BLEConnectDevice && _self.BLEConnectDevice.deviceType == "BLERope") {
|
|
|
console.warn("还没设置关闭跳绳模式")
|
|
@@ -210,7 +216,7 @@
|
|
|
...mapMutations(['addlocalCalorie', 'syncRequestEvent', 'onWriteBLEConnectionValue',
|
|
|
'gCreateFilterObj', 'gUpdateFilter', 'B_OpenRopeSkipping', 'B_CloseRopeSkipping',
|
|
|
'gStopSimulateBLEUpdate', 'gStartSimulateBLEUpdate', 'gUpdateSandbagAlgorithm',
|
|
|
- 'gCreateSandbagAlgorithm', 'onConvertDeviceData'
|
|
|
+ 'gCreateSandbagAlgorithm', 'onConvertDeviceData','addSandbagHitCount','uploadUserData_hitCount'
|
|
|
]),
|
|
|
navBack() {
|
|
|
|
|
@@ -385,6 +391,7 @@
|
|
|
return;
|
|
|
}
|
|
|
let initStr = JSON.stringify(data);
|
|
|
+ // console.log(functionName);
|
|
|
this.$refs.webview.evalJs("onWebViewMessage(" + initStr + ")");
|
|
|
},
|
|
|
sendMessageToWebview() {
|
|
@@ -422,7 +429,6 @@
|
|
|
// score: 1230,
|
|
|
// cityCode: '110101',
|
|
|
// };
|
|
|
-
|
|
|
//2. calorieBurned 处理卡路里
|
|
|
// 记录卡路里到本地
|
|
|
this.addlocalCalorie(gameData.calorieBurned);
|
|
@@ -441,6 +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) {
|
|
@@ -536,17 +543,8 @@
|
|
|
}
|
|
|
|
|
|
} else if (temp.funName == "openAccelerometer") {
|
|
|
- //打开加速计s
|
|
|
- // if (this.globalGameAcc) {
|
|
|
- // uni.$on('watchAcceleration', this.gWatchAcceleration);
|
|
|
- // } else {
|
|
|
- // AccAndOri.bindAcc((accId) => {
|
|
|
- // this.$store.state.globalGameAcc = accId;
|
|
|
- // console.log("开启的:globalGameAcc=",this.globalGameAcc);
|
|
|
- // uni.$on('watchAcceleration', this.gWatchAcceleration);
|
|
|
- // });
|
|
|
- // }
|
|
|
if (this.globalAcc) {
|
|
|
+ uni.$off('watchAcceleration', this.gWatchAcceleration);
|
|
|
uni.$on('watchAcceleration', this.gWatchAcceleration);
|
|
|
} else {
|
|
|
uni.$emit("bindAcc", {
|
|
@@ -554,6 +552,7 @@
|
|
|
console.log("开启的:globalAcc=", accId);
|
|
|
this.bGameOpenListen = true;
|
|
|
this.$store.state.globalAcc = accId;
|
|
|
+ uni.$off('watchAcceleration', this.gWatchAcceleration);
|
|
|
uni.$on('watchAcceleration', this.gWatchAcceleration);
|
|
|
}
|
|
|
});
|
|
@@ -568,30 +567,27 @@
|
|
|
} else if (temp.funName == "openOrientation") {
|
|
|
//打开陀螺仪
|
|
|
if (this.globalOri) {
|
|
|
+ uni.$off('watchOrientation', this.gWatchOrientation);
|
|
|
uni.$on('watchOrientation', this.gWatchOrientation);
|
|
|
} else {
|
|
|
- // AccAndOri.bindOri((oriId) => {
|
|
|
- // this.$store.state.globalOri = oriId;
|
|
|
- // uni.$on('watchOrientation', this.gWatchOrientation);
|
|
|
- // });
|
|
|
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);
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
} else if (temp.funName == "closeOrientation") {
|
|
|
-
|
|
|
- // uni.$off('watchOrientation', this.gWatchOrientation);
|
|
|
uni.$off('watchOrientation', this.gWatchOrientation);
|
|
|
uni.$emit("unBindOri", this.globalOri);
|
|
|
this.$store.state.globalOri = null;
|
|
|
|
|
|
} else if (temp.funName == "bindBoxingPost") {
|
|
|
if (this.globalAcc) {
|
|
|
+ uni.$off('watchAcceleration', this.gWatchBoxingAcc);
|
|
|
uni.$on('watchAcceleration', this.gWatchBoxingAcc);
|
|
|
} else {
|
|
|
uni.$emit("bindAcc", {
|
|
@@ -599,12 +595,12 @@
|
|
|
console.log("bindBoxingPost开启的:globalAcc=", accId);
|
|
|
this.bGameOpenListen = true;
|
|
|
this.$store.state.globalAcc = accId;
|
|
|
+ uni.$off('watchAcceleration', this.gWatchBoxingAcc);
|
|
|
uni.$on('watchAcceleration', this.gWatchBoxingAcc);
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
} else if (temp.funName == "unbindBoxingPost") {
|
|
|
-
|
|
|
uni.$off('watchAcceleration', this.gWatchBoxingAcc);
|
|
|
uni.$emit("unBindAcc", this.globalAcc);
|
|
|
this.$store.state.globalAcc = null;
|
|
@@ -618,9 +614,12 @@
|
|
|
});
|
|
|
}
|
|
|
} else if (temp.funName == "bindHitBoxingPost") {
|
|
|
+ /**
|
|
|
+ * 返回拳击柱的绑定状态
|
|
|
+ */
|
|
|
console.log("bindHitBoxingPost");
|
|
|
-
|
|
|
if (this.ConnectBindingDevice) {
|
|
|
+ uni.$off('updateBLEDeviceData', this.gWatchBLEUpdate);
|
|
|
uni.$on('updateBLEDeviceData', this.gWatchBLEUpdate);
|
|
|
//hotman 沙袋情景
|
|
|
this.gCreateSandbagAlgorithm();
|
|
@@ -636,14 +635,14 @@
|
|
|
this.onWriteBLEConnectionValue({
|
|
|
value: "3"
|
|
|
});
|
|
|
- setTimeout(() => {
|
|
|
- //设置加速计b:20ms a:10ms
|
|
|
- this.onWriteBLEConnectionValue({
|
|
|
- value: config.refreshRate
|
|
|
- });
|
|
|
-
|
|
|
- }, 2000)
|
|
|
+ // 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 ==
|
|
@@ -652,11 +651,13 @@
|
|
|
this._createEquipmentBasedOnBoxingPostHit();
|
|
|
} else if (this.BLEConnectDevice.usageMode == "hotman") {
|
|
|
//hotman 沙袋情景
|
|
|
- this.gCreateFilterObj();
|
|
|
+ // this.gCreateFilterObj();
|
|
|
+ this.gCreateSandbagAlgorithm();
|
|
|
}
|
|
|
} else if (this.BLEConnectDevice.deviceType == "mySelf") {
|
|
|
//处理手机本身情况下
|
|
|
if (this.globalAcc) {
|
|
|
+ uni.$off('watchAcceleration', this.gWatchHitBoxingAcc);
|
|
|
uni.$on('watchAcceleration', this.gWatchHitBoxingAcc);
|
|
|
} else {
|
|
|
//开启手机加速计
|
|
@@ -665,6 +666,7 @@
|
|
|
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") {
|
|
@@ -683,12 +685,15 @@
|
|
|
this.B_OpenRopeSkipping();
|
|
|
this._createActionJumpOnBoxingPostHit();
|
|
|
//监听蓝牙回调
|
|
|
+ uni.$off('updateBLEDeviceData', this.gWatchBLEUpdate);
|
|
|
uni.$on('updateBLEDeviceData', this.gWatchBLEUpdate);
|
|
|
}
|
|
|
|
|
|
|
|
|
} else if (temp.funName == "unbindHitBoxingPost") {
|
|
|
-
|
|
|
+ /**
|
|
|
+ * 解绑拳击柱的绑定状态
|
|
|
+ */
|
|
|
if (this.ConnectBindingDevice) {
|
|
|
uni.$off('updateBLEDeviceData', this.gWatchBLEUpdate);
|
|
|
this.gStopSimulateBLEUpdate();
|
|
@@ -732,10 +737,12 @@
|
|
|
} 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);
|
|
@@ -745,6 +752,7 @@
|
|
|
this.bMyAttitudeListen = true;
|
|
|
this.gStartSimulateBLEUpdate();
|
|
|
//监听蓝牙回调
|
|
|
+ uni.$off('updateBLEDeviceData', this.gWatchBLEUpdate);
|
|
|
uni.$on('updateBLEDeviceData', this.gWatchBLEUpdate);
|
|
|
} else if (temp.funName == "onStopAccAndGyro") {
|
|
|
this.bMyAttitudeListen = false;
|
|
@@ -839,7 +847,8 @@
|
|
|
// console.log(res);
|
|
|
if (res.type == 'hit') {
|
|
|
// console.log('gUpdateFilter callback:',res)
|
|
|
-
|
|
|
+ //记录打击次数
|
|
|
+ this.addSandbagHitCount({count:1});
|
|
|
let temp = {
|
|
|
direction: res.direction,
|
|
|
angle: res.angle,
|
|
@@ -873,13 +882,34 @@
|
|
|
})
|
|
|
} else if (this.BLEConnectDevice.usageMode == "hotman") {
|
|
|
//hotman 沙袋情景 todo
|
|
|
- this.gUpdateFilter({
|
|
|
+ // this.gUpdateFilter({
|
|
|
+ // data: data,
|
|
|
+ // callback: (res) => {
|
|
|
+ // // console.log(res);
|
|
|
+ // if (res.type == 'hit') {
|
|
|
+ // // console.log('gUpdateFilter callback:',res)
|
|
|
+
|
|
|
+ // let temp = {
|
|
|
+ // direction: res.direction,
|
|
|
+ // angle: res.angle,
|
|
|
+ // name: res.name,
|
|
|
+ // ename: res.ename,
|
|
|
+ // value: res.hit,
|
|
|
+ // mass: 10, //质量
|
|
|
+ // hitPower: res.hit //计算的力
|
|
|
+ // }
|
|
|
+ // this.sendMessage("onBoxingPostHit", temp);
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ // });
|
|
|
+ this.gUpdateSandbagAlgorithm({
|
|
|
data: data,
|
|
|
callback: (res) => {
|
|
|
// console.log(res);
|
|
|
if (res.type == 'hit') {
|
|
|
// console.log('gUpdateFilter callback:',res)
|
|
|
-
|
|
|
+ //记录打击次数
|
|
|
+ this.addSandbagHitCount({count:1});
|
|
|
let temp = {
|
|
|
direction: res.direction,
|
|
|
angle: res.angle,
|