fix:处理添加锁后wifi配网loading中断的问题
This commit is contained in:
parent
7817d414c6
commit
f474ad2f2a
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -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;
|
||||
}
|
||||
@ -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,
|
||||
|
||||
@ -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,
|
||||
|
||||
@ -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}),
|
||||
|
||||
@ -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 {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user