我的蓝牙小程序连接设备运行一个完整周期后回到主界面,然后断开蓝牙。但是设定的蓝牙弹窗列表没有弹出,在调试模式下可以看到断连时setData发送的数据是正确的,但是没有出现弹窗。点击切换界面按钮(change)时,data里的数据又回到了断连前的情况。
wx.onBLEConnectionStateChanged(function (res) { if (res.connected) { wx.showToast({ title: '连接成功', duration: 3000 }) that.setData({ showModal: false, bluetoothflag: '', BEflag: 1, }) } else { wx.closeBluetoothAdapter({ success: function (res) { console.log(res); that.setData({ showModal: true, bluetoothflag: '#ccc', BEflag: 0, notify_id: '', write_id: '', deviceId: '', PYS_serviceId: '', }) }, }) wx.showToast({ title: '连接失败', image: '../../images/error.png', duration: 3000, }) that.bluetooth(); console.log("index disconnect", that.data) } }), |
