|
@@ -57,6 +57,9 @@
|
|
|
<em>心率带未连接</em>
|
|
<em>心率带未连接</em>
|
|
|
<button>点击连接</button>
|
|
<button>点击连接</button>
|
|
|
</div>
|
|
</div>
|
|
|
|
|
+ <div class="classInfo" v-if="InClass == 1">
|
|
|
|
|
+ <em><span>课程名称</span>:{{DpName}}</em>
|
|
|
|
|
+ </div>
|
|
|
</div>
|
|
</div>
|
|
|
<div class="middle">
|
|
<div class="middle">
|
|
|
<ul>
|
|
<ul>
|
|
@@ -124,6 +127,9 @@
|
|
|
import LineExample from '../components/LineExample'
|
|
import LineExample from '../components/LineExample'
|
|
|
import {
|
|
import {
|
|
|
UserSelfQuery,
|
|
UserSelfQuery,
|
|
|
|
|
+ GetDuInfoAndUserInfoByUserMd5,
|
|
|
|
|
+ HrSensorsUpdate,
|
|
|
|
|
+ AddAppHeartRate,
|
|
|
} from '../api/getApiRes.js'
|
|
} from '../api/getApiRes.js'
|
|
|
|
|
|
|
|
let qs = require('qs');
|
|
let qs = require('qs');
|
|
@@ -156,17 +162,31 @@
|
|
|
cal: 0,
|
|
cal: 0,
|
|
|
sportCal: 0,
|
|
sportCal: 0,
|
|
|
ck: 0,
|
|
ck: 0,
|
|
|
|
|
+ addCalories: 0,//增量卡路里
|
|
|
|
|
+ addPureCalories: 0,//增量运动卡路里
|
|
|
screenWidth: parseInt(document.body.clientWidth - 10),
|
|
screenWidth: parseInt(document.body.clientWidth - 10),
|
|
|
screenHeight: parseInt(document.documentElement.clientHeight / 3),
|
|
screenHeight: parseInt(document.documentElement.clientHeight / 3),
|
|
|
watchs: [],
|
|
watchs: [],
|
|
|
begin: null,
|
|
begin: null,
|
|
|
heartLine: [],
|
|
heartLine: [],
|
|
|
dataLabels: [],
|
|
dataLabels: [],
|
|
|
|
|
+ InClass: 0,//是否上课
|
|
|
|
|
+ DpName: '1234',//课程名称
|
|
|
|
|
+ HrId: '',//心率带
|
|
|
|
|
+ duId:'',
|
|
|
|
|
+ sn:'',
|
|
|
}
|
|
}
|
|
|
},
|
|
},
|
|
|
mounted() {
|
|
mounted() {
|
|
|
this.getBodyInfo();
|
|
this.getBodyInfo();
|
|
|
this.init();
|
|
this.init();
|
|
|
|
|
+ clearInterval(this.timer);
|
|
|
|
|
+ this.timer = setInterval(() => {
|
|
|
|
|
+ this.isClass();
|
|
|
|
|
+ }, 3000);
|
|
|
|
|
+ },
|
|
|
|
|
+ beforeDestroy() {
|
|
|
|
|
+ clearInterval(this.timer);
|
|
|
},
|
|
},
|
|
|
watch: {
|
|
watch: {
|
|
|
activeLevel(val) {
|
|
activeLevel(val) {
|
|
@@ -197,7 +217,7 @@
|
|
|
that.activeLevelText = '峰值锻炼';
|
|
that.activeLevelText = '峰值锻炼';
|
|
|
break;
|
|
break;
|
|
|
}
|
|
}
|
|
|
- }
|
|
|
|
|
|
|
+ },
|
|
|
},
|
|
},
|
|
|
methods: {
|
|
methods: {
|
|
|
init() {
|
|
init() {
|
|
@@ -205,7 +225,6 @@
|
|
|
// 页面初始化操作
|
|
// 页面初始化操作
|
|
|
document.addEventListener('plusready', function (e) {
|
|
document.addEventListener('plusready', function (e) {
|
|
|
plus.bluetooth.onBLECharacteristicValueChange(function (e) {
|
|
plus.bluetooth.onBLECharacteristicValueChange(function (e) {
|
|
|
- console.log(e.characteristicId);
|
|
|
|
|
if (e.characteristicId == '00002A19-0000-1000-8000-00805F9B34FB') {
|
|
if (e.characteristicId == '00002A19-0000-1000-8000-00805F9B34FB') {
|
|
|
// 获取电量
|
|
// 获取电量
|
|
|
var value = that.buffer2hexPower(e.value);
|
|
var value = that.buffer2hexPower(e.value);
|
|
@@ -229,11 +248,37 @@
|
|
|
that.dataLabels.push('');
|
|
that.dataLabels.push('');
|
|
|
}
|
|
}
|
|
|
that.DrawHeartLine(that.heartLine, that.dataLabels);
|
|
that.DrawHeartLine(that.heartLine, that.dataLabels);
|
|
|
- // that.reportInfo();
|
|
|
|
|
|
|
+ // that.AutoAddAppHeartRate();
|
|
|
}
|
|
}
|
|
|
});
|
|
});
|
|
|
});
|
|
});
|
|
|
},
|
|
},
|
|
|
|
|
+ // 是否正在上课
|
|
|
|
|
+ isClass() {
|
|
|
|
|
+ let that = this;
|
|
|
|
|
+ let param = {
|
|
|
|
|
+ token: localStorage.token,
|
|
|
|
|
+ };
|
|
|
|
|
+ let postdata = qs.stringify(param);
|
|
|
|
|
+ GetDuInfoAndUserInfoByUserMd5(postdata).then(res => {
|
|
|
|
|
+ let json = res;
|
|
|
|
|
+ if (json.Code == 0) {
|
|
|
|
|
+ that.InClass = json.InClass;//0下课,1上课
|
|
|
|
|
+ if (that.InClass == 1) {
|
|
|
|
|
+ // 记录duid
|
|
|
|
|
+ that.duid = json.DuInfo.DuId;
|
|
|
|
|
+ // 上课就上报
|
|
|
|
|
+ that.AutoAddAppHeartRate();
|
|
|
|
|
+ } else {
|
|
|
|
|
+ // 不上课就不报
|
|
|
|
|
+ console.log('下课中,不汇报');
|
|
|
|
|
+ return false
|
|
|
|
|
+ }
|
|
|
|
|
+ } else {
|
|
|
|
|
+ that.$message.error(json.Memo);
|
|
|
|
|
+ }
|
|
|
|
|
+ })
|
|
|
|
|
+ },
|
|
|
buffer2hexPower(value) {
|
|
buffer2hexPower(value) {
|
|
|
var t = '';
|
|
var t = '';
|
|
|
if (value) {
|
|
if (value) {
|
|
@@ -298,6 +343,9 @@
|
|
|
plus.bluetooth.createBLEConnection({
|
|
plus.bluetooth.createBLEConnection({
|
|
|
deviceId: w.deviceId,
|
|
deviceId: w.deviceId,
|
|
|
success: function (e) {
|
|
success: function (e) {
|
|
|
|
|
+ // 记录心率带sn
|
|
|
|
|
+ that.sn = w.localName;
|
|
|
|
|
+ that.AddHrSensorsUpdate(w.localName);
|
|
|
that.Toast('连接成功!', 'success');
|
|
that.Toast('连接成功!', 'success');
|
|
|
// 渲染完毕再执行这个,所以才能没有延时的更改
|
|
// 渲染完毕再执行这个,所以才能没有延时的更改
|
|
|
// 需要一个回调等待5S
|
|
// 需要一个回调等待5S
|
|
@@ -417,7 +465,6 @@
|
|
|
},
|
|
},
|
|
|
// 获取基础身体数据
|
|
// 获取基础身体数据
|
|
|
getBodyInfo() {
|
|
getBodyInfo() {
|
|
|
- // todo
|
|
|
|
|
let that = this;
|
|
let that = this;
|
|
|
let param = {
|
|
let param = {
|
|
|
token: localStorage.token,
|
|
token: localStorage.token,
|
|
@@ -426,14 +473,28 @@
|
|
|
UserSelfQuery(postdata).then(res => {
|
|
UserSelfQuery(postdata).then(res => {
|
|
|
let json = res;
|
|
let json = res;
|
|
|
if (json.Code == 0) {
|
|
if (json.Code == 0) {
|
|
|
- that.username = json.Rs.username;
|
|
|
|
|
- that.sex = json.Rs.sex;
|
|
|
|
|
- that.height = json.Rs.height;
|
|
|
|
|
- that.age = json.Rs.age;
|
|
|
|
|
- that.weight = json.Rs.weight;
|
|
|
|
|
- that.peaceHeart = json.Rs.peaceHeart;
|
|
|
|
|
|
|
+ that.username = json.Rs.UserName;
|
|
|
|
|
+ that.sex = json.Rs.Sex;
|
|
|
|
|
+ that.height = json.Rs.Height;
|
|
|
|
|
+ // Birthday
|
|
|
|
|
+ let age = parseInt((new Date().getTime() - new Date(json.Rs.Birthday).getTime()) / (365 * 24 * 60 * 60 * 1000));
|
|
|
|
|
+ that.age = age;
|
|
|
|
|
+ that.weight = parseInt(json.Rs.Weight) / 10;
|
|
|
|
|
+ that.peaceHeart = json.Rs.StaticHr;
|
|
|
|
|
+ // 有无默认头像
|
|
|
|
|
+ if (json.Rs.Head) {
|
|
|
|
|
+ that.userHead = json.Rs.Head;
|
|
|
|
|
+ } else {
|
|
|
|
|
+ that.userHead = 'http://xhead.beswell.com/flyhead.png';
|
|
|
|
|
+ }
|
|
|
} else {
|
|
} else {
|
|
|
- that.$message.error(json.Memo);
|
|
|
|
|
|
|
+ if (json.Code == 9999999999) {
|
|
|
|
|
+ that.Toast('登陆已失效,请重新登陆');
|
|
|
|
|
+ localStorage.token = '';
|
|
|
|
|
+ this.$router.push({path: '/login'});
|
|
|
|
|
+ } else {
|
|
|
|
|
+ that.Toast(json.Memo, 'error');
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
})
|
|
})
|
|
|
}
|
|
}
|
|
@@ -476,14 +537,12 @@
|
|
|
calcActLevel(heartRate) {
|
|
calcActLevel(heartRate) {
|
|
|
let sum = 170 - this.age;
|
|
let sum = 170 - this.age;
|
|
|
this.activeLevel = parseInt((heartRate / sum) * 100);
|
|
this.activeLevel = parseInt((heartRate / sum) * 100);
|
|
|
- }
|
|
|
|
|
- ,
|
|
|
|
|
|
|
+ },
|
|
|
// 持续时间
|
|
// 持续时间
|
|
|
calcHoldTime(curTime) {
|
|
calcHoldTime(curTime) {
|
|
|
let res = parseInt(curTime.getTime() - this.begin.getTime()) / 1000;
|
|
let res = parseInt(curTime.getTime() - this.begin.getTime()) / 1000;
|
|
|
return parseInt(res)
|
|
return parseInt(res)
|
|
|
- }
|
|
|
|
|
- ,
|
|
|
|
|
|
|
+ },
|
|
|
// 计算卡路里
|
|
// 计算卡路里
|
|
|
calcCalorie(heartRate) {
|
|
calcCalorie(heartRate) {
|
|
|
let that = this;
|
|
let that = this;
|
|
@@ -496,39 +555,38 @@
|
|
|
} else {
|
|
} else {
|
|
|
calorieNoVo2 = ((-20.4022 + (0.4472 * heartRate) + (0.1263 * that.weight) + (0.074 * that.age)) / 4.184) / 60 * 1;
|
|
calorieNoVo2 = ((-20.4022 + (0.4472 * heartRate) + (0.1263 * that.weight) + (0.074 * that.age)) / 4.184) / 60 * 1;
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
|
|
+ // 记录增量卡路里
|
|
|
|
|
+ that.addCalories = calorieNoVo2;
|
|
|
that.cal = that.cal + calorieNoVo2;
|
|
that.cal = that.cal + calorieNoVo2;
|
|
|
// 计算CK
|
|
// 计算CK
|
|
|
that.calcCk(that.cal);
|
|
that.calcCk(that.cal);
|
|
|
that.calcSportCal(calorieNoVo2, curTime)
|
|
that.calcSportCal(calorieNoVo2, curTime)
|
|
|
- }
|
|
|
|
|
- ,
|
|
|
|
|
|
|
+ },
|
|
|
// 计算CK
|
|
// 计算CK
|
|
|
calcCk(cal) {
|
|
calcCk(cal) {
|
|
|
this.ck = parseFloat(cal / this.weight).toFixed(2);
|
|
this.ck = parseFloat(cal / this.weight).toFixed(2);
|
|
|
- }
|
|
|
|
|
- ,
|
|
|
|
|
|
|
+ },
|
|
|
// 计算运动卡路里
|
|
// 计算运动卡路里
|
|
|
calcSportCal(calorieNoVo2) {
|
|
calcSportCal(calorieNoVo2) {
|
|
|
let bmrMSjDaily = (10.00 * this.weight) + (6.25 * this.height) - (5.00 * this.age) + 5.00;
|
|
let bmrMSjDaily = (10.00 * this.weight) + (6.25 * this.height) - (5.00 * this.age) + 5.00;
|
|
|
let BmrMSjRmrcb = parseFloat((bmrMSjDaily * 1.1) / 24);
|
|
let BmrMSjRmrcb = parseFloat((bmrMSjDaily * 1.1) / 24);
|
|
|
let calorieNoVo2Pure = (calorieNoVo2 - BmrMSjRmrcb / 3600 * 1);
|
|
let calorieNoVo2Pure = (calorieNoVo2 - BmrMSjRmrcb / 3600 * 1);
|
|
|
|
|
+
|
|
|
|
|
+ // 记录增量运动卡路里
|
|
|
|
|
+ that.addPureCalories = calorieNoVo2Pure;
|
|
|
this.sportCal = this.sportCal + calorieNoVo2Pure;
|
|
this.sportCal = this.sportCal + calorieNoVo2Pure;
|
|
|
- }
|
|
|
|
|
- ,
|
|
|
|
|
|
|
+ },
|
|
|
// 绘制心电图
|
|
// 绘制心电图
|
|
|
DrawHeartLine(heartLine, dataLabels) {
|
|
DrawHeartLine(heartLine, dataLabels) {
|
|
|
this.dataLabels = dataLabels;
|
|
this.dataLabels = dataLabels;
|
|
|
this.dataDatasets = heartLine;
|
|
this.dataDatasets = heartLine;
|
|
|
this.calcMaxHr(heartLine);
|
|
this.calcMaxHr(heartLine);
|
|
|
this.calcAveHr(heartLine);
|
|
this.calcAveHr(heartLine);
|
|
|
- }
|
|
|
|
|
- ,
|
|
|
|
|
|
|
+ },
|
|
|
// 最大心率
|
|
// 最大心率
|
|
|
calcMaxHr(heartLine) {
|
|
calcMaxHr(heartLine) {
|
|
|
this.heartMax = Math.max(...heartLine);
|
|
this.heartMax = Math.max(...heartLine);
|
|
|
- }
|
|
|
|
|
- ,
|
|
|
|
|
|
|
+ },
|
|
|
// 平均心率
|
|
// 平均心率
|
|
|
calcAveHr(heartLine) {
|
|
calcAveHr(heartLine) {
|
|
|
var sum = 0;
|
|
var sum = 0;
|
|
@@ -538,19 +596,43 @@
|
|
|
this.heartAverage = parseInt(sum / heartLine.length);
|
|
this.heartAverage = parseInt(sum / heartLine.length);
|
|
|
},
|
|
},
|
|
|
// 上报信息
|
|
// 上报信息
|
|
|
- reportInfo() {
|
|
|
|
|
- // todo
|
|
|
|
|
|
|
+ AutoAddAppHeartRate() {
|
|
|
let that = this;
|
|
let that = this;
|
|
|
let param = {
|
|
let param = {
|
|
|
token: localStorage.token,
|
|
token: localStorage.token,
|
|
|
- regionid: regionid,
|
|
|
|
|
|
|
+ duId: that.duId,
|
|
|
|
|
+ sn: that.sn,
|
|
|
|
|
+ hrId: that.HrId,
|
|
|
|
|
+ heartRate: that.heartRate,
|
|
|
|
|
+ rcvTime: new Date().getTime(),
|
|
|
|
|
+ calories: that.addCalories,
|
|
|
|
|
+ pureCalories: that.addPureCalories,
|
|
|
};
|
|
};
|
|
|
let postdata = qs.stringify(param);
|
|
let postdata = qs.stringify(param);
|
|
|
- SchoolTimeQueryByDate(postdata).then(res => {
|
|
|
|
|
|
|
+ AddAppHeartRate(postdata).then(res => {
|
|
|
let json = res;
|
|
let json = res;
|
|
|
if (json.Code == 0) {
|
|
if (json.Code == 0) {
|
|
|
|
|
+ console.log('心率数据上传成功!');
|
|
|
} else {
|
|
} else {
|
|
|
- that.$message.error(json.Memo);
|
|
|
|
|
|
|
+ that.Toast(json.Memo);
|
|
|
|
|
+ }
|
|
|
|
|
+ })
|
|
|
|
|
+ },
|
|
|
|
|
+ AddHrSensorsUpdate(sn) {
|
|
|
|
|
+ let that = this;
|
|
|
|
|
+ let param = {
|
|
|
|
|
+ token: localStorage.token,
|
|
|
|
|
+ sn: sn,
|
|
|
|
|
+ };
|
|
|
|
|
+ let postdata = qs.stringify(param);
|
|
|
|
|
+ HrSensorsUpdate(postdata).then(res => {
|
|
|
|
|
+ let json = res;
|
|
|
|
|
+ if (json.Code == 0) {
|
|
|
|
|
+ that.HrId = json.HrId;
|
|
|
|
|
+ that.Toast('心率带已连接在线课程', 'success');
|
|
|
|
|
+ } else {
|
|
|
|
|
+ that.HrId = '';
|
|
|
|
|
+ that.Toast(json.Memo);
|
|
|
}
|
|
}
|
|
|
})
|
|
})
|
|
|
},
|
|
},
|
|
@@ -1098,4 +1180,17 @@
|
|
|
float: right;
|
|
float: right;
|
|
|
text-align: right;
|
|
text-align: right;
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ .classInfo {
|
|
|
|
|
+ width: 100%;
|
|
|
|
|
+ overflow: hidden;
|
|
|
|
|
+ display: block;
|
|
|
|
|
+ margin: 0 auto;
|
|
|
|
|
+ font-size: 16px;
|
|
|
|
|
+ text-align: center;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ .classInfo span {
|
|
|
|
|
+ font-size: 12px;
|
|
|
|
|
+ }
|
|
|
</style>
|
|
</style>
|