|
@@ -1,9 +1,9 @@
|
|
|
<template>
|
|
|
<view>
|
|
|
- <!-- :src="url" src = 'http://192.168.0.112:7456/build/index.html' :src="LocationGameUrl" :src="'http://' + LocationGameUrl + '/'" -->
|
|
|
- <!-- @receivedtitle="onReceivedTitle" @pagefinish="onPageFinish"-->
|
|
|
+ <!-- :src="url" src = 'http://192.168.0.112:7456/build/index.html' :src="LocationGameUrl" -->
|
|
|
+ <!-- @receivedtitle="onReceivedTitle" @pagefinish="onPageFinish" http://192.168.31.223:7456/-->
|
|
|
<view class="web-view">
|
|
|
- <web-view class="web-view-child" :src="url" ref="webview" @pagestart="onPageStart"
|
|
|
+ <web-view class="web-view-child" src='http://192.168.1.12:7456/' ref="webview" @pagestart="onPageStart"
|
|
|
@onPostMessage="handlePostMessage" @error="onError"></web-view>
|
|
|
</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() {
|
|
|
|
|
@@ -307,7 +313,7 @@
|
|
|
* 初始化发送数据给游戏
|
|
|
*/
|
|
|
sendGameInit() {
|
|
|
-
|
|
|
+ console.log("this.avatarUrl:",this.avatarUrl);
|
|
|
this.urlToBase64(this.avatarUrl, (toBase64Url) => {
|
|
|
let device = null;
|
|
|
/**
|
|
@@ -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,15 +614,18 @@
|
|
|
});
|
|
|
}
|
|
|
} else if (temp.funName == "bindHitBoxingPost") {
|
|
|
+ /**
|
|
|
+ * 返回拳击柱的绑定状态
|
|
|
+ */
|
|
|
console.log("bindHitBoxingPost");
|
|
|
-
|
|
|
- // if (this.ConnectBindingDevice) {
|
|
|
- // uni.$on('updateBLEDeviceData', this.gWatchBLEUpdate);
|
|
|
- // //hotman 沙袋情景
|
|
|
- // this.gCreateSandbagAlgorithm();
|
|
|
- // this.gStartSimulateBLEUpdate();
|
|
|
- // return;
|
|
|
- // }
|
|
|
+ if (this.ConnectBindingDevice) {
|
|
|
+ uni.$off('updateBLEDeviceData', this.gWatchBLEUpdate);
|
|
|
+ uni.$on('updateBLEDeviceData', this.gWatchBLEUpdate);
|
|
|
+ //hotman 沙袋情景
|
|
|
+ this.gCreateSandbagAlgorithm();
|
|
|
+ this.gStartSimulateBLEUpdate();
|
|
|
+ return;
|
|
|
+ }
|
|
|
|
|
|
if (!this.BLEConnectDevice) return;
|
|
|
//用设备来区分,开启什么加速计;
|
|
@@ -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 ==
|
|
@@ -658,6 +657,7 @@
|
|
|
} else if (this.BLEConnectDevice.deviceType == "mySelf") {
|
|
|
//处理手机本身情况下
|
|
|
if (this.globalAcc) {
|
|
|
+ uni.$off('watchAcceleration', this.gWatchHitBoxingAcc);
|
|
|
uni.$on('watchAcceleration', this.gWatchHitBoxingAcc);
|
|
|
} else {
|
|
|
//开启手机加速计
|
|
@@ -666,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") {
|
|
@@ -684,17 +685,20 @@
|
|
|
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();
|
|
|
- // return;
|
|
|
- // }
|
|
|
+ /**
|
|
|
+ * 解绑拳击柱的绑定状态
|
|
|
+ */
|
|
|
+ if (this.ConnectBindingDevice) {
|
|
|
+ uni.$off('updateBLEDeviceData', this.gWatchBLEUpdate);
|
|
|
+ this.gStopSimulateBLEUpdate();
|
|
|
+ return;
|
|
|
+ }
|
|
|
|
|
|
if (this.BLEConnectDevice && this.BLEConnectDevice.deviceType == "BLEHandle") {
|
|
|
//开启设备回调 3/4关闭
|
|
@@ -733,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);
|
|
@@ -746,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;
|
|
@@ -832,30 +839,31 @@
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
- // if (this.ConnectBindingDevice) {
|
|
|
- // //hotman 沙袋情景 todo
|
|
|
- // this.gUpdateSandbagAlgorithm({
|
|
|
- // 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);
|
|
|
- // }
|
|
|
- // }
|
|
|
- // });
|
|
|
- // return;
|
|
|
- // }
|
|
|
+ if (this.ConnectBindingDevice) {
|
|
|
+ //hotman 沙袋情景 todo
|
|
|
+ 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,
|
|
|
+ name: res.name,
|
|
|
+ ename: res.ename,
|
|
|
+ value: res.hit,
|
|
|
+ mass: 10, //质量
|
|
|
+ hitPower: res.hit //计算的力
|
|
|
+ }
|
|
|
+ this.sendMessage("onBoxingPostHit", temp);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ return;
|
|
|
+ }
|
|
|
|
|
|
if (this.BLEConnectDevice.usageMode == "phone" || this.BLEConnectDevice.usageMode == "general") {
|
|
|
//手机情景或者自由模式
|
|
@@ -899,6 +907,9 @@
|
|
|
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,
|
|
@@ -1046,10 +1057,10 @@
|
|
|
hitPower: 10 //计算的力
|
|
|
}
|
|
|
if (e.type == 'stateDataOfJump') {
|
|
|
- console.log("game stateDataOfJump");
|
|
|
+ // console.log("game stateDataOfJump");
|
|
|
this.sendMessage("onBoxingPostHit", temp);
|
|
|
} else if (e.type == 'stop') {
|
|
|
- console.log("game stop");
|
|
|
+ // console.log("game stop");
|
|
|
this.onClearData();
|
|
|
// this.sendMessage("onBoxingPostHit", temp);
|
|
|
}
|