Commit fd705e6b authored by Sky's avatar Sky

修改常亮问题

parent e362e5e5
...@@ -19,6 +19,16 @@ export default { ...@@ -19,6 +19,16 @@ export default {
_this.averHeartRate = _this.endAverHeartRate; _this.averHeartRate = _this.endAverHeartRate;
_this.maxHeartRate = _this.endMaxHeartRate; _this.maxHeartRate = _this.endMaxHeartRate;
}, },
onShow() {
//取消常亮
brightness.setKeepScreenOn({
keepScreenOn: false,
success: function () {
},
fail: function (data, code) {
}
})
},
onDestroy() { onDestroy() {
//取消接收手机侧第三方应用发过来的消息 //取消接收手机侧第三方应用发过来的消息
FeatureAbility.unsubscribeMsg(); FeatureAbility.unsubscribeMsg();
......
...@@ -17,7 +17,6 @@ export default { ...@@ -17,7 +17,6 @@ export default {
isLast: "", //是否第一个动作 "0":真 "1":假 isLast: "", //是否第一个动作 "0":真 "1":假
isFirst: "", // 是否最后一个动作 "0":真 "1":假 isFirst: "", // 是否最后一个动作 "0":真 "1":假
fitDuration: "00:00", //训练持续时长 fitDuration: "00:00", //训练持续时长
heartRateList: [], //心率数组
newHeartRate: "--", //当前心率 newHeartRate: "--", //当前心率
isStop: false, //是否是手表端暂停 isStop: false, //是否是手表端暂停
sendFlg: false, // 是否在发送消息 sendFlg: false, // 是否在发送消息
...@@ -57,12 +56,7 @@ export default { ...@@ -57,12 +56,7 @@ export default {
}, },
onShow() { onShow() {
let _this = this; let _this = this;
//保持屏幕常亮 //重新回到训练界面时,同步一下训练数据
_this.keepScreenOn();
timer = setInterval(function () {
_this.keepScreenOn();
},2 * 60 * 1000);
//重新回到训练界面时,同步一下训练数据及暂停播放状态
_this.sendMsg({ _this.sendMsg({
"eventFlg": "8", "eventFlg": "8",
}); });
...@@ -88,6 +82,14 @@ export default { ...@@ -88,6 +82,14 @@ export default {
let _this = this; let _this = this;
let model = msg.acModel; let model = msg.acModel;
//保持屏幕常亮
if (timer == null) {
_this.keepScreenOn();
timer = setInterval(function () {
_this.keepScreenOn();
},2 * 60 * 1000);
}
//手表端主动关闭训练后,不接收除17外的初始化事件, //手表端主动关闭训练后,不接收除17外的初始化事件,
if (msg.eventFlg == "17") { if (msg.eventFlg == "17") {
//数据重置 //数据重置
...@@ -217,12 +219,13 @@ export default { ...@@ -217,12 +219,13 @@ export default {
break; break;
case "9": //完成训练 case "9": //完成训练
_this.vibrate(); _this.vibrate();
sensor.unsubscribeHeartRate();
router.replace({ router.replace({
uri: "pages/end/end", uri: "pages/end/end",
params: { params: {
endTotalTime: model.fitTotalDuration, //训练时间 endTotalTime: model.fitTotalDuration, //训练时间
endAverHeartRate: _this.getAverHeartRate(_this.heartRateList), //平均心率 endAverHeartRate: model.averHeartRate, //平均心率
endMaxHeartRate: _this.getMaxHeartRate(_this.heartRateList), //最高心率 endMaxHeartRate: model.maxHeartRate, //最高心率
endCalorie: model.acCalorie, //消耗心率 endCalorie: model.acCalorie, //消耗心率
} }
}); });
...@@ -363,7 +366,6 @@ export default { ...@@ -363,7 +366,6 @@ export default {
success: function (data) { success: function (data) {
if (data.heartRate != 255) { if (data.heartRate != 255) {
_this.newHeartRate = data.heartRate; _this.newHeartRate = data.heartRate;
_this.heartRateList.push(data.heartRate);
} else { } else {
_this.newHeartRate = "--"; _this.newHeartRate = "--";
} }
...@@ -378,44 +380,6 @@ export default { ...@@ -378,44 +380,6 @@ export default {
}) })
}, },
/**
*计算平均心率
*/
getAverHeartRate(arr) {
if (arr.length > 0) {
//将array的长度赋给len
let len = arr.length;
let sum = 0;
//利用for循环遍历数组的内容,利用sum累加求和
for (let i = 0; i < len; i++) {
sum += arr[i];
}
//返回数组的和与长度求平均值
return parseInt(sum / len);
} else {
return "--"
}
}
,
/**
*获取最大心率
*/
getMaxHeartRate(arr) {
if (arr.length > 0) {
let max = arr[0];
for (let i = 0; i < arr.length; i++) {
if (arr[i] > max) {
max = arr[i];
}
}
return parseInt(max)
} else {
return "--"
}
},
/** /**
*暂停 *暂停
*/ */
...@@ -511,7 +475,6 @@ export default { ...@@ -511,7 +475,6 @@ export default {
this.fitDuration = "00:00"; this.fitDuration = "00:00";
this.progress = "", //进度条 this.progress = "", //进度条
this.countdownT = "", // 倒计时 this.countdownT = "", // 倒计时
this.heartRateList = [];
//取消接收手机侧第三方应用发过来的消息 //取消接收手机侧第三方应用发过来的消息
FeatureAbility.unsubscribeMsg(); FeatureAbility.unsubscribeMsg();
sensor.unsubscribeHeartRate() //取消监听心率 sensor.unsubscribeHeartRate() //取消监听心率
...@@ -543,10 +506,18 @@ export default { ...@@ -543,10 +506,18 @@ export default {
this.progress = "", //进度条 this.progress = "", //进度条
this.countdownT = "", // 倒计时 this.countdownT = "", // 倒计时
this.newHeartRate = "--", //当前心率 this.newHeartRate = "--", //当前心率
this.heartRateList = [];
sensor.unsubscribeHeartRate() //取消监听心率 sensor.unsubscribeHeartRate() //取消监听心率
if (timer != null) { if (timer != null) {
clearInterval(timer); clearInterval(timer);
timer = null;
//取消常亮
brightness.setKeepScreenOn({
keepScreenOn: false,
success: function () {
},
fail: function (data, code) {
}
})
} }
}, },
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment