From bc48f573a19ea1f1d7c27c98ddac313323fa72f3 Mon Sep 17 00:00:00 2001 From: liyi Date: Mon, 10 Feb 2025 13:40:02 +0800 Subject: [PATCH 1/4] =?UTF-8?q?fix:=E8=B0=83=E6=95=B4WiFi=E9=85=8D?= =?UTF-8?q?=E7=BD=91=E6=97=B6loading=E4=B8=8D=E8=BF=9E=E7=BB=AD=E7=9A=84?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/blue/reciver_data.dart | 2 +- .../configuringWifi_logic.dart | 17 ++++++-- .../configuringWifi/configuringWifi_page.dart | 42 +++++++++++-------- .../configuringWifi_state.dart | 2 + 4 files changed, 42 insertions(+), 21 deletions(-) diff --git a/lib/blue/reciver_data.dart b/lib/blue/reciver_data.dart index 08fbd978..8f1db2af 100755 --- a/lib/blue/reciver_data.dart +++ b/lib/blue/reciver_data.dart @@ -115,7 +115,7 @@ class CommandReciverManager { break; } parseData(oriDataList).then((Reply? value) async { - EasyLoading.dismiss(); + // EasyLoading.dismiss(); await EventBusManager().eventBusFir(value); }).catchError((Object error) { AppLog.log('APP解析数据时发生错误: ${error.toString()}'); diff --git a/lib/main/lockDetail/lockSet/configuringWifi/configuringWifi/configuringWifi_logic.dart b/lib/main/lockDetail/lockSet/configuringWifi/configuringWifi/configuringWifi_logic.dart index 4eb5b6c6..d5c062c5 100755 --- a/lib/main/lockDetail/lockSet/configuringWifi/configuringWifi/configuringWifi_logic.dart +++ b/lib/main/lockDetail/lockSet/configuringWifi/configuringWifi/configuringWifi_logic.dart @@ -88,11 +88,13 @@ class ConfiguringWifiLogic extends BaseGetXController { Future _replySenderConfiguringWifiResult(Reply reply) async { final int status = reply.data[2]; state.sureBtnState.value = 0; + state.isLoading.value = false; + switch (status) { case 0x00: //成功 cancelBlueConnetctToastTimer(); - dismissEasyLoading(); + final int secretKeyJsonLength = (reply.data[4] << 8) + reply.data[3]; final List secretKeyList = @@ -110,7 +112,8 @@ class ConfiguringWifiLogic extends BaseGetXController { /// 配网成功后,赋值锁的peerId StartChartManage().lockPeerId = peerId ?? ''; - + dismissEasyLoading(); + state.isLoading.value = false; // 保存到缓存 await Storage.saveLockNetWorkInfo(jsonMap); // 上报服务器 @@ -126,6 +129,7 @@ class ConfiguringWifiLogic extends BaseGetXController { dismissEasyLoading(); cancelBlueConnetctToastTimer(); showToast('配网失败'.tr); + state.isLoading.value = false; break; } } @@ -138,6 +142,10 @@ class ConfiguringWifiLogic extends BaseGetXController { // 点击配置wifi Future senderConfiguringWifiAction() async { + if (state.isLoading.isTrue) { + AppLog.log('正在配网中请勿重复点击'); + return; + } if (state.wifiNameController.text.isEmpty) { showToast('请输入wifi名称'.tr); return; @@ -197,11 +205,14 @@ class ConfiguringWifiLogic extends BaseGetXController { password: state.wifiPWDController.text, gatewayConfigurationStr: state.getGatewayConfigurationStr, ); - EasyLoading.show(); } }, isAddEquipment: true, ); + // 显示加载指示器 + showEasyLoading(); + state.isLoading.value = true; + // 模拟异步请求 } // 获取设备状态 diff --git a/lib/main/lockDetail/lockSet/configuringWifi/configuringWifi/configuringWifi_page.dart b/lib/main/lockDetail/lockSet/configuringWifi/configuringWifi/configuringWifi_page.dart index 6bfec6a6..55a6a02c 100755 --- a/lib/main/lockDetail/lockSet/configuringWifi/configuringWifi/configuringWifi_page.dart +++ b/lib/main/lockDetail/lockSet/configuringWifi/configuringWifi/configuringWifi_page.dart @@ -1,4 +1,3 @@ - import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:flutter_easyloading/flutter_easyloading.dart'; @@ -21,7 +20,8 @@ class ConfiguringWifiPage extends StatefulWidget { State createState() => _ConfiguringWifiPageState(); } -class _ConfiguringWifiPageState extends State with RouteAware { +class _ConfiguringWifiPageState extends State + with RouteAware { final ConfiguringWifiLogic logic = Get.put(ConfiguringWifiLogic()); final ConfiguringWifiState state = Get.find().state; @@ -30,24 +30,32 @@ class _ConfiguringWifiPageState extends State with RouteAwa return Scaffold( backgroundColor: Colors.white, appBar: TitleAppBar( - barTitle: '配置WiFi'.tr, - haveBack: true, - backgroundColor: AppColors.mainColor), + barTitle: '配置WiFi'.tr, + haveBack: true, + backgroundColor: AppColors.mainColor), body: Column( children: [ - configuringWifiTFWidget('WiFi名称'.tr, '请输入WiFi名字'.tr, state.wifiNameController), - Container(width: 1.sw, height: 1.h,color: AppColors.mainBackgroundColor), - configuringWifiTFWidget('WiFi密码'.tr, '请输入WiFi密码'.tr, state.wifiPWDController), - SizedBox(height: 50.h,), - SubmitBtn(btnName: '确定'.tr, onClick: () { - logic.senderConfiguringWifiAction(); - }), + configuringWifiTFWidget( + 'WiFi名称'.tr, '请输入WiFi名字'.tr, state.wifiNameController), + Container( + width: 1.sw, height: 1.h, color: AppColors.mainBackgroundColor), + configuringWifiTFWidget( + 'WiFi密码'.tr, '请输入WiFi密码'.tr, state.wifiPWDController), + SizedBox( + height: 50.h, + ), + SubmitBtn( + btnName: '确定'.tr, + onClick: () { + logic.senderConfiguringWifiAction(); + }, + ), ], )); } Widget configuringWifiTFWidget( - String titleStr, String rightTitle,TextEditingController controller) { + String titleStr, String rightTitle, TextEditingController controller) { return Column( children: [ Container(height: 10.h), @@ -86,16 +94,16 @@ class _ConfiguringWifiPageState extends State with RouteAwa hintStyle: TextStyle(fontSize: 22.sp), focusedBorder: const OutlineInputBorder( borderSide: - BorderSide(width: 0, color: Colors.transparent)), + BorderSide(width: 0, color: Colors.transparent)), disabledBorder: const OutlineInputBorder( borderSide: - BorderSide(width: 0, color: Colors.transparent)), + BorderSide(width: 0, color: Colors.transparent)), enabledBorder: const OutlineInputBorder( borderSide: - BorderSide(width: 0, color: Colors.transparent)), + BorderSide(width: 0, color: Colors.transparent)), border: const OutlineInputBorder( borderSide: - BorderSide(width: 0, color: Colors.transparent)), + BorderSide(width: 0, color: Colors.transparent)), contentPadding: const EdgeInsets.symmetric(vertical: 0), ), style: TextStyle( diff --git a/lib/main/lockDetail/lockSet/configuringWifi/configuringWifi/configuringWifi_state.dart b/lib/main/lockDetail/lockSet/configuringWifi/configuringWifi/configuringWifi_state.dart index 1fc13548..33707851 100755 --- a/lib/main/lockDetail/lockSet/configuringWifi/configuringWifi/configuringWifi_state.dart +++ b/lib/main/lockDetail/lockSet/configuringWifi/configuringWifi/configuringWifi_state.dart @@ -26,4 +26,6 @@ class ConfiguringWifiState{ TextEditingController wifiNameController = TextEditingController(); TextEditingController wifiPWDController = TextEditingController(); String getGatewayConfigurationStr = ''; + + RxBool isLoading=false.obs; } \ No newline at end of file From 494a57074e088e4e067bc0d05f8f01ef27797ea4 Mon Sep 17 00:00:00 2001 From: liyi Date: Mon, 10 Feb 2025 13:40:21 +0800 Subject: [PATCH 2/4] =?UTF-8?q?fix:=E8=B0=83=E6=95=B4=E4=B8=BA=E6=89=8B?= =?UTF-8?q?=E5=8A=A8=E9=9A=90=E8=97=8Floading=E6=A1=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/mine/addLock/nearbyLock/nearbyLock_logic.dart | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/mine/addLock/nearbyLock/nearbyLock_logic.dart b/lib/mine/addLock/nearbyLock/nearbyLock_logic.dart index 426ddef6..808ed7de 100755 --- a/lib/mine/addLock/nearbyLock/nearbyLock_logic.dart +++ b/lib/mine/addLock/nearbyLock/nearbyLock_logic.dart @@ -93,6 +93,7 @@ class NearbyLockLogic extends BaseGetXController { showToast('固件升级完成'.tr); closeOTADAta(); } + dismissEasyLoading(); }); } From 329989b2baa21dc76c3d71d994d0db14d0ea7f55 Mon Sep 17 00:00:00 2001 From: liyi Date: Mon, 10 Feb 2025 13:40:41 +0800 Subject: [PATCH 3/4] =?UTF-8?q?fix:=E8=B0=83=E6=95=B4=E9=94=81=E6=97=B6?= =?UTF-8?q?=E9=97=B4=E8=8E=B7=E5=8F=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../lockSet/lockTime/lockTime_logic.dart | 105 ++++++++++-------- 1 file changed, 58 insertions(+), 47 deletions(-) diff --git a/lib/main/lockDetail/lockSet/lockTime/lockTime_logic.dart b/lib/main/lockDetail/lockSet/lockTime/lockTime_logic.dart index e3ab45be..a6700931 100755 --- a/lib/main/lockDetail/lockSet/lockTime/lockTime_logic.dart +++ b/lib/main/lockDetail/lockSet/lockTime/lockTime_logic.dart @@ -1,4 +1,3 @@ - import 'dart:async'; import 'package:date_format/date_format.dart'; @@ -20,19 +19,21 @@ import '../../../../tools/dateTool.dart'; import '../../../../tools/storage.dart'; import 'lockTime_state.dart'; -class LockTimeLogic extends BaseGetXController{ +class LockTimeLogic extends BaseGetXController { final LockTimeState state = LockTimeState(); // 获取解析后的数据 late StreamSubscription _replySubscription; + void _initReplySubscription() { - _replySubscription = EventBusManager().eventBus!.on().listen((Reply reply) { - if(reply is TimingReply) { + _replySubscription = + EventBusManager().eventBus!.on().listen((Reply reply) { + if (reply is TimingReply) { _replyTiming(reply); } // 获取锁状态 - if(reply is GetStarLockStatuInfoReply && state.ifCurrentScreen.value == true) { + if (reply is GetStarLockStatuInfoReply) { _replyGetStarLockStatusInfo(reply); } }); @@ -50,16 +51,19 @@ class LockTimeLogic extends BaseGetXController{ // 有效时间 final List indate = reply.data.sublist(150, 154); final int indateValue = (0xff & indate[0]) << 24 | - (0xff & indate[1]) << 16 | - (0xff & indate[2]) << 8 | - (0xFF & indate[3]); - AppLog.log('indate:$indate indateValue:$indateValue'); + (0xff & indate[1]) << 16 | + (0xff & indate[2]) << 8 | + (0xFF & indate[3]); + AppLog.log( + '====================indate:$indate indateValue:$indateValue'); state.dateTime.value = DateTool().dateToYMDHNString('$indateValue'); break; case 0x06: //需要鉴权 - final List? privateKey = await Storage.getStringList(saveBluePrivateKey); - final List getPrivateKeyList = changeStringListToIntList(privateKey!); + final List? privateKey = + await Storage.getStringList(saveBluePrivateKey); + final List getPrivateKeyList = + changeStringListToIntList(privateKey!); IoSenderManage.senderGetStarLockStatuInfo( lockID: BlueManage().connectDeviceName, @@ -79,10 +83,11 @@ class LockTimeLogic extends BaseGetXController{ // 校时数据解析 Future _replyTiming(Reply reply) async { final int status = reply.data[2]; - switch(status){ + switch (status) { case 0x00: //成功 - final String dataEime = DateTool().dateToYMDHNString('${state.serverTime}'); + final String dataEime = + DateTool().dateToYMDHNString('${state.serverTime}'); state.dateTime.value = dataEime; state.sureBtnState.value = 0; @@ -118,43 +123,47 @@ class LockTimeLogic extends BaseGetXController{ // 校验时间 Future sendTiming() async { - if(state.sureBtnState.value == 1){ + if (state.sureBtnState.value == 1) { return; } state.sureBtnState.value = 1; showEasyLoading(); - showBlueConnetctToastTimer(action: (){ + showBlueConnetctToastTimer(action: () { dismissEasyLoading(); state.sureBtnState.value = 0; }); - BlueManage().blueSendData(BlueManage().connectDeviceName, (BluetoothConnectionState connectionState) async { + BlueManage().blueSendData(BlueManage().connectDeviceName, + (BluetoothConnectionState connectionState) async { if (connectionState == BluetoothConnectionState.connected) { - final List? privateKey = await Storage.getStringList(saveBluePrivateKey); - final List getPrivateKeyList = changeStringListToIntList(privateKey!); + final List? privateKey = + await Storage.getStringList(saveBluePrivateKey); + final List getPrivateKeyList = + changeStringListToIntList(privateKey!); final List? token = await Storage.getStringList(saveBlueToken); final List getTokenList = changeStringListToIntList(token!); - final List? signKey = await Storage.getStringList(saveBlueSignKey); + final List? signKey = + await Storage.getStringList(saveBlueSignKey); final List getSignKeyList = changeStringListToIntList(signKey!); IoSenderManage.senderTimingCommand( - lockID:BlueManage().connectDeviceName, - userID:await Storage.getUid(), + lockID: BlueManage().connectDeviceName, + userID: await Storage.getUid(), nowTime: state.serverTime, - token:getTokenList, - needAuthor:1, - signKey:getSignKeyList, - privateKey:getPrivateKeyList, + token: getTokenList, + needAuthor: 1, + signKey: getSignKeyList, + privateKey: getPrivateKeyList, ); } else if (connectionState == BluetoothConnectionState.disconnected) { dismissEasyLoading(); cancelBlueConnetctToastTimer(); state.sureBtnState.value = 0; - if(state.ifCurrentScreen.value == true){ - showBlueConnetctToast(); - } + // if (state.ifCurrentScreen.value == true) { + // showBlueConnetctToast(); + // } } }); } @@ -168,8 +177,10 @@ class LockTimeLogic extends BaseGetXController{ BlueManage().blueSendData(BlueManage().connectDeviceName, (BluetoothConnectionState deviceConnectionState) async { if (deviceConnectionState == BluetoothConnectionState.connected) { - final List? privateKey = await Storage.getStringList(saveBluePrivateKey); - final List getPrivateKeyList = changeStringListToIntList(privateKey!); + final List? privateKey = + await Storage.getStringList(saveBluePrivateKey); + final List getPrivateKeyList = + changeStringListToIntList(privateKey!); IoSenderManage.senderGetStarLockStatuInfo( lockID: BlueManage().connectDeviceName, @@ -179,41 +190,42 @@ class LockTimeLogic extends BaseGetXController{ isBeforeAddUser: false, privateKey: getPrivateKeyList, ); - } else if (deviceConnectionState == BluetoothConnectionState.disconnected) { + } else if (deviceConnectionState == + BluetoothConnectionState.disconnected) { dismissEasyLoading(); cancelBlueConnetctToastTimer(); - if (state.ifCurrentScreen.value == true) { - showBlueConnetctToast(); - } + // if (state.ifCurrentScreen.value == true) { + // showBlueConnetctToast(); + // } } }); } // 从网关获取时间 - Future getLockTimeFromGateway() async{ - final GetServerDatetimeEntity entity = await ApiRepository.to.getLockTimeFromGateway( + Future getLockTimeFromGateway() async { + final GetServerDatetimeEntity entity = + await ApiRepository.to.getLockTimeFromGateway( lockId: state.lockSetInfoData.value.lockId.toString(), ); - if(entity.errorCode!.codeIsSuccessful){ - - } + if (entity.errorCode!.codeIsSuccessful) {} } // 从服务器获取锁的时间 开锁时传入 - Future getServerDatetime(bool isSendTime) async{ - final GetServerDatetimeEntity entity = await ApiRepository.to.getServerDatetimeData(isUnShowLoading:false); - if(entity.errorCode!.codeIsSuccessful){ + Future getServerDatetime(bool isSendTime) async { + final GetServerDatetimeEntity entity = + await ApiRepository.to.getServerDatetimeData(isUnShowLoading: false); + if (entity.errorCode!.codeIsSuccessful) { state.serverTime = entity.data!.date! ~/ 1000; // AppLog.log("entity.data!.date! ~/ 1000:${entity.data!.date! ~/ 1000} DateTime.now().millisecondsSinceEpoch ~/ 1000:${DateTime.now().millisecondsSinceEpoch ~/ 1000} 服务器时间差:${state.differentialTime}"); - if(isSendTime == false){ + if (isSendTime == false) { getStarLockStatus(); - }else{ + } else { sendTiming(); } } } - int getLocalTime(){ + int getLocalTime() { final DateTime now = DateTime.now(); final Duration timeZoneOffset = now.timeZoneOffset; // AppLog.log('timeZoneOffset.inSeconds:$timeZoneOffset.inSeconds'); @@ -229,7 +241,6 @@ class LockTimeLogic extends BaseGetXController{ // getLockTimeFromGateway(); getServerDatetime(false); - } @override @@ -242,4 +253,4 @@ class LockTimeLogic extends BaseGetXController{ super.onClose(); _replySubscription.cancel(); } -} \ No newline at end of file +} From e5d11f6ee8801894a7f15b09a94623172a5e8582 Mon Sep 17 00:00:00 2001 From: liyi Date: Mon, 10 Feb 2025 13:41:15 +0800 Subject: [PATCH 4/4] =?UTF-8?q?fix:=E6=B3=A8=E9=87=8A=E2=80=9C=E9=94=81?= =?UTF-8?q?=E5=B7=B2=E7=BB=8F=E8=A2=AB=E9=87=8D=E7=BD=AE=E2=80=9D=E7=9A=84?= =?UTF-8?q?=E6=8F=90=E7=A4=BA=E6=A1=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../lockDetail/lockDetail_logic.dart | 45 ++++++++++--------- 1 file changed, 24 insertions(+), 21 deletions(-) diff --git a/lib/main/lockDetail/lockDetail/lockDetail_logic.dart b/lib/main/lockDetail/lockDetail/lockDetail_logic.dart index b5d3a1aa..edf17bc0 100755 --- a/lib/main/lockDetail/lockDetail/lockDetail_logic.dart +++ b/lib/main/lockDetail/lockDetail/lockDetail_logic.dart @@ -426,25 +426,26 @@ class LockDetailLogic extends BaseGetXController { AppLog.log('command:${command}'); showBlueConnetctToastTimer( - outTimer: 20, - action: () async { - final String getMobile = (await Storage.getMobile())!; - ApmHelper.instance.trackEvent('open_lock', { - 'lock_name': state.keyInfos.value.lockName!, - 'account': - getMobile.isNotEmpty ? getMobile : (await Storage.getEmail())!, - 'date': DateTool().getNowDateWithType(1), - 'open_lock_result': '超时', - }); - - resetOpenDoorState(); - blueManageDisconnect(); - BuglyTool.uploadException( - message: '开门超时处理-开锁失败', - detail: '开门超时,断开连接,开锁失败--OpenLockCommand:$command', - upload: true); + outTimer: 20, + action: () async { + final String getMobile = (await Storage.getMobile())!; + ApmHelper.instance.trackEvent('open_lock', { + 'lock_name': state.keyInfos.value.lockName!, + 'account': + getMobile.isNotEmpty ? getMobile : (await Storage.getEmail())!, + 'date': DateTool().getNowDateWithType(1), + 'open_lock_result': '超时', }); + resetOpenDoorState(); + blueManageDisconnect(); + BuglyTool.uploadException( + message: '开门超时处理-开锁失败', + detail: '开门超时,断开连接,开锁失败--OpenLockCommand:$command', + upload: true); + }, + ); + BlueManage() .blueSendData(state.keyInfos.value.bluetooth!.bluetoothDeviceName!, (BluetoothConnectionState deviceConnectionState) async { @@ -481,9 +482,9 @@ class LockDetailLogic extends BaseGetXController { 'open_lock_result': '断开连接', }); - if (state.ifCurrentScreen.value == true) { - showBlueConnetctToast(); - } + // if (state.ifCurrentScreen.value == true) { + // showBlueConnetctToast(); + // } resetOpenDoorState(); } }); @@ -658,7 +659,9 @@ class LockDetailLogic extends BaseGetXController { // 远程开锁 Future remoteOpenLock() async { final LoginEntity entity = await ApiRepository.to.remoteOpenLock( - lockId: state.keyInfos.value.lockId.toString(), timeOut: 60); + lockId: state.keyInfos.value.lockId.toString(), + timeOut: 60, + ); if (entity.errorCode!.codeIsSuccessful) { showToast('已开锁'.tr); }