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
4f5b8209
Commit
4f5b8209
authored
Sep 10, 2020
by
Sky
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改bug
parent
84e2256a
Changes
3
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
402 additions
and
327 deletions
+402
-327
index.css
entry/src/main/js/default/pages/index/index.css
+300
-285
index.hml
entry/src/main/js/default/pages/index/index.hml
+14
-16
index.js
entry/src/main/js/default/pages/index/index.js
+88
-26
No files found.
entry/src/main/js/default/pages/index/index.css
View file @
4f5b8209
This diff is collapsed.
Click to expand it.
entry/src/main/js/default/pages/index/index.hml
View file @
4f5b8209
...
@@ -6,7 +6,7 @@
...
@@ -6,7 +6,7 @@
<div class="train-quit" if="page == '12'">
<div class="train-quit" if="page == '12'">
<image class="train-quit-icon" src="../../common/oppo_img_fit.png"></image>
<image class="train-quit-icon" src="../../common/oppo_img_fit.png"></image>
<div class="train-quit-text-box">
<div class="train-quit-text-box">
<text class="train-quit-text">
<text class="train-quit-text
">
请在手机上打开Fit,并登录账户
请在手机上打开Fit,并登录账户
</text>
</text>
</div>
</div>
...
@@ -23,30 +23,32 @@
...
@@ -23,30 +23,32 @@
</text>
</text>
<!--训练准备倒计时end-->
<!--训练准备倒计时end-->
<!-- 标题 -->
<!-- 标题 -->
<div class="title" if="page == '2'">
<div class="title" if="page == '2'
&& !dataPageShow
">
<text class="text">{{acName}}
<text class="text">{{acName}}
</text>
</text>
</div>
</div>
<!-- 对端应用未安装 -->
<div class="install" if="page == '999'">
<text class="installText">
{{installText}}
</text>
</div>
<!-- 标题end -->
<!-- 标题end -->
<swiper index="{{tabIndex}}" class="todo-wraper" if="
page == '3' || page == '4' || page == '5'|| page == '6'
">
<swiper index="{{tabIndex}}" class="todo-wraper" if="
dataPageShow" @change="swiperChange
">
<div class="todo-item">
<div class="todo-item">
<!-- 动作预览 -->
<!-- 动作预览 -->
<div class="train-view">
<div class="train-view">
<text if="page == '3'" class="train-page-title">
<text if="page == '
2'||page == '
3'" class="train-page-title">
动作预览
动作预览
</text>
</text>
<div if="page == '4' " class="train-pape-num-box">
<div if="page == '4' " class="train-pape-num-box">
<text class="train-pape-num-o">{{countdownT}}
<text class="train-pape-num-o">{{countdownT}}
</text>
</text>
</div>
</div>
<div if="
(page == '5'|| page == '6') && acType == '1'
" class="train-pape-num-box">
<div if="
page == '5'|| page == '6'
" class="train-pape-num-box">
<text class="train-pape-num">{{countdownT}}
<text class="train-pape-num">{{countdownT}}
</text>
</text>
</div>
</div>
<div if="page == '5'&& acType == '0' " class="train-pape-num-box">
<text class="train-pape-num">{{acCnt}}/{{acTotalCnt}}
</text>
</div>
<text class="train-view-title"> {{acName}}
<text class="train-view-title"> {{acName}}
</text>
</text>
<div class="train-view-progress-line">
<div class="train-view-progress-line">
...
@@ -55,16 +57,12 @@
...
@@ -55,16 +57,12 @@
<div class="train-num">
<div class="train-num">
<div class="train-heartbeat">
<div class="train-heartbeat">
<image class="train-num-icon" src="../../common/oppo_icon_heart.png"></image>
<image class="train-num-icon" src="../../common/oppo_icon_heart.png"></image>
<text if="newHeartRate != '--'" class="train-num-text">{{newHeartRate}}
<text class="train-num-text">{{newHeartRate}}
</text>
<text class="train-num-text train-num-text-no" else>{{newHeartRate}}
</text>
</text>
</div>
</div>
<div class="train-calorie">
<div class="train-calorie">
<image class="train-num-icon" src="../../common/oppo_icon_calorie.png"></image>
<image class="train-num-icon" src="../../common/oppo_icon_calorie.png"></image>
<text if="acCalorie != '--'" class="train-num-text">{{acCalorie}}
<text class="train-num-text">{{acCalorie}}
</text>
<text class="train-num-text train-num-text-no" else>{{acCalorie}}
</text>
</text>
</div>
</div>
</div>
</div>
...
@@ -98,7 +96,7 @@
...
@@ -98,7 +96,7 @@
</div>
</div>
</swiper>
</swiper>
<!--切换圆点-->
<!--切换圆点-->
<div class="select" if="
page == '3' || page == '4' || page == '5' || page == '7' || page == '8'
">
<div class="select" if="
dataPageShow
">
<div if="{{tabIndex == 0}}" class="select-item select-item-active"></div>
<div if="{{tabIndex == 0}}" class="select-item select-item-active"></div>
<div if="{{tabIndex == 0}}" class="select-item"></div>
<div if="{{tabIndex == 0}}" class="select-item"></div>
<div if="{{tabIndex == 1}}" class="select-item"></div>
<div if="{{tabIndex == 1}}" class="select-item"></div>
...
...
entry/src/main/js/default/pages/index/index.js
View file @
4f5b8209
import
sensor
from
'@system.sensor'
;
//传感器
import
sensor
from
'@system.sensor'
;
//传感器
import
vibrator
from
'@system.vibrator'
;
//震动
import
vibrator
from
'@system.vibrator'
;
//震动
import
brightness
from
'@system.brightness'
//保持屏幕常亮
import
brightness
from
'@system.brightness'
//保持屏幕常亮
//import {P2pClient, Message, Builder} from '../wearengine'
export
default
{
export
default
{
data
:
{
data
:
{
page
:
""
,
//显示页面
page
:
""
,
//显示页面
title
:
"训练准备"
,
//页面标题
title
:
"训练准备"
,
//页面标题
acName
:
"
"
,
//动作名称
acName
:
""
,
//动作名称
progress
:
""
,
//进度条
progress
:
""
,
//进度条
acType
:
""
,
//次/秒 (0:次,1:秒)
acType
:
""
,
//次/秒 (0:次,1:秒)
acCnt
:
"00"
,
//动作次数
acTotalCnt
:
"00"
,
// 动作总次数
acCalorie
:
""
,
//卡路里
acCalorie
:
""
,
//卡路里
countdownT
:
""
,
// 倒计时
countdownT
:
""
,
// 倒计时
restHint
:
""
,
//休息文案
restHint
:
""
,
//休息文案
...
@@ -23,19 +22,23 @@ export default {
...
@@ -23,19 +22,23 @@ export default {
maxHeartRate
:
""
,
//最高心率
maxHeartRate
:
""
,
//最高心率
rollbackStop
:
""
,
//切出回来时候,是否需要暂停 "0":暂停 "0以外":切出训练
rollbackStop
:
""
,
//切出回来时候,是否需要暂停 "0":暂停 "0以外":切出训练
newHeartRate
:
"--"
,
//当前心率
newHeartRate
:
"--"
,
//当前心率
isStop
:
false
,
//是否暂停
isStop
:
false
,
//是否
是手表端
暂停
sendFlg
:
false
,
// 是否在发送消息
sendFlg
:
false
,
// 是否在发送消息
stopFlg
:
false
,
//是否暂停
stopFlg
:
false
,
//是否暂停
tabIndex
:
0
,
//滑动index
tabIndex
:
0
,
//滑动index
isPhoneLeave
:
false
,
//手机端离开状态
isPhoneLeave
:
false
,
//手机端离开状态
isEnd
:
false
,
//是否完成
isEnd
:
false
,
//是否完成
lastPage
:
""
,
//上个页面标识
isJumpLoginPage
:
true
,
//是否跳转到未登录提示页
isReceiveStartMessage
:
false
,
//启动时收到手机端给的回复消息
dataPageShow
:
false
,
//训练数据页面是否显示
canReceiveMessage
:
true
,
//是否可以接收手机端其他事件(手表端主动暂停或训练结束后,不再接收除17外的其他事件)
installText
:
"请在手机上下载
\n
Fit App"
,
},
},
onReady
()
{
onReady
()
{
let
_this
=
this
;
let
_this
=
this
;
//数据重置
//数据重置
_this
.
restore
();
_this
.
restore
();
//ping手机端状态
// _this.ping();
//获取客户端信息
//获取客户端信息
_this
.
getMsg
();
_this
.
getMsg
();
//发送个启动事件
//发送个启动事件
...
@@ -44,7 +47,7 @@ export default {
...
@@ -44,7 +47,7 @@ export default {
});
});
//关闭启动页
//关闭启动页
setTimeout
(
function
()
{
setTimeout
(
function
()
{
if
(
!
_this
.
isReceiveStartMess
age
)
{
if
(
_this
.
isJumpLoginP
age
)
{
_this
.
page
=
"12"
;
_this
.
page
=
"12"
;
}
}
},
1500
);
},
1500
);
...
@@ -66,12 +69,19 @@ export default {
...
@@ -66,12 +69,19 @@ export default {
let
_this
=
this
;
let
_this
=
this
;
let
model
=
msg
.
acModel
;
let
model
=
msg
.
acModel
;
//手表端主动关闭训练后,不接收除17外的初始化事件,
if
(
msg
.
eventFlg
==
"17"
)
{
_this
.
canReceiveMessage
=
true
;
}
if
(
!
_this
.
canReceiveMessage
)
{
return
;
}
//接到手机端消息时(去掉17初始化的事件),启动页显示完后,不显示提示登录页面page 12
//接到手机端消息时(去掉17初始化的事件),启动页显示完后,不显示提示登录页面page 12
if
(
msg
.
eventFlg
!=
""
)
{
if
(
msg
.
eventFlg
!=
""
)
{
if
(
msg
.
eventFlg
==
"17"
)
{
if
(
msg
.
eventFlg
==
"17"
)
{
_this
.
page
=
"11"
;
_this
.
page
=
"11"
;
}
}
_this
.
is
ReceiveStartMessage
=
tru
e
;
_this
.
is
JumpLoginPage
=
fals
e
;
}
}
if
(
_this
.
sendFlg
)
{
if
(
_this
.
sendFlg
)
{
return
false
;
return
false
;
...
@@ -82,7 +92,7 @@ export default {
...
@@ -82,7 +92,7 @@ export default {
_this
.
isStop
=
false
;
_this
.
isStop
=
false
;
//手机端主动离开事件,等待0.5秒后再处理其他事件
//手机端主动离开事件,等待0.5秒后再处理其他事件
if
(
_this
.
isPhoneLeave
)
{
if
(
_this
.
isPhoneLeave
&&
msg
.
eventFlg
!=
"10"
)
{
return
return
}
}
if
(
msg
.
eventFlg
==
"15"
&&
model
.
rollbackStop
!=
'0'
)
{
if
(
msg
.
eventFlg
==
"15"
&&
model
.
rollbackStop
!=
'0'
)
{
...
@@ -97,6 +107,17 @@ export default {
...
@@ -97,6 +107,17 @@ export default {
return
false
;
return
false
;
}
}
}
}
//训练数据页面是否显示(避免重复添加、移除操作)
if
(
msg
.
eventFlg
!=
"13"
&&
msg
.
eventFlg
!=
"14"
)
{
if
(
msg
.
eventFlg
==
"3"
||
msg
.
eventFlg
==
"4"
||
msg
.
eventFlg
==
"5"
||
msg
.
eventFlg
==
"6"
||
msg
.
eventFlg
==
"7"
||
msg
.
eventFlg
==
"8"
)
{
if
(
!
_this
.
dataPageShow
)
{
_this
.
dataPageShow
=
true
;
}
}
else
{
_this
.
dataPageShow
=
false
;
}
}
// _this.sendErrMsg(msg.eventFlg,"手表端处理接收到的消息类型:");
switch
(
msg
.
eventFlg
)
{
switch
(
msg
.
eventFlg
)
{
case
"0"
:
//训练准备
case
"0"
:
//训练准备
_this
.
page
=
"0"
;
_this
.
page
=
"0"
;
...
@@ -114,6 +135,8 @@ export default {
...
@@ -114,6 +135,8 @@ export default {
_this
.
acName
=
model
.
acName
;
_this
.
acName
=
model
.
acName
;
_this
.
isLast
=
model
.
isLast
;
_this
.
isLast
=
model
.
isLast
;
_this
.
isFirst
=
model
.
isFirst
;
_this
.
isFirst
=
model
.
isFirst
;
_this
.
tabIndex
=
0
;
_this
.
stopFlg
=
false
;
break
;
break
;
case
"3"
:
//动作预览
case
"3"
:
//动作预览
_this
.
page
=
"3"
;
_this
.
page
=
"3"
;
...
@@ -127,11 +150,11 @@ export default {
...
@@ -127,11 +150,11 @@ export default {
case
"5"
:
//训练动作倒计时
case
"5"
:
//训练动作倒计时
_this
.
page
=
"5"
;
_this
.
page
=
"5"
;
_this
.
acName
=
model
.
acName
;
_this
.
acName
=
model
.
acName
;
_this
.
countdownT
=
model
.
countdownT
==
"-1"
?
"0"
:
model
.
countdownT
;
_this
.
acType
=
model
.
acType
;
_this
.
acType
=
model
.
acType
;
if
(
model
.
acType
==
"0"
)
{
if
(
model
.
acType
==
"0"
)
{
_this
.
acCnt
=
model
.
acCnt
;
_this
.
countdownT
=
model
.
acCnt
+
"/"
+
model
.
acTotalCnt
;
_this
.
acTotalCnt
=
model
.
acTotalCnt
;
}
else
{
_this
.
countdownT
=
model
.
countdownT
;
}
}
break
;
break
;
case
"6"
:
//休息中
case
"6"
:
//休息中
...
@@ -141,6 +164,7 @@ export default {
...
@@ -141,6 +164,7 @@ export default {
_this
.
acType
=
1
;
_this
.
acType
=
1
;
break
;
break
;
case
"7"
:
//暂停
case
"7"
:
//暂停
_this
.
page
=
"7"
;
_this
.
tabIndex
=
1
;
_this
.
tabIndex
=
1
;
_this
.
stopFlg
=
true
;
_this
.
stopFlg
=
true
;
break
;
break
;
...
@@ -151,24 +175,25 @@ export default {
...
@@ -151,24 +175,25 @@ export default {
break
;
break
;
case
"9"
:
//完成训练
case
"9"
:
//完成训练
_this
.
vibrate
();
_this
.
vibrate
();
_this
.
canReceiveMessage
=
false
;
_this
.
isEnd
=
true
;
_this
.
isEnd
=
true
;
_this
.
page
=
"9"
;
_this
.
page
=
"9"
;
_this
.
fitTotalDuration
=
model
.
fitTotalDuration
;
_this
.
fitTotalDuration
=
model
.
fitTotalDuration
;
_this
.
averHeartRate
=
_this
.
getAverHeartRate
(
_this
.
heartRateList
);
//平均心率
_this
.
averHeartRate
=
_this
.
getAverHeartRate
(
_this
.
heartRateList
);
//平均心率
_this
.
maxHeartRate
=
_this
.
getMaxHeartRatet
(
_this
.
heartRateList
);
//最高心率
_this
.
maxHeartRate
=
_this
.
getMaxHeartRatet
(
_this
.
heartRateList
);
//最高心率
_this
.
acCalorie
=
model
.
acCalorie
;
_this
.
acCalorie
=
model
.
acCalorie
;
this
.
quit
();
_
this
.
quit
();
break
;
break
;
case
"10"
:
//退出训练
case
"10"
:
//退出训练
_this
.
page
=
"10"
;
_this
.
page
=
"10"
;
this
.
quit
();
_
this
.
quit
();
break
;
break
;
case
"11"
:
//登录中
case
"11"
:
//登录中
_this
.
page
=
"11"
_this
.
page
=
"11"
break
;
break
;
case
"12"
:
//退出登录
case
"12"
:
//退出登录
_this
.
page
=
"12"
;
_this
.
page
=
"12"
;
this
.
quit
();
_
this
.
quit
();
break
;
break
;
case
"13"
:
//进度条
case
"13"
:
//进度条
_this
.
progress
=
((
model
.
acProgress
/
model
.
maxProgress
)
*
350
);
_this
.
progress
=
((
model
.
acProgress
/
model
.
maxProgress
)
*
350
);
...
@@ -178,19 +203,12 @@ export default {
...
@@ -178,19 +203,12 @@ export default {
_this
.
fitDuration
=
model
.
fitDuration
;
_this
.
fitDuration
=
model
.
fitDuration
;
break
;
break
;
case
"15"
:
//离开或者返回训练
case
"15"
:
//离开或者返回训练
if
(
model
.
rollbackStop
==
'0'
)
{
_this
.
page
=
"15"
;
if
(
_this
.
lastPage
!=
""
)
{
_this
.
quit
();
_this
.
page
=
_this
.
lastPage
;
}
}
else
{
_this
.
lastPage
=
_this
.
page
;
_this
.
page
=
"15"
}
this
.
quit
();
break
;
break
;
case
"16"
:
//杀掉进程
case
"16"
:
//杀掉进程
_this
.
page
=
"12"
;
_this
.
page
=
"12"
;
this
.
quit
();
_
this
.
quit
();
break
;
break
;
case
"17"
:
//播放初始化、注册心率
case
"17"
:
//播放初始化、注册心率
//获取心率
//获取心率
...
@@ -199,6 +217,39 @@ export default {
...
@@ -199,6 +217,39 @@ export default {
}
}
},
},
/**
*PING手机端状态
*/
// ping() {
// let _this = this;
// // 步骤1:创建点对点通信对象
// var p2pClient = new P2pClient();
// // 步骤2:设置需要通信的手机侧对应的三方应用包名
// p2pClient.setPeerPkgName("com.sportq.fit");
// // 步骤3:检测手机侧对应的第三方应用是否在线
// p2pClient.ping({
// onSuccess: function () {
// console.log('ping success.');
// },
// onFailure: function () {
// console.log('ping failed');
// },
// onPingResult: function (resultCode) {
// //205:手机端应用已安装 204:未安装
// if (resultCode.code == 205) {
// //发送个启动事件
// _this.sendMsg({
// "eventFlg": "6",
// });
// } else {
// //对端应用未安装,提示安装
// _this.isJumpLoginPage = false;
// _this.page = "999";
// }
// console.log(resultCode.data + resultCode.code);
// },
// });
// },
/**
/**
发送短消息给客户端
发送短消息给客户端
*/
*/
...
@@ -245,6 +296,7 @@ export default {
...
@@ -245,6 +296,7 @@ export default {
let
_this
=
this
;
let
_this
=
this
;
FeatureAbility
.
subscribeMsg
({
FeatureAbility
.
subscribeMsg
({
success
:
function
(
data
)
{
success
:
function
(
data
)
{
// _this.sendErrMsg(data.message,"手表端接收到消息数据:");
_this
.
start
(
JSON
.
parse
(
data
.
message
));
_this
.
start
(
JSON
.
parse
(
data
.
message
));
},
},
fail
:
function
(
data
,
code
)
{
fail
:
function
(
data
,
code
)
{
...
@@ -361,6 +413,8 @@ export default {
...
@@ -361,6 +413,8 @@ export default {
*关闭
*关闭
*/
*/
close
()
{
close
()
{
this
.
canReceiveMessage
=
false
;
this
.
page
=
"10"
;
this
.
sendMsg
({
this
.
sendMsg
({
"eventFlg"
:
"5"
,
"eventFlg"
:
"5"
,
});
});
...
@@ -410,8 +464,8 @@ export default {
...
@@ -410,8 +464,8 @@ export default {
*数据重置
*数据重置
*/
*/
restore
()
{
restore
()
{
this
.
lastPage
=
""
;
this
.
isStop
=
false
;
this
.
isStop
=
false
;
this
.
canReceiveMessage
=
true
;
this
.
sendFlg
=
false
;
this
.
sendFlg
=
false
;
this
.
stopFlg
=
false
;
this
.
stopFlg
=
false
;
this
.
heartRateList
=
[];
this
.
heartRateList
=
[];
...
@@ -438,5 +492,13 @@ export default {
...
@@ -438,5 +492,13 @@ export default {
*/
*/
end
()
{
end
()
{
this
.
page
=
'10'
;
this
.
page
=
'10'
;
},
/*
*swiper滑动
*/
swiperChange
(
index
)
{
console
.
info
(
index
);
this
.
tabIndex
=
index
.
index
;
}
}
}
}
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