F01PRO新增AiLink蓝牙名称

This commit is contained in:
subing008 2025-08-18 10:58:58 +08:00
parent d3b80546d6
commit e5b7648729
76 changed files with 563 additions and 544 deletions

View File

@ -1,298 +1,304 @@
<template> <template>
<view> <view>
<view class="content weightPages"> <view class="content weightPages">
<view class="title" v-if="isConnection == 0">连接中请稍后</view> <view class="title" v-if="isConnection == 0">连接中请稍后</view>
<view class="title" v-if="isConnection == 1">连接成功请开始测量</view> <view class="title" v-if="isConnection == 1">连接成功请开始测量</view>
<view class="title" v-if="isConnection == 2" @click="openBluetoothAdapter">连接失败点击重新连接</view> <view class="title" v-if="isConnection == 2" @click="openBluetoothAdapter">连接失败点击重新连接</view>
<view class="text">{{textW}}</view> <view class="text">{{textW}}</view>
<view class="text">{{textH}}</view> <view class="text">{{textH}}</view>
<view class="text" v-if="textImp != ''">{{textImp}}</view> <view class="text" v-if="textImp != ''">{{textImp}}</view>
<view class="image" style="margin-top: 200rpx;"> <view class="image" style="margin-top: 200rpx;">
<image src="/pageTwo/static/F018P01.gif" mode="widthFix"></image> <image src="/pageTwo/static/F018P01.gif" mode="widthFix"></image>
</view> </view>
<view class="tips"> <view class="tips">
<text>请确保</text> <text>请确保</text>
<text>1.请确定设备是开机状态</text> <text>1.请确定设备是开机状态</text>
<text>2.请确定手机蓝牙位置信息已打开</text> <text>2.请确定手机蓝牙位置信息已打开</text>
<text>3.ios系统需打开设置>应用>微信里的蓝牙权限</text> <text>3.ios系统需打开设置>应用>微信里的蓝牙权限</text>
</view> </view>
</view> </view>
</view> </view>
</template> </template>
<script> <script>
import { import {
mapState mapState
} from "vuex"; } from "vuex";
var myTime; var myTime;
const plugin = requirePlugin("sdkPlugin").AiLink; const plugin = requirePlugin("sdkPlugin").AiLink;
export default { export default {
data() { data() {
return { return {
textW: "", textW: "",
textH: "", textH: "",
textImp: "", textImp: "",
height: "", height: "",
weight: "", weight: "",
imp: 0, imp: 0,
macAddr: "", macAddr: "",
deviceId: "", deviceId: "",
serviceId: "", serviceId: "",
readId: "", readId: "",
writeId: "", writeId: "",
notifyId: "", notifyId: "",
isSend: true, isSend: true,
Unload: false, Unload: false,
isConnection: 0, isConnection: 0,
data01: {}, data01: {},
data02: {}, data02: {},
BLEResult: {} BLEResult: {}
} }
}, },
computed: { computed: {
...mapState(["user", "isConnected", "isBluetoothTyle"]), ...mapState(["user", "isConnected", "isBluetoothTyle"]),
userInfo() { userInfo() {
return this.user return this.user
} }
}, },
onUnload: function() { onUnload: async function() {
let that = this let that = this
console.log('F01PROonUnload-' + that.Unload) if (!that.Unload) {
if (!that.Unload) { clearTimeout(myTime)
clearTimeout(myTime)
that.closeBLEConnection()
that.closeBluetoothAdapter()
that.$store.state.devicesList2 = [] that.$store.state.devicesList2 = []
console.log("页面返回onUnload")
} that.closeBLEConnection()
}, that.closeBluetoothAdapter()
watch: {
isConnected: function() { if(that.isConnection != 1) {
let that = this let pages = getCurrentPages();
if (!that.isConnected) { pages[pages.length - 2].$vm.islink = -1;
pages[pages.length - 2].$vm.textLink = '开始连接';
}
}
},
watch: {
isConnected: function() {
let that = this
if (!that.isConnected) {
console.log('F01PROisConnected-' + that.isConnected) console.log('F01PROisConnected-' + that.isConnected)
that.handleBack() that.handleBack()
that.isConnection = 2 that.isConnection = 2
} }
}, },
isBluetoothTyle: function() { isBluetoothTyle: function() {
let that = this let that = this
if (!that.isBluetoothTyle) { if (!that.isBluetoothTyle) {
console.log('F01PROisBluetoothTyle-' + that.isBluetoothTyle) console.log('F01PROisBluetoothTyle-' + that.isBluetoothTyle)
that.handleBack() that.handleBack()
that.isConnection = 2 that.isConnection = 2
} }
}, },
}, },
onLoad(options) { onLoad(options) {
let that = this let that = this
that.textW = "" that.textW = ""
that.textH = "" that.textH = ""
console.log("options", options) console.log("options", options)
if (options && options.deviceId) { if (options && options.deviceId) {
that.deviceId = options.deviceId that.deviceId = options.deviceId
that.createBLEConnection() that.createBLEConnection()
} }
that.onBLEConnectionStateChange() that.onBLEConnectionStateChange()
uni.onBluetoothAdapterStateChange(function(res) { uni.onBluetoothAdapterStateChange(function(res) {
that.$store.commit("changeBluetooth", res.available); that.$store.commit("changeBluetooth", res.available);
}) })
}, },
methods: { methods: {
// //
openBluetoothAdapter() { openBluetoothAdapter() {
let that = this let that = this
that.textW = "" that.textW = ""
that.textH = "" that.textH = ""
that.isSend = true that.isSend = true
that.Unload = false that.Unload = false
uni.openBluetoothAdapter({ uni.openBluetoothAdapter({
success: e => { success: e => {
that.isConnection = 0 that.isConnection = 0
that.startBluetoothDeviceDiscovery() that.startBluetoothDeviceDiscovery()
console.log('初始化蓝牙成功:' + e.errMsg); console.log('初始化蓝牙成功:' + e.errMsg);
}, },
fail: e => { fail: e => {
that.isConnection = 2 that.isConnection = 2
that.$tools.msg("请确定设备是开机状态、手机蓝牙权限已打开!") that.$tools.msg("请确定设备是开机状态、手机蓝牙权限已打开!")
} }
}); });
}, },
// //
onBLEConnectionStateChange() { onBLEConnectionStateChange() {
let that = this let that = this
uni.onBLEConnectionStateChange(function(res) { uni.onBLEConnectionStateChange(function(res) {
console.log('F01PROonBLEConnectionStateChange-' + that.Unload) console.log('F01PROonBLEConnectionStateChange-' + res.connected)
if (!res.connected) { if (!res.connected) {
that.Unload = true that.Unload = true
that.isConnection = 2 that.isConnection = 2
clearTimeout(myTime); clearTimeout(myTime);
that.closeBLEConnection() that.closeBLEConnection()
that.closeBluetoothAdapter() that.closeBluetoothAdapter()
} }
that.$store.commit("changeConnected", res.connected); that.$store.commit("changeConnected", res.connected);
}) })
}, },
// //
startBluetoothDeviceDiscovery() { startBluetoothDeviceDiscovery() {
let that = this let that = this
uni.startBluetoothDevicesDiscovery({ uni.startBluetoothDevicesDiscovery({
allowDuplicatesKey: false, allowDuplicatesKey: false,
interval: 500, // interval: 500, //
success: res => { success: res => {
that.isConnection = 0 that.isConnection = 0
that.onBluetoothDeviceFound(); that.onBluetoothDeviceFound();
}, },
fail: res => { fail: res => {
that.isConnection = 2 that.isConnection = 2
that.$tools.msg("请确定设备是开机状态、手机蓝牙权限已打开!") that.$tools.msg("请确定设备是开机状态、手机蓝牙权限已打开!")
} }
}); });
}, },
/** /**
* 发现外围设备 * 发现外围设备
*/ */
onBluetoothDeviceFound() { onBluetoothDeviceFound() {
var that = this; var that = this;
that.isConnection = 0 that.isConnection = 0
uni.onBluetoothDeviceFound(res => { uni.onBluetoothDeviceFound(res => {
res.devices.forEach(device => { res.devices.forEach(device => {
if (!device.name && !device.localName) { if (!device.name && !device.localName) {
return return
} }
if (device.name.indexOf('AiLink_') != -1 || device.name.indexOf('PCF01') != -1 || (device.localName && (device.localName if (device.name.indexOf('AiLink_') != -1 || device.name.indexOf('PCF01') != -1 || (device
.indexOf('AiLink_') != -1 || device.localName .localName && (device.localName
.indexOf('PCF01') != -1))) { .indexOf('AiLink_') != -1 || device.localName
clearTimeout(myTime); .indexOf('PCF01') != -1))) {
if (device.deviceId.indexOf(that.deviceId) != -1) { clearTimeout(myTime);
that.stopBluetoothDevicesDiscovery() if (device.deviceId.indexOf(that.deviceId) != -1) {
that.deviceId = device.deviceId that.stopBluetoothDevicesDiscovery()
const foundDevices = that.$store.state.devicesList2 that.deviceId = device.deviceId
const idx = that.$tools.inArray(foundDevices, "deviceId", device.deviceId) const foundDevices = that.$store.state.devicesList2
if (idx === -1) { const idx = that.$tools.inArray(foundDevices, "deviceId", device.deviceId)
that.$store.state.devicesList2.push(device); if (idx === -1) {
} else { that.$store.state.devicesList2.push(device);
that.$store.state.devicesList2[idx] = device } else {
} that.$store.state.devicesList2[idx] = device
that.createBLEConnection() }
return; that.createBLEConnection()
} return;
} }
}) }
}); })
}, });
/** },
* 停止搜索蓝牙设备 /**
*/ * 停止搜索蓝牙设备
stopBluetoothDevicesDiscovery() { */
uni.stopBluetoothDevicesDiscovery({ stopBluetoothDevicesDiscovery() {
success: e => { uni.stopBluetoothDevicesDiscovery({
console.log("停止搜索蓝牙设备", e) success: e => {
}, console.log("停止搜索蓝牙设备", e)
}); },
}, });
// },
createBLEConnection() { //
let that = this; createBLEConnection() {
uni.createBLEConnection({ let that = this;
deviceId: that.deviceId, uni.createBLEConnection({
success: res => { deviceId: that.deviceId,
console.log("设备连接成功获取设备的services", res); success: res => {
that.isConnection = 0 console.log("设备连接成功获取设备的services", res);
that.getBLEDeviceServices(); that.isConnection = 0
}, that.getBLEDeviceServices();
fail: res => { },
that.isConnection = 2 fail: res => {
console.log("设备连接失败,请重新连接", res); that.isConnection = 2
} console.log("设备连接失败,请重新连接", res);
}); }
}, });
/** },
* 获取设备的UUID /**
*/ * 获取设备的UUID
getBLEDeviceServices() { */
let serviceList = []; getBLEDeviceServices() {
let that = this; let serviceList = [];
uni.getBLEDeviceServices({ let that = this;
deviceId: that.deviceId, uni.getBLEDeviceServices({
success: res => { deviceId: that.deviceId,
console.log("获取设备的UUID成功", res) success: res => {
serviceList = res.services; console.log("获取设备的UUID成功", res)
for (let i = 0; i < serviceList.length; i++) { serviceList = res.services;
let service = serviceList[i]; for (let i = 0; i < serviceList.length; i++) {
if (service.uuid.indexOf('FFE0') != -1) { let service = serviceList[i];
that.serviceId = service.uuid; if (service.uuid.indexOf('FFE0') != -1) {
that.isConnection = 1 that.serviceId = service.uuid;
that.getBLEDeviceCharacteristics(that.deviceId, service.uuid); that.isConnection = 1
console.log("设备的FFE0的serviceId ", that.serviceId); that.getBLEDeviceCharacteristics(that.deviceId, service.uuid);
break; console.log("设备的FFE0的serviceId ", that.serviceId);
} break;
} }
}, }
fail: res => { },
console.log('获取设备的UUID失败:', res) fail: res => {
} console.log('获取设备的UUID失败:', res)
}); }
}, });
/** },
* 获取指定服务的特征值 /**
*/ * 获取指定服务的特征值
getBLEDeviceCharacteristics(deviceId, serviceId) { */
let characteristicsList = []; getBLEDeviceCharacteristics(deviceId, serviceId) {
let that = this; let characteristicsList = [];
uni.getBLEDeviceCharacteristics({ let that = this;
deviceId: deviceId, uni.getBLEDeviceCharacteristics({
serviceId: serviceId, deviceId: deviceId,
success: res => { serviceId: serviceId,
console.log("服务的特征值成功", res) success: res => {
characteristicsList = res.characteristics; console.log("服务的特征值成功", res)
for (let i = 0; i < characteristicsList.length; i++) { characteristicsList = res.characteristics;
let item = characteristicsList[i]; for (let i = 0; i < characteristicsList.length; i++) {
if (item.uuid.indexOf('0000FFE1') != -1) { let item = characteristicsList[i];
that.uuid1 = item.uuid // if (item.uuid.indexOf('0000FFE1') != -1) {
} else if (item.uuid.indexOf('0000FFE2') != -1) { that.uuid1 = item.uuid //
that.uuid2 = item.uuid // } else if (item.uuid.indexOf('0000FFE2') != -1) {
} else if (item.uuid.indexOf('0000FFE3') != -1) { that.uuid2 = item.uuid //
that.uuid3 = item.uuid // } else if (item.uuid.indexOf('0000FFE3') != -1) {
} that.uuid3 = item.uuid //
} }
// }
uni.notifyBLECharacteristicValueChange({ //
deviceId, uni.notifyBLECharacteristicValueChange({
serviceId, deviceId,
characteristicId: that.uuid2, serviceId,
state: true, characteristicId: that.uuid2,
}) state: true,
uni.notifyBLECharacteristicValueChange({ })
deviceId, uni.notifyBLECharacteristicValueChange({
serviceId, deviceId,
characteristicId: that.uuid3, serviceId,
state: true, characteristicId: that.uuid3,
}) state: true,
// })
console.log("初始化插件", that.$store.state.devicesList2) //
that.$store.state.devicesList2[0].serviceId = that.serviceId console.log("初始化插件", that.$store.state.devicesList2)
that.$store.state.devicesList2[0].serviceId = that.serviceId
plugin.initPlugin(res.characteristics, that.$store.state.devicesList2[0])
uni.onBLECharacteristicValueChange((characteristic) => { plugin.initPlugin(res.characteristics, that.$store.state.devicesList2[0])
let bleData = plugin.parseBleData(characteristic.value) uni.onBLECharacteristicValueChange((characteristic) => {
let dw1 = "kg" let bleData = plugin.parseBleData(characteristic.value)
console.log("bleData", bleData) let dw1 = "kg"
if (bleData.status == 0) { console.log("bleData", bleData)
let sex0 = that.userInfo.gender == 1 ? 1 : 0 if (bleData.status == 0) {
let sex = "0x0" + sex0.toString(16) let sex0 = that.userInfo.gender == 1 ? 1 : 0
let age = "0x" + that.userInfo.age.toString(16) let sex = "0x0" + sex0.toString(16)
let height = "0x" + that.userInfo.height.toString(16) let age = "0x" + that.userInfo.age.toString(16)
let arr = [0x01, parseInt(sex), parseInt(age), parseInt(height), 0x00] let height = "0x" + that.userInfo.height.toString(16)
plugin.sendDataOfA7(arr) let arr = [0x01, parseInt(sex), parseInt(age), parseInt(height), 0x00]
console.log("握手成功", arr) plugin.sendDataOfA7(arr)
} else if (bleData.status == 1) { console.log("握手成功", arr)
let payload = that.$tools.ab2hex(bleData.data, '') } else if (bleData.status == 1) {
let typeInfo = payload.substring(4, 6) let payload = that.$tools.ab2hex(bleData.data, '')
let type = payload.substring(0, 2) let typeInfo = payload.substring(4, 6)
console.log("开始测量", payload) let type = payload.substring(0, 2)
if(type == '03') { console.log("开始测量", payload)
if (type == '03') {
console.log('MCU主动请求用户数据') console.log('MCU主动请求用户数据')
let sex0 = that.userInfo.gender == 1 ? 1 : 0 let sex0 = that.userInfo.gender == 1 ? 1 : 0
let sex = "0x0" + sex0.toString(16) let sex = "0x0" + sex0.toString(16)
@ -301,185 +307,182 @@
let arr = [0x01, parseInt(sex), parseInt(age), parseInt(height), 0x00] let arr = [0x01, parseInt(sex), parseInt(age), parseInt(height), 0x00]
plugin.sendDataOfA7(arr) plugin.sendDataOfA7(arr)
} }
if (type == "10" || type == "30" || type == "40") { // if (type == "10" || type == "30" || type == "40") { //
let data = parseInt(payload.substring(6, 12), 16) let data = parseInt(payload.substring(6, 12), 16)
let msg = parseInt(payload.substring(12, 14), 16).toString(2) let msg = parseInt(payload.substring(12, 14), 16).toString(2)
let dw = that.$tools.PrefixZero(msg, 8).substring(4, 8) let dw = that.$tools.PrefixZero(msg, 8).substring(4, 8)
let num = that.$tools.PrefixZero(msg, 8).substring(0, 4) let num = that.$tools.PrefixZero(msg, 8).substring(0, 4)
let dw1 = "kg" let dw1 = "kg"
if (dw == "0001") { if (dw == "0001") {
dw1 = '斤' dw1 = '斤'
}
if (dw == "0110") {
dw1 = 'lb'
}
if (num == "0001") {
data = data / 10
}
if (num == "0010") {
data = data / 100
}
if (num == "0011") {
data = data / 1000
}
if (typeInfo == "01") {
that.textW = "您的实时体重是:" + data + dw1
}
if (typeInfo == "02") {
that.textW = "您的体重是:" + data + dw1
that.weight = data + dw1
}
}
if (type == "14" || type == "41") { //
let height = parseInt(payload.substring(4, 8), 16)
let numH = parseInt(payload.substring(10, 12), 16)
if (numH == "1") {
height = height / 10
}
if (numH == "2") {
height = height / 100
}
that.textH = "您的身高是:" + height + "cm"
that.height = height
console.log("身高模式:", that.height)
}
if (type == "11") { //
if (typeInfo == "01") { //
that.textImp = '正在测量体脂:请双手紧握扶手'
} }
if (typeInfo == "02") { if (dw == "0110") {
that.imp = 0 dw1 = 'lb'
}
if (num == "0001") {
data = data / 10
}
if (num == "0010") {
data = data / 100
}
if (num == "0011") {
data = data / 1000
}
if (typeInfo == "01") {
that.textW = "您的实时体重是:" + data + dw1
}
if (typeInfo == "02") {
that.textW = "您的体重是:" + data + dw1
that.weight = data + dw1
}
}
if (type == "14" || type == "41") { //
let height = parseInt(payload.substring(4, 8), 16)
let numH = parseInt(payload.substring(10, 12), 16)
if (numH == "1") {
height = height / 10
}
if (numH == "2") {
height = height / 100
}
that.textH = "您的身高是:" + height + "cm"
that.height = height
console.log("身高模式:", that.height)
}
if (type == "11") { //
if (typeInfo == "01") { //
that.textImp = '正在测量体脂:请双手紧握扶手'
}
if (typeInfo == "02") {
that.imp = 0
that.textImp = "" that.textImp = ""
} }
if (typeInfo == "04") { if (typeInfo == "04") {
that.textImp = "" that.textImp = ""
that.imp = parseInt(payload.substring(8, 12), 16) that.imp = parseInt(payload.substring(8, 12), 16)
} }
console.log("阻抗:", that.imp) console.log("阻抗:", that.imp)
} }
if (type == '15') { if (type == '15') {
if (typeInfo == "01") { if (typeInfo == "01") {
that.data01 = { that.data01 = {
bodyage: parseInt(payload.substring(26, 28), bodyage: parseInt(payload.substring(26, 28),
16), 16),
fat_r: parseInt(payload.substring(6, 10), fat_r: parseInt(payload.substring(6, 10),
16) / 10, 16) / 10,
muscle: parseInt(payload.substring(18, 22), muscle: parseInt(payload.substring(18, 22),
16) / 10, 16) / 10,
kcal: parseInt(payload.substring(22, 26), kcal: parseInt(payload.substring(22, 26),
16), 16),
visceral: parseInt(payload.substring(14, visceral: parseInt(payload.substring(14,
18), 16), 18), 16),
sfr: parseInt(payload.substring(10, 14), sfr: parseInt(payload.substring(10, 14),
16) / 10, 16) / 10,
} }
} }
if (typeInfo == '02') { if (typeInfo == '02') {
that.data02 = { that.data02 = {
water: parseInt(payload.substring(10, 14), water: parseInt(payload.substring(10, 14),
16) / 10, 16) / 10,
bone: parseInt(payload.substring(6, 10), bone: parseInt(payload.substring(6, 10),
16) / 10, 16) / 10,
fatlevlval: parseInt(payload.substring(24, fatlevlval: parseInt(payload.substring(24,
26), 16) / 26), 16) /
10, 10,
protein: parseInt(payload.substring(14, 18), protein: parseInt(payload.substring(14, 18),
16) / 10, 16) / 10,
bmi: parseInt(payload.substring(18, 22), bmi: parseInt(payload.substring(18, 22),
16) / 10, 16) / 10,
} }
} }
console.log("体脂数据", that.data01, that.data02) console.log("体脂数据", that.data01, that.data02)
that.BLEResult.info = Object.assign(that.data01, that.data02) that.BLEResult.info = Object.assign(that.data01, that.data02)
} }
if (type == "80") { // if (type == "80") { //
that.BLEResult.weight = that.weight that.BLEResult.weight = that.weight
that.BLEResult.adc = that.imp ? that.imp : 0 that.BLEResult.adc = that.imp ? that.imp : 0
that.BLEResult.height = (that.height ? that.height : that.userInfo.height) + 'cm' that.BLEResult.height = (that.height ? that.height : that.userInfo.height) + 'cm'
that.BLEResult.aud_id = that.userInfo.id that.BLEResult.aud_id = that.userInfo.id
console.log("体脂成功:", that.BLEResult) console.log("体脂成功:", that.BLEResult)
that.handleGetMeasure(that.BLEResult) that.handleGetMeasure(that.BLEResult)
} }
} }
}) })
}, },
fail: res => { fail: res => {
console.log('获取特征值失败:', JSON.stringify(res)) console.log('获取特征值失败:', JSON.stringify(res))
} }
}) })
}, },
// //
handleGetMeasure(data) { handleGetMeasure(data) {
console.log("保存结果") console.log("保存结果")
let that = this let that = this
that.$model.getmeasurefunit(data).then(res => { that.$model.getmeasurefunit(data).then(res => {
if (res.code == 0) { if (res.code == 0) {
that.$store.dispatch('getUserInfo', { that.$store.dispatch('getUserInfo', {
aud_id: uni.getStorageSync('userid') aud_id: uni.getStorageSync('userid')
}) })
that.$store.dispatch("getResult", { that.$store.dispatch("getResult", {
aud_id: uni.getStorageSync('userid') aud_id: uni.getStorageSync('userid')
}) })
setTimeout(() => { setTimeout(() => {
uni.showToast({ uni.showToast({
title: '测量成功' title: '测量成功'
}) })
},500) }, 500)
} else { } else {
uni.showToast({ uni.showToast({
title: res.message, title: res.message,
icon:"error" icon: "error"
}) })
} }
that.Unload = true that.Unload = true
setTimeout(function() { setTimeout(function() {
that.closeBLEConnection() that.closeBLEConnection()
that.closeBluetoothAdapter() that.closeBluetoothAdapter()
that.$store.state.devicesList2 = [] that.$store.state.devicesList2 = []
// setTimeout(() => {
// let pages = getCurrentPages(); uni.switchTab({
// pages[pages.length - 2].$vm.getBlereload(); url: "/pages/home/home"
// },1000) })
uni.switchTab({ }, 1000)
url: "/pages/home/home" })
}) },
}, 1000) /**
}) * 断开蓝牙模块
}, */
/** closeBluetoothAdapter() {
* 断开蓝牙模块 let that = this;
*/ uni.closeBluetoothAdapter({
closeBluetoothAdapter() { success: res => {
let that = this; console.log('F01PRO蓝牙模块关闭成功');
uni.closeBluetoothAdapter({ }
success: res => { })
console.log('F01PRO蓝牙模块关闭成功'); },
} handleBack() {
}) let that = this
}, that.Unload = true
handleBack() {
let that = this
that.Unload = true
console.log('F01PROhandleBack'); console.log('F01PROhandleBack');
that.stopBluetoothDevicesDiscovery() // that.stopBluetoothDevicesDiscovery() //
that.closeBLEConnection() that.closeBLEConnection()
that.closeBluetoothAdapter() that.closeBluetoothAdapter()
that.$store.state.devicesList2 = [] that.$store.state.devicesList2 = []
}, },
/** /**
* 断开蓝牙连接 * 断开蓝牙连接
*/ */
closeBLEConnection() { closeBLEConnection() {
var that = this; var that = this;
uni.closeBLEConnection({ uni.closeBLEConnection({
deviceId: that.deviceId, deviceId: that.deviceId,
success: res => { success: res => {
console.log('F01PRO断开蓝牙连接成功'); console.log('F01PRO断开蓝牙连接成功');
} }
}); });
}, },
}, },
} }
</script> </script>
<style scoped lang="scss"> <style scoped lang="scss">

View File

@ -382,7 +382,7 @@
watch: { watch: {
isConnected: function() { isConnected: function() {
let that = this let that = this
console.log("HomeisConnected-", that.isConnected) console.log("------------HomeisConnected-", that.isConnected)
if (!that.isConnected) { if (!that.isConnected) {
that.textLink = "开始连接" that.textLink = "开始连接"
that.islink = -1 that.islink = -1
@ -390,7 +390,7 @@
}, },
isBluetoothTyle: function() { isBluetoothTyle: function() {
let that = this let that = this
console.log("HomeisBluetoothTyle-", that.isBluetoothTyle) console.log("-------------HomeisBluetoothTyle-", that.isBluetoothTyle)
if (!that.isBluetoothTyle) { if (!that.isBluetoothTyle) {
that.textLink = "开始连接" that.textLink = "开始连接"
that.islink = -1 that.islink = -1
@ -660,7 +660,6 @@
let that = this let that = this
const foundDevices = that.devicesList const foundDevices = that.devicesList
const idx = that.$tools.inArray(foundDevices, "deviceId", device.deviceId) const idx = that.$tools.inArray(foundDevices, "deviceId", device.deviceId)
console.log("1111111", device.name)
if (idx === -1) { if (idx === -1) {
// //
if (device.name.toLowerCase().indexOf("pcl") != -1) { if (device.name.toLowerCase().indexOf("pcl") != -1) {

File diff suppressed because one or more lines are too long

View File

@ -1 +1 @@
<view class="data-v-5409745b"><view class="content weightPages data-v-5409745b"><block wx:if="{{isConnection==0}}"><view class="title data-v-5409745b">连接中,请稍后</view></block><block wx:if="{{isConnection==1}}"><view class="title data-v-5409745b">连接成功,请开始测量</view></block><block wx:if="{{isConnection==2}}"><view data-event-opts="{{[['tap',[['openBluetoothAdapter',['$event']]]]]}}" class="title data-v-5409745b" bindtap="__e">连接失败,点击重新连接</view></block><view class="text data-v-5409745b">{{textW}}</view><view class="text data-v-5409745b">{{textH}}</view><block wx:if="{{textImp!=''}}"><view class="text data-v-5409745b">{{textImp}}</view></block><view class="image data-v-5409745b" style="margin-top:200rpx;"><image src="/pageTwo/static/F018P01.gif" mode="widthFix" class="data-v-5409745b"></image></view><view class="tips data-v-5409745b"><text class="data-v-5409745b">请确保:</text><text class="data-v-5409745b">1.请确定设备是开机状态</text><text class="data-v-5409745b">2.请确定手机蓝牙、位置信息已打开</text><text class="data-v-5409745b">3.ios系统需打开设置—>应用—>微信里的蓝牙权限</text></view></view></view> <view class="data-v-4c084893"><view class="content weightPages data-v-4c084893"><block wx:if="{{isConnection==0}}"><view class="title data-v-4c084893">连接中,请稍后</view></block><block wx:if="{{isConnection==1}}"><view class="title data-v-4c084893">连接成功,请开始测量</view></block><block wx:if="{{isConnection==2}}"><view data-event-opts="{{[['tap',[['openBluetoothAdapter',['$event']]]]]}}" class="title data-v-4c084893" bindtap="__e">连接失败,点击重新连接</view></block><view class="text data-v-4c084893">{{textW}}</view><view class="text data-v-4c084893">{{textH}}</view><block wx:if="{{textImp!=''}}"><view class="text data-v-4c084893">{{textImp}}</view></block><view class="image data-v-4c084893" style="margin-top:200rpx;"><image src="/pageTwo/static/F018P01.gif" mode="widthFix" class="data-v-4c084893"></image></view><view class="tips data-v-4c084893"><text class="data-v-4c084893">请确保:</text><text class="data-v-4c084893">1.请确定设备是开机状态</text><text class="data-v-4c084893">2.请确定手机蓝牙、位置信息已打开</text><text class="data-v-4c084893">3.ios系统需打开设置—>应用—>微信里的蓝牙权限</text></view></view></view>

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -140,6 +140,8 @@ Object.defineProperty(exports, "__esModule", {
value: true value: true
}); });
exports.default = void 0; exports.default = void 0;
var _regenerator = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/regenerator */ 462));
var _asyncToGenerator2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/asyncToGenerator */ 465));
var _defineProperty2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/defineProperty */ 11)); var _defineProperty2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/defineProperty */ 11));
var _vuex = __webpack_require__(/*! vuex */ 34); var _vuex = __webpack_require__(/*! vuex */ 34);
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; } function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
@ -174,17 +176,37 @@ var _default = {
return this.user; return this.user;
} }
}), }),
onUnload: function onUnload() { onUnload: function () {
var that = this; var _onUnload = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee() {
console.log('F01PROonUnload-' + that.Unload); var that, pages;
if (!that.Unload) { return _regenerator.default.wrap(function _callee$(_context) {
clearTimeout(myTime); while (1) {
that.closeBLEConnection(); switch (_context.prev = _context.next) {
that.closeBluetoothAdapter(); case 0:
that.$store.state.devicesList2 = []; that = this;
console.log("页面返回onUnload"); if (!that.Unload) {
clearTimeout(myTime);
that.$store.state.devicesList2 = [];
that.closeBLEConnection();
that.closeBluetoothAdapter();
if (that.isConnection != 1) {
pages = getCurrentPages();
pages[pages.length - 2].$vm.islink = -1;
pages[pages.length - 2].$vm.textLink = '开始连接';
}
}
case 2:
case "end":
return _context.stop();
}
}
}, _callee, this);
}));
function onUnload() {
return _onUnload.apply(this, arguments);
} }
}, return onUnload;
}(),
watch: { watch: {
isConnected: function isConnected() { isConnected: function isConnected() {
var that = this; var that = this;
@ -241,7 +263,7 @@ var _default = {
onBLEConnectionStateChange: function onBLEConnectionStateChange() { onBLEConnectionStateChange: function onBLEConnectionStateChange() {
var that = this; var that = this;
uni.onBLEConnectionStateChange(function (res) { uni.onBLEConnectionStateChange(function (res) {
console.log('F01PROonBLEConnectionStateChange-' + that.Unload); console.log('F01PROonBLEConnectionStateChange-' + res.connected);
if (!res.connected) { if (!res.connected) {
that.Unload = true; that.Unload = true;
that.isConnection = 2; that.isConnection = 2;
@ -545,10 +567,6 @@ var _default = {
that.closeBLEConnection(); that.closeBLEConnection();
that.closeBluetoothAdapter(); that.closeBluetoothAdapter();
that.$store.state.devicesList2 = []; that.$store.state.devicesList2 = [];
// setTimeout(() => {
// let pages = getCurrentPages();
// pages[pages.length - 2].$vm.getBlereload();
// },1000)
uni.switchTab({ uni.switchTab({
url: "/pages/home/home" url: "/pages/home/home"
}); });

View File

@ -436,7 +436,7 @@ var _default = {
watch: { watch: {
isConnected: function isConnected() { isConnected: function isConnected() {
var that = this; var that = this;
console.log("HomeisConnected-", that.isConnected); console.log("------------HomeisConnected-", that.isConnected);
if (!that.isConnected) { if (!that.isConnected) {
that.textLink = "开始连接"; that.textLink = "开始连接";
that.islink = -1; that.islink = -1;
@ -444,7 +444,7 @@ var _default = {
}, },
isBluetoothTyle: function isBluetoothTyle() { isBluetoothTyle: function isBluetoothTyle() {
var that = this; var that = this;
console.log("HomeisBluetoothTyle-", that.isBluetoothTyle); console.log("-------------HomeisBluetoothTyle-", that.isBluetoothTyle);
if (!that.isBluetoothTyle) { if (!that.isBluetoothTyle) {
that.textLink = "开始连接"; that.textLink = "开始连接";
that.islink = -1; that.islink = -1;
@ -713,7 +713,6 @@ var _default = {
var that = this; var that = this;
var foundDevices = that.devicesList; var foundDevices = that.devicesList;
var idx = that.$tools.inArray(foundDevices, "deviceId", device.deviceId); var idx = that.$tools.inArray(foundDevices, "deviceId", device.deviceId);
console.log("1111111", device.name);
if (idx === -1) { if (idx === -1) {
// 体脂秤 // 体脂秤
if (device.name.toLowerCase().indexOf("pcl") != -1) { if (device.name.toLowerCase().indexOf("pcl") != -1) {