From 41ee8d062f1de20af36cc59a794900a082efdb35 Mon Sep 17 00:00:00 2001 From: Daisy <> Date: Mon, 26 Feb 2024 17:56:30 +0800 Subject: [PATCH 1/4] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E9=97=A8=E9=94=81?= =?UTF-8?q?=E6=97=A5=E5=BF=97=E9=A1=B5=E9=9D=A2=E6=8E=A5=E5=8F=A3=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E4=B8=8EUI=E7=9A=84=E9=80=BB=E8=BE=91=E5=A4=84?= =?UTF-8?q?=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- star_lock/assets/DoorLockLogEntity.json | 77 +++++++++++ .../doorLockLog/doorLockLog_entity.dart | 119 +++++++++++++++++ .../doorLockLog/doorLockLog_logic.dart | 44 +++--- .../doorLockLog/doorLockLog_page.dart | 125 ++++++++++-------- .../doorLockLog/doorLockLog_state.dart | 16 ++- .../lockDetail/lockDetail_page.dart | 14 +- .../lockOperatingRecord_logic.dart | 73 +++++----- .../lockSet/lockSet/lockSet_page.dart | 24 ++-- star_lock/lib/network/api_repository.dart | 5 +- 9 files changed, 364 insertions(+), 133 deletions(-) create mode 100644 star_lock/assets/DoorLockLogEntity.json create mode 100644 star_lock/lib/main/lockDetail/doorLockLog/doorLockLog_entity.dart diff --git a/star_lock/assets/DoorLockLogEntity.json b/star_lock/assets/DoorLockLogEntity.json new file mode 100644 index 00000000..258e0dc2 --- /dev/null +++ b/star_lock/assets/DoorLockLogEntity.json @@ -0,0 +1,77 @@ +{ + "errorCode": 0, + "description": "success", + "errorMsg": "success", + "data": { + "list": [{ + "recordId": 42672, + "lockId": 1744, + "lockAlias": "T9A_d7d74b2f66b8", + "recordType": 130, + "recordTypeName": "防拆报警", + "username": "", + "operateDate": 1705852800000, + "imagesUrl": null, + "videoUrl": null, + "headUrl": "", + "userid": "" + }, + { + "recordId": 42660, + "lockId": 1744, + "lockAlias": "T9A_d7d74b2f66b8", + "recordType": 220, + "recordTypeName": "逗留检测", + "username": "", + "operateDate": 1706494730335, + "imagesUrl": "http:\/\/oss-pre-starlock.star-lock.cn\/starchart\/T9A_d7d74b2f66b8-1706494718\/54c5044a-93bd-466d-a123-e1face292841.jpg", + "videoUrl": "http:\/\/oss-pre-starlock.star-lock.cn\/starchart\/T9A_d7d74b2f66b8-1706494718\/08a2b732-536b-4f06-9d20-778fdf94f137.mp4", + "headUrl": "", + "userid": "" + }, + { + "recordId": 42659, + "lockId": 1744, + "lockAlias": "T9A_d7d74b2f66b8", + "recordType": 220, + "recordTypeName": "逗留检测", + "username": "", + "operateDate": 1706494672036, + "imagesUrl": "http:\/\/oss-pre-starlock.star-lock.cn\/starchart\/T9A_d7d74b2f66b8-1706494660\/d85dcea0-c402-4f68-8664-5641a0feabe3.jpg", + "videoUrl": "http:\/\/oss-pre-starlock.star-lock.cn\/starchart\/T9A_d7d74b2f66b8-1706494660\/f3de0384-63f8-4177-9611-d8c43707afce.mp4", + "headUrl": "", + "userid": "" + }, + { + "recordId": 42658, + "lockId": 1744, + "lockAlias": "T9A_d7d74b2f66b8", + "recordType": 130, + "recordTypeName": "防拆报警", + "username": "", + "operateDate": 1706493793884, + "imagesUrl": "http:\/\/oss-pre-starlock.star-lock.cn\/starchart\/T9A_d7d74b2f66b8-1706493778\/f43ec840-ddaa-4d94-b759-7ae4384edd8f.jpg", + "videoUrl": "http:\/\/oss-pre-starlock.star-lock.cn\/starchart\/T9A_d7d74b2f66b8-1706493778\/b4a90c5c-d86f-4995-8365-d7e21a67a48d.mp4", + "headUrl": "", + "userid": "" + }, + { + "recordId": 42657, + "lockId": 1744, + "lockAlias": "T9A_d7d74b2f66b8", + "recordType": 130, + "recordTypeName": "防拆报警", + "username": "", + "operateDate": 1706493715812, + "imagesUrl": "http:\/\/oss-pre-starlock.star-lock.cn\/starchart\/T9A_d7d74b2f66b8-1706493702\/928c2b1d-1cd4-4d7f-9e61-e9315f8c4547.jpg", + "videoUrl": "http:\/\/oss-pre-starlock.star-lock.cn\/starchart\/T9A_d7d74b2f66b8-1706493702\/29e8b8e4-cd79-436d-a384-3e50dacf5cc8.mp4", + "headUrl": "", + "userid": "" + } + ], + "pageNo": 1, + "pageSize": 5, + "pages": 4, + "total": 18 + } +} \ No newline at end of file diff --git a/star_lock/lib/main/lockDetail/doorLockLog/doorLockLog_entity.dart b/star_lock/lib/main/lockDetail/doorLockLog/doorLockLog_entity.dart new file mode 100644 index 00000000..864ce1c6 --- /dev/null +++ b/star_lock/lib/main/lockDetail/doorLockLog/doorLockLog_entity.dart @@ -0,0 +1,119 @@ +class DoorLockLogEntity { + int? errorCode; + String? description; + String? errorMsg; + Data? data; + + DoorLockLogEntity( + {this.errorCode, this.description, this.errorMsg, this.data}); + + DoorLockLogEntity.fromJson(Map json) { + errorCode = json['errorCode']; + description = json['description']; + errorMsg = json['errorMsg']; + data = json['data'] != null ? Data.fromJson(json['data']) : null; + } + + Map toJson() { + final Map data = {}; + data['errorCode'] = errorCode; + data['description'] = description; + data['errorMsg'] = errorMsg; + if (this.data != null) { + data['data'] = this.data!.toJson(); + } + return data; + } +} + +class Data { + List? itemList; + int? pageNo; + int? pageSize; + int? pages; + int? total; + + Data({this.itemList, this.pageNo, this.pageSize, this.pages, this.total}); + + Data.fromJson(Map json) { + if (json['list'] != null) { + itemList = []; + json['list'].forEach((v) { + itemList!.add(DoorLockLogDataItem.fromJson(v)); + }); + } + pageNo = json['pageNo']; + pageSize = json['pageSize']; + pages = json['pages']; + total = json['total']; + } + + Map toJson() { + final Map data = {}; + if (itemList != null) { + data['list'] = itemList!.map((v) => v.toJson()).toList(); + } + data['pageNo'] = pageNo; + data['pageSize'] = pageSize; + data['pages'] = pages; + data['total'] = total; + return data; + } +} + +class DoorLockLogDataItem { + int? recordId; + int? lockId; + String? lockAlias; + int? recordType; + String? recordTypeName; + String? username; + int? operateDate; + String? imagesUrl; + String? videoUrl; + String? headUrl; + String? userid; + + DoorLockLogDataItem( + {this.recordId, + this.lockId, + this.lockAlias, + this.recordType, + this.recordTypeName, + this.username, + this.operateDate, + this.imagesUrl, + this.videoUrl, + this.headUrl, + this.userid}); + + DoorLockLogDataItem.fromJson(Map json) { + recordId = json['recordId']; + lockId = json['lockId']; + lockAlias = json['lockAlias']; + recordType = json['recordType']; + recordTypeName = json['recordTypeName']; + username = json['username']; + operateDate = json['operateDate']; + imagesUrl = json['imagesUrl']; + videoUrl = json['videoUrl']; + headUrl = json['headUrl']; + userid = json['userid']; + } + + Map toJson() { + final Map data = {}; + data['recordId'] = recordId; + data['lockId'] = lockId; + data['lockAlias'] = lockAlias; + data['recordType'] = recordType; + data['recordTypeName'] = recordTypeName; + data['username'] = username; + data['operateDate'] = operateDate; + data['imagesUrl'] = imagesUrl; + data['videoUrl'] = videoUrl; + data['headUrl'] = headUrl; + data['userid'] = userid; + return data; + } +} diff --git a/star_lock/lib/main/lockDetail/doorLockLog/doorLockLog_logic.dart b/star_lock/lib/main/lockDetail/doorLockLog/doorLockLog_logic.dart index 757b05f8..21e4ff9e 100644 --- a/star_lock/lib/main/lockDetail/doorLockLog/doorLockLog_logic.dart +++ b/star_lock/lib/main/lockDetail/doorLockLog/doorLockLog_logic.dart @@ -1,7 +1,10 @@ import 'dart:async'; +import 'dart:convert'; +import 'package:flutter/services.dart'; import 'package:flutter_easyloading/flutter_easyloading.dart'; import 'package:flutter_reactive_ble/flutter_reactive_ble.dart'; +import 'package:star_lock/main/lockDetail/doorLockLog/doorLockLog_entity.dart'; import 'package:star_lock/main/lockDetail/doorLockLog/doorLockLog_state.dart'; import 'package:star_lock/main/lockDetail/lockOperatingRecord/lockOperatingRecordGetLastRecordTime_entity.dart'; import 'package:star_lock/tools/eventBusEventManage.dart'; @@ -186,16 +189,17 @@ class DoorLockLogLogic extends BaseGetXController { //请求操作记录列表(门锁日志) void mockNetworkDataRequest() async { - KeyOperationRecordEntity entity = await ApiRepository.to.lockEventList( + DoorLockLogEntity entity = await ApiRepository.to.lockEventList( lockId: state.keyInfos.value.lockId!, lockEventType: state.dropdownValue.value, pageNo: 1, pageSize: 20, startDate: state.startDate.value, endDate: state.endDate.value); - if (entity.errorCode!.codeIsSuccessful) { - print("操作记录列表成功:${entity.data?.itemList}"); - state.lockOperatingRecordListData.value = entity.data!.itemList!; + + if (state.lockLogEntity.value.errorCode!.codeIsSuccessful) { + print("操作记录列表成功:${state.lockLogEntity.value.data?.itemList}"); + state.lockLogItemList.value = state.lockLogEntity.value.data!.itemList!; } else {} } @@ -259,35 +263,26 @@ class DoorLockLogLogic extends BaseGetXController { // 获取是否是演示模式 演示模式不获取接口 var isDemoMode = await Storage.getBool(ifIsDemoModeOrNot); if (isDemoMode == false) { - _initReplySubscription(); + // _initReplySubscription(); - mockNetworkDataRequest(); - _getDoorLockLogListRefreshUIAction(); + // mockNetworkDataRequest(); + // _getDoorLockLogListRefreshUIAction(); } } @override Future onInit() async { - // TODO: implement onInit super.onInit(); - print("onInit()"); // 获取是否是演示模式 演示模式不获取接口 var isDemoMode = await Storage.getBool(ifIsDemoModeOrNot); if (isDemoMode == false) { - // getLockRecordLastUploadDataTime(); + getLockRecordLastUploadDataTime(); // senderReferEventRecordTime(); // senderReferEventRecordNumber(); - } - DateTime now = DateTime.now(); -// 设置startDate为当天的0点 - state.startDate.value = - DateTime(now.year, now.month, now.day).millisecondsSinceEpoch; -// 设置endDate为下一天的0点,然后减去1毫秒 - state.endDate.value = (DateTime(now.year, now.month, now.day + 1) - .subtract(const Duration(milliseconds: 1))) - .millisecondsSinceEpoch; + mockNetworkDataRequest(); + } } @override @@ -302,4 +297,15 @@ class DoorLockLogLogic extends BaseGetXController { _getDoorLockLogListRefreshUIEvent?.cancel(); } } + +//测试方法,得到真实数据后删除 + testReadJsonData() async { + // 读取JSON文件 + String jsonString = + await rootBundle.loadString('assets/DoorLockLogEntity.json'); + + // 解析JSON数据并转换为实体对象 + Map jsonData = json.decode(jsonString); + state.lockLogEntity.value = DoorLockLogEntity.fromJson(jsonData); + } } diff --git a/star_lock/lib/main/lockDetail/doorLockLog/doorLockLog_page.dart b/star_lock/lib/main/lockDetail/doorLockLog/doorLockLog_page.dart index b8a6e0dd..e5ace84c 100644 --- a/star_lock/lib/main/lockDetail/doorLockLog/doorLockLog_page.dart +++ b/star_lock/lib/main/lockDetail/doorLockLog/doorLockLog_page.dart @@ -2,6 +2,7 @@ import 'package:flutter/material.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:get/get.dart'; import 'package:star_lock/appRouters.dart'; +import 'package:star_lock/main/lockDetail/doorLockLog/doorLockLog_entity.dart'; import 'package:star_lock/main/lockDetail/doorLockLog/doorLockLog_logic.dart'; import 'package:star_lock/tools/advancedCalendar/src/widget.dart'; import 'package:star_lock/tools/menuItem/xsDropDownWidget.dart'; @@ -66,15 +67,7 @@ class _DoorLockLogPageState extends State { endIndent: 30.w, ), eventDropDownWidget(), - // Expanded(child: timeLineView()) - Expanded( - child: ListView.builder( - itemBuilder: (context, index) { - return timeLineView(); - }, - itemCount: state.lockOperatingRecordListData.value.length, - ), - ), + Expanded(child: Obx(() => timeLineView(state.lockLogItemList.value))) ], ), ); @@ -131,7 +124,6 @@ class _DoorLockLogPageState extends State { items: state.getDropDownItemList, value: state.dropdownTitle.value, valueChanged: (value) { - print('dropdownValue选中了$value'); state.dropdownValue.value = int.parse(value); logic.mockNetworkDataRequest(); })), @@ -141,64 +133,89 @@ class _DoorLockLogPageState extends State { } //时间轴组件 - Widget timeLineView() { + Widget timeLineView(List timelineDataList) { return Container( margin: EdgeInsets.only(left: 20.w, right: 20.w, bottom: 20.h, top: 20.h), - //给contain设置一个10像素的圆角 decoration: BoxDecoration( - color: Colors.white, borderRadius: BorderRadius.circular(16.w)), + color: Colors.white, + borderRadius: BorderRadius.circular(16.w), + ), child: Timeline.tileBuilder( builder: TimelineTileBuilder.fromStyle( contentsAlign: ContentsAlign.basic, - contentsBuilder: (context, index) => Padding( - padding: EdgeInsets.only(left: 20.w, top: 20.h), - child: Column( - mainAxisAlignment: MainAxisAlignment.start, - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Text('09:30 有人出现在门口', + itemCount: timelineDataList.length, + contentsBuilder: (context, index) { + DoorLockLogDataItem timelineData = timelineDataList[index]; + DateTime dateTime = + DateTime.fromMillisecondsSinceEpoch(timelineData.operateDate!); + String formattedTime = + '${dateTime.hour.toString().padLeft(2, '0')}:${dateTime.minute.toString().padLeft(2, '0')}'; + + return Padding( + padding: EdgeInsets.only(left: 20.w, top: 20.h), + child: Column( + mainAxisAlignment: MainAxisAlignment.start, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + '$formattedTime ${timelineData.recordTypeName}', textAlign: TextAlign.left, style: TextStyle( - color: Colors.black, - fontSize: 24.sp, - fontWeight: FontWeight.w600)), - GestureDetector( - onTap: () { - Get.toNamed(Routers.videoLogDetailPage); - }, - child: Stack( - children: [ - Image( - image: const AssetImage( - 'images/main/icon_lockDetail_monitoringvoiceFrist.png'), - width: 260.w, - height: 260.h, - ), - //在图片上添加一个三角视频图标 - Positioned( - top: 200.h, - left: 10.w, - child: Image( - image: const AssetImage( - 'images/main/icon_lockLog_play.png'), - width: 24.w, - height: 20.w, - ), - ), - ], + color: Colors.black, + fontSize: 24.sp, + fontWeight: FontWeight.w600, + ), ), - ), - ], - ), - ), - itemCount: 10, + GestureDetector( + onTap: () { + Get.toNamed(Routers.videoLogDetailPage); + }, + child: Stack( + children: [ + if (timelineData.imagesUrl != null) + // Image.network( + // timelineData.imagesUrl!, + // width: 260.w, + // height: 260.h, + // ) + Image( + image: const AssetImage( + 'images/main/icon_lockDetail_monitoringvoiceFrist.png'), + width: 260.w, + height: 260.h, + ) + else + Container(), + Positioned( + top: 200.h, + left: 10.w, + child: Image( + image: const AssetImage( + 'images/main/icon_lockLog_play.png'), + width: 24.w, + height: 20.w, + ), + ), + ], + ), + ), + ], + ), + ); + }, ), theme: TimelineThemeData( nodePosition: 0.04, //居左侧距离 connectorTheme: const ConnectorThemeData( - thickness: 1.0, color: AppColors.greyLineColor, indent: 0.5), + thickness: 1.0, + color: AppColors.greyLineColor, + indent: 0.5, + ), indicatorTheme: const IndicatorThemeData( - size: 8.0, color: AppColors.greyLineColor, position: 0.07), + size: 8.0, + color: AppColors.greyLineColor, + position: 0.7, + ), ), ), ); diff --git a/star_lock/lib/main/lockDetail/doorLockLog/doorLockLog_state.dart b/star_lock/lib/main/lockDetail/doorLockLog/doorLockLog_state.dart index ae9e06f7..18a62a68 100644 --- a/star_lock/lib/main/lockDetail/doorLockLog/doorLockLog_state.dart +++ b/star_lock/lib/main/lockDetail/doorLockLog/doorLockLog_state.dart @@ -1,14 +1,15 @@ import 'package:get/get.dart'; import 'package:star_lock/common/XSConstantMacro/XSConstantMacro.dart'; +import 'package:star_lock/main/lockDetail/doorLockLog/doorLockLog_entity.dart'; import 'package:star_lock/tools/advancedCalendar/src/controller.dart'; import 'package:star_lock/tools/menuItem/dropDownItem.dart'; import '../../lockMian/entity/lockListInfo_entity.dart'; -import '../electronicKey/electronicKeyDetail/keyOperationRecordEntity.dart'; class DoorLockLogState { + final lockLogEntity = DoorLockLogEntity().obs; final keyInfos = LockListInfoItemEntity().obs; - final lockOperatingRecordListData = [].obs; + final lockLogItemList = [].obs; final calendarControllerToday = AdvancedCalendarController.today(); final calendarControllerCustom = AdvancedCalendarController.today(); final events = [ @@ -16,8 +17,15 @@ class DoorLockLogState { DateTime(2024, 10, 10), ]; - final startDate = 0.obs; - final endDate = 0.obs; + final startDate = + DateTime(DateTime.now().year, DateTime.now().month, DateTime.now().day) + .millisecondsSinceEpoch + .obs; + final endDate = (DateTime( + DateTime.now().year, DateTime.now().month, DateTime.now().day + 1) + .subtract(const Duration(milliseconds: 1))) + .millisecondsSinceEpoch + .obs; var dropdownTitle = '全部事件'.obs; var dropdownValue = XSConstantMacro.lockEventTypeAll.obs; diff --git a/star_lock/lib/main/lockDetail/lockDetail/lockDetail_page.dart b/star_lock/lib/main/lockDetail/lockDetail/lockDetail_page.dart index 2d98164d..7fcf5eab 100644 --- a/star_lock/lib/main/lockDetail/lockDetail/lockDetail_page.dart +++ b/star_lock/lib/main/lockDetail/lockDetail/lockDetail_page.dart @@ -160,10 +160,10 @@ class _LockDetailPageState extends State )))), Positioned( child: Obx(() => GestureDetector( - onTap: (){ - logic.getStarLockStatus(); - }, - child: Row( + onTap: () { + logic.getStarLockStatus(); + }, + child: Row( mainAxisAlignment: MainAxisAlignment.end, children: [ Image.asset( @@ -184,7 +184,7 @@ class _LockDetailPageState extends State SizedBox(width: 20.w), ], ), - ))) + ))) ], ), SizedBox(height: 30.h), @@ -391,6 +391,10 @@ class _LockDetailPageState extends State '照明', state.bottomBtnisUneable.value, () {})); // 照明 + showWidgetArr.add(bottomItem('images/main/icon_lockDetail_illuminator.png', + '门磁', state.bottomBtnisUneable.value, () {})); + + // 门磁 showWidgetArr.add(bottomItem('images/main/icon_lockDetail_illuminator.png', '开门器', state.bottomBtnisUneable.value, () {})); diff --git a/star_lock/lib/main/lockDetail/lockOperatingRecord/lockOperatingRecord_logic.dart b/star_lock/lib/main/lockDetail/lockOperatingRecord/lockOperatingRecord_logic.dart index ac8a3fa7..2bb2e546 100644 --- a/star_lock/lib/main/lockDetail/lockOperatingRecord/lockOperatingRecord_logic.dart +++ b/star_lock/lib/main/lockDetail/lockOperatingRecord/lockOperatingRecord_logic.dart @@ -1,4 +1,3 @@ - import 'dart:async'; import 'package:flutter_easyloading/flutter_easyloading.dart'; @@ -17,18 +16,19 @@ import '../electronicKey/electronicKeyDetail/keyOperationRecordEntity.dart'; import 'lockOperatingRecordGetLastRecordTime_entity.dart'; import 'lockOperatingRecord_state.dart'; -class LockOperatingRecordLogic extends BaseGetXController{ +class LockOperatingRecordLogic extends BaseGetXController { LockOperatingRecordState state = LockOperatingRecordState(); // 获取解析后的数据 late StreamSubscription _replySubscription; void _initReplySubscription() { - _replySubscription = EventBusManager().eventBus!.on().listen((reply) { + _replySubscription = + EventBusManager().eventBus!.on().listen((reply) { // if(reply is SenderReferEventRecordNumberReply) { // _replyReferEventRecordNumber(reply); // } - if(reply is SenderReferEventRecordTimeReply) { + if (reply is SenderReferEventRecordTimeReply) { _replyReferEventRecordTime(reply); } }); @@ -69,17 +69,17 @@ class LockOperatingRecordLogic extends BaseGetXController{ // 根据时间查解析数据 Future _replyReferEventRecordTime(Reply reply) async { int status = reply.data[2]; - switch(status){ + switch (status) { case 0x00: //成功 print("${reply.commandType}数据解析成功"); - if(reply.data[5] > 0){ + if (reply.data[5] > 0) { reply.data.removeRange(0, 6); // 把得到的数据按8位分割成数组 然后塞进一个新的数组里面 var getList = splitList(reply.data, 8); print("getList:$getList"); var uploadList = []; - for(int i = 0; i senderReferEventRecordTime(int time) async { - BlueManage().bludSendData(BlueManage().connectDeviceName, (DeviceConnectionState state) async { + BlueManage().bludSendData(BlueManage().connectDeviceName, + (DeviceConnectionState state) async { if (state == DeviceConnectionState.connected) { var privateKey = await Storage.getStringList(saveBluePrivateKey); List getPrivateKeyList = changeStringListToIntList(privateKey!); @@ -168,15 +169,15 @@ class LockOperatingRecordLogic extends BaseGetXController{ EasyLoading.show(); IoSenderManage.senderReferEventRecordTimeCommand( - keyID:BlueManage().connectDeviceName, - userID:await Storage.getUid(), - logsCount:20, + keyID: BlueManage().connectDeviceName, + userID: await Storage.getUid(), + logsCount: 20, // time:DateTime.now().millisecondsSinceEpoch~/1000, time: time, - token:getTokenList, - needAuthor:1, - publicKey:getPublicKeyList, - privateKey:getPrivateKeyList, + token: getTokenList, + needAuthor: 1, + publicKey: getPublicKeyList, + privateKey: getPrivateKeyList, ); } }); @@ -202,25 +203,24 @@ class LockOperatingRecordLogic extends BaseGetXController{ if (entity.errorCode!.codeIsSuccessful) { print("操作记录列表成功:${entity.data?.itemList}"); state.lockOperatingRecordListData.value = entity.data!.itemList!; - }else{ - - } + } else {} } // 查询锁记录最后时间 void getLockRecordLastUploadDataTime() async { - LockOperatingRecordGetLastRecordTimeEntity entity = - await ApiRepository.to.getLockRecordLastUploadDataTime(lockId: state.keyInfos.value.lockId.toString()); + LockOperatingRecordGetLastRecordTimeEntity entity = await ApiRepository.to + .getLockRecordLastUploadDataTime( + lockId: state.keyInfos.value.lockId.toString()); if (entity.errorCode!.codeIsSuccessful) { - senderReferEventRecordTime(entity.data!.operateDate!~/1000); + senderReferEventRecordTime(entity.data!.operateDate! ~/ 1000); } } // 操作记录上传 void lockRecordUploadData(List list) async { - KeyOperationRecordEntity entity = await ApiRepository.to.lockRecordUploadData( - lockId: state.keyInfos.value.lockId.toString(), - records: list); + KeyOperationRecordEntity entity = await ApiRepository.to + .lockRecordUploadData( + lockId: state.keyInfos.value.lockId.toString(), records: list); if (entity.errorCode!.codeIsSuccessful) { mockNetworkDataRequest(); } @@ -229,7 +229,7 @@ class LockOperatingRecordLogic extends BaseGetXController{ //清空操作记录 void clearOperationRecordRequest() async { KeyOperationRecordEntity entity = - await ApiRepository.to.clearOperationRecord('28'); + await ApiRepository.to.clearOperationRecord('28'); if (entity.errorCode!.codeIsSuccessful) { showToast("清除数据成功"); } @@ -242,8 +242,8 @@ class LockOperatingRecordLogic extends BaseGetXController{ print("onReady()"); // 获取是否是演示模式 演示模式不获取接口 - var isDemoMode = await Storage.getBool(ifIsDemoModeOrNot); - if(isDemoMode == false){ + var isDemoMode = await Storage.getBool(ifIsDemoModeOrNot); + if (isDemoMode == false) { _initReplySubscription(); mockNetworkDataRequest(); @@ -257,8 +257,8 @@ class LockOperatingRecordLogic extends BaseGetXController{ print("onInit()"); // 获取是否是演示模式 演示模式不获取接口 - var isDemoMode = await Storage.getBool(ifIsDemoModeOrNot); - if(isDemoMode == false){ + var isDemoMode = await Storage.getBool(ifIsDemoModeOrNot); + if (isDemoMode == false) { getLockRecordLastUploadDataTime(); // senderReferEventRecordTime(); // senderReferEventRecordNumber(); @@ -271,10 +271,9 @@ class LockOperatingRecordLogic extends BaseGetXController{ super.onClose(); // 获取是否是演示模式 演示模式不获取接口 - var isDemoMode = await Storage.getBool(ifIsDemoModeOrNot); - if(isDemoMode == false){ + var isDemoMode = await Storage.getBool(ifIsDemoModeOrNot); + if (isDemoMode == false) { _replySubscription.cancel(); } } - -} \ No newline at end of file +} diff --git a/star_lock/lib/main/lockDetail/lockSet/lockSet/lockSet_page.dart b/star_lock/lib/main/lockDetail/lockSet/lockSet/lockSet_page.dart index e5e5a368..67fa5572 100644 --- a/star_lock/lib/main/lockDetail/lockSet/lockSet/lockSet_page.dart +++ b/star_lock/lib/main/lockDetail/lockSet/lockSet/lockSet_page.dart @@ -179,19 +179,19 @@ class _LockSetPageState extends State with RouteAware { arguments: {'lockSetInfoData': state.lockSetInfoData.value}); }), SizedBox(height: 10.h), - // 门磁 - Obx(() => Visibility( - visible: state.lockFeature.value.doorStatus == 1 ? true : false, - child: CommonItem( - leftTitel: TranslationLoader.lanKeys!.doorMagnetic!.tr, - rightTitle: "", - isHaveLine: true, - isHaveDirection: true, - action: () { - Get.toNamed(Routers.doorMagneticPage); - // Toast.show(msg: "功能暂未开放"); - }))), //by DaisyWu 田总:移至锁详情配件区 + // 门磁 + // Obx(() => Visibility( + // visible: state.lockFeature.value.doorStatus == 1 ? true : false, + // child: CommonItem( + // leftTitel: TranslationLoader.lanKeys!.doorMagnetic!.tr, + // rightTitle: "", + // isHaveLine: true, + // isHaveDirection: true, + // action: () { + // Get.toNamed(Routers.doorMagneticPage); + // // Toast.show(msg: "功能暂未开放"); + // }))), // // 无线键盘 // Obx(() => Visibility( // visible: state.lockFeature.value.wirelessKeyboard == 1 ? true : false, diff --git a/star_lock/lib/network/api_repository.dart b/star_lock/lib/network/api_repository.dart index c160c5b3..eb38101f 100644 --- a/star_lock/lib/network/api_repository.dart +++ b/star_lock/lib/network/api_repository.dart @@ -1,5 +1,6 @@ import 'package:get/get.dart'; import 'package:star_lock/login/selectCountryRegion/common/countryRegionEntity.dart'; +import 'package:star_lock/main/lockDetail/doorLockLog/doorLockLog_entity.dart'; import 'package:star_lock/main/lockDetail/electronicKey/electronicKeyDetail/keyOperationRecordEntity.dart'; import 'package:star_lock/main/lockDetail/electronicKey/electronicKeyList/entity/ElectronicKeyListEntity.dart'; import 'package:star_lock/main/lockDetail/electronicKey/massSendElectronicKey/massSendLockGroupList/lockUserList/lockUserListEntity.dart'; @@ -218,7 +219,7 @@ class ApiRepository { } //门锁事件日志 - Future lockEventList({ + Future lockEventList({ required int lockId, required int lockEventType, required int pageNo, @@ -234,7 +235,7 @@ class ApiRepository { startDate, endDate, ); - return KeyOperationRecordEntity.fromJson(res.body); + return DoorLockLogEntity.fromJson(res.body); } //操作记录上传 From b68b9dc7dad202e1c01e24a7fb0972873c55dcfc Mon Sep 17 00:00:00 2001 From: Daisy <> Date: Tue, 27 Feb 2024 09:25:33 +0800 Subject: [PATCH 2/4] =?UTF-8?q?=E9=97=A8=E9=94=81=E6=97=A5=E5=BF=97?= =?UTF-8?q?=E9=A1=B5=E6=8F=90=E4=BA=A4=E8=A1=A5=E5=85=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../lib/main/lockDetail/doorLockLog/doorLockLog_logic.dart | 1 + star_lock/lib/main/lockDetail/doorLockLog/doorLockLog_page.dart | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/star_lock/lib/main/lockDetail/doorLockLog/doorLockLog_logic.dart b/star_lock/lib/main/lockDetail/doorLockLog/doorLockLog_logic.dart index 21e4ff9e..9d309a67 100644 --- a/star_lock/lib/main/lockDetail/doorLockLog/doorLockLog_logic.dart +++ b/star_lock/lib/main/lockDetail/doorLockLog/doorLockLog_logic.dart @@ -281,6 +281,7 @@ class DoorLockLogLogic extends BaseGetXController { // senderReferEventRecordTime(); // senderReferEventRecordNumber(); + testReadJsonData(); mockNetworkDataRequest(); } } diff --git a/star_lock/lib/main/lockDetail/doorLockLog/doorLockLog_page.dart b/star_lock/lib/main/lockDetail/doorLockLog/doorLockLog_page.dart index e5ace84c..b078aa4b 100644 --- a/star_lock/lib/main/lockDetail/doorLockLog/doorLockLog_page.dart +++ b/star_lock/lib/main/lockDetail/doorLockLog/doorLockLog_page.dart @@ -116,7 +116,7 @@ class _DoorLockLogPageState extends State { //事件下拉框组件 Widget eventDropDownWidget() { return Container( - margin: EdgeInsets.only(top: 20.h, left: 30.w, bottom: 20.h), + margin: EdgeInsets.only(top: 20.h, left: 30.w, bottom: 10.h), child: Row( mainAxisAlignment: MainAxisAlignment.start, children: [ From c9ca7228f63e73c590ff7020555a9b94e7bc3d0c Mon Sep 17 00:00:00 2001 From: Daisy <> Date: Tue, 27 Feb 2024 11:50:53 +0800 Subject: [PATCH 3/4] =?UTF-8?q?=E9=85=8D=E4=BB=B6=E5=95=86=E5=9F=8E?= =?UTF-8?q?=E9=A1=B5=E9=9D=A2=E6=96=B0=E5=A2=9E=E9=A1=B6=E9=83=A8=E8=BF=9B?= =?UTF-8?q?=E5=BA=A6=E6=9D=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- star_lock/lib/mine/mall/lockMall_logic.dart | 22 +++++++++++++++++++++ star_lock/lib/mine/mall/lockMall_page.dart | 18 ++++++++++++++++- star_lock/lib/mine/mall/lockMall_state.dart | 5 ++++- 3 files changed, 43 insertions(+), 2 deletions(-) diff --git a/star_lock/lib/mine/mall/lockMall_logic.dart b/star_lock/lib/mine/mall/lockMall_logic.dart index 6cb9aef5..360678fb 100644 --- a/star_lock/lib/mine/mall/lockMall_logic.dart +++ b/star_lock/lib/mine/mall/lockMall_logic.dart @@ -1,6 +1,7 @@ import 'package:star_lock/mine/mall/lockMall_entity.dart'; import 'package:star_lock/mine/mall/lockMall_state.dart'; import 'package:star_lock/network/api_repository.dart'; +import 'package:webview_flutter/webview_flutter.dart'; import '../../tools/baseGetXController.dart'; @@ -12,6 +13,27 @@ class LockMallLogic extends BaseGetXController { LockMallDataEntity entity = await ApiRepository.to.getMallURLData(); if (entity.errorCode!.codeIsSuccessful) { state.lockMallUrl.value = entity.data!.url!; + state.mallWebView.setNavigationDelegate( + NavigationDelegate( + onProgress: (int progress) { + // Update loading bar. + state.webProgress.value = progress / 100; + }, + onPageStarted: (String url) { + state.webProgress.value = 0.0; + }, + onPageFinished: (String url) { + state.webProgress.value = 1.0; + }, + onWebResourceError: (WebResourceError error) {}, + onNavigationRequest: (NavigationRequest request) { + // if (request.url.startsWith('https://www.youtube.com/')) { + // return NavigationDecision.prevent; + // } + return NavigationDecision.navigate; + }, + ), + ); state.mallWebView.loadRequest(Uri.parse(state.lockMallUrl.value)); } } diff --git a/star_lock/lib/mine/mall/lockMall_page.dart b/star_lock/lib/mine/mall/lockMall_page.dart index 37cc9364..8270ac89 100644 --- a/star_lock/lib/mine/mall/lockMall_page.dart +++ b/star_lock/lib/mine/mall/lockMall_page.dart @@ -1,4 +1,5 @@ import 'package:flutter/material.dart'; +import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:get/get.dart'; import 'package:star_lock/app_settings/app_colors.dart'; import 'package:star_lock/mine/mall/lockMall_logic.dart'; @@ -36,7 +37,22 @@ class _LockMallPageState extends State { haveBack: true, backgroundColor: AppColors.mainColor, ), - body: WebViewWidget(controller: state.mallWebView)); + body: Obx(() => Column( + children: [ + Container( + padding: EdgeInsets.only(bottom: 10.w), + child: LinearProgressIndicator( + value: state.webProgress.value, + backgroundColor: Colors.grey, + valueColor: + AlwaysStoppedAnimation(AppColors.mainColor), + ), + ), + Expanded( + child: WebViewWidget(controller: state.mallWebView), + ), + ], + ))); } String getWebTitle() { diff --git a/star_lock/lib/mine/mall/lockMall_state.dart b/star_lock/lib/mine/mall/lockMall_state.dart index 2ad6312d..20ddb81b 100644 --- a/star_lock/lib/mine/mall/lockMall_state.dart +++ b/star_lock/lib/mine/mall/lockMall_state.dart @@ -1,8 +1,11 @@ +import 'package:flutter/material.dart'; import 'package:get/get.dart'; import 'package:webview_flutter/webview_flutter.dart'; class LockMallState { var lockMallUrl = "".obs; + var webProgress = 0.0.obs; late WebViewController mallWebView = WebViewController() - ..setJavaScriptMode(JavaScriptMode.unrestricted); + ..setJavaScriptMode(JavaScriptMode.unrestricted) + ..setBackgroundColor(Colors.white); } From 027f81fb61597d3b018a276be334cd61146545a3 Mon Sep 17 00:00:00 2001 From: Daisy <> Date: Tue, 27 Feb 2024 13:52:49 +0800 Subject: [PATCH 4/4] =?UTF-8?q?=E4=BC=98=E5=8C=96=E5=AE=8C=E5=96=84?= =?UTF-8?q?=E9=97=A8=E9=94=81=E6=97=A5=E5=BF=97=E9=A1=B5=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../doorLockLog/doorLockLog_page.dart | 41 +++++++++++-------- 1 file changed, 24 insertions(+), 17 deletions(-) diff --git a/star_lock/lib/main/lockDetail/doorLockLog/doorLockLog_page.dart b/star_lock/lib/main/lockDetail/doorLockLog/doorLockLog_page.dart index b078aa4b..f0601186 100644 --- a/star_lock/lib/main/lockDetail/doorLockLog/doorLockLog_page.dart +++ b/star_lock/lib/main/lockDetail/doorLockLog/doorLockLog_page.dart @@ -116,7 +116,7 @@ class _DoorLockLogPageState extends State { //事件下拉框组件 Widget eventDropDownWidget() { return Container( - margin: EdgeInsets.only(top: 20.h, left: 30.w, bottom: 10.h), + margin: EdgeInsets.only(top: 20.h, left: 30.w, bottom: 10.h, right: 20.w), child: Row( mainAxisAlignment: MainAxisAlignment.start, children: [ @@ -166,28 +166,32 @@ class _DoorLockLogPageState extends State { fontWeight: FontWeight.w600, ), ), + SizedBox( + height: 10.h, + ), GestureDetector( onTap: () { Get.toNamed(Routers.videoLogDetailPage); }, child: Stack( children: [ - if (timelineData.imagesUrl != null) - // Image.network( - // timelineData.imagesUrl!, - // width: 260.w, - // height: 260.h, - // ) - Image( - image: const AssetImage( - 'images/main/icon_lockDetail_monitoringvoiceFrist.png'), - width: 260.w, - height: 260.h, - ) - else - Container(), + timelineData.imagesUrl != null + ? + // Image.network( + // timelineData.imagesUrl!, + // width: 260.w, + // height: 260.h, + // ) + Image( + image: const AssetImage( + 'images/main/icon_lockDetail_monitoringvoiceFrist.png'), + width: 240.w, + height: 180.h, + fit: BoxFit.contain, + ) + : Container(), Positioned( - top: 200.h, + top: 150.h, left: 10.w, child: Image( image: const AssetImage( @@ -199,6 +203,9 @@ class _DoorLockLogPageState extends State { ], ), ), + SizedBox( + height: 20.h, + ), ], ), ); @@ -214,7 +221,7 @@ class _DoorLockLogPageState extends State { indicatorTheme: const IndicatorThemeData( size: 8.0, color: AppColors.greyLineColor, - position: 0.7, + position: 0.4, ), ), ),