Commit 4f5b8209 authored by Sky's avatar Sky

修改bug

parent 84e2256a
......@@ -6,7 +6,7 @@
<div class="train-quit" if="page == '12'">
<image class="train-quit-icon" src="../../common/oppo_img_fit.png"></image>
<div class="train-quit-text-box">
<text class="train-quit-text">
<text class="train-quit-text ">
请在手机上打开Fit,并登录账户
</text>
</div>
......@@ -23,30 +23,32 @@
</text>
<!--训练准备倒计时end-->
<!-- 标题 -->
<div class="title" if="page == '2'">
<div class="title" if="page == '2' && !dataPageShow">
<text class="text">{{acName}}
</text>
</div>
<!-- 对端应用未安装 -->
<div class="install" if="page == '999'">
<text class="installText">
{{installText}}
</text>
</div>
<!-- 标题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="train-view">
<text if="page == '3'" class="train-page-title">
<text if="page == '2'||page == '3'" class="train-page-title">
动作预览
</text>
<div if="page == '4' " class="train-pape-num-box">
<text class="train-pape-num-o">{{countdownT}}
</text>
</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>
</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>
<div class="train-view-progress-line">
......@@ -55,16 +57,12 @@
<div class="train-num">
<div class="train-heartbeat">
<image class="train-num-icon" src="../../common/oppo_icon_heart.png"></image>
<text if="newHeartRate != '--'" class="train-num-text">{{newHeartRate}}
</text>
<text class="train-num-text train-num-text-no" else>{{newHeartRate}}
<text class="train-num-text">{{newHeartRate}}
</text>
</div>
<div class="train-calorie">
<image class="train-num-icon" src="../../common/oppo_icon_calorie.png"></image>
<text if="acCalorie != '--'" class="train-num-text">{{acCalorie}}
</text>
<text class="train-num-text train-num-text-no" else>{{acCalorie}}
<text class="train-num-text">{{acCalorie}}
</text>
</div>
</div>
......@@ -98,7 +96,7 @@
</div>
</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"></div>
<div if="{{tabIndex == 1}}" class="select-item"></div>
......
import sensor from '@system.sensor'; //传感器
import vibrator from '@system.vibrator'; //震动
import brightness from '@system.brightness' //保持屏幕常亮
//import {P2pClient, Message, Builder} from '../wearengine'
export default {
data: {
page: "", //显示页面
title: "训练准备", //页面标题
acName: " ", //动作名称
acName: "", //动作名称
progress: "", //进度条
acType: "", //次/秒 (0:次,1:秒)
acCnt: "00", //动作次数
acTotalCnt: "00", // 动作总次数
acCalorie: "", //卡路里
countdownT: "", // 倒计时
restHint: "", //休息文案
......@@ -23,19 +22,23 @@ export default {
maxHeartRate: "", //最高心率
rollbackStop: "", //切出回来时候,是否需要暂停 "0":暂停 "0以外":切出训练
newHeartRate: "--", //当前心率
isStop: false, //是否暂停
isStop: false, //是否是手表端暂停
sendFlg: false, // 是否在发送消息
stopFlg: false, //是否暂停
tabIndex: 0, //滑动index
isPhoneLeave: false, //手机端离开状态
isEnd: false, //是否完成
lastPage: "", //上个页面标识
isReceiveStartMessage: false, //启动时收到手机端给的回复消息
isJumpLoginPage: true, //是否跳转到未登录提示页
dataPageShow: false, //训练数据页面是否显示
canReceiveMessage: true, //是否可以接收手机端其他事件(手表端主动暂停或训练结束后,不再接收除17外的其他事件)
installText: "请在手机上下载\nFit App",
},
onReady() {
let _this = this;
//数据重置
_this.restore();
//ping手机端状态
// _this.ping();
//获取客户端信息
_this.getMsg();
//发送个启动事件
......@@ -44,7 +47,7 @@ export default {
});
//关闭启动页
setTimeout(function () {
if (!_this.isReceiveStartMessage) {
if (_this.isJumpLoginPage) {
_this.page = "12";
}
},1500);
......@@ -66,12 +69,19 @@ export default {
let _this = this;
let model = msg.acModel;
//手表端主动关闭训练后,不接收除17外的初始化事件,
if (msg.eventFlg == "17") {
_this.canReceiveMessage = true;
}
if (!_this.canReceiveMessage) {
return;
}
//接到手机端消息时(去掉17初始化的事件),启动页显示完后,不显示提示登录页面page 12
if (msg.eventFlg != "") {
if (msg.eventFlg == "17") {
_this.page = "11";
}
_this.isReceiveStartMessage = true;
_this.isJumpLoginPage = false;
}
if (_this.sendFlg) {
return false;
......@@ -82,7 +92,7 @@ export default {
_this.isStop = false;
//手机端主动离开事件,等待0.5秒后再处理其他事件
if (_this.isPhoneLeave) {
if (_this.isPhoneLeave && msg.eventFlg != "10") {
return
}
if (msg.eventFlg == "15" && model.rollbackStop != '0') {
......@@ -97,6 +107,17 @@ export default {
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) {
case "0": //训练准备
_this.page = "0";
......@@ -114,6 +135,8 @@ export default {
_this.acName = model.acName;
_this.isLast = model.isLast;
_this.isFirst = model.isFirst;
_this.tabIndex = 0;
_this.stopFlg = false;
break;
case "3": //动作预览
_this.page = "3";
......@@ -127,11 +150,11 @@ export default {
case "5": //训练动作倒计时
_this.page = "5";
_this.acName = model.acName;
_this.countdownT = model.countdownT == "-1" ? "0" : model.countdownT;
_this.acType = model.acType;
if (model.acType == "0") {
_this.acCnt = model.acCnt;
_this.acTotalCnt = model.acTotalCnt;
_this.countdownT = model.acCnt + "/" + model.acTotalCnt;
} else {
_this.countdownT = model.countdownT;
}
break;
case "6": //休息中
......@@ -141,6 +164,7 @@ export default {
_this.acType = 1;
break;
case "7": //暂停
_this.page = "7";
_this.tabIndex = 1;
_this.stopFlg = true;
break;
......@@ -151,24 +175,25 @@ export default {
break;
case "9": //完成训练
_this.vibrate();
_this.canReceiveMessage = false;
_this.isEnd = true;
_this.page = "9";
_this.fitTotalDuration = model.fitTotalDuration;
_this.averHeartRate = _this.getAverHeartRate(_this.heartRateList); //平均心率
_this.maxHeartRate = _this.getMaxHeartRatet(_this.heartRateList); //最高心率
_this.acCalorie = model.acCalorie;
this.quit();
_this.quit();
break;
case "10": //退出训练
_this.page = "10";
this.quit();
_this.quit();
break;
case "11": //登录中
_this.page = "11"
break;
case "12": //退出登录
_this.page = "12";
this.quit();
_this.quit();
break;
case "13": //进度条
_this.progress = ((model.acProgress / model.maxProgress) * 350);
......@@ -178,19 +203,12 @@ export default {
_this.fitDuration = model.fitDuration;
break;
case "15": //离开或者返回训练
if (model.rollbackStop == '0') {
if (_this.lastPage != "") {
_this.page = _this.lastPage;
}
} else {
_this.lastPage = _this.page;
_this.page = "15"
}
this.quit();
_this.page = "15";
_this.quit();
break;
case "16": //杀掉进程
_this.page = "12";
this.quit();
_this.quit();
break;
case "17": //播放初始化、注册心率
//获取心率
......@@ -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 {
let _this = this;
FeatureAbility.subscribeMsg({
success: function (data) {
// _this.sendErrMsg(data.message,"手表端接收到消息数据:");
_this.start(JSON.parse(data.message));
},
fail: function (data, code) {
......@@ -361,6 +413,8 @@ export default {
*关闭
*/
close() {
this.canReceiveMessage = false;
this.page = "10";
this.sendMsg({
"eventFlg": "5",
});
......@@ -410,8 +464,8 @@ export default {
*数据重置
*/
restore() {
this.lastPage = "";
this.isStop = false;
this.canReceiveMessage = true;
this.sendFlg = false;
this.stopFlg = false;
this.heartRateList = [];
......@@ -438,5 +492,13 @@ export default {
*/
end() {
this.page = '10';
},
/*
*swiper滑动
*/
swiperChange(index) {
console.info(index);
this.tabIndex = index.index;
}
}
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