This commit is contained in:
aihe 2024-05-10 02:42:59 +08:00
parent f2babe0dd9
commit 2e99e87872

View File

@ -7,7 +7,7 @@
<u-row custom-style="gap: 10rpx;"> <u-row custom-style="gap: 10rpx;">
<u-button @click="discoveryPrinter">搜索周边设备</u-button> <u-button @click="discoveryPrinter">搜索周边设备</u-button>
<u-button @click="stopDiscoveryPrinter">停止搜索</u-button> <u-button @click="stopDiscoveryPrinter">停止搜索</u-button>
<u-button @click="writeBLECharacteristicValue" type="primary" disabled="!(deviceId && !serviceId && characteristicId)">打印</u-button> <u-button @click="writeBLECharacteristicValue" type="primary" :disabled="!(deviceId && serviceId && characteristicId)">打印</u-button>
</u-row> </u-row>
</view> </view>
<view class=""> <view class="">
@ -15,7 +15,7 @@
<u-steps activeColor="#969799" :current="curTab" direction="column" dot="true"> <u-steps activeColor="#969799" :current="curTab" direction="column" dot="true">
<u-steps-item v-for="(item, index) in conInfos" @click="changeTab(index)"> <u-steps-item v-for="(item, index) in conInfos" @click="changeTab(index)">
<template v-slot:title> <template v-slot:title>
<view class="clr-sub pl-20">{{item.title}}</view> <view :class="`${index == curTab ? 'clr-prm' : 'clr-sub'} pl-20`">{{item.title}}</view>
</template> </template>
<template v-slot:desc> <template v-slot:desc>
<view class="mt-10 pl-20">{{item.desc}}</view> <view class="mt-10 pl-20">{{item.desc}}</view>
@ -119,11 +119,11 @@ export default {
canvas_height: 240, canvas_height: 240,
curTab: 0, curTab: 0,
devices: [], devices: [],
deviceId: '', deviceId: 'dda',
serverList: [], serverList: [],
serviceId: '', serviceId: 'dda',
characteristics: [], characteristics: [],
characteristicId: '' characteristicId: 'dd'
} }
}, },
mounted () { mounted () {
@ -161,7 +161,11 @@ export default {
// ArrayBuffer转16进度字符串示例 // ArrayBuffer转16进度字符串示例
uni.onBluetoothDeviceFound(devices => { uni.onBluetoothDeviceFound(devices => {
console.log("========devices=====", devices) console.log("========devices=====", devices)
_this.devices.push(devices.devices[0]) let curDvs = devices?.devices?.[0] || {}
// 过滤重复的
if(curDvs.deviceId && _this.devices.map(t=> t.deviceId).indexOf(curDvs.deviceId) == -1) {
_this.devices.push(curDvs)
}
}) })
} }
} }