diff --git a/pages/common/qrcode/qrcode.vue b/pages/common/qrcode/qrcode.vue index fd8689a..d3137e3 100644 --- a/pages/common/qrcode/qrcode.vue +++ b/pages/common/qrcode/qrcode.vue @@ -86,14 +86,29 @@ } catch (error) {} } }, - }, - onLoad(options) { - if (options.deviceId) { - this.deviceId = decodeURIComponent(options.deviceId); - } else { - this.deviceId = '未获取到设备ID'; - } + }, + // 处理返回键 + onBackPress() { + // 如果绑定成功了,返回时也要刷新首页 + if (this.isSuccess) { + uni.$emit('refreshDeviceList'); } + return false; // 允许正常返回 + }, + // 页面卸载时处理 + onUnload() { + // 如果绑定成功了,卸载时也要刷新首页 + if (this.isSuccess) { + uni.$emit('refreshDeviceList'); + } + }, + onLoad(options) { + if (options.deviceId) { + this.deviceId = decodeURIComponent(options.deviceId); + } else { + this.deviceId = '未获取到设备ID'; + } + } }