Commit b9ad6fe2 authored by Sky's avatar Sky

ide升级配置修改

parent 1e7f4b7b
// Top-level build file where you can add configuration options common to all sub-projects/modules. // Top-level build file where you can add configuration options common to all sub-projects/modules.
apply plugin: 'com.huawei.harmony.app' apply plugin: 'com.huawei.ohos.app'
harmonyos { ohos {
signingConfigs { signingConfigs {
release { release {
signAlg 'SHA256withECDSA' signAlg 'SHA256withECDSA'
} }
} }
compileSdkVersion 1 compileSdkVersion 3
defaultConfig { defaultConfig {
compatibleSdkVersion 1 compatibleSdkVersion 3
} }
} }
buildscript { buildscript {
repositories { repositories {
maven { maven {
url uri('E:\\HarmonyOS\\plugin') url 'https://mirrors.huaweicloud.com/repository/maven/'
} }
maven { maven {
url 'https://mirrors.huaweicloud.com/repository/maven/' url 'https://developer.huawei.com/repo/'
} }
jcenter() jcenter()
} }
dependencies { dependencies {
classpath 'com.huawei.harmony:hap:1.0.7.4' classpath 'com.huawei.ohos:hap:2.0.0.6'
} }
} }
...@@ -32,10 +32,10 @@ buildscript { ...@@ -32,10 +32,10 @@ buildscript {
allprojects { allprojects {
repositories { repositories {
maven { maven {
url uri('E:\\HarmonyOS\\plugin') url 'https://mirrors.huaweicloud.com/repository/maven/'
} }
maven { maven {
url 'https://mirrors.huaweicloud.com/repository/maven/' url 'https://developer.huawei.com/repo/'
} }
jcenter() jcenter()
} }
......
{
"profile": {
"package": "com.company.fit",
"version-code": 1,
"version-name": "1.0.0",
"uses-sdk": {
"min-version": "zsdk 1.0.0"
},
"distro": {
"delivery-with-install": true,
"module-name": "entry",
"module-type": "entry"
},
"application": {
"label": "Fit",
"icon": "res/drawable",
"abilities": [
{
"name": "default",
"label": "Fit"
}
],
"js": [
{
"name": "default",
"pages": [
"pages/index/index"
]
}
]
}
}
}
\ No newline at end of file
apply plugin: 'com.huawei.harmony.hap' apply plugin: 'com.huawei.ohos.hap'
harmonyos { ohos {
signingConfigs { signingConfigs {
debug { debug {
certpath file('D:/HuaweiWatchClient/fitjs_certificate.cer') certpath file('D:/HuaweiWatchClient/fitjs_certificate.cer')
...@@ -12,9 +12,9 @@ harmonyos { ...@@ -12,9 +12,9 @@ harmonyos {
storeFile file('D:/HuaweiWatchClient/huawei_watch.jks') storeFile file('D:/HuaweiWatchClient/huawei_watch.jks')
} }
} }
compileSdkVersion 1 compileSdkVersion 3
defaultConfig { defaultConfig {
compatibleSdkVersion 1 compatibleSdkVersion 3
} }
} }
sourceSets{ sourceSets{
......
...@@ -4,19 +4,16 @@ ...@@ -4,19 +4,16 @@
"version": { "version": {
"code": 1, "code": 1,
"name": "1.0.0" "name": "1.0.0"
}
}, },
"deviceConfig": { "apiVersion": {
"default": { "compatible": 3,
"reqSdk": { "target": 3
"compatible": "zsdk 1.0.0",
"target": "zsdk 1.0.0"
}
} }
}, },
"deviceConfig": {},
"module": { "module": {
"deviceType": [ "deviceType": [
"fitnessWatch" "liteWearable"
], ],
"abilities": [ "abilities": [
{ {
......
<div class="container"> <div class="container" onswipe="touchMove">
<!--启动页面--> <!--启动页面-->
<image class="logo" if="!page" src="../../common/default_img.png"></image> <image class="logo" if="!page" src="../../common/default_img.png"></image>
<!--启动页面--> <!--启动页面-->
...@@ -174,8 +174,6 @@ ...@@ -174,8 +174,6 @@
<div class="train-out-text-box"> <div class="train-out-text-box">
<text class="train-out-text"> <text class="train-out-text">
在手机上开启你 在手机上开启你
</text>
<text class="train-out-text">
今天的训练 今天的训练
</text> </text>
</div> </div>
......
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' import app from '@system.app' //右滑退出
var timer; var timer;
export default { export default {
...@@ -15,7 +16,7 @@ export default { ...@@ -15,7 +16,7 @@ export default {
restHint: "", //休息文案 restHint: "", //休息文案
isLast: "", //是否第一个动作 "0":真 "1":假 isLast: "", //是否第一个动作 "0":真 "1":假
isFirst: "", // 是否最后一个动作 "0":真 "1":假 isFirst: "", // 是否最后一个动作 "0":真 "1":假
fitDuration: "", //训练持续时长 fitDuration: "00:00", //训练持续时长
fitTotalDuration: "", //训练时长-用于训练完成界面 fitTotalDuration: "", //训练时长-用于训练完成界面
heartRateList: [], //心率数组 heartRateList: [], //心率数组
averHeartRate: "", //平均心率 averHeartRate: "", //平均心率
...@@ -28,10 +29,11 @@ export default { ...@@ -28,10 +29,11 @@ export default {
tabIndex: 0, //滑动index tabIndex: 0, //滑动index
isPhoneLeave: false, //手机端离开状态 isPhoneLeave: false, //手机端离开状态
isEnd: false, //是否完成 isEnd: false, //是否完成
lastPage: "", //手机端离开训练页面时的页面paeg
isJumpLoginPage: true, //是否跳转到未登录提示页 isJumpLoginPage: true, //是否跳转到未登录提示页
dataPageShow: false, //训练数据页面是否显示 dataPageShow: false, //训练数据页面是否显示
canReceiveMessage: true, //是否可以接收手机端其他事件(手表端主动暂停或训练结束后,不再接收除17外的其他事件) canReceiveMessage: true, //是否可以接收手机端其他事件(手表端主动暂停或训练结束后,不再接收除17外的其他事件)
installText: "", isFirstInit: true, //是否是第一次初始化事件
}, },
onReady() { onReady() {
let _this = this; let _this = this;
...@@ -55,10 +57,10 @@ export default { ...@@ -55,10 +57,10 @@ export default {
onShow() { onShow() {
let _this = this; let _this = this;
//保持屏幕常亮 //保持屏幕常亮
this.keepScreenOn(); _this.keepScreenOn();
timer = setInterval(function () { timer = setInterval(function () {
_this.keepScreenOn(); _this.keepScreenOn();
},4 * 60 * 1000); },3 * 60 * 1000);
}, },
onDestroy() { onDestroy() {
//发送页面销毁时间 //发送页面销毁时间
...@@ -75,35 +77,64 @@ export default { ...@@ -75,35 +77,64 @@ export default {
//手表端主动关闭训练后,不接收除17外的初始化事件, //手表端主动关闭训练后,不接收除17外的初始化事件,
if (msg.eventFlg == "17") { if (msg.eventFlg == "17") {
//数据重置
_this.init();
_this.canReceiveMessage = true; _this.canReceiveMessage = true;
if (_this.isFirstInit) {
_this.isFirstInit = false;
_this.page = "11";
}
} }
if (!_this.canReceiveMessage) { if (!_this.canReceiveMessage) {
return; return;
} }
//接到手机端消息时(去掉17初始化的事件),启动页显示完后,不显示提示登录页面page 12 //接到手机端消息时(去掉17初始化的事件),启动页显示完后,不显示提示登录页面page 12
if (msg.eventFlg != "") { if (msg.eventFlg != "") {
if (msg.eventFlg == "17") {
_this.page = "11";
}
_this.isJumpLoginPage = false; _this.isJumpLoginPage = false;
} }
//手表端正在发送消息,不处理事件
if (_this.sendFlg) { if (_this.sendFlg) {
return false; return false;
} }
//手表端主动暂停的场合,只接受手机端此次返回的暂停事件,防止显示错乱
if (_this.isStop && msg.eventFlg != "7") { if (_this.isStop && msg.eventFlg != "7") {
return false; return false;
} }
_this.isStop = false; _this.isStop = false;
//手机端主动离开事件,等待0.5秒后再处理其他事件 //手机端主动离开训练页面标识,只接受手机端返回事件或者应用退出事件(手机端返回训练页面时,应该还是暂停状态,手表端状态同步)
if (_this.isPhoneLeave && msg.eventFlg != "10") { if (_this.isPhoneLeave) {
//只处理返回训练页面、退出训练、杀进程事件
//1事件是手机端点击左上角关闭按钮,再继续训练的场合
if (msg.eventFlg != "16" && msg.eventFlg != "15" && msg.eventFlg != "10" && msg.eventFlg != "1") {
return return
} }
_this.isPhoneLeave = false;
}
//手机端返回训练页面
if (msg.eventFlg == "15" && model.rollbackStop == '0') {
//获取心率
_this.getHeartRate();
//还原暂停状态页面
if (!_this.dataPageShow) {
_this.dataPageShow = true;
}
_this.tabIndex = 1;
_this.stopFlg = true;
//训练数据页面显示的实际数据
if (_this.lastPage != "") { //有可能是手机离开页面的15事件,手表端没有收到,所以导致lastpage没有值,这时候按训练中的页面算
_this.page = _this.lastPage;
}
if (_this.page != "3" && _this.page != "4" && _this.page != "5" && _this.page != "6" && _this.page != "7" && _this.page != "8") { //其他场合,全都重置页面page
_this.page = "2";
_this.acName = "";
}
_this.lastPage = "";
return;
}
//手机端离开训练页面,添加标识
if (msg.eventFlg == "15" && model.rollbackStop != '0') { if (msg.eventFlg == "15" && model.rollbackStop != '0') {
_this.isPhoneLeave = true; _this.isPhoneLeave = true;
setTimeout(function () {
_this.isPhoneLeave = false;
},500)
} }
//完成训练停止接受10、15事件 //完成训练停止接受10、15事件
if (_this.isEnd) { if (_this.isEnd) {
...@@ -127,31 +158,30 @@ export default { ...@@ -127,31 +158,30 @@ export default {
_this.page = "0"; _this.page = "0";
break; break;
case "1": //训练准备后的倒计时 case "1": //训练准备后的倒计时
_this.page = "1";
_this.countdownT = model.countdownT; _this.countdownT = model.countdownT;
_this.isEnd = false; _this.isEnd = false;
_this.stopFlg = false; _this.stopFlg = false;
_this.page = "1";
break; break;
case "2": //动作名称 case "2": //动作名称
_this.vibrate(); _this.vibrate();
_this.page = "2";
_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.tabIndex = 0;
_this.stopFlg = false; _this.stopFlg = false;
_this.page = "2";
break; break;
case "3": //动作预览 case "3": //动作预览
_this.page = "3";
_this.acName = model.acName; _this.acName = model.acName;
_this.page = "3";
break; break;
case "4": //动作预览倒计时 case "4": //动作预览倒计时
_this.page = "4";
_this.acName = model.acName; _this.acName = model.acName;
_this.countdownT = model.countdownT; _this.countdownT = model.countdownT;
_this.page = "4";
break; break;
case "5": //训练动作倒计时 case "5": //训练动作倒计时
_this.page = "5";
_this.acName = model.acName; _this.acName = model.acName;
_this.acType = model.acType; _this.acType = model.acType;
if (model.acType == "0") { if (model.acType == "0") {
...@@ -159,20 +189,23 @@ export default { ...@@ -159,20 +189,23 @@ export default {
} else { } else {
_this.countdownT = model.countdownT; _this.countdownT = model.countdownT;
} }
_this.page = "5";
break; break;
case "6": //休息中 case "6": //休息中
_this.page = "6";
_this.acName = model.acName; _this.acName = model.acName;
_this.countdownT = model.countdownT; _this.countdownT = model.countdownT;
_this.acType = 1; _this.acType = 1;
_this.page = "6";
break; break;
case "7": //暂停 case "7": //暂停
_this.page = "7";
_this.tabIndex = 1; _this.tabIndex = 1;
_this.stopFlg = true; _this.stopFlg = true;
//如果暂停的时候,正在准备开始训练或倒计时的场合,需要隐藏这个页面
if (_this.page == "0" || _this.page == "1") {
_this.page = "2";
}
break; break;
case "8": //继续 case "8": //继续
_this.tabIndex = 0;
_this.countdownT = model.countdownT; _this.countdownT = model.countdownT;
_this.stopFlg = false; _this.stopFlg = false;
break; break;
...@@ -180,19 +213,19 @@ export default { ...@@ -180,19 +213,19 @@ export default {
_this.vibrate(); _this.vibrate();
_this.canReceiveMessage = false; _this.canReceiveMessage = false;
_this.isEnd = true; _this.isEnd = true;
_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();
_this.page = "9";
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";
...@@ -206,11 +239,12 @@ export default { ...@@ -206,11 +239,12 @@ export default {
_this.fitDuration = model.fitDuration; _this.fitDuration = model.fitDuration;
break; break;
case "15": //离开或者返回训练 case "15": //离开或者返回训练
_this.page = "15";
if (model.rollbackStop == '0') { if (model.rollbackStop == '0') {
//获取心率 //获取心率
_this.getHeartRate(); _this.getHeartRate();
} else { } else {
_this.lastPage = _this.page;
_this.page = "15";
//移除心率监听 //移除心率监听
sensor.unsubscribeHeartRate() //取消监听心率 sensor.unsubscribeHeartRate() //取消监听心率
} }
...@@ -226,40 +260,6 @@ export default { ...@@ -226,40 +260,6 @@ 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";
// _this.installText = "请在手机上下载\nFit App";
// }
// console.log(resultCode.data + resultCode.code);
// },
// });
// },
/** /**
发送短消息给客户端 发送短消息给客户端
*/ */
...@@ -279,9 +279,45 @@ export default { ...@@ -279,9 +279,45 @@ export default {
console.log('handing fail, message: ' + data + ', code: ' + code); console.log('handing fail, message: ' + data + ', code: ' + code);
} }
}); });
},
/**
发送心率消息
*/
sendHeartRateMsg(obj) {
let _this = this;
FeatureAbility.sendMsg({
deviceId: 'remote',
bundleName: 'com.sportq.fit',
message: JSON.stringify(obj),
success: function () {
console.log('sendMsg success.');
},
fail: function (data, code) {
console.log('handing fail, message: ' + data + ', code: ' + code);
} }
});
},
, /**
* 把错误信息发送至客户端
*/
sendErrMsg(data, code) {
FeatureAbility.sendMsg({
deviceId: 'remote',
bundleName: 'com.sportq.fit',
message: JSON.stringify({
"errData": data,
"errCode": code,
}),
success: function () {
console.log('sendErrMsg success.');
},
fail: function (data, code) {
console.log('handing fail, message: ' + data + ', code: ' + code);
}
});
},
/** /**
*保持屏幕常亮 *保持屏幕常亮
...@@ -290,10 +326,8 @@ export default { ...@@ -290,10 +326,8 @@ export default {
brightness.setKeepScreenOn({ brightness.setKeepScreenOn({
keepScreenOn: true, keepScreenOn: true,
success: function () { success: function () {
console.log("handling set keep screen on success")
}, },
fail: function (data, code) { fail: function (data, code) {
console.log("handling set keep screen on fail, code:" + code);
} }
}) })
} }
...@@ -310,29 +344,6 @@ export default { ...@@ -310,29 +344,6 @@ export default {
_this.start(JSON.parse(data.message)); _this.start(JSON.parse(data.message));
}, },
fail: function (data, code) { fail: function (data, code) {
console.log('handing fail, message: ' + data + ', code: ' + code);
}
});
}
,
/**
* 把错误信息发送至客户端
*/
sendErrMsg(data, code) {
FeatureAbility.sendMsg({
deviceId: 'remote',
bundleName: 'com.sportq.fit',
message: JSON.stringify({
"errData": data,
"errCode": code,
}),
success: function () {
console.log('sendErrMsg success.');
},
fail: function (data, code) {
console.log('handing fail, message: ' + data + ', code: ' + code);
} }
}); });
} }
...@@ -348,19 +359,16 @@ export default { ...@@ -348,19 +359,16 @@ export default {
if (data.heartRate != 255) { if (data.heartRate != 255) {
_this.newHeartRate = data.heartRate; _this.newHeartRate = data.heartRate;
_this.heartRateList.push(data.heartRate); _this.heartRateList.push(data.heartRate);
console.log('获取心率成功: ' + data.heartRate);
} else { } else {
_this.newHeartRate = "--"; _this.newHeartRate = "--";
} }
_this.sendMsg({ _this.sendHeartRateMsg({
"eventFlg": "0", "eventFlg": "0",
"rateCnt": _this.newHeartRate "rateCnt": _this.newHeartRate
}); });
}, },
fail: function (data, code) { fail: function (data, code) {
_this.newHeartRate = "--"; _this.newHeartRate = "--";
console.log('获取心率失败: ' + data);
_this.sendErrMsg(data,code)
} }
}) })
} }
...@@ -370,6 +378,7 @@ export default { ...@@ -370,6 +378,7 @@ export default {
*计算平均心率 *计算平均心率
*/ */
getAverHeartRate(arr) { getAverHeartRate(arr) {
if (arr.length > 0) {
//将array的长度赋给len //将array的长度赋给len
let len = arr.length; let len = arr.length;
let sum = 0; let sum = 0;
...@@ -379,6 +388,9 @@ export default { ...@@ -379,6 +388,9 @@ export default {
} }
//返回数组的和与长度求平均值 //返回数组的和与长度求平均值
return parseInt(sum / len); return parseInt(sum / len);
} else {
return "--"
}
} }
, ,
...@@ -386,11 +398,15 @@ export default { ...@@ -386,11 +398,15 @@ export default {
*获取最大心率 *获取最大心率
*/ */
getMaxHeartRatet(arr) { getMaxHeartRatet(arr) {
if (arr.length > 0) {
let max = arr[0]; let max = arr[0];
for (let i = 0; i < arr.length - 1; i++) { for (let i = 0; i < arr.length - 1; i++) {
max = max < arr[i + 1] ? arr[i + 1] : arr max = max < arr[i + 1] ? arr[i + 1] : arr
} }
return parseInt(max) return parseInt(max)
} else {
return "--"
}
} }
, ,
...@@ -424,6 +440,7 @@ export default { ...@@ -424,6 +440,7 @@ export default {
*/ */
close() { close() {
this.canReceiveMessage = false; this.canReceiveMessage = false;
this.dataPageShow = false;
this.page = "10"; this.page = "10";
this.sendMsg({ this.sendMsg({
"eventFlg": "5", "eventFlg": "5",
...@@ -460,13 +477,11 @@ export default { ...@@ -460,13 +477,11 @@ export default {
vibrator.vibrate({ vibrator.vibrate({
mode: "short", mode: "short",
success() { success() {
console.log("success to vibrate");
}, },
fail(data, code) { fail(data, code) {
console.log(`handle fail, data = ${data}, code = ${code}`);
} }
}); });
} },
, ,
...@@ -474,17 +489,35 @@ export default { ...@@ -474,17 +489,35 @@ export default {
*数据重置 *数据重置
*/ */
restore() { restore() {
this.isFirstInit = true;
this.isStop = false; this.isStop = false;
this.canReceiveMessage = true; this.canReceiveMessage = true;
this.sendFlg = false; this.sendFlg = false;
this.stopFlg = false; this.stopFlg = false;
this.isLast = "", //是否第一个动作 "0":真 "1":假
this.isFirst = "", // 是否最后一个动作 "0":真 "1":假
this.acName = "";
this.fitDuration = "00:00";
this.progress = "", //进度条
this.countdownT = "", // 倒计时
this.heartRateList = []; this.heartRateList = [];
//取消接收手机侧第三方应用发过来的消息 //取消接收手机侧第三方应用发过来的消息
FeatureAbility.unsubscribeMsg(); FeatureAbility.unsubscribeMsg();
sensor.unsubscribeHeartRate() //取消监听心率 sensor.unsubscribeHeartRate() //取消监听心率
} },
/**
*数据重置
*/
init() {
this.isStop = false;
this.sendFlg = false;
this.stopFlg = false;
this.isEnd = false;
this.isPhoneLeave = false;
},
,
/** /**
*退出训练 *退出训练
*/ */
...@@ -492,6 +525,13 @@ export default { ...@@ -492,6 +525,13 @@ export default {
this.isStop = false; this.isStop = false;
this.sendFlg = false; this.sendFlg = false;
this.stopFlg = false; this.stopFlg = false;
this.isLast = "", //是否第一个动作 "0":真 "1":假
this.isFirst = "", // 是否最后一个动作 "0":真 "1":假
this.acName = "";
this.fitDuration = "00:00";
this.progress = "", //进度条
this.countdownT = "", // 倒计时
this.newHeartRate = "--", //当前心率
this.heartRateList = []; this.heartRateList = [];
sensor.unsubscribeHeartRate() //取消监听心率 sensor.unsubscribeHeartRate() //取消监听心率
if (timer != null) { if (timer != null) {
...@@ -507,11 +547,20 @@ export default { ...@@ -507,11 +547,20 @@ export default {
this.page = '10'; this.page = '10';
}, },
/* /**
*swiper滑动 *swiper滑动
*/ */
swiperChange(index) { swiperChange(index) {
console.info(index); console.info(index);
this.tabIndex = index.index; this.tabIndex = index.index;
},
/**
*右滑退出
*/
touchMove: function (e) {
if (e.direction == "right") {
app.terminate();
}
} }
} }
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