|
@@ -1,10 +1,13 @@
|
|
|
<template>
|
|
<template>
|
|
|
<view>
|
|
<view>
|
|
|
- <view style="height: 20px;"></view>
|
|
|
|
|
|
|
+ <view style="height: 20px;text-align: center;">
|
|
|
|
|
+ 心率区间120-150,超出区间每隔3秒钟语音报
|
|
|
|
|
+ </view>
|
|
|
<!-- <view>
|
|
<!-- <view>
|
|
|
<view class="title">Cocos预览地址:{{LocationGameUrl}}</view>
|
|
<view class="title">Cocos预览地址:{{LocationGameUrl}}</view>
|
|
|
<input class="uni-input" :value="LocationGameUrl" @input="onKeyInput" placeholder="输入cocos预览地址" />
|
|
<input class="uni-input" :value="LocationGameUrl" @input="onKeyInput" placeholder="输入cocos预览地址" />
|
|
|
</view> -->
|
|
</view> -->
|
|
|
|
|
+
|
|
|
<view class="card-view padding-top padding-bottom" v-for="(item,index) in devicesList" :key="index"
|
|
<view class="card-view padding-top padding-bottom" v-for="(item,index) in devicesList" :key="index"
|
|
|
:id="'task_'+index" :class="item.bRatio?'hardware-border':''" :style="{'z-index': threeZIndex}">
|
|
:id="'task_'+index" :class="item.bRatio?'hardware-border':''" :style="{'z-index': threeZIndex}">
|
|
|
<view class="flex justify-between align-center">
|
|
<view class="flex justify-between align-center">
|
|
@@ -35,22 +38,24 @@
|
|
|
<view v-if="currentItem" style="display: flex;flex-direction: row;">
|
|
<view v-if="currentItem" style="display: flex;flex-direction: row;">
|
|
|
<!-- <button style="margin: 10rpx;" type="primary" @click="writeBLEValue('H')">开启高速</button> -->
|
|
<!-- <button style="margin: 10rpx;" type="primary" @click="writeBLEValue('H')">开启高速</button> -->
|
|
|
<!-- <button style="margin: 10rpx;" type="primary" @click="writeBLEValue('h')">关闭高速</button> -->
|
|
<!-- <button style="margin: 10rpx;" type="primary" @click="writeBLEValue('h')">关闭高速</button> -->
|
|
|
- <!-- <button style="margin: 10rpx;" type="primary" @click="writeBLEValue('3')">开启</button>
|
|
|
|
|
|
|
+ <!-- <button style="margin: 10rpx;" type="primary" @click="writeBLEValue('3')">开启</button>
|
|
|
<button style="margin: 10rpx;" type="primary" @click="writeBLEValue('4')">关闭</button> -->
|
|
<button style="margin: 10rpx;" type="primary" @click="writeBLEValue('4')">关闭</button> -->
|
|
|
</view>
|
|
</view>
|
|
|
<scroll-view class="text-box" scroll-y="true">
|
|
<scroll-view class="text-box" scroll-y="true">
|
|
|
<scroll-view scroll-x="true">
|
|
<scroll-view scroll-x="true">
|
|
|
- <text selectable="true" style="background-color: greenyellow;">{{text}}</text>
|
|
|
|
|
|
|
+ <text selectable="true" style="background-color: greenyellow;">{{text}} \n {{nums}}</text>
|
|
|
</scroll-view>
|
|
</scroll-view>
|
|
|
</scroll-view>
|
|
</scroll-view>
|
|
|
|
|
|
|
|
<!-- <button style="margin-top: 2px;" type="warn" :disabled="!currentItem" @click="onShowGame">
|
|
<!-- <button style="margin-top: 2px;" type="warn" :disabled="!currentItem" @click="onShowGame">
|
|
|
显示游戏
|
|
显示游戏
|
|
|
</button> -->
|
|
</button> -->
|
|
|
- <button type="warn" :disabled="extraLine.length<=0" @click="remove">
|
|
|
|
|
|
|
+ <!-- <button type="warn" :disabled="extraLine.length<=0" @click="remove">
|
|
|
清除输入框数据
|
|
清除输入框数据
|
|
|
- </button>
|
|
|
|
|
-
|
|
|
|
|
|
|
+ </button> -->
|
|
|
|
|
+ <!-- <button @click="initTextToSpeech()">initTextToSpeech</button> -->
|
|
|
|
|
+ <!-- <button @click="playSpeak('当前心率123')">playSpeak</button> -->
|
|
|
|
|
+ <!-- <button @click="stopSpeak()">stopSpeak</button> -->
|
|
|
|
|
|
|
|
<!-- <button style="margin-top: 2px;" type="warn" @click="onEmit">
|
|
<!-- <button style="margin-top: 2px;" type="warn" @click="onEmit">
|
|
|
模拟发送
|
|
模拟发送
|
|
@@ -59,7 +64,17 @@
|
|
|
<!-- <button style="margin-top: 2px;" type="warn" @click="onClise">
|
|
<!-- <button style="margin-top: 2px;" type="warn" @click="onClise">
|
|
|
close
|
|
close
|
|
|
</button> -->
|
|
</button> -->
|
|
|
-
|
|
|
|
|
|
|
+ <view>
|
|
|
|
|
+ <button style="margin-top: 2px;" type="warn" @click="startTimer()">
|
|
|
|
|
+ 开始
|
|
|
|
|
+ </button>
|
|
|
|
|
+ <button style="margin-top: 2px;" type="warn" @click="pauseTime()">
|
|
|
|
|
+ 暂停
|
|
|
|
|
+ </button>
|
|
|
|
|
+ <button style="margin-top: 2px;" type="warn" @click="closeTimer()">
|
|
|
|
|
+ 清零
|
|
|
|
|
+ </button>
|
|
|
|
|
+ </view>
|
|
|
|
|
|
|
|
<!-- <view class="content">
|
|
<!-- <view class="content">
|
|
|
</view> -->
|
|
</view> -->
|
|
@@ -77,7 +92,8 @@
|
|
|
mapState,
|
|
mapState,
|
|
|
mapMutations
|
|
mapMutations
|
|
|
} from 'vuex';
|
|
} from 'vuex';
|
|
|
-
|
|
|
|
|
|
|
+ // 获取 module
|
|
|
|
|
+ var testModule = uni.requireNativePlugin("TestModule")
|
|
|
export default {
|
|
export default {
|
|
|
computed: mapState(['bOpenBluetooth', 'bOpenSuccess', 'bListenAdapterStateChange', 'bListenDeviceFound',
|
|
computed: mapState(['bOpenBluetooth', 'bOpenSuccess', 'bListenAdapterStateChange', 'bListenDeviceFound',
|
|
|
'BLEConnectDevice', 'BLEGetServices', 'cIndex', 'bConnection', 'bVerifiedConnection', 'BLEInfoList',
|
|
'BLEConnectDevice', 'BLEGetServices', 'cIndex', 'bConnection', 'bVerifiedConnection', 'BLEInfoList',
|
|
@@ -124,6 +140,21 @@
|
|
|
extraLine: [],
|
|
extraLine: [],
|
|
|
|
|
|
|
|
bShowGame: false,
|
|
bShowGame: false,
|
|
|
|
|
+
|
|
|
|
|
+ bPlayText: false,
|
|
|
|
|
+ playTime: 0,
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 计时器部分
|
|
|
|
|
+ */
|
|
|
|
|
+ timer: null,
|
|
|
|
|
+ nums: '',
|
|
|
|
|
+ bTimerPlay: false,
|
|
|
|
|
+ bTimerpause: false,
|
|
|
|
|
+ hour: 0,
|
|
|
|
|
+ minute: 0,
|
|
|
|
|
+ second: 0,
|
|
|
|
|
+ millisecond: 0
|
|
|
}
|
|
}
|
|
|
},
|
|
},
|
|
|
onLoad(op) {
|
|
onLoad(op) {
|
|
@@ -131,7 +162,7 @@
|
|
|
uni.$on('retryConnectBLESuccess', this.onRetryConnectBLESuccess);
|
|
uni.$on('retryConnectBLESuccess', this.onRetryConnectBLESuccess);
|
|
|
uni.$on('callbackCloseBLE', this.hardCallbackCloseBLE);
|
|
uni.$on('callbackCloseBLE', this.hardCallbackCloseBLE);
|
|
|
uni.$on('listenerBLE', this.onListenerBLE);
|
|
uni.$on('listenerBLE', this.onListenerBLE);
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
this.BLEInfoList.forEach((item, index, selfarr) => {
|
|
this.BLEInfoList.forEach((item, index, selfarr) => {
|
|
|
if (item.usageMode == 'CL806' || item.usageMode == 'CL831') {
|
|
if (item.usageMode == 'CL806' || item.usageMode == 'CL831') {
|
|
|
let item = Object.assign({}, selfarr[index], {
|
|
let item = Object.assign({}, selfarr[index], {
|
|
@@ -149,6 +180,7 @@
|
|
|
this.onGetLocationGameUrl();
|
|
this.onGetLocationGameUrl();
|
|
|
uni.$on("log", this.add)
|
|
uni.$on("log", this.add)
|
|
|
|
|
|
|
|
|
|
+
|
|
|
},
|
|
},
|
|
|
onUnload() {
|
|
onUnload() {
|
|
|
uni.$off('retryConnectBLESuccess', this.onRetryConnectBLESuccess);
|
|
uni.$off('retryConnectBLESuccess', this.onRetryConnectBLESuccess);
|
|
@@ -156,19 +188,24 @@
|
|
|
uni.$off('listenerBLE', this.onListenerBLE);
|
|
uni.$off('listenerBLE', this.onListenerBLE);
|
|
|
//清除定时器
|
|
//清除定时器
|
|
|
this.onClearTimeout();
|
|
this.onClearTimeout();
|
|
|
- uni.$off("log", this.add)
|
|
|
|
|
|
|
+ uni.$off("log", this.add);
|
|
|
|
|
|
|
|
|
|
+ //停止语音
|
|
|
|
|
+ this.stopSpeak();
|
|
|
},
|
|
},
|
|
|
onShow() {
|
|
onShow() {
|
|
|
this.bShow = true;
|
|
this.bShow = true;
|
|
|
uni.$on('updateBLEDeviceData', this.callbackUpdateBLEData);
|
|
uni.$on('updateBLEDeviceData', this.callbackUpdateBLEData);
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
|
|
+ },
|
|
|
|
|
+ onReady() {
|
|
|
|
|
+ //初始化语音
|
|
|
|
|
+ this.initTextToSpeech();
|
|
|
},
|
|
},
|
|
|
- onReady() {},
|
|
|
|
|
onHide() {
|
|
onHide() {
|
|
|
//如果蓝牙弹出匹配框,会触发onHide。这时候处理蓝牙连接流程检测应等onShow 时候,再检测
|
|
//如果蓝牙弹出匹配框,会触发onHide。这时候处理蓝牙连接流程检测应等onShow 时候,再检测
|
|
|
this.bShow = false;
|
|
this.bShow = false;
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
uni.$off('updateBLEDeviceData', this.callbackUpdateBLEData);
|
|
uni.$off('updateBLEDeviceData', this.callbackUpdateBLEData);
|
|
|
},
|
|
},
|
|
|
methods: {
|
|
methods: {
|
|
@@ -197,10 +234,10 @@
|
|
|
// console.log(data)
|
|
// console.log(data)
|
|
|
function getIntValue(formatType, offset) {
|
|
function getIntValue(formatType, offset) {
|
|
|
console.log("getIntValue:" + formatType + " = " + offset);
|
|
console.log("getIntValue:" + formatType + " = " + offset);
|
|
|
- let array = new Uint8Array(data.ab);
|
|
|
|
|
|
|
+ let array = new Uint8Array(data.ab);
|
|
|
console.log(array);
|
|
console.log(array);
|
|
|
console.log(array[offset]);
|
|
console.log(array[offset]);
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
switch (formatType) {
|
|
switch (formatType) {
|
|
|
case 17:
|
|
case 17:
|
|
|
return ble.unsignedByteToInt(array[offset]);
|
|
return ble.unsignedByteToInt(array[offset]);
|
|
@@ -213,12 +250,16 @@
|
|
|
let flags = getIntValue(17, offset);
|
|
let flags = getIntValue(17, offset);
|
|
|
console.log("flags:", flags);
|
|
console.log("flags:", flags);
|
|
|
let hearRateType = (flags & 1) == 0 ? 17 : 18;
|
|
let hearRateType = (flags & 1) == 0 ? 17 : 18;
|
|
|
- console.log("hearRateType:"+ hearRateType);
|
|
|
|
|
|
|
+ console.log("hearRateType:" + hearRateType);
|
|
|
offset = offset + 1;
|
|
offset = offset + 1;
|
|
|
let heartRate = getIntValue(hearRateType, offset);
|
|
let heartRate = getIntValue(hearRateType, offset);
|
|
|
- console.log("heartRate:"+ heartRate);
|
|
|
|
|
- this.text = JSON.stringify(data.hex)+ "\n" + "心率:" + heartRate + "bpm" + "\n";
|
|
|
|
|
-
|
|
|
|
|
|
|
+ console.log("heartRate:" + heartRate);
|
|
|
|
|
+ this.text = JSON.stringify(data.hex) + "\n" + "心率:" + heartRate + "bpm" + "\n";
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ if (heartRate >= 120 && heartRate <= 150) {
|
|
|
|
|
+ this.playSpeak("当前心率" + heartRate);
|
|
|
|
|
+ }
|
|
|
},
|
|
},
|
|
|
|
|
|
|
|
onClearTimeout() {
|
|
onClearTimeout() {
|
|
@@ -255,8 +296,8 @@
|
|
|
for (let i = 0; i < this.devicesList.length; i++) {
|
|
for (let i = 0; i < this.devicesList.length; i++) {
|
|
|
let eq = this.devicesList[i];
|
|
let eq = this.devicesList[i];
|
|
|
//CL806_Bandage
|
|
//CL806_Bandage
|
|
|
- if ((eq.ename.indexOf("CL806") > -1 && this.BLEConnectDevice.id == 0)||
|
|
|
|
|
- (eq.ename.indexOf("CL831") > -1 && this.BLEConnectDevice.id == 1)) {
|
|
|
|
|
|
|
+ if ((eq.ename.indexOf("CL806") > -1 && this.BLEConnectDevice.id == 0) ||
|
|
|
|
|
+ (eq.ename.indexOf("CL831") > -1 && this.BLEConnectDevice.id == 1)) {
|
|
|
|
|
|
|
|
eq.bRatio = true;
|
|
eq.bRatio = true;
|
|
|
this.currentItem = eq;
|
|
this.currentItem = eq;
|
|
@@ -503,7 +544,8 @@
|
|
|
*/
|
|
*/
|
|
|
// console.log("onBluetoothDeviceFound:", res);
|
|
// console.log("onBluetoothDeviceFound:", res);
|
|
|
res.devices.forEach(device => {
|
|
res.devices.forEach(device => {
|
|
|
- if (device.name.indexOf('Fitcent_CL806') > -1 || device.name.indexOf('CL831') > -1 ) {
|
|
|
|
|
|
|
+ if (device.name.indexOf('Fitcent_CL806') > -1 || device.name.indexOf('CL831') > -
|
|
|
|
|
+ 1) {
|
|
|
//如果搜索的设备名 不是对应当前设备类型,过滤
|
|
//如果搜索的设备名 不是对应当前设备类型,过滤
|
|
|
// if (_self.currentItem.deviceName.indexOf('CL806') == -1 || _self.currentItem.deviceName.indexOf('CL831') == -1) return;
|
|
// if (_self.currentItem.deviceName.indexOf('CL806') == -1 || _self.currentItem.deviceName.indexOf('CL831') == -1) return;
|
|
|
//寻找到对应设备时候,其余的返回
|
|
//寻找到对应设备时候,其余的返回
|
|
@@ -557,7 +599,8 @@
|
|
|
this.onGetBLEDeviceServices({
|
|
this.onGetBLEDeviceServices({
|
|
|
item: item,
|
|
item: item,
|
|
|
success: (res) => {
|
|
success: (res) => {
|
|
|
- console.log("******getBLEDeviceServices************", res);
|
|
|
|
|
|
|
+ console.log("******getBLEDeviceServices************",
|
|
|
|
|
+ res);
|
|
|
//连接成功了,设置旧的item
|
|
//连接成功了,设置旧的item
|
|
|
this.oldItem = this.currentItem;
|
|
this.oldItem = this.currentItem;
|
|
|
setTimeout(() => {
|
|
setTimeout(() => {
|
|
@@ -678,6 +721,75 @@
|
|
|
},
|
|
},
|
|
|
onKeyInput: function(event) {
|
|
onKeyInput: function(event) {
|
|
|
this.onSetLocationGameUrl(event.target.value);
|
|
this.onSetLocationGameUrl(event.target.value);
|
|
|
|
|
+ },
|
|
|
|
|
+
|
|
|
|
|
+ initTextToSpeech() {
|
|
|
|
|
+ // 调用同步方法
|
|
|
|
|
+ var ret = testModule.initTextToSpeech();
|
|
|
|
|
+ console.log(ret);
|
|
|
|
|
+ uni.showToast({
|
|
|
|
|
+ title: "initTextToSpeech"
|
|
|
|
|
+ })
|
|
|
|
|
+ },
|
|
|
|
|
+ playSpeak(text) {
|
|
|
|
|
+ let currentTime = new Date().getTime() - this.playTime;
|
|
|
|
|
+ if (currentTime > 3000) {
|
|
|
|
|
+ // 调用同步方法
|
|
|
|
|
+ var ret = testModule.playSpeak(text);
|
|
|
|
|
+ console.log(ret);
|
|
|
|
|
+ this.playTime = new Date().getTime();
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ },
|
|
|
|
|
+ stopSpeak() {
|
|
|
|
|
+ // 调用同步方法
|
|
|
|
|
+ var ret = testModule.stopSpeak();
|
|
|
|
|
+ console.log(ret);
|
|
|
|
|
+ uni.showToast({
|
|
|
|
|
+ title: "stopSpeak"
|
|
|
|
|
+ })
|
|
|
|
|
+ },
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 计时器
|
|
|
|
|
+ */
|
|
|
|
|
+ startTimer() {
|
|
|
|
|
+ if (this.timer) {
|
|
|
|
|
+ clearInterval(this.timer);
|
|
|
|
|
+ this.timer = null;
|
|
|
|
|
+ }
|
|
|
|
|
+ this.timer = setInterval(() => {
|
|
|
|
|
+ this.millisecond = this.millisecond + 50;
|
|
|
|
|
+ if (this.millisecond >= 1000) {
|
|
|
|
|
+ this.millisecond = 0;
|
|
|
|
|
+ this.second = this.second + 1;
|
|
|
|
|
+ }
|
|
|
|
|
+ if (this.second >= 60) {
|
|
|
|
|
+ this.second = 0;
|
|
|
|
|
+ this.minute = this.minute + 1;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if (this.minute >= 60) {
|
|
|
|
|
+ this.minute = 0;
|
|
|
|
|
+ this.hour = this.hour + 1;
|
|
|
|
|
+ }
|
|
|
|
|
+ this.nums = this.hour + '时' + this.minute + '分' + this.second + '秒';
|
|
|
|
|
+ }, 50);
|
|
|
|
|
+ },
|
|
|
|
|
+ pauseTime() {
|
|
|
|
|
+ if (this.timer) {
|
|
|
|
|
+ clearInterval(this.timer);
|
|
|
|
|
+ this.timer = null;
|
|
|
|
|
+ }
|
|
|
|
|
+ },
|
|
|
|
|
+ closeTimer() {
|
|
|
|
|
+ this.hour = this.minute = this.second = 0; //初始化
|
|
|
|
|
+ this.millisecond = 0; //毫秒
|
|
|
|
|
+ if (this.timer) {
|
|
|
|
|
+ clearInterval(this.timer);
|
|
|
|
|
+ this.timer = null;
|
|
|
|
|
+ }
|
|
|
|
|
+ this.nums = 0 + '时' + 0 + '分' + 0 + '秒';
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|