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/material.dart';
import 'package:flutter_easyloading/flutter_easyloading.dart'; import 'package:flutter_easyloading/flutter_easyloading.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart';
@ -19,7 +19,8 @@ class RemoteUnlockingPage extends StatefulWidget {
State<RemoteUnlockingPage> createState() => _RemoteUnlockingPageState(); 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 RemoteUnlockingLogic logic = Get.put(RemoteUnlockingLogic());
final RemoteUnlockingState state = Get.find<RemoteUnlockingLogic>().state; 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( SizedBox(
height: 40.h, height: 40.h,
), ),
Obx(() => SubmitBtn( Obx(() => SubmitBtn(
btnName: state.remoteEnable.value == 1 btnName: state.remoteEnable.value == 1 ? '关闭'.tr : '开启'.tr,
? '关闭'.tr
: '开启'.tr,
onClick: () { onClick: () {
// //
bool isContains = BlueManage().connectDeviceName.contains('T9A'); bool isContains =
BlueManage().connectDeviceName.contains('T9A');
if (isContains) { if (isContains) {
logic.remoteUnlockingOpenOrClose(); logic.remoteUnlockingOpenOrClose();
} else { } else {

View File

@ -5,6 +5,7 @@ import '../../../login/login/entity/LoginEntity.dart';
import '../../../network/api_repository.dart'; import '../../../network/api_repository.dart';
import '../../../tools/eventBusEventManage.dart'; import '../../../tools/eventBusEventManage.dart';
import '../../../tools/showTipView.dart'; import '../../../tools/showTipView.dart';
import '../../mineSet/transferGateway/selectGetewayList_entity.dart';
import 'gatewayDetail_state.dart'; import 'gatewayDetail_state.dart';
class GatewayDetailLogic extends BaseGetXController { 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: () { action: () {
Get.toNamed(Routers.gatewayConnectionLockPage, arguments: { Get.toNamed(Routers.gatewayConnectionLockPage, arguments: {
'gatewayId': state.getewayItemData.value.gatewayId ?? 0 'gatewayId': state.getewayItemData.value.gatewayId ?? 0
})?.then((value) {
logic.getGatewayDetail();
}); });
}), }),
// CommonItem( // CommonItem(

View File

@ -1,5 +1,4 @@
class GetewayDataEntity { class GetewayDataEntity {
GetewayDataEntity( GetewayDataEntity(
{this.errorCode, this.description, this.errorMsg, this.data}); {this.errorCode, this.description, this.errorMsg, this.data});
@ -9,6 +8,7 @@ class GetewayDataEntity {
errorMsg = json['errorMsg']; errorMsg = json['errorMsg'];
data = json['data'] != null ? GetewayListData.fromJson(json['data']) : null; data = json['data'] != null ? GetewayListData.fromJson(json['data']) : null;
} }
int? errorCode; int? errorCode;
String? description; String? description;
String? errorMsg; String? errorMsg;
@ -27,8 +27,8 @@ class GetewayDataEntity {
} }
class GetewayListData { class GetewayListData {
GetewayListData(
GetewayListData({this.list, this.pageNo, this.pageSize, this.pages, this.total}); {this.list, this.pageNo, this.pageSize, this.pages, this.total});
GetewayListData.fromJson(Map<String, dynamic> json) { GetewayListData.fromJson(Map<String, dynamic> json) {
if (json['list'] != null) { if (json['list'] != null) {
@ -42,6 +42,7 @@ class GetewayListData {
pages = json['pages']; pages = json['pages'];
total = json['total']; total = json['total'];
} }
List<GetewayItemData>? list; List<GetewayItemData>? list;
int? pageNo; int? pageNo;
int? pageSize; int? pageSize;
@ -62,20 +63,19 @@ class GetewayListData {
} }
class GetewayItemData { class GetewayItemData {
GetewayItemData( GetewayItemData(
{this.serialNumber, {this.serialNumber,
this.gatewayMac, this.gatewayMac,
this.gatewayName, this.gatewayName,
this.gatewayType, this.gatewayType,
this.networkName, this.networkName,
this.networkMac, this.networkMac,
this.lockNum, this.lockNum,
this.isOnline, this.isOnline,
this.firmwareInfo, this.firmwareInfo,
this.needUpgrade, this.needUpgrade,
this.version, this.version,
this.gatewayId}); this.gatewayId});
GetewayItemData.fromJson(Map<String, dynamic> json) { GetewayItemData.fromJson(Map<String, dynamic> json) {
serialNumber = json['serialNumber']; serialNumber = json['serialNumber'];
@ -96,6 +96,7 @@ class GetewayItemData {
version = json['version']; version = json['version'];
gatewayId = json['gatewayId']; gatewayId = json['gatewayId'];
} }
String? serialNumber; String? serialNumber;
String? gatewayMac; String? gatewayMac;
String? gatewayName; 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 gatewaykListURL = '/gateway/list'; //
final String addGatewayURL = '/gateway/add'; // final String addGatewayURL = '/gateway/add'; //
final String deletGatewayURL = '/gateway/delete'; // final String deletGatewayURL = '/gateway/delete'; //
final String gatewayDetailURL = '/gateway/detail'; //
final String transferGatewayConfirmURL = final String transferGatewayConfirmURL =
'/plug/transferPlugConfirm'; // '/plug/transferPlugConfirm'; //
final String transferGatewayURL = '/plug/transfer'; // final String transferGatewayURL = '/plug/transfer'; //

View File

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

View File

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

View File

@ -1045,6 +1045,14 @@ packages:
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "0.4.13" 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: leak_tracker:
dependency: transitive dependency: transitive
description: description: