fix: 1、取消锁详情进入操作记录界面就从锁上面拉取记录功能。2、修复操作记录频繁调用接口bug
This commit is contained in:
parent
ad0c0a2e5f
commit
ab1ab37cbd
@ -1,6 +1,7 @@
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:flutter_blue_plus/flutter_blue_plus.dart';
|
||||
import 'package:flutter_easyloading/flutter_easyloading.dart';
|
||||
import 'package:star_lock/app_settings/app_settings.dart';
|
||||
|
||||
import 'package:star_lock/main/lockDetail/doorLockLog/doorLockLog_entity.dart';
|
||||
@ -47,6 +48,7 @@ class DoorLockLogLogic extends BaseGetXController {
|
||||
upload: true
|
||||
);
|
||||
|
||||
state.isLockReceiveResponse = true;
|
||||
cancelBlueConnetctToastTimer();
|
||||
final int status = reply.data[2];
|
||||
|
||||
@ -86,8 +88,8 @@ class DoorLockLogLogic extends BaseGetXController {
|
||||
(0xff & indexList[4]) << 16 |
|
||||
(0xff & indexList[5]) << 8 |
|
||||
(0xFF & indexList[6]);
|
||||
final operateDate = time * 1000;
|
||||
final serverTime = state.currentDate;
|
||||
final int operateDate = time * 1000;
|
||||
final int serverTime = state.currentDate;
|
||||
if (DateTime.fromMillisecondsSinceEpoch(operateDate).isAfter(
|
||||
DateTime.fromMillisecondsSinceEpoch(serverTime*1000))) {
|
||||
// AppLog.log('operateDate:$operateDate state.currentDate:${state.currentDate}');
|
||||
@ -110,6 +112,7 @@ class DoorLockLogLogic extends BaseGetXController {
|
||||
break;
|
||||
default:
|
||||
//失败
|
||||
dismissEasyLoading();
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -138,7 +141,8 @@ class DoorLockLogLogic extends BaseGetXController {
|
||||
privateKey: getPrivateKeyList,
|
||||
).toString();
|
||||
|
||||
showBlueConnetctToastTimer(isShowBlueConnetctToast:false, action: () async {
|
||||
showEasyLoading();
|
||||
showBlueConnetctToastTimer(isShowBlueConnetctToast:true, action: () async {
|
||||
cancelBlueConnetctToastTimer();
|
||||
|
||||
final String getMobile = (await Storage.getMobile())!;
|
||||
@ -155,6 +159,9 @@ class DoorLockLogLogic extends BaseGetXController {
|
||||
eventStr: '查询锁记录事件超时',
|
||||
upload: true
|
||||
);
|
||||
if(state.isLockReceiveResponse == false){
|
||||
dismissEasyLoading();
|
||||
}
|
||||
});
|
||||
BlueManage().blueSendData(BlueManage().connectDeviceName, (BluetoothConnectionState connectionStateState) async {
|
||||
if (connectionStateState == BluetoothConnectionState.connected) {
|
||||
@ -180,6 +187,9 @@ class DoorLockLogLogic extends BaseGetXController {
|
||||
privateKey: getPrivateKeyList,
|
||||
);
|
||||
} else if (connectionStateState == BluetoothConnectionState.disconnected) {
|
||||
if (state.ifCurrentScreen.value == true) {
|
||||
showBlueConnetctToast();
|
||||
}
|
||||
cancelBlueConnetctToastTimer();
|
||||
|
||||
final String getMobile = (await Storage.getMobile())!;
|
||||
@ -225,19 +235,18 @@ class DoorLockLogLogic extends BaseGetXController {
|
||||
|
||||
/// 刷新门锁日志列表
|
||||
StreamSubscription? _getDoorLockLogListRefreshUIEvent;
|
||||
|
||||
void _getDoorLockLogListRefreshUIAction() {
|
||||
_getDoorLockLogListRefreshUIEvent = eventBus
|
||||
.on<DoorLockLogListRefreshUI>()
|
||||
.listen((DoorLockLogListRefreshUI event) {
|
||||
_getDoorLockLogListRefreshUIEvent = eventBus.on<DoorLockLogListRefreshUI>().listen((DoorLockLogListRefreshUI event) {
|
||||
state.currentSelectDate.value = event.getDoorLockLogTime;
|
||||
// 设置startDate为当天的0点
|
||||
|
||||
// 设置startDate为当天的0点
|
||||
state.startDate.value = DateTime(
|
||||
state.currentSelectDate.value.year,
|
||||
state.currentSelectDate.value.month,
|
||||
state.currentSelectDate.value.day)
|
||||
.millisecondsSinceEpoch;
|
||||
// 设置endDate为下一天的0点,然后减去1毫秒
|
||||
|
||||
// 设置endDate为下一天的0点,然后减去1毫秒
|
||||
state.endDate.value = DateTime(
|
||||
state.currentSelectDate.value.year,
|
||||
state.currentSelectDate.value.month,
|
||||
@ -246,7 +255,6 @@ class DoorLockLogLogic extends BaseGetXController {
|
||||
.millisecondsSinceEpoch;
|
||||
|
||||
pageNo = 1;
|
||||
AppLog.log('_getDoorLockLogListRefreshUIAction');
|
||||
mockNetworkDataRequest(isRefresh: true);
|
||||
});
|
||||
}
|
||||
@ -275,6 +283,7 @@ class DoorLockLogLogic extends BaseGetXController {
|
||||
final String getMobile = (await Storage.getMobile())!;
|
||||
if (entity.errorCode!.codeIsSuccessful) {
|
||||
if (state.ifHaveNext == true) {
|
||||
showEasyLoading();
|
||||
getLockRecordLastUploadDataTime();
|
||||
} else {
|
||||
UmengCommonSdk.onEvent('check_doorLockLog', {
|
||||
@ -285,6 +294,7 @@ class DoorLockLogLogic extends BaseGetXController {
|
||||
});
|
||||
mockNetworkDataRequest(isRefresh: true);
|
||||
}
|
||||
dismissEasyLoading();
|
||||
}else{
|
||||
UmengCommonSdk.onEvent('check_doorLockLog', {
|
||||
'lockName':state.keyInfos.value.lockName!,
|
||||
@ -292,6 +302,7 @@ class DoorLockLogLogic extends BaseGetXController {
|
||||
'date':DateTool().getNowDateWithType(1),
|
||||
'open_lock_result':'上传数据接口失败',
|
||||
});
|
||||
dismissEasyLoading();
|
||||
}
|
||||
}
|
||||
|
||||
@ -331,7 +342,7 @@ class DoorLockLogLogic extends BaseGetXController {
|
||||
if (isDemoMode == false) {
|
||||
mockNetworkDataRequest(isRefresh: true);
|
||||
|
||||
getLockRecordLastUploadDataTime();
|
||||
// getLockRecordLastUploadDataTime();
|
||||
_initReplySubscription();
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_easyloading/flutter_easyloading.dart';
|
||||
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
||||
@ -19,7 +20,6 @@ import 'package:timelines/timelines.dart';
|
||||
import '../../../app_settings/app_colors.dart';
|
||||
import '../../../tools/appRouteObserver.dart';
|
||||
import '../../../tools/titleAppBar.dart';
|
||||
import '../../../translations/trans_lib.dart';
|
||||
|
||||
class DoorLockLogPage extends StatefulWidget {
|
||||
const DoorLockLogPage({Key? key}) : super(key: key);
|
||||
@ -88,7 +88,7 @@ class _DoorLockLogPageState extends State<DoorLockLogPage> with RouteAware {
|
||||
body: Column(
|
||||
mainAxisSize: MainAxisSize.max,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
children: <Widget>[
|
||||
topAdvancedCalendarWidget(),
|
||||
Divider(
|
||||
height: 1,
|
||||
@ -124,6 +124,7 @@ class _DoorLockLogPageState extends State<DoorLockLogPage> with RouteAware {
|
||||
switch (value) {
|
||||
case '读取记录':
|
||||
{
|
||||
state.isLockReceiveResponse = false;
|
||||
logic.getLockRecordLastUploadDataTime();
|
||||
}
|
||||
break;
|
||||
@ -177,7 +178,7 @@ class _DoorLockLogPageState extends State<DoorLockLogPage> with RouteAware {
|
||||
disabledColor: Colors.grey,
|
||||
),
|
||||
child: Stack(
|
||||
children: [
|
||||
children: <Widget>[
|
||||
AdvancedCalendar(
|
||||
controller: state.calendarControllerCustom,
|
||||
events: state.events,
|
||||
@ -338,7 +339,6 @@ class _DoorLockLogPageState extends State<DoorLockLogPage> with RouteAware {
|
||||
|
||||
@override
|
||||
void didChangeDependencies() {
|
||||
// TODO: implement didChangeDependencies
|
||||
super.didChangeDependencies();
|
||||
|
||||
/// 路由订阅
|
||||
@ -347,7 +347,6 @@ class _DoorLockLogPageState extends State<DoorLockLogPage> with RouteAware {
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
// TODO: implement dispose
|
||||
/// 取消路由订阅
|
||||
AppRouteObserver().routeObserver.unsubscribe(this);
|
||||
super.dispose();
|
||||
@ -365,7 +364,9 @@ class _DoorLockLogPageState extends State<DoorLockLogPage> with RouteAware {
|
||||
void didPop() {
|
||||
super.didPop();
|
||||
logic.cancelBlueConnetctToastTimer();
|
||||
if (EasyLoading.isShow) EasyLoading.dismiss(animation: true);
|
||||
if (EasyLoading.isShow) {
|
||||
EasyLoading.dismiss(animation: true);
|
||||
}
|
||||
state.ifCurrentScreen.value = false;
|
||||
}
|
||||
|
||||
|
||||
@ -67,4 +67,5 @@ class DoorLockLogState {
|
||||
bool ifHaveNext = false; // 页码
|
||||
int logCountPage = 10; // 蓝牙记录一页多少个
|
||||
Rx<DateTime> currentSelectDate = DateTime.now().obs;
|
||||
bool isLockReceiveResponse = false; // 是否收到回复
|
||||
}
|
||||
|
||||
@ -21,129 +21,129 @@ class LockOperatingRecordLogic extends BaseGetXController {
|
||||
LockOperatingRecordState state = LockOperatingRecordState();
|
||||
|
||||
// 获取解析后的数据
|
||||
late StreamSubscription<Reply> _replySubscription;
|
||||
// late StreamSubscription<Reply> _replySubscription;
|
||||
|
||||
void _initReplySubscription() {
|
||||
_replySubscription =
|
||||
EventBusManager().eventBus!.on<Reply>().listen((Reply reply) {
|
||||
if (reply is SenderReferEventRecordTimeReply) {
|
||||
_replyReferEventRecordTime(reply);
|
||||
}
|
||||
});
|
||||
}
|
||||
// void _initReplySubscription() {
|
||||
// _replySubscription =
|
||||
// EventBusManager().eventBus!.on<Reply>().listen((Reply reply) {
|
||||
// if (reply is SenderReferEventRecordTimeReply) {
|
||||
// _replyReferEventRecordTime(reply);
|
||||
// }
|
||||
// });
|
||||
// }
|
||||
|
||||
// 根据时间查解析数据
|
||||
Future<void> _replyReferEventRecordTime(Reply reply) async {
|
||||
cancelBlueConnetctToastTimer();
|
||||
final int status = reply.data[2];
|
||||
switch (status) {
|
||||
case 0x00:
|
||||
//成功
|
||||
final int dataLength = (reply.data[5] << 8) + reply.data[6];
|
||||
AppLog.log('dataLength:$dataLength');
|
||||
// var dataLength = reply.data[5];
|
||||
if (dataLength > 0) {
|
||||
reply.data.removeRange(0, 7);
|
||||
// 把得到的数据按8位分割成数组 然后塞进一个新的数组里面
|
||||
if (reply.data.length < 17) {
|
||||
return;
|
||||
}
|
||||
final List<List<int>> getList = splitList(reply.data, 17);
|
||||
// AppLog.log("getList:$getList");
|
||||
final List uploadList = [];
|
||||
for (int i = 0; i < getList.length; i++) {
|
||||
final List<int> indexList = getList[i];
|
||||
// AppLog.log("indexList:$indexList");
|
||||
final Map indexMap = {};
|
||||
|
||||
indexMap['type'] = indexList[0].toString();
|
||||
|
||||
final int userNo = (indexList[1] * 256) + indexList[2];
|
||||
indexMap['user'] = userNo.toString();
|
||||
AppLog.log('userNouserNouserNouserNo:$userNo');
|
||||
|
||||
final List<int> passwordData = indexList.sublist(7, 17);
|
||||
final String password = utf8String(passwordData);
|
||||
indexMap['password'] = password.toString();
|
||||
AppLog.log('passwordpasswordpassword:$password');
|
||||
|
||||
indexMap['success'] = '1';
|
||||
|
||||
final int time = (0xff & indexList[3]) << 24 |
|
||||
(0xff & indexList[4]) << 16 |
|
||||
(0xff & indexList[5]) << 8 |
|
||||
(0xFF & indexList[6]);
|
||||
final operateDate = time * 1000;
|
||||
final serverTime = state.currentDate;
|
||||
if (DateTime.fromMillisecondsSinceEpoch(operateDate).isAfter(
|
||||
DateTime.fromMillisecondsSinceEpoch(serverTime*1000))) {
|
||||
continue;
|
||||
}
|
||||
indexMap['date'] = '$operateDate';
|
||||
uploadList.add(indexMap);
|
||||
}
|
||||
if (dataLength == state.logCountPage) {
|
||||
state.ifHaveNext = true;
|
||||
} else {
|
||||
state.ifHaveNext = false;
|
||||
}
|
||||
lockRecordUploadData(uploadList);
|
||||
}
|
||||
break;
|
||||
case 0x06:
|
||||
//无权限 需要鉴权
|
||||
|
||||
break;
|
||||
default:
|
||||
//失败
|
||||
break;
|
||||
}
|
||||
}
|
||||
// Future<void> _replyReferEventRecordTime(Reply reply) async {
|
||||
// cancelBlueConnetctToastTimer();
|
||||
// final int status = reply.data[2];
|
||||
// switch (status) {
|
||||
// case 0x00:
|
||||
// //成功
|
||||
// final int dataLength = (reply.data[5] << 8) + reply.data[6];
|
||||
// AppLog.log('dataLength:$dataLength');
|
||||
// // var dataLength = reply.data[5];
|
||||
// if (dataLength > 0) {
|
||||
// reply.data.removeRange(0, 7);
|
||||
// // 把得到的数据按8位分割成数组 然后塞进一个新的数组里面
|
||||
// if (reply.data.length < 17) {
|
||||
// return;
|
||||
// }
|
||||
// final List<List<int>> getList = splitList(reply.data, 17);
|
||||
// // AppLog.log("getList:$getList");
|
||||
// final List uploadList = [];
|
||||
// for (int i = 0; i < getList.length; i++) {
|
||||
// final List<int> indexList = getList[i];
|
||||
// // AppLog.log("indexList:$indexList");
|
||||
// final Map indexMap = {};
|
||||
//
|
||||
// indexMap['type'] = indexList[0].toString();
|
||||
//
|
||||
// final int userNo = (indexList[1] * 256) + indexList[2];
|
||||
// indexMap['user'] = userNo.toString();
|
||||
// AppLog.log('userNouserNouserNouserNo:$userNo');
|
||||
//
|
||||
// final List<int> passwordData = indexList.sublist(7, 17);
|
||||
// final String password = utf8String(passwordData);
|
||||
// indexMap['password'] = password.toString();
|
||||
// AppLog.log('passwordpasswordpassword:$password');
|
||||
//
|
||||
// indexMap['success'] = '1';
|
||||
//
|
||||
// final int time = (0xff & indexList[3]) << 24 |
|
||||
// (0xff & indexList[4]) << 16 |
|
||||
// (0xff & indexList[5]) << 8 |
|
||||
// (0xFF & indexList[6]);
|
||||
// final operateDate = time * 1000;
|
||||
// final serverTime = state.currentDate;
|
||||
// if (DateTime.fromMillisecondsSinceEpoch(operateDate).isAfter(
|
||||
// DateTime.fromMillisecondsSinceEpoch(serverTime*1000))) {
|
||||
// continue;
|
||||
// }
|
||||
// indexMap['date'] = '$operateDate';
|
||||
// uploadList.add(indexMap);
|
||||
// }
|
||||
// if (dataLength == state.logCountPage) {
|
||||
// state.ifHaveNext = true;
|
||||
// } else {
|
||||
// state.ifHaveNext = false;
|
||||
// }
|
||||
// lockRecordUploadData(uploadList);
|
||||
// }
|
||||
// break;
|
||||
// case 0x06:
|
||||
// //无权限 需要鉴权
|
||||
//
|
||||
// break;
|
||||
// default:
|
||||
// //失败
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
|
||||
// 查询事件记录(时间查询)
|
||||
Future<void> senderReferEventRecordTime() async {
|
||||
showEasyLoading();
|
||||
showBlueConnetctToastTimer(action: () {
|
||||
dismissEasyLoading();
|
||||
});
|
||||
BlueManage().blueSendData(BlueManage().connectDeviceName,
|
||||
(BluetoothConnectionState connectionStateState) async {
|
||||
if (connectionStateState == BluetoothConnectionState.connected) {
|
||||
final List<String>? privateKey =
|
||||
await Storage.getStringList(saveBluePrivateKey);
|
||||
final List<int> getPrivateKeyList =
|
||||
changeStringListToIntList(privateKey!);
|
||||
|
||||
final List<String>? token = await Storage.getStringList(saveBlueToken);
|
||||
final List<int> getTokenList = changeStringListToIntList(token!);
|
||||
|
||||
final List<String>? publicKey =
|
||||
await Storage.getStringList(saveBluePublicKey);
|
||||
final List<int> getPublicKeyList =
|
||||
changeStringListToIntList(publicKey!);
|
||||
|
||||
IoSenderManage.senderReferEventRecordTimeCommand(
|
||||
keyID: BlueManage().connectDeviceName,
|
||||
userID: await Storage.getUid(),
|
||||
logsCount: state.logCountPage,
|
||||
// time:DateTime.now().millisecondsSinceEpoch~/1000,
|
||||
time: state.operateDate,
|
||||
currentDate: state.currentDate,
|
||||
token: getTokenList,
|
||||
needAuthor: 1,
|
||||
publicKey: getPublicKeyList,
|
||||
privateKey: getPrivateKeyList,
|
||||
);
|
||||
} else if (connectionStateState ==
|
||||
BluetoothConnectionState.disconnected) {
|
||||
dismissEasyLoading();
|
||||
cancelBlueConnetctToastTimer();
|
||||
if (state.ifCurrentScreen.value == true) {
|
||||
showBlueConnetctToast();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
// Future<void> senderReferEventRecordTime() async {
|
||||
// showEasyLoading();
|
||||
// showBlueConnetctToastTimer(action: () {
|
||||
// dismissEasyLoading();
|
||||
// });
|
||||
// BlueManage().blueSendData(BlueManage().connectDeviceName,
|
||||
// (BluetoothConnectionState connectionStateState) async {
|
||||
// if (connectionStateState == BluetoothConnectionState.connected) {
|
||||
// final List<String>? privateKey =
|
||||
// await Storage.getStringList(saveBluePrivateKey);
|
||||
// final List<int> getPrivateKeyList =
|
||||
// changeStringListToIntList(privateKey!);
|
||||
//
|
||||
// final List<String>? token = await Storage.getStringList(saveBlueToken);
|
||||
// final List<int> getTokenList = changeStringListToIntList(token!);
|
||||
//
|
||||
// final List<String>? publicKey =
|
||||
// await Storage.getStringList(saveBluePublicKey);
|
||||
// final List<int> getPublicKeyList =
|
||||
// changeStringListToIntList(publicKey!);
|
||||
//
|
||||
// IoSenderManage.senderReferEventRecordTimeCommand(
|
||||
// keyID: BlueManage().connectDeviceName,
|
||||
// userID: await Storage.getUid(),
|
||||
// logsCount: state.logCountPage,
|
||||
// // time:DateTime.now().millisecondsSinceEpoch~/1000,
|
||||
// time: state.operateDate,
|
||||
// currentDate: state.currentDate,
|
||||
// token: getTokenList,
|
||||
// needAuthor: 1,
|
||||
// publicKey: getPublicKeyList,
|
||||
// privateKey: getPrivateKeyList,
|
||||
// );
|
||||
// } else if (connectionStateState ==
|
||||
// BluetoothConnectionState.disconnected) {
|
||||
// dismissEasyLoading();
|
||||
// cancelBlueConnetctToastTimer();
|
||||
// if (state.ifCurrentScreen.value == true) {
|
||||
// showBlueConnetctToast();
|
||||
// }
|
||||
// }
|
||||
// });
|
||||
// }
|
||||
|
||||
//请求操作记录列表
|
||||
Future<KeyOperationRecordEntity> mockNetworkDataRequest() async {
|
||||
@ -180,48 +180,48 @@ class LockOperatingRecordLogic extends BaseGetXController {
|
||||
}
|
||||
|
||||
// 查询锁记录最后时间
|
||||
Future<void> getLockRecordLastUploadDataTime() async {
|
||||
final LockOperatingRecordGetLastRecordTimeEntity entity =
|
||||
await ApiRepository.to.getLockRecordLastUploadDataTime(
|
||||
lockId: CommonDataManage().currentKeyInfo.lockId.toString());
|
||||
if (entity.errorCode!.codeIsSuccessful) {
|
||||
state.operateDate = entity.data!.operateDate! ~/ 1000;
|
||||
state.currentDate = entity.data!.currentDate! ~/ 1000;
|
||||
senderReferEventRecordTime();
|
||||
}
|
||||
}
|
||||
// Future<void> getLockRecordLastUploadDataTime() async {
|
||||
// final LockOperatingRecordGetLastRecordTimeEntity entity =
|
||||
// await ApiRepository.to.getLockRecordLastUploadDataTime(
|
||||
// lockId: CommonDataManage().currentKeyInfo.lockId.toString());
|
||||
// if (entity.errorCode!.codeIsSuccessful) {
|
||||
// state.operateDate = entity.data!.operateDate! ~/ 1000;
|
||||
// state.currentDate = entity.data!.currentDate! ~/ 1000;
|
||||
// senderReferEventRecordTime();
|
||||
// }
|
||||
// }
|
||||
|
||||
// 操作记录上传
|
||||
Future<void> lockRecordUploadData(List list) async {
|
||||
if(list.isEmpty){
|
||||
return;
|
||||
}
|
||||
final KeyOperationRecordEntity entity = await ApiRepository.to
|
||||
.lockRecordUploadData(
|
||||
lockId: CommonDataManage().currentKeyInfo.lockId.toString(),
|
||||
records: list);
|
||||
if (entity.errorCode!.codeIsSuccessful) {
|
||||
if (state.ifHaveNext == true) {
|
||||
getLockRecordLastUploadDataTime();
|
||||
} else {
|
||||
pageNo = 1;
|
||||
mockNetworkDataRequest();
|
||||
}
|
||||
}
|
||||
}
|
||||
// Future<void> lockRecordUploadData(List list) async {
|
||||
// if(list.isEmpty){
|
||||
// return;
|
||||
// }
|
||||
// final KeyOperationRecordEntity entity = await ApiRepository.to
|
||||
// .lockRecordUploadData(
|
||||
// lockId: CommonDataManage().currentKeyInfo.lockId.toString(),
|
||||
// records: list);
|
||||
// if (entity.errorCode!.codeIsSuccessful) {
|
||||
// if (state.ifHaveNext == true) {
|
||||
// getLockRecordLastUploadDataTime();
|
||||
// } else {
|
||||
// pageNo = 1;
|
||||
// mockNetworkDataRequest();
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
//清空操作记录
|
||||
Future<void> clearOperationRecordRequest() async {
|
||||
final KeyOperationRecordEntity entity = await ApiRepository.to
|
||||
.clearOperationRecord(
|
||||
CommonDataManage().currentKeyInfo.lockId.toString());
|
||||
if (entity.errorCode!.codeIsSuccessful) {
|
||||
showToast('清除数据成功', something: () {
|
||||
pageNo = 1;
|
||||
mockNetworkDataRequest();
|
||||
});
|
||||
}
|
||||
}
|
||||
// Future<void> clearOperationRecordRequest() async {
|
||||
// final KeyOperationRecordEntity entity = await ApiRepository.to
|
||||
// .clearOperationRecord(
|
||||
// CommonDataManage().currentKeyInfo.lockId.toString());
|
||||
// if (entity.errorCode!.codeIsSuccessful) {
|
||||
// showToast('清除数据成功', something: () {
|
||||
// pageNo = 1;
|
||||
// mockNetworkDataRequest();
|
||||
// });
|
||||
// }
|
||||
// }
|
||||
|
||||
@override
|
||||
Future<void> onReady() async {
|
||||
@ -244,10 +244,10 @@ class LockOperatingRecordLogic extends BaseGetXController {
|
||||
// 获取是否是演示模式 演示模式不获取接口
|
||||
final bool? isDemoMode = await Storage.getBool(ifIsDemoModeOrNot);
|
||||
if (isDemoMode == false) {
|
||||
getLockRecordLastUploadDataTime();
|
||||
// getLockRecordLastUploadDataTime();
|
||||
// senderReferEventRecordTime();
|
||||
// senderReferEventRecordNumber();
|
||||
_initReplySubscription();
|
||||
// _initReplySubscription();
|
||||
}
|
||||
}
|
||||
|
||||
@ -258,7 +258,7 @@ class LockOperatingRecordLogic extends BaseGetXController {
|
||||
//获取是否是演示模式 演示模式不获取接口
|
||||
final bool? isDemoMode = await Storage.getBool(ifIsDemoModeOrNot);
|
||||
if (isDemoMode == false) {
|
||||
_replySubscription.cancel();
|
||||
// _replySubscription.cancel();
|
||||
// _getDoorLockLogListRefreshUIEvent?.cancel();
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,7 +1,9 @@
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_easyloading/flutter_easyloading.dart';
|
||||
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:star_lock/main/lockDetail/lockOperatingRecord/lockOperatingRecord_state.dart';
|
||||
|
||||
import '../../../app_settings/app_colors.dart';
|
||||
import '../../../tools/EasyRefreshTool.dart';
|
||||
@ -25,11 +27,11 @@ class LockOperatingRecordPage extends StatefulWidget {
|
||||
}
|
||||
|
||||
class _LockOperatingRecordPageState extends State<LockOperatingRecordPage> with RouteAware{
|
||||
final logic = Get.put(LockOperatingRecordLogic());
|
||||
final state = Get.find<LockOperatingRecordLogic>().state;
|
||||
final LockOperatingRecordLogic logic = Get.put(LockOperatingRecordLogic());
|
||||
final LockOperatingRecordState state = Get.find<LockOperatingRecordLogic>().state;
|
||||
|
||||
Future<void> getHttpData() async {
|
||||
var isDemoMode = await Storage.getBool(ifIsDemoModeOrNot);
|
||||
final bool? isDemoMode = await Storage.getBool(ifIsDemoModeOrNot);
|
||||
if (isDemoMode == false) {
|
||||
logic.mockNetworkDataRequest().then((KeyOperationRecordEntity value){
|
||||
if (mounted) {
|
||||
@ -85,7 +87,7 @@ class _LockOperatingRecordPageState extends State<LockOperatingRecordPage> with
|
||||
getHttpData();
|
||||
},
|
||||
child: Column(
|
||||
children: [
|
||||
children: <Widget>[
|
||||
// (CommonDataManage().currentKeyInfo.isLockOwner == 1 ||
|
||||
// CommonDataManage().currentKeyInfo.keyRight == 1)
|
||||
// ? Column(
|
||||
@ -120,13 +122,13 @@ class _LockOperatingRecordPageState extends State<LockOperatingRecordPage> with
|
||||
return Obx(() => state.lockOperatingRecordListData.value.isNotEmpty
|
||||
? ListView.separated(
|
||||
itemCount: state.lockOperatingRecordListData.length,
|
||||
itemBuilder: (c, index) {
|
||||
KeyRecordDataItem dataItem =
|
||||
itemBuilder: (BuildContext c, int index) {
|
||||
final KeyRecordDataItem dataItem =
|
||||
state.lockOperatingRecordListData[index];
|
||||
int? operateDate = dataItem.operateDate;
|
||||
DateTime dateStr =
|
||||
final int? operateDate = dataItem.operateDate;
|
||||
final DateTime dateStr =
|
||||
DateTime.fromMillisecondsSinceEpoch(operateDate!);
|
||||
String operateDateStr =
|
||||
final String operateDateStr =
|
||||
'${dateStr.toLocal().toString().substring(0, 16)} ';
|
||||
// return _operatingRecordItem(getTypeIcon(dataItem.recordType!),
|
||||
// dataItem.recordTypeName!, operateDateStr, () {});
|
||||
@ -181,7 +183,7 @@ class _LockOperatingRecordPageState extends State<LockOperatingRecordPage> with
|
||||
),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
children: [
|
||||
children: <Widget>[
|
||||
Icon(Icons.access_time, size: 35.w),
|
||||
SizedBox(width: 10.w,),
|
||||
Text(
|
||||
@ -196,7 +198,7 @@ class _LockOperatingRecordPageState extends State<LockOperatingRecordPage> with
|
||||
child:Container(
|
||||
margin: EdgeInsets.only(bottom: 3.w),
|
||||
child: Row(
|
||||
children: [
|
||||
children: <Widget>[
|
||||
Flexible(
|
||||
child: Text(
|
||||
userNameStr,
|
||||
@ -273,43 +275,40 @@ class _LockOperatingRecordPageState extends State<LockOperatingRecordPage> with
|
||||
// );
|
||||
// }
|
||||
|
||||
Future _openModalBottomSheet() async {
|
||||
showModalBottomSheet(
|
||||
context: context,
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadiusDirectional.circular(10)),
|
||||
builder: (BuildContext context) {
|
||||
return AlertBottomWidget(
|
||||
topTitle: '',
|
||||
// items: const ['读取记录', '清空记录', '导出记录'],
|
||||
items: const ['清空记录'],
|
||||
chooseCallback: (value) {
|
||||
int getSelectIndex = value;
|
||||
// if (getSelectIndex == 0) {
|
||||
// logic.mockNetworkDataRequest();
|
||||
// } else if (getSelectIndex == 1) {
|
||||
// logic.clearOperationRecordRequest();
|
||||
// }
|
||||
if (getSelectIndex == 0) {
|
||||
logic.clearOperationRecordRequest();
|
||||
}
|
||||
},
|
||||
);
|
||||
});
|
||||
}
|
||||
// Future _openModalBottomSheet() async {
|
||||
// showModalBottomSheet(
|
||||
// context: context,
|
||||
// shape: RoundedRectangleBorder(
|
||||
// borderRadius: BorderRadiusDirectional.circular(10)),
|
||||
// builder: (BuildContext context) {
|
||||
// return AlertBottomWidget(
|
||||
// topTitle: '',
|
||||
// // items: const ['读取记录', '清空记录', '导出记录'],
|
||||
// items: const ['清空记录'],
|
||||
// chooseCallback: (value) {
|
||||
// int getSelectIndex = value;
|
||||
// // if (getSelectIndex == 0) {
|
||||
// // logic.mockNetworkDataRequest();
|
||||
// // } else if (getSelectIndex == 1) {
|
||||
// // logic.clearOperationRecordRequest();
|
||||
// // }
|
||||
// if (getSelectIndex == 0) {
|
||||
// logic.clearOperationRecordRequest();
|
||||
// }
|
||||
// },
|
||||
// );
|
||||
// });
|
||||
// }
|
||||
|
||||
@override
|
||||
void didChangeDependencies() {
|
||||
// TODO: implement didChangeDependencies
|
||||
super.didChangeDependencies();
|
||||
|
||||
/// 路由订阅
|
||||
AppRouteObserver().routeObserver.subscribe(this, ModalRoute.of(context)!);
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
// TODO: implement dispose
|
||||
/// 取消路由订阅
|
||||
AppRouteObserver().routeObserver.unsubscribe(this);
|
||||
super.dispose();
|
||||
@ -327,7 +326,9 @@ class _LockOperatingRecordPageState extends State<LockOperatingRecordPage> with
|
||||
void didPop() {
|
||||
super.didPop();
|
||||
logic.cancelBlueConnetctToastTimer();
|
||||
if (EasyLoading.isShow) EasyLoading.dismiss(animation: true);
|
||||
if (EasyLoading.isShow) {
|
||||
EasyLoading.dismiss(animation: true);
|
||||
}
|
||||
state.ifCurrentScreen.value = false;
|
||||
}
|
||||
|
||||
@ -343,7 +344,9 @@ class _LockOperatingRecordPageState extends State<LockOperatingRecordPage> with
|
||||
void didPushNext() {
|
||||
super.didPushNext();
|
||||
logic.cancelBlueConnetctToastTimer();
|
||||
if (EasyLoading.isShow) EasyLoading.dismiss(animation: true);
|
||||
if (EasyLoading.isShow) {
|
||||
EasyLoading.dismiss(animation: true);
|
||||
}
|
||||
state.ifCurrentScreen.value = false;
|
||||
}
|
||||
|
||||
|
||||
@ -232,8 +232,7 @@ class _AdvancedCalendarState extends State<AdvancedCalendar>
|
||||
child: ValueListenableBuilder<DateTime>(
|
||||
valueListenable: _controller,
|
||||
builder: (_, selectedDate, __) {
|
||||
AppLog.log('****selectedDate: $selectedDate');
|
||||
eventBus.fire(DoorLockLogListRefreshUI(selectedDate));
|
||||
// AppLog.log('****selectedDate: $selectedDate');
|
||||
return Stack(
|
||||
alignment: Alignment.center,
|
||||
children: [
|
||||
@ -252,6 +251,7 @@ class _AdvancedCalendarState extends State<AdvancedCalendar>
|
||||
);
|
||||
}
|
||||
_monthViewCurrentPage.value = pageIndex;
|
||||
AppLog.log('调用onPageChanged');
|
||||
},
|
||||
controller: _monthPageController,
|
||||
physics: _animationController.value == 1.0
|
||||
@ -389,6 +389,8 @@ class _AdvancedCalendarState extends State<AdvancedCalendar>
|
||||
|
||||
void _handleDateChanged(DateTime date) {
|
||||
_controller.value = date;
|
||||
AppLog.log('点击日期了');
|
||||
eventBus.fire(DoorLockLogListRefreshUI(date));
|
||||
}
|
||||
|
||||
void _handleFinishDrag() async {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user