2024-05-29 16:35:45 +08:00
|
|
|
|
<template>
|
|
|
|
|
|
<view class="content skipping">
|
|
|
|
|
|
<!-- -->
|
|
|
|
|
|
<view class="skiptop">
|
2024-07-22 14:13:19 +08:00
|
|
|
|
<view class="status" @click="handleisSdevice()">
|
|
|
|
|
|
<text>{{islink==0?"正在连接":islink==1?'连接成功':'重新连接'}}</text>
|
|
|
|
|
|
<image v-if="islink!=1" :class="[islink==-1?'':'icon_link']" src="../../static/zhuan.png"></image>
|
|
|
|
|
|
<image v-if="islink==1" src="../../static/dui.png"></image>
|
|
|
|
|
|
</view>
|
2024-05-29 16:35:45 +08:00
|
|
|
|
<view class="item">
|
|
|
|
|
|
<view class="item-ite">今日个数<text>{{info?info.today_jump_num:'--'}}</text></view>
|
|
|
|
|
|
<view class="item-ite">今日时长<text>{{info?info.today_jump_time:'--'}}</text></view>
|
|
|
|
|
|
<view class="item-ite">卡路里/kcal<text>{{info?info.today_jump_kcal:'--'}}</text></view>
|
|
|
|
|
|
</view>
|
|
|
|
|
|
</view>
|
|
|
|
|
|
<!-- -->
|
2024-06-13 18:03:50 +08:00
|
|
|
|
<view class="tabbar">
|
2024-05-29 16:35:45 +08:00
|
|
|
|
<view @click="active=1" :class="[active==1?'active':'']">自由训练</view>
|
|
|
|
|
|
<view @click="active=2" :class="[active==2?'active':'']">定时训练</view>
|
|
|
|
|
|
<view @click="active=3" :class="[active==3?'active':'']">定数训练</view>
|
2024-06-13 18:03:50 +08:00
|
|
|
|
</view>
|
2024-05-29 16:35:45 +08:00
|
|
|
|
<!--自由训练 -->
|
|
|
|
|
|
<view class="box1 box" v-if="active==1">
|
|
|
|
|
|
<view class="item">
|
2024-07-22 14:13:19 +08:00
|
|
|
|
<text class="item-set item-set0">自由</text>
|
|
|
|
|
|
<text class="tips">无限制</text>
|
2024-05-29 16:35:45 +08:00
|
|
|
|
</view>
|
2024-07-22 14:13:19 +08:00
|
|
|
|
<view :class="[isConnection?'start':'start Nstart']" @click="handleStart(1)">开始</view>
|
|
|
|
|
|
<!-- <view class="item">
|
2024-05-29 16:35:45 +08:00
|
|
|
|
<text class="item-ite">本次时长</text>
|
2024-07-22 14:13:19 +08:00
|
|
|
|
<text class="bold">{{info?info.last_jump_time:'0'}}</text>
|
2024-05-29 16:35:45 +08:00
|
|
|
|
</view>
|
|
|
|
|
|
<view class="item">
|
|
|
|
|
|
<text class="item-ite">消耗卡路里</text>
|
2024-07-22 14:13:19 +08:00
|
|
|
|
<text class="bold">{{info?info.last_jump_kcal:'0'}}</text>
|
|
|
|
|
|
</view> -->
|
2024-05-29 16:35:45 +08:00
|
|
|
|
</view>
|
|
|
|
|
|
<!--定时训练 -->
|
|
|
|
|
|
<view class="box1 box" v-if="active==2">
|
|
|
|
|
|
<view class="item">
|
|
|
|
|
|
<view class="item-set">
|
2024-07-22 14:13:19 +08:00
|
|
|
|
<text @click="handleTimeEdit('减')">-</text>
|
|
|
|
|
|
<text>{{time_m}}:{{time_s}}</text>
|
|
|
|
|
|
<text @click="handleTimeEdit('加')">+</text>
|
|
|
|
|
|
</view>
|
|
|
|
|
|
<view class="tips">
|
2024-05-29 16:35:45 +08:00
|
|
|
|
<picker mode="multiSelector" :range="timeList" :value="timesTndex" @change="bindTimeChange">
|
2024-07-22 14:13:19 +08:00
|
|
|
|
<view>调整目标</view>
|
2024-05-29 16:35:45 +08:00
|
|
|
|
</picker>
|
|
|
|
|
|
</view>
|
|
|
|
|
|
</view>
|
2024-07-22 14:13:19 +08:00
|
|
|
|
<view :class="[isConnection?'start':'start Nstart']" @click="handleStart(2)">开始</view>
|
|
|
|
|
|
<!-- <view class="item">
|
2024-05-29 16:35:45 +08:00
|
|
|
|
<text class="item-ite">本次个数</text>
|
2024-07-22 14:13:19 +08:00
|
|
|
|
<text></text>
|
2024-05-29 16:35:45 +08:00
|
|
|
|
</view>
|
|
|
|
|
|
<view class="item">
|
|
|
|
|
|
<text class="item-ite">消耗卡路里</text>
|
2024-07-22 14:13:19 +08:00
|
|
|
|
<text></text>
|
|
|
|
|
|
</view> -->
|
2024-05-29 16:35:45 +08:00
|
|
|
|
</view>
|
|
|
|
|
|
<!--定数训练 -->
|
|
|
|
|
|
<view class="box1 box" v-if="active==3">
|
|
|
|
|
|
<view class="item">
|
|
|
|
|
|
<view class="item-set">
|
2024-07-22 14:13:19 +08:00
|
|
|
|
<text @click="handleWeightEdit('减')">-</text>
|
|
|
|
|
|
<text v-if="!disabled">{{weight>50?weight:50}}</text>
|
|
|
|
|
|
<input type="number" v-model="weight" focus="true" v-else @blur="disabled=false">
|
|
|
|
|
|
<text @click="handleWeightEdit('加')">+</text>
|
2024-05-29 16:35:45 +08:00
|
|
|
|
</view>
|
2024-07-22 14:13:19 +08:00
|
|
|
|
<text class="tips" @click="disabled=true">调整目标</text>
|
2024-05-29 16:35:45 +08:00
|
|
|
|
</view>
|
2024-07-22 14:13:19 +08:00
|
|
|
|
<view :class="[isConnection?'start':'start Nstart']" @click="handleStart(3)">开始</view>
|
|
|
|
|
|
<!-- <view class="item">
|
2024-05-29 16:35:45 +08:00
|
|
|
|
<text class="item-ite">本次时长</text>
|
2024-07-22 14:13:19 +08:00
|
|
|
|
<text>0</text>
|
2024-05-29 16:35:45 +08:00
|
|
|
|
</view>
|
|
|
|
|
|
<view class="item">
|
|
|
|
|
|
<text class="item-ite">消耗卡路里</text>
|
2024-07-22 14:13:19 +08:00
|
|
|
|
<text>0</text>
|
|
|
|
|
|
</view> -->
|
2024-05-29 16:35:45 +08:00
|
|
|
|
</view>
|
|
|
|
|
|
<!-- -->
|
|
|
|
|
|
<view class="gridList">
|
|
|
|
|
|
<view class="data">
|
2024-08-22 09:48:00 +08:00
|
|
|
|
<view class="item" @click="navTo('/pages/skiping/charts')">
|
2024-05-29 16:35:45 +08:00
|
|
|
|
<view class="image">
|
2024-08-22 09:48:00 +08:00
|
|
|
|
<image src="@/static/charts.png"></image>
|
2024-05-29 16:35:45 +08:00
|
|
|
|
</view>
|
|
|
|
|
|
<view class="name">运动曲线</view>
|
|
|
|
|
|
</view>
|
|
|
|
|
|
<view class="item" @click="navTo('/pages/history/history?acd_id='+acd_id)">
|
|
|
|
|
|
<view class="image">
|
2024-08-22 09:48:00 +08:00
|
|
|
|
<image src="@/static/add.png"></image>
|
2024-05-29 16:35:45 +08:00
|
|
|
|
</view>
|
|
|
|
|
|
<view class="name">历史记录</view>
|
|
|
|
|
|
</view>
|
|
|
|
|
|
<view class="item" @click="navTo('/pages/compk/contrast?acd_id='+acd_id)">
|
|
|
|
|
|
<view class="image">
|
2024-08-22 09:48:00 +08:00
|
|
|
|
<image src="@/static/pk.png"></image>
|
2024-05-29 16:35:45 +08:00
|
|
|
|
</view>
|
|
|
|
|
|
<view class="name">数据对比</view>
|
|
|
|
|
|
</view>
|
|
|
|
|
|
<view class="item" @click="$store.commit('changeRecord',true)">
|
|
|
|
|
|
<view class="image">
|
2024-08-22 09:48:00 +08:00
|
|
|
|
<image src="@/static/history.png"></image>
|
2024-05-29 16:35:45 +08:00
|
|
|
|
</view>
|
|
|
|
|
|
<view class="name">添加记录</view>
|
|
|
|
|
|
</view>
|
|
|
|
|
|
</view>
|
|
|
|
|
|
</view>
|
|
|
|
|
|
<!-- 手动记录 -->
|
|
|
|
|
|
<record :rtype="acd_id"></record>
|
|
|
|
|
|
</view>
|
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
|
|
<script>
|
2024-07-22 14:13:19 +08:00
|
|
|
|
let myTime;
|
2024-05-29 16:35:45 +08:00
|
|
|
|
import {
|
|
|
|
|
|
mapState
|
|
|
|
|
|
} from "vuex";
|
2024-08-22 09:48:00 +08:00
|
|
|
|
import record from '@/element/manuallyAdd/record.vue';
|
2024-05-29 16:35:45 +08:00
|
|
|
|
export default {
|
|
|
|
|
|
data() {
|
|
|
|
|
|
return {
|
|
|
|
|
|
active: 1,
|
|
|
|
|
|
acd_id: 6,
|
2024-07-22 14:13:19 +08:00
|
|
|
|
weight: 50,
|
|
|
|
|
|
disabled: false,
|
2024-08-05 10:01:06 +08:00
|
|
|
|
isDevice: 0,
|
2024-07-22 14:13:19 +08:00
|
|
|
|
isConnection: false,
|
|
|
|
|
|
time_m: "",
|
|
|
|
|
|
time_s: "",
|
2024-05-29 16:35:45 +08:00
|
|
|
|
timeList: [],
|
2024-07-22 14:13:19 +08:00
|
|
|
|
timesTndex: [1, 0],
|
|
|
|
|
|
deviceId: "",
|
|
|
|
|
|
serviceId: "",
|
|
|
|
|
|
write: "",
|
|
|
|
|
|
notify: "",
|
|
|
|
|
|
islink: 0 //0连接中,1成功,-1失败
|
2024-05-29 16:35:45 +08:00
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
components: {
|
|
|
|
|
|
record
|
|
|
|
|
|
},
|
|
|
|
|
|
computed: {
|
2024-07-22 14:13:19 +08:00
|
|
|
|
...mapState(['user', "MeasureSkip", "isConnected", "isBluetoothTyle", "devicesList"]),
|
2024-05-29 16:35:45 +08:00
|
|
|
|
info() {
|
|
|
|
|
|
return this.MeasureSkip
|
2024-07-22 14:13:19 +08:00
|
|
|
|
},
|
|
|
|
|
|
},
|
|
|
|
|
|
mounted() {
|
|
|
|
|
|
let that = this
|
|
|
|
|
|
that.timeList = that.$tools.gethms()
|
|
|
|
|
|
that.time_m = that.timeList[0][1].substring(0, 2)
|
|
|
|
|
|
that.time_s = that.timeList[1][0].substring(0, 2)
|
2024-05-29 16:35:45 +08:00
|
|
|
|
},
|
|
|
|
|
|
onLoad(options) {
|
|
|
|
|
|
let that = this
|
2024-08-16 14:37:37 +08:00
|
|
|
|
console.log('options', options)
|
2024-07-22 14:13:19 +08:00
|
|
|
|
// 首页进入
|
|
|
|
|
|
if (options && options.acd_id) {
|
|
|
|
|
|
that.acd_id = options.acd_id
|
|
|
|
|
|
that.isDevice = options.device
|
|
|
|
|
|
setTimeout(function() {
|
|
|
|
|
|
that.handleisSdevice()
|
|
|
|
|
|
}, 1000)
|
|
|
|
|
|
}
|
|
|
|
|
|
// 跳绳页返回
|
|
|
|
|
|
if (options && options.info) {
|
|
|
|
|
|
let data = JSON.parse(options.info)
|
|
|
|
|
|
that.active = data.active
|
|
|
|
|
|
that.deviceId = data.deviceId
|
|
|
|
|
|
that.serviceId = data.serviceId
|
|
|
|
|
|
that.write = data.write
|
|
|
|
|
|
that.notify = data.notify
|
2024-08-16 14:37:37 +08:00
|
|
|
|
that.islink = !that.isConnected ? -1 : 1
|
2024-07-22 14:13:19 +08:00
|
|
|
|
that.notifyBLECharacteristicValue()
|
|
|
|
|
|
}
|
2024-05-29 16:35:45 +08:00
|
|
|
|
that.$store.dispatch("getSkipResult", {
|
|
|
|
|
|
aud_id: uni.getStorageSync('userid')
|
|
|
|
|
|
})
|
2024-07-22 14:13:19 +08:00
|
|
|
|
that.isConnection = that.isConnected
|
|
|
|
|
|
that.$Bluetooth.onBLEConnectionStateChange()
|
|
|
|
|
|
uni.onBluetoothAdapterStateChange(function(res) {
|
|
|
|
|
|
that.$store.commit("changeBluetooth", res.available);
|
|
|
|
|
|
})
|
2024-05-29 16:35:45 +08:00
|
|
|
|
},
|
2024-07-26 16:43:31 +08:00
|
|
|
|
onPullDownRefresh() {
|
|
|
|
|
|
setTimeout(() => {
|
|
|
|
|
|
uni.stopPullDownRefresh()
|
|
|
|
|
|
}, 1000);
|
|
|
|
|
|
},
|
2024-07-22 14:13:19 +08:00
|
|
|
|
onShow() {
|
|
|
|
|
|
let that = this
|
|
|
|
|
|
// 跳绳页返回
|
|
|
|
|
|
uni.$on('updateData', function(data) {
|
|
|
|
|
|
let info = JSON.parse(data)
|
|
|
|
|
|
that.acd_id = info.acd_id
|
|
|
|
|
|
that.isDevice = info.device
|
|
|
|
|
|
console.log('监听到事件来自 updateData ,携带参数为:' + info);
|
|
|
|
|
|
})
|
|
|
|
|
|
},
|
|
|
|
|
|
onBackPress(options) {
|
|
|
|
|
|
let that = this
|
2024-08-16 14:37:37 +08:00
|
|
|
|
that.islink = -1
|
2024-07-22 14:13:19 +08:00
|
|
|
|
clearTimeout(myTime);
|
|
|
|
|
|
that.isConnection = false
|
|
|
|
|
|
that.$Bluetooth.closeBluetoothAdapter()
|
2024-08-30 18:03:10 +08:00
|
|
|
|
that.$Bluetooth.closeBLEConnection(that.deviceId)
|
2024-07-22 14:13:19 +08:00
|
|
|
|
that.$Bluetooth.stopBluetoothDevicesDiscovery()
|
|
|
|
|
|
that.$store.commit("changeBluetooth", false);
|
|
|
|
|
|
that.$store.commit("changeConnected", false);
|
2024-08-16 14:37:37 +08:00
|
|
|
|
setTimeout(() => {
|
|
|
|
|
|
uni.switchTab({
|
2024-08-22 09:48:00 +08:00
|
|
|
|
url: '/pages/home/home'
|
2024-08-16 14:37:37 +08:00
|
|
|
|
})
|
|
|
|
|
|
}, 300)
|
|
|
|
|
|
console.log("返回首页")
|
|
|
|
|
|
return true
|
2024-07-22 14:13:19 +08:00
|
|
|
|
},
|
|
|
|
|
|
watch: {
|
|
|
|
|
|
devicesList() {
|
|
|
|
|
|
let that = this
|
|
|
|
|
|
if (that.devicesList.length) {
|
|
|
|
|
|
clearTimeout(myTime);
|
|
|
|
|
|
that.$Bluetooth.stopBluetoothDevicesDiscovery()
|
2024-08-30 18:03:10 +08:00
|
|
|
|
that.handleDevType(that.devicesList[0])
|
2024-07-22 14:13:19 +08:00
|
|
|
|
}
|
|
|
|
|
|
console.log("devicesList", that.devicesList)
|
|
|
|
|
|
},
|
|
|
|
|
|
isConnected() {
|
|
|
|
|
|
let that = this
|
2024-08-16 14:37:37 +08:00
|
|
|
|
if (!that.isConnected) {
|
2024-07-22 14:13:19 +08:00
|
|
|
|
that.islink = -1
|
|
|
|
|
|
}
|
2024-08-16 14:37:37 +08:00
|
|
|
|
that.isConnection = that.isConnected
|
2024-07-22 14:13:19 +08:00
|
|
|
|
console.log("蓝牙是否连接", that.isConnected)
|
|
|
|
|
|
},
|
|
|
|
|
|
isBluetoothTyle() {
|
|
|
|
|
|
let that = this
|
|
|
|
|
|
if (!that.isBluetoothTyle) {
|
|
|
|
|
|
that.isConnection = false
|
|
|
|
|
|
that.islink = -1
|
|
|
|
|
|
}
|
|
|
|
|
|
console.log("蓝牙是否打开", that.isBluetoothTyle)
|
|
|
|
|
|
}
|
2024-05-29 16:35:45 +08:00
|
|
|
|
},
|
|
|
|
|
|
methods: {
|
2024-07-22 14:13:19 +08:00
|
|
|
|
handleisSdevice() {
|
|
|
|
|
|
let that = this
|
|
|
|
|
|
if (that.isConnected) return
|
2024-08-05 10:01:06 +08:00
|
|
|
|
if (Number(that.isDevice) != 0) {
|
2024-07-22 14:13:19 +08:00
|
|
|
|
that.$Bluetooth.stopBluetoothDevicesDiscovery()
|
|
|
|
|
|
uni.openBluetoothAdapter({
|
|
|
|
|
|
success: e => {
|
|
|
|
|
|
that.islink = 0
|
|
|
|
|
|
that.handleMyTime()
|
|
|
|
|
|
that.$store.commit("changedevicesList", []);
|
|
|
|
|
|
that.$store.commit("changeBluetooth", true)
|
|
|
|
|
|
that.$Bluetooth.startBluetoothDeviceDiscovery()
|
|
|
|
|
|
console.log('初始化蓝牙成功:' + e.errMsg);
|
|
|
|
|
|
},
|
|
|
|
|
|
fail: e => {
|
|
|
|
|
|
that.islink = -1
|
|
|
|
|
|
that.$Bluetooth.getBluetoothAdapter(e)
|
|
|
|
|
|
}
|
|
|
|
|
|
});
|
|
|
|
|
|
} else {
|
2026-03-23 14:22:23 +08:00
|
|
|
|
that.islink = -1
|
2024-07-22 14:13:19 +08:00
|
|
|
|
that.$tools.msg("请先添加设备!")
|
2026-03-23 14:22:23 +08:00
|
|
|
|
that.$Bluetooth.stopBluetoothDevicesDiscovery()
|
|
|
|
|
|
// setTimeout(function() {
|
|
|
|
|
|
// uni.switchTab({
|
|
|
|
|
|
// url: "/pages/business/business"
|
|
|
|
|
|
// })
|
|
|
|
|
|
// }, 500)
|
2024-07-22 14:13:19 +08:00
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
// 设备排查
|
2024-08-30 18:03:10 +08:00
|
|
|
|
handleDevType(device) {
|
2024-07-22 14:13:19 +08:00
|
|
|
|
let that = this
|
2024-08-30 18:03:10 +08:00
|
|
|
|
console.log("device123", device)
|
2024-07-22 14:13:19 +08:00
|
|
|
|
that.$model.getdevdetail({
|
2024-08-30 18:03:10 +08:00
|
|
|
|
mac: device.macAddr,
|
2024-07-22 14:13:19 +08:00
|
|
|
|
acd_id: that.acd_id
|
|
|
|
|
|
}).then(res => {
|
|
|
|
|
|
console.log("排查返回", res)
|
|
|
|
|
|
if (res.code == 0) {
|
2024-08-30 18:03:10 +08:00
|
|
|
|
that.deviceId = device.deviceId
|
2024-07-22 14:13:19 +08:00
|
|
|
|
that.createBLEConnection()
|
|
|
|
|
|
}
|
|
|
|
|
|
})
|
|
|
|
|
|
},
|
|
|
|
|
|
// 连接蓝牙
|
|
|
|
|
|
createBLEConnection() {
|
|
|
|
|
|
let that = this;
|
|
|
|
|
|
uni.createBLEConnection({
|
|
|
|
|
|
deviceId: that.deviceId,
|
|
|
|
|
|
success: res => {
|
|
|
|
|
|
setTimeout(function() {
|
|
|
|
|
|
uni.hideLoading()
|
|
|
|
|
|
that.islink = 1
|
|
|
|
|
|
that.isConnection = true
|
|
|
|
|
|
that.getBLEDeviceServices()
|
|
|
|
|
|
}, 1000)
|
|
|
|
|
|
},
|
|
|
|
|
|
fail: res => {
|
2024-08-30 18:03:10 +08:00
|
|
|
|
console.log("设备连接失败,请重新连接", res, that.deviceId);
|
2024-07-22 14:13:19 +08:00
|
|
|
|
}
|
|
|
|
|
|
});
|
|
|
|
|
|
},
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 获取设备的UUID
|
|
|
|
|
|
*/
|
|
|
|
|
|
getBLEDeviceServices() {
|
|
|
|
|
|
let serviceList = [];
|
|
|
|
|
|
let that = this;
|
|
|
|
|
|
uni.getBLEDeviceServices({
|
|
|
|
|
|
deviceId: that.deviceId,
|
|
|
|
|
|
success: res => {
|
|
|
|
|
|
console.log("获取设备的UUID成功", res)
|
|
|
|
|
|
serviceList = res.services;
|
|
|
|
|
|
for (let i = 0; i < serviceList.length; i++) {
|
|
|
|
|
|
let service = serviceList[i];
|
|
|
|
|
|
if (service.uuid.indexOf("FFE0") != -1) {
|
|
|
|
|
|
that.serviceId = service.uuid;
|
|
|
|
|
|
that.getBLEDeviceCharacteristics();
|
|
|
|
|
|
console.log("设备的FFE0的serviceId: " + that.serviceId);
|
|
|
|
|
|
break;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
fail: res => {
|
|
|
|
|
|
console.log('获取设备的UUID失败:', res)
|
|
|
|
|
|
}
|
|
|
|
|
|
});
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 获取指定服务的特征值
|
|
|
|
|
|
*/
|
|
|
|
|
|
getBLEDeviceCharacteristics() {
|
|
|
|
|
|
let characteristicsList = [];
|
|
|
|
|
|
let that = this;
|
|
|
|
|
|
uni.getBLEDeviceCharacteristics({
|
|
|
|
|
|
deviceId: that.deviceId,
|
|
|
|
|
|
serviceId: that.serviceId,
|
|
|
|
|
|
success: res => {
|
|
|
|
|
|
console.log("服务的特征值成功", res)
|
|
|
|
|
|
// * 读read: true, //,写write: true, //,通知notify: true
|
|
|
|
|
|
for (let i = 0; i < res.characteristics.length; i++) {
|
|
|
|
|
|
let item = res.characteristics[i];
|
|
|
|
|
|
if (item.uuid.indexOf('0000FF12') != -1) {
|
|
|
|
|
|
that.write = item.uuid
|
|
|
|
|
|
|
|
|
|
|
|
} else if (item.uuid.indexOf('0000FFE4') != -1) {
|
|
|
|
|
|
that.notify = item.uuid
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
setTimeout(function() {
|
|
|
|
|
|
let j = Number(165 + 10 + 1 + 8 + 8 + 8 + 8 + 8 + 8).toString(16)
|
|
|
|
|
|
let str = "A50A01080808080808" + j.substr(j.length - 2, 2)
|
|
|
|
|
|
that.SendData(str)
|
2024-09-12 11:20:52 +08:00
|
|
|
|
}, 300)
|
2024-07-22 14:13:19 +08:00
|
|
|
|
// 体重
|
|
|
|
|
|
setTimeout(function() {
|
|
|
|
|
|
that.handleStart(4)
|
2024-09-12 11:20:52 +08:00
|
|
|
|
}, 600)
|
2024-07-22 14:13:19 +08:00
|
|
|
|
uni.notifyBLECharacteristicValueChange({
|
|
|
|
|
|
deviceId: that.deviceId,
|
|
|
|
|
|
serviceId: that.serviceId,
|
|
|
|
|
|
characteristicId: that.notify,
|
|
|
|
|
|
state: true,
|
|
|
|
|
|
})
|
|
|
|
|
|
uni.notifyBLECharacteristicValueChange({
|
|
|
|
|
|
deviceId: that.deviceId,
|
|
|
|
|
|
serviceId: that.serviceId,
|
|
|
|
|
|
characteristicId: that.write,
|
|
|
|
|
|
state: true,
|
|
|
|
|
|
})
|
|
|
|
|
|
that.notifyBLECharacteristicValue()
|
|
|
|
|
|
},
|
|
|
|
|
|
fail: res => {
|
|
|
|
|
|
console.log('获取特征值失败:', JSON.stringify(res))
|
|
|
|
|
|
}
|
|
|
|
|
|
})
|
|
|
|
|
|
},
|
|
|
|
|
|
notifyBLECharacteristicValue() {
|
|
|
|
|
|
let that = this;
|
|
|
|
|
|
uni.notifyBLECharacteristicValueChange({
|
|
|
|
|
|
state: true, // 启用 notify 功能
|
|
|
|
|
|
deviceId: that.deviceId,
|
|
|
|
|
|
serviceId: that.serviceId,
|
|
|
|
|
|
characteristicId: that.notify,
|
|
|
|
|
|
success(res) {
|
|
|
|
|
|
uni.onBLECharacteristicValueChange(function(res) {
|
|
|
|
|
|
let value = that.$tools.ab2hex(res.value, "");
|
|
|
|
|
|
if (value == '5a05090169') { //模式设置成功
|
|
|
|
|
|
let info = {
|
|
|
|
|
|
active: that.active,
|
|
|
|
|
|
deviceId: that.deviceId,
|
|
|
|
|
|
serviceId: that.serviceId,
|
|
|
|
|
|
notify: that.notify,
|
|
|
|
|
|
write: that.write,
|
|
|
|
|
|
acd_id: that.acd_id,
|
|
|
|
|
|
isDevice: that.isDevice
|
|
|
|
|
|
}
|
|
|
|
|
|
setTimeout(function() {
|
|
|
|
|
|
uni.navigateTo({
|
2024-09-12 11:20:52 +08:00
|
|
|
|
url: "/pages/devices/PCT01?info=" + JSON.stringify(info)
|
2024-07-22 14:13:19 +08:00
|
|
|
|
})
|
2024-09-12 14:42:45 +08:00
|
|
|
|
}, 200)
|
2024-07-22 14:13:19 +08:00
|
|
|
|
}
|
|
|
|
|
|
console.log("value", value, that.active)
|
|
|
|
|
|
})
|
|
|
|
|
|
}
|
|
|
|
|
|
})
|
|
|
|
|
|
},
|
|
|
|
|
|
// 开启蓝牙主动上报模式
|
|
|
|
|
|
SendData(str) {
|
|
|
|
|
|
let that = this
|
|
|
|
|
|
let buf = new Uint8Array(str.match(/[\da-f]{2}/gi).map(function(h) {
|
|
|
|
|
|
return parseInt(h, 16)
|
|
|
|
|
|
}))
|
2024-09-12 11:20:52 +08:00
|
|
|
|
console.log("xiafa", str)
|
2024-07-22 14:13:19 +08:00
|
|
|
|
uni.writeBLECharacteristicValue({
|
|
|
|
|
|
deviceId: that.deviceId,
|
|
|
|
|
|
serviceId: that.serviceId,
|
|
|
|
|
|
characteristicId: that.write,
|
|
|
|
|
|
value: buf.buffer,
|
|
|
|
|
|
success: res => {
|
|
|
|
|
|
console.log('下发指令成功', res.errMsg)
|
|
|
|
|
|
},
|
|
|
|
|
|
fail: res => {
|
|
|
|
|
|
console.log("下发指令失败", res);
|
|
|
|
|
|
},
|
|
|
|
|
|
})
|
|
|
|
|
|
},
|
|
|
|
|
|
// 模式切换
|
|
|
|
|
|
handleStart(ind) {
|
|
|
|
|
|
let that = this
|
|
|
|
|
|
let m = null
|
|
|
|
|
|
let send = null
|
|
|
|
|
|
if (!that.isConnected) {
|
|
|
|
|
|
that.$tools.msg("请先连接设备!")
|
|
|
|
|
|
return
|
|
|
|
|
|
}
|
|
|
|
|
|
if (ind == 1) { // 1自由
|
|
|
|
|
|
m = Number(165 + 8 + 9).toString(16)
|
|
|
|
|
|
send = "A5080900000000" + m.substr(m.length - 2, 2)
|
|
|
|
|
|
}
|
|
|
|
|
|
if (ind == 2) { //2定时
|
|
|
|
|
|
let time = Number(that.time_m) * 60 + Number(that.time_s)
|
|
|
|
|
|
m = Number(165 + 8 + 9 + time).toString(16)
|
|
|
|
|
|
send = "A508090000" + that.$tools.toHex(time, 4) + m.substr(m.length - 2, 2)
|
|
|
|
|
|
}
|
|
|
|
|
|
if (ind == 3) { //3定数
|
|
|
|
|
|
let weight = that.$tools.toHex(that.weight, 4)
|
|
|
|
|
|
m = Number(165 + 8 + 9 + that.weight).toString(16)
|
|
|
|
|
|
send = "A50809" + weight + "0000" + m.substr(m.length - 2, 2)
|
|
|
|
|
|
}
|
|
|
|
|
|
if (ind == 4) { //体重
|
|
|
|
|
|
|
|
|
|
|
|
let weight = Number(that.user.weight) * 2
|
|
|
|
|
|
let num = parseInt(weight).toString();
|
|
|
|
|
|
m = Number(165 + 5 + 8 + Number(num)).toString(16)
|
|
|
|
|
|
send = "A50508" + Number(num).toString(16) + m.substr(m.length - 2, 2)
|
|
|
|
|
|
}
|
|
|
|
|
|
that.SendData(send)
|
|
|
|
|
|
that.$Bluetooth.stopBluetoothDevicesDiscovery()
|
2024-05-29 16:35:45 +08:00
|
|
|
|
},
|
2024-07-08 10:50:07 +08:00
|
|
|
|
// 历史数据删除时重新加载接口
|
|
|
|
|
|
reload() {
|
|
|
|
|
|
let that = this
|
|
|
|
|
|
this.$nextTick(() => {
|
|
|
|
|
|
that.$store.dispatch("getSkipResult", {
|
|
|
|
|
|
aud_id: uni.getStorageSync('userid')
|
|
|
|
|
|
})
|
|
|
|
|
|
})
|
|
|
|
|
|
},
|
2024-07-22 14:13:19 +08:00
|
|
|
|
// 定时训练
|
|
|
|
|
|
//
|
|
|
|
|
|
bindTimeChange(e) {
|
|
|
|
|
|
let that = this
|
|
|
|
|
|
let m = e.target.value[0]
|
|
|
|
|
|
let s = e.target.value[1]
|
|
|
|
|
|
that.timesTndex = e.target.value
|
|
|
|
|
|
let time_m = Number(that.timeList[0][m].substring(0, 2)) * 60
|
|
|
|
|
|
let time_s = Number(that.timeList[1][s].substring(0, 2))
|
|
|
|
|
|
if (Number(time_m + time_s) < 30) {
|
|
|
|
|
|
that.time_m = '00'
|
|
|
|
|
|
that.time_s = '30'
|
|
|
|
|
|
} else {
|
|
|
|
|
|
that.time_m = that.timeList[0][m].substring(0, 2)
|
|
|
|
|
|
that.time_s = that.timeList[1][s].substring(0, 2)
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
handleTimeEdit(text) {
|
|
|
|
|
|
let that = this
|
|
|
|
|
|
let time_m = Number(that.time_m) * 60
|
|
|
|
|
|
let time_s = Number(that.time_s)
|
|
|
|
|
|
let minutes = null
|
|
|
|
|
|
let seconds = null
|
|
|
|
|
|
|
|
|
|
|
|
if (Number(time_m + time_s) >= 3570 && text == '加') {
|
|
|
|
|
|
that.time_m = '59'
|
|
|
|
|
|
that.time_s = '59'
|
|
|
|
|
|
return
|
|
|
|
|
|
}
|
|
|
|
|
|
if (Number(time_m + time_s) <= 30 && text == '减') {
|
|
|
|
|
|
that.time_m = '00'
|
|
|
|
|
|
that.time_s = '30'
|
|
|
|
|
|
return
|
|
|
|
|
|
}
|
|
|
|
|
|
if (text == '减') {
|
|
|
|
|
|
minutes = Math.floor((Number(time_m + time_s - 30) % 3600) / 60)
|
|
|
|
|
|
seconds = Number(time_m + time_s - 30) % 60
|
|
|
|
|
|
}
|
|
|
|
|
|
if (text == '加') {
|
|
|
|
|
|
minutes = Math.floor((Number(time_m + time_s + 30) % 3600) / 60)
|
|
|
|
|
|
seconds = Number(time_m + time_s + 30) % 60
|
|
|
|
|
|
}
|
|
|
|
|
|
that.time_m = minutes > 9 ? minutes : '0' + minutes;
|
|
|
|
|
|
that.time_s = seconds > 9 ? seconds : '0' + seconds;
|
|
|
|
|
|
that.timesTndex = [Number(that.time_m), Number(that.time_s)]
|
|
|
|
|
|
},
|
|
|
|
|
|
handleWeightEdit(text) {
|
|
|
|
|
|
let that = this
|
|
|
|
|
|
if (text == '减') {
|
|
|
|
|
|
that.weight = Number(that.weight) - 50 > 50 ? Number(that.weight) - 50 : 50
|
|
|
|
|
|
}
|
|
|
|
|
|
if (text == '加') {
|
|
|
|
|
|
that.weight = Number(that.weight) + 50
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
// 蓝牙搜索记时
|
|
|
|
|
|
handleMyTime() {
|
|
|
|
|
|
let that = this
|
|
|
|
|
|
myTime = setTimeout(function() {
|
|
|
|
|
|
if (!that.devicesList.length) {
|
|
|
|
|
|
that.islink = -1
|
|
|
|
|
|
that.$tools.showModal("没有查找到设备")
|
|
|
|
|
|
}
|
|
|
|
|
|
clearTimeout(myTime)
|
|
|
|
|
|
that.$Bluetooth.stopBluetoothDevicesDiscovery()
|
|
|
|
|
|
}, 12000);
|
|
|
|
|
|
},
|
2024-05-29 16:35:45 +08:00
|
|
|
|
navTo(url) {
|
2024-07-22 14:13:19 +08:00
|
|
|
|
let that = this
|
|
|
|
|
|
if (!that.isConnected) {
|
|
|
|
|
|
that.islink = -1
|
|
|
|
|
|
clearTimeout(myTime)
|
|
|
|
|
|
that.$Bluetooth.closeBluetoothAdapter()
|
2024-08-30 18:03:10 +08:00
|
|
|
|
that.$Bluetooth.closeBLEConnection(that.deviceId)
|
2024-07-22 14:13:19 +08:00
|
|
|
|
that.$Bluetooth.stopBluetoothDevicesDiscovery()
|
|
|
|
|
|
console.log("蓝牙没有连接")
|
|
|
|
|
|
}
|
2024-05-29 16:35:45 +08:00
|
|
|
|
uni.navigateTo({
|
|
|
|
|
|
url: url
|
|
|
|
|
|
})
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
|
|
<style lang="scss" scoped>
|
|
|
|
|
|
.content {
|
|
|
|
|
|
width: 100%;
|
|
|
|
|
|
min-height: 100vh;
|
|
|
|
|
|
background-color: #F5F6FA;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2024-08-22 09:48:00 +08:00
|
|
|
|
.skiptop {
|
|
|
|
|
|
margin-top: 15px;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2024-05-29 16:35:45 +08:00
|
|
|
|
.tabbar {
|
|
|
|
|
|
width: 100%;
|
|
|
|
|
|
margin-top: 20px;
|
|
|
|
|
|
margin-bottom: 20px;
|
|
|
|
|
|
display: flex;
|
|
|
|
|
|
align-items: center;
|
|
|
|
|
|
justify-content: space-around;
|
|
|
|
|
|
|
|
|
|
|
|
view {
|
|
|
|
|
|
position: relative;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.active:after {
|
|
|
|
|
|
content: "";
|
|
|
|
|
|
height: 3px;
|
|
|
|
|
|
width: 100%;
|
|
|
|
|
|
position: absolute;
|
|
|
|
|
|
bottom: -8px;
|
|
|
|
|
|
left: 0;
|
|
|
|
|
|
border-radius: 5px;
|
|
|
|
|
|
background: $maincolor;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.box1 {
|
|
|
|
|
|
background-color: #fff;
|
|
|
|
|
|
padding: 10px !important;
|
|
|
|
|
|
color: #999;
|
|
|
|
|
|
margin: 15px;
|
|
|
|
|
|
border-radius: 10px;
|
|
|
|
|
|
width: calc(100%- 30px);
|
|
|
|
|
|
|
|
|
|
|
|
.time {
|
|
|
|
|
|
width: 100%;
|
2024-08-05 10:01:06 +08:00
|
|
|
|
font-size: 32rpx;
|
2024-05-29 16:35:45 +08:00
|
|
|
|
margin-bottom: 20px;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.item {
|
|
|
|
|
|
width: 100%;
|
|
|
|
|
|
color: #333;
|
2024-08-05 10:01:06 +08:00
|
|
|
|
font-size: 44rpx;
|
2024-05-29 16:35:45 +08:00
|
|
|
|
text-align: center;
|
2024-07-22 14:13:19 +08:00
|
|
|
|
margin-bottom: 15px;
|
2024-05-29 16:35:45 +08:00
|
|
|
|
|
|
|
|
|
|
text {
|
|
|
|
|
|
display: block;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.item-ite {
|
2024-08-05 10:01:06 +08:00
|
|
|
|
font-size: 36rpx;
|
2024-07-22 14:13:19 +08:00
|
|
|
|
margin-bottom: 15px;
|
2024-05-29 16:35:45 +08:00
|
|
|
|
width: 100%;
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.item-set {
|
2024-07-22 14:13:19 +08:00
|
|
|
|
width: calc(100% - 30px);
|
2024-05-29 16:35:45 +08:00
|
|
|
|
display: flex;
|
|
|
|
|
|
align-items: center;
|
2024-07-22 14:13:19 +08:00
|
|
|
|
height: 55px;
|
|
|
|
|
|
line-height: 55px;
|
2024-08-05 10:01:06 +08:00
|
|
|
|
font-size: 60rpx;
|
2024-05-29 16:35:45 +08:00
|
|
|
|
margin-bottom: 5px;
|
|
|
|
|
|
background-color: #f7f7f7;
|
2024-07-22 14:13:19 +08:00
|
|
|
|
padding: 0 15px;
|
|
|
|
|
|
justify-content: space-between;
|
2024-05-29 16:35:45 +08:00
|
|
|
|
margin: auto;
|
|
|
|
|
|
position: relative;
|
|
|
|
|
|
|
|
|
|
|
|
/deep/input {
|
2024-08-05 10:01:06 +08:00
|
|
|
|
font-size: 60rpx;
|
2024-07-22 14:13:19 +08:00
|
|
|
|
height: 55px;
|
|
|
|
|
|
line-height: 55px;
|
2024-05-29 16:35:45 +08:00
|
|
|
|
}
|
2024-07-22 14:13:19 +08:00
|
|
|
|
}
|
2024-05-29 16:35:45 +08:00
|
|
|
|
|
2024-07-22 14:13:19 +08:00
|
|
|
|
.item-set0 {
|
|
|
|
|
|
background-color: #fff;
|
|
|
|
|
|
justify-content: center
|
2024-05-29 16:35:45 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.tips {
|
2024-08-05 10:01:06 +08:00
|
|
|
|
font-size: 32rpx;
|
2024-05-29 16:35:45 +08:00
|
|
|
|
color: #999;
|
|
|
|
|
|
margin-top: 10px;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2024-07-22 14:13:19 +08:00
|
|
|
|
|
|
|
|
|
|
.start {
|
|
|
|
|
|
color: #fff;
|
|
|
|
|
|
width: 100px;
|
|
|
|
|
|
height: 100px;
|
2024-08-05 10:01:06 +08:00
|
|
|
|
font-size: 36rpx;
|
2024-07-22 14:13:19 +08:00
|
|
|
|
font-weight: bold;
|
|
|
|
|
|
line-height: 100px;
|
|
|
|
|
|
text-align: center;
|
|
|
|
|
|
border-radius: 50%;
|
|
|
|
|
|
background: $textcolor;
|
|
|
|
|
|
margin: 15px auto;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.Nstart {
|
|
|
|
|
|
opacity: 0.5 !important;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.status {
|
|
|
|
|
|
background-color: #fff;
|
|
|
|
|
|
|
|
|
|
|
|
image {
|
|
|
|
|
|
width: 18px;
|
|
|
|
|
|
height: 18px;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.icon_link {
|
|
|
|
|
|
animation: rotation 0.6s infinite linear;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@keyframes rotation {
|
|
|
|
|
|
0% {
|
|
|
|
|
|
transform: rotate(0deg);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
100% {
|
|
|
|
|
|
transform: rotate(360deg);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2024-05-29 16:35:45 +08:00
|
|
|
|
}
|
|
|
|
|
|
</style>
|