fix:处理添加锁后wifi配网loading中断的问题

This commit is contained in:
liyi 2025-02-26 11:35:29 +08:00
parent 8ff338452e
commit 5145bae229
6 changed files with 62 additions and 25 deletions

View File

@ -75,6 +75,11 @@ class ConfiguringWifiLogic extends BaseGetXController {
} else { } else {
Get.offAllNamed(Routers.starLockMain); Get.offAllNamed(Routers.starLockMain);
} }
dismissEasyLoading();
if (state.loadingTimer != null) {
state.loadingTimer!.cancel();
state.loadingTimer = null;
}
}); });
} }
} }
@ -85,6 +90,7 @@ class ConfiguringWifiLogic extends BaseGetXController {
void _initReplySubscription() { void _initReplySubscription() {
_replySubscription = _replySubscription =
EventBusManager().eventBus!.on<Reply>().listen((Reply reply) async { EventBusManager().eventBus!.on<Reply>().listen((Reply reply) async {
AppLog.log('收到蓝牙回调${EasyLoading.isShow}');
// WIFI配网结果 // WIFI配网结果
if (reply is GatewayConfiguringWifiResultReply) { if (reply is GatewayConfiguringWifiResultReply) {
_replySenderConfiguringWifiResult(reply); _replySenderConfiguringWifiResult(reply);
@ -95,6 +101,7 @@ class ConfiguringWifiLogic extends BaseGetXController {
if (reply is GatewayGetStatusReply) { if (reply is GatewayGetStatusReply) {
_replyStatusInfo(reply); _replyStatusInfo(reply);
} }
AppLog.log('蓝牙回调处理完毕${EasyLoading.isShow}');
}); });
} }
@ -106,9 +113,6 @@ class ConfiguringWifiLogic extends BaseGetXController {
switch (status) { switch (status) {
case 0x00: case 0x00:
//
cancelBlueConnetctToastTimer();
final int secretKeyJsonLength = (reply.data[4] << 8) + reply.data[3]; final int secretKeyJsonLength = (reply.data[4] << 8) + reply.data[3];
final List<int> secretKeyList = final List<int> secretKeyList =
@ -126,7 +130,7 @@ class ConfiguringWifiLogic extends BaseGetXController {
/// ,peerId /// ,peerId
StartChartManage().lockPeerId = peerId ?? ''; StartChartManage().lockPeerId = peerId ?? '';
dismissEasyLoading();
state.isLoading.value = false; state.isLoading.value = false;
// //
await Storage.saveLockNetWorkInfo(jsonMap); await Storage.saveLockNetWorkInfo(jsonMap);
@ -141,6 +145,10 @@ class ConfiguringWifiLogic extends BaseGetXController {
default: default:
// //
dismissEasyLoading(); dismissEasyLoading();
if (state.loadingTimer != null) {
state.loadingTimer!.cancel();
state.loadingTimer = null;
}
cancelBlueConnetctToastTimer(); cancelBlueConnetctToastTimer();
showToast('配网失败'.tr); showToast('配网失败'.tr);
state.isLoading.value = false; state.isLoading.value = false;
@ -156,6 +164,8 @@ class ConfiguringWifiLogic extends BaseGetXController {
// wifi // wifi
Future<void> senderConfiguringWifiAction() async { Future<void> senderConfiguringWifiAction() async {
AppLog.log('开始配网${EasyLoading.isShow}');
EasyLoading.show();
if (state.isLoading.isTrue) { if (state.isLoading.isTrue) {
AppLog.log('正在配网中请勿重复点击'); AppLog.log('正在配网中请勿重复点击');
return; return;
@ -175,7 +185,7 @@ class ConfiguringWifiLogic extends BaseGetXController {
state.sureBtnState.value = 1; state.sureBtnState.value = 1;
final GetGatewayConfigurationEntity entity = final GetGatewayConfigurationEntity entity =
await ApiRepository.to.getGatewayConfiguration(timeout: 60); await ApiRepository.to.getGatewayConfigurationNotLoading(timeout: 60);
if (entity.errorCode!.codeIsSuccessful) { if (entity.errorCode!.codeIsSuccessful) {
state.getGatewayConfigurationStr = entity.data ?? ''; state.getGatewayConfigurationStr = entity.data ?? '';
} }
@ -210,6 +220,8 @@ class ConfiguringWifiLogic extends BaseGetXController {
state.getGatewayConfigurationStr = "{\"userPeerld\": \"$appPeerId\"}"; state.getGatewayConfigurationStr = "{\"userPeerld\": \"$appPeerId\"}";
} }
AppLog.log('获取到配网信息===开始发送蓝牙指令${EasyLoading.isShow}');
BlueManage().blueSendData( BlueManage().blueSendData(
BlueManage().connectDeviceName, BlueManage().connectDeviceName,
(BluetoothConnectionState connectionState) async { (BluetoothConnectionState connectionState) async {
@ -223,8 +235,12 @@ class ConfiguringWifiLogic extends BaseGetXController {
}, },
isAddEquipment: true, isAddEquipment: true,
); );
// state.loadingTimer ??= Timer.periodic(Duration(milliseconds: 100), (timer) {
showEasyLoading(); if (!EasyLoading.isShow) {
EasyLoading.show();
}
});
state.isLoading.value = true; state.isLoading.value = true;
// 15 // 15
Future.delayed(const Duration(seconds: 15), () { Future.delayed(const Duration(seconds: 15), () {
@ -232,9 +248,14 @@ class ConfiguringWifiLogic extends BaseGetXController {
EasyLoading.dismiss(); EasyLoading.dismiss();
state.isLoading.value = false; state.isLoading.value = false;
state.sureBtnState.value = 0; state.sureBtnState.value = 0;
if (state.loadingTimer != null) {
state.loadingTimer!.cancel();
state.loadingTimer = null;
}
showToast('配网失败'.tr); showToast('配网失败'.tr);
} }
}); });
AppLog.log('发送方法执行完毕${EasyLoading.isShow}');
} }
// //
@ -358,9 +379,24 @@ class ConfiguringWifiLogic extends BaseGetXController {
// //
dismissEasyLoading(); dismissEasyLoading();
showToast('配网失败'.tr); showToast('配网失败'.tr);
if (state.loadingTimer != null) {
state.loadingTimer!.cancel();
state.loadingTimer = null;
}
break; break;
} }
} }
void _replyStatusInfo(reply) {} void _replyStatusInfo(reply) {}
@override
void dispose() {
// TODO: implement dispose
super.dispose();
state.isLoading.value = false;
if (state.loadingTimer != null) {
state.loadingTimer!.cancel();
state.loadingTimer = null;
}
}
} }

View File

@ -1,4 +1,6 @@
import 'dart:async';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:get/get.dart'; import 'package:get/get.dart';
@ -30,4 +32,5 @@ class ConfiguringWifiState{
String getGatewayConfigurationStr = ''; String getGatewayConfigurationStr = '';
RxBool isLoading=false.obs; RxBool isLoading=false.obs;
Timer? loadingTimer;
} }

View File

@ -78,10 +78,10 @@ class _WifiListPageState extends State<WifiListPage> {
borderRadius: 20.w, borderRadius: 20.w,
padding: EdgeInsets.only(top: 25.w, bottom: 25.w), padding: EdgeInsets.only(top: 25.w, bottom: 25.w),
onClick: () { onClick: () {
Get.toNamed(Routers.configuringWifiPage, Get.toNamed(Routers.configuringWifiPage, arguments: {
arguments: <String, LockSetInfoData>{ 'lockSetInfoData': state.lockSetInfoData.value,
'lockSetInfoData': state.lockSetInfoData.value 'pageName': state.pageName.value,
}); });
}), }),
SizedBox( SizedBox(
height: 64.h, height: 64.h,

View File

@ -491,25 +491,12 @@ class SaveLockLogic extends BaseGetXController {
// //
final LockSetInfoEntity entity = final LockSetInfoEntity entity =
await ApiRepository.to.getLockSettingInfoDataIsNotLoadingIcon( await ApiRepository.to.getLockSettingInfoData(
lockId: state.lockId.toString(), lockId: state.lockId.toString(),
); );
if (entity.errorCode!.codeIsSuccessful) { if (entity.errorCode!.codeIsSuccessful) {
state.lockSetInfoData.value = entity.data!; state.lockSetInfoData.value = entity.data!;
if (state.lockSetInfoData.value.lockFeature?.wifi == 1) { if (state.lockSetInfoData.value.lockFeature?.wifi == 1) {
// await Future<void>.delayed(const Duration(seconds: 1), () {c
// Get.close(state.isFromMap == 1
// ? (CommonDataManage().seletLockType == 0 ? 4 : 5)
// : (CommonDataManage().seletLockType == 0 ? 5 : 6));
// });
// // 2
// await Future<void>.delayed(const Duration(milliseconds: 200), () {
// if (Get.isRegistered<LockDetailLogic>()) {
// Get.find<LockDetailLogic>()
// .functionBlocker
// .countdownProhibited(duration: const Duration(seconds: 2));
// }
// });
// wifi锁WIFI // wifi锁WIFI
Get.toNamed(Routers.wifiListPage, arguments: { Get.toNamed(Routers.wifiListPage, arguments: {
'lockSetInfoData': state.lockSetInfoData.value, 'lockSetInfoData': state.lockSetInfoData.value,

View File

@ -1811,6 +1811,9 @@ class ApiProvider extends BaseProvider {
Future<Response> getGatewayConfiguration(int timeout) => Future<Response> getGatewayConfiguration(int timeout) =>
post(getGatewayConfigURL.toUrl, jsonEncode({}), timeout: timeout); post(getGatewayConfigURL.toUrl, jsonEncode({}), timeout: timeout);
Future<Response> getGatewayConfigurationNotLoading(int timeout) =>
post(getGatewayConfigURL.toUrl, jsonEncode({}), timeout: timeout,isUnShowLoading: true);
Future<Response> gatewayConnectionLockListLoadData( Future<Response> gatewayConnectionLockListLoadData(
int gatewayId, int timeout) => int gatewayId, int timeout) =>
post(gatewayListByLockURL.toUrl, jsonEncode({'gatewayId': gatewayId}), post(gatewayListByLockURL.toUrl, jsonEncode({'gatewayId': gatewayId}),

View File

@ -2010,6 +2010,14 @@ class ApiRepository {
return GetGatewayConfigurationEntity.fromJson(res.body); return GetGatewayConfigurationEntity.fromJson(res.body);
} }
//
Future<GetGatewayConfigurationEntity> getGatewayConfigurationNotLoading(
{required int timeout}) async {
final res = await apiProvider.getGatewayConfigurationNotLoading(timeout);
return GetGatewayConfigurationEntity.fromJson(res.body);
}
// //
Future<RecipientInformationEntity> removeBrokenLockData( Future<RecipientInformationEntity> removeBrokenLockData(
{required List lockIdList}) async { {required List lockIdList}) async {