uu
This commit is contained in:
parent
d54d9268a3
commit
540ee738f1
@ -5,7 +5,7 @@
|
|||||||
<view class="blcok-white">
|
<view class="blcok-white">
|
||||||
<view >
|
<view >
|
||||||
<u-row custom-style="gap: 10rpx;">
|
<u-row custom-style="gap: 10rpx;">
|
||||||
<u-button @click="discoveryPrinter">搜索周边设备</u-button>
|
<u-button @click="discoveryPrinter" type="info" :loading="searchLoading" loadingSize="24" loadingText="搜索中">搜索周边设备</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>
|
||||||
@ -118,6 +118,7 @@ export default {
|
|||||||
canvas_width: 240,
|
canvas_width: 240,
|
||||||
canvas_height: 240,
|
canvas_height: 240,
|
||||||
curTab: 0,
|
curTab: 0,
|
||||||
|
searchLoading: false,
|
||||||
devices: [],
|
devices: [],
|
||||||
deviceId: '',
|
deviceId: '',
|
||||||
serverList: [],
|
serverList: [],
|
||||||
@ -130,6 +131,9 @@ export default {
|
|||||||
// 初始化蓝牙模块
|
// 初始化蓝牙模块
|
||||||
this.openBluetoothAdapter()
|
this.openBluetoothAdapter()
|
||||||
},
|
},
|
||||||
|
unmounted() {
|
||||||
|
this.stopDiscoveryPrinter()
|
||||||
|
},
|
||||||
methods: {
|
methods: {
|
||||||
changeTab(type) {
|
changeTab(type) {
|
||||||
this.curTab = type
|
this.curTab = type
|
||||||
@ -154,6 +158,7 @@ export default {
|
|||||||
discoveryPrinter () {
|
discoveryPrinter () {
|
||||||
var _this = this
|
var _this = this
|
||||||
_this.devices = []
|
_this.devices = []
|
||||||
|
_this.searchLoading = true
|
||||||
_this.curTab = 0
|
_this.curTab = 0
|
||||||
uni.startBluetoothDevicesDiscovery({
|
uni.startBluetoothDevicesDiscovery({
|
||||||
complete (e) {
|
complete (e) {
|
||||||
@ -174,6 +179,7 @@ export default {
|
|||||||
},
|
},
|
||||||
// 停止搜寻附近的蓝牙外围设备
|
// 停止搜寻附近的蓝牙外围设备
|
||||||
async stopDiscoveryPrinter () {
|
async stopDiscoveryPrinter () {
|
||||||
|
this.searchLoading = false
|
||||||
let res = await this.renderPic()
|
let res = await this.renderPic()
|
||||||
uni.stopBluetoothDevicesDiscovery()
|
uni.stopBluetoothDevicesDiscovery()
|
||||||
},
|
},
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user