From 96367baaeaeef016dc1c49c1088e8ada06c63218 Mon Sep 17 00:00:00 2001 From: liyi Date: Sat, 26 Apr 2025 15:51:16 +0800 Subject: [PATCH] =?UTF-8?q?fix:=E8=B0=83=E6=95=B4=E9=85=8D=E7=BD=91?= =?UTF-8?q?=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../configuringWifi_logic.dart | 56 +++++++++---------- 1 file changed, 28 insertions(+), 28 deletions(-) diff --git a/lib/main/lockDetail/lockSet/configuringWifi/configuringWifi/configuringWifi_logic.dart b/lib/main/lockDetail/lockSet/configuringWifi/configuringWifi/configuringWifi_logic.dart index a940ca4e..3b23c309 100755 --- a/lib/main/lockDetail/lockSet/configuringWifi/configuringWifi/configuringWifi_logic.dart +++ b/lib/main/lockDetail/lockSet/configuringWifi/configuringWifi/configuringWifi_logic.dart @@ -55,7 +55,7 @@ class ConfiguringWifiLogic extends BaseGetXController { } /// 更新网络信息到服务器 - void updateNetworkInfo({ + Future updateNetworkInfo({ required String peerId, required String wifiName, required String secretKey, @@ -71,27 +71,12 @@ class ConfiguringWifiLogic extends BaseGetXController { secretKey: secretKey, peerId: peerId, ); - - if (entity.errorCode!.codeIsSuccessful) { - // 设置锁的peerID - StartChartManage().lockNetworkInfo = DeviceNetworkInfo( - wifiName: wifiName, - networkMac: networkMac, - secretKey: secretKey, - peerId: peerId, - ); - - await _getUploadLockSet(); - } else { - dismissEasyLoading(); - showToast('网络配置失败,请重试'.tr); - state.sureBtnState.value = 0; - } + return entity; } catch (e) { dismissEasyLoading(); - showToast('网络配置异常:${e.toString()}'.tr); state.sureBtnState.value = 0; AppLog.log('网络配置异常:$e'); + return LoginEntity(); } } @@ -174,19 +159,34 @@ class ConfiguringWifiLogic extends BaseGetXController { throw Exception('Missing required network information'); } - /// 配网成功后,赋值锁的peerId - StartChartManage().lockPeerId = peerId; - - // 保存到缓存 - await Storage.saveLockNetWorkInfo(jsonMap); - // 上报服务器 - 注意: sureBtnState 状态将在 updateNetworkInfo 方法中或其回调中完成重置 - updateNetworkInfo( + final info = await updateNetworkInfo( peerId: peerId, wifiName: wifiName ?? '', secretKey: secretKey, deviceMac: deviceMac ?? '', networkMac: networkMac ?? ''); + if (info.errorCode!.codeIsSuccessful) { + // 设置锁的peerID + StartChartManage().lockNetworkInfo = DeviceNetworkInfo( + wifiName: wifiName, + networkMac: networkMac, + secretKey: secretKey, + peerId: peerId, + ); + + /// 配网成功后,赋值锁的peerId + StartChartManage().lockPeerId = peerId; + + // 保存到缓存 + await Storage.saveLockNetWorkInfo(jsonMap); + + await _getUploadLockSet(); + } else { + dismissEasyLoading(); + showToast('网络配置失败,请重试'.tr); + state.sureBtnState.value = 0; + } } catch (e) { if (EasyLoading.isShow) { dismissEasyLoading(); @@ -495,13 +495,13 @@ class ConfiguringWifiLogic extends BaseGetXController { throw Exception('Token is empty'); } final List getTokenList = changeStringListToIntList(token); + // 蓝牙获取锁设置 await _uploadLockSet(getTokenList); } catch (e) { if (EasyLoading.isShow) { dismissEasyLoading(); } cancelBlueConnetctToastTimer(); - showToast('获取设置失败:${e.toString()}'.tr); state.sureBtnState.value = 0; } } @@ -613,14 +613,14 @@ class ConfiguringWifiLogic extends BaseGetXController { if (EasyLoading.isShow) { dismissEasyLoading(); } - showToast('数据上传失败:${entity.errorCode}'.tr); + // showToast('数据上传失败:${entity.errorCode}'.tr); state.sureBtnState.value = 0; // 确保重置状态 } } catch (e) { if (EasyLoading.isShow) { dismissEasyLoading(); } - showToast('数据上传异常:${e.toString()}'.tr); + // showToast('数据上传异常:${e.toString()}'.tr); state.sureBtnState.value = 0; // 确保重置状态 } }