fix:调整配网loading卡主的问题
This commit is contained in:
parent
49ed169506
commit
cd41dd4ccf
@ -62,17 +62,15 @@ class ConfiguringWifiLogic extends BaseGetXController {
|
||||
peerId: peerId,
|
||||
);
|
||||
if (entity.errorCode!.codeIsSuccessful) {
|
||||
// 设置锁的peerID
|
||||
StartChartManage().lockNetworkInfo = DeviceNetworkInfo(
|
||||
wifiName: wifiName,
|
||||
networkMac: networkMac,
|
||||
secretKey: secretKey,
|
||||
peerId: peerId,
|
||||
);
|
||||
|
||||
showToast('配网成功'.tr, something: () async {
|
||||
// 设置锁的peerID
|
||||
StartChartManage().lockNetworkInfo = DeviceNetworkInfo(
|
||||
wifiName: wifiName,
|
||||
networkMac: networkMac,
|
||||
secretKey: secretKey,
|
||||
peerId: peerId,
|
||||
);
|
||||
});
|
||||
_getUploadLockSet();
|
||||
await _getUploadLockSet();
|
||||
}
|
||||
}
|
||||
|
||||
@ -106,8 +104,11 @@ class ConfiguringWifiLogic extends BaseGetXController {
|
||||
// WIFI配网结果
|
||||
Future<void> _replySenderConfiguringWifiResult(Reply reply) async {
|
||||
final int status = reply.data[2];
|
||||
state.sureBtnState.value = 0;
|
||||
state.isLoading.value = false;
|
||||
// state.sureBtnState.value = 0;
|
||||
|
||||
// 取消loading超时定时器
|
||||
state.loadingTimer?.cancel();
|
||||
state.loadingTimer = null;
|
||||
|
||||
switch (status) {
|
||||
case 0x00:
|
||||
@ -140,15 +141,17 @@ class ConfiguringWifiLogic extends BaseGetXController {
|
||||
secretKey: secretKey ?? '',
|
||||
deviceMac: deviceMac ?? '',
|
||||
networkMac: networkMac ?? '');
|
||||
|
||||
break;
|
||||
default:
|
||||
//失败
|
||||
dismissEasyLoading();
|
||||
dismissEasyLoading(); // 关闭loading
|
||||
cancelBlueConnetctToastTimer();
|
||||
if (state.loadingTimer != null) {
|
||||
state.loadingTimer!.cancel();
|
||||
state.loadingTimer = null;
|
||||
}
|
||||
cancelBlueConnetctToastTimer();
|
||||
|
||||
showToast('配网失败'.tr);
|
||||
state.isLoading.value = false;
|
||||
break;
|
||||
@ -164,7 +167,7 @@ class ConfiguringWifiLogic extends BaseGetXController {
|
||||
// 点击配置wifi
|
||||
Future<void> senderConfiguringWifiAction() async {
|
||||
AppLog.log('开始配网${EasyLoading.isShow}');
|
||||
EasyLoading.show();
|
||||
|
||||
if (state.isLoading.isTrue) {
|
||||
AppLog.log('正在配网中请勿重复点击');
|
||||
return;
|
||||
@ -178,10 +181,10 @@ class ConfiguringWifiLogic extends BaseGetXController {
|
||||
showToast('请输入WiFi密码'.tr);
|
||||
return;
|
||||
}
|
||||
if (state.sureBtnState.value == 1) {
|
||||
return;
|
||||
}
|
||||
state.sureBtnState.value = 1;
|
||||
// if (state.sureBtnState.value == 1) {
|
||||
// return;
|
||||
// }
|
||||
// state.sureBtnState.value = 1;
|
||||
|
||||
final GetGatewayConfigurationEntity entity =
|
||||
await ApiRepository.to.getGatewayConfigurationNotLoading(timeout: 60);
|
||||
@ -218,9 +221,13 @@ class ConfiguringWifiLogic extends BaseGetXController {
|
||||
// 如果为空,则直接赋值
|
||||
state.getGatewayConfigurationStr = "{\"userPeerld\": \"$appPeerId\"}";
|
||||
}
|
||||
showEasyLoading();
|
||||
showBlueConnetctToastTimer(action: () {
|
||||
dismissEasyLoading();
|
||||
state.isLoading.value = false;
|
||||
});
|
||||
|
||||
AppLog.log('获取到配网信息===开始发送蓝牙指令${EasyLoading.isShow}');
|
||||
|
||||
// 发送配网指令
|
||||
BlueManage().blueSendData(
|
||||
BlueManage().connectDeviceName,
|
||||
(BluetoothConnectionState connectionState) async {
|
||||
@ -233,35 +240,16 @@ class ConfiguringWifiLogic extends BaseGetXController {
|
||||
} else if (connectionState == BluetoothConnectionState.disconnected) {
|
||||
dismissEasyLoading();
|
||||
cancelBlueConnetctToastTimer();
|
||||
state.sureBtnState.value = 0;
|
||||
state.isLoading.value = false;
|
||||
// state.sureBtnState.value = 0;
|
||||
if (state.ifCurrentScreen.value == true) {
|
||||
showBlueConnetctToast();
|
||||
}
|
||||
}
|
||||
},
|
||||
isAddEquipment: true,
|
||||
isAddEquipment: false,
|
||||
);
|
||||
state.loadingTimer ??= Timer.periodic(Duration(milliseconds: 100), (timer) {
|
||||
if (!EasyLoading.isShow) {
|
||||
EasyLoading.show();
|
||||
}
|
||||
});
|
||||
|
||||
state.isLoading.value = true;
|
||||
// 添加15秒超时检查
|
||||
Future.delayed(const Duration(seconds: 15), () {
|
||||
if (state.isLoading.isTrue) {
|
||||
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}');
|
||||
}
|
||||
|
||||
// 获取设备状态
|
||||
@ -320,7 +308,7 @@ class ConfiguringWifiLogic extends BaseGetXController {
|
||||
|
||||
getWifiLockServiceIpAndPort();
|
||||
_initReplySubscription();
|
||||
getDevicesStatusAction();
|
||||
// getDevicesStatusAction();
|
||||
}
|
||||
|
||||
@override
|
||||
@ -336,13 +324,13 @@ class ConfiguringWifiLogic extends BaseGetXController {
|
||||
|
||||
void _replyGatewayGetStatusReply(GatewayGetStatusReply reply) {
|
||||
final int status = reply.data[2];
|
||||
|
||||
//成功
|
||||
dismissEasyLoading();
|
||||
cancelBlueConnetctToastTimer();
|
||||
switch (status) {
|
||||
case 0x00:
|
||||
//成功
|
||||
// state.sureBtnState.value = 0;
|
||||
cancelBlueConnetctToastTimer();
|
||||
dismissEasyLoading();
|
||||
// state.sureBtnState.value = 0;
|
||||
|
||||
final GetGatewayInfoModel gatewayModel = GetGatewayInfoModel();
|
||||
// 网关MAC地址
|
||||
@ -393,28 +381,17 @@ class ConfiguringWifiLogic extends BaseGetXController {
|
||||
}
|
||||
}
|
||||
|
||||
void _replyStatusInfo(reply) {}
|
||||
|
||||
// 上传数据获取设置
|
||||
Future<void> _getUploadLockSet() async {
|
||||
// showEasyLoading();
|
||||
// showBlueConnetctToastTimer(action: () {
|
||||
// dismissEasyLoading();
|
||||
// });
|
||||
BlueManage().blueSendData(BlueManage().connectDeviceName,
|
||||
(BluetoothConnectionState connectionState) async {
|
||||
if (connectionState == BluetoothConnectionState.connected) {
|
||||
final List<String>? token = await Storage.getStringList(saveBlueToken);
|
||||
final List<int> getTokenList = changeStringListToIntList(token!);
|
||||
|
||||
_uploadLockSet(getTokenList);
|
||||
} else if (connectionState == BluetoothConnectionState.disconnected) {
|
||||
cancelBlueConnetctToastTimer();
|
||||
if (state.ifCurrentScreen.value == true) {
|
||||
showBlueConnetctToast();
|
||||
}
|
||||
}
|
||||
showEasyLoading();
|
||||
showBlueConnetctToastTimer(action: () {
|
||||
dismissEasyLoading();
|
||||
});
|
||||
|
||||
final List<String>? token = await Storage.getStringList(saveBlueToken);
|
||||
final List<int> getTokenList = changeStringListToIntList(token!);
|
||||
|
||||
await _uploadLockSet(getTokenList);
|
||||
}
|
||||
|
||||
// 公共的上传锁设置
|
||||
@ -438,15 +415,15 @@ class ConfiguringWifiLogic extends BaseGetXController {
|
||||
// 上传数据获取锁设置解析
|
||||
Future<void> _replyUpdataLockSetReply(Reply reply) async {
|
||||
final int status = reply.data[2];
|
||||
dismissEasyLoading(); // 关闭loading
|
||||
cancelBlueConnetctToastTimer();
|
||||
switch (status) {
|
||||
case 0x00:
|
||||
//成功
|
||||
dismissEasyLoading();
|
||||
cancelBlueConnetctToastTimer();
|
||||
_lockDataUpload(
|
||||
await _lockDataUpload(
|
||||
uploadType: 1,
|
||||
recordType: 0,
|
||||
records: reply.data.sublist(7, reply.data.length));
|
||||
|
||||
break;
|
||||
case 0x06:
|
||||
//无权限
|
||||
@ -475,33 +452,18 @@ class ConfiguringWifiLogic extends BaseGetXController {
|
||||
records: records,
|
||||
isUnShowLoading: true);
|
||||
if (entity.errorCode!.codeIsSuccessful) {
|
||||
await Future.delayed((Duration(seconds: 1)));
|
||||
if (state.pageName.value == 'lockSet') {
|
||||
Get.close(2);
|
||||
} else {
|
||||
Get.offAllNamed(Routers.starLockMain);
|
||||
}
|
||||
dismissEasyLoading();
|
||||
eventBus
|
||||
.fire(PassCurrentLockInformationEvent(state.lockSetInfoData.value));
|
||||
eventBus
|
||||
.fire(SuccessfulDistributionNetwork());
|
||||
if (state.loadingTimer != null) {
|
||||
state.loadingTimer!.cancel();
|
||||
state.loadingTimer = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
showToast('配网成功'.tr, something: () {
|
||||
state.isLoading.value = false;
|
||||
if (state.pageName.value == 'lockSet') {
|
||||
Get.close(2);
|
||||
} else {
|
||||
Get.offAllNamed(Routers.starLockMain);
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
dismissEasyLoading();
|
||||
// TODO: implement dispose
|
||||
super.dispose();
|
||||
state.isLoading.value = false;
|
||||
if (state.loadingTimer != null) {
|
||||
state.loadingTimer!.cancel();
|
||||
state.loadingTimer = null;
|
||||
eventBus
|
||||
.fire(PassCurrentLockInformationEvent(state.lockSetInfoData.value));
|
||||
eventBus.fire(SuccessfulDistributionNetwork());
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -93,7 +93,6 @@ class NearbyLockLogic extends BaseGetXController {
|
||||
showToast('固件升级完成'.tr);
|
||||
closeOTADAta();
|
||||
}
|
||||
dismissEasyLoading();
|
||||
});
|
||||
}
|
||||
|
||||
@ -160,6 +159,7 @@ class NearbyLockLogic extends BaseGetXController {
|
||||
// 获取星锁状态
|
||||
Future<void> _replyGetStarLockStatusInfo(Reply reply) async {
|
||||
final int status = reply.data[2];
|
||||
dismissEasyLoading();
|
||||
switch (status) {
|
||||
case 0x00:
|
||||
//成功
|
||||
@ -743,8 +743,8 @@ class NearbyLockLogic extends BaseGetXController {
|
||||
|
||||
@override
|
||||
void onClose() {
|
||||
super.onClose();
|
||||
_replySubscription?.cancel();
|
||||
super.onClose();
|
||||
}
|
||||
|
||||
Future<void> getNearByLimits() async {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user