wangfukang 3 years ago
parent
commit
59cfc30a0a
  1. 63
      components/kk-printer/index.vue

63
components/kk-printer/index.vue

@ -6,14 +6,6 @@
<view class="kk-shadow" :class="isShowSearch?'show':''" @tap="handleSearchClose">
<view class="kk-modal" @tap.stop="doNothing">
<view class="kk-search-device">
<!-- <view class="kk-filter-wrap">
<view class="filter-title">根据SRRI过滤设备</view>
<slider @change="handleSRRIChange" max='-20' min='-100' value="-95" show-value/>
</view>
<view class="kk-filter-wrap">
<view class="filter-title">根据蓝牙名过滤</view>
<input type="text" placeholder-class="kk-placeholder-class" placeholder="请输入蓝牙名字或设备ID搜索" v-model="filterName" />
</view> -->
<view class="kk-btn-wrap">
<view class="kk-btn-item confirm-btn" @tap="sousuo" v-if="!isSearching">
搜索设备
@ -143,7 +135,8 @@
console.log('初始化蓝牙模块', res2)
that.sousuo()
},
fail: (res) => {
fail: (res) => {
console.log('初始化蓝牙模块', res)
that.tui.toast('初始化失败', res)
this.isShowSearch = true
uni.hideLoading();
@ -160,8 +153,17 @@
that.jiantingshebei()
},
fail(err) {
console.log('获取设备失败', err)
that.tui.toast('获取设备失败', err)
wx.closeBLEConnection({
deviceId:uni.getStorageSync('deviceId'),
success (res) {
console.log(res)
}
})
uni.removeStorageSync('deviceId');
this.isShowSearch = true
this.sousuo()
uni.hideLoading();
}
})
@ -179,6 +181,7 @@
let that = this;
if(uni.getStorageSync('deviceId')){
console.log("111")
// that.huoqufuwu(uni.getStorageSync('deviceId'))
that.lianejieshebei(uni.getStorageSync('deviceId'))
}else{
console.log("222")
@ -203,12 +206,27 @@
wx.createBLEConnection({//555
deviceId: deviceId, // 搜索到设备的 deviceId
success: () => {
this.isShowSearch = false
console.log('连接设备成功')
that.huoqufuwu(deviceId)
},
fail: (res) => {
console.log('连接设备失败',res)
that.tui.toast('连接设备失败', res)
this.isShowSearch = true
if(uni.getStorageSync('deviceId')){
this.huoqufuwu(uni.getStorageSync('deviceId'))
}else{
wx.closeBLEConnection({
deviceId:uni.getStorageSync('deviceId'),
success (res) {
console.log(res)
}
})
uni.removeStorageSync('deviceId')
this.sousuo()
this.isShowSearch = true
}
uni.hideLoading();
}
})
@ -223,7 +241,14 @@
that.duxietezhengzhi(deviceId,res5)
},
fail: (res) => {
console.log(res)
that.tui.toast('获取服务失败', res)
wx.closeBLEConnection({
deviceId:uni.getStorageSync('deviceId'),
success (res1) {
console.log(res1)
}
})
this.isShowSearch = true
uni.hideLoading();
}
@ -251,6 +276,12 @@
},
fail: (res) => {
that.tui.toast('读写特征值失败', res)
wx.closeBLEConnection({
deviceId:uni.getStorageSync('deviceId'),
success (res) {
console.log(res)
}
})
this.isShowSearch = true
uni.hideLoading();
}
@ -297,6 +328,12 @@
},
fail(res) {
console.log('writeBLECharacteristicValue fail', res)
wx.closeBLEConnection({
deviceId:uni.getStorageSync('deviceId'),
success (res) {
console.log(res)
}
})
if(uni.getStorageSync('deviceId')){
console.log("111")
that.xierushuju()
@ -305,6 +342,10 @@
}
}
})
uni.hideLoading();
},
handleSearchClose(){
this.isShowSearch = false
}
}
}
@ -334,7 +375,7 @@
.kk-modal {
width: 680upx;
height: 80%;
height: 60%;
padding: 24upx;
box-sizing: border-box;
overflow-y: auto;

Loading…
Cancel
Save