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

View File

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

View File

@ -491,25 +491,12 @@ class SaveLockLogic extends BaseGetXController {
//
final LockSetInfoEntity entity =
await ApiRepository.to.getLockSettingInfoDataIsNotLoadingIcon(
await ApiRepository.to.getLockSettingInfoData(
lockId: state.lockId.toString(),
);
if (entity.errorCode!.codeIsSuccessful) {
state.lockSetInfoData.value = entity.data!;
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
Get.toNamed(Routers.wifiListPage, arguments: {
'lockSetInfoData': state.lockSetInfoData.value,

View File

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

View File

@ -2010,6 +2010,14 @@ class ApiRepository {
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(
{required List lockIdList}) async {