diff --git a/star_lock/lib/app.dart b/star_lock/lib/app.dart index 8528b05f..8083d5be 100644 --- a/star_lock/lib/app.dart +++ b/star_lock/lib/app.dart @@ -17,6 +17,8 @@ import 'baseWidget.dart'; import 'tools/appRouteObserver.dart'; import 'dart:io'; +import 'tools/store_service.dart'; + class MyApp extends StatefulWidget { const MyApp({GlobalKey? key}) : super(key: key); @@ -47,8 +49,7 @@ class _MyAppState extends State with WidgetsBindingObserver, BaseWidget { ], localeResolutionCallback: (locale, supportedLocales) { if (!supportedLocales.contains(locale)) { - int idx = appSupportedLocales.indexWhere( - (element) => element.languageCode == locale!.languageCode); + int idx = appSupportedLocales.indexWhere((element) => element.languageCode == locale!.languageCode); if (idx != -1) { locale = appSupportedLocales[idx]; } else { @@ -56,12 +57,11 @@ class _MyAppState extends State with WidgetsBindingObserver, BaseWidget { } } // print("localelocalelocalelocalelocale locale:${locale} locale.languageCode:${locale.languageCode} locale.countryCode:${locale.countryCode} supportedLocales:${supportedLocales}"); - AppManager() - .setLanCode(code: '${locale!.languageCode}_${locale.countryCode}'); + AppManager().setLanCode(code: '${locale!.languageCode}_${locale.countryCode}'); return locale; }, - // locale: StoreService.to.getLanguageCode().isNotEmpty ? appDept.deptSupportedLocales.where((element) => element.languageCode == StoreService.to.getLanguageCode()).first : Get.deviceLocale, - locale: Get.deviceLocale, + locale: StoreService.to.getLanguageCode()!.isNotEmpty ? appDept.deptSupportedLocales.where((element) => element.languageCode == StoreService.to.getLanguageCode()).first : Get.deviceLocale, + // locale: Get.deviceLocale, fallbackLocale: const Locale('zh', 'CN'), theme: ThemeData( scaffoldBackgroundColor: const Color(0xFFF6F6F6), diff --git a/star_lock/lib/appRouters.dart b/star_lock/lib/appRouters.dart index d05dba91..8165b4e2 100644 --- a/star_lock/lib/appRouters.dart +++ b/star_lock/lib/appRouters.dart @@ -30,7 +30,7 @@ import 'package:star_lock/mine/minePersonInfo/minePersonInfoViewSafetyProblem/mi import 'package:star_lock/mine/mineSet/authorizedAdministrator/administratorDetails/adminDetailChangeDate_page.dart'; import 'package:star_lock/mine/mineSet/authorizedAdministrator/administratorDetails/administratorDetails_page.dart'; import 'package:star_lock/mine/mineSet/lockGroup/lockGroupList/lockGroupList_page.dart'; -import 'package:star_lock/mine/mineSet/lockUserManage/expireLockList/expireLockList_page.dart'; +import 'package:star_lock/mine/mineSet/lockUserManage/expireLockList/expireLockManage_page.dart'; import 'package:star_lock/mine/mineSet/mineSet/mineSet_page.dart'; import 'package:star_lock/mine/mineSet/transferGateway/selectGetewayList_page.dart'; import 'package:star_lock/mine/mineSet/transferSmartLock/recipientInformation/recipientInformation_page.dart'; @@ -368,12 +368,10 @@ abstract class Routers { static const massSendReceiverPage = '/massSendReceiverPage'; //群发接收人 static const lockUserListPage = '/lockUserListPage'; //锁用户列表 static const administratorDetailsPage = '/administratorDetailsPage'; //管理员详情 - static const expireLockListPage = '/expireLockListPage'; //即将到期 + static const expireLockManagePage = '/expireLockManagePage'; //即将到期 static const adminDetailChangeDatePage = '/adminDetailChangeDatePage'; //管理员详情修改生效时间 static const adminLockListPage = '/adminLockListPage'; //管理员详情的锁列表 - static const expireLockChangeDatePage = - '/expireLockChangeDatePage'; //即将到期列表有效期修改 static const safeVerifyPage = '/safeVerifyPage'; //删除账号安全验证 static const webviewShowPage = '/webviewShowPage'; //网页 static const demoModeLockDetailPage = '/DemoModeLockDetailPage'; // 演示模式锁详情页 @@ -906,8 +904,8 @@ abstract class AppRouters { name: Routers.administratorDetailsPage, page: () => const AdministratorDetailsPage()), GetPage( - name: Routers.expireLockListPage, - page: () => const ExpireLockListPage()), + name: Routers.expireLockManagePage, + page: () => const ExpireLockManagePage()), GetPage( name: Routers.otherTypeKeyChangeDatePage, page: () => const OtherTypeKeyChangeDatePage()), diff --git a/star_lock/lib/blue/io_protocol/io_getWifiList.dart b/star_lock/lib/blue/io_protocol/io_getWifiList.dart index 4d8d8528..17cbbc3b 100644 --- a/star_lock/lib/blue/io_protocol/io_getWifiList.dart +++ b/star_lock/lib/blue/io_protocol/io_getWifiList.dart @@ -99,6 +99,13 @@ class SenderGetWifiCommand extends SenderProtocol { } } +class SenderGetWifiReply extends Reply { + SenderGetWifiReply.parseData(CommandType commandType, List dataDetail) + : super.parseData(commandType, dataDetail) { + data = dataDetail; + } +} + class SenderGetWifiListReply extends Reply { SenderGetWifiListReply.parseData(CommandType commandType, List dataDetail) : super.parseData(commandType, dataDetail) { diff --git a/star_lock/lib/blue/reciver_data.dart b/star_lock/lib/blue/reciver_data.dart index ed3ba91b..508828c9 100644 --- a/star_lock/lib/blue/reciver_data.dart +++ b/star_lock/lib/blue/reciver_data.dart @@ -111,7 +111,7 @@ class CommandReciverManager { break; } parseData(oriDataList).then((value) async { - // Get.log("parseData222 data:$value"); + Get.log("parseData222 data:$value"); EasyLoading.dismiss(); await EventBusManager().eventBusFir(value); }).catchError((error) { @@ -293,6 +293,13 @@ class CommandReciverManager { SenderConfiguringWifiReply.parseData(commandType, data); } break; + case 53: + { + // 获取wifilist + reply = + SenderGetWifiReply.parseData(commandType, data); + } + break; case 54: { // 门锁搜索2.4G WIFI SSID 结果 diff --git a/star_lock/lib/main/lockDetail/card/otherTypeKeyChangeDate/otherTypeKeyChangeDate_state.dart b/star_lock/lib/main/lockDetail/card/otherTypeKeyChangeDate/otherTypeKeyChangeDate_state.dart index 36d38545..38c6e8c6 100644 --- a/star_lock/lib/main/lockDetail/card/otherTypeKeyChangeDate/otherTypeKeyChangeDate_state.dart +++ b/star_lock/lib/main/lockDetail/card/otherTypeKeyChangeDate/otherTypeKeyChangeDate_state.dart @@ -17,6 +17,10 @@ class OtherTypeKeyChangeDateState{ pushType.value = map["pushType"]; } + if(map["fingerprintItemData"] != null){ + fingerprintItemData.value = map["fingerprintItemData"]; + } + if(fingerprintItemData.value.startDate == 0 && fingerprintItemData.value.endDate == 0){ // getStartDate = "${formatDate(DateTime.now(), [yyyy,'-',mm,'-', dd, ' ', HH,])}:00"; //生效时间 // // state.selectEffectiveDate.value = getStartDate; 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 bd2914ed..695f7ea1 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 @@ -56,11 +56,11 @@ class ElectronicKeyDetailLogic extends BaseGetXController { } } - //删除电子钥匙名称请求 setAdministrator + //删除电子钥匙名称请求 Future deleteKeyRequest(int includeUnderlings) async { ElectronicKeyListEntity entity = await ApiRepository.to.deleteElectronicKey( keyId:state.itemData.value.keyId.toString(), - includeUnderlings: 0 + includeUnderlings: includeUnderlings ); if (entity.errorCode!.codeIsSuccessful) { print("删除电子钥匙成功"); 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 9b6e67b2..d6d1e6c8 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 @@ -1,7 +1,7 @@ import 'package:get/get.dart'; import 'package:star_lock/main/lockDetail/electronicKey/electronicKeyList/entity/ElectronicKeyListEntity.dart'; -import 'package:star_lock/mine/mineSet/lockUserManage/expireLockList/expireLockList_entity.dart'; +import 'package:star_lock/mine/mineSet/lockUserManage/expireLockList/expireElectronicKey/expireLockList_entity.dart'; import '../../../../../tools/dateTool.dart'; diff --git a/star_lock/lib/main/lockDetail/electronicKey/electronicKeyDetail/electronicKeyPeriodValidity/electronicKeyPeriodValidity_state.dart b/star_lock/lib/main/lockDetail/electronicKey/electronicKeyDetail/electronicKeyPeriodValidity/electronicKeyPeriodValidity_state.dart index 17453795..115fa619 100644 --- a/star_lock/lib/main/lockDetail/electronicKey/electronicKeyDetail/electronicKeyPeriodValidity/electronicKeyPeriodValidity_state.dart +++ b/star_lock/lib/main/lockDetail/electronicKey/electronicKeyDetail/electronicKeyPeriodValidity/electronicKeyPeriodValidity_state.dart @@ -1,7 +1,7 @@ import 'package:flutter/material.dart'; import 'package:get/get.dart'; import 'package:star_lock/main/lockDetail/electronicKey/electronicKeyList/entity/ElectronicKeyListEntity.dart'; -import 'package:star_lock/mine/mineSet/lockUserManage/expireLockList/expireLockList_entity.dart'; +import 'package:star_lock/mine/mineSet/lockUserManage/expireLockList/expireElectronicKey/expireLockList_entity.dart'; import '../../../../../tools/dateTool.dart'; diff --git a/star_lock/lib/main/lockDetail/lockDetail/lockDetail_logic.dart b/star_lock/lib/main/lockDetail/lockDetail/lockDetail_logic.dart index f04bcb3a..cbd7a8e6 100644 --- a/star_lock/lib/main/lockDetail/lockDetail/lockDetail_logic.dart +++ b/star_lock/lib/main/lockDetail/lockDetail/lockDetail_logic.dart @@ -455,6 +455,8 @@ class LockDetailLogic extends BaseGetXController { // signKey: signKeyDataList, // privateKey: getPrivateKeyList, // ); + + Get.log("openMode:$openMode"); BlueManage() .bludSendData(state.keyInfos.value.bluetooth!.bluetoothDeviceName!, (BluetoothConnectionState deviceConnectionState) async { diff --git a/star_lock/lib/main/lockDetail/lockSet/configuringWifi/wifiList/wifiList_logic.dart b/star_lock/lib/main/lockDetail/lockSet/configuringWifi/wifiList/wifiList_logic.dart index f80dacc2..9d22164d 100644 --- a/star_lock/lib/main/lockDetail/lockSet/configuringWifi/wifiList/wifiList_logic.dart +++ b/star_lock/lib/main/lockDetail/lockSet/configuringWifi/wifiList/wifiList_logic.dart @@ -22,12 +22,52 @@ class WifiListLogic extends BaseGetXController { late StreamSubscription _replySubscription; void _initReplySubscription() { _replySubscription = EventBusManager().eventBus!.on().listen((reply) { + if(reply is SenderGetWifiReply) { + _replySendGetWifiParameters(reply); + } + if(reply is SenderGetWifiListReply) { _replyGetWifiListParameters(reply); } }); } + // 发送获取wifi列表数据解析 + Future _replySendGetWifiParameters(Reply reply) async { + int status = reply.data[2]; + switch(status){ + case 0x00: + //成功 + print("${reply.commandType}数据解析成功"); + showEasyLoading(); + cancelBlueConnetctToastTimer(); + Future.delayed(5.seconds, (){ + dismissEasyLoading(); + }); + break; + case 0x06: + //无权限 + print("${reply.commandType}需要鉴权"); + + break; + case 0x07: + //无权限 + print("${reply.commandType}用户无权限"); + + break; + case 0x09: + // 权限校验错误 + print("${reply.commandType}权限校验错误"); + + break; + default: + //失败 + print("${reply.commandType}失败"); + + break; + } + } + // 设置自动落锁数据解析 Future _replyGetWifiListParameters(Reply reply) async { int status = reply.data[2]; @@ -36,11 +76,8 @@ class WifiListLogic extends BaseGetXController { //成功 print("${reply.commandType}数据解析成功"); // showEasyLoading(); - Future.delayed(4.seconds, (){ - dismissEasyLoading(); - }); + dismissEasyLoading(); state.sureBtnState.value = 0; - cancelBlueConnetctToastTimer(); if (reply.data[6] > 0) { reply.data.removeRange(0, 7); diff --git a/star_lock/lib/main/lockDetail/remoteControl/addRemoteControl/addRemoteControl_page.dart b/star_lock/lib/main/lockDetail/remoteControl/addRemoteControl/addRemoteControl_page.dart index 687ceb39..bd02330e 100644 --- a/star_lock/lib/main/lockDetail/remoteControl/addRemoteControl/addRemoteControl_page.dart +++ b/star_lock/lib/main/lockDetail/remoteControl/addRemoteControl/addRemoteControl_page.dart @@ -9,6 +9,7 @@ import 'package:star_lock/tools/pickers/time_picker/model/date_mode.dart'; import '../../../../appRouters.dart'; import '../../../../app_settings/app_colors.dart'; import '../../../../tools/commonItem.dart'; +import '../../../../tools/dateTool.dart'; import '../../../../tools/storage.dart'; import '../../../../tools/submitBtn.dart'; import '../../../../translations/trans_lib.dart'; @@ -78,15 +79,22 @@ class _AddRemoteControlPageState extends State { rightTitle: "", isHaveDirection: true, action: () async { - Map result = await Get.toNamed( - Routers.electronicKeyPeriodValidityPage); - state.weekdaysList.value = result['validityValue']; - state.effectiveDateTime.value = - result['starDate'].millisecondsSinceEpoch; - state.failureDateTime.value = - result['endDate'].millisecondsSinceEpoch; - print( - '得到的有效期数据:${state.weekdaysList.value} == ${state.effectiveDateTime.value} == ${state.failureDateTime.value}'); + var result = await Get.toNamed(Routers.seletKeyCyclicDatePage, + arguments: { + 'validityValue': state.weekdaysList.value, + 'starDate': state.beginTime.value, + 'endDate': state.endTime.value, + 'starTime': state.effectiveDateTime.value, + 'endTime': state.failureDateTime.value + }); + if(result != null && result.isNotEmpty){ + state.weekdaysList.value = result['validityValue']; + state.beginTime.value = result['starDate']; + state.endTime.value = result['endDate']; + state.effectiveDateTime.value = result['starTime']; + state.failureDateTime.value = result['endTime']; + Get.log('得到的有效期数据:${state.weekdaysList.value} == ${state.beginTime.value} == ${state.endTime.value}== ${state.effectiveDateTime.value} == ${state.failureDateTime.value}'); + } }), SizedBox(height: 10.h), keyBottomWidget() @@ -103,7 +111,6 @@ class _AddRemoteControlPageState extends State { String titleStr, String rightTitle, TextEditingController controller) { return Column( children: [ - Container(height: 10.h), CommonItem( leftTitel: titleStr, rightTitle: "", @@ -126,16 +133,7 @@ class _AddRemoteControlPageState extends State { action: () async { Pickers.showDatePicker(context, mode: DateMode.YMDHM, onConfirm: (p) { - setState(() { - setState(() { - 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 - .toString(); - }); - }); + state.beginTime.value = DateTool().getYMDHNDateString(p, 1); }); })), Obx(() => CommonItem( @@ -143,18 +141,8 @@ class _AddRemoteControlPageState extends State { rightTitle: state.endTime.value, isHaveDirection: true, action: () { - Pickers.showDatePicker(context, mode: DateMode.YMDHM, - onConfirm: (p) { - setState(() { - setState(() { - 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 - .toString(); - }); - }); + Pickers.showDatePicker(context, mode: DateMode.YMDHM, onConfirm: (p) { + state.endTime.value = DateTool().getYMDHNDateString(p, 1); }); })), Container(height: 10.h), diff --git a/star_lock/lib/main/lockDetail/remoteControl/addRemoteControl/addRemoteControl_state.dart b/star_lock/lib/main/lockDetail/remoteControl/addRemoteControl/addRemoteControl_state.dart index 58817080..433df90a 100644 --- a/star_lock/lib/main/lockDetail/remoteControl/addRemoteControl/addRemoteControl_state.dart +++ b/star_lock/lib/main/lockDetail/remoteControl/addRemoteControl/addRemoteControl_state.dart @@ -6,11 +6,8 @@ class AddRemoteControlState{ var beginTime = "".obs;// 开始时间 var endTime = "".obs;// 结束时间 - var beginTimeTimestamp = "".obs;// 开始时间时间戳 - var endTimeTimestamp = "".obs;// 结束时间时间戳 - - var effectiveDateTime = 0.obs;// 生效时间 - var failureDateTime = 0.obs;// 失效时间 + var effectiveDateTime = "".obs;// 生效时间 + var failureDateTime = "".obs;// 失效时间 var weekdaysList = [].obs; final TextEditingController nameController = TextEditingController(); diff --git a/star_lock/lib/mine/mineMultiLanguage/mineMultiLanguage_page.dart b/star_lock/lib/mine/mineMultiLanguage/mineMultiLanguage_page.dart index 5a2a3ee6..623bcdc2 100644 --- a/star_lock/lib/mine/mineMultiLanguage/mineMultiLanguage_page.dart +++ b/star_lock/lib/mine/mineMultiLanguage/mineMultiLanguage_page.dart @@ -39,18 +39,18 @@ class _MineMultiLanguagePageState extends State { List _children() { List l = []; - l.add( - CommonItem( - leftTitel: '跟随系统', - rightTitle: "", - isHaveLine: true, - isHaveDirection: false, - isHaveRightWidget: true, - rightWidget: Container(), - action: () { - // logic.changeLanguage(e); - }), - ); + // l.add( + // CommonItem( + // leftTitel: '跟随系统', + // rightTitle: "", + // isHaveLine: true, + // isHaveDirection: false, + // isHaveRightWidget: true, + // rightWidget: Container(), + // action: () { + // // logic.changeLanguage(e); + // }), + // ); for (int i = 0; i < state.languages.length; i++) { var e = state.languages[i]; var lanType = ExtensionLanguageType.fromLanguageCode(e.languageCode); diff --git a/star_lock/lib/mine/mineMultiLanguage/mineMultiLanguage_state.dart b/star_lock/lib/mine/mineMultiLanguage/mineMultiLanguage_state.dart index 556c67ab..c638d6c3 100644 --- a/star_lock/lib/mine/mineMultiLanguage/mineMultiLanguage_state.dart +++ b/star_lock/lib/mine/mineMultiLanguage/mineMultiLanguage_state.dart @@ -20,6 +20,6 @@ class MineMultiLanguageState { void resetLan() { currentLanguageType.value = ExtensionLanguageType.fromLanguageCode(Get.locale!.languageCode); print("currentLanguageType.value:${currentLanguageType.value}"); - // StoreService.to.saveLanguageCode(Get.locale!.languageCode); + StoreService.to.saveLanguageCode(Get.locale!.languageCode); } } \ No newline at end of file diff --git a/star_lock/lib/mine/mineSet/appUnlockNeedMobileNetworkingLock/appUnlockNeedMobileNetworkingLock_page.dart b/star_lock/lib/mine/mineSet/appUnlockNeedMobileNetworkingLock/appUnlockNeedMobileNetworkingLock_page.dart index 0430c9e9..0be3ae30 100644 --- a/star_lock/lib/mine/mineSet/appUnlockNeedMobileNetworkingLock/appUnlockNeedMobileNetworkingLock_page.dart +++ b/star_lock/lib/mine/mineSet/appUnlockNeedMobileNetworkingLock/appUnlockNeedMobileNetworkingLock_page.dart @@ -5,6 +5,7 @@ import 'package:star_lock/mine/mineSet/appUnlockNeedMobileNetworkingLock/selectL import '../../../app_settings/app_colors.dart'; import '../../../tools/commonItem.dart'; +import '../../../tools/noData.dart'; import '../../../tools/submitBtn.dart'; import '../../../tools/titleAppBar.dart'; import '../../../translations/trans_lib.dart'; @@ -46,7 +47,7 @@ class _APPUnlockNeedMobileNetworkingLockPageState extends State state.lockItemList.value.isEmpty ? NoData() :Column( children: [ Container( padding: EdgeInsets.all(30.w), @@ -73,10 +74,10 @@ class _APPUnlockNeedMobileNetworkingLockPageState extends State ListView.builder( + child: ListView.builder( itemCount: state.lockItemList.value.length, itemBuilder: (c, index) { LockItemData itemData = state.lockItemList.value[index]; @@ -104,7 +105,7 @@ class _APPUnlockNeedMobileNetworkingLockPageState extends State json) { lockId = json['lockId']; lockAlias = json['lockAlias']; + appUnlockOnline = json['appUnlockOnline']; } Map toJson() { final Map data = {}; data['lockId'] = lockId; data['lockAlias'] = lockAlias; + data['appUnlockOnline'] = appUnlockOnline; return data; } } diff --git a/star_lock/lib/mine/mineSet/hideInvalidUnlockPermissions/hideInvalidUnlockPermissions_page.dart b/star_lock/lib/mine/mineSet/hideInvalidUnlockPermissions/hideInvalidUnlockPermissions_page.dart index 068f3315..30ce4543 100644 --- a/star_lock/lib/mine/mineSet/hideInvalidUnlockPermissions/hideInvalidUnlockPermissions_page.dart +++ b/star_lock/lib/mine/mineSet/hideInvalidUnlockPermissions/hideInvalidUnlockPermissions_page.dart @@ -2,7 +2,7 @@ import 'package:flutter/material.dart'; import 'package:flutter_easyloading/flutter_easyloading.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:get/get.dart'; -import 'package:star_lock/mine/mineSet/lockUserManage/expireLockList/expireLockList_entity.dart'; +import 'package:star_lock/mine/mineSet/lockUserManage/expireLockList/expireElectronicKey/expireLockList_entity.dart'; import 'package:star_lock/network/api_repository.dart'; import 'package:star_lock/tools/baseGetXController.dart'; diff --git a/star_lock/lib/mine/mineSet/lockScreen/lockScreen_page.dart b/star_lock/lib/mine/mineSet/lockScreen/lockScreen_page.dart index 29b8a07f..b7822d9e 100644 --- a/star_lock/lib/mine/mineSet/lockScreen/lockScreen_page.dart +++ b/star_lock/lib/mine/mineSet/lockScreen/lockScreen_page.dart @@ -2,7 +2,7 @@ import 'package:flutter/material.dart'; import 'package:flutter_easyloading/flutter_easyloading.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:get/get.dart'; -import 'package:star_lock/mine/mineSet/lockUserManage/expireLockList/expireLockList_entity.dart'; +import 'package:star_lock/mine/mineSet/lockUserManage/expireLockList/expireElectronicKey/expireLockList_entity.dart'; import 'package:star_lock/network/api_repository.dart'; import 'package:star_lock/tools/baseGetXController.dart'; diff --git a/star_lock/lib/mine/mineSet/lockUserManage/expireLockList/expireCard/expireCard_entity.dart b/star_lock/lib/mine/mineSet/lockUserManage/expireLockList/expireCard/expireCard_entity.dart new file mode 100644 index 00000000..52829086 --- /dev/null +++ b/star_lock/lib/mine/mineSet/lockUserManage/expireLockList/expireCard/expireCard_entity.dart @@ -0,0 +1,217 @@ +class ExpireCardEntity { + int? errorCode; + String? description; + String? errorMsg; + ExpireCardListEntity? data; + + ExpireCardEntity( + {this.errorCode, this.description, this.errorMsg, this.data}); + + ExpireCardEntity.fromJson(Map json) { + errorCode = json['errorCode']; + description = json['description']; + errorMsg = json['errorMsg']; + data = json['data'] != null ? ExpireCardListEntity.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 ExpireCardListEntity { + List? list; + int? pageNo; + int? pageSize; + int? pages; + int? total; + + ExpireCardListEntity({this.list, this.pageNo, this.pageSize, this.pages, this.total}); + + ExpireCardListEntity.fromJson(Map json) { + if (json['list'] != null) { + list = []; + json['list'].forEach((v) { + list!.add(ExpireCardItemEntity.fromJson(v)); + }); + } + pageNo = json['pageNo']; + pageSize = json['pageSize']; + pages = json['pages']; + total = json['total']; + } + + Map toJson() { + final Map data = {}; + if (list != null) { + data['list'] = list!.map((v) => v.toJson()).toList(); + } + data['pageNo'] = pageNo; + data['pageSize'] = pageSize; + data['pages'] = pages; + data['total'] = total; + return data; + } +} + +class ExpireCardItemEntity { + String? clientId; + int? lockOwnerId; + int? lockId; + String? cardNumber; + int? startDate; + int? endDate; + int? cardStatus; + int? cardType; + int? cardRight; + List? weekDay; + int? addType; + int? isCoerced; + int? cardUserNo; + int? businessId; + String? createdAt; + String? updatedAt; + ApiUser? apiUser; + LockInfo? lockInfo; + int? cardId; + int? uid; + String? nickname; + String? lockAlias; + int? expireDate; + + ExpireCardItemEntity( + {this.clientId, + this.lockOwnerId, + this.lockId, + this.cardNumber, + this.startDate, + this.endDate, + this.cardStatus, + this.cardType, + this.cardRight, + this.weekDay, + this.addType, + this.isCoerced, + this.cardUserNo, + this.businessId, + this.createdAt, + this.updatedAt, + this.apiUser, + this.lockInfo, + this.cardId, + this.uid, + this.nickname, + this.lockAlias, + this.expireDate}); + + ExpireCardItemEntity.fromJson(Map json) { + clientId = json['clientId']; + lockOwnerId = json['lockOwnerId']; + lockId = json['lockId']; + cardNumber = json['cardNumber']; + startDate = json['startDate']; + endDate = json['endDate']; + cardStatus = json['cardStatus']; + cardType = json['cardType']; + cardRight = json['cardRight']; + if (json['weekDays'] != null) { + weekDay = []; + json['weekDays'].forEach((v) { + weekDay!.add(v); + }); + } + addType = json['addType']; + isCoerced = json['isCoerced']; + cardUserNo = json['cardUserNo']; + businessId = json['businessId']; + createdAt = json['created_at']; + updatedAt = json['updated_at']; + apiUser = json['api_user'] != null + ? ApiUser.fromJson(json['api_user']) + : null; + lockInfo = json['lock_info'] != null + ? new LockInfo.fromJson(json['lock_info']) + : null; + cardId = json['cardId']; + uid = json['uid']; + nickname = json['nickname']; + lockAlias = json['lockAlias']; + expireDate = json['expireDate']; + } + + Map toJson() { + final Map data = {}; + data['clientId'] = clientId; + data['lockOwnerId'] = lockOwnerId; + data['lockId'] = lockId; + data['cardNumber'] = cardNumber; + data['startDate'] = startDate; + data['endDate'] = endDate; + data['cardStatus'] = cardStatus; + data['cardType'] = cardType; + data['cardRight'] = cardRight; + if (weekDay != null) { + data['weekDay'] = weekDay!.map((v) => v.toJson()).toList(); + } + data['addType'] = addType; + data['isCoerced'] = isCoerced; + data['cardUserNo'] = cardUserNo; + data['businessId'] = businessId; + data['created_at'] = createdAt; + data['updated_at'] = updatedAt; + if (apiUser != null) { + data['api_user'] = apiUser!.toJson(); + } + if (this.lockInfo != null) { + data['lock_info'] = this.lockInfo!.toJson(); + } + data['cardId'] = cardId; + data['uid'] = uid; + data['nickname'] = nickname; + data['lockAlias'] = lockAlias; + data['expireDate'] = expireDate; + return data; + } +} + +class ApiUser { + int? id; + String? accountName; + + ApiUser({this.id, this.accountName}); + + ApiUser.fromJson(Map json) { + id = json['id']; + accountName = json['account_name']; + } + + Map toJson() { + final Map data = {}; + data['id'] = id; + data['account_name'] = accountName; + return data; + } +} + +class LockInfo { + String? btDeviceName; + + LockInfo({this.btDeviceName}); + + LockInfo.fromJson(Map json) { + btDeviceName = json['btDeviceName']; + } + + Map toJson() { + final Map data = Map(); + data['btDeviceName'] = btDeviceName; + return data; + } +} \ No newline at end of file diff --git a/star_lock/lib/mine/mineSet/lockUserManage/expireLockList/expireCard/expireCard_logic.dart b/star_lock/lib/mine/mineSet/lockUserManage/expireLockList/expireCard/expireCard_logic.dart new file mode 100644 index 00000000..b12c31f6 --- /dev/null +++ b/star_lock/lib/mine/mineSet/lockUserManage/expireLockList/expireCard/expireCard_logic.dart @@ -0,0 +1,209 @@ + +import 'dart:async'; + +import 'package:flutter_blue_plus/flutter_blue_plus.dart'; +import 'package:get/get.dart'; +import 'package:star_lock/blue/blue_manage.dart'; +import 'package:star_lock/blue/io_reply.dart'; +import 'package:star_lock/blue/io_tool/io_tool.dart'; +import 'package:star_lock/blue/io_tool/manager_event_bus.dart'; +import 'package:star_lock/blue/io_type.dart'; +import 'package:star_lock/tools/baseGetXController.dart'; +import 'package:star_lock/tools/dateTool.dart'; + +import '../../../../../blue/io_protocol/io_addICCard.dart'; +import '../../../../../blue/sender_manage.dart'; +import '../../../../../network/api_repository.dart'; +import '../../../../../tools/eventBusEventManage.dart'; +import '../../../../../tools/storage.dart'; +import 'expireCard_entity.dart'; +import 'expireCard_state.dart'; + +class ExpireCardLogic extends BaseGetXController { + ExpireCardState state = ExpireCardState(); + + // 监听设备返回的数据 + late StreamSubscription _replySubscription; + void _initReplySubscription() { + _replySubscription = EventBusManager().eventBus!.on().listen((reply) async { + // 添加卡片开始(重置锁里面所有卡) + if((reply is SenderAddICCardReply)) { + _replyAddICCardBegin(reply); + } + }); + } + + // 添加卡片开始(此处用作删除卡片) + Future _replyAddICCardBegin(Reply reply) async { + int status = reply.data[2]; + print("_replyAddFingerprintStatus:$status"); + + switch(status){ + case 0x00: + //成功 + print("${reply.commandType!.typeValue} 数据解析成功"); + cancelBlueConnetctToastTimer(); + dismissEasyLoading(); + deletICCardData(); + break; + case 0x06: + //无权限 + print("${reply.commandType!.typeValue} 需要鉴权"); + var privateKey = await Storage.getStringList(saveBluePrivateKey); + List getPrivateKeyList = changeStringListToIntList(privateKey!); + + var publicKey = await Storage.getStringList(saveBluePublicKey); + List publicKeyDataList = changeStringListToIntList(publicKey!); + + var token = await Storage.getStringList(saveBlueToken); + List getTokenList = changeStringListToIntList(token!); + + String? userID = await Storage.getUid(); + IoSenderManage.senderAddICCardCommand( + keyID:state.deletExpireCardItemEntity.cardId.toString(), + userID:userID, + cardNo:state.deletExpireCardItemEntity.cardUserNo!, + useCountLimit:0, + startTime:state.deletExpireCardItemEntity.startDate!~/1000, + endTime:state.deletExpireCardItemEntity.endDate!~/1000, + needAuthor:1, + publicKey:publicKeyDataList, + privateKey:getPrivateKeyList, + token: getTokenList, + ); + break; + case 0x07: + //无权限 + print("${reply.commandType!.typeValue} 用户无权限"); + + break; + case 0x09: + // 权限校验错误 + print("${reply.commandType!.typeValue} 权限校验错误"); + + break; + default: + //失败 + print("${reply.commandType!.typeValue} 失败"); + + break; + } + } + + // 添加卡片 + Future senderAddICCard() async { + if(state.sureBtnState.value == 1){ + return; + } + state.sureBtnState.value = 1; + + showEasyLoading(); + showBlueConnetctToastTimer(action: (){ + dismissEasyLoading(); + state.sureBtnState.value = 0; + }); + BlueManage().bludSendData(state.deletExpireCardItemEntity.lockInfo!.btDeviceName!, (BluetoothConnectionState deviceConnectionState) async { + if (deviceConnectionState == BluetoothConnectionState.connected){ + var publicKey = await Storage.getStringList(saveBluePublicKey); + List publicKeyDataList = changeStringListToIntList(publicKey!); + + var privateKey = await Storage.getStringList(saveBluePrivateKey); + List getPrivateKeyList = changeStringListToIntList(privateKey!); + + var token = await Storage.getStringList(saveBlueToken); + List getTokenList = changeStringListToIntList(token!); + print("openDoorTokenPubToken:$getTokenList"); + + String? userID = await Storage.getUid(); + IoSenderManage.senderAddICCardCommand( + keyID:state.deletExpireCardItemEntity.cardId.toString(), + userID:userID, + cardNo:state.deletExpireCardItemEntity.cardUserNo!, + useCountLimit:0, + startTime:state.deletExpireCardItemEntity.startDate!~/1000, + endTime:state.deletExpireCardItemEntity.endDate!~/1000, + needAuthor:1, + publicKey:publicKeyDataList, + privateKey:getPrivateKeyList, + token: getTokenList, + ); + } else if (deviceConnectionState == BluetoothConnectionState.disconnected) { + dismissEasyLoading(); + cancelBlueConnetctToastTimer(); + state.sureBtnState.value = 0; + if(state.ifCurrentScreen.value == true){ + showBlueConnetctToast(); + } + } + }); + } + + //请求卡即将到期列表 + Future expirCardListRequest() async { + ExpireCardEntity entity = await ApiRepository.to.expireCardList(pageNo.toString(), pageSize.toString()); + if(entity.errorCode!.codeIsSuccessful){ + if (pageNo == 1) { + state.dataList.value = entity.data!.list!; + pageNo++; + } else { + if (entity.data!.list!.isNotEmpty) { + state.dataList.value.addAll(entity.data!.list!); + pageNo++; + } + } + } + return entity; + } + + // 删除IC卡 + void deletICCardData() async{ + var entity = await ApiRepository.to.deletIcCardData( + cardId: state.deletExpireCardItemEntity.cardId.toString(), + lockId: state.deletExpireCardItemEntity.lockId.toString(), + type: "0", + deleteType:"1" + ); + if(entity.errorCode!.codeIsSuccessful){ + showToast("删除成功", something: (){ + BlueManage().disconnect(); + pageNo = 1; + expirCardListRequest(); + eventBus.fire(LockUserManageListRefreshUI()); + }); + } + } + + //使用期限 + String getExpireDateStr(ExpireCardItemEntity itemData) { + String useDateStr = ''; + if(itemData.cardType == 4){ + useDateStr = '循环'; + }else{ + useDateStr = '${DateTool().dateToYMDString(itemData.startDate.toString())}-${DateTool().dateToYMDString(itemData.endDate.toString())}'; + } + return useDateStr; + } + + @override + void onReady() { + // TODO: implement onReady + super.onReady(); + + _initReplySubscription(); + } + + @override + void onInit() { + // TODO: implement onInit + super.onInit(); + + } + + @override + void onClose() { + // TODO: implement onClose + super.onClose(); + + _replySubscription.cancel(); + } +} \ No newline at end of file diff --git a/star_lock/lib/mine/mineSet/lockUserManage/expireLockList/expireCard/expireCard_page.dart b/star_lock/lib/mine/mineSet/lockUserManage/expireLockList/expireCard/expireCard_page.dart new file mode 100644 index 00000000..cc7035d1 --- /dev/null +++ b/star_lock/lib/mine/mineSet/lockUserManage/expireLockList/expireCard/expireCard_page.dart @@ -0,0 +1,242 @@ + + +import 'package:flutter/material.dart'; +import 'package:flutter_screenutil/flutter_screenutil.dart'; +import 'package:flutter_slidable/flutter_slidable.dart'; +import 'package:get/get.dart'; +import 'package:star_lock/app_settings/app_colors.dart'; +import 'package:star_lock/tools/EasyRefreshTool.dart'; +import 'package:star_lock/tools/noData.dart'; + +import '../../../../../appRouters.dart'; +import '../../../../../tools/showTipView.dart'; +import 'expireCard_entity.dart'; +import 'expireCard_logic.dart'; + +class ExpireCardPage extends StatefulWidget { + const ExpireCardPage({Key? key}) : super(key: key); + + @override + State createState() => _ExpireCardPageState(); +} + +class _ExpireCardPageState extends State { + final logic = Get.put(ExpireCardLogic()); + final state = Get.find().state; + + Future getHttpData() async { + logic.expirCardListRequest().then((ExpireCardEntity value){ + if(mounted) setState(() {}); + }); + } + + @override + void initState() { + super.initState(); + + getHttpData(); + } + + @override + Widget build(BuildContext context) { + return EasyRefreshTool( + onRefresh: (){ + logic.pageNo = 1; + getHttpData(); + }, + onLoad: (){ + getHttpData(); + }, + child: Obx(() => _buildMainUI()) + ); + } + + Widget _buildMainUI() { + return state.dataList.isEmpty + ? NoData(noDataHeight: 1.sh - ScreenUtil().statusBarHeight - ScreenUtil().bottomBarHeight - 190.h - 64.h) + : SlidableAutoCloseBehavior( + child: ListView.separated( + itemCount: state.dataList.length, + itemBuilder: (c, index) { + ExpireCardItemEntity indexEntity = state.dataList[index]; + return Slidable( + key:ValueKey(indexEntity.uid), + endActionPane: ActionPane( + extentRatio: 0.2, + motion: const ScrollMotion(), + children: [ + SlidableAction( + onPressed: (BuildContext context){ + ShowTipView().showIosTipWithContentDialog("确定删除卡吗?", (){ + state.deletExpireCardItemEntity = indexEntity; + logic.senderAddICCard(); + }); + }, + backgroundColor: Colors.red, + foregroundColor: Colors.white, + label: '删除', + padding: EdgeInsets.only(left: 5.w, right: 5.w), + ), + ], + ), + child: _electronicKeyItem(indexEntity), + ); + }, + separatorBuilder: (BuildContext context, int index) { + return const Divider( + height: 1, + color: AppColors.greyLineColor, + ); + }, + ), + ); + } + + Widget _electronicKeyItem(ExpireCardItemEntity itemData) { + return GestureDetector( + onTap: () async { + // if(itemData.cardType! == 4){ + // // 循环 + // var data = await Get.toNamed(Routers.electronicKeyPeriodValidityPage, arguments: { + // "pushType": 0, + // "expireLockItem": itemData, + // }); + // if(data != null) { + // // setState(() { + // // state.starDate.value = data["starDate"]; + // // state.endDate.value = data["endDate"]; + // // state.starTime.value = data["starTime"]; + // // state.endTime.value = data["endTime"]; + // // state.weekDay.value = data["validityValue"]; + // // }); + // logic.pageNo = 1; + // getHttpData(); + // } + // }else{ + // var data = await Get.toNamed(Routers.electronicKeyDetailChangeDate, arguments: { + // "pushType": 0, + // "expireLockItem": itemData, + // }); + // if(data != null) { + // setState(() { + // // state.starDate.value = data["beginTimeTimestamp"].toString(); + // // state.endDate.value = data["endTimeTimestamp"].toString(); + // // state.keyType.value = 2; + // logic.pageNo = 1; + // getHttpData(); + // }); + // } + // } + }, + child: Container( + height: 90.h, + color: Colors.white, + child: Row( + children: [ + SizedBox( + width: 30.w, + ), + Image.asset( + 'images/controls_user.png', + width: 60.w, + height: 60.w, + ), + SizedBox( + width: 20.w, + ), + Expanded( + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Row( + mainAxisAlignment: MainAxisAlignment.start, + children: [ + Text( + itemData.nickname ?? '', + style: TextStyle( + fontSize: 20.sp, color: AppColors.blackColor), + ), + Expanded( + child: SizedBox( + width: 10.w, + )), + Text( + itemData.lockAlias ?? '', + style: TextStyle( + fontSize: 20.sp, color: AppColors.blackColor), + ), + ], + ), + SizedBox(height: 10.h), + Row( + mainAxisAlignment: MainAxisAlignment.start, + children: [ + Text( + logic.getExpireDateStr(itemData), + style: TextStyle( + fontSize: 18.sp, + color: AppColors.placeholderTextColor), + ), + SizedBox( + width: 5.w, + ), + getStatus(itemData), + ], + ), + SizedBox(width: 20.h), + ], + ), + ), + SizedBox(width: 20.w), + ], + ), + ), + ); + } + + Widget getStatus(ExpireCardItemEntity itemData) { + // if (itemData.keyboardPwdStatus! == 1) { + // return Container( + // padding: EdgeInsets.only(left: 5.w, right: 5.w), + // decoration: BoxDecoration( + // color: Colors.red, + // borderRadius: BorderRadius.circular(2.0), + // ), + // child: Text( + // '未生效', + // style: TextStyle( + // color: Colors.white, fontSize: 13.sp), + // ), + // ); + // } else { + if (itemData.expireDate! > 0) { + return Container( + padding: EdgeInsets.only(left: 5.w, right: 5.w), + decoration: BoxDecoration( + color: AppColors.expireTextBgColor, + borderRadius: BorderRadius.circular(2.0), + ), + child: Text( + '余${itemData.expireDate.toString()}天', + style: TextStyle( + color: Colors.white, fontSize: 13.sp), + ), + ); + } else { + return Container( + padding: EdgeInsets.only(left: 5.w, right: 5.w), + decoration: BoxDecoration( + color: Colors.red, + borderRadius: BorderRadius.circular(2.0), + ), + child: Text( + '已过期', + style: TextStyle( + color: Colors.white, fontSize: 13.sp), + ), + ); + } + // } + } + +} diff --git a/star_lock/lib/mine/mineSet/lockUserManage/expireLockList/expireCard/expireCard_state.dart b/star_lock/lib/mine/mineSet/lockUserManage/expireLockList/expireCard/expireCard_state.dart new file mode 100644 index 00000000..971346a9 --- /dev/null +++ b/star_lock/lib/mine/mineSet/lockUserManage/expireLockList/expireCard/expireCard_state.dart @@ -0,0 +1,12 @@ + +import 'package:get/get.dart'; + +import 'expireCard_entity.dart'; + +class ExpireCardState{ + final dataList = [].obs; + + var ifCurrentScreen = true.obs; // 是否是当前界面,用于判断是否需要针对当前界面进行展示 + var sureBtnState = 0.obs;// 0普通状态(可用) 1连接中(不可用) + ExpireCardItemEntity deletExpireCardItemEntity = ExpireCardItemEntity(); +} \ No newline at end of file diff --git a/star_lock/lib/mine/mineSet/lockUserManage/expireLockList/expireLockList_entity.dart b/star_lock/lib/mine/mineSet/lockUserManage/expireLockList/expireElectronicKey/expireLockList_entity.dart similarity index 100% rename from star_lock/lib/mine/mineSet/lockUserManage/expireLockList/expireLockList_entity.dart rename to star_lock/lib/mine/mineSet/lockUserManage/expireLockList/expireElectronicKey/expireLockList_entity.dart diff --git a/star_lock/lib/mine/mineSet/lockUserManage/expireLockList/expireElectronicKey/expireLockList_logic.dart b/star_lock/lib/mine/mineSet/lockUserManage/expireLockList/expireElectronicKey/expireLockList_logic.dart new file mode 100644 index 00000000..96b7e618 --- /dev/null +++ b/star_lock/lib/mine/mineSet/lockUserManage/expireLockList/expireElectronicKey/expireLockList_logic.dart @@ -0,0 +1,75 @@ + + +import 'package:star_lock/tools/baseGetXController.dart'; +import 'package:star_lock/tools/dateTool.dart'; +import 'package:star_lock/tools/eventBusEventManage.dart'; +import 'package:star_lock/tools/showTipView.dart'; + +import '../../../../../main/lockDetail/electronicKey/electronicKeyList/entity/ElectronicKeyListEntity.dart'; +import '../../../../../network/api_repository.dart'; +import 'expireLockList_entity.dart'; +import 'expireLockList_state.dart'; + +class ExpireLockListLogic extends BaseGetXController{ + ExpireLockListState state = ExpireLockListState(); + + //请求即将到期列表 + Future expireLockListRequest() async { + ExpireLockListEntity entity = await ApiRepository.to.expireLockList(pageNo.toString(), pageSize.toString()); + if(entity.errorCode!.codeIsSuccessful){ + if (pageNo == 1) { + state.dataList.value = entity.data!.itemList!; + pageNo++; + } else { + if (entity.data!.itemList!.isNotEmpty) { + state.dataList.value.addAll(entity.data!.itemList!); + pageNo++; + } + } + } + return entity; + } + + //删除电子钥匙名称请求 + Future deleteKeyRequest(int includeUnderlings, ExpireLockItem expireLockItem) async { + ElectronicKeyListEntity entity = await ApiRepository.to.deleteElectronicKey( + keyId:expireLockItem.keyId.toString(), + includeUnderlings: includeUnderlings + ); + if (entity.errorCode!.codeIsSuccessful) { + print("删除电子钥匙成功"); + showToast("删除成功", something: () { + pageNo = 1; + expireLockListRequest(); + eventBus.fire(LockUserManageListRefreshUI()); + }); + } + } + +//使用期限 + String getExpireDateStr(ExpireLockItem itemData) { + String useDateStr = ''; + if(itemData.keyType == 4){ + useDateStr = '循环'; + }else{ + useDateStr = '${DateTool().dateToYMDString(itemData.startDate.toString())}-${DateTool().dateToYMDString(itemData.endDate.toString())}'; + } + return useDateStr; + } + + deletKeyLogic(ExpireLockItem expireLockItem){ + if(expireLockItem.keyRight == 1){ + // 授权管理员 + ShowTipView().showDeleteAdministratorIsHaveAllDataDialog((isAllData) { + deleteKeyRequest(isAllData ? 1 : 0, expireLockItem); + }); + }else{ + // 普通用户 + ShowTipView().showDeleteKeyDataDialogDialog((){ + deleteKeyRequest(0, expireLockItem); + }); + } + } + + +} \ No newline at end of file diff --git a/star_lock/lib/mine/mineSet/lockUserManage/expireLockList/expireLockList_page.dart b/star_lock/lib/mine/mineSet/lockUserManage/expireLockList/expireElectronicKey/expireLockList_page.dart similarity index 58% rename from star_lock/lib/mine/mineSet/lockUserManage/expireLockList/expireLockList_page.dart rename to star_lock/lib/mine/mineSet/lockUserManage/expireLockList/expireElectronicKey/expireLockList_page.dart index 30ce481f..db433b24 100644 --- a/star_lock/lib/mine/mineSet/lockUserManage/expireLockList/expireLockList_page.dart +++ b/star_lock/lib/mine/mineSet/lockUserManage/expireLockList/expireElectronicKey/expireLockList_page.dart @@ -1,14 +1,15 @@ + import 'package:flutter/material.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; +import 'package:flutter_slidable/flutter_slidable.dart'; import 'package:get/get.dart'; -import 'package:star_lock/mine/mineSet/lockUserManage/expireLockList/expireLockList_entity.dart'; +import 'package:star_lock/common/XSConstantMacro/XSConstantMacro.dart'; +import 'package:star_lock/mine/mineSet/lockUserManage/expireLockList/expireElectronicKey/expireLockList_entity.dart'; -import '../../../../appRouters.dart'; -import '../../../../app_settings/app_colors.dart'; -import '../../../../tools/EasyRefreshTool.dart'; -import '../../../../tools/noData.dart'; -import '../../../../tools/titleAppBar.dart'; -import '../../../../translations/trans_lib.dart'; +import '../../../../../appRouters.dart'; +import '../../../../../app_settings/app_colors.dart'; +import '../../../../../tools/EasyRefreshTool.dart'; +import '../../../../../tools/noData.dart'; import 'expireLockList_logic.dart'; class ExpireLockListPage extends StatefulWidget { @@ -37,48 +38,61 @@ class _ExpireLockListPageState extends State { @override Widget build(BuildContext context) { - return Scaffold( - backgroundColor: AppColors.mainBackgroundColor, - appBar: TitleAppBar( - barTitle: TranslationLoader.lanKeys!.aboutToExpire!.tr, - haveBack: true, - backgroundColor: AppColors.mainColor, - ), - body: EasyRefreshTool( - onRefresh: (){ - logic.pageNo = 1; - getHttpData(); - }, - onLoad: (){ - getHttpData(); - }, - child: Obx(() => _buildMainUI()) - ), + return EasyRefreshTool( + onRefresh: (){ + logic.pageNo = 1; + getHttpData(); + }, + onLoad: (){ + getHttpData(); + }, + child: Obx(() => _buildMainUI()) ); } Widget _buildMainUI() { return state.dataList.isEmpty ? NoData(noDataHeight: 1.sh - ScreenUtil().statusBarHeight - ScreenUtil().bottomBarHeight - 190.h - 64.h) - : ListView.separated( - itemCount: state.dataList.length, - itemBuilder: (c, index) { - ExpireLockItem indexEntity = state.dataList[index]; - return _electronicKeyItem(indexEntity); - }, - separatorBuilder: (BuildContext context, int index) { - return const Divider( - height: 1, - color: AppColors.greyLineColor, + : SlidableAutoCloseBehavior( + child: ListView.separated( + itemCount: state.dataList.length, + itemBuilder: (c, index) { + ExpireLockItem indexEntity = state.dataList[index]; + return Slidable( + key:ValueKey(indexEntity.uid), + endActionPane: ActionPane( + extentRatio: 0.2, + motion: const ScrollMotion(), + children: [ + SlidableAction( + onPressed: (BuildContext context){ + logic.deletKeyLogic(indexEntity); + }, + backgroundColor: Colors.red, + foregroundColor: Colors.white, + label: '删除', + padding: EdgeInsets.only(left: 5.w, right: 5.w), + ), + ], + ), + child: _electronicKeyItem(indexEntity), + ); + }, + separatorBuilder: (BuildContext context, int index) { + return const Divider( + height: 1, + color: AppColors.greyLineColor, + ); + }, + ), ); - }, - ); } Widget _electronicKeyItem(ExpireLockItem itemData) { return GestureDetector( onTap: () async { if(itemData.keyType! == 4){ + // 循环 var data = await Get.toNamed(Routers.electronicKeyPeriodValidityPage, arguments: { "pushType": 0, "expireLockItem": itemData, @@ -163,31 +177,7 @@ class _ExpireLockListPageState extends State { SizedBox( width: 5.w, ), - itemData.expireDate! > 0 - ? Container( - padding: EdgeInsets.only(left: 5.w, right: 5.w), - decoration: BoxDecoration( - color: AppColors.expireTextBgColor, - borderRadius: BorderRadius.circular(2.0), - ), - child: Text( - '余${itemData.expireDate.toString()}天', - style: TextStyle( - color: Colors.white, fontSize: 13.sp), - ), - ) - : Container( - padding: EdgeInsets.only(left: 5.w, right: 5.w), - decoration: BoxDecoration( - color: Colors.red, - borderRadius: BorderRadius.circular(2.0), - ), - child: Text( - '已过期', - style: TextStyle( - color: Colors.white, fontSize: 13.sp), - ), - ) + getStatus(itemData), ], ), SizedBox(width: 20.h), @@ -200,4 +190,50 @@ class _ExpireLockListPageState extends State { ), ); } + + Widget getStatus(ExpireLockItem itemData) { + if (itemData.keyStatus! == XSConstantMacro.keyStatusWaitIneffective) { + return Container( + padding: EdgeInsets.only(left: 5.w, right: 5.w), + decoration: BoxDecoration( + color: Colors.red, + borderRadius: BorderRadius.circular(2.0), + ), + child: Text( + '未生效', + style: TextStyle( + color: Colors.white, fontSize: 13.sp), + ), + ); + } else { + if (itemData.expireDate! > 0) { + return Container( + padding: EdgeInsets.only(left: 5.w, right: 5.w), + decoration: BoxDecoration( + color: AppColors.expireTextBgColor, + borderRadius: BorderRadius.circular(2.0), + ), + child: Text( + '余${itemData.expireDate.toString()}天', + style: TextStyle( + color: Colors.white, fontSize: 13.sp), + ), + ); + } else { + return Container( + padding: EdgeInsets.only(left: 5.w, right: 5.w), + decoration: BoxDecoration( + color: Colors.red, + borderRadius: BorderRadius.circular(2.0), + ), + child: Text( + '已过期', + style: TextStyle( + color: Colors.white, fontSize: 13.sp), + ), + ); + } + } + } + } diff --git a/star_lock/lib/mine/mineSet/lockUserManage/expireLockList/expireLockList_state.dart b/star_lock/lib/mine/mineSet/lockUserManage/expireLockList/expireElectronicKey/expireLockList_state.dart similarity index 100% rename from star_lock/lib/mine/mineSet/lockUserManage/expireLockList/expireLockList_state.dart rename to star_lock/lib/mine/mineSet/lockUserManage/expireLockList/expireElectronicKey/expireLockList_state.dart diff --git a/star_lock/lib/mine/mineSet/lockUserManage/expireLockList/expireFace/expireFace_entity.dart b/star_lock/lib/mine/mineSet/lockUserManage/expireLockList/expireFace/expireFace_entity.dart new file mode 100644 index 00000000..e69de29b diff --git a/star_lock/lib/mine/mineSet/lockUserManage/expireLockList/expireFace/expireFace_logic.dart b/star_lock/lib/mine/mineSet/lockUserManage/expireLockList/expireFace/expireFace_logic.dart new file mode 100644 index 00000000..bfd67487 --- /dev/null +++ b/star_lock/lib/mine/mineSet/lockUserManage/expireLockList/expireFace/expireFace_logic.dart @@ -0,0 +1,39 @@ + +import 'package:star_lock/tools/baseGetXController.dart'; +import 'package:star_lock/tools/dateTool.dart'; +import '../../../../../network/api_repository.dart'; +import '../expireFingerprint/expireFingerprint_entity.dart'; +import 'expireFace_state.dart'; + +class ExpireFaceLogic extends BaseGetXController { + ExpireFaceState state = ExpireFaceState(); + + //请求人脸即将到期列表 + Future expirFaceListRequest() async { + ExpireFingerprintEntity entity = await ApiRepository.to.expireFingerprintList(pageNo.toString(), pageSize.toString()); + if(entity.errorCode!.codeIsSuccessful){ + if (pageNo == 1) { + state.dataList.value = entity.data!.list!; + pageNo++; + } else { + if (entity.data!.list!.isNotEmpty) { + state.dataList.value.addAll(entity.data!.list!); + pageNo++; + } + } + } + return entity; + } + + //使用期限 + String getExpireDateStr(ExpireFingerprintItemEntity itemData) { + String useDateStr = ''; + if(itemData.fingerprintType == 4){ + useDateStr = '循环'; + }else{ + useDateStr = '${DateTool().dateToYMDString(itemData.startDate.toString())}-${DateTool().dateToYMDString(itemData.endDate.toString())}'; + } + return useDateStr; + } + +} \ No newline at end of file diff --git a/star_lock/lib/mine/mineSet/lockUserManage/expireLockList/expireFace/expireFace_page.dart b/star_lock/lib/mine/mineSet/lockUserManage/expireLockList/expireFace/expireFace_page.dart new file mode 100644 index 00000000..ae0a3be0 --- /dev/null +++ b/star_lock/lib/mine/mineSet/lockUserManage/expireLockList/expireFace/expireFace_page.dart @@ -0,0 +1,240 @@ + +import 'package:flutter/material.dart'; +import 'package:flutter_screenutil/flutter_screenutil.dart'; +import 'package:flutter_slidable/flutter_slidable.dart'; +import 'package:get/get.dart'; +import 'package:star_lock/tools/EasyRefreshTool.dart'; + +import '../../../../../app_settings/app_colors.dart'; +import '../../../../../tools/noData.dart'; +import '../../../../../tools/showTipView.dart'; +import '../expireFingerprint/expireFingerprint_entity.dart'; +import 'expireFace_logic.dart'; + +class ExpireFacePage extends StatefulWidget { + const ExpireFacePage({Key? key}) : super(key: key); + + @override + State createState() => _ExpireFacePageState(); +} + +class _ExpireFacePageState extends State { + final logic = Get.put(ExpireFaceLogic()); + final state = Get.find().state; + + Future getHttpData() async { + logic.expirFaceListRequest().then((ExpireFingerprintEntity value){ + if(mounted) setState(() {}); + }); + } + + @override + void initState() { + super.initState(); + + getHttpData(); + } + + @override + Widget build(BuildContext context) { + return EasyRefreshTool( + onRefresh: (){ + logic.pageNo = 1; + getHttpData(); + }, + onLoad: (){ + getHttpData(); + }, + child: Obx(() => _buildMainUI()) + ); + } + + Widget _buildMainUI() { + return state.dataList.isEmpty + ? NoData(noDataHeight: 1.sh - ScreenUtil().statusBarHeight - ScreenUtil().bottomBarHeight - 190.h - 64.h) + : SlidableAutoCloseBehavior( + child: ListView.separated( + itemCount: state.dataList.length, + itemBuilder: (c, index) { + ExpireFingerprintItemEntity indexEntity = state.dataList[index]; + return Slidable( + key:ValueKey(indexEntity.uid), + endActionPane: ActionPane( + extentRatio: 0.2, + motion: const ScrollMotion(), + children: [ + SlidableAction( + onPressed: (BuildContext context){ + ShowTipView().showIosTipWithContentDialog("确定删除卡吗?", (){ + // state.deletExpireFingerprintItemEntity = indexEntity; + // logic.senderAddFingerprint(); + }); + }, + backgroundColor: Colors.red, + foregroundColor: Colors.white, + label: '删除', + padding: EdgeInsets.only(left: 5.w, right: 5.w), + ), + ], + ), + child: _electronicKeyItem(indexEntity), + ); + }, + separatorBuilder: (BuildContext context, int index) { + return const Divider( + height: 1, + color: AppColors.greyLineColor, + ); + }, + ), + ); + } + + Widget _electronicKeyItem(ExpireFingerprintItemEntity itemData) { + return GestureDetector( + onTap: () async { + // if(itemData.cardType! == 4){ + // // 循环 + // var data = await Get.toNamed(Routers.electronicKeyPeriodValidityPage, arguments: { + // "pushType": 0, + // "expireLockItem": itemData, + // }); + // if(data != null) { + // // setState(() { + // // state.starDate.value = data["starDate"]; + // // state.endDate.value = data["endDate"]; + // // state.starTime.value = data["starTime"]; + // // state.endTime.value = data["endTime"]; + // // state.weekDay.value = data["validityValue"]; + // // }); + // logic.pageNo = 1; + // getHttpData(); + // } + // }else{ + // var data = await Get.toNamed(Routers.electronicKeyDetailChangeDate, arguments: { + // "pushType": 0, + // "expireLockItem": itemData, + // }); + // if(data != null) { + // setState(() { + // // state.starDate.value = data["beginTimeTimestamp"].toString(); + // // state.endDate.value = data["endTimeTimestamp"].toString(); + // // state.keyType.value = 2; + // logic.pageNo = 1; + // getHttpData(); + // }); + // } + // } + }, + child: Container( + height: 90.h, + color: Colors.white, + child: Row( + children: [ + SizedBox( + width: 30.w, + ), + Image.asset( + 'images/controls_user.png', + width: 60.w, + height: 60.w, + ), + SizedBox( + width: 20.w, + ), + Expanded( + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Row( + mainAxisAlignment: MainAxisAlignment.start, + children: [ + Text( + itemData.nickname ?? '', + style: TextStyle( + fontSize: 20.sp, color: AppColors.blackColor), + ), + Expanded( + child: SizedBox( + width: 10.w, + )), + Text( + itemData.lockAlias ?? '', + style: TextStyle( + fontSize: 20.sp, color: AppColors.blackColor), + ), + ], + ), + SizedBox(height: 10.h), + Row( + mainAxisAlignment: MainAxisAlignment.start, + children: [ + Text( + logic.getExpireDateStr(itemData), + style: TextStyle( + fontSize: 18.sp, + color: AppColors.placeholderTextColor), + ), + SizedBox( + width: 5.w, + ), + getStatus(itemData), + ], + ), + SizedBox(width: 20.h), + ], + ), + ), + SizedBox(width: 20.w), + ], + ), + ), + ); + } + + Widget getStatus(ExpireFingerprintItemEntity itemData) { + // if (itemData.keyboardPwdStatus! == 1) { + // return Container( + // padding: EdgeInsets.only(left: 5.w, right: 5.w), + // decoration: BoxDecoration( + // color: Colors.red, + // borderRadius: BorderRadius.circular(2.0), + // ), + // child: Text( + // '未生效', + // style: TextStyle( + // color: Colors.white, fontSize: 13.sp), + // ), + // ); + // } else { + if (itemData.expireDate! > 0) { + return Container( + padding: EdgeInsets.only(left: 5.w, right: 5.w), + decoration: BoxDecoration( + color: AppColors.expireTextBgColor, + borderRadius: BorderRadius.circular(2.0), + ), + child: Text( + '余${itemData.expireDate.toString()}天', + style: TextStyle( + color: Colors.white, fontSize: 13.sp), + ), + ); + } else { + return Container( + padding: EdgeInsets.only(left: 5.w, right: 5.w), + decoration: BoxDecoration( + color: Colors.red, + borderRadius: BorderRadius.circular(2.0), + ), + child: Text( + '已过期', + style: TextStyle( + color: Colors.white, fontSize: 13.sp), + ), + ); + } + // } + } + +} diff --git a/star_lock/lib/mine/mineSet/lockUserManage/expireLockList/expireFace/expireFace_state.dart b/star_lock/lib/mine/mineSet/lockUserManage/expireLockList/expireFace/expireFace_state.dart new file mode 100644 index 00000000..5054fff7 --- /dev/null +++ b/star_lock/lib/mine/mineSet/lockUserManage/expireLockList/expireFace/expireFace_state.dart @@ -0,0 +1,13 @@ + +import 'package:get/get.dart'; + +import '../expireFingerprint/expireFingerprint_entity.dart'; + +class ExpireFaceState{ + final dataList = [].obs; + + var ifCurrentScreen = true.obs; // 是否是当前界面,用于判断是否需要针对当前界面进行展示 + var sureBtnState = 0.obs;// 0普通状态(可用) 1连接中(不可用) + ExpireFingerprintItemEntity deletExpireFingerprintItemEntity = ExpireFingerprintItemEntity(); + +} \ No newline at end of file diff --git a/star_lock/lib/mine/mineSet/lockUserManage/expireLockList/expireFingerprint/expireFingerprint_entity.dart b/star_lock/lib/mine/mineSet/lockUserManage/expireLockList/expireFingerprint/expireFingerprint_entity.dart new file mode 100644 index 00000000..88cb63b4 --- /dev/null +++ b/star_lock/lib/mine/mineSet/lockUserManage/expireLockList/expireFingerprint/expireFingerprint_entity.dart @@ -0,0 +1,218 @@ + +class ExpireFingerprintEntity { + int? errorCode; + String? description; + String? errorMsg; + ExpireFingerprintListEntity? data; + + ExpireFingerprintEntity( + {this.errorCode, this.description, this.errorMsg, this.data}); + + ExpireFingerprintEntity.fromJson(Map json) { + errorCode = json['errorCode']; + description = json['description']; + errorMsg = json['errorMsg']; + data = json['data'] != null ? ExpireFingerprintListEntity.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 ExpireFingerprintListEntity { + List? list; + int? pageNo; + int? pageSize; + int? pages; + int? total; + + ExpireFingerprintListEntity({this.list, this.pageNo, this.pageSize, this.pages, this.total}); + + ExpireFingerprintListEntity.fromJson(Map json) { + if (json['list'] != null) { + list = []; + json['list'].forEach((v) { + list!.add(ExpireFingerprintItemEntity.fromJson(v)); + }); + } + pageNo = json['pageNo']; + pageSize = json['pageSize']; + pages = json['pages']; + total = json['total']; + } + + Map toJson() { + final Map data = {}; + if (list != null) { + data['list'] = list!.map((v) => v.toJson()).toList(); + } + data['pageNo'] = pageNo; + data['pageSize'] = pageSize; + data['pages'] = pages; + data['total'] = total; + return data; + } +} + +class ExpireFingerprintItemEntity { + String? clientId; + int? lockOwnerId; + int? lockId; + int? fingerprintStatus; + String? fingerprintNumber; + int? fingerprintType; + int? startDate; + int? endDate; + List? weekDay; + int? addType; + int? fingerRight; + int? isCoerced; + int? fingerprintUserNo; + int? businessId; + String? createdAt; + String? updatedAt; + ApiUser? apiUser; + LockInfo? lockInfo; + int? fingerprintId; + int? uid; + String? nickname; + String? lockAlias; + int? expireDate; + + ExpireFingerprintItemEntity( + {this.clientId, + this.lockOwnerId, + this.lockId, + this.fingerprintStatus, + this.fingerprintNumber, + this.fingerprintType, + this.startDate, + this.endDate, + this.weekDay, + this.addType, + this.fingerRight, + this.isCoerced, + this.fingerprintUserNo, + this.businessId, + this.createdAt, + this.updatedAt, + this.apiUser, + this.lockInfo, + this.fingerprintId, + this.uid, + this.nickname, + this.lockAlias, + this.expireDate}); + + ExpireFingerprintItemEntity.fromJson(Map json) { + clientId = json['clientId']; + lockOwnerId = json['lockOwnerId']; + lockId = json['lockId']; + fingerprintStatus = json['fingerprintStatus']; + fingerprintNumber = json['fingerprintNumber']; + fingerprintType = json['fingerprintType']; + startDate = json['startDate']; + endDate = json['endDate']; + if (json['weekDays'] != null) { + weekDay = []; + json['weekDays'].forEach((v) { + weekDay!.add(v); + }); + } + addType = json['addType']; + fingerRight = json['fingerRight']; + isCoerced = json['isCoerced']; + fingerprintUserNo = json['fingerprintUserNo']; + businessId = json['businessId']; + createdAt = json['created_at']; + updatedAt = json['updated_at']; + apiUser = json['api_user'] != null + ? ApiUser.fromJson(json['api_user']) + : null; + lockInfo = json['lock_info'] != null + ? LockInfo.fromJson(json['lock_info']) + : null; + fingerprintId = json['fingerprintId']; + uid = json['uid']; + nickname = json['nickname']; + lockAlias = json['lockAlias']; + expireDate = json['expireDate']; + } + + Map toJson() { + final Map data = {}; + data['clientId'] = clientId; + data['lockOwnerId'] = lockOwnerId; + data['lockId'] = lockId; + data['fingerprintStatus'] = fingerprintStatus; + data['fingerprintNumber'] = fingerprintNumber; + data['fingerprintType'] = fingerprintType; + data['startDate'] = startDate; + data['endDate'] = endDate; + if (weekDay != null) { + data['weekDay'] = weekDay!.map((v) => v.toJson()).toList(); + } + data['addType'] = addType; + data['fingerRight'] = fingerRight; + data['isCoerced'] = isCoerced; + data['fingerprintUserNo'] = fingerprintUserNo; + data['businessId'] = businessId; + data['created_at'] = createdAt; + data['updated_at'] = updatedAt; + if (apiUser != null) { + data['api_user'] = apiUser!.toJson(); + } + if (lockInfo != null) { + data['lock_info'] = lockInfo!.toJson(); + } + data['fingerprintId'] = fingerprintId; + data['uid'] = uid; + data['nickname'] = nickname; + data['lockAlias'] = lockAlias; + data['expireDate'] = expireDate; + return data; + } +} + +class ApiUser { + int? id; + String? accountName; + + ApiUser({this.id, this.accountName}); + + ApiUser.fromJson(Map json) { + id = json['id']; + accountName = json['account_name']; + } + + Map toJson() { + final Map data = {}; + data['id'] = id; + data['account_name'] = accountName; + return data; + } +} + +class LockInfo { + String? btDeviceName; + + LockInfo({this.btDeviceName}); + + LockInfo.fromJson(Map json) { + btDeviceName = json['btDeviceName']; + } + + Map toJson() { + final Map data = {}; + data['btDeviceName'] = btDeviceName; + return data; + } +} \ No newline at end of file diff --git a/star_lock/lib/mine/mineSet/lockUserManage/expireLockList/expireFingerprint/expireFingerprint_logic.dart b/star_lock/lib/mine/mineSet/lockUserManage/expireLockList/expireFingerprint/expireFingerprint_logic.dart new file mode 100644 index 00000000..9c951c99 --- /dev/null +++ b/star_lock/lib/mine/mineSet/lockUserManage/expireLockList/expireFingerprint/expireFingerprint_logic.dart @@ -0,0 +1,211 @@ + +import 'dart:async'; + +import 'package:flutter_blue_plus/flutter_blue_plus.dart'; +import 'package:star_lock/blue/io_protocol/io_addFingerprint.dart'; +import 'package:star_lock/blue/io_tool/io_tool.dart'; +import 'package:star_lock/blue/io_type.dart'; +import 'package:star_lock/tools/baseGetXController.dart'; +import 'package:star_lock/tools/dateTool.dart'; + +import '../../../../../blue/blue_manage.dart'; +import '../../../../../blue/io_reply.dart'; +import '../../../../../blue/io_tool/manager_event_bus.dart'; +import '../../../../../blue/sender_manage.dart'; +import '../../../../../network/api_repository.dart'; +import '../../../../../tools/eventBusEventManage.dart'; +import '../../../../../tools/storage.dart'; +import 'expireFingerprint_entity.dart'; +import 'expireFingerprint_state.dart'; + +class ExpireFingerprintLogic extends BaseGetXController { + ExpireFingerprintState state = ExpireFingerprintState(); + + // 获取解析后的数据 + late StreamSubscription _replySubscription; + void _initReplySubscription() { + _replySubscription = EventBusManager().eventBus!.on().listen((reply) { + // 添加指纹开始(此处用作删除指纹) + if((reply is SenderAddFingerprintReply)) { + _replyAddFingerprintBegin(reply); + } + }); + } + + // 添加指纹开始 + Future _replyAddFingerprintBegin(Reply reply) async { + + int status = reply.data[2]; + print("status:$status"); + + switch(status){ + case 0x00: + //成功 + print("${reply.commandType!.typeValue} 数据解析成功"); + state.sureBtnState.value = 0; + cancelBlueConnetctToastTimer(); + dismissEasyLoading(); + deletFingerprintsData(); + break; + case 0x06: + //无权限 + print("${reply.commandType!.typeValue} 需要鉴权"); + var privateKey = await Storage.getStringList(saveBluePrivateKey); + List getPrivateKeyList = changeStringListToIntList(privateKey!); + + var publicKey = await Storage.getStringList(saveBluePublicKey); + List publicKeyDataList = changeStringListToIntList(publicKey!); + + var token = await Storage.getStringList(saveBlueToken); + List getTokenList = changeStringListToIntList(token!); + + String? userID = await Storage.getUid(); + IoSenderManage.senderAddFingerprintCommand( + keyID:state.deletExpireFingerprintItemEntity.fingerprintId.toString(), + userID:userID, + fingerNo:int.parse(state.deletExpireFingerprintItemEntity.fingerprintNumber!), + useCountLimit:0, + startTime:state.deletExpireFingerprintItemEntity.startDate!~/1000, + endTime:state.deletExpireFingerprintItemEntity.endDate!~/1000, + needAuthor:1, + publicKey:publicKeyDataList, + privateKey:getPrivateKeyList, + token: getTokenList, + ); + break; + case 0x07: + //无权限 + print("${reply.commandType!.typeValue} 用户无权限"); + + break; + case 0x09: + // 权限校验错误 + print("${reply.commandType!.typeValue} 权限校验错误"); + + break; + default: + //失败 + print("${reply.commandType!.typeValue} 失败"); + + break; + } + } + + // 删除指纹 + Future senderAddFingerprint() async { + if(state.sureBtnState.value == 1){ + return; + } + state.sureBtnState.value = 1; + + showEasyLoading(); + showBlueConnetctToastTimer(action: (){ + dismissEasyLoading(); + state.sureBtnState.value = 0; + }); + BlueManage().bludSendData(state.deletExpireFingerprintItemEntity.lockInfo!.btDeviceName!, (BluetoothConnectionState deviceConnectionState) async { + if (deviceConnectionState == BluetoothConnectionState.connected){ + var publicKey = await Storage.getStringList(saveBluePublicKey); + List publicKeyDataList = changeStringListToIntList(publicKey!); + + var privateKey = await Storage.getStringList(saveBluePrivateKey); + List getPrivateKeyList = changeStringListToIntList(privateKey!); + + var token = await Storage.getStringList(saveBlueToken); + List getTokenList = changeStringListToIntList(token!); + + String? userID = await Storage.getUid(); + + IoSenderManage.senderAddFingerprintCommand( + keyID:state.deletExpireFingerprintItemEntity.fingerprintId.toString(), + userID:userID, + fingerNo:int.parse(state.deletExpireFingerprintItemEntity.fingerprintNumber!), + useCountLimit:0, + startTime:state.deletExpireFingerprintItemEntity.startDate!~/1000, + endTime:state.deletExpireFingerprintItemEntity.endDate!~/1000, + needAuthor:1, + publicKey:publicKeyDataList, + privateKey:getPrivateKeyList, + token: getTokenList, + ); + } else if (deviceConnectionState == BluetoothConnectionState.disconnected) { + dismissEasyLoading(); + cancelBlueConnetctToastTimer(); + state.sureBtnState.value = 0; + if(state.ifCurrentScreen.value == true){ + showBlueConnetctToast(); + } + } + }); + } + + // 删除指纹 + void deletFingerprintsData() async{ + var entity = await ApiRepository.to.deletFingerprintsData( + fingerprintId: state.deletExpireFingerprintItemEntity.fingerprintId.toString(), + lockId: state.deletExpireFingerprintItemEntity.lockId.toString(), + type: "0", + deleteType:"1" + ); + if(entity.errorCode!.codeIsSuccessful){ + showToast("删除成功",something: (){ + BlueManage().disconnect(); + pageNo = 1; + expirFingerprintListRequest(); + eventBus.fire(LockUserManageListRefreshUI()); + }); + } + } + + //请求指纹即将到期列表 + Future expirFingerprintListRequest() async { + ExpireFingerprintEntity entity = await ApiRepository.to.expireFingerprintList(pageNo.toString(), pageSize.toString()); + if(entity.errorCode!.codeIsSuccessful){ + if (pageNo == 1) { + state.dataList.value = entity.data!.list!; + pageNo++; + } else { + if (entity.data!.list!.isNotEmpty) { + state.dataList.value.addAll(entity.data!.list!); + pageNo++; + } + } + } + return entity; + } + + //使用期限 + String getExpireDateStr(ExpireFingerprintItemEntity itemData) { + String useDateStr = ''; + if(itemData.fingerprintType == 4){ + useDateStr = '循环'; + }else{ + useDateStr = '${DateTool().dateToYMDString(itemData.startDate.toString())}-${DateTool().dateToYMDString(itemData.endDate.toString())}'; + } + return useDateStr; + } + + @override + void onReady() { + // TODO: implement onReady + super.onReady(); + + _initReplySubscription(); + } + + @override + void onInit() { + // TODO: implement onInit + super.onInit(); + + } + + @override + void onClose() { + // TODO: implement onClose + super.onClose(); + + _replySubscription.cancel(); + } + +} \ No newline at end of file diff --git a/star_lock/lib/mine/mineSet/lockUserManage/expireLockList/expireFingerprint/expireFingerprint_page.dart b/star_lock/lib/mine/mineSet/lockUserManage/expireLockList/expireFingerprint/expireFingerprint_page.dart new file mode 100644 index 00000000..69c0ee60 --- /dev/null +++ b/star_lock/lib/mine/mineSet/lockUserManage/expireLockList/expireFingerprint/expireFingerprint_page.dart @@ -0,0 +1,240 @@ + +import 'package:flutter/material.dart'; +import 'package:flutter_screenutil/flutter_screenutil.dart'; +import 'package:flutter_slidable/flutter_slidable.dart'; +import 'package:get/get.dart'; +import 'package:star_lock/tools/noData.dart'; +import 'package:star_lock/tools/showTipView.dart'; + +import '../../../../../app_settings/app_colors.dart'; +import '../../../../../tools/EasyRefreshTool.dart'; +import 'expireFingerprint_entity.dart'; +import 'expireFingerprint_logic.dart'; + +class ExpireFingerprintPage extends StatefulWidget { + const ExpireFingerprintPage({Key? key}) : super(key: key); + + @override + State createState() => _ExpireFingerprintPageState(); +} + +class _ExpireFingerprintPageState extends State { + final logic = Get.put(ExpireFingerprintLogic()); + final state = Get.find().state; + + Future getHttpData() async { + logic.expirFingerprintListRequest().then((ExpireFingerprintEntity value){ + if(mounted) setState(() {}); + }); + } + + @override + void initState() { + super.initState(); + + getHttpData(); + } + + @override + Widget build(BuildContext context) { + return EasyRefreshTool( + onRefresh: (){ + logic.pageNo = 1; + getHttpData(); + }, + onLoad: (){ + getHttpData(); + }, + child: Obx(() => _buildMainUI()) + ); + } + + Widget _buildMainUI() { + return state.dataList.isEmpty + ? NoData(noDataHeight: 1.sh - ScreenUtil().statusBarHeight - ScreenUtil().bottomBarHeight - 190.h - 64.h) + : SlidableAutoCloseBehavior( + child: ListView.separated( + itemCount: state.dataList.length, + itemBuilder: (c, index) { + ExpireFingerprintItemEntity indexEntity = state.dataList[index]; + return Slidable( + key:ValueKey(indexEntity.uid), + endActionPane: ActionPane( + extentRatio: 0.2, + motion: const ScrollMotion(), + children: [ + SlidableAction( + onPressed: (BuildContext context){ + ShowTipView().showIosTipWithContentDialog("确定删除卡吗?", (){ + state.deletExpireFingerprintItemEntity = indexEntity; + logic.senderAddFingerprint(); + }); + }, + backgroundColor: Colors.red, + foregroundColor: Colors.white, + label: '删除', + padding: EdgeInsets.only(left: 5.w, right: 5.w), + ), + ], + ), + child: _electronicKeyItem(indexEntity), + ); + }, + separatorBuilder: (BuildContext context, int index) { + return const Divider( + height: 1, + color: AppColors.greyLineColor, + ); + }, + ), + ); + } + + Widget _electronicKeyItem(ExpireFingerprintItemEntity itemData) { + return GestureDetector( + onTap: () async { + // if(itemData.cardType! == 4){ + // // 循环 + // var data = await Get.toNamed(Routers.electronicKeyPeriodValidityPage, arguments: { + // "pushType": 0, + // "expireLockItem": itemData, + // }); + // if(data != null) { + // // setState(() { + // // state.starDate.value = data["starDate"]; + // // state.endDate.value = data["endDate"]; + // // state.starTime.value = data["starTime"]; + // // state.endTime.value = data["endTime"]; + // // state.weekDay.value = data["validityValue"]; + // // }); + // logic.pageNo = 1; + // getHttpData(); + // } + // }else{ + // var data = await Get.toNamed(Routers.electronicKeyDetailChangeDate, arguments: { + // "pushType": 0, + // "expireLockItem": itemData, + // }); + // if(data != null) { + // setState(() { + // // state.starDate.value = data["beginTimeTimestamp"].toString(); + // // state.endDate.value = data["endTimeTimestamp"].toString(); + // // state.keyType.value = 2; + // logic.pageNo = 1; + // getHttpData(); + // }); + // } + // } + }, + child: Container( + height: 90.h, + color: Colors.white, + child: Row( + children: [ + SizedBox( + width: 30.w, + ), + Image.asset( + 'images/controls_user.png', + width: 60.w, + height: 60.w, + ), + SizedBox( + width: 20.w, + ), + Expanded( + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Row( + mainAxisAlignment: MainAxisAlignment.start, + children: [ + Text( + itemData.nickname ?? '', + style: TextStyle( + fontSize: 20.sp, color: AppColors.blackColor), + ), + Expanded( + child: SizedBox( + width: 10.w, + )), + Text( + itemData.lockAlias ?? '', + style: TextStyle( + fontSize: 20.sp, color: AppColors.blackColor), + ), + ], + ), + SizedBox(height: 10.h), + Row( + mainAxisAlignment: MainAxisAlignment.start, + children: [ + Text( + logic.getExpireDateStr(itemData), + style: TextStyle( + fontSize: 18.sp, + color: AppColors.placeholderTextColor), + ), + SizedBox( + width: 5.w, + ), + getStatus(itemData), + ], + ), + SizedBox(width: 20.h), + ], + ), + ), + SizedBox(width: 20.w), + ], + ), + ), + ); + } + + Widget getStatus(ExpireFingerprintItemEntity itemData) { + // if (itemData.keyboardPwdStatus! == 1) { + // return Container( + // padding: EdgeInsets.only(left: 5.w, right: 5.w), + // decoration: BoxDecoration( + // color: Colors.red, + // borderRadius: BorderRadius.circular(2.0), + // ), + // child: Text( + // '未生效', + // style: TextStyle( + // color: Colors.white, fontSize: 13.sp), + // ), + // ); + // } else { + if (itemData.expireDate! > 0) { + return Container( + padding: EdgeInsets.only(left: 5.w, right: 5.w), + decoration: BoxDecoration( + color: AppColors.expireTextBgColor, + borderRadius: BorderRadius.circular(2.0), + ), + child: Text( + '余${itemData.expireDate.toString()}天', + style: TextStyle( + color: Colors.white, fontSize: 13.sp), + ), + ); + } else { + return Container( + padding: EdgeInsets.only(left: 5.w, right: 5.w), + decoration: BoxDecoration( + color: Colors.red, + borderRadius: BorderRadius.circular(2.0), + ), + child: Text( + '已过期', + style: TextStyle( + color: Colors.white, fontSize: 13.sp), + ), + ); + } + // } + } + +} diff --git a/star_lock/lib/mine/mineSet/lockUserManage/expireLockList/expireFingerprint/expireFingerprint_state.dart b/star_lock/lib/mine/mineSet/lockUserManage/expireLockList/expireFingerprint/expireFingerprint_state.dart new file mode 100644 index 00000000..0cbda268 --- /dev/null +++ b/star_lock/lib/mine/mineSet/lockUserManage/expireLockList/expireFingerprint/expireFingerprint_state.dart @@ -0,0 +1,12 @@ + +import 'package:get/get.dart'; + +import 'expireFingerprint_entity.dart'; + +class ExpireFingerprintState{ + final dataList = [].obs; + + var ifCurrentScreen = true.obs; // 是否是当前界面,用于判断是否需要针对当前界面进行展示 + var sureBtnState = 0.obs;// 0普通状态(可用) 1连接中(不可用) + ExpireFingerprintItemEntity deletExpireFingerprintItemEntity = ExpireFingerprintItemEntity(); +} \ No newline at end of file diff --git a/star_lock/lib/mine/mineSet/lockUserManage/expireLockList/expireLockList_logic.dart b/star_lock/lib/mine/mineSet/lockUserManage/expireLockList/expireLockList_logic.dart deleted file mode 100644 index 5be7674c..00000000 --- a/star_lock/lib/mine/mineSet/lockUserManage/expireLockList/expireLockList_logic.dart +++ /dev/null @@ -1,41 +0,0 @@ - - -import 'package:star_lock/tools/baseGetXController.dart'; -import 'package:star_lock/tools/dateTool.dart'; - -import '../../../../network/api_repository.dart'; -import 'expireLockList_entity.dart'; -import 'expireLockList_state.dart'; - -class ExpireLockListLogic extends BaseGetXController{ - ExpireLockListState state = ExpireLockListState(); - - //请求即将到期列表 - Future expireLockListRequest() async { - ExpireLockListEntity entity = await ApiRepository.to.expireLockList(pageNo.toString(), pageSize.toString()); - if(entity.errorCode!.codeIsSuccessful){ - if (pageNo == 1) { - state.dataList.value = entity.data!.itemList!; - pageNo++; - } else { - if (entity.data!.itemList!.isNotEmpty) { - state.dataList.value.addAll(entity.data!.itemList!); - pageNo++; - } - } - } - return entity; - } - -//使用期限 - String getExpireDateStr(ExpireLockItem itemData) { - String useDateStr = ''; - if(itemData.keyType == 4){ - useDateStr = '循环'; - }else{ - useDateStr = '${DateTool().dateToYMDString(itemData.startDate.toString())}-${DateTool().dateToYMDString(itemData.endDate.toString())}'; - } - return useDateStr; - } - -} \ No newline at end of file diff --git a/star_lock/lib/mine/mineSet/lockUserManage/expireLockList/expireLockManage_page.dart b/star_lock/lib/mine/mineSet/lockUserManage/expireLockList/expireLockManage_page.dart new file mode 100644 index 00000000..bc6ed43f --- /dev/null +++ b/star_lock/lib/mine/mineSet/lockUserManage/expireLockList/expireLockManage_page.dart @@ -0,0 +1,33 @@ + +import 'package:flutter/material.dart'; +import 'package:star_lock/tools/titleAppBar.dart'; + +import '../../../../app_settings/app_colors.dart'; +import 'expireLockManage_tabbar.dart'; + +class ExpireLockManagePage extends StatefulWidget { + const ExpireLockManagePage({Key? key}) : super(key: key); + + @override + State createState() => _ExpireLockManagePageState(); +} + +class _ExpireLockManagePageState extends State { + + @override + Widget build(BuildContext context) { + + return Scaffold( + backgroundColor: AppColors.mainBackgroundColor, + appBar: TitleAppBar( + barTitle: "即将到期", + haveBack: true, + backgroundColor: AppColors.mainColor), + body: const Column( + children: [ + ExpireLockManageTabbar(), + ], + ), + ); + } +} diff --git a/star_lock/lib/mine/mineSet/lockUserManage/expireLockList/expireLockManage_tabbar.dart b/star_lock/lib/mine/mineSet/lockUserManage/expireLockList/expireLockManage_tabbar.dart new file mode 100644 index 00000000..0ef5fbef --- /dev/null +++ b/star_lock/lib/mine/mineSet/lockUserManage/expireLockList/expireLockManage_tabbar.dart @@ -0,0 +1,117 @@ + +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/CustomUnderlineTabIndicator.dart'; +import 'package:star_lock/translations/trans_lib.dart'; + +import 'expireCard/expireCard_page.dart'; +import 'expireElectronicKey/expireLockList_page.dart'; +import 'expireFace/expireFace_page.dart'; +import 'expireFingerprint/expireFingerprint_page.dart'; +import 'expirePassword/expirePassword_page.dart'; + +class ExpireLockManageTabbar extends StatefulWidget { + + const ExpireLockManageTabbar({Key? key}) : super(key: key); + + @override + State createState() => _ExpireLockManageTabbarState(); +} + +class _ExpireLockManageTabbarState extends State with SingleTickerProviderStateMixin { + late TabController _tabController; + + final List _itemTabs = [ + ItemView(title: TranslationLoader.lanKeys!.electronicKey!.tr, selectType: "0"), + ItemView(title: TranslationLoader.lanKeys!.password!.tr, selectType: "1"), + ItemView(title: TranslationLoader.lanKeys!.card!.tr, selectType: "2"), + ItemView(title: TranslationLoader.lanKeys!.fingerprint!.tr, selectType: "3"), + ItemView(title: TranslationLoader.lanKeys!.face!.tr, selectType: "4"), + ]; + + @override + void initState() { + // TODO: implement initState + super.initState(); + + _tabController = TabController( + vsync: this, + length: _itemTabs.length, + initialIndex: 1); + _tabController.addListener(() { + if (_tabController.animation!.value == _tabController.index) { + FocusScope.of(context).requestFocus(FocusNode()); + } + }); + } + + @override + Widget build(BuildContext context) { + return Expanded( + child: Column( + children: [ + _tabBar(), + _pageWidget(), + ], + )); + } + + TabBar _tabBar() { + return TabBar( + controller: _tabController, + onTap: (index) { + FocusScope.of(context).requestFocus(FocusNode()); + }, + tabs: _itemTabs.map((ItemView item) => _tab(item)).toList(), + isScrollable: true, + indicatorColor: Colors.red, + unselectedLabelColor: Colors.black, + unselectedLabelStyle: TextStyle( + color: AppColors.mainColor, + fontSize: 24.sp, + ), + automaticIndicatorColorAdjustment: true, + labelColor: AppColors.mainColor, + labelStyle: TextStyle( + color: AppColors.mainColor, + fontSize: 24.sp, + fontWeight: FontWeight.w600), + indicator: CustomUnderlineTabIndicator( + borderSide: BorderSide(color: AppColors.mainColor, width: 4.w), + strokeCap: StrokeCap.round, + width: 30.w), + ); + } + + Tab _tab(ItemView item) { + return Tab( + child: SizedBox( + // width: 1.sw / 5, + child: Text(item.title, textAlign: TextAlign.center))); + } + + Widget _pageWidget() { + return Expanded( + child: TabBarView( + controller: _tabController, + children:const [ + ExpireLockListPage(), + ExpirePasswordPage(), + ExpireCardPage(), + ExpireFingerprintPage(), + ExpireFacePage(), + ] + ), + ); + } +} + +class ItemView { + const ItemView({required this.title, required this.selectType}); + + final String title; + final String selectType; +} + diff --git a/star_lock/lib/mine/mineSet/lockUserManage/expireLockList/expirePassword/expirePassword_entity.dart b/star_lock/lib/mine/mineSet/lockUserManage/expireLockList/expirePassword/expirePassword_entity.dart new file mode 100644 index 00000000..97e6cf3b --- /dev/null +++ b/star_lock/lib/mine/mineSet/lockUserManage/expireLockList/expirePassword/expirePassword_entity.dart @@ -0,0 +1,198 @@ +class ExpirePasswordEntity { + int? errorCode; + String? description; + String? errorMsg; + ExpirePasswordListData? data; + + ExpirePasswordEntity( + {this.errorCode, this.description, this.errorMsg, this.data}); + + ExpirePasswordEntity.fromJson(Map json) { + errorCode = json['errorCode']; + description = json['description']; + errorMsg = json['errorMsg']; + data = json['data'] != null ? ExpirePasswordListData.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 ExpirePasswordListData { + List? list; + int? pageNo; + int? pageSize; + int? pages; + int? total; + + ExpirePasswordListData({this.list, this.pageNo, this.pageSize, this.pages, this.total}); + + ExpirePasswordListData.fromJson(Map json) { + if (json['list'] != null) { + list = []; + json['list'].forEach((v) { + list!.add(ExpirePasswordItemData.fromJson(v)); + }); + } + pageNo = json['pageNo']; + pageSize = json['pageSize']; + pages = json['pages']; + total = json['total']; + } + + Map toJson() { + final Map data = {}; + if (list != null) { + data['list'] = list!.map((v) => v.toJson()).toList(); + } + data['pageNo'] = pageNo; + data['pageSize'] = pageSize; + data['pages'] = pages; + data['total'] = total; + return data; + } +} + +class ExpirePasswordItemData { + String? clientId; + int? lockOwnerId; + int? lockId; + int? keyboardPwdType; + int? keyboardPwdStatus; + int? startDate; + int? endDate; + String? keyboardPwd; + String? keyboardPwdHash; + int? addType; + int? pwdRight; + int? isCustom; + int? isCoerced; + int? hoursStart; + int? hoursEnd; + int? pwdUserNo; + int? businessId; + String? createdAt; + String? updatedAt; + ApiUser? apiUser; + int? pwdId; + int? uid; + String? nickname; + String? lockAlias; + int? expireDate; + + ExpirePasswordItemData( + {this.clientId, + this.lockOwnerId, + this.lockId, + this.keyboardPwdType, + this.keyboardPwdStatus, + this.startDate, + this.endDate, + this.keyboardPwd, + this.keyboardPwdHash, + this.addType, + this.pwdRight, + this.isCustom, + this.isCoerced, + this.hoursStart, + this.hoursEnd, + this.pwdUserNo, + this.businessId, + this.createdAt, + this.updatedAt, + this.apiUser, + this.pwdId, + this.uid, + this.nickname, + this.lockAlias, + this.expireDate}); + + ExpirePasswordItemData.fromJson(Map json) { + clientId = json['clientId']; + lockOwnerId = json['lockOwnerId']; + lockId = json['lockId']; + keyboardPwdType = json['keyboardPwdType']; + keyboardPwdStatus = json['keyboardPwdStatus']; + startDate = json['startDate']; + endDate = json['endDate']; + keyboardPwd = json['keyboardPwd']; + keyboardPwdHash = json['keyboardPwdHash']; + addType = json['addType']; + pwdRight = json['pwdRight']; + isCustom = json['isCustom']; + isCoerced = json['isCoerced']; + hoursStart = json['hoursStart']; + hoursEnd = json['hoursEnd']; + pwdUserNo = json['pwdUserNo']; + businessId = json['businessId']; + createdAt = json['created_at']; + updatedAt = json['updated_at']; + apiUser = json['api_user'] != null + ? ApiUser.fromJson(json['api_user']) + : null; + pwdId = json['pwdId']; + uid = json['uid']; + nickname = json['nickname']; + lockAlias = json['lockAlias']; + expireDate = json['expireDate']; + } + + Map toJson() { + final Map data = {}; + data['clientId'] = clientId; + data['lockOwnerId'] = lockOwnerId; + data['lockId'] = lockId; + data['keyboardPwdType'] = keyboardPwdType; + data['keyboardPwdStatus'] = keyboardPwdStatus; + data['startDate'] = startDate; + data['endDate'] = endDate; + data['keyboardPwd'] = keyboardPwd; + data['keyboardPwdHash'] = keyboardPwdHash; + data['addType'] = addType; + data['pwdRight'] = pwdRight; + data['isCustom'] = isCustom; + data['isCoerced'] = isCoerced; + data['hoursStart'] = hoursStart; + data['hoursEnd'] = hoursEnd; + data['pwdUserNo'] = pwdUserNo; + data['businessId'] = businessId; + data['created_at'] = createdAt; + data['updated_at'] = updatedAt; + if (apiUser != null) { + data['api_user'] = apiUser!.toJson(); + } + data['pwdId'] = pwdId; + data['uid'] = uid; + data['nickname'] = nickname; + data['lockAlias'] = lockAlias; + data['expireDate'] = expireDate; + return data; + } +} + +class ApiUser { + int? id; + String? accountName; + + ApiUser({this.id, this.accountName}); + + ApiUser.fromJson(Map json) { + id = json['id']; + accountName = json['account_name']; + } + + Map toJson() { + final Map data = {}; + data['id'] = id; + data['account_name'] = accountName; + return data; + } +} diff --git a/star_lock/lib/mine/mineSet/lockUserManage/expireLockList/expirePassword/expirePassword_logic.dart b/star_lock/lib/mine/mineSet/lockUserManage/expireLockList/expirePassword/expirePassword_logic.dart new file mode 100644 index 00000000..9890f5a1 --- /dev/null +++ b/star_lock/lib/mine/mineSet/lockUserManage/expireLockList/expirePassword/expirePassword_logic.dart @@ -0,0 +1,57 @@ + +import 'package:star_lock/tools/baseGetXController.dart'; +import 'package:star_lock/tools/dateTool.dart'; + +import '../../../../../main/lockDetail/passwordKey/passwordKey_perpetual/passwordKeyEntity.dart'; +import '../../../../../network/api_repository.dart'; +import '../../../../../tools/eventBusEventManage.dart'; +import 'expirePassword_entity.dart'; +import 'expirePassword_state.dart'; + +class ExpirePasswordLogic extends BaseGetXController { + ExpirePasswordState state = ExpirePasswordState(); + + //请求即将到期列表 + Future expirePasswordListRequest() async { + ExpirePasswordEntity entity = await ApiRepository.to.expirePasswordList(pageNo.toString(), pageSize.toString()); + if(entity.errorCode!.codeIsSuccessful){ + if (pageNo == 1) { + state.dataList.value = entity.data!.list!; + pageNo++; + } else { + if (entity.data!.list!.isNotEmpty) { + state.dataList.value.addAll(entity.data!.list!); + pageNo++; + } + } + } + return entity; + } + + //删除密码请求 deleteType:1-蓝牙 2-网关 + Future deletePwdRequest(ExpirePasswordItemData expirePasswordItemData) async { + PasswordKeyEntity entity = await ApiRepository.to.deleteKeyboardPwd( + expirePasswordItemData.lockId.toString(), + expirePasswordItemData.pwdId.toString(), + 1); + if (entity.errorCode!.codeIsSuccessful) { + showToast("删除成功", something: () { + pageNo = 1; + expirePasswordListRequest(); + eventBus.fire(LockUserManageListRefreshUI()); + }); + } + } + + //使用期限 + String getExpireDateStr(ExpirePasswordItemData itemData) { + String useDateStr = ''; + if(itemData.keyboardPwdType == 4){ + useDateStr = '循环'; + }else{ + useDateStr = '${DateTool().dateToYMDString(itemData.startDate.toString())}-${DateTool().dateToYMDString(itemData.endDate.toString())}'; + } + return useDateStr; + } + +} \ No newline at end of file diff --git a/star_lock/lib/mine/mineSet/lockUserManage/expireLockList/expirePassword/expirePassword_page.dart b/star_lock/lib/mine/mineSet/lockUserManage/expireLockList/expirePassword/expirePassword_page.dart new file mode 100644 index 00000000..c7db1c43 --- /dev/null +++ b/star_lock/lib/mine/mineSet/lockUserManage/expireLockList/expirePassword/expirePassword_page.dart @@ -0,0 +1,240 @@ + +import 'package:flutter/material.dart'; +import 'package:flutter_screenutil/flutter_screenutil.dart'; +import 'package:flutter_slidable/flutter_slidable.dart'; +import 'package:get/get.dart'; +import 'package:star_lock/appRouters.dart'; +import 'package:star_lock/app_settings/app_colors.dart'; +import 'package:star_lock/tools/EasyRefreshTool.dart'; +import 'package:star_lock/tools/noData.dart'; + +import '../../../../../tools/showTipView.dart'; +import 'expirePassword_entity.dart'; +import 'expirePassword_logic.dart'; + +class ExpirePasswordPage extends StatefulWidget { + const ExpirePasswordPage({Key? key}) : super(key: key); + + @override + State createState() => _ExpirePasswordPageState(); +} + +class _ExpirePasswordPageState extends State { + final logic = Get.put(ExpirePasswordLogic()); + final state = Get.find().state; + + Future getHttpData() async { + logic.expirePasswordListRequest().then((ExpirePasswordEntity value){ + if(mounted) setState(() {}); + }); + } + + @override + void initState() { + super.initState(); + + getHttpData(); + } + + @override + Widget build(BuildContext context) { + return EasyRefreshTool( + onRefresh: (){ + logic.pageNo = 1; + getHttpData(); + }, + onLoad: (){ + getHttpData(); + }, + child: Obx(() => _buildMainUI()) + ); + } + + Widget _buildMainUI() { + return state.dataList.isEmpty + ? NoData(noDataHeight: 1.sh - ScreenUtil().statusBarHeight - ScreenUtil().bottomBarHeight - 190.h - 64.h) + : SlidableAutoCloseBehavior( + child: ListView.separated( + itemCount: state.dataList.length, + itemBuilder: (c, index) { + ExpirePasswordItemData indexEntity = state.dataList[index]; + return Slidable( + key:ValueKey(indexEntity.uid), + endActionPane: ActionPane( + extentRatio: 0.2, + motion: const ScrollMotion(), + children: [ + SlidableAction( + onPressed: (BuildContext context){ + ShowTipView().showIosTipWithContentDialog("确定删除该密码吗?", (){ + logic.deletePwdRequest(indexEntity); + }); + }, + backgroundColor: Colors.red, + foregroundColor: Colors.white, + label: '删除', + padding: EdgeInsets.only(left: 5.w, right: 5.w), + ), + ], + ), + child: _electronicKeyItem(indexEntity), + ); + }, + separatorBuilder: (BuildContext context, int index) { + return const Divider( + height: 1, + color: AppColors.greyLineColor, + ); + }, + ), + ); + } + + Widget _electronicKeyItem(ExpirePasswordItemData itemData) { + return GestureDetector( + onTap: () async { + // if(itemData.keyboardPwdType! == 4){ + // // 循环 + // var data = await Get.toNamed(Routers.electronicKeyPeriodValidityPage, arguments: { + // "pushType": 0, + // "expireLockItem": itemData, + // }); + // if(data != null) { + // // setState(() { + // // state.starDate.value = data["starDate"]; + // // state.endDate.value = data["endDate"]; + // // state.starTime.value = data["starTime"]; + // // state.endTime.value = data["endTime"]; + // // state.weekDay.value = data["validityValue"]; + // // }); + // logic.pageNo = 1; + // getHttpData(); + // } + // }else{ + // var data = await Get.toNamed(Routers.electronicKeyDetailChangeDate, arguments: { + // "pushType": 0, + // "expireLockItem": itemData, + // }); + // if(data != null) { + // setState(() { + // // state.starDate.value = data["beginTimeTimestamp"].toString(); + // // state.endDate.value = data["endTimeTimestamp"].toString(); + // // state.keyType.value = 2; + // logic.pageNo = 1; + // getHttpData(); + // }); + // } + // } + }, + child: Container( + height: 90.h, + color: Colors.white, + child: Row( + children: [ + SizedBox( + width: 30.w, + ), + Image.asset( + 'images/controls_user.png', + width: 60.w, + height: 60.w, + ), + SizedBox( + width: 20.w, + ), + Expanded( + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Row( + mainAxisAlignment: MainAxisAlignment.start, + children: [ + Text( + itemData.nickname ?? '', + style: TextStyle( + fontSize: 20.sp, color: AppColors.blackColor), + ), + Expanded( + child: SizedBox( + width: 10.w, + )), + Text( + itemData.lockAlias ?? '', + style: TextStyle( + fontSize: 20.sp, color: AppColors.blackColor), + ), + ], + ), + SizedBox(height: 10.h), + Row( + mainAxisAlignment: MainAxisAlignment.start, + children: [ + Text( + logic.getExpireDateStr(itemData), + style: TextStyle( + fontSize: 18.sp, + color: AppColors.placeholderTextColor), + ), + SizedBox( + width: 5.w, + ), + getStatus(itemData), + ], + ), + SizedBox(width: 20.h), + ], + ), + ), + SizedBox(width: 20.w), + ], + ), + ), + ); + } + + Widget getStatus(ExpirePasswordItemData itemData) { + // if (itemData.keyboardPwdStatus! == 1) { + // return Container( + // padding: EdgeInsets.only(left: 5.w, right: 5.w), + // decoration: BoxDecoration( + // color: Colors.red, + // borderRadius: BorderRadius.circular(2.0), + // ), + // child: Text( + // '未生效', + // style: TextStyle( + // color: Colors.white, fontSize: 13.sp), + // ), + // ); + // } else { + if (itemData.expireDate! > 0) { + return Container( + padding: EdgeInsets.only(left: 5.w, right: 5.w), + decoration: BoxDecoration( + color: AppColors.expireTextBgColor, + borderRadius: BorderRadius.circular(2.0), + ), + child: Text( + '余${itemData.expireDate.toString()}天', + style: TextStyle( + color: Colors.white, fontSize: 13.sp), + ), + ); + } else { + return Container( + padding: EdgeInsets.only(left: 5.w, right: 5.w), + decoration: BoxDecoration( + color: Colors.red, + borderRadius: BorderRadius.circular(2.0), + ), + child: Text( + '已过期', + style: TextStyle( + color: Colors.white, fontSize: 13.sp), + ), + ); + } + // } + } + +} diff --git a/star_lock/lib/mine/mineSet/lockUserManage/expireLockList/expirePassword/expirePassword_state.dart b/star_lock/lib/mine/mineSet/lockUserManage/expireLockList/expirePassword/expirePassword_state.dart new file mode 100644 index 00000000..838831c4 --- /dev/null +++ b/star_lock/lib/mine/mineSet/lockUserManage/expireLockList/expirePassword/expirePassword_state.dart @@ -0,0 +1,7 @@ + +import 'package:get/get.dart'; +import 'expirePassword_entity.dart'; + +class ExpirePasswordState { + final dataList = [].obs; +} \ No newline at end of file diff --git a/star_lock/lib/mine/mineSet/lockUserManage/lockUserManageList/lockUserManageList_logic.dart b/star_lock/lib/mine/mineSet/lockUserManage/lockUserManageList/lockUserManageList_logic.dart index f01e8dce..a41303c2 100644 --- a/star_lock/lib/mine/mineSet/lockUserManage/lockUserManageList/lockUserManageList_logic.dart +++ b/star_lock/lib/mine/mineSet/lockUserManage/lockUserManageList/lockUserManageList_logic.dart @@ -1,10 +1,13 @@ +import 'dart:async'; + import 'package:flutter_easyloading/flutter_easyloading.dart'; import 'package:get/get.dart'; import '../../../../main/lockDetail/electronicKey/massSendElectronicKey/massSendLockGroupList/lockUserList/lockUserListEntity.dart'; import '../../../../network/api_repository.dart'; import '../../../../tools/baseGetXController.dart'; +import '../../../../tools/eventBusEventManage.dart'; import 'lockUserManageList_state.dart'; class LockUserManageListLogic extends BaseGetXController { @@ -13,7 +16,7 @@ class LockUserManageListLogic extends BaseGetXController { //请求锁用户列表 Future lockUserListRequest() async { LockUserListEntity entity = - await ApiRepository.to.lockUserList(pageNo.toString(), '20', state.searchController.text); + await ApiRepository.to.lockUserList(pageNo.toString(), pageSize, state.searchController.text); if(entity.errorCode!.codeIsSuccessful){ if (pageNo == 1) { state.dataList.value = entity.data!; @@ -41,12 +44,22 @@ class LockUserManageListLogic extends BaseGetXController { } } + /// 刷新电子钥匙列表 + StreamSubscription? _getElectronicKeyListRefreshUIEvent; + void _getElectronicKeyListRefreshUIAction() { + // 蓝牙协议通知传输跟蓝牙之外的数据传输类不一样 eventBus + _getElectronicKeyListRefreshUIEvent = eventBus.on().listen((event) { + pageNo = 1; + lockUserListRequest(); + }); + } + @override void onReady() { // TODO: implement onReady super.onReady(); - // lockUserListRequest(); + _getElectronicKeyListRefreshUIAction(); } @override @@ -58,5 +71,8 @@ class LockUserManageListLogic extends BaseGetXController { @override void onClose() { // TODO: implement onClose + super.onClose(); + + _getElectronicKeyListRefreshUIEvent?.cancel(); } } \ No newline at end of file diff --git a/star_lock/lib/mine/mineSet/lockUserManage/lockUserManageList/lockUserManageList_page.dart b/star_lock/lib/mine/mineSet/lockUserManage/lockUserManageList/lockUserManageList_page.dart index 749d9c3a..0cc01d0c 100644 --- a/star_lock/lib/mine/mineSet/lockUserManage/lockUserManageList/lockUserManageList_page.dart +++ b/star_lock/lib/mine/mineSet/lockUserManage/lockUserManageList/lockUserManageList_page.dart @@ -11,7 +11,6 @@ import '../../../../../tools/titleAppBar.dart'; import '../../../../../translations/trans_lib.dart'; import '../../../../tools/EasyRefreshTool.dart'; import '../../../../tools/keySearchWidget.dart'; -import '../../../../tools/left_slide_actions.dart'; import '../../../../tools/showIosTipView.dart'; import 'lockUserManageList_logic.dart'; @@ -54,7 +53,7 @@ class _LockUserManageListPageState extends State { style: TextStyle(color: Colors.white, fontSize: 24.sp), ), onPressed: () { - Navigator.pushNamed(context, Routers.expireLockListPage); + Navigator.pushNamed(context, Routers.expireLockManagePage); }, ), ], @@ -139,18 +138,6 @@ class _LockUserManageListPageState extends State { ), child: _electronicKeyItem(indexEntity), ); - - // return LeftSlideActions( - // key: Key(indexEntity.userid!), - // actionsWidth: 60, - // actions: [ - // _buildDeleteBtn(indexEntity), - // ], - // decoration: const BoxDecoration( - // borderRadius: BorderRadius.all(Radius.circular(1)), - // ), - // child: _electronicKeyItem(indexEntity), - // ); } return const SizedBox.shrink(); // return _electronicKeyItem(indexEntity); @@ -233,36 +220,13 @@ class _LockUserManageListPageState extends State { ); } - // Widget _buildDeleteBtn(LockUserData passwordKeyListItem) { - // return GestureDetector( - // onTap: () { - // // 省略: 弹出是否删除的确认对话框。 - // showIosTipViewDialog(context, passwordKeyListItem); - // }, - // child: Container( - // width: 60, - // color: const Color(0xFFF20101), - // alignment: Alignment.center, - // child: const Text( - // '删除', - // style: TextStyle( - // fontSize: 16, - // fontWeight: FontWeight.w500, - // color: Colors.white, - // height: 1, - // ), - // ), - // ), - // ); - // } - void showIosTipViewDialog(BuildContext context, LockUserData lockUserData) { showDialog( context: context, builder: (BuildContext context) { return ShowIosTipView( title: "提示", - tipTitle: "确定要删除吗?", + tipTitle: "删除用户时,会将用户拥有的钥匙一起删除。", sureClick: () { Get.back(); logic.deletelockUserRequest(lockUserData.uid!); diff --git a/star_lock/lib/mine/mineSet/lockUserManage/ownedKeyList/ownedKeyList_logic.dart b/star_lock/lib/mine/mineSet/lockUserManage/ownedKeyList/ownedKeyList_logic.dart index 91b9cbe7..5c320971 100644 --- a/star_lock/lib/mine/mineSet/lockUserManage/ownedKeyList/ownedKeyList_logic.dart +++ b/star_lock/lib/mine/mineSet/lockUserManage/ownedKeyList/ownedKeyList_logic.dart @@ -1,6 +1,9 @@ +import 'package:get/get.dart'; import 'package:star_lock/common/XSConstantMacro/XSConstantMacro.dart'; import 'package:star_lock/tools/baseGetXController.dart'; +import 'package:star_lock/tools/eventBusEventManage.dart'; +import '../../../../main/lockDetail/electronicKey/electronicKeyList/entity/ElectronicKeyListEntity.dart'; import '../../../../network/api_repository.dart'; import '../lockUserManageList/keyListByUserEntity.dart'; import 'ownedKeyList_state.dart'; @@ -9,19 +12,63 @@ class OwnedKeyListLogic extends BaseGetXController { OwnedKeyListState state = OwnedKeyListState(); //请求用户拥有的锁 - Future> mockNetworkDataRequest() async { - KeyListByUserEntity entity = await ApiRepository.to.keyListByUser('1', '20', state.getUidStr); + Future mockNetworkDataRequest() async { + KeyListByUserEntity entity = await ApiRepository.to.keyListByUser(pageNo.toString(), pageSize, state.getUidStr.toString()); + // if (entity.errorCode!.codeIsSuccessful) { + // print("请求用户拥有的锁:${entity.data!.keyList}"); + // } + // if (entity.data != null) { + // return entity.data!.keyList!; + // } else { + // List dataList = []; + // return dataList; + // } + + if(entity.errorCode!.codeIsSuccessful){ + if (pageNo == 1) { + state.dataList.value = entity.data!.keyList!; + pageNo++; + } else { + if (entity.data!.keyList!.isNotEmpty) { + state.dataList.value.addAll(entity.data!.keyList!); + print("state.itemDataList.value.length:${state.dataList.value.length}"); + pageNo++; + } + } + } + return entity; + } + + //删除电子钥匙名称请求 setAdministrator + Future deleteKeyRequest(int keyId) async { + ElectronicKeyListEntity entity = await ApiRepository.to.deleteElectronicKey( + keyId:keyId.toString(), + includeUnderlings: 0 + ); if (entity.errorCode!.codeIsSuccessful) { - print("请求用户拥有的锁:${entity.data!.keyList}"); - } - if (entity.data != null) { - return entity.data!.keyList!; - } else { - List dataList = []; - return dataList; + print("删除电子钥匙成功"); + showToast("删除成功", something: () { + pageNo = 1; + mockNetworkDataRequest(); + eventBus.fire(LockUserManageListRefreshUI()); + }); } } + //设置授权管理员 + Future setAdministrator() async { + // ElectronicKeyListEntity entity = await ApiRepository.to.setAdministrator( + // keyId:state.itemData.value.keyId.toString(), + // ); + // if (entity.errorCode!.codeIsSuccessful) { + // showToast("设置成功", something: () { + // // eventBus.fire(ElectronicKeyListRefreshUI()); + // // eventBus.fire(AuthorizedAdminPageRefreshUI()); + // Get.back(); + // }); + // } + } + //使用期限 String getUseDateStr(KeyListItem indexEntity) { String useDateStr = ''; diff --git a/star_lock/lib/mine/mineSet/lockUserManage/ownedKeyList/ownedKeyList_page.dart b/star_lock/lib/mine/mineSet/lockUserManage/ownedKeyList/ownedKeyList_page.dart index 1e3e644f..58784bce 100644 --- a/star_lock/lib/mine/mineSet/lockUserManage/ownedKeyList/ownedKeyList_page.dart +++ b/star_lock/lib/mine/mineSet/lockUserManage/ownedKeyList/ownedKeyList_page.dart @@ -1,15 +1,19 @@ import 'package:flutter/material.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; +import 'package:flutter_slidable/flutter_slidable.dart'; import 'package:get/get.dart'; import 'package:get/get_utils/get_utils.dart'; import 'package:star_lock/common/XSConstantMacro/XSConstantMacro.dart'; import 'package:star_lock/mine/mineSet/lockUserManage/lockUserManageList/keyListByUserEntity.dart'; import 'package:star_lock/network/api_repository.dart'; import 'package:star_lock/tools/baseGetXController.dart'; +import 'package:star_lock/tools/noData.dart'; +import 'package:star_lock/tools/showIosTipView.dart'; import 'package:star_lock/translations/trans_lib.dart'; import '../../../../../app_settings/app_colors.dart'; import '../../../../../tools/titleAppBar.dart'; +import '../../../../tools/EasyRefreshTool.dart'; import 'ownedKeyList_logic.dart'; class OwnedKeyListPage extends StatefulWidget { @@ -23,9 +27,18 @@ class _OwnedKeyListPageState extends State { final logic = Get.put(OwnedKeyListLogic()); final state = Get.find().state; + + Future getHttpData() async { + logic.mockNetworkDataRequest().then((KeyListByUserEntity value){ + if(mounted) setState(() {}); + }); + } + @override void initState() { super.initState(); + + getHttpData(); } @override @@ -37,31 +50,20 @@ class _OwnedKeyListPageState extends State { haveBack: true, backgroundColor: AppColors.mainColor, ), - body: FutureBuilder>( - future: logic.mockNetworkDataRequest(), - builder: (BuildContext context, - AsyncSnapshot> snapshot) { - //请求结束 - if (snapshot.connectionState == ConnectionState.done) { - if (snapshot.hasError) { - //请求失败 - return const Text('请求失败'); - } else { - //请求成功 - final List itemList = snapshot.data!; - - return Column( - children: [ - _topOwnedKeyText(), - Expanded(child: _buildMainUI(itemList)), - ], - ); - } - } else { - //请求未结束 显示loading - return Container(); - } - })); + body: EasyRefreshTool( + onRefresh: () { + logic.pageNo = 1; + getHttpData(); + }, + onLoad: () { + getHttpData(); + }, + child: Column( + children: [ + _topOwnedKeyText(), + Obx(() => Expanded(child: _buildMainUI())), + ], + ))); } Widget _topOwnedKeyText() { @@ -80,16 +82,43 @@ class _OwnedKeyListPageState extends State { ); } - Widget _buildMainUI(List itemList) { - return ListView.builder( - itemCount: itemList.length, - itemBuilder: (c, index) { - KeyListItem itemData = itemList[index]; - return _electronicKeyItem(itemData); - }); + Widget _buildMainUI() { + return state.dataList.isEmpty + ? NoData(noDataHeight: 1.sh - ScreenUtil().statusBarHeight - ScreenUtil().bottomBarHeight - 190.h - 64.h) + : SlidableAutoCloseBehavior( + child: ListView.builder( + itemCount: state.dataList.length, + itemBuilder: (c, index) { + KeyListItem itemData = state.dataList[index]; + return Slidable( + key:ValueKey(itemData.keyId), + endActionPane: ActionPane( + extentRatio: 0.2, + motion: const ScrollMotion(), + children: [ + SlidableAction( + onPressed: (BuildContext context){ + showIosTipViewDialog(itemData); + }, + backgroundColor: Colors.red, + foregroundColor: Colors.white, + label: '删除', + padding: EdgeInsets.only(left: 5.w, right: 5.w), + ), + ], + ), + child: _electronicKeyItem(itemData), + ); + }), + ); } Widget _electronicKeyItem(KeyListItem itemData) { + var isHaveExpired = false; + if(itemData.keyStatus == XSConstantMacro.keyStatusExpired){ + isHaveExpired = true; + } + return GestureDetector( onTap: () {}, child: Container( @@ -111,7 +140,28 @@ class _OwnedKeyListPageState extends State { Row( mainAxisAlignment: MainAxisAlignment.start, children: [ - Text(itemData.lockAlias ?? '', style: TextStyle(fontSize: 24.sp, color: AppColors.blackColor)), + // Text(itemData.lockAlias ?? '', style: TextStyle(fontSize: 24.sp, color: AppColors.blackColor)), + SizedBox( + width: 1.sw - 110.w - 100.w, + child: Row( + children: [ + Flexible( + child: Text( + itemData.lockAlias ?? '', + maxLines: 1, + overflow: TextOverflow.ellipsis, + style: TextStyle(fontSize: 24.sp, color: isHaveExpired ? Colors.grey:AppColors.blackColor) + ), + ), + ], + ), + ), + Visibility( + visible: isHaveExpired, + child: Text("已过期", + style: TextStyle(fontSize: 22.sp, color: Colors.grey)), + ), + SizedBox(width: 10.w), ], ), SizedBox(height: 5.h), @@ -120,7 +170,7 @@ class _OwnedKeyListPageState extends State { children: [ Text( logic.getUseDateStr(itemData), - style: TextStyle(fontSize: 18.sp, color: AppColors.placeholderTextColor), + style: TextStyle(fontSize: 18.sp, color: isHaveExpired ? Colors.grey:AppColors.placeholderTextColor), ), ], ), @@ -134,4 +184,24 @@ class _OwnedKeyListPageState extends State { ), ); } + + void showIosTipViewDialog(KeyListItem lockUserData) { + showDialog( + context: Get.context!, + builder: (BuildContext context) { + return ShowIosTipView( + title: "提示", + tipTitle: "删除钥匙会在用户APP连网后生效", + sureClick: () { + Get.back(); + logic.deleteKeyRequest(lockUserData.keyId!); + }, + cancelClick: () { + Get.back(); + }, + ); + } + ); + } + } diff --git a/star_lock/lib/mine/mineSet/lockUserManage/ownedKeyList/ownedKeyList_state.dart b/star_lock/lib/mine/mineSet/lockUserManage/ownedKeyList/ownedKeyList_state.dart index 57f05a04..c0e00f84 100644 --- a/star_lock/lib/mine/mineSet/lockUserManage/ownedKeyList/ownedKeyList_state.dart +++ b/star_lock/lib/mine/mineSet/lockUserManage/ownedKeyList/ownedKeyList_state.dart @@ -1,11 +1,11 @@ - import 'package:get/get.dart'; +import '../lockUserManageList/keyListByUserEntity.dart'; class OwnedKeyListState{ - var getUidStr = ''; - var dataList = [].obs; + var getUidStr = 0; + var dataList = [].obs; OwnedKeyListState(){ Map map = Get.arguments; diff --git a/star_lock/lib/mine/mineSet/mineSet/mineSet_logic.dart b/star_lock/lib/mine/mineSet/mineSet/mineSet_logic.dart index 4ea009f5..65eb4b55 100644 --- a/star_lock/lib/mine/mineSet/mineSet/mineSet_logic.dart +++ b/star_lock/lib/mine/mineSet/mineSet/mineSet_logic.dart @@ -2,7 +2,7 @@ import 'dart:async'; import 'package:get/get.dart'; import 'package:star_lock/appRouters.dart'; import 'package:star_lock/login/login/entity/LoginEntity.dart'; -import 'package:star_lock/mine/mineSet/lockUserManage/expireLockList/expireLockList_entity.dart'; +import 'package:star_lock/mine/mineSet/lockUserManage/expireLockList/expireElectronicKey/expireLockList_entity.dart'; import 'package:star_lock/mine/mineSet/mineSet/mineSet_state.dart'; import 'package:star_lock/tools/storage.dart'; import '../../../../network/api_repository.dart'; diff --git a/star_lock/lib/mine/mineSet/transferSmartLock/recipientInformation/recipientInformation_entity.dart b/star_lock/lib/mine/mineSet/transferSmartLock/recipientInformation/recipientInformation_entity.dart index e2c80eda..3726d46f 100644 --- a/star_lock/lib/mine/mineSet/transferSmartLock/recipientInformation/recipientInformation_entity.dart +++ b/star_lock/lib/mine/mineSet/transferSmartLock/recipientInformation/recipientInformation_entity.dart @@ -27,7 +27,7 @@ class RecipientInformationEntity { } class RecipientInformationData { - String? uid; + int? uid; String? nickname; String? headUrl; String? userid; diff --git a/star_lock/lib/mine/mineSet/transferSmartLock/recipientInformation/recipientInformation_page.dart b/star_lock/lib/mine/mineSet/transferSmartLock/recipientInformation/recipientInformation_page.dart index b6818828..4365d8e1 100644 --- a/star_lock/lib/mine/mineSet/transferSmartLock/recipientInformation/recipientInformation_page.dart +++ b/star_lock/lib/mine/mineSet/transferSmartLock/recipientInformation/recipientInformation_page.dart @@ -292,7 +292,7 @@ class _RecipientInformationPageState extends State { return Center( child: Container( width: 400.w, - height: 370.h, + height: 400.h, color: Colors.white, child: Column( children: [ diff --git a/star_lock/lib/mine/mineSet/transferSmartLock/transferSmartLockList/transferSmartLock_page.dart b/star_lock/lib/mine/mineSet/transferSmartLock/transferSmartLockList/transferSmartLock_page.dart index b189006b..288240e7 100644 --- a/star_lock/lib/mine/mineSet/transferSmartLock/transferSmartLockList/transferSmartLock_page.dart +++ b/star_lock/lib/mine/mineSet/transferSmartLock/transferSmartLockList/transferSmartLock_page.dart @@ -66,7 +66,7 @@ class _TransferSmartLockPageState extends State { onRefresh: (){ getHttpData(); }, - child: Column( + child: Obx(() => state.transferSmartLockListData.value.isNotEmpty ? Column( children: [ // KeySearchWidget( // editingController: state.searchController, @@ -80,13 +80,13 @@ class _TransferSmartLockPageState extends State { _buildNextBtn(), SizedBox(height: 64.h) ], - ), + ): NoData()), ), ); } Widget _buildMainUI() { - return Obx(() => state.transferSmartLockListData.value.isNotEmpty ? ListView.separated( + return ListView.separated( itemCount: state.transferSmartLockListData.value.length, separatorBuilder: (context, index) { return Divider( @@ -107,7 +107,7 @@ class _TransferSmartLockPageState extends State { } }); }); - }): NoData()); + }); } Widget _electronicKeyItem(TransferSmartLockItemData transferSmartLockItemData, Function() action) { diff --git a/star_lock/lib/network/api.dart b/star_lock/lib/network/api.dart index b9f99203..ac04ac88 100644 --- a/star_lock/lib/network/api.dart +++ b/star_lock/lib/network/api.dart @@ -147,6 +147,10 @@ abstract class Api { final String updateAdministratorURL = '/authorizedAdmin/update'; //管理员姓名/有效期/远程开锁修改 final String expireLockListURL = '/keyUser/listExpireUser'; //即将到期的锁列表 + final String expirePasswordListURL = '/keyUser/listExpirePwd'; //即将到期的密码列表 + final String expireCardListURL = '/keyUser/listExpireCard'; //即将到期的卡列表 + final String expireFingerprintListURL = '/keyUser/listExpireFingerprint'; //即将到期的指纹列表 + final String expireFaceListURL = '//keyUser/listExpireFace'; //即将到期的人脸列表 final String userSettingsInfoURL = '/user/userSettingsInfo'; //个人设置信息 final String setAlertModeURL = '/user/setAlertMode'; //提示音 final String setTouchUnlockFlagURL = '/user/setTouchUnlockFlag'; //触摸开锁 diff --git a/star_lock/lib/network/api_provider.dart b/star_lock/lib/network/api_provider.dart index 337fc2b1..3b09af3d 100644 --- a/star_lock/lib/network/api_provider.dart +++ b/star_lock/lib/network/api_provider.dart @@ -586,6 +586,34 @@ class ApiProvider extends BaseProvider { 'pageSize': pageSize, })); + Future expirePasswordList(String pageNo, String pageSize) => post( + expirePasswordListURL.toUrl, + jsonEncode({ + 'pageNo': pageNo, + 'pageSize': pageSize, + })); + + Future expireCardList(String pageNo, String pageSize) => post( + expireCardListURL.toUrl, + jsonEncode({ + 'pageNo': pageNo, + 'pageSize': pageSize, + })); + + Future expireFingerprintList(String pageNo, String pageSize) => post( + expireFingerprintListURL.toUrl, + jsonEncode({ + 'pageNo': pageNo, + 'pageSize': pageSize, + })); + + Future expireFaceList(String pageNo, String pageSize) => post( + expireFaceListURL.toUrl, + jsonEncode({ + 'pageNo': pageNo, + 'pageSize': pageSize, + })); + Future deleteKeyboardPwd( String lockId, String keyboardPwdId, int deleteType) => post( diff --git a/star_lock/lib/network/api_repository.dart b/star_lock/lib/network/api_repository.dart index 5f2662da..19c3cc07 100644 --- a/star_lock/lib/network/api_repository.dart +++ b/star_lock/lib/network/api_repository.dart @@ -17,7 +17,8 @@ import 'package:star_lock/mine/minePersonInfo/minePersonInfoViewSafetyProblem/mi import 'package:star_lock/mine/mineSet/appUnlockNeedMobileNetworkingLock/selectLockListEntity.dart'; import 'package:star_lock/mine/mineSet/authorizedAdministrator/administratorDetails/administratorDetailEntity.dart'; import 'package:star_lock/mine/mineSet/authorizedAdministrator/authorizedAdministrator/authorizedAdminListEntity.dart'; -import 'package:star_lock/mine/mineSet/lockUserManage/expireLockList/expireLockList_entity.dart'; +import 'package:star_lock/mine/mineSet/lockUserManage/expireLockList/expireElectronicKey/expireLockList_entity.dart'; +import 'package:star_lock/mine/mineSet/lockUserManage/expireLockList/expireFingerprint/expireFingerprint_entity.dart'; import 'package:star_lock/mine/mineSet/lockUserManage/lockUserManageList/keyListByUserEntity.dart'; import 'package:star_lock/mine/mineSet/mineSet/userSettingInfoEntity.dart'; import '../common/safetyVerification/entity/CheckSafetyVerificationEntity.dart'; @@ -45,6 +46,8 @@ import '../main/lockMian/entity/lockListInfo_entity.dart'; import '../mine/addLock/saveLock/entity/SaveLockEntity.dart'; import '../mine/message/messageList/messageList_entity.dart'; import '../mine/minePersonInfo/minePersonInfoPage/minePersonGetUploadFileInfo_entity.dart'; +import '../mine/mineSet/lockUserManage/expireLockList/expireCard/expireCard_entity.dart'; +import '../mine/mineSet/lockUserManage/expireLockList/expirePassword/expirePassword_entity.dart'; import '../mine/mineSet/transferGateway/selectGetewayList_entity.dart'; import '../mine/mineSet/transferSmartLock/recipientInformation/recipientInformation_entity.dart'; import '../mine/mineSet/transferSmartLock/transferSmartLockList/transferSmartLock_entity.dart'; @@ -586,13 +589,32 @@ class ApiRepository { return ElectronicKeyListEntity.fromJson(res.body); } - //即将到期的锁列表 + //即将到期的电子钥匙列表 Future expireLockList( String pageNo, String pageSize) async { final res = await apiProvider.expireLockList(pageNo, pageSize); return ExpireLockListEntity.fromJson(res.body); } + //即将到期的密码列表 + Future expirePasswordList( + String pageNo, String pageSize) async { + final res = await apiProvider.expirePasswordList(pageNo, pageSize); + return ExpirePasswordEntity.fromJson(res.body); + } + + //即将到期的卡列表 + Future expireCardList(String pageNo, String pageSize) async { + final res = await apiProvider.expireCardList(pageNo, pageSize); + return ExpireCardEntity.fromJson(res.body); + } + + //即将到期的指纹列表 + Future expireFingerprintList(String pageNo, String pageSize) async { + final res = await apiProvider.expireFingerprintList(pageNo, pageSize); + return ExpireFingerprintEntity.fromJson(res.body); + } + //删除密码 Future deleteKeyboardPwd( String lockId, String keyboardPwdId, int deleteType) async { diff --git a/star_lock/lib/tools/eventBusEventManage.dart b/star_lock/lib/tools/eventBusEventManage.dart index da944c40..d7c7dbe7 100644 --- a/star_lock/lib/tools/eventBusEventManage.dart +++ b/star_lock/lib/tools/eventBusEventManage.dart @@ -110,3 +110,8 @@ class DoorLockLogListRefreshUI { DateTime getDoorLockLogTime; DoorLockLogListRefreshUI(this.getDoorLockLogTime); } + +/// 刷新更多设置锁用户管理列表 +class LockUserManageListRefreshUI { + LockUserManageListRefreshUI(); +} diff --git a/star_lock/lib/tools/showTipView.dart b/star_lock/lib/tools/showTipView.dart index f2452782..c3a4cf43 100644 --- a/star_lock/lib/tools/showTipView.dart +++ b/star_lock/lib/tools/showTipView.dart @@ -93,4 +93,30 @@ class ShowTipView { ); } + void showIosTipWithContentDialog(String contentStr, Function sureClick) { + showCupertinoDialog( + context: Get.context!, + builder: (context) { + return CupertinoAlertDialog( + content: Text(contentStr), + actions: [ + CupertinoDialogAction( + child: Text(TranslationLoader.lanKeys!.cancel!.tr), + onPressed: () { + Get.back(); + }, + ), + CupertinoDialogAction( + child: Text(TranslationLoader.lanKeys!.sure!.tr), + onPressed: () { + Get.back(); + sureClick(); + }, + ), + ], + ); + }, + ); + } + } \ No newline at end of file diff --git a/star_lock/lib/tools/store_service.dart b/star_lock/lib/tools/store_service.dart index 9424a811..9f98430a 100644 --- a/star_lock/lib/tools/store_service.dart +++ b/star_lock/lib/tools/store_service.dart @@ -23,9 +23,9 @@ class StoreService extends GetxService { final String _deviceUUID = 'DEVICE_ID'; final String _languageCode = 'LANGUAGE_CODE'; - Object? getDeviceId() => hasData(_deviceUUID) ? read(_deviceUUID): ""; + String? getDeviceId() => hasData(_deviceUUID) ? read(_deviceUUID).toString(): ""; Future saveDeviceId(String uuid) => save(_deviceUUID, uuid); - Object? getLanguageCode() => hasData(_languageCode) ? read(_languageCode): ""; + String? getLanguageCode() => hasData(_languageCode) ? read(_languageCode).toString(): ""; Future saveLanguageCode(String code) => save(_languageCode, code); }