diff --git a/star_lock/README.md b/star_lock/README.md index 3a80949a..371461b5 100644 --- a/star_lock/README.md +++ b/star_lock/README.md @@ -70,3 +70,21 @@ flutter build apk --split-per-abi --release --flavor sky -t lib/main_sky.dart ```bash apksigner verify --print-certs -v build/app/outputs/flutter-apk/app-sky-release.apk ``` + + +## 用于Google Play发布的指南 +https://www.gstatic.com/play-apps-publisher-rapid/signing-tool/prod/pepk-src.jar +1. 下载 Play Encrypt Private Key (PEPK) 工具,请注意 [pepk-src.jar中没有主清单属性](https://stackoverflow.com/questions/44719351/googles-pepk-src-not-working) +2. 生成密钥 +```bash +java -jar android/google/pepk.jar --keystore=android/app/sky.jks --alias=upload --output=android/google/google_pek.zip --include-cert --rsa-aes-encryption --encryption-key-path=android/google/encryption_public_key.pem +``` +3. 上传密钥 +上传android/google/google_pek.zip文件到谷歌Play管理中心 +4. 编译和上传 app bundle +```bash +flutter build appbundle --release --flavor sky -t lib/main_sky.dart +``` +然后文件在:`build/app/outputs/bundle/skyRelease/app-sky-release.aab` + +- 注意,这里的sky.jks和google_pek.zip和encryption_public_key.pem都是sky渠道的,和谷歌账号对应。如果需要使用其他谷歌账号,需要更换这两个文件。 diff --git a/star_lock/android/google/encryption_public_key.pem b/star_lock/android/google/encryption_public_key.pem new file mode 100644 index 00000000..d3dc2a67 --- /dev/null +++ b/star_lock/android/google/encryption_public_key.pem @@ -0,0 +1,11 @@ +-----BEGIN PUBLIC KEY----- +MIIBojANBgkqhkiG9w0BAQEFAAOCAY8AMIIBigKCAYEAk4KvDplvoZN04n0son5V +wrG4vN92MkPuXLWCpU97OaUJUKtlROZkhwrMMeFlLLYBJOsymN3J4qISDVQJRxpl +D7vNZfb0NE8WleTRdhOjkWGvtODczOK+ZmYy3xCSnsAAH4+GYdAH+35rVshJ4EcC +6ibeuPTOuboqtS6jXN7Zh+FH/LZ0rMUgSQ7+W6ydlo/05d2j+dAaEEc3YSo63/0W +waBAV35IXWhgxqllgVw3ZEW3wdBGtbF7Xp3NkS0NrJIFNdE6oyBe8Vdtc17+M2mA +bEuWHAbe0bj5kOG+XQYbZXy9TuK+/vS2KKsIEWDx1OewgcHZFP9qXkTfWGV2am8k +MKdT8XunatKIrUabroxjQMk/70F4uQ9/xKxk7vN+ouiJUYUlBw59THCkgi/Iyfdu +Df6+OFJCuuTU4KlhnH3LqT4WF7wDxuP5tryzG1qHYDtBAwrD3P7R3zkhkl4RtqWC +/J5L88XY/XjdN7OdPdMzmMsgDGQQw6dIRQSAEQhUEu2HAgMBAAE= +-----END PUBLIC KEY----- diff --git a/star_lock/android/google/google_pek.zip b/star_lock/android/google/google_pek.zip new file mode 100644 index 00000000..97cded41 Binary files /dev/null and b/star_lock/android/google/google_pek.zip differ diff --git a/star_lock/android/google/pepk.jar b/star_lock/android/google/pepk.jar new file mode 100644 index 00000000..5ffdd4c8 Binary files /dev/null and b/star_lock/android/google/pepk.jar differ 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/ios/Runner/AppDelegate.m b/star_lock/ios/Runner/AppDelegate.m index 6de73520..56817721 100644 --- a/star_lock/ios/Runner/AppDelegate.m +++ b/star_lock/ios/Runner/AppDelegate.m @@ -18,8 +18,8 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { - [self initCloudPush]; - [CloudPushSDK sendNotificationAck:launchOptions]; +// [self initCloudPush]; +// [CloudPushSDK sendNotificationAck:launchOptions]; XSFlutterManager *VC = [[XSFlutterManager alloc] init]; self.window.rootViewController = VC; [self.window makeKeyAndVisible]; diff --git a/star_lock/lib/app.dart b/star_lock/lib/app.dart index ec474a95..203c7924 100644 --- a/star_lock/lib/app.dart +++ b/star_lock/lib/app.dart @@ -1,4 +1,3 @@ -import 'package:aliyun_push/aliyun_push.dart'; import 'package:flutter/material.dart'; import 'package:flutter_easyloading/flutter_easyloading.dart'; import 'package:flutter_localizations/flutter_localizations.dart'; @@ -8,8 +7,6 @@ import 'package:permission_handler/permission_handler.dart'; import 'package:star_lock/tools/app_manager.dart'; import 'package:star_lock/tools/bindings/app_binding.dart'; -import 'package:star_lock/tools/storage.dart'; -import 'package:star_lock/tools/xs_aliyunPush.dart'; import 'package:star_lock/translations/app_dept.dart'; import 'package:star_lock/translations/trans_lib.dart'; @@ -17,7 +14,6 @@ import 'appRouters.dart'; import 'baseWidget.dart'; import 'tools/appRouteObserver.dart'; import 'dart:io'; -import 'package:flutter/services.dart'; class MyApp extends StatefulWidget { const MyApp({GlobalKey? key}) : super(key: key); @@ -50,7 +46,7 @@ class _MyAppState extends State with WidgetsBindingObserver, BaseWidget { localeResolutionCallback: (locale, supportedLocales) { if (!supportedLocales.contains(locale)) { int idx = appSupportedLocales.indexWhere( - (element) => element.languageCode == locale!.languageCode); + (element) => element.languageCode == locale!.languageCode); if (idx != -1) { locale = appSupportedLocales[idx]; } else { @@ -70,12 +66,12 @@ class _MyAppState extends State with WidgetsBindingObserver, BaseWidget { backgroundColor: const Color(0xFFF6F6F6), primaryColor: const Color(0xFFFFFFFF), textTheme: TextTheme( - //用在非Material组件上的文字显示, + //用在非Material组件上的文字显示, bodyText1: - TextStyle(fontSize: 28.sp, color: const Color(0xff2E2B2B)), + TextStyle(fontSize: 28.sp, color: const Color(0xff2E2B2B)), //Material组件上的文字显示 bodyText2: - TextStyle(fontSize: 28.sp, color: const Color(0xff2E2B2B)), + TextStyle(fontSize: 28.sp, color: const Color(0xff2E2B2B)), button: TextStyle(fontSize: 28.sp)), iconTheme: IconThemeData(size: 28.sp, color: const Color(0xff2E2B2B)), appBarTheme: AppBarTheme( @@ -103,29 +99,6 @@ class _MyAppState extends State with WidgetsBindingObserver, BaseWidget { WidgetsBinding.instance.addObserver(this); // openBlueScan(); - - initAliyunPush(); - } - - //初始化阿里云推送 - void initAliyunPush() { - final aliyunPush = AliyunPush(); - XSAliyunPushProvider().init(aliyunPush); - XSAliyunPushProvider().initAliyunPush(); - - if (Platform.isAndroid) { - XSAliyunPushProvider().initAliyunThirdPush(); - } - - //暂使用DeviceID推送 - aliyunPush.getDeviceId().then((deviceId) async { - // print('得到的DeviceId$deviceId'); - final data = await Storage.getString(saveUserLoginData); - if (data!.isNotEmpty && deviceId.isNotEmpty) { - XSAliyunPushProvider() - .pushBindDeviceID(deviceId, Platform.isAndroid ? 10 : 20); - } - }); } @override @@ -135,7 +108,6 @@ class _MyAppState extends State with WidgetsBindingObserver, BaseWidget { } } - void openBlueScan() { if (Platform.isIOS) { print("有蓝牙权限开始扫描"); diff --git a/star_lock/lib/appRouters.dart b/star_lock/lib/appRouters.dart index a91cb89f..c82faf0e 100644 --- a/star_lock/lib/appRouters.dart +++ b/star_lock/lib/appRouters.dart @@ -2,6 +2,7 @@ import 'package:get/get.dart'; import 'package:star_lock/common/safetyVerification/safetyVerification_binding.dart'; import 'package:star_lock/login/register/starLock_register_binding.dart'; import 'package:star_lock/main/lockDetail/doorLockLog/doorLockLog_page.dart'; +import 'package:star_lock/main/lockDetail/electronicKey/electronicKeyDetail/keyOperationRecord/keyOperationRecord_page.dart'; import 'package:star_lock/main/lockDetail/electronicKey/massSendElectronicKey/massSendLockGroupList/lockUserList/lockUserList_page.dart'; import 'package:star_lock/main/lockDetail/electronicKey/massSendElectronicKey/massSendLockGroupList/massSendLockGroupList_page.dart'; @@ -59,7 +60,6 @@ import 'main/lockDetail/checkingIn/checkingInSetWorkdaySet/checkingInSetWorkdayS import 'main/lockDetail/checkingIn/checkingInStaff/checkingInSetAddStaff/checkingInAddStaff_page.dart'; import 'main/lockDetail/checkingIn/checkingInStaff/checkingInSetStaffList/checkingInStaffList_page.dart'; import 'main/lockDetail/checkingIn/checkingInStaff/checkingInStaffDetail/checkingInStaffDetail_page.dart'; -import 'main/lockDetail/electronicKey/electronicKeyDetail/keyOperationRecord_page.dart'; import 'main/lockDetail/face/addFace/addFace_page.dart'; import 'main/lockDetail/face/addFaceType/addFaceTypeManage/addFaceTypeManage_page.dart'; import 'main/lockDetail/face/faceList/faceList_page.dart'; diff --git a/star_lock/lib/main/lockDetail/authorizedAdmin/authorizedAdmin/authorizedAdmin_logic.dart b/star_lock/lib/main/lockDetail/authorizedAdmin/authorizedAdmin/authorizedAdmin_logic.dart index fb14201a..0bc4a172 100644 --- a/star_lock/lib/main/lockDetail/authorizedAdmin/authorizedAdmin/authorizedAdmin_logic.dart +++ b/star_lock/lib/main/lockDetail/authorizedAdmin/authorizedAdmin/authorizedAdmin_logic.dart @@ -8,10 +8,8 @@ import 'package:star_lock/blue/io_type.dart'; import 'package:star_lock/translations/trans_lib.dart'; import '../../../../blue/blue_manage.dart'; -import '../../../../blue/io_protocol/io_addUser.dart'; import '../../../../blue/io_reply.dart'; import '../../../../blue/io_protocol/io_transferPermissions.dart'; -import '../../../../blue/io_tool/io_manager.dart'; import '../../../../blue/io_tool/io_tool.dart'; import '../../../../blue/io_tool/manager_event_bus.dart'; import '../../../../blue/sender_manage.dart'; @@ -163,7 +161,8 @@ class AuthorizedAdminLogic extends BaseGetXController { // 转移权限 Future transferPermissionsAction() 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!); @@ -228,33 +227,47 @@ class AuthorizedAdminLogic extends BaseGetXController { //发送授权管理员列表请求 Future sendElectronicKeyRequest() async { - if(state.emailOrPhoneController.text.isEmpty){ + if (state.emailOrPhoneController.text.isEmpty) { showToast("请输入接收者账号"); return; } - if(state.keyNameController.text.isEmpty){ + if (state.keyNameController.text.isEmpty) { showToast("请输入接收者姓名"); return; } - String getFailureDateTime = '0'; - String getEffectiveDateTime = '0'; + // String getFailureDateTime = '0'; + // String getEffectiveDateTime = '0'; String lockID = state.keyInfo.value.lockId.toString(); Get.log("state.type.value:${state.type.value}"); String getKeyType = "1"; if (state.type.value == '0') { getKeyType = "2"; - getFailureDateTime = state.failureDateTime.value.millisecondsSinceEpoch.toString(); - getEffectiveDateTime = state.effectiveDateTime.value.millisecondsSinceEpoch.toString(); + // getFailureDateTime = + // state.failureDateTime.value.millisecondsSinceEpoch.toString(); + // getEffectiveDateTime = + // state.effectiveDateTime.value.millisecondsSinceEpoch.toString(); - DateTime startDateTime = DateTime(state.effectiveDateTime.value.year, state.effectiveDateTime.value.month, state.effectiveDateTime.value.day, state.effectiveDateTime.value.hour, state.effectiveDateTime.value.minute); - DateTime endDateTime = DateTime(state.failureDateTime.value.year, state.failureDateTime.value.month, state.failureDateTime.value.day, state.failureDateTime.value.hour, state.failureDateTime.value.minute); - if (!startDateTime.isBefore(endDateTime) || startDateTime.isAtSameMomentAs(endDateTime)) { + DateTime startDateTime = DateTime( + state.effectiveDateTime.value.year, + state.effectiveDateTime.value.month, + state.effectiveDateTime.value.day, + state.effectiveDateTime.value.hour, + state.effectiveDateTime.value.minute); + DateTime endDateTime = DateTime( + state.failureDateTime.value.year, + state.failureDateTime.value.month, + state.failureDateTime.value.day, + state.failureDateTime.value.hour, + state.failureDateTime.value.minute); + if (!startDateTime.isBefore(endDateTime) || + startDateTime.isAtSameMomentAs(endDateTime)) { showToast("失效时间需大于生效时间"); return; } - if (!startDateTime.isBefore(DateTime.now()) || startDateTime.isAtSameMomentAs(DateTime.now())) { + if (!startDateTime.isBefore(DateTime.now()) || + startDateTime.isAtSameMomentAs(DateTime.now())) { showToast("生效时间需大于当前时间"); return; } @@ -264,7 +277,7 @@ class AuthorizedAdminLogic extends BaseGetXController { createUser: state.isCreateUser.value ? "1" : "0", countryCode: state.countryCode.value, usernameType: '1', - endDate: getFailureDateTime, + endDate: state.failureDateTime.value.millisecondsSinceEpoch, faceAuthentication: state.isAuthentication.value == true ? '1' : '2', isCameraEnable: '2', isRemoteUnlock: '2', @@ -275,8 +288,10 @@ class AuthorizedAdminLogic extends BaseGetXController { operatorUid: '', receiverUsername: state.emailOrPhoneController.text, remarks: '', - startDate: getEffectiveDateTime, - weekDays: state.weekdaysList); + startDate: state.effectiveDateTime.value.millisecondsSinceEpoch, + weekDays: state.weekdaysList, + startTime: state.startTime.value, + endTime: state.endTime.value); if (entity.errorCode!.codeIsSuccessful) { print('发送电子钥匙成功'); state.isSendSuccess.value = true; diff --git a/star_lock/lib/main/lockDetail/authorizedAdmin/authorizedAdmin/authorizedAdmin_page.dart b/star_lock/lib/main/lockDetail/authorizedAdmin/authorizedAdmin/authorizedAdmin_page.dart index 1cb64622..a14aa653 100644 --- a/star_lock/lib/main/lockDetail/authorizedAdmin/authorizedAdmin/authorizedAdmin_page.dart +++ b/star_lock/lib/main/lockDetail/authorizedAdmin/authorizedAdmin/authorizedAdmin_page.dart @@ -6,6 +6,7 @@ import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:get/get.dart'; import 'package:star_lock/network/api_repository.dart'; import 'package:star_lock/tools/baseGetXController.dart'; +import 'package:star_lock/tools/dateUtils.dart'; import 'package:star_lock/tools/pickers/pickers.dart'; import 'package:star_lock/tools/pickers/time_picker/model/date_mode.dart'; import 'package:star_lock/tools/storage.dart'; @@ -135,10 +136,11 @@ class _AuthorizedAdminPageState extends State { Pickers.showDatePicker(context, mode: DateMode.YMDHM, onConfirm: (p) { setState(() { - state.selectEffectiveDate.value = - '${p.year}-${intToStr(p.month!)}-${intToStr(p.day!)} ${intToStr(p.hour!)}:${intToStr(p.minute!)}'; - state.effectiveDateTime.value = - DateTime.parse(state.selectEffectiveDate.value); + state.effectiveDateTime.value = XSDateUtils.parseDateTime( + '${p.year}-${p.month!}-${p.day} ${p.hour!}:${p.minute!}', + 'yyyy-mm-dd HH:mm'); + state.selectEffectiveDate.value = XSDateUtils.formatDateTime( + state.effectiveDateTime.value, 'yyyy-mm-dd HH:mm'); }); }); }), @@ -150,10 +152,11 @@ class _AuthorizedAdminPageState extends State { Pickers.showDatePicker(context, mode: DateMode.YMDHM, onConfirm: (p) { setState(() { - state.selectFailureDate.value = - '${p.year}-${intToStr(p.month!)}-${intToStr(p.day!)} ${intToStr(p.hour!)}:${intToStr(p.minute!)}'; - state.failureDateTime.value = - DateTime.parse(state.selectFailureDate.value); + state.failureDateTime.value = XSDateUtils.parseDateTime( + '${p.year}-${p.month!}-${p.day} ${p.hour!}:${p.minute!}', + 'yyyy-mm-dd HH:mm'); + state.selectFailureDate.value = XSDateUtils.formatDateTime( + state.failureDateTime.value, 'yyyy-mm-dd HH:mm'); }); }); }), @@ -286,13 +289,15 @@ class _AuthorizedAdminPageState extends State { height: 10.h, ), OutLineBtn( - btnName: state.emailOrPhoneController.text.contains("@")?'邮件通知':"短信通知", + btnName: + state.emailOrPhoneController.text.contains("@") ? '邮件通知' : "短信通知", onClick: () { - if(state.emailOrPhoneController.text.contains("@")){ + if (state.emailOrPhoneController.text.contains("@")) { Get.toNamed(Routers.sendEmailNotificationPage); - }else{ + } else { // _openModalBottomSheet(); - NativeInteractionTool.loadNativeShare(shareText:state.pwdShareStr); + NativeInteractionTool.loadNativeShare( + shareText: state.pwdShareStr); } // Get.toNamed(state.emailOrPhoneController.text.contains("@")? Routers.sendEmailNotificationPage:Routers.sendEmailNotificationPage); }, @@ -304,7 +309,7 @@ class _AuthorizedAdminPageState extends State { btnName: '微信通知', onClick: () { // _openModalBottomSheet(); - NativeInteractionTool.loadNativeShare(shareText:state.pwdShareStr); + NativeInteractionTool.loadNativeShare(shareText: state.pwdShareStr); }, ), SizedBox( @@ -345,10 +350,18 @@ class _AuthorizedAdminPageState extends State { // contentPadding: const EdgeInsets.only(top: 12.0, bottom: 8.0), hintText: tfStr, hintStyle: TextStyle(fontSize: 22.sp), - focusedBorder: const OutlineInputBorder(borderSide: BorderSide(width: 0, color: Colors.transparent)), - disabledBorder: const OutlineInputBorder(borderSide: BorderSide(width: 0, color: Colors.transparent)), - enabledBorder: const OutlineInputBorder(borderSide: BorderSide(width: 0, color: Colors.transparent)), - border: const OutlineInputBorder(borderSide: BorderSide(width: 0, color: Colors.transparent)), + focusedBorder: const OutlineInputBorder( + borderSide: + BorderSide(width: 0, color: Colors.transparent)), + disabledBorder: const OutlineInputBorder( + borderSide: + BorderSide(width: 0, color: Colors.transparent)), + enabledBorder: const OutlineInputBorder( + borderSide: + BorderSide(width: 0, color: Colors.transparent)), + border: const OutlineInputBorder( + borderSide: + BorderSide(width: 0, color: Colors.transparent)), contentPadding: const EdgeInsets.symmetric(vertical: 0), ), // decoration: InputDecoration( @@ -389,7 +402,8 @@ class _AuthorizedAdminPageState extends State { } if (currentContact.fullName!.isNotEmpty) { - state.keyNameController.text = currentContact.fullName!; + state.keyNameController.text = + currentContact.fullName!; } }); }, @@ -416,10 +430,6 @@ class _AuthorizedAdminPageState extends State { ); } - String intToStr(int v) { - return (v < 10) ? "0$v" : "$v"; - } - Future _openModalBottomSheet() async { showModalBottomSheet( context: context, @@ -443,7 +453,7 @@ class _AuthorizedAdminPageState extends State { TextButton( style: ButtonStyle( overlayColor: - MaterialStateProperty.all(Colors.white)), + MaterialStateProperty.all(Colors.white)), child: Text( '取消', style: TextStyle( @@ -469,13 +479,14 @@ class _AuthorizedAdminPageState extends State { return widgetList; } - GestureDetector buildCenter3(String imageName, String titleStr, int itemIndex) { + GestureDetector buildCenter3( + String imageName, String titleStr, int itemIndex) { return GestureDetector( child: Container( width: 120.w, // height: 64.h, margin: - EdgeInsets.only(top: 20.w, bottom: 20.w, left: 10.w, right: 10.w), + EdgeInsets.only(top: 20.w, bottom: 20.w, left: 10.w, right: 10.w), child: Column( mainAxisAlignment: MainAxisAlignment.center, children: [ @@ -504,31 +515,30 @@ class _AuthorizedAdminPageState extends State { Get.back(); switch (itemIndex) { case 0: - //微信好友 + //微信好友 { - NativeInteractionTool.loadNativeShare(shareText:state.pwdShareStr); + NativeInteractionTool.loadNativeShare(shareText: state.pwdShareStr); } break; case 1: - //短信 + //短信 { - NativeInteractionTool.loadNativeShare(shareText:state.pwdShareStr); + NativeInteractionTool.loadNativeShare(shareText: state.pwdShareStr); } break; case 2: - //邮件 + //邮件 { Navigator.pushNamed(context, Routers.sendEmailNotificationPage); } break; case 3: - //更多 + //更多 { - NativeInteractionTool.loadNativeShare(shareText:state.pwdShareStr); + NativeInteractionTool.loadNativeShare(shareText: state.pwdShareStr); } break; default: } } - } diff --git a/star_lock/lib/main/lockDetail/authorizedAdmin/authorizedAdmin/authorizedAdmin_state.dart b/star_lock/lib/main/lockDetail/authorizedAdmin/authorizedAdmin/authorizedAdmin_state.dart index c599d4ac..42747954 100644 --- a/star_lock/lib/main/lockDetail/authorizedAdmin/authorizedAdmin/authorizedAdmin_state.dart +++ b/star_lock/lib/main/lockDetail/authorizedAdmin/authorizedAdmin/authorizedAdmin_state.dart @@ -1,4 +1,3 @@ - import 'package:flutter/material.dart'; import 'package:flutter_native_contact_picker/flutter_native_contact_picker.dart'; import 'package:get/get.dart'; @@ -6,8 +5,10 @@ import 'package:get/get.dart'; import '../../../lockMian/entity/lockListInfo_entity.dart'; class AuthorizedAdminState { - final TextEditingController emailOrPhoneController = TextEditingController(); //邮箱/手机号输入框 - final TextEditingController keyNameController = TextEditingController(); //钥匙名输入框 + final TextEditingController emailOrPhoneController = + TextEditingController(); //邮箱/手机号输入框 + final TextEditingController keyNameController = + TextEditingController(); //钥匙名输入框 final FlutterContactPicker contactPicker = FlutterContactPicker(); late Contact contact; @@ -20,8 +21,15 @@ class AuthorizedAdminState { final effectiveDateTime = DateTime.now().obs; final failureDateTime = DateTime.now().obs; - var selectEffectiveDate = '${DateTime.now().year}-${DateTime.now().month}-${DateTime.now().day} ${DateTime.now().hour}:${DateTime.now().minute}'.obs; //默认为当前时间 - var selectFailureDate = '${DateTime.now().year}-${DateTime.now().month}-${DateTime.now().day} ${DateTime.now().hour}:${DateTime.now().minute}'.obs; //默认为当前时间 + var selectEffectiveDate = + '${DateTime.now().year}-${DateTime.now().month}-${DateTime.now().day} ${DateTime.now().hour}:${DateTime.now().minute}' + .obs; //默认为当前时间 + var selectFailureDate = + '${DateTime.now().year}-${DateTime.now().month}-${DateTime.now().day} ${DateTime.now().hour}:${DateTime.now().minute}' + .obs; //默认为当前时间 + + var startTime = 0.obs; + var endTime = 0.obs; var isSendSuccess = false.obs; var countryName = '中国'.obs; @@ -38,4 +46,4 @@ class AuthorizedAdminState { // lockMainEntity.value = map["lockMainEntity"]; keyInfo.value = map["keyInfo"]; } -} \ 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..6230e790 100644 --- a/star_lock/lib/main/lockDetail/doorLockLog/doorLockLog_logic.dart +++ b/star_lock/lib/main/lockDetail/doorLockLog/doorLockLog_logic.dart @@ -1,8 +1,12 @@ 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/electronicKey/electronicKeyDetail/keyOperationRecord/keyOperationRecord_entity.dart'; import 'package:star_lock/main/lockDetail/lockOperatingRecord/lockOperatingRecordGetLastRecordTime_entity.dart'; import 'package:star_lock/tools/eventBusEventManage.dart'; @@ -15,7 +19,6 @@ import '../../../blue/sender_manage.dart'; import '../../../network/api_repository.dart'; import '../../../tools/baseGetXController.dart'; import '../../../tools/storage.dart'; -import '../electronicKey/electronicKeyDetail/keyOperationRecordEntity.dart'; class DoorLockLogLogic extends BaseGetXController { DoorLockLogState state = DoorLockLogState(); @@ -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,27 @@ 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; + testReadJsonData(); + mockNetworkDataRequest(); + } } @override @@ -302,4 +298,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..f0601186 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))) ], ), ); @@ -123,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, right: 20.w), child: Row( mainAxisAlignment: MainAxisAlignment.start, children: [ @@ -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,96 @@ 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, + SizedBox( + height: 10.h, + ), + GestureDetector( + onTap: () { + Get.toNamed(Routers.videoLogDetailPage); + }, + child: Stack( + children: [ + 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: 150.h, + left: 10.w, + child: Image( + image: const AssetImage( + 'images/main/icon_lockLog_play.png'), + width: 24.w, + height: 20.w, + ), + ), + ], + ), + ), + SizedBox( + height: 20.h, + ), + ], + ), + ); + }, ), 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.4, + ), ), ), ); 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/electronicKey/electronicKeyDetail/electronicKeyDetail/electronicKeyDetail_logic.dart b/star_lock/lib/main/lockDetail/electronicKey/electronicKeyDetail/electronicKeyDetail/electronicKeyDetail_logic.dart index 11348c9f..efa66fe7 100644 --- a/star_lock/lib/main/lockDetail/electronicKey/electronicKeyDetail/electronicKeyDetail/electronicKeyDetail_logic.dart +++ b/star_lock/lib/main/lockDetail/electronicKey/electronicKeyDetail/electronicKeyDetail/electronicKeyDetail_logic.dart @@ -1,6 +1,6 @@ import 'package:get/get.dart'; import 'package:star_lock/main/lockDetail/electronicKey/electronicKeyDetail/electronicKeyDetail/electronicKeyDetail_state.dart'; -import 'package:star_lock/main/lockDetail/electronicKey/electronicKeyDetail/keyOperationRecordEntity.dart'; +import 'package:star_lock/main/lockDetail/electronicKey/electronicKeyDetail/keyOperationRecord/keyOperationRecord_entity.dart'; import 'package:star_lock/main/lockDetail/electronicKey/electronicKeyList/entity/ElectronicKeyListEntity.dart'; import 'package:star_lock/network/api_repository.dart'; import 'package:star_lock/tools/baseGetXController.dart'; @@ -23,7 +23,7 @@ class ElectronicKeyDetailLogic extends BaseGetXController { state.itemData.value.keyName = state.changeNameController.text; state.keyName.value = state.itemData.value.keyName!; Get.back(); - showToast("修改成功", something: (){ + showToast("修改成功", something: () { eventBus.fire(ElectronicKeyListRefreshUI()); eventBus.fire(AuthorizedAdminPageRefreshUI()); }); @@ -36,7 +36,7 @@ class ElectronicKeyDetailLogic extends BaseGetXController { .deleteElectronicKey(state.itemData.value.keyId.toString()); if (entity.errorCode!.codeIsSuccessful) { print("删除电子钥匙成功"); - showToast("删除成功", something: (){ + showToast("删除成功", something: () { eventBus.fire(ElectronicKeyListRefreshUI()); eventBus.fire(AuthorizedAdminPageRefreshUI()); Get.back(); diff --git a/star_lock/lib/main/lockDetail/electronicKey/electronicKeyDetail/electronicKeyDetailChangeDate/electronicKeyDetailChangeDate_logic.dart b/star_lock/lib/main/lockDetail/electronicKey/electronicKeyDetail/electronicKeyDetailChangeDate/electronicKeyDetailChangeDate_logic.dart index 602cd14f..360d7244 100644 --- a/star_lock/lib/main/lockDetail/electronicKey/electronicKeyDetail/electronicKeyDetailChangeDate/electronicKeyDetailChangeDate_logic.dart +++ b/star_lock/lib/main/lockDetail/electronicKey/electronicKeyDetail/electronicKeyDetailChangeDate/electronicKeyDetailChangeDate_logic.dart @@ -1,6 +1,6 @@ import 'package:get/get.dart'; import 'package:star_lock/main/lockDetail/electronicKey/electronicKeyDetail/electronicKeyDetailChangeDate/electronicKeyDetailChangeDate_state.dart'; -import 'package:star_lock/main/lockDetail/electronicKey/electronicKeyDetail/keyOperationRecordEntity.dart'; +import 'package:star_lock/main/lockDetail/electronicKey/electronicKeyDetail/keyOperationRecord/keyOperationRecord_entity.dart'; import 'package:star_lock/main/lockDetail/passwordKey/passwordKey_perpetual/passwordKeyEntity.dart'; import 'package:star_lock/network/api_repository.dart'; import 'package:star_lock/tools/baseGetXController.dart'; @@ -18,14 +18,14 @@ class ElectronicKeyDetailChangeDateLogic extends BaseGetXController { keyboardPwdId: state.pwdId.value.toString(), keyboardPwdName: state.inputNameController.text, newKeyboardPwd: state.inputPwdController.text, - startDate: state.beginTimeTimestamp.value, - endDate: state.endTimeTimestamp.value, + startDate: state.effectiveDateTime.millisecondsSinceEpoch, + endDate: state.failureDateTime.millisecondsSinceEpoch, changeType: state.changeType.value, hoursStart: state.hoursStart.value, hoursEnd: state.hoursEnd.value, isCoerced: state.isCoerced.value); if (entity.errorCode!.codeIsSuccessful) { - showToast("修改成功", something: (){ + showToast("修改成功", something: () { eventBus.fire(ElectronicKeyListRefreshUI()); eventBus.fire(AuthorizedAdminPageRefreshUI()); Get.back(); @@ -33,11 +33,13 @@ class ElectronicKeyDetailChangeDateLogic extends BaseGetXController { } } - //修改钥匙请求 + //编辑电子钥匙有效期请求 Future updateKeyDateRequest() async { - var beginTimeTimestamp = state.beginTimeTimestamp.value ~/ 1000; - var endTimeTimestamp = state.endTimeTimestamp.value ~/ 1000; - if (beginTimeTimestamp > endTimeTimestamp || beginTimeTimestamp == endTimeTimestamp) { + var beginTimeTimestamp = + state.effectiveDateTime.millisecondsSinceEpoch ~/ 1000; + var endTimeTimestamp = state.failureDateTime.millisecondsSinceEpoch ~/ 1000; + if (beginTimeTimestamp > endTimeTimestamp || + beginTimeTimestamp == endTimeTimestamp) { showToast("失效时间需大于生效时间"); return; } @@ -49,19 +51,17 @@ class ElectronicKeyDetailChangeDateLogic extends BaseGetXController { KeyOperationRecordEntity entity = await ApiRepository.to.updateKeyDate( state.itemData.value.keyId.toString(), state.itemData.value.lockId.toString(), - state.endTimeTimestamp.value.toString(), - state.endDay.value, - '', - state.beginTimeTimestamp.value.toString(), - state.startDay.value, - state.weekDays.value); + state.failureDateTime.millisecondsSinceEpoch.toString(), + state.effectiveDateTime.millisecondsSinceEpoch.toString(), + state.weekDays.value, + state.itemData.value.keyType! == 1 ? 2 : state.itemData.value.keyType!); if (entity.errorCode!.codeIsSuccessful) { - showToast("修改成功", something: (){ + showToast("修改成功", something: () { eventBus.fire(ElectronicKeyListRefreshUI()); eventBus.fire(AuthorizedAdminPageRefreshUI()); Get.back(result: { - "beginTimeTimestamp":state.beginTimeTimestamp.value, - "endTimeTimestamp":state.endTimeTimestamp.value, + "beginTimeTimestamp": beginTimeTimestamp, + "endTimeTimestamp": endTimeTimestamp, }); }); } diff --git a/star_lock/lib/main/lockDetail/electronicKey/electronicKeyDetail/electronicKeyDetailChangeDate/electronicKeyDetailChangeDate_page.dart b/star_lock/lib/main/lockDetail/electronicKey/electronicKeyDetail/electronicKeyDetailChangeDate/electronicKeyDetailChangeDate_page.dart index 8c1701b4..0cdf62c8 100644 --- a/star_lock/lib/main/lockDetail/electronicKey/electronicKeyDetail/electronicKeyDetailChangeDate/electronicKeyDetailChangeDate_page.dart +++ b/star_lock/lib/main/lockDetail/electronicKey/electronicKeyDetail/electronicKeyDetailChangeDate/electronicKeyDetailChangeDate_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/main/lockDetail/electronicKey/electronicKeyDetail/electronicKeyDetailChangeDate/electronicKeyDetailChangeDate_logic.dart'; +import 'package:star_lock/tools/dateUtils.dart'; import 'package:star_lock/tools/pickers/pickers.dart'; import 'package:star_lock/tools/pickers/time_picker/model/date_mode.dart'; @@ -73,32 +74,34 @@ class _ElectronicKeyDetailChangeDateState children: [ Obx(() => CommonItem( leftTitel: TranslationLoader.lanKeys!.effectiveTime!.tr, - rightTitle: state.beginTime.value, + rightTitle: state.selectEffectiveDate.value, isHaveLine: true, isHaveDirection: true, action: () { - Pickers.showDatePicker(context, mode: DateMode.YMDHM, onConfirm: (p) { - state.beginTime.value = "${p.year}-${p.month.toString().padLeft(2, '0')}-${p.day.toString().padLeft(2, '0')} ${p.hour.toString().padLeft(2, '0')}:${p.minute!.toString().padLeft(2, '0')}"; - state.beginTimeTimestamp.value = DateTime.parse(state.beginTime.value).millisecondsSinceEpoch; - print("state.beginTimeTimestamp.value:${state.beginTimeTimestamp.value}"); + Pickers.showDatePicker(context, mode: DateMode.YMDHM, + onConfirm: (p) { + state.effectiveDateTime = XSDateUtils.parseDateTime( + '${p.year}-${p.month!}-${p.day} ${p.hour!}:${p.minute!}', + 'yyyy-mm-dd HH:mm'); + state.selectEffectiveDate.value = XSDateUtils.formatDateTime( + state.effectiveDateTime, 'yyyy-mm-dd HH:mm'); }); })), Obx(() => CommonItem( leftTitel: TranslationLoader.lanKeys!.failureTime!.tr, - rightTitle: state.endTime.value, + rightTitle: state.selectFailureDate.value, isHaveDirection: true, action: () { - Pickers.showDatePicker(context, mode: DateMode.YMDHM, onConfirm: (p) { - state.endTime.value = "${p.year}-${p.month.toString().padLeft(2, '0')}-${p.day.toString().padLeft(2, '0')} ${p.hour.toString().padLeft(2, '0')}:${p.minute!.toString().padLeft(2, '0')}"; - state.endTimeTimestamp.value = DateTime.parse(state.endTime.value).millisecondsSinceEpoch; - print("state.endTimeTimestamp.value:${state.endTimeTimestamp.value}"); + Pickers.showDatePicker(context, mode: DateMode.YMDHM, + onConfirm: (p) { + state.failureDateTime = XSDateUtils.parseDateTime( + '${p.year}-${p.month!}-${p.day} ${p.hour!}:${p.minute!}', + 'yyyy-mm-dd HH:mm'); + state.selectFailureDate.value = XSDateUtils.formatDateTime( + state.failureDateTime, 'yyyy-mm-dd HH:mm'); }); })), ], ); } - - String intToStr(int v) { - return (v < 10) ? "0$v" : "$v"; - } } diff --git a/star_lock/lib/main/lockDetail/electronicKey/electronicKeyDetail/electronicKeyDetailChangeDate/electronicKeyDetailChangeDate_state.dart b/star_lock/lib/main/lockDetail/electronicKey/electronicKeyDetail/electronicKeyDetailChangeDate/electronicKeyDetailChangeDate_state.dart index 186c7636..960a6961 100644 --- a/star_lock/lib/main/lockDetail/electronicKey/electronicKeyDetail/electronicKeyDetailChangeDate/electronicKeyDetailChangeDate_state.dart +++ b/star_lock/lib/main/lockDetail/electronicKey/electronicKeyDetail/electronicKeyDetailChangeDate/electronicKeyDetailChangeDate_state.dart @@ -16,21 +16,10 @@ class ElectronicKeyDetailChangeDateState { final pwdId = ''.obs; final lockId = 0.obs; final fromType = ''.obs; - - // final startDate = 0.obs; - // final endDate = 0.obs; - // final selectEffectiveDate = ''.obs; //生效时间 - // final selectFailureDate = ''.obs; //失效时间 - // DateTime effectiveDateTime = DateTime.now(); - // DateTime failureDateTime = DateTime.now(); - - var beginTime = "".obs;// 开始时间 - var endTime = "".obs;// 结束时间 - var beginTimeTimestamp = 0.obs;// 开始时间时间戳 - var endTimeTimestamp = 0.obs;// 结束时间时间戳 - - final endDay = ''.obs; - final startDay = ''.obs; + final selectEffectiveDate = ''.obs; //生效时间 + final selectFailureDate = ''.obs; //失效时间 + DateTime effectiveDateTime = DateTime.now(); + DateTime failureDateTime = DateTime.now(); final weekDays = [].obs; ElectronicKeyDetailChangeDateState() { @@ -38,10 +27,10 @@ class ElectronicKeyDetailChangeDateState { // itemData.value = map["itemData"]; if ((map["itemData"] != null)) { itemData.value = map["itemData"]; - beginTime.value = DateTool().dateToYMDHNString(itemData.value.startDate.toString()); - endTime.value = DateTool().dateToYMDHNString(itemData.value.endDate.toString()); - beginTimeTimestamp.value = itemData.value.startDate!; - endTimeTimestamp.value = itemData.value.endDate!; + // beginTime.value = DateTool().dateToYMDHNString(itemData.value.startDate.toString()); + // endTime.value = DateTool().dateToYMDHNString(itemData.value.endDate.toString()); + // beginTimeTimestamp.value = itemData.value.startDate!; + // endTimeTimestamp.value = itemData.value.endDate!; } if ((map["pwdId"] != null)) { pwdId.value = map["pwdId"]; diff --git a/star_lock/lib/main/lockDetail/electronicKey/electronicKeyDetail/keyOperationRecordEntity.dart b/star_lock/lib/main/lockDetail/electronicKey/electronicKeyDetail/keyOperationRecord/keyOperationRecord_entity.dart similarity index 100% rename from star_lock/lib/main/lockDetail/electronicKey/electronicKeyDetail/keyOperationRecordEntity.dart rename to star_lock/lib/main/lockDetail/electronicKey/electronicKeyDetail/keyOperationRecord/keyOperationRecord_entity.dart diff --git a/star_lock/lib/main/lockDetail/electronicKey/electronicKeyDetail/keyOperationRecord/keyOperationRecord_logic.dart b/star_lock/lib/main/lockDetail/electronicKey/electronicKeyDetail/keyOperationRecord/keyOperationRecord_logic.dart new file mode 100644 index 00000000..53cb638b --- /dev/null +++ b/star_lock/lib/main/lockDetail/electronicKey/electronicKeyDetail/keyOperationRecord/keyOperationRecord_logic.dart @@ -0,0 +1,31 @@ +import 'package:star_lock/main/lockDetail/electronicKey/electronicKeyDetail/keyOperationRecord/keyOperationRecord_entity.dart'; +import 'package:star_lock/main/lockDetail/electronicKey/electronicKeyDetail/keyOperationRecord/keyOperationRecord_state.dart'; +import 'package:star_lock/network/api_repository.dart'; +import 'package:star_lock/tools/baseGetXController.dart'; + +class KeyOperationRecordLogic extends BaseGetXController { + final KeyOperationRecordState state = KeyOperationRecordState(); + + //请求操作记录列表 + Future mockNetworkDataRequest() async { + KeyOperationRecordEntity entity = await ApiRepository.to.lockRecordList( + '0', + state.keyId.value, + '0', + state.lockId.value, + '1', + '1', + '20', + '0', + '', + '', + '', + state.keyboardPwdId.value, + state.cardId.value, + state.fingerprintId.value); + if (entity.errorCode!.codeIsSuccessful) { + print("操作记录列表成功:${entity.data?.itemList}"); + state.dataList.value = entity.data!.itemList!; + } + } +} diff --git a/star_lock/lib/main/lockDetail/electronicKey/electronicKeyDetail/keyOperationRecord/keyOperationRecord_page.dart b/star_lock/lib/main/lockDetail/electronicKey/electronicKeyDetail/keyOperationRecord/keyOperationRecord_page.dart new file mode 100644 index 00000000..09ef5302 --- /dev/null +++ b/star_lock/lib/main/lockDetail/electronicKey/electronicKeyDetail/keyOperationRecord/keyOperationRecord_page.dart @@ -0,0 +1,88 @@ +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/main/lockDetail/electronicKey/electronicKeyDetail/keyOperationRecord/keyOperationRecord_entity.dart'; +import 'package:star_lock/main/lockDetail/electronicKey/electronicKeyDetail/keyOperationRecord/keyOperationRecord_logic.dart'; +import 'package:star_lock/tools/noData.dart'; +import 'package:star_lock/tools/titleAppBar.dart'; +import 'package:star_lock/translations/trans_lib.dart'; + +class KeyOperationRecordPage extends StatefulWidget { + const KeyOperationRecordPage({Key? key}) : super(key: key); + + @override + State createState() => _KeyOperationRecordPageState(); +} + +class _KeyOperationRecordPageState extends State { + final logic = Get.put(KeyOperationRecordLogic()); + final state = Get.find().state; + + @override + Widget build(BuildContext context) { + return Scaffold( + backgroundColor: AppColors.mainBackgroundColor, + appBar: TitleAppBar( + barTitle: TranslationLoader.lanKeys!.operatingRecord!.tr, + haveBack: true, + backgroundColor: AppColors.mainColor, + ), + body: Obx(() => state.dataList.value.isEmpty + ? NoData() + : _buildMainUI(state.dataList.value)), + ); + } + + Widget _buildMainUI(List itemDataList) { + return ListView.separated( + itemCount: itemDataList.length, + itemBuilder: (c, index) { + KeyRecordDataItem dataItem = itemDataList[index]; + int? operateDate = dataItem.operateDate; + DateTime dateStr = DateTime.fromMillisecondsSinceEpoch(operateDate!); + String operateDateStr = + '${dateStr.toLocal().toString().substring(0, 16)} 开锁'; + + return _electronicKeyItem(operateDateStr, () {}); + }, + separatorBuilder: (BuildContext context, int index) { + return const Divider( + height: 1, + color: AppColors.greyLineColor, + ); + }, + ); + } + + Widget _electronicKeyItem(String operateDate, Function() action) { + return GestureDetector( + onTap: action, + child: Container( + color: Colors.white, + height: 68.h, + child: Row( + children: [ + SizedBox( + width: 30.w, + ), + Image.asset( + 'images/icon_recordDate.png', + width: 24.w, + height: 24.w, + color: AppColors.darkGrayTextColor, + ), + SizedBox( + width: 20.w, + ), + Text( + operateDate, + style: TextStyle(color: AppColors.blackColor, fontSize: 20.sp), + ), + SizedBox(width: 20.h), + ], + ), + ), + ); + } +} diff --git a/star_lock/lib/main/lockDetail/electronicKey/electronicKeyDetail/keyOperationRecord/keyOperationRecord_state.dart b/star_lock/lib/main/lockDetail/electronicKey/electronicKeyDetail/keyOperationRecord/keyOperationRecord_state.dart new file mode 100644 index 00000000..e063016b --- /dev/null +++ b/star_lock/lib/main/lockDetail/electronicKey/electronicKeyDetail/keyOperationRecord/keyOperationRecord_state.dart @@ -0,0 +1,31 @@ +import 'package:get/get.dart'; +import 'package:star_lock/main/lockDetail/electronicKey/electronicKeyDetail/keyOperationRecord/keyOperationRecord_entity.dart'; + +class KeyOperationRecordState { + var dataList = [].obs; + final keyId = ''.obs; + final lockId = ''.obs; + final keyboardPwdId = ''.obs; //密码ID + final cardId = ''.obs; //卡ID + final fingerprintId = ''.obs; //指纹ID + + KeyOperationRecordState() { + Map map = Get.arguments; + if ((map["keyId"] != null)) { + keyId.value = map["keyId"]; + } + if ((map["lockId"] != null)) { + lockId.value = map["lockId"]; + } + if ((map["keyboardPwdId"] != null)) { + keyboardPwdId.value = map["keyboardPwdId"]; + } + if ((map["cardId"] != null)) { + cardId.value = map["cardId"]; + } + + if ((map["fingerprintId"] != null)) { + fingerprintId.value = map["fingerprintId"]; + } + } +} diff --git a/star_lock/lib/main/lockDetail/electronicKey/electronicKeyDetail/keyOperationRecord_page.dart b/star_lock/lib/main/lockDetail/electronicKey/electronicKeyDetail/keyOperationRecord_page.dart deleted file mode 100644 index 750329f2..00000000 --- a/star_lock/lib/main/lockDetail/electronicKey/electronicKeyDetail/keyOperationRecord_page.dart +++ /dev/null @@ -1,159 +0,0 @@ -import 'package:flutter/material.dart'; -import 'package:flutter_screenutil/flutter_screenutil.dart'; -import 'package:get/get.dart'; -import 'package:star_lock/main/lockDetail/electronicKey/electronicKeyDetail/keyOperationRecordEntity.dart'; -import 'package:star_lock/network/api_repository.dart'; -import 'package:star_lock/tools/baseGetXController.dart'; - -import '../../../../app_settings/app_colors.dart'; -import '../../../../tools/titleAppBar.dart'; -import '../../../../translations/trans_lib.dart'; - -class KeyOperationRecordPage extends StatefulWidget { - const KeyOperationRecordPage({Key? key}) : super(key: key); - - @override - State createState() => _KeyOperationRecordPageState(); -} - -class _KeyOperationRecordPageState extends State { - String _keyId = ''; - String _lockId = ''; - String _keyboardPwdId = ''; //密码ID - String _cardId = ''; //卡ID - String _fingerprintId = ''; //指纹ID - @override - Widget build(BuildContext context) { - dynamic obj = ModalRoute.of(context)?.settings.arguments; - if (obj != null && (obj["keyId"] != null)) { - _keyId = obj["keyId"]; - } - if (obj != null && (obj["lockId"] != null)) { - _lockId = obj["lockId"]; - } - if (obj != null && (obj["keyboardPwdId"] != null)) { - _keyboardPwdId = obj["keyboardPwdId"]; - } - if (obj != null && (obj["cardId"] != null)) { - _cardId = obj["cardId"]; - } - - if (obj != null && (obj["fingerprintId"] != null)) { - _fingerprintId = obj["fingerprintId"]; - } - - return Scaffold( - backgroundColor: AppColors.mainBackgroundColor, - appBar: TitleAppBar( - barTitle: TranslationLoader.lanKeys!.operatingRecord!.tr, - haveBack: true, - backgroundColor: AppColors.mainColor, - ), - body: FutureBuilder>( - future: mockNetworkDataRequest(), - builder: (BuildContext context, - AsyncSnapshot> snapshot) { - //请求结束 - if (snapshot.connectionState == ConnectionState.done) { - if (snapshot.hasError) { - //请求失败 - return const Text('请求失败'); - } else { - //请求成功 - final List itemDataList = snapshot.data!; - - return Column( - children: [ - Expanded(child: _buildMainUI(itemDataList)), - ], - ); - } - } else { - //请求未结束 显示loading - return Container(); - } - }), - ); - } - - //请求操作记录列表 - Future> mockNetworkDataRequest() async { - KeyOperationRecordEntity entity = await ApiRepository.to.lockRecordList( - '0', - _keyId, - '0', - _lockId, - '1', - '1', - '20', - '0', - '', - '', - '', - _keyboardPwdId, - _cardId, - _fingerprintId); - if (entity.errorCode!.codeIsSuccessful) { - print("操作记录列表成功:${entity.data?.itemList}"); - } - final data = entity.data; - if (data != null) { - return data.itemList!; - } else { - List dataList = []; - return dataList; - } - } - - Widget _buildMainUI(List itemDataList) { - return ListView.separated( - itemCount: itemDataList.length, - itemBuilder: (c, index) { - KeyRecordDataItem dataItem = itemDataList[index]; - int? operateDate = dataItem.operateDate; - DateTime dateStr = DateTime.fromMillisecondsSinceEpoch(operateDate!); - String operateDateStr = - '${dateStr.toLocal().toString().substring(0, 16)} 开锁'; - - return _electronicKeyItem(operateDateStr, () {}); - }, - separatorBuilder: (BuildContext context, int index) { - return const Divider( - height: 1, - color: AppColors.greyLineColor, - ); - }, - ); - } - - Widget _electronicKeyItem(String operateDate, Function() action) { - return GestureDetector( - onTap: action, - child: Container( - color: Colors.white, - height: 68.h, - child: Row( - children: [ - SizedBox( - width: 30.w, - ), - Image.asset( - 'images/icon_recordDate.png', - width: 24.w, - height: 24.w, - color: AppColors.darkGrayTextColor, - ), - SizedBox( - width: 20.w, - ), - Text( - operateDate, - style: TextStyle(color: AppColors.blackColor, fontSize: 20.sp), - ), - SizedBox(width: 20.h), - ], - ), - ), - ); - } -} diff --git a/star_lock/lib/main/lockDetail/electronicKey/electronicKeyList/electronicKeyList_page.dart b/star_lock/lib/main/lockDetail/electronicKey/electronicKeyList/electronicKeyList_page.dart index 48c80968..2cac4ed1 100644 --- a/star_lock/lib/main/lockDetail/electronicKey/electronicKeyList/electronicKeyList_page.dart +++ b/star_lock/lib/main/lockDetail/electronicKey/electronicKeyList/electronicKeyList_page.dart @@ -40,7 +40,7 @@ class _ElectronicKeyListPageState extends State { // 获取是否是演示模式 演示模式不获取接口 var isDemoMode = await Storage.getBool(ifIsDemoModeOrNot); if (isDemoMode == false) { - logic.mockNetworkDataRequest().then((ElectronicKeyListEntity value){ + logic.mockNetworkDataRequest().then((ElectronicKeyListEntity value) { setState(() {}); }); } @@ -73,11 +73,11 @@ class _ElectronicKeyListPageState extends State { ], ), body: EasyRefreshTool( - onRefresh: (){ + onRefresh: () { logic.pageNo = 1; mockRequest(); }, - onLoad: (){ + onLoad: () { mockRequest(); }, child: Column( @@ -92,8 +92,7 @@ class _ElectronicKeyListPageState extends State { SizedBox( height: 20.h, ), - Expanded( - child: _buildMainUI()), + Expanded(child: _buildMainUI()), SizedBox( height: 20.h, ), @@ -123,65 +122,78 @@ class _ElectronicKeyListPageState extends State { Widget _buildMainUI() { return Obx(() => state.itemDataList.value.isEmpty - ? NoData(noDataHeight: 1.sh - ScreenUtil().statusBarHeight - ScreenUtil().bottomBarHeight - 190.h - 64.h) + ? NoData( + noDataHeight: 1.sh - + ScreenUtil().statusBarHeight - + ScreenUtil().bottomBarHeight - + 190.h - + 64.h) : SlidableAutoCloseBehavior( - child: ListView.separated( - shrinkWrap: true, - itemCount: state.itemDataList.value.length, - itemBuilder: (c, index) { - ElectronicKeyListItem indexEntity = state.itemDataList.value[index]; - String useDateStr = ''; //使用期限 - String keyStatus = ''; //钥匙状态 + child: ListView.separated( + shrinkWrap: true, + itemCount: state.itemDataList.value.length, + itemBuilder: (c, index) { + ElectronicKeyListItem indexEntity = + state.itemDataList.value[index]; + String useDateStr = ''; //使用期限 + String keyStatus = ''; //钥匙状态 - //使用期限 - useDateStr = getUseDateStr(indexEntity); + //使用期限 + useDateStr = getUseDateStr(indexEntity); - //钥匙状态 - keyStatus = getKeyStatus(indexEntity.keyStatus); + //钥匙状态 + keyStatus = getKeyStatus(indexEntity.keyStatus); - //是否为管理钥匙 - bool isAdminKey = false; - if (indexEntity.keyRight == 1) { - isAdminKey = true; - } else { - isAdminKey = false; - } + //是否为管理钥匙 + bool isAdminKey = false; + if (indexEntity.keyRight == 1) { + isAdminKey = true; + } else { + isAdminKey = false; + } - return Slidable( - key:ValueKey(indexEntity.keyId), - endActionPane: ActionPane( - extentRatio: 0.2, - motion: const ScrollMotion(), - children: [ - SlidableAction( - onPressed: (BuildContext context){ - showIosTipViewDialog(context, indexEntity.keyId!.toString()); - }, - backgroundColor: Colors.red, - foregroundColor: Colors.white, - label: '删除', - ), - ], + return Slidable( + key: ValueKey(indexEntity.keyId), + endActionPane: ActionPane( + extentRatio: 0.2, + motion: const ScrollMotion(), + children: [ + SlidableAction( + onPressed: (BuildContext context) { + showIosTipViewDialog( + context, indexEntity.keyId!.toString()); + }, + backgroundColor: Colors.red, + foregroundColor: Colors.white, + label: '删除', + ), + ], + ), + child: _electronicKeyItem( + 'images/controls_user.png', + indexEntity.keyName!, + useDateStr, + keyStatus, + isAdminKey, () { + Navigator.pushNamed( + context, Routers.electronicKeyDetailPage, + arguments: {"itemData": indexEntity}).then((val) { + if (val != null) { + logic.mockNetworkDataRequest(); + setState(() {}); + } + }); + }), + ); + }, + separatorBuilder: (BuildContext context, int index) { + return const Divider( + height: 1, + color: AppColors.greyLineColor, + ); + }, ), - child: _electronicKeyItem('images/controls_user.png', indexEntity.keyName!, useDateStr, keyStatus, isAdminKey, () { - Navigator.pushNamed(context, Routers.electronicKeyDetailPage, - arguments: {"itemData": indexEntity}).then((val) { - if (val != null) { - logic.mockNetworkDataRequest(); - setState(() {}); - } - }); - }), - ); - }, - separatorBuilder: (BuildContext context, int index) { - return const Divider( - height: 1, - color: AppColors.greyLineColor, - ); - }, - ), - )); + )); } Widget _buildDeleteBtn(String keyId) { @@ -291,7 +303,11 @@ class _ElectronicKeyListPageState extends State { child: Row( children: [ SizedBox(width: 30.w), - Image.asset(avatarURL, width: 60.w, height: 60.w,), + Image.asset( + avatarURL, + width: 60.w, + height: 60.w, + ), SizedBox(width: 20.w), Expanded( child: Column( @@ -305,16 +321,20 @@ class _ElectronicKeyListPageState extends State { child: Row( children: [ Flexible( - child: Text( - receiveUser, - maxLines: 1, - overflow: TextOverflow.ellipsis, - style: TextStyle(fontSize: 24.sp, color: AppColors.blackColor) - ), + child: Text(receiveUser, + maxLines: 1, + overflow: TextOverflow.ellipsis, + style: TextStyle( + fontSize: 24.sp, + color: AppColors.blackColor)), ), SizedBox(width: 10.w), isAdminKey - ? Image.asset('images/icon_electronicKey_admin.png', width: 24.w, height: 20.w,) + ? Image.asset( + 'images/icon_electronicKey_admin.png', + width: 24.w, + height: 20.w, + ) : Container(), ], ), diff --git a/star_lock/lib/main/lockDetail/electronicKey/electronicKeyPeriodValidity/electronicKeyPeriodValidity_page.dart b/star_lock/lib/main/lockDetail/electronicKey/electronicKeyPeriodValidity/electronicKeyPeriodValidity_page.dart index edd243e4..57cb71d1 100644 --- a/star_lock/lib/main/lockDetail/electronicKey/electronicKeyPeriodValidity/electronicKeyPeriodValidity_page.dart +++ b/star_lock/lib/main/lockDetail/electronicKey/electronicKeyPeriodValidity/electronicKeyPeriodValidity_page.dart @@ -1,9 +1,9 @@ -import 'package:date_format/date_format.dart'; import 'package:flutter/material.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:get/get.dart'; import 'package:star_lock/main/lockDetail/electronicKey/electronicKeyPeriodValidity/KeyPeriodValidityModel.dart'; import 'package:star_lock/main/lockDetail/electronicKey/electronicKeyPeriodValidity/electronicKeyPeriodValidity_logic.dart'; +import 'package:star_lock/tools/dateUtils.dart'; import 'package:star_lock/tools/pickers/pickers.dart'; import 'package:star_lock/tools/pickers/time_picker/model/date_mode.dart'; @@ -52,15 +52,15 @@ class _ElectronicKeyPeriodValidityPageState backgroundColor: AppColors.mainColor), body: ListView( children: [ - topWidget(), - Container( - color: Colors.white, + effectiveDateWidget(), + SizedBox( height: 10.h, ), - const Divider( - height: 1, - color: AppColors.greyLineColor, + topWidget(), + SizedBox( + height: 10.h, ), + effectiveTimeWidget(), bottomWidget() ], )); @@ -68,7 +68,7 @@ class _ElectronicKeyPeriodValidityPageState Widget topWidget() { return Container( - height: 150.h, + height: 160.h, width: 1.sw, color: Colors.white, child: Column( @@ -92,7 +92,11 @@ class _ElectronicKeyPeriodValidityPageState KeyPeriodValidityModel model = state.validityDataList.value[index]; return btnItem(model); - })) + })), + Container( + color: Colors.white, + height: 10.h, + ), ], ), ); @@ -107,6 +111,7 @@ class _ElectronicKeyPeriodValidityPageState } else { state.selectIndexList.value.remove(model.validityValue); } + setState(() {}); }, child: Container( @@ -135,7 +140,8 @@ class _ElectronicKeyPeriodValidityPageState )); } - Widget bottomWidget() { + //生效日期 + Widget effectiveDateWidget() { return Column( children: [ Obx(() => CommonItem( @@ -144,14 +150,13 @@ class _ElectronicKeyPeriodValidityPageState isHaveDirection: true, isHaveLine: true, action: () { - Pickers.showDatePicker(context, mode: DateMode.YMDHM, + Pickers.showDatePicker(context, mode: DateMode.YMD, onConfirm: (p) { state.isHaveEffectiveDate.value = true; - state.effectiveDateTime.value = DateTime.parse( - '${p.year}-${intToStr(p.month!)}-${intToStr(p.day!)} ${intToStr(p.hour!)}:${intToStr(p.minute!)}'); - state.selectEffectiveDate.value = formatDate( - state.effectiveDateTime.value, - [yyyy, '-', mm, '-', dd, ' ', HH, ':', nn]); + state.effectiveDate.value = XSDateUtils.parseDateTime( + '${p.year}-${p.month!}-${p.day!}', 'yyyy-mm-dd'); + state.selectEffectiveDate.value = XSDateUtils.formatDateTime( + state.effectiveDate.value, 'yyyy-mm-dd'); }); })), Obx(() => CommonItem( @@ -159,16 +164,59 @@ class _ElectronicKeyPeriodValidityPageState rightTitle: state.selectFailureDate.value, isHaveDirection: true, action: () { - Pickers.showDatePicker(context, mode: DateMode.YMDHM, + Pickers.showDatePicker(context, mode: DateMode.YMD, onConfirm: (p) { state.isHaveFailureDate.value = true; - state.failureDateTime.value = DateTime.parse( - '${p.year}-${intToStr(p.month!)}-${intToStr(p.day!)} ${intToStr(p.hour!)}:${intToStr(p.minute!)}'); - state.selectFailureDate.value = formatDate( - state.failureDateTime.value, - [yyyy, '-', mm, '-', dd, ' ', HH, ':', nn]); + state.failureDate.value = XSDateUtils.parseDateTime( + '${p.year}-${p.month!}-${p.day!}', 'yyyy-mm-dd'); + state.selectFailureDate.value = XSDateUtils.formatDateTime( + state.failureDate.value, 'yyyy-mm-dd'); }); })), + ], + ); + } + + //生效时间 + Widget effectiveTimeWidget() { + return Column( + children: [ + Obx(() => CommonItem( + leftTitel: TranslationLoader.lanKeys!.effectiveTime!.tr, + rightTitle: state.selectEffectiveTime.value, + isHaveDirection: true, + isHaveLine: true, + action: () { + Pickers.showDatePicker(context, mode: DateMode.HM, + onConfirm: (p) { + state.isHaveEffectiveTime.value = true; + state.effectiveTime.value = XSDateUtils.parseDateTime( + '${p.hour!}:${p.minute!}', 'HH:mm'); + state.selectEffectiveTime.value = XSDateUtils.formatDateTime( + state.effectiveTime.value, 'HH:mm'); + }); + })), + Obx(() => CommonItem( + leftTitel: TranslationLoader.lanKeys!.failureTime!.tr, + rightTitle: state.selectFailureTime.value, + isHaveDirection: true, + action: () { + Pickers.showDatePicker(context, mode: DateMode.HM, + onConfirm: (p) { + state.isHaveFailureTime.value = true; + state.failureTime.value = XSDateUtils.parseDateTime( + '${p.hour!}:${p.minute!}', 'HH:mm'); + state.selectFailureTime.value = XSDateUtils.formatDateTime( + state.failureTime.value, 'HH:mm'); + }); + })), + ], + ); + } + + Widget bottomWidget() { + return Column( + children: [ Container(height: 40.h), Obx(() => SubmitBtn( btnName: TranslationLoader.lanKeys!.sure!.tr, @@ -177,7 +225,9 @@ class _ElectronicKeyPeriodValidityPageState padding: EdgeInsets.only(top: 25.w, bottom: 25.w), isDisabled: (state.selectIndexList.value.isNotEmpty && state.isHaveEffectiveDate.value == true && - state.isHaveFailureDate.value == true) + state.isHaveFailureDate.value == true && + state.isHaveEffectiveTime.value == true && + state.isHaveFailureTime.value == true) ? true : false, onClick: () { @@ -185,17 +235,17 @@ class _ElectronicKeyPeriodValidityPageState state.isHaveEffectiveDate.value == true && state.isHaveFailureDate.value == true)) { DateTime startDateTime = DateTime( - state.effectiveDateTime.value.year, - state.effectiveDateTime.value.month, - state.effectiveDateTime.value.day, - state.effectiveDateTime.value.hour, - state.effectiveDateTime.value.minute); + state.effectiveDate.value.year, + state.effectiveDate.value.month, + state.effectiveDate.value.day, + state.effectiveDate.value.hour, + state.effectiveDate.value.minute); DateTime endDateTime = DateTime( - state.failureDateTime.value.year, - state.failureDateTime.value.month, - state.failureDateTime.value.day, - state.failureDateTime.value.hour, - state.failureDateTime.value.minute); + state.failureDate.value.year, + state.failureDate.value.month, + state.failureDate.value.day, + state.failureDate.value.hour, + state.failureDate.value.minute); //时间判断 if (!startDateTime.isBefore(endDateTime) || startDateTime.isAtSameMomentAs(endDateTime)) { @@ -203,8 +253,10 @@ class _ElectronicKeyPeriodValidityPageState } else { Map resultMap = {}; resultMap['validityValue'] = state.selectIndexList.value; - resultMap['starDate'] = state.effectiveDateTime.value; - resultMap['endDate'] = state.failureDateTime.value; + resultMap['starDate'] = state.effectiveDate.value; + resultMap['endDate'] = state.failureDate.value; + resultMap['starTime'] = state.effectiveTime.value; + resultMap['endTime'] = state.failureTime.value; Navigator.pop(context, resultMap); } } @@ -212,8 +264,4 @@ class _ElectronicKeyPeriodValidityPageState ], ); } - - String intToStr(int v) { - return (v < 10) ? "0$v" : "$v"; - } } diff --git a/star_lock/lib/main/lockDetail/electronicKey/electronicKeyPeriodValidity/electronicKeyPeriodValidity_state.dart b/star_lock/lib/main/lockDetail/electronicKey/electronicKeyPeriodValidity/electronicKeyPeriodValidity_state.dart index 8e4027c6..c96e263d 100644 --- a/star_lock/lib/main/lockDetail/electronicKey/electronicKeyPeriodValidity/electronicKeyPeriodValidity_state.dart +++ b/star_lock/lib/main/lockDetail/electronicKey/electronicKeyPeriodValidity/electronicKeyPeriodValidity_state.dart @@ -1,3 +1,4 @@ +import 'package:date_format/date_format.dart'; import 'package:flutter/material.dart'; import 'package:get/get.dart'; import 'package:star_lock/main/lockDetail/electronicKey/electronicKeyList/entity/ElectronicKeyListEntity.dart'; @@ -24,11 +25,24 @@ class ElectronicKeyPeriodValidityState { ].obs; final validityDataList = [].obs; //自定义数据块 final selectIndexList = [].obs; //选中的有效期数组 - final selectEffectiveDate = ''.obs; //生效时间 - final selectFailureDate = ''.obs; //失效时间 + DateTime dateTime = DateTime.now(); - final effectiveDateTime = DateTime.now().obs; - final failureDateTime = DateTime.now().obs; + final effectiveDate = DateTime.now().obs; + final failureDate = DateTime.now().obs; + final selectEffectiveDate = ''.obs; //生效日期 + final selectFailureDate = ''.obs; //失效日期 + + final selectEffectiveTime = ''.obs; //生效时间 + final selectFailureTime = ''.obs; //失效时间 + final effectiveTime = DateTime.now().obs; + final failureTime = DateTime.now().obs; + var isHaveEffectiveDate = false.obs; var isHaveFailureDate = false.obs; + var isHaveEffectiveTime = false.obs; + var isHaveFailureTime = false.obs; + + String intToStr(int v) { + return (v < 10) ? "0$v" : "$v"; + } } diff --git a/star_lock/lib/main/lockDetail/electronicKey/sendElectronicKey/sendElectronicKey/sendElectronicKey_logic.dart b/star_lock/lib/main/lockDetail/electronicKey/sendElectronicKey/sendElectronicKey/sendElectronicKey_logic.dart index 4f8ca43d..b1eaddf3 100644 --- a/star_lock/lib/main/lockDetail/electronicKey/sendElectronicKey/sendElectronicKey/sendElectronicKey_logic.dart +++ b/star_lock/lib/main/lockDetail/electronicKey/sendElectronicKey/sendElectronicKey/sendElectronicKey_logic.dart @@ -14,26 +14,41 @@ class SendElectronicKeyLogic extends BaseGetXController { //发送钥匙请求 Future sendElectronicKeyRequest() async { - if(state.emailOrPhoneController.text.isEmpty){ + if (state.emailOrPhoneController.text.isEmpty) { showToast("请输入接收者账号"); return; } - if(state.keyNameController.text.isEmpty){ - showToast("请输入接收者姓名"); - return; - } + // 姓名变为非必填(同通通锁) + // if(state.keyNameController.text.isEmpty){ + // showToast("请输入接收者姓名"); + // return; + // } + + DateTime startDateTime = DateTime( + state.effectiveDateTime.value.year, + state.effectiveDateTime.value.month, + state.effectiveDateTime.value.day, + state.effectiveDateTime.value.hour, + state.effectiveDateTime.value.minute); + DateTime endDateTime = DateTime( + state.failureDateTime.value.year, + state.failureDateTime.value.month, + state.failureDateTime.value.day, + state.failureDateTime.value.hour, + state.failureDateTime.value.minute); - DateTime startDateTime = DateTime(state.effectiveDateTime.value.year, state.effectiveDateTime.value.month, state.effectiveDateTime.value.day, state.effectiveDateTime.value.hour, state.effectiveDateTime.value.minute); - DateTime endDateTime = DateTime(state.failureDateTime.value.year, state.failureDateTime.value.month, state.failureDateTime.value.day, state.failureDateTime.value.hour, state.failureDateTime.value.minute); //发送钥匙请求 if (state.type.value == "0" || state.type.value == "3") { - print("startDateTime:$startDateTime endDateTime:$endDateTime DateTime.now():${DateTime.now()} startDateTime.isBefore(endDateTime):${startDateTime.isBefore(endDateTime)}"); - if (!startDateTime.isBefore(endDateTime) || startDateTime.isAtSameMomentAs(endDateTime)) { + print( + "startDateTime:$startDateTime endDateTime:$endDateTime DateTime.now():${DateTime.now()} startDateTime.isBefore(endDateTime):${startDateTime.isBefore(endDateTime)}"); + if (!startDateTime.isBefore(endDateTime) || + startDateTime.isAtSameMomentAs(endDateTime)) { showToast("失效时间需大于生效时间"); return; } - if (!startDateTime.isBefore(DateTime.now()) || startDateTime.isAtSameMomentAs(DateTime.now())) { + if (!startDateTime.isBefore(DateTime.now()) || + startDateTime.isAtSameMomentAs(DateTime.now())) { showToast("生效时间需大于当前时间"); return; } @@ -45,8 +60,10 @@ class SendElectronicKeyLogic extends BaseGetXController { case 0: { typeValue = XSConstantMacro.keyTypeTime; - state.failureTimestamp.value = state.failureDateTime.value.millisecondsSinceEpoch; - state.effectiveTimestamp.value = state.effectiveDateTime.value.millisecondsSinceEpoch; + state.failureTimestamp.value = + state.failureDateTime.value.millisecondsSinceEpoch; + state.effectiveTimestamp.value = + state.effectiveDateTime.value.millisecondsSinceEpoch; } break; case 1: @@ -70,7 +87,7 @@ class SendElectronicKeyLogic extends BaseGetXController { usernameType: isPhoneNumber(state.emailOrPhoneController.text) == true ? '1' : '2', - endDate: state.failureTimestamp.value.toString(), + endDate: state.failureTimestamp.value, faceAuthentication: state.isAuthentication.value == true ? '1' : '2', isCameraEnable: '2', isRemoteUnlock: state.isRemoteUnlock.value == true ? '1' : '2', @@ -81,8 +98,10 @@ class SendElectronicKeyLogic extends BaseGetXController { operatorUid: '', receiverUsername: state.emailOrPhoneController.text, remarks: '', - startDate: state.effectiveTimestamp.value.toString(), - weekDays: state.weekdaysList.value); + startDate: state.effectiveTimestamp.value, + weekDays: state.weekdaysList.value, + startTime: state.startTime.value, + endTime: state.endTime.value); if (entity.errorCode!.codeIsSuccessful) { print('发送电子钥匙成功'); state.isSendSuccess.value = true; @@ -190,10 +209,14 @@ class SendElectronicKeyLogic extends BaseGetXController { ); } - void resetData(){ + void resetData() { state.emailOrPhoneController.text = ""; state.keyNameController.text = ""; - state.selectEffectiveDate = '${DateTime.now().year}-${DateTime.now().month}-${DateTime.now().day} ${DateTime.now().hour}:${DateTime.now().minute}'.obs; //默认为当前时间 - state.selectFailureDate = '${DateTime.now().year}-${DateTime.now().month}-${DateTime.now().day} ${DateTime.now().hour}:${DateTime.now().minute}'.obs; //默认为当前时间 + state.selectEffectiveDate = + '${DateTime.now().year}-${DateTime.now().month}-${DateTime.now().day} ${DateTime.now().hour}:${DateTime.now().minute}' + .obs; //默认为当前时间 + state.selectFailureDate = + '${DateTime.now().year}-${DateTime.now().month}-${DateTime.now().day} ${DateTime.now().hour}:${DateTime.now().minute}' + .obs; //默认为当前时间 } } diff --git a/star_lock/lib/main/lockDetail/electronicKey/sendElectronicKey/sendElectronicKey/sendElectronicKey_page.dart b/star_lock/lib/main/lockDetail/electronicKey/sendElectronicKey/sendElectronicKey/sendElectronicKey_page.dart index 98ceb8d3..b40935b9 100644 --- a/star_lock/lib/main/lockDetail/electronicKey/sendElectronicKey/sendElectronicKey/sendElectronicKey_page.dart +++ b/star_lock/lib/main/lockDetail/electronicKey/sendElectronicKey/sendElectronicKey/sendElectronicKey_page.dart @@ -8,6 +8,7 @@ import 'package:flutter_native_contact_picker/flutter_native_contact_picker.dart import 'package:star_lock/main/lockDetail/electronicKey/sendElectronicKey/sendElectronicKey/sendElectronicKey_logic.dart'; import 'package:star_lock/network/api_repository.dart'; import 'package:star_lock/tools/baseGetXController.dart'; +import 'package:star_lock/tools/dateUtils.dart'; import 'package:star_lock/tools/pickers/pickers.dart'; import 'package:star_lock/tools/pickers/time_picker/model/date_mode.dart'; import 'package:star_lock/tools/storage.dart'; @@ -53,7 +54,8 @@ class _SendElectronicKeyPageState extends State { } Widget indexChangeWidget() { - if (state.isSendSuccess.value == true && state.sendSucceedType.value.toString() == widget.type) { + if (state.isSendSuccess.value == true && + state.sendSucceedType.value.toString() == widget.type) { return sendElectronicKeySucceed(); } else { switch (int.parse(widget.type)) { @@ -66,7 +68,7 @@ class _SendElectronicKeyPageState extends State { keyTimeWidget(), remoteUnlockingWidget(), keyRealNameWidget(), - keyBottomWidget() + keyBottomWidget(state.timeLimitTips) ], ); } @@ -78,7 +80,7 @@ class _SendElectronicKeyPageState extends State { keyInfoWidget(), remoteUnlockingWidget(), keyRealNameWidget(), - keyBottomWidget() + keyBottomWidget(state.permanentTips) ], ); } @@ -90,7 +92,7 @@ class _SendElectronicKeyPageState extends State { keyInfoWidget(), remoteUnlockingWidget(), keyRealNameWidget(), - keyBottomWidget() + keyBottomWidget(state.onceLimitTips) ], ); } @@ -103,7 +105,7 @@ class _SendElectronicKeyPageState extends State { keyPeriodValidityWidget(), remoteUnlockingWidget(), keyRealNameWidget(), - keyBottomWidget() + keyBottomWidget(state.cycleLimitTips) ], ); } @@ -144,7 +146,6 @@ class _SendElectronicKeyPageState extends State { result as Map; state.countryCode.value = result['code']; state.countryName.value = result['countryName']; - setState(() {}); } }, ), @@ -171,12 +172,11 @@ class _SendElectronicKeyPageState extends State { action: () { Pickers.showDatePicker(context, mode: DateMode.YMDHM, onConfirm: (p) { - setState(() { - state.selectEffectiveDate.value = - '${p.year}-${intToStr(p.month!)}-${intToStr(p.day!)} ${intToStr(p.hour!)}:${intToStr(p.minute!)}'; - state.effectiveDateTime.value = - DateTime.parse(state.selectEffectiveDate.value); - }); + state.effectiveDateTime.value = XSDateUtils.parseDateTime( + '${p.year}-${p.month!}-${p.day} ${p.hour!}:${p.minute!}', + 'yyyy-mm-dd HH:mm'); + state.selectEffectiveDate.value = XSDateUtils.formatDateTime( + state.effectiveDateTime.value, 'yyyy-mm-dd HH:mm'); }); }), CommonItem( @@ -186,12 +186,11 @@ class _SendElectronicKeyPageState extends State { action: () { Pickers.showDatePicker(context, mode: DateMode.YMDHM, onConfirm: (p) { - setState(() { - state.selectFailureDate.value = - '${p.year}-${intToStr(p.month!)}-${intToStr(p.day!)} ${intToStr(p.hour!)}:${intToStr(p.minute!)}'; - state.failureDateTime.value = - DateTime.parse(state.selectFailureDate.value); - }); + state.failureDateTime.value = XSDateUtils.parseDateTime( + '${p.year}-${p.month!}-${p.day} ${p.hour!}:${p.minute!}', + 'yyyy-mm-dd HH:mm'); + state.selectFailureDate.value = XSDateUtils.formatDateTime( + state.failureDateTime.value, 'yyyy-mm-dd HH:mm'); }); }), Container(height: 10.h), @@ -221,7 +220,7 @@ class _SendElectronicKeyPageState extends State { Widget keyPeriodValidityWidget() { return Column( children: [ - Obx(() => CommonItem( + CommonItem( leftTitel: TranslationLoader.lanKeys!.periodValidity!.tr, rightTitle: state.weekdaysList.value.isEmpty ? '' @@ -237,8 +236,11 @@ class _SendElectronicKeyPageState extends State { result['starDate'].millisecondsSinceEpoch; state.failureTimestamp.value = result['endDate'].millisecondsSinceEpoch; + state.startTime.value = + result['starTime'].millisecondsSinceEpoch; + state.endTime.value = result['endTime'].millisecondsSinceEpoch; } - })), + }), SizedBox( height: 10.h, ) @@ -246,7 +248,7 @@ class _SendElectronicKeyPageState extends State { ); } - Widget keyBottomWidget() { + Widget keyBottomWidget(String sendElectronicKeyTips) { return Column( children: [ Container( @@ -256,7 +258,7 @@ class _SendElectronicKeyPageState extends State { children: [ Expanded( child: Text( - TranslationLoader.lanKeys!.sendKeyBottomTip!.tr, + sendElectronicKeyTips, textAlign: TextAlign.start, style: TextStyle( fontSize: 18.sp, color: AppColors.darkGrayTextColor), @@ -411,7 +413,6 @@ class _SendElectronicKeyPageState extends State { // if (entity.errorCode!.codeIsSuccessful) { // print("标记为已入住成功啦啦啦啦啦"); // Toast.show(msg: "标记成功"); - // setState(() {}); // } else { // Toast.show(msg: '操作失败'); // } @@ -423,7 +424,6 @@ class _SendElectronicKeyPageState extends State { if (entity.errorCode!.codeIsSuccessful) { print("标记为已入住成功啦啦啦啦啦"); logic.showToast("标记成功"); - setState(() {}); } } @@ -461,10 +461,18 @@ class _SendElectronicKeyPageState extends State { // contentPadding: const EdgeInsets.only(top: 12.0, bottom: 8.0), hintText: tfStr, hintStyle: TextStyle(fontSize: 22.sp), - focusedBorder: const OutlineInputBorder(borderSide: BorderSide(width: 0, color: Colors.transparent)), - disabledBorder: const OutlineInputBorder(borderSide: BorderSide(width: 0, color: Colors.transparent)), - enabledBorder: const OutlineInputBorder(borderSide: BorderSide(width: 0, color: Colors.transparent)), - border: const OutlineInputBorder(borderSide: BorderSide(width: 0, color: Colors.transparent)), + focusedBorder: const OutlineInputBorder( + borderSide: + BorderSide(width: 0, color: Colors.transparent)), + disabledBorder: const OutlineInputBorder( + borderSide: + BorderSide(width: 0, color: Colors.transparent)), + enabledBorder: const OutlineInputBorder( + borderSide: + BorderSide(width: 0, color: Colors.transparent)), + border: const OutlineInputBorder( + borderSide: + BorderSide(width: 0, color: Colors.transparent)), contentPadding: const EdgeInsets.symmetric(vertical: 0), ), style: TextStyle( @@ -489,17 +497,15 @@ class _SendElectronicKeyPageState extends State { onTap: () async { Contact? currentContact = await state.contactPicker.selectContact(); - setState(() { - state.contact = currentContact!; - if (currentContact.phoneNumbers!.isNotEmpty) { - state.emailOrPhoneController.text = currentContact - .phoneNumbers![0] - .replaceAll(RegExp(r"\s+\b|\b\s"), ""); - } - if (currentContact.fullName!.isNotEmpty) { - state.keyNameController.text = currentContact.fullName!; - } - }); + state.contact = currentContact!; + if (currentContact.phoneNumbers!.isNotEmpty) { + state.emailOrPhoneController.text = currentContact + .phoneNumbers![0] + .replaceAll(RegExp(r"\s+\b|\b\s"), ""); + } + if (currentContact.fullName!.isNotEmpty) { + state.keyNameController.text = currentContact.fullName!; + } }, ), ) @@ -512,15 +518,16 @@ class _SendElectronicKeyPageState extends State { // 远程开锁 Widget remoteUnlockingWidget() { return Visibility( - visible: state.keyInfo.value.lockSetting!.remoteUnlock == 1 ? true : false, + visible: + state.keyInfo.value.lockSetting!.remoteUnlock == 1 ? true : false, child: Column( children: [ CommonItem( leftTitel: TranslationLoader.lanKeys!.remoteUnlockingAllowed!.tr, rightTitle: "", isHaveRightWidget: true, - rightWidget: - SizedBox(width: 60.w, height: 50.h, child: _remoteSwitch(true)), + rightWidget: SizedBox( + width: 60.w, height: 50.h, child: _remoteSwitch(true)), action: () {}), Container(height: 10.h), ], @@ -537,21 +544,15 @@ class _SendElectronicKeyPageState extends State { value: isRemote ? state.isRemoteUnlock.value : state.isAuthentication.value, onChanged: (value) { - setState(() { - if (isRemote) { - state.isRemoteUnlock.value = !state.isRemoteUnlock.value; - } else { - state.isAuthentication.value = !state.isAuthentication.value; - } - }); + if (isRemote) { + state.isRemoteUnlock.value = !state.isRemoteUnlock.value; + } else { + state.isAuthentication.value = !state.isAuthentication.value; + } }, ); } - String intToStr(int v) { - return (v < 10) ? "0$v" : "$v"; - } - Future _openModalBottomSheet() async { showModalBottomSheet( context: context, @@ -639,14 +640,14 @@ class _SendElectronicKeyPageState extends State { //微信好友 { String pwdShareStr = '您好,您的电子钥匙生成成功'; - NativeInteractionTool.loadNativeShare(shareText:pwdShareStr); + NativeInteractionTool.loadNativeShare(shareText: pwdShareStr); } break; case 1: //短信 { String pwdShareStr = '您好,您的电子钥匙生成成功'; - NativeInteractionTool.loadNativeShare(shareText:pwdShareStr); + NativeInteractionTool.loadNativeShare(shareText: pwdShareStr); } break; case 2: @@ -659,7 +660,7 @@ class _SendElectronicKeyPageState extends State { //更多 { String pwdShareStr = '您好,您的电子钥匙生成成功'; - NativeInteractionTool.loadNativeShare(shareText:pwdShareStr); + NativeInteractionTool.loadNativeShare(shareText: pwdShareStr); } break; default: diff --git a/star_lock/lib/main/lockDetail/electronicKey/sendElectronicKey/sendElectronicKey/sendElectronicKey_state.dart b/star_lock/lib/main/lockDetail/electronicKey/sendElectronicKey/sendElectronicKey/sendElectronicKey_state.dart index 1eb85be8..47965f72 100644 --- a/star_lock/lib/main/lockDetail/electronicKey/sendElectronicKey/sendElectronicKey/sendElectronicKey_state.dart +++ b/star_lock/lib/main/lockDetail/electronicKey/sendElectronicKey/sendElectronicKey/sendElectronicKey_state.dart @@ -19,6 +19,8 @@ class SendElectronicKeyState { final failureDateTime = DateTime.now().obs; final effectiveTimestamp = 0.obs; final failureTimestamp = 0.obs; + final startTime = 0.obs; + final endTime = 0.obs; var selectEffectiveDate = '${DateTime.now().year}-${DateTime.now().month}-${DateTime.now().day} ${DateTime.now().hour}:${DateTime.now().minute}' @@ -36,6 +38,11 @@ class SendElectronicKeyState { final sendSucceedType = 0.obs; + final timeLimitTips = '接收者在有效期内可以不限次数使用'; //限时 + final permanentTips = '接收者可以使用此App开关锁'; //永久 + final onceLimitTips = '单次钥匙有效期为1小时,只能使用一次'; //单次 + final cycleLimitTips = '接收者可以在有效期内的固定时间段里,不限次数使用'; //循环 + SendElectronicKeyState() { Map map = Get.arguments; keyInfo.value = map["keyInfo"]; diff --git a/star_lock/lib/main/lockDetail/lockDetail/lockDetail_logic.dart b/star_lock/lib/main/lockDetail/lockDetail/lockDetail_logic.dart index aa6cda64..852c6ad1 100644 --- a/star_lock/lib/main/lockDetail/lockDetail/lockDetail_logic.dart +++ b/star_lock/lib/main/lockDetail/lockDetail/lockDetail_logic.dart @@ -5,8 +5,8 @@ import 'package:flutter_reactive_ble/flutter_reactive_ble.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:get/get.dart'; import 'package:intl/intl.dart'; +import 'package:star_lock/main/lockDetail/electronicKey/electronicKeyDetail/keyOperationRecord/keyOperationRecord_entity.dart'; -import '../../../appRouters.dart'; import '../../../app_settings/app_colors.dart'; import '../../../blue/blue_manage.dart'; import '../../../blue/io_protocol/io_addUser.dart'; @@ -21,7 +21,6 @@ import '../../../network/api_repository.dart'; import '../../../tools/baseGetXController.dart'; import '../../../tools/eventBusEventManage.dart'; import '../../../tools/storage.dart'; -import '../electronicKey/electronicKeyDetail/keyOperationRecordEntity.dart'; import '../lockOperatingRecord/lockOperatingRecordGetLastRecordTime_entity.dart'; import 'lockDetail_state.dart'; import 'lockNetToken_entity.dart'; @@ -73,7 +72,7 @@ class LockDetailLogic extends BaseGetXController { // _showFullScreenOverlay(Get.context!); state.iSClosedUnlockSuccessfulPopup.value = true; - if(state.closedUnlockSuccessfulTimer != null){ + if (state.closedUnlockSuccessfulTimer != null) { state.closedUnlockSuccessfulTimer!.cancel(); state.closedUnlockSuccessfulTimer = null; } @@ -135,10 +134,10 @@ class LockDetailLogic extends BaseGetXController { break; case 0x16: - // 正在开锁中... + // 正在开锁中... print("${reply.commandType}正在开锁中..."); state.openLockBtnState.value = 0; - showToast("正在开锁中...", something: (){ + showToast("正在开锁中...", something: () { cancelBlueConnetctToastTimer(); }); break; @@ -370,13 +369,15 @@ class LockDetailLogic extends BaseGetXController { // 添加用户(普通用户接收电子钥匙) Future addUserConnectBlue() async { - showBlueConnetctToastTimer(action:() { + showBlueConnetctToastTimer(action: () { state.openLockBtnState.value = 0; // state.animationController.reset(); // state.animationController.forward(); }); - BlueManage().bludSendData(state.keyInfos.value.bluetooth!.bluetoothDeviceName!, (DeviceConnectionState deviceConnectionState) async { + BlueManage() + .bludSendData(state.keyInfos.value.bluetooth!.bluetoothDeviceName!, + (DeviceConnectionState deviceConnectionState) async { if (deviceConnectionState == DeviceConnectionState.connected) { // 私钥 var privateKey = await Storage.getStringList(saveBluePrivateKey); @@ -390,7 +391,8 @@ class LockDetailLogic extends BaseGetXController { if (token != null) { getTokenList = changeStringListToIntList(token); } - print("BlueManage().connectDeviceName:${BlueManage().connectDeviceName} authUserID:${state.senderUserId.toString()} keyID:${state.keyInfos.value.keyId.toString()} userID:${await Storage.getUid()}"); + print( + "BlueManage().connectDeviceName:${BlueManage().connectDeviceName} authUserID:${state.senderUserId.toString()} keyID:${state.keyInfos.value.keyId.toString()} userID:${await Storage.getUid()}"); IoSenderManage.senderAddUser( lockID: BlueManage().connectDeviceName, authUserID: state.senderUserId.toString(), @@ -406,9 +408,9 @@ class LockDetailLogic extends BaseGetXController { publicKey: publicKeyDataList, privateKey: getPrivateKeyList, token: getTokenList); - }else if (deviceConnectionState == DeviceConnectionState.disconnected){ + } else if (deviceConnectionState == DeviceConnectionState.disconnected) { cancelBlueConnetctToastTimer(); - if(state.ifCurrentScreen.value == true){ + if (state.ifCurrentScreen.value == true) { showBlueConnetctToast(); } @@ -421,7 +423,7 @@ class LockDetailLogic extends BaseGetXController { // 点击开门事件 Future openDoorAction(int openMode) async { - showBlueConnetctToastTimer(action:() { + showBlueConnetctToastTimer(action: () { state.openLockBtnState.value = 0; BlueManage().stopScan(); @@ -437,7 +439,8 @@ class LockDetailLogic extends BaseGetXController { var token = await Storage.getStringList(saveBlueToken); List getTokenList = changeStringListToIntList(token!); - print("openDoorTokenPubToken:$getTokenList getPrivateKeyList:$getPrivateKeyList"); + print( + "openDoorTokenPubToken:$getTokenList getPrivateKeyList:$getPrivateKeyList"); // ListlistData = await IoSenderManage.senderOpenLock( // keyID: BlueManage().connectDeviceName, // userID: await Storage.getUid(), @@ -449,8 +452,10 @@ class LockDetailLogic extends BaseGetXController { // signKey: signKeyDataList, // privateKey: getPrivateKeyList, // ); - BlueManage().bludSendData(state.keyInfos.value.bluetooth!.bluetoothDeviceName!, (DeviceConnectionState deviceConnectionState) async { - if (deviceConnectionState == DeviceConnectionState.connected){ + BlueManage() + .bludSendData(state.keyInfos.value.bluetooth!.bluetoothDeviceName!, + (DeviceConnectionState deviceConnectionState) async { + if (deviceConnectionState == DeviceConnectionState.connected) { IoSenderManage.senderOpenLock( keyID: BlueManage().connectDeviceName, userID: await Storage.getUid(), @@ -462,9 +467,9 @@ class LockDetailLogic extends BaseGetXController { signKey: signKeyDataList, privateKey: getPrivateKeyList, ); - }else if (deviceConnectionState == DeviceConnectionState.disconnected){ + } else if (deviceConnectionState == DeviceConnectionState.disconnected) { cancelBlueConnetctToastTimer(); - if(state.ifCurrentScreen.value == true){ + if (state.ifCurrentScreen.value == true) { showBlueConnetctToast(); } @@ -537,10 +542,11 @@ class LockDetailLogic extends BaseGetXController { // 获取锁状态 更新电量 Future getStarLockStatus() async { showEasyLoading(); - showBlueConnetctToastTimer(action: (){ + showBlueConnetctToastTimer(action: () { dismissEasyLoading(); }); - BlueManage().bludSendData(BlueManage().connectDeviceName, (DeviceConnectionState deviceConnectionState) async { + BlueManage().bludSendData(BlueManage().connectDeviceName, + (DeviceConnectionState deviceConnectionState) async { if (deviceConnectionState == DeviceConnectionState.connected) { dismissEasyLoading(); var privateKey = await Storage.getStringList(saveBluePrivateKey); @@ -553,7 +559,7 @@ class LockDetailLogic extends BaseGetXController { } else if (deviceConnectionState == DeviceConnectionState.disconnected) { dismissEasyLoading(); cancelBlueConnetctToastTimer(); - if(state.ifCurrentScreen.value == true){ + if (state.ifCurrentScreen.value == true) { showBlueConnetctToast(); } } @@ -591,7 +597,7 @@ class LockDetailLogic extends BaseGetXController { // startOpenLock() { - if(state.openLockBtnState.value == 1){ + if (state.openLockBtnState.value == 1) { return; } state.iSOpenLock.value = true; @@ -614,7 +620,7 @@ class LockDetailLogic extends BaseGetXController { } startUnLock() { - if(state.openLockBtnState.value == 1){ + if (state.openLockBtnState.value == 1) { return; } state.iSOpenLock.value = false; @@ -672,7 +678,8 @@ class LockDetailLogic extends BaseGetXController { // 获取手机联网token,根据锁设置里面获取的开锁时是否联网来判断是否调用这个接口 void getLockNetToken() async { - LockNetTokenEntity entity = await ApiRepository.to.getLockNetToken(lockId: state.keyInfos.value.lockId.toString()); + LockNetTokenEntity entity = await ApiRepository.to + .getLockNetToken(lockId: state.keyInfos.value.lockId.toString()); if (entity.errorCode!.codeIsSuccessful) { state.lockNetToken = entity.data!.token!; print("state.lockNetToken:${state.lockNetToken}"); @@ -698,7 +705,9 @@ class LockDetailLogic extends BaseGetXController { // 查询锁记录最后时间 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); } @@ -716,27 +725,34 @@ class LockDetailLogic extends BaseGetXController { //电量更新请求 Future uploadElectricQuantityRequest(String electricQuantity) async { - KeyOperationRecordEntity entity = await ApiRepository.to.uploadElectricQuantity(electricQuantity, state.keyInfos.value.lockId.toString()); + KeyOperationRecordEntity entity = await ApiRepository.to + .uploadElectricQuantity( + electricQuantity, state.keyInfos.value.lockId.toString()); if (entity.errorCode!.codeIsSuccessful) { - showToast("电量更新成功", something: (){ + showToast("电量更新成功", something: () { eventBus.fire(RefreshLockListInfoDataEvent()); }); } } + /// 锁设置里面开启关闭考勤刷新锁详情 StreamSubscription? _lockSetOpenOrCloseCheckInRefreshLockDetailWithAttendanceEvent; void _initLockSetOpenOrCloseCheckInRefreshLockDetailWithAttendanceAction() { // 蓝牙协议通知传输跟蓝牙之外的数据传输类不一样 eventBus - _lockSetOpenOrCloseCheckInRefreshLockDetailWithAttendanceEvent = eventBus.on().listen((event) { + _lockSetOpenOrCloseCheckInRefreshLockDetailWithAttendanceEvent = eventBus + .on() + .listen((event) { if (event.type == 0) { // 0考勤 state.isAttendance.value = int.parse(event.setResult); - state.keyInfos.value.lockSetting!.attendance = int.parse(event.setResult); + state.keyInfos.value.lockSetting!.attendance = + int.parse(event.setResult); } else if (event.type == 1) { // 1 开锁时是否需联网 state.isOpenLockNeedOnline.value = int.parse(event.setResult); - state.keyInfos.value.lockSetting!.appUnlockOnline = int.parse(event.setResult); + state.keyInfos.value.lockSetting!.appUnlockOnline = + int.parse(event.setResult); } else if (event.type == 2) { // 2 常开模式 state.isOpenPassageMode.value = int.parse(event.setResult); @@ -753,13 +769,22 @@ class LockDetailLogic extends BaseGetXController { }); } - late StreamSubscription>_scanListDiscoveredDeviceSubscription; + late StreamSubscription> + _scanListDiscoveredDeviceSubscription; void _scanListDiscoveredDeviceSubscriptionAction() { - _scanListDiscoveredDeviceSubscription = EventBusManager().eventBus!.on>().listen((List list) { - final knownDeviceIndex = list.indexWhere((d) => d.name == state.keyInfos.value.bluetooth!.bluetoothDeviceName!); + _scanListDiscoveredDeviceSubscription = EventBusManager() + .eventBus! + .on>() + .listen((List list) { + final knownDeviceIndex = list.indexWhere((d) => + d.name == state.keyInfos.value.bluetooth!.bluetoothDeviceName!); if (knownDeviceIndex >= 0) { // 存在的时候赋值 - state.currentDeviceUUid.value = (list[knownDeviceIndex].serviceUuids.isNotEmpty ? list[knownDeviceIndex].serviceUuids[0] : "").toString(); + state.currentDeviceUUid.value = + (list[knownDeviceIndex].serviceUuids.isNotEmpty + ? list[knownDeviceIndex].serviceUuids[0] + : "") + .toString(); } }); } @@ -767,7 +792,7 @@ class LockDetailLogic extends BaseGetXController { //开锁成功弹出的小界面 void _showFullScreenOverlay(BuildContext context) { Future.delayed(const Duration(seconds: 3), () { - if(state.iSClosedUnlockSuccessfulPopup.value != true){ + if (state.iSClosedUnlockSuccessfulPopup.value != true) { state.iSClosedUnlockSuccessfulPopup.value = true; Get.back(); } @@ -779,7 +804,7 @@ class LockDetailLogic extends BaseGetXController { builder: (BuildContext context) { return GestureDetector( onTap: () { - if(state.iSClosedUnlockSuccessfulPopup.value != true){ + if (state.iSClosedUnlockSuccessfulPopup.value != true) { state.iSClosedUnlockSuccessfulPopup.value = true; Get.back(); } 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..b86c5c68 100644 --- a/star_lock/lib/main/lockDetail/lockOperatingRecord/lockOperatingRecord_logic.dart +++ b/star_lock/lib/main/lockDetail/lockOperatingRecord/lockOperatingRecord_logic.dart @@ -1,8 +1,8 @@ - import 'dart:async'; import 'package:flutter_easyloading/flutter_easyloading.dart'; import 'package:flutter_reactive_ble/flutter_reactive_ble.dart'; +import 'package:star_lock/main/lockDetail/electronicKey/electronicKeyDetail/keyOperationRecord/keyOperationRecord_entity.dart'; import '../../../blue/blue_manage.dart'; import '../../../blue/io_protocol/io_referEventRecordTime.dart'; @@ -13,22 +13,22 @@ import '../../../blue/sender_manage.dart'; import '../../../network/api_repository.dart'; import '../../../tools/baseGetXController.dart'; import '../../../tools/storage.dart'; -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/lockOperatingRecord/lockOperatingRecord_page.dart b/star_lock/lib/main/lockDetail/lockOperatingRecord/lockOperatingRecord_page.dart index ded8cae4..bd429acc 100644 --- a/star_lock/lib/main/lockDetail/lockOperatingRecord/lockOperatingRecord_page.dart +++ b/star_lock/lib/main/lockDetail/lockOperatingRecord/lockOperatingRecord_page.dart @@ -1,8 +1,7 @@ - import 'package:flutter/material.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:get/get.dart'; -import 'package:star_lock/main/lockDetail/electronicKey/electronicKeyDetail/keyOperationRecordEntity.dart'; +import 'package:star_lock/main/lockDetail/electronicKey/electronicKeyDetail/keyOperationRecord/keyOperationRecord_entity.dart'; import '../../../app_settings/app_colors.dart'; import '../../../tools/custom_bottom_sheet.dart'; @@ -26,7 +25,6 @@ class _LockOperatingRecordPageState extends State { @override Widget build(BuildContext context) { - return Scaffold( backgroundColor: AppColors.mainBackgroundColor, appBar: TitleAppBar( @@ -34,38 +32,39 @@ class _LockOperatingRecordPageState extends State { haveBack: true, backgroundColor: AppColors.mainColor, actionsList: [ - (state.keyInfos.value.isLockOwner == 1 || state.keyInfos.value.keyRight == 1) - ? IconButton( - icon: Image.asset( - 'images/icon_bar_more.png', - height: 30.h, - width: 10.w, - ), - onPressed: () async { - var isDemoMode = await Storage.getBool(ifIsDemoModeOrNot); - if(isDemoMode == false){ - // JhPopMenus.showLinePop(context, clickCallback: (index, selText) { - // print('选中index: $index'); - // print('选中text: $selText'); - // if (index == 0) { - // logic.mockNetworkDataRequest(); - // } else if (index == 1) { - // logic.clearOperationRecordRequest(); - // } - // }, listData: [ - // {'text': '读取记录'}, - // {'text': '清空记录'}, - // {'text': '导出记录'}, - // ]); + (state.keyInfos.value.isLockOwner == 1 || + state.keyInfos.value.keyRight == 1) + ? IconButton( + icon: Image.asset( + 'images/icon_bar_more.png', + height: 30.h, + width: 10.w, + ), + onPressed: () async { + var isDemoMode = await Storage.getBool(ifIsDemoModeOrNot); + if (isDemoMode == false) { + // JhPopMenus.showLinePop(context, clickCallback: (index, selText) { + // print('选中index: $index'); + // print('选中text: $selText'); + // if (index == 0) { + // logic.mockNetworkDataRequest(); + // } else if (index == 1) { + // logic.clearOperationRecordRequest(); + // } + // }, listData: [ + // {'text': '读取记录'}, + // {'text': '清空记录'}, + // {'text': '导出记录'}, + // ]); - _openModalBottomSheet(); - }else{ - // Get.toNamed(Routers.selectLockTypePage); - logic.showToast("演示模式"); - } - }, - ) - : Container(), + _openModalBottomSheet(); + } else { + // Get.toNamed(Routers.selectLockTypePage); + logic.showToast("演示模式"); + } + }, + ) + : Container(), ], ), body: Column( @@ -79,9 +78,7 @@ class _LockOperatingRecordPageState extends State { ), ), _searchWidget(), - SizedBox( - height: 10.h - ), + SizedBox(height: 10.h), Expanded(child: _buildMainUI()), ], ), @@ -124,24 +121,28 @@ class _LockOperatingRecordPageState extends State { } Widget _buildMainUI() { - return Obx(() => state.lockOperatingRecordListData.value.isNotEmpty ? ListView.separated( - itemCount: state.lockOperatingRecordListData.length, - itemBuilder: (c, index) { - KeyRecordDataItem dataItem = state.lockOperatingRecordListData[index]; - int? operateDate = dataItem.operateDate; - DateTime dateStr = DateTime.fromMillisecondsSinceEpoch(operateDate!); - String operateDateStr = '${dateStr.toLocal().toString().substring(0, 16)} '; - return _operatingRecordItem(getTypeIcon(dataItem.recordType!), dataItem.recordTypeName!, operateDateStr, () { - - }); - }, - separatorBuilder: (BuildContext context, int index) { - return const Divider( - height: 1, - color: AppColors.greyLineColor, - ); - }, - ) : NoData()); + return Obx(() => state.lockOperatingRecordListData.value.isNotEmpty + ? ListView.separated( + itemCount: state.lockOperatingRecordListData.length, + itemBuilder: (c, index) { + KeyRecordDataItem dataItem = + state.lockOperatingRecordListData[index]; + int? operateDate = dataItem.operateDate; + DateTime dateStr = + DateTime.fromMillisecondsSinceEpoch(operateDate!); + String operateDateStr = + '${dateStr.toLocal().toString().substring(0, 16)} '; + return _operatingRecordItem(getTypeIcon(dataItem.recordType!), + dataItem.recordTypeName!, operateDateStr, () {}); + }, + separatorBuilder: (BuildContext context, int index) { + return const Divider( + height: 1, + color: AppColors.greyLineColor, + ); + }, + ) + : NoData()); } Widget _dateItem(String lockDate) { @@ -185,7 +186,8 @@ class _LockOperatingRecordPageState extends State { return title; } - Widget _operatingRecordItem(String userAvatarStr, String userNameStr, String unlockDescStr, Function() action) { + Widget _operatingRecordItem(String userAvatarStr, String userNameStr, + String unlockDescStr, Function() action) { return GestureDetector( onTap: action, child: Container( @@ -261,5 +263,4 @@ class _LockOperatingRecordPageState extends State { ); }); } - } diff --git a/star_lock/lib/main/lockDetail/lockOperatingRecord/lockOperatingRecord_state.dart b/star_lock/lib/main/lockDetail/lockOperatingRecord/lockOperatingRecord_state.dart index ca96ce6e..5942df9f 100644 --- a/star_lock/lib/main/lockDetail/lockOperatingRecord/lockOperatingRecord_state.dart +++ b/star_lock/lib/main/lockDetail/lockOperatingRecord/lockOperatingRecord_state.dart @@ -1,14 +1,12 @@ - import 'package:get/get.dart'; +import 'package:star_lock/main/lockDetail/electronicKey/electronicKeyDetail/keyOperationRecord/keyOperationRecord_entity.dart'; import '../../lockMian/entity/lockListInfo_entity.dart'; -import '../electronicKey/electronicKeyDetail/keyOperationRecordEntity.dart'; -class LockOperatingRecordState{ +class LockOperatingRecordState { final keyInfos = LockListInfoItemEntity().obs; final lockOperatingRecordListData = [].obs; LockOperatingRecordState() { keyInfos.value = Get.arguments["keyInfo"]; } - -} \ No newline at end of file +} diff --git a/star_lock/lib/main/lockDetail/lockSet/basicInformation/editLockName/editLockName_logic.dart b/star_lock/lib/main/lockDetail/lockSet/basicInformation/editLockName/editLockName_logic.dart index 1e5b66a9..4fef0fe5 100644 --- a/star_lock/lib/main/lockDetail/lockSet/basicInformation/editLockName/editLockName_logic.dart +++ b/star_lock/lib/main/lockDetail/lockSet/basicInformation/editLockName/editLockName_logic.dart @@ -1,31 +1,28 @@ - import 'package:get/get.dart'; +import 'package:star_lock/main/lockDetail/electronicKey/electronicKeyDetail/keyOperationRecord/keyOperationRecord_entity.dart'; import '../../../../../network/api_repository.dart'; import '../../../../../tools/baseGetXController.dart'; import '../../../../../tools/eventBusEventManage.dart'; -import '../../../electronicKey/electronicKeyDetail/keyOperationRecordEntity.dart'; import 'editLockName_state.dart'; -class EditLockNameLogic extends BaseGetXController{ +class EditLockNameLogic extends BaseGetXController { final EditLockNameState state = EditLockNameState(); //修改锁名称请求 Future modifyKeyNameRequest() async { KeyOperationRecordEntity entity = await ApiRepository.to.updateLockName( lockId: state.lockSetInfoData.value.lockId.toString(), - lockName:state.changeLockNameController.text); + lockName: state.changeLockNameController.text); if (entity.errorCode!.codeIsSuccessful) { state.lockBasicInfo.value.lockAlias = state.changeLockNameController.text; - showToast("修改成功", something: (){ - eventBus.fire(LockSetChangeSetRefreshLockDetailWithType(3, state.lockBasicInfo.value.lockAlias!)); + showToast("修改成功", something: () { + eventBus.fire(LockSetChangeSetRefreshLockDetailWithType( + 3, state.lockBasicInfo.value.lockAlias!)); eventBus.fire(RefreshLockListInfoDataEvent()); }); - Get.back(result: { - "lockBasicInfo":state.lockBasicInfo.value - }); + Get.back(result: {"lockBasicInfo": state.lockBasicInfo.value}); } } - } diff --git a/star_lock/lib/main/lockDetail/lockSet/basicInformation/uploadElectricQuantity/uploadElectricQuantity_logic.dart b/star_lock/lib/main/lockDetail/lockSet/basicInformation/uploadElectricQuantity/uploadElectricQuantity_logic.dart index 1daedf9c..334be6da 100644 --- a/star_lock/lib/main/lockDetail/lockSet/basicInformation/uploadElectricQuantity/uploadElectricQuantity_logic.dart +++ b/star_lock/lib/main/lockDetail/lockSet/basicInformation/uploadElectricQuantity/uploadElectricQuantity_logic.dart @@ -1,7 +1,7 @@ - import 'dart:async'; import 'package:flutter_reactive_ble/flutter_reactive_ble.dart'; +import 'package:star_lock/main/lockDetail/electronicKey/electronicKeyDetail/keyOperationRecord/keyOperationRecord_entity.dart'; import '../../../../../blue/blue_manage.dart'; import '../../../../../blue/io_protocol/io_getStarLockStatusInfo.dart'; @@ -13,7 +13,6 @@ import '../../../../../network/api_repository.dart'; import '../../../../../tools/baseGetXController.dart'; import '../../../../../tools/eventBusEventManage.dart'; import '../../../../../tools/storage.dart'; -import '../../../electronicKey/electronicKeyDetail/keyOperationRecordEntity.dart'; import 'uploadElectricQuantity_state.dart'; class UploadElectricQuantityLogic extends BaseGetXController { @@ -21,12 +20,15 @@ class UploadElectricQuantityLogic extends BaseGetXController { //电量更新请求 Future uploadElectricQuantityRequest(String electricQuantity) async { - KeyOperationRecordEntity entity = await ApiRepository.to.uploadElectricQuantity(electricQuantity, state.lockSetInfoData.value.lockId.toString()); + KeyOperationRecordEntity entity = await ApiRepository.to + .uploadElectricQuantity( + electricQuantity, state.lockSetInfoData.value.lockId.toString()); if (entity.errorCode!.codeIsSuccessful) { - - showToast("锁电量更新成功", something: (){ - eventBus.fire(PassCurrentLockInformationEvent(state.lockSetInfoData.value)); - eventBus.fire(LockSetChangeSetRefreshLockDetailWithType(0, electricQuantity)); + showToast("锁电量更新成功", something: () { + eventBus + .fire(PassCurrentLockInformationEvent(state.lockSetInfoData.value)); + eventBus.fire( + LockSetChangeSetRefreshLockDetailWithType(0, electricQuantity)); eventBus.fire(RefreshLockListInfoDataEvent()); }); } @@ -34,17 +36,18 @@ class UploadElectricQuantityLogic extends BaseGetXController { // 获取锁状态 Future getStarLockStatus() async { - if(state.sureBtnState.value == 1){ + if (state.sureBtnState.value == 1) { return; } state.sureBtnState.value = 1; showEasyLoading(); - showBlueConnetctToastTimer(action: (){ + showBlueConnetctToastTimer(action: () { dismissEasyLoading(); state.sureBtnState.value = 0; }); - BlueManage().bludSendData(BlueManage().connectDeviceName, (DeviceConnectionState deviceConnectionState) async { + BlueManage().bludSendData(BlueManage().connectDeviceName, + (DeviceConnectionState deviceConnectionState) async { if (deviceConnectionState == DeviceConnectionState.connected) { dismissEasyLoading(); var privateKey = await Storage.getStringList(saveBluePrivateKey); @@ -58,7 +61,7 @@ class UploadElectricQuantityLogic extends BaseGetXController { dismissEasyLoading(); cancelBlueConnetctToastTimer(); state.sureBtnState.value = 0; - if(state.ifCurrentScreen.value == true){ + if (state.ifCurrentScreen.value == true) { showBlueConnetctToast(); } } @@ -68,7 +71,8 @@ class UploadElectricQuantityLogic extends BaseGetXController { // 获取解析后的数据 late StreamSubscription _replySubscription; void _initReplySubscription() { - _replySubscription = EventBusManager().eventBus!.on().listen((reply) { + _replySubscription = + EventBusManager().eventBus!.on().listen((reply) { // 获取锁状态信息 if (reply is GetStarLockStatuInfoReply) { _replyGetStarLockStatusInfo(reply); @@ -81,7 +85,7 @@ class UploadElectricQuantityLogic extends BaseGetXController { int status = reply.data[2]; switch (status) { case 0x00: - //成功 + //成功 print("${reply.commandType}数据解析成功"); state.sureBtnState.value = 0; dismissEasyLoading(); @@ -89,28 +93,31 @@ class UploadElectricQuantityLogic extends BaseGetXController { // 电池剩余电量 var battRemCap = reply.data[132]; - state.lockSetInfoData.value.lockBasicInfo!.electricQuantity = battRemCap; - state.uploadElectricQuantityDate.value = DateTime.now().millisecondsSinceEpoch; - state.lockSetInfoData.value.lockBasicInfo!.electricQuantityDate = DateTime.now().millisecondsSinceEpoch; + state.lockSetInfoData.value.lockBasicInfo!.electricQuantity = + battRemCap; + state.uploadElectricQuantityDate.value = + DateTime.now().millisecondsSinceEpoch; + state.lockSetInfoData.value.lockBasicInfo!.electricQuantityDate = + DateTime.now().millisecondsSinceEpoch; uploadElectricQuantityRequest(battRemCap.toString()); break; case 0x06: - //无权限 + //无权限 print("${reply.commandType}需要鉴权"); break; case 0x07: - //无权限 + //无权限 print("${reply.commandType}用户无权限"); break; case 0x09: - // 权限校验错误 + // 权限校验错误 print("${reply.commandType}权限校验错误"); break; default: - //失败 + //失败 print("${reply.commandType}失败"); break; @@ -139,5 +146,4 @@ class UploadElectricQuantityLogic extends BaseGetXController { super.onClose(); _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 d4d7e625..bf8b25e6 100644 --- a/star_lock/lib/main/lockDetail/lockSet/lockSet/lockSet_page.dart +++ b/star_lock/lib/main/lockDetail/lockSet/lockSet/lockSet_page.dart @@ -177,19 +177,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/main/lockMian/lockMain/lockMain_page.dart b/star_lock/lib/main/lockMian/lockMain/lockMain_page.dart index 91cd56cd..108f7764 100644 --- a/star_lock/lib/main/lockMian/lockMain/lockMain_page.dart +++ b/star_lock/lib/main/lockMian/lockMain/lockMain_page.dart @@ -1,9 +1,13 @@ +import 'dart:io'; + +import 'package:aliyun_push/aliyun_push.dart'; 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/tools/noData.dart'; import 'package:star_lock/tools/submitBtn.dart'; +import 'package:star_lock/tools/xs_aliyunPush.dart'; import '../../../appRouters.dart'; import '../../../baseWidget.dart'; @@ -29,8 +33,8 @@ class _StarLockMainPageState extends State with BaseWidget { final logic = Get.put(LockMainLogic()); final state = Get.find().state; - void getHttpData(){ - logic.getStarLockInfo().then((LockListInfoEntity value){ + void getHttpData() { + logic.getStarLockInfo().then((LockListInfoEntity value) { setState(() {}); }); } @@ -40,6 +44,7 @@ class _StarLockMainPageState extends State with BaseWidget { super.initState(); getHttpData(); + initAliyunPush(); } @override @@ -92,12 +97,11 @@ class _StarLockMainPageState extends State with BaseWidget { // }, // ), body: EasyRefreshTool( - onRefresh: (){ + onRefresh: () { logic.pageNo = 1; getHttpData(); }, - child: Obx(() => getDataReturnUI(state.dataLength.value)) - ), + child: Obx(() => getDataReturnUI(state.dataLength.value))), // body:smartRefresher( // logic.refreshController, // onRefresh:logic.onRefresh, @@ -118,12 +122,16 @@ class _StarLockMainPageState extends State with BaseWidget { case 1: // 只有一条数据 Storage.setBool(ifIsDemoModeOrNot, false); - returnWidget = LockDetailPage(isOnlyOneData: true, lockListInfoItemEntity: state.lockListInfoEntity.value.data!.groupList![0].lockList![0]); + returnWidget = LockDetailPage( + isOnlyOneData: true, + lockListInfoItemEntity: state + .lockListInfoEntity.value.data!.groupList![0].lockList![0]); break; case 2: // 有多条数据 Storage.setBool(ifIsDemoModeOrNot, false); - returnWidget = LockListPage(lockListInfoGroupEntity: state.lockListInfoEntity.value.data!); + returnWidget = LockListPage( + lockListInfoGroupEntity: state.lockListInfoEntity.value.data!); break; default: returnWidget = NoData(); @@ -179,13 +187,13 @@ class _StarLockMainPageState extends State with BaseWidget { Container( // padding: EdgeInsets.all(30.w), child: Text( - TranslationLoader - .lanKeys!.whenAddingLockThePhoneMustBeNextToTheLock!.tr, - style: TextStyle( - fontSize: 26.sp, - // fontWeight: FontWeight.w800, - color: Colors.black), - )), + TranslationLoader + .lanKeys!.whenAddingLockThePhoneMustBeNextToTheLock!.tr, + style: TextStyle( + fontSize: 26.sp, + // fontWeight: FontWeight.w800, + color: Colors.black), + )), SizedBox( height: 160.h, ), @@ -204,4 +212,25 @@ class _StarLockMainPageState extends State with BaseWidget { void onShow() {} void onHide() {} + + //初始化阿里云推送 + void initAliyunPush() { + final aliyunPush = AliyunPush(); + XSAliyunPushProvider().init(aliyunPush); + XSAliyunPushProvider().initAliyunPush(); + + if (Platform.isAndroid) { + XSAliyunPushProvider().initAliyunThirdPush(); + } + + //暂使用DeviceID推送 + aliyunPush.getDeviceId().then((deviceId) async { + // print('得到的DeviceId$deviceId'); + final data = await Storage.getString(saveUserLoginData); + if (data!.isNotEmpty && deviceId.isNotEmpty) { + XSAliyunPushProvider() + .pushBindDeviceID(deviceId, Platform.isAndroid ? 10 : 20); + } + }); + } } 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); } diff --git a/star_lock/lib/mine/mineSet/addAuthorizedAdministrator/addAuthorizedAdministrator_logic.dart b/star_lock/lib/mine/mineSet/addAuthorizedAdministrator/addAuthorizedAdministrator_logic.dart index 2eb818a2..4b6efe85 100644 --- a/star_lock/lib/mine/mineSet/addAuthorizedAdministrator/addAuthorizedAdministrator_logic.dart +++ b/star_lock/lib/mine/mineSet/addAuthorizedAdministrator/addAuthorizedAdministrator_logic.dart @@ -16,9 +16,9 @@ class AddAuthorizedAdministratorLogic extends BaseGetXController { String getEffectiveDateTime = '0'; if (state.tabController!.index == 1) { getFailureDateTime = - state.failureDateTime.value.millisecondsSinceEpoch.toString(); + state.failureDate.value.millisecondsSinceEpoch.toString(); getEffectiveDateTime = - state.effectiveDateTime.value.millisecondsSinceEpoch.toString(); + state.effectiveDate.value.millisecondsSinceEpoch.toString(); } var entity = await ApiRepository.to.addAuthorizedAdmin( state.isCreateUser.value ? "1" : "0", @@ -45,46 +45,46 @@ class AddAuthorizedAdministratorLogic extends BaseGetXController { } } - //发送钥匙请求 - Future sendElectronicKeyRequest(BuildContext widgetContext) async { - String getFailureDateTime = '0'; - String getEffectiveDateTime = '0'; - String lockID = state.keyInfo.value.lockId.toString(); - String getKeyType = (int.parse(state.type.value) + 1).toString(); - if (state.type.value == '0') { - getFailureDateTime = - state.failureDateTime.value.millisecondsSinceEpoch.toString(); - getEffectiveDateTime = - state.effectiveDateTime.value.millisecondsSinceEpoch.toString(); - } + // //发送钥匙请求 + // Future sendElectronicKeyRequest(BuildContext widgetContext) async { + // String lockID = state.keyInfo.value.lockId.toString(); + // String getKeyType = (int.parse(state.type.value) + 1).toString(); + // if (state.type.value == '0') { + // // getFailureDateTime = + // // state.failureDateTime.value.millisecondsSinceEpoch.toString(); + // // getEffectiveDateTime = + // // state.effectiveDateTime.value.millisecondsSinceEpoch.toString(); + // } - var entity = await ApiRepository.to.sendElectronicKey( - createUser: state.isCreateUser.value ? "1" : "0", - countryCode: state.countryCode.value, - usernameType: '1', - endDate: getFailureDateTime, - faceAuthentication: state.isAuthentication.value == true ? '1' : '2', - isCameraEnable: '2', - isRemoteUnlock: state.isRemoteUnlock.value == true ? '1' : '2', - keyNameForAdmin: state.keyNameController.text, - keyRight: '0', - keyType: getKeyType, - lockId: lockID, - operatorUid: '', - receiverUsername: state.emailOrPhoneController.text, - remarks: '', - startDate: getEffectiveDateTime, - weekDays: state.weekdaysList); - if (entity.errorCode!.codeIsSuccessful) { - print('发送电子钥匙成功'); - state.isSendSuccess.value = true; - } else { - if (entity.errorCode == 425) { - //用户未注册 - _showDialog(widgetContext, '${entity.errorMsg}'); - } - } - } + // var entity = await ApiRepository.to.sendElectronicKey( + // createUser: state.isCreateUser.value ? "1" : "0", + // countryCode: state.countryCode.value, + // usernameType: '1', + // endDate: state.failureDateTime.value.millisecondsSinceEpoch, + // faceAuthentication: state.isAuthentication.value == true ? '1' : '2', + // isCameraEnable: '2', + // isRemoteUnlock: state.isRemoteUnlock.value == true ? '1' : '2', + // keyNameForAdmin: state.keyNameController.text, + // keyRight: '0', + // keyType: getKeyType, + // lockId: lockID, + // operatorUid: '', + // receiverUsername: state.emailOrPhoneController.text, + // remarks: '', + // startDate: state.effectiveDateTime.value.millisecondsSinceEpoch, + // weekDays: state.weekdaysList, + // startTime: state.st.value, + // endTime: state.endTime.value); + // if (entity.errorCode!.codeIsSuccessful) { + // print('发送电子钥匙成功'); + // state.isSendSuccess.value = true; + // } else { + // if (entity.errorCode == 425) { + // //用户未注册 + // _showDialog(widgetContext, '${entity.errorMsg}'); + // } + // } + // } //用户未注册确认弹窗 void _showDialog(widgetContext, String errMsg) { diff --git a/star_lock/lib/mine/mineSet/addAuthorizedAdministrator/addAuthorizedAdministrator_page.dart b/star_lock/lib/mine/mineSet/addAuthorizedAdministrator/addAuthorizedAdministrator_page.dart index 3ed8f486..3ecfe6f9 100644 --- a/star_lock/lib/mine/mineSet/addAuthorizedAdministrator/addAuthorizedAdministrator_page.dart +++ b/star_lock/lib/mine/mineSet/addAuthorizedAdministrator/addAuthorizedAdministrator_page.dart @@ -3,12 +3,10 @@ import 'package:flutter/material.dart'; import 'package:flutter_native_contact_picker/flutter_native_contact_picker.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:get/get.dart'; -import 'package:get/get_utils/get_utils.dart'; import 'package:star_lock/appRouters.dart'; import 'package:star_lock/app_settings/app_colors.dart'; -import 'package:star_lock/network/api_repository.dart'; -import 'package:star_lock/tools/baseGetXController.dart'; import 'package:star_lock/tools/commonItem.dart'; +import 'package:star_lock/tools/dateUtils.dart'; import 'package:star_lock/tools/pickers/pickers.dart'; import 'package:star_lock/tools/pickers/time_picker/model/date_mode.dart'; import 'package:star_lock/tools/submitBtn.dart'; @@ -25,28 +23,13 @@ class AddAuthorizedAdministratorPage extends StatefulWidget { } } -class _AddAuthorizedAdministratorPageState extends State with SingleTickerProviderStateMixin { +class _AddAuthorizedAdministratorPageState + extends State + with SingleTickerProviderStateMixin { final logic = Get.put(AddAuthorizedAdministratorLogic()); final state = Get.find().state; TabController? _tabController; - final FlutterContactPicker _contactPicker = FlutterContactPicker(); - late Contact _contact; - final _templateNameTf = TextEditingController(); - late List _lockIdList; - late bool _isRemoteUnlock; - late bool _isCreateUser; - var _selectEffectiveDate = ''; //生效时间 - var _selectFailureDate = ''; //失效时间 - late DateTime _effectiveDateTime; - late DateTime _failureDateTime; - final TextEditingController _emailOrPhoneController = - TextEditingController(); //邮箱/手机号输入框 - final TextEditingController _keyNameController = - TextEditingController(); //钥匙名输入框 - String countryName = '中国'; - String countryCode = '86'; - late bool _isSendSuccess; List tabs = [ TranslationLoader.lanKeys!.permanent!.tr, @@ -57,10 +40,6 @@ class _AddAuthorizedAdministratorPageState extends State; - _lockIdList = value['selectLockIdList']; + state.lockIdList.value = value['selectLockIdList']; setState(() {}); } @@ -164,7 +143,7 @@ class _AddAuthorizedAdministratorPageState extends State; - _lockIdList = value['selectLockIdList']; + state.lockIdList.value = value['selectLockIdList']; setState(() {}); } @@ -211,41 +190,6 @@ class _AddAuthorizedAdministratorPageState extends State addAuthorizedAdminRequest() async { - String getFailureDateTime = '0'; - String getEffectiveDateTime = '0'; - if (_tabController!.index == 1) { - getFailureDateTime = _failureDateTime.millisecondsSinceEpoch.toString(); - getEffectiveDateTime = - _effectiveDateTime.millisecondsSinceEpoch.toString(); - } - var entity = await ApiRepository.to.addAuthorizedAdmin( - _isCreateUser ? "1" : "0", - getFailureDateTime, - _isRemoteUnlock == true ? '1' : '2', - [], - _lockIdList, - _keyNameController.text, - getEffectiveDateTime, - _emailOrPhoneController.text, - countryCode, - '1', - ); - if (entity.errorCode!.codeIsSuccessful) { - print('发送电子钥匙成功'); - _isSendSuccess = true; - setState(() {}); - } else { - logic.showToast("${entity.errorMsg}"); - if (entity.errorCode == 425) { - //用户未注册 - _isCreateUser = true; - addAuthorizedAdminRequest(); - } - } - } - // 顶部钥匙信息widget Widget keyInfoWidget() { return Column( @@ -259,7 +203,7 @@ class _AddAuthorizedAdministratorPageState extends State; - countryCode = result['code']; - countryName = result['countryName']; + state.countryCode.value = result['code']; + state.countryName.value = result['countryName']; setState(() {}); } }, @@ -290,7 +234,7 @@ class _AddAuthorizedAdministratorPageState extends State _switch())), action: () {}), Container(height: 40.h), ], @@ -377,30 +322,34 @@ class _AddAuthorizedAdministratorPageState extends State { itemData.keyId.toString(), itemData.lockId.toString(), _failureDateTime.millisecondsSinceEpoch.toString(), - '', - '', _effectiveDateTime.millisecondsSinceEpoch.toString(), - '', []); + [], + itemData.keyType!); if (entity.errorCode!.codeIsSuccessful) { print("修改要是名称成功啦啦啦啦啦"); - EasyLoading.showToast('修改成功',duration: 2000.milliseconds); + EasyLoading.showToast('修改成功', duration: 2000.milliseconds); setState(() { Navigator.pop(context); }); diff --git a/star_lock/lib/network/api_provider.dart b/star_lock/lib/network/api_provider.dart index d82f63db..f3fd785c 100644 --- a/star_lock/lib/network/api_provider.dart +++ b/star_lock/lib/network/api_provider.dart @@ -17,20 +17,22 @@ class ApiProvider extends BaseProvider { })); Future register( - int receiverType, - int countryCode, - String account, - String password, - String verificationCode, - ) => - post(registerUrl.toUrl, jsonEncode({ - 'receiverType': receiverType, - 'countryCode': countryCode, - "account": account, - 'password': password, - 'verificationCode': verificationCode, - 'platId': "2", - })); + int receiverType, + int countryCode, + String account, + String password, + String verificationCode, + ) => + post( + registerUrl.toUrl, + jsonEncode({ + 'receiverType': receiverType, + 'countryCode': countryCode, + "account": account, + 'password': password, + 'verificationCode': verificationCode, + 'platId': "2", + })); // post( // registerUrl.toUrl, @@ -97,16 +99,16 @@ class ApiProvider extends BaseProvider { post(getCountryRegionURL.toUrl, jsonEncode({'type': type})); Future electronicKeyList( - String endDate, - String keyId, - String keyStatus, - String keyRight, - String lockId, - String pageNo, - String pageSize, - String startDate, - String searchStr, - ) => + String endDate, + String keyId, + String keyStatus, + String keyRight, + String lockId, + String pageNo, + String pageSize, + String startDate, + String searchStr, + ) => post( electronicKeyListURL.toUrl, jsonEncode({ @@ -125,7 +127,7 @@ class ApiProvider extends BaseProvider { String createUser, String countryCode, String usernameType, - String endDate, + int endDate, String faceAuthentication, String isCameraEnable, String isRemoteUnlock, @@ -136,8 +138,10 @@ class ApiProvider extends BaseProvider { String operatorUid, String receiverUsername, String remarks, - String startDate, - List weekDays) => + int startDate, + List weekDays, + int startTime, + int endTime) => post( sendElectronicKeyURL.toUrl, jsonEncode({ @@ -156,7 +160,9 @@ class ApiProvider extends BaseProvider { 'receiverUsername': receiverUsername, 'remarks': remarks, 'startDate': startDate, - 'weekDays': weekDays + 'weekDays': weekDays, + 'startTime': startTime, + 'endTime': endTime })); Future uploadElectricQuantity( @@ -196,26 +202,17 @@ class ApiProvider extends BaseProvider { 'operatorUid': operatorUid, })); - Future updateKeyDate( - String keyId, - String lockId, - String endDate, - String endDay, - String operatorUid, - String startDate, - String startDay, - List weekDays) => + Future updateKeyDate(String keyId, String lockId, String endDate, + String startDate, List weekDays, int keyType) => post( updateKeyDateURL.toUrl, jsonEncode({ 'keyId': keyId, 'lockId': lockId, 'endDate': endDate, - 'endDay': endDay, - 'operatorUid': operatorUid, 'startDate': startDate, - 'startDay': startDay, 'weekDays': weekDays, + 'keyType': keyType })); Future resetElectronicKey(String lockId, String operatorUid) => diff --git a/star_lock/lib/network/api_repository.dart b/star_lock/lib/network/api_repository.dart index 4be41a1e..9ad01031 100644 --- a/star_lock/lib/network/api_repository.dart +++ b/star_lock/lib/network/api_repository.dart @@ -1,6 +1,7 @@ import 'package:get/get.dart'; import 'package:star_lock/login/selectCountryRegion/common/countryRegionEntity.dart'; -import 'package:star_lock/main/lockDetail/electronicKey/electronicKeyDetail/keyOperationRecordEntity.dart'; +import 'package:star_lock/main/lockDetail/doorLockLog/doorLockLog_entity.dart'; +import 'package:star_lock/main/lockDetail/electronicKey/electronicKeyDetail/keyOperationRecord/keyOperationRecord_entity.dart'; import 'package:star_lock/main/lockDetail/electronicKey/electronicKeyList/entity/ElectronicKeyListEntity.dart'; import 'package:star_lock/main/lockDetail/electronicKey/massSendElectronicKey/massSendLockGroupList/lockUserList/lockUserListEntity.dart'; import 'package:star_lock/main/lockDetail/electronicKey/massSendElectronicKey/massSendLockGroupList/massSendLockGroupListEntity.dart'; @@ -143,7 +144,7 @@ class ApiRepository { {required String createUser, required String countryCode, required String usernameType, - required String endDate, + required int endDate, required String faceAuthentication, required String isCameraEnable, required String isRemoteUnlock, @@ -154,8 +155,10 @@ class ApiRepository { required String operatorUid, required String receiverUsername, required String remarks, - required String startDate, - required List weekDays}) async { + required int startDate, + required List weekDays, + required int startTime, + required int endTime}) async { final res = await apiProvider.sendElectronicKey( createUser, countryCode, @@ -172,7 +175,9 @@ class ApiRepository { receiverUsername, remarks, startDate, - weekDays); + weekDays, + startTime, + endTime); return AuthorizedAdminSendEntity.fromJson(res.body); } @@ -218,7 +223,7 @@ class ApiRepository { } //门锁事件日志 - Future lockEventList({ + Future lockEventList({ required int lockId, required int lockEventType, required int pageNo, @@ -234,7 +239,7 @@ class ApiRepository { startDate, endDate, ); - return KeyOperationRecordEntity.fromJson(res.body); + return DoorLockLogEntity.fromJson(res.body); } //操作记录上传 @@ -324,17 +329,10 @@ class ApiRepository { } //编辑电子钥匙有效期 - Future updateKeyDate( - String keyId, - String lockId, - String endDate, - String endDay, - String operatorUid, - String startDate, - String startDay, - List weekDays) async { - final res = await apiProvider.updateKeyDate(keyId, lockId, endDate, endDay, - operatorUid, startDate, startDay, weekDays); + Future updateKeyDate(String keyId, String lockId, + String endDate, String startDate, List weekDays, int keyType) async { + final res = await apiProvider.updateKeyDate( + keyId, lockId, endDate, startDate, weekDays, keyType); return KeyOperationRecordEntity.fromJson(res.body); } diff --git a/star_lock/lib/tools/dateUtils.dart b/star_lock/lib/tools/dateUtils.dart new file mode 100644 index 00000000..71635ffb --- /dev/null +++ b/star_lock/lib/tools/dateUtils.dart @@ -0,0 +1,28 @@ +import 'package:intl/intl.dart'; + +class XSDateUtils { + // 将DateTime对象格式化为指定格式的字符串 + static String formatDateTime(DateTime dateTime, String format) { + DateFormat dateFormat = DateFormat(format); + return dateFormat.format(dateTime); + } + + // 将指定格式的日期时间字符串解析为DateTime对象 + static DateTime parseDateTime(String dateString, String format) { + DateFormat dateFormat = DateFormat(format); + return dateFormat.parse(dateString); + } +} + +// 使用示例 +// void main() { +// // 格式化日期时间 +// DateTime now = DateTime.now(); +// String formattedDateTime = DateUtils.formatDateTime(now, 'HH:mm'); +// print('Formatted DateTime: $formattedDateTime'); + +// // 解析日期时间字符串 +// String dateString = '08:30'; +// DateTime parsedDateTime = DateUtils.parseDateTime(dateString, 'HH:mm'); +// print('Parsed DateTime: $parsedDateTime'); +// } diff --git a/star_lock/lib/tools/menuItem/xsDropDownWidget.dart b/star_lock/lib/tools/menuItem/xsDropDownWidget.dart index 25ea1eb4..5fcc61d2 100644 --- a/star_lock/lib/tools/menuItem/xsDropDownWidget.dart +++ b/star_lock/lib/tools/menuItem/xsDropDownWidget.dart @@ -127,6 +127,7 @@ class _XSDropDownWidgetState extends State { child: Text( item.itemTitle, style: TextStyle( + fontSize: 24.sp, color: item.itemValue == currentValue ? Colors.white : Colors.black, // 设置选中项文字颜色为白色