fix: 在选择网关界面当显示出网关时网关拔掉电源,左上键返回再点下一步应没有该网关显示

This commit is contained in:
Liuyf 2025-03-12 11:01:55 +08:00
parent 6769e9af5d
commit 42d9bfd2ec
8 changed files with 92 additions and 24 deletions

View File

@ -1,4 +1,4 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_easyloading/flutter_easyloading.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
@ -19,7 +19,8 @@ class RemoteUnlockingPage extends StatefulWidget {
State<RemoteUnlockingPage> createState() => _RemoteUnlockingPageState();
}
class _RemoteUnlockingPageState extends State<RemoteUnlockingPage> with RouteAware {
class _RemoteUnlockingPageState extends State<RemoteUnlockingPage>
with RouteAware {
final RemoteUnlockingLogic logic = Get.put(RemoteUnlockingLogic());
final RemoteUnlockingState state = Get.find<RemoteUnlockingLogic>().state;
@ -62,16 +63,20 @@ class _RemoteUnlockingPageState extends State<RemoteUnlockingPage> with RouteAwa
],
);
}),
Padding(
padding: EdgeInsets.only(top: 20.h),
child: Text('功能开启后,你将可以通过网关远程开锁。此功能的开启和关闭只能在锁附近通过手机蓝牙进行。'.tr,
style: TextStyle(fontSize: 20.sp)),
),
SizedBox(
height: 40.h,
),
Obx(() => SubmitBtn(
btnName: state.remoteEnable.value == 1
? '关闭'.tr
: '开启'.tr,
btnName: state.remoteEnable.value == 1 ? '关闭'.tr : '开启'.tr,
onClick: () {
//
bool isContains = BlueManage().connectDeviceName.contains('T9A');
bool isContains =
BlueManage().connectDeviceName.contains('T9A');
if (isContains) {
logic.remoteUnlockingOpenOrClose();
} else {

View File

@ -5,6 +5,7 @@ import '../../../login/login/entity/LoginEntity.dart';
import '../../../network/api_repository.dart';
import '../../../tools/eventBusEventManage.dart';
import '../../../tools/showTipView.dart';
import '../../mineSet/transferGateway/selectGetewayList_entity.dart';
import 'gatewayDetail_state.dart';
class GatewayDetailLogic extends BaseGetXController {
@ -40,4 +41,13 @@ class GatewayDetailLogic extends BaseGetXController {
});
}
}
Future<void> getGatewayDetail() async {
final GetewayInfoEntity entity = await ApiRepository.to
.getGatewayDetailData(
gatewayId: state.getewayItemData.value.gatewayId ?? 0, timeout: 60);
if (entity.errorCode!.codeIsSuccessful) {
state.getewayItemData.value = entity.data!;
}
}
}

View File

@ -84,6 +84,8 @@ class _GatewayDetailPageState extends State<GatewayDetailPage> {
action: () {
Get.toNamed(Routers.gatewayConnectionLockPage, arguments: {
'gatewayId': state.getewayItemData.value.gatewayId ?? 0
})?.then((value) {
logic.getGatewayDetail();
});
}),
// CommonItem(

View File

@ -1,5 +1,4 @@
class GetewayDataEntity {
GetewayDataEntity(
{this.errorCode, this.description, this.errorMsg, this.data});
@ -9,6 +8,7 @@ class GetewayDataEntity {
errorMsg = json['errorMsg'];
data = json['data'] != null ? GetewayListData.fromJson(json['data']) : null;
}
int? errorCode;
String? description;
String? errorMsg;
@ -27,8 +27,8 @@ class GetewayDataEntity {
}
class GetewayListData {
GetewayListData({this.list, this.pageNo, this.pageSize, this.pages, this.total});
GetewayListData(
{this.list, this.pageNo, this.pageSize, this.pages, this.total});
GetewayListData.fromJson(Map<String, dynamic> json) {
if (json['list'] != null) {
@ -42,6 +42,7 @@ class GetewayListData {
pages = json['pages'];
total = json['total'];
}
List<GetewayItemData>? list;
int? pageNo;
int? pageSize;
@ -62,20 +63,19 @@ class GetewayListData {
}
class GetewayItemData {
GetewayItemData(
{this.serialNumber,
this.gatewayMac,
this.gatewayName,
this.gatewayType,
this.networkName,
this.networkMac,
this.lockNum,
this.isOnline,
this.firmwareInfo,
this.needUpgrade,
this.version,
this.gatewayId});
this.gatewayMac,
this.gatewayName,
this.gatewayType,
this.networkName,
this.networkMac,
this.lockNum,
this.isOnline,
this.firmwareInfo,
this.needUpgrade,
this.version,
this.gatewayId});
GetewayItemData.fromJson(Map<String, dynamic> json) {
serialNumber = json['serialNumber'];
@ -96,6 +96,7 @@ class GetewayItemData {
version = json['version'];
gatewayId = json['gatewayId'];
}
String? serialNumber;
String? gatewayMac;
String? gatewayName;
@ -130,3 +131,30 @@ class GetewayItemData {
}
}
class GetewayInfoEntity {
GetewayInfoEntity(
{this.errorCode, this.description, this.errorMsg, this.data});
GetewayInfoEntity.fromJson(Map<String, dynamic> json) {
errorCode = json['errorCode'];
description = json['description'];
errorMsg = json['errorMsg'];
data = json['data'] != null ? GetewayItemData.fromJson(json['data']) : null;
}
int? errorCode;
String? description;
String? errorMsg;
GetewayItemData? data;
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = <String, dynamic>{};
data['errorCode'] = errorCode;
data['description'] = description;
data['errorMsg'] = errorMsg;
if (this.data != null) {
data['data'] = this.data!.toJson();
}
return data;
}
}

View File

@ -158,6 +158,7 @@ abstract class Api {
final String gatewaykListURL = '/gateway/list'; //
final String addGatewayURL = '/gateway/add'; //
final String deletGatewayURL = '/gateway/delete'; //
final String gatewayDetailURL = '/gateway/detail'; //
final String transferGatewayConfirmURL =
'/plug/transferPlugConfirm'; //
final String transferGatewayURL = '/plug/transfer'; //

View File

@ -1742,6 +1742,11 @@ class ApiProvider extends BaseProvider {
jsonEncode({'pageNo': pageNo, 'pageSize': pageSize}),
timeout: timeout);
//
Future<Response> getGatewayDetailData(int gatewayId, int timeout) =>
post(gatewayDetailURL.toUrl, jsonEncode({'gatewayId': gatewayId}),
timeout: timeout);
//
Future<Response> addGatewayNetwork(
String gatewayName,
@ -1823,7 +1828,8 @@ class ApiProvider extends BaseProvider {
post(getGatewayConfigURL.toUrl, jsonEncode({}), timeout: timeout);
Future<Response> getGatewayConfigurationNotLoading(int timeout) =>
post(getGatewayConfigURL.toUrl, jsonEncode({}), timeout: timeout,isUnShowLoading: true);
post(getGatewayConfigURL.toUrl, jsonEncode({}),
timeout: timeout, isUnShowLoading: true);
Future<Response> gatewayConnectionLockListLoadData(
int gatewayId, int timeout) =>

View File

@ -496,10 +496,12 @@ class ApiRepository {
final res = await apiProvider.getLockSettingInfoData(lockId);
return LockSetInfoEntity.fromJson(res.body);
}
// ()
Future<LockSetInfoEntity> getLockSettingInfoDataIsNotLoadingIcon(
{required String lockId}) async {
final res = await apiProvider.getLockSettingInfoDataIsNotLoadingIcon(lockId);
final res =
await apiProvider.getLockSettingInfoDataIsNotLoadingIcon(lockId);
return LockSetInfoEntity.fromJson(res.body);
}
@ -1928,6 +1930,13 @@ class ApiRepository {
return GetewayDataEntity.fromJson(res.body);
}
//
Future<GetewayInfoEntity> getGatewayDetailData(
{required int gatewayId, required int timeout}) async {
final res = await apiProvider.getGatewayDetailData(gatewayId, timeout);
return GetewayInfoEntity.fromJson(res.body);
}
//
Future<LoginEntity> gatewayDistributionNetwork(
{required String gatewayName,
@ -2027,7 +2036,6 @@ class ApiRepository {
return GetGatewayConfigurationEntity.fromJson(res.body);
}
//
Future<RecipientInformationEntity> removeBrokenLockData(
{required List lockIdList}) async {

View File

@ -1045,6 +1045,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "0.4.13"
jverify:
dependency: "direct main"
description:
name: jverify
sha256: "26d1667d8c71403b77a2620a8c618625f8b4bfc950dac285b8f35ebc5e60fa5a"
url: "https://pub.dev"
source: hosted
version: "3.0.0"
leak_tracker:
dependency: transitive
description: