收藏
回答

motorola 手机运行小程序,打开蓝牙闪退

框架类型 问题类型 操作系统 操作系统版本 手机型号 微信版本
小程序 Bug Android Android XT2175-2 8.0.30

已上传错误日志 微信号:bangecheng1 提交时间 2024年03月20日 9点43分左右

wx.openBluetoothAdapter({ success: function(res) { that.$toast('初始化蓝牙适配器成功!') //监听蓝牙适配器状态 that.status = 1 wx.onBluetoothAdapterStateChange(function(res) { console.log('蓝牙开始改变2', res) // that.status = 1 }) // 启动定时器,定时获取已发现的设备 timer = setInterval(function() { wx.getBluetoothDevices({ success: function(res) { console.log(res.devices, '获取设备参数') var mydevices = that.getContecDevices(res.devices); if (mydevices.length && that.status != 2) { //检测到设备并且没有绑定的时候进入 防止非必现bug 绑定重复触发 console.log('进来了'); clearInterval(timer); timer = null; that.status = 2; that.activeIndex = 0; that.deviceData = mydevices[0]; console.log(that.deviceData, '设备信息') const id = that.deviceData.device.deviceId that.deviceIds = [id]; if (that.systemInfo == 'ios') { that.getIosMacId(id); } else { that.deviceData.device.mac = id uni.$u.throttle(that.sureBind(), 3000) } } else { that.status = 3; } //监听蓝牙适配器状态 wx.onBluetoothAdapterStateChange(function(res) { console.log('蓝牙开始改变3', res) that.status = 1 if (res.discovering) { that.status = 1 } else { that.status = 0 } if (!res.available) { that.status = 6 //不可用 } }) } }) }, 1000) // 开启搜索 wx.startBluetoothDevicesDiscovery({ allowDuplicatesKey: false, //services: ['0000FF12-0000-1000-8000-00805F9B34FB'], success: function(res) { that.setData({ msg: "搜索设备" + JSON.stringify(res), discovering: true, }) //监听蓝牙适配器状态 wx.onBluetoothAdapterStateChange(function(res) { console.log('蓝牙开始改变4', res) if (res.discovering) { that.status = 1 } else { that.status = 0 } if (!res.available) { that.status = 6 //不可用 } }) } }) }, fail: function(err) { // that.$toast('初始化蓝牙适配器失败!') console.log(err, '蓝牙初始化失败') that.errType = 1; //蓝牙启动失败 that.errMsg = '蓝牙初始化失败-' + JSON.stringify(err); that.status = 6; if ( err.errno === 1500102 ) { that.$showModal('微信无法使用蓝牙,请到系统设置中启用',false).then(_res => { // that.uploadError(); }) return false; } that.$showModal('抱歉!手机蓝牙不可用,请检查手机蓝牙权限:' + JSON.stringify(err), false).then(_res => { that.uploadError(); }) } })
最后一次编辑于  03-20
回答关注问题邀请回答
收藏

1 个回答

  • Demons
    Demons
    03-20

    更新一下微信版本

    03-20
    有用
    回复
登录 后发表内容