Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
H
huaweiWatchClient
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Sky
huaweiWatchClient
Commits
fd705e6b
Commit
fd705e6b
authored
Dec 11, 2020
by
Sky
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改常亮问题
parent
e362e5e5
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
31 additions
and
50 deletions
+31
-50
end.js
entry/src/main/js/default/pages/end/end.js
+10
-0
index.js
entry/src/main/js/default/pages/index/index.js
+21
-50
No files found.
entry/src/main/js/default/pages/end/end.js
View file @
fd705e6b
...
...
@@ -19,6 +19,16 @@ export default {
_this
.
averHeartRate
=
_this
.
endAverHeartRate
;
_this
.
maxHeartRate
=
_this
.
endMaxHeartRate
;
},
onShow
()
{
//取消常亮
brightness
.
setKeepScreenOn
({
keepScreenOn
:
false
,
success
:
function
()
{
},
fail
:
function
(
data
,
code
)
{
}
})
},
onDestroy
()
{
//取消接收手机侧第三方应用发过来的消息
FeatureAbility
.
unsubscribeMsg
();
...
...
entry/src/main/js/default/pages/index/index.js
View file @
fd705e6b
...
...
@@ -17,7 +17,6 @@ export default {
isLast
:
""
,
//是否第一个动作 "0":真 "1":假
isFirst
:
""
,
// 是否最后一个动作 "0":真 "1":假
fitDuration
:
"00:00"
,
//训练持续时长
heartRateList
:
[],
//心率数组
newHeartRate
:
"--"
,
//当前心率
isStop
:
false
,
//是否是手表端暂停
sendFlg
:
false
,
// 是否在发送消息
...
...
@@ -57,12 +56,7 @@ export default {
},
onShow
()
{
let
_this
=
this
;
//保持屏幕常亮
_this
.
keepScreenOn
();
timer
=
setInterval
(
function
()
{
_this
.
keepScreenOn
();
},
2
*
60
*
1000
);
//重新回到训练界面时,同步一下训练数据及暂停播放状态
//重新回到训练界面时,同步一下训练数据
_this
.
sendMsg
({
"eventFlg"
:
"8"
,
});
...
...
@@ -88,6 +82,14 @@ export default {
let
_this
=
this
;
let
model
=
msg
.
acModel
;
//保持屏幕常亮
if
(
timer
==
null
)
{
_this
.
keepScreenOn
();
timer
=
setInterval
(
function
()
{
_this
.
keepScreenOn
();
},
2
*
60
*
1000
);
}
//手表端主动关闭训练后,不接收除17外的初始化事件,
if
(
msg
.
eventFlg
==
"17"
)
{
//数据重置
...
...
@@ -217,12 +219,13 @@ export default {
break
;
case
"9"
:
//完成训练
_this
.
vibrate
();
sensor
.
unsubscribeHeartRate
();
router
.
replace
({
uri
:
"pages/end/end"
,
params
:
{
endTotalTime
:
model
.
fitTotalDuration
,
//训练时间
endAverHeartRate
:
_this
.
getAverHeartRate
(
_this
.
heartRateList
)
,
//平均心率
endMaxHeartRate
:
_this
.
getMaxHeartRate
(
_this
.
heartRateList
)
,
//最高心率
endAverHeartRate
:
model
.
averHeartRate
,
//平均心率
endMaxHeartRate
:
model
.
maxHeartRate
,
//最高心率
endCalorie
:
model
.
acCalorie
,
//消耗心率
}
});
...
...
@@ -363,7 +366,6 @@ export default {
success
:
function
(
data
)
{
if
(
data
.
heartRate
!=
255
)
{
_this
.
newHeartRate
=
data
.
heartRate
;
_this
.
heartRateList
.
push
(
data
.
heartRate
);
}
else
{
_this
.
newHeartRate
=
"--"
;
}
...
...
@@ -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 {
this
.
fitDuration
=
"00:00"
;
this
.
progress
=
""
,
//进度条
this
.
countdownT
=
""
,
// 倒计时
this
.
heartRateList
=
[];
//取消接收手机侧第三方应用发过来的消息
FeatureAbility
.
unsubscribeMsg
();
sensor
.
unsubscribeHeartRate
()
//取消监听心率
...
...
@@ -543,10 +506,18 @@ export default {
this
.
progress
=
""
,
//进度条
this
.
countdownT
=
""
,
// 倒计时
this
.
newHeartRate
=
"--"
,
//当前心率
this
.
heartRateList
=
[];
sensor
.
unsubscribeHeartRate
()
//取消监听心率
if
(
timer
!=
null
)
{
clearInterval
(
timer
);
timer
=
null
;
//取消常亮
brightness
.
setKeepScreenOn
({
keepScreenOn
:
false
,
success
:
function
()
{
},
fail
:
function
(
data
,
code
)
{
}
})
}
},
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment