更新记录
1.0.0.2(2024-01-15) 下载此版本
完善监听无线蓝牙是否断开
1.0.0.1(2024-01-11) 下载此版本
梳理了代码逻辑 优化性能
1.0.0.0(2024-01-10) 下载此版本
第一版本微信小程序上线 后台模块开发完成
查看更多平台兼容性
uni-app
Vue2 | Vue3 | Chrome | Safari | app-vue | app-nvue | Android | iOS | 鸿蒙 |
---|---|---|---|---|---|---|---|---|
√ | √ | - | - | - | - | - | - | - |
微信小程序 | 支付宝小程序 | 抖音小程序 | 百度小程序 | 快手小程序 | 京东小程序 | 鸿蒙元服务 | QQ小程序 | 飞书小程序 | 快应用-华为 | 快应用-联盟 |
---|---|---|---|---|---|---|---|---|---|---|
√ | - | - | - | - | - | - | - | - | - | - |
-
部分代码:
发现蓝牙:
uni.openBluetoothAdapter({
success: (res) => {
console.log('初始化蓝牙成功', res)
this.getBluetoothAdapterState(); // 检测本机蓝牙是否可用
},
fail(err) {
wx.showModal({
content: '请开启手机蓝牙后再试',
});
}
});
连接蓝牙
uni.createBLEConnection({
// 这里的 deviceId 需要已经通过 createBLEConnection 与
deviceId: this.deviceId,
success: (res) => {
console.log('连接成功', res);
this.getservice(); //接设备的service服务
// 关闭蓝牙
setTimeout(function() {
wx.stopBluetoothDevicesDiscovery({
success: function(res) {},
});
wx.offBluetoothDeviceFound({
success: function(res) {},
});
}, 2000);
},
fail: (err) => {
console.log("蓝牙连接失败-------", err)
this.ToastShow("蓝牙连接失败,请重新连接");
},
complete: function(com) {
console.log("蓝牙连接----", com)
}
})
支持定制,联系方式 QQ:1250533624