From 496145a6b343c513dd5a62490af585db2730f0b8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=AD=8F=E5=B0=91=E9=98=B3?= <786612630@qq.com> Date: Mon, 1 Apr 2024 16:21:46 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E4=BF=AE=E6=94=B9TAPD=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .idea/starLock.iml | 84 +++++++++++++++++++ star_lock/lib/blue/blue_manage.dart | 8 +- .../starLock_forgetPassword_page.dart | 2 +- .../card/cardDetail/cardDetail_logic.dart | 6 +- .../card/cardList/cardList_logic.dart | 2 +- .../otherTypeKeyChangeDate_logic.dart | 12 +-- .../fingerprintList_logic.dart | 2 +- .../lockDetail/lockDetail_logic.dart | 34 ++++---- .../lockDetail/lockDetail_page.dart | 32 +++---- .../lockDetail/lockDetail_state.dart | 4 +- .../basicInformation_page.dart | 19 ++++- .../lockSet/lockSet/lockSetInfo_entity.dart | 6 +- .../passwordKey_perpetual_page.dart | 5 ++ .../main/lockMian/lockList/lockList_page.dart | 35 ++++++-- .../main/lockMian/lockMain/lockMain_page.dart | 3 + star_lock/lib/tools/baseGetXController.dart | 5 +- 16 files changed, 197 insertions(+), 62 deletions(-) diff --git a/.idea/starLock.iml b/.idea/starLock.iml index 5164eec4..43102452 100644 --- a/.idea/starLock.iml +++ b/.idea/starLock.iml @@ -252,6 +252,90 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/star_lock/lib/blue/blue_manage.dart b/star_lock/lib/blue/blue_manage.dart index 995e847a..4eda5f68 100644 --- a/star_lock/lib/blue/blue_manage.dart +++ b/star_lock/lib/blue/blue_manage.dart @@ -559,9 +559,11 @@ class BlueManage { // 断开连接 Future disconnect() async { try { - connectDeviceMacAddress = ""; - await bluetoothConnectDevice!.disconnect(); - Get.log("断开连接成功"); + // if(bluetoothConnectDevice != null && bluetoothConnectDevice!.connectionState == BluetoothConnectionState.connected){ + connectDeviceMacAddress = ""; + await bluetoothConnectDevice!.disconnect(); + Get.log("断开连接成功"); + // } } on Exception catch (e, _) { Get.log("Error disconnecting from a device: $e"); } finally { diff --git a/star_lock/lib/login/forgetPassword/starLock_forgetPassword_page.dart b/star_lock/lib/login/forgetPassword/starLock_forgetPassword_page.dart index 0cc93a53..cf80fdd2 100644 --- a/star_lock/lib/login/forgetPassword/starLock_forgetPassword_page.dart +++ b/star_lock/lib/login/forgetPassword/starLock_forgetPassword_page.dart @@ -186,7 +186,7 @@ class _StarLockForgetPasswordPageState var result = await Navigator.pushNamed( context, Routers.safetyVerificationPage, arguments: { - "countryCode": "+86", + "countryCode": "86", "account": state.phoneStr.value }); logic.state.xWidth.value = diff --git a/star_lock/lib/main/lockDetail/card/cardDetail/cardDetail_logic.dart b/star_lock/lib/main/lockDetail/card/cardDetail/cardDetail_logic.dart index f40f54cd..9b188733 100644 --- a/star_lock/lib/main/lockDetail/card/cardDetail/cardDetail_logic.dart +++ b/star_lock/lib/main/lockDetail/card/cardDetail/cardDetail_logic.dart @@ -144,8 +144,8 @@ class CardDetailLogic extends BaseGetXController{ cardId: state.keyId.value.toString(), lockId: state.fingerprintItemData.value.lockId.toString(), weekDay: state.weekDay.value, - startDate: state.starDate.value, - endDate: state.endDate.value, + startDate: state.starDate.value*1000, + endDate: state.endDate.value*1000, isCoerced: state.isStressFingerprint.value ? "2" : "1", cardName: state.changeNameController.text, changeType: "1", @@ -182,7 +182,7 @@ class CardDetailLogic extends BaseGetXController{ }else if(state.keyType.value == 2){ useDateStr = "${DateTool().dateToYMDHNString(state.starDate.value)}\n${DateTool().dateToYMDHNString(state.endDate.value)}"; } else if(state.keyType.value == 4){ - useDateStr = "${DateTool().dateToYMDString(state.starDate.value)}-${DateTool().dateToYMDString(state.endDate.value)}"; + useDateStr = "${DateTool().dateToYMDString(state.starDate.value)}\n${DateTool().dateToYMDString(state.endDate.value)}"; } return useDateStr; } diff --git a/star_lock/lib/main/lockDetail/card/cardList/cardList_logic.dart b/star_lock/lib/main/lockDetail/card/cardList/cardList_logic.dart index 24f85514..7b6525e8 100644 --- a/star_lock/lib/main/lockDetail/card/cardList/cardList_logic.dart +++ b/star_lock/lib/main/lockDetail/card/cardList/cardList_logic.dart @@ -372,7 +372,7 @@ class CardListLogic extends BaseGetXController { }else if(fingerprintItemData.cardType! == 2){ keyDateTypeStr = "${DateTool().dateToYMDHNString(fingerprintItemData.startDate.toString())} - ${DateTool().dateToYMDHNString(fingerprintItemData.endDate.toString())} 限时"; }else if(fingerprintItemData.cardType! == 4){ - keyDateTypeStr = "循环"; + keyDateTypeStr = "${DateTool().dateToYMDString(fingerprintItemData.startDate.toString())}-${DateTool().dateToYMDString(fingerprintItemData.endDate.toString())} 循环"; } return keyDateTypeStr; } diff --git a/star_lock/lib/main/lockDetail/card/otherTypeKeyChangeDate/otherTypeKeyChangeDate_logic.dart b/star_lock/lib/main/lockDetail/card/otherTypeKeyChangeDate/otherTypeKeyChangeDate_logic.dart index 6cb48f87..183bac90 100644 --- a/star_lock/lib/main/lockDetail/card/otherTypeKeyChangeDate/otherTypeKeyChangeDate_logic.dart +++ b/star_lock/lib/main/lockDetail/card/otherTypeKeyChangeDate/otherTypeKeyChangeDate_logic.dart @@ -11,14 +11,14 @@ class OtherTypeKeyChangeDateLogic extends BaseGetXController{ // 修改指纹信息 void editFingerprintsData() async{ - var beginTimeTimestamp = DateTool().dateToTimestamp(state.beginTime.value, 1) ~/ 1000; - var endTimeTimestamp = DateTool().dateToTimestamp(state.endTime.value, 1) ~/ 1000; + var beginTimeTimestamp = DateTool().dateToTimestamp(state.beginTime.value, 1); + var endTimeTimestamp = DateTool().dateToTimestamp(state.endTime.value, 1); if (beginTimeTimestamp > endTimeTimestamp || beginTimeTimestamp == endTimeTimestamp) { showToast("失效时间需大于生效时间"); return; } - if (endTimeTimestamp < DateTime.now().millisecondsSinceEpoch ~/ 1000) { + if (endTimeTimestamp < DateTime.now().millisecondsSinceEpoch) { showToast("生效时间需大于当前时间"); return; } @@ -48,14 +48,14 @@ class OtherTypeKeyChangeDateLogic extends BaseGetXController{ // 编辑iC卡 void editICCardData() async{ - var beginTimeTimestamp = DateTool().dateToTimestamp(state.beginTime.value, 1) ~/ 1000; - var endTimeTimestamp = DateTool().dateToTimestamp(state.endTime.value, 1) ~/ 1000; + var beginTimeTimestamp = DateTool().dateToTimestamp(state.beginTime.value, 1); + var endTimeTimestamp = DateTool().dateToTimestamp(state.endTime.value, 1); if (beginTimeTimestamp > endTimeTimestamp || beginTimeTimestamp == endTimeTimestamp) { showToast("失效时间需大于生效时间"); return; } - if (endTimeTimestamp < DateTime.now().millisecondsSinceEpoch ~/ 1000) { + if (endTimeTimestamp < DateTime.now().millisecondsSinceEpoch) { showToast("生效时间需大于当前时间"); return; } diff --git a/star_lock/lib/main/lockDetail/fingerprint/fingerprintList/fingerprintList_logic.dart b/star_lock/lib/main/lockDetail/fingerprint/fingerprintList/fingerprintList_logic.dart index d5f67f08..cdcc484f 100644 --- a/star_lock/lib/main/lockDetail/fingerprint/fingerprintList/fingerprintList_logic.dart +++ b/star_lock/lib/main/lockDetail/fingerprint/fingerprintList/fingerprintList_logic.dart @@ -405,7 +405,7 @@ class FingerprintListLogic extends BaseGetXController{ }else if(fingerprintItemData.fingerprintType! == 2){ keyDateTypeStr = "${DateTool().dateToYMDHNString(fingerprintItemData.startDate.toString())} - ${DateTool().dateToYMDHNString(fingerprintItemData.endDate.toString())} 限时"; }else if(fingerprintItemData.fingerprintType! == 4){ - keyDateTypeStr = "循环"; + keyDateTypeStr = "${DateTool().dateToYMDString(fingerprintItemData.startDate.toString())}-${DateTool().dateToYMDString(fingerprintItemData.endDate.toString())} 循环"; } return keyDateTypeStr; } diff --git a/star_lock/lib/main/lockDetail/lockDetail/lockDetail_logic.dart b/star_lock/lib/main/lockDetail/lockDetail/lockDetail_logic.dart index cbd7a8e6..b6e3d0ee 100644 --- a/star_lock/lib/main/lockDetail/lockDetail/lockDetail_logic.dart +++ b/star_lock/lib/main/lockDetail/lockDetail/lockDetail_logic.dart @@ -117,7 +117,7 @@ class LockDetailLogic extends BaseGetXController { IoSenderManage.senderOpenLock( keyID: BlueManage().connectDeviceName, userID: await Storage.getUid(), - openMode: 1, + openMode: state.openDoorModel, openTime: DateTime.now().millisecondsSinceEpoch ~/ 1000, onlineToken: state.lockNetToken, token: tokenData, @@ -323,12 +323,12 @@ class LockDetailLogic extends BaseGetXController { state.lockUserNo = reply.data[47]; _updateLockUserNo(); - if (state.isOpenLockNeedOnline.value == 0) { - openDoorAction(1); - } else { - getLockNetToken(); - } - eventBus.fire(RefreshLockDetailInfoDataEvent()); + // if (state.isOpenLockNeedOnline.value == 0) { + // openDoorAction(1); + // } else { + // getLockNetToken(); + // } + // eventBus.fire(RefreshLockDetailInfoDataEvent()); // clickPushBtnAction(); break; case 0x06: @@ -428,7 +428,7 @@ class LockDetailLogic extends BaseGetXController { } // 点击开门事件 - Future openDoorAction(int openMode) async { + Future openDoorAction() async { showBlueConnetctToastTimer(action: () { state.openLockBtnState.value = 0; BlueManage().stopScan(); @@ -456,7 +456,7 @@ class LockDetailLogic extends BaseGetXController { // privateKey: getPrivateKeyList, // ); - Get.log("openMode:$openMode"); + Get.log("openMode:${state.openDoorModel}"); BlueManage() .bludSendData(state.keyInfos.value.bluetooth!.bluetoothDeviceName!, (BluetoothConnectionState deviceConnectionState) async { @@ -464,7 +464,7 @@ class LockDetailLogic extends BaseGetXController { IoSenderManage.senderOpenLock( keyID: BlueManage().connectDeviceName, userID: await Storage.getUid(), - openMode: openMode, + openMode: state.openDoorModel, openTime: DateTime.now().millisecondsSinceEpoch ~/ 1000, onlineToken: state.lockNetToken, token: getTokenList, @@ -647,7 +647,7 @@ class LockDetailLogic extends BaseGetXController { if (entity.errorCode!.codeIsSuccessful) { state.lockNetToken = entity.data!.token!; Get.log("state.lockNetToken:${state.lockNetToken}"); - openDoorAction(1); + openDoorAction(); } } @@ -657,11 +657,15 @@ class LockDetailLogic extends BaseGetXController { keyId: state.keyInfos.value.keyId.toString(), lockUserNo: state.lockUserNo.toString()); if (entity.errorCode!.codeIsSuccessful) { - if (state.isOpenLockNeedOnline.value == 0) { - state.bottomBtnisEable.value = true; - eventBus.fire(RefreshLockDetailInfoDataEvent()); + // state.keyInfos.value.lockUserNo = state.lockUserNo; + // state.bottomBtnisEable.value = true; + // print("state.bottomBtnisEable.value:${state.bottomBtnisEable.value} state.keyInfos.value.lockUserNo:${state.keyInfos.value.lockUserNo}"); + eventBus.fire(RefreshLockDetailInfoDataEvent()); + SchedulerBinding.instance.addPostFrameCallback((_) { eventBus.fire(RefreshLockListInfoDataEvent()); - openDoorAction(1); + }); + if (state.isOpenLockNeedOnline.value == 0) { + openDoorAction(); } else { getLockNetToken(); } diff --git a/star_lock/lib/main/lockDetail/lockDetail/lockDetail_page.dart b/star_lock/lib/main/lockDetail/lockDetail/lockDetail_page.dart index 9cee013e..c6988dd0 100644 --- a/star_lock/lib/main/lockDetail/lockDetail/lockDetail_page.dart +++ b/star_lock/lib/main/lockDetail/lockDetail/lockDetail_page.dart @@ -71,16 +71,12 @@ class _LockDetailPageState extends State StreamSubscription? _lockRefreshLockDetailInfoDataEvent; void _initRefreshLockDetailInfoDataEventAction() { // 蓝牙协议通知传输跟蓝牙之外的数据传输类不一样 eventBus - _lockRefreshLockDetailInfoDataEvent = - eventBus.on().listen((event) { + _lockRefreshLockDetailInfoDataEvent = eventBus.on().listen((event) { setState(() {}); }); } void loadData() { - // print("widget.lockListInfoItemEntity.lockUserNo:${widget.lockListInfoItemEntity.lockUserNo}"); - // print("state.lockUserNo:${state.lockUserNo}"); - state.keyInfos.value = widget.lockListInfoItemEntity; state.lockUserNo = state.keyInfos.value.lockUserNo!; if (state.lockUserNo == 0) { @@ -146,10 +142,7 @@ class _LockDetailPageState extends State visible: ((state.keyInfos.value.keyType == XSConstantMacro.keyTypeTime || state.keyInfos.value.keyType == XSConstantMacro.keyTypeLoop) && // 限时、循环 (DateTool().compareTimeGetDaysFromNow(state.keyInfos.value.endDate!) <= 15 && DateTool().compareTimeGetDaysFromNow(state.keyInfos.value.endDate!) >= 0) && // 0到30天 - (state.keyInfos.value.keyStatus == - XSConstantMacro.keyStatusNormalUse || - state.keyInfos.value.keyStatus == - XSConstantMacro.keyStatusWaitReceive) // 正常使用、待接收 + (state.keyInfos.value.keyStatus == XSConstantMacro.keyStatusNormalUse || state.keyInfos.value.keyStatus == XSConstantMacro.keyStatusWaitReceive) // 正常使用、待接收 ) ? true : false, @@ -188,7 +181,7 @@ class _LockDetailPageState extends State controller: state.pageController, // child: Row( children: [ - bottomWidget(), + Obx(() => bottomWidget()), attachmentWidget(), ], // ), @@ -272,16 +265,11 @@ class _LockDetailPageState extends State Row( mainAxisAlignment: MainAxisAlignment.end, children: [ - Image.asset(showElectricIcon(state.electricQuantity.value), - width: 30.w, height: 24.w), + Image.asset(showElectricIcon(state.electricQuantity.value), width: 30.w, height: 24.w), SizedBox(width: 2.w), - Text("--%", - style: TextStyle( - fontSize: 18.sp, - color: AppColors.darkGrayTextColor)), + Text("--%", style: TextStyle(fontSize: 18.sp, color: AppColors.darkGrayTextColor)), SizedBox(width: 2.w), - Icon( - Icons.info, // 使用内置的 warning 图标,它是一个叹号 + Icon(Icons.info, // 使用内置的 warning 图标,它是一个叹号 color: AppColors.mainColor, // 设置图标颜色为红色 size: 25.w, // 设置图标大小为 30 ), @@ -949,7 +937,9 @@ class _LockDetailPageState extends State // print("state.isOpenLockNeedOnline.value:${state.isOpenLockNeedOnline.value}"); if (state.isOpenLockNeedOnline.value == 0) { // 不需要联网 - logic.openDoorAction(1); + print("开锁开锁开锁开锁开锁开锁开锁开锁"); + state.openDoorModel = 1; + logic.openDoorAction(); } else { // 需要联网 logic.getLockNetToken(); @@ -971,7 +961,9 @@ class _LockDetailPageState extends State // 电子钥匙lockUserNo为0 要先添加用户 logic.addUserConnectBlue(); } else { - logic.openDoorAction(32); + print("闭锁闭锁闭锁闭锁闭锁闭锁闭锁闭锁"); + state.openDoorModel = 32; + logic.openDoorAction(); } } diff --git a/star_lock/lib/main/lockDetail/lockDetail/lockDetail_state.dart b/star_lock/lib/main/lockDetail/lockDetail/lockDetail_state.dart index bb13da46..4ccd21c1 100644 --- a/star_lock/lib/main/lockDetail/lockDetail/lockDetail_state.dart +++ b/star_lock/lib/main/lockDetail/lockDetail/lockDetail_state.dart @@ -22,7 +22,7 @@ class LockDetailState { StreamSubscription? lockSetOpenOrCloseCheckInRefreshLockDetailWithAttendanceEvent; String lockNetToken = ""; - var lockUserNo = 0; + int lockUserNo = 0; var senderUserId = 0; var isOnlyOneData = false; @@ -42,6 +42,8 @@ class LockDetailState { var bottomBtnisEable = true.obs; // 是否不可用 用于限制底部按钮是否可用 var openDoorBtnisUneable = true.obs; // 当钥匙状态不能使用的情况下开锁按钮禁止使用,默认可用 + var openDoorModel = 0; + //过渡动画控制器 AnimationController? animationController; // var lockState = 0.obs;// 0未连接普通状态 1连接开锁中(展示动画) 2已连接开锁成功 3检测可用性 4连接失败 5连接失败重连中 diff --git a/star_lock/lib/main/lockDetail/lockSet/basicInformation/basicInformation/basicInformation_page.dart b/star_lock/lib/main/lockDetail/lockSet/basicInformation/basicInformation/basicInformation_page.dart index 901440e1..f236ea0b 100644 --- a/star_lock/lib/main/lockDetail/lockSet/basicInformation/basicInformation/basicInformation_page.dart +++ b/star_lock/lib/main/lockDetail/lockSet/basicInformation/basicInformation/basicInformation_page.dart @@ -1,6 +1,7 @@ import 'package:flutter/material.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:get/get.dart'; +import 'package:star_lock/tools/dateTool.dart'; import '../../../../../appRouters.dart'; import '../../../../../app_settings/app_colors.dart'; @@ -71,7 +72,23 @@ class _BasicInformationPageState extends State { state.lockBasicInfo.value.endDate, state.lockBasicInfo.value.keyType), allHeight: 70.h, - isHaveLine: false)), + isHaveLine: true)), + Obx(() => Visibility( + visible: state.lockBasicInfo.value.keyType == 4 ? true : false, + child: CommonItem( + leftTitel: "有效日".tr, + rightTitle: state.lockBasicInfo.value!.weekDays!.join(",").toString(), + allHeight: 70.h, + isHaveLine: true), + )), + Obx(() => Visibility( + visible: state.lockBasicInfo.value.keyType == 4 ? true : false, + child: CommonItem( + leftTitel: "有效时间", + rightTitle: "${DateTool().dateToHNString(state.lockBasicInfo.value.startDate.toString())}-${DateTool().dateToHNString(state.lockBasicInfo.value.endDate.toString())}", + allHeight: 70.h, + isHaveLine: true), + )), SizedBox(height: 10.h), Obx(() => Visibility( visible: (state.lockBasicInfo.value.isLockOwner == 1 || diff --git a/star_lock/lib/main/lockDetail/lockSet/lockSet/lockSetInfo_entity.dart b/star_lock/lib/main/lockDetail/lockSet/lockSet/lockSetInfo_entity.dart index a341a000..f0bb3197 100644 --- a/star_lock/lib/main/lockDetail/lockSet/lockSet/lockSetInfo_entity.dart +++ b/star_lock/lib/main/lockDetail/lockSet/lockSet/lockSetInfo_entity.dart @@ -334,6 +334,7 @@ class LockBasicInfo { int? keyRight; int? senderUserId; int? lockUserNo; + List? weekDays; LockBasicInfo( {this.lockId, @@ -355,7 +356,8 @@ class LockBasicInfo { this.mac, this.keyRight, this.senderUserId, - this.lockUserNo}); + this.lockUserNo, + this.weekDays}); LockBasicInfo.fromJson(Map json) { lockId = json['lockId']; @@ -383,6 +385,7 @@ class LockBasicInfo { keyRight = json['keyRight']; senderUserId = json['senderUserId']; lockUserNo = json['lockUserNo']; + weekDays = json['weekDays']; } Map toJson() { @@ -409,6 +412,7 @@ class LockBasicInfo { data['keyRight'] = keyRight; data['senderUserId'] = senderUserId; data['lockUserNo'] = lockUserNo; + data['weekDays'] = weekDays; return data; } } diff --git a/star_lock/lib/main/lockDetail/passwordKey/passwordKey_perpetual/passwordKey_perpetual_page.dart b/star_lock/lib/main/lockDetail/passwordKey/passwordKey_perpetual/passwordKey_perpetual_page.dart index b13aa194..aef2a045 100644 --- a/star_lock/lib/main/lockDetail/passwordKey/passwordKey_perpetual/passwordKey_perpetual_page.dart +++ b/star_lock/lib/main/lockDetail/passwordKey/passwordKey_perpetual/passwordKey_perpetual_page.dart @@ -448,6 +448,11 @@ class _PasswordKeyPerpetualPageState extends State wit } } + if (state.pwdController.text.length < 6 || state.pwdController.text.length > 9) { + logic.showToast("请输入6-9位数字密码"); + return; + } + logic.senderCustomPasswords(); } else { if (state.nameController.text.isEmpty) { diff --git a/star_lock/lib/main/lockMian/lockList/lockList_page.dart b/star_lock/lib/main/lockMian/lockList/lockList_page.dart index 7aacf070..9e0ef8f2 100644 --- a/star_lock/lib/main/lockMian/lockList/lockList_page.dart +++ b/star_lock/lib/main/lockMian/lockList/lockList_page.dart @@ -99,14 +99,29 @@ class _LockListPageState extends State { } // print("lockItemList.length:${lockItemList.length} == ${index+1} $isLast"); return lockInfoListItem(keyInfo, isLast, () { - if(DateTool().compareTimeIsOvertime(keyInfo.endDate!) && keyInfo.keyType == XSConstantMacro.keyTypeTime){ - logic.showToast("钥匙已过期"); - return; - } + // if(DateTool().compareTimeIsOvertime(keyInfo.endDate!) && keyInfo.keyType == XSConstantMacro.keyTypeTime){ + // logic.showToast("钥匙已过期"); + // return; + // } + // var lockCount = 0; // for(GroupList itemData in groupDataList){ // lockCount+=itemData.lockList!.length; // } + + // || keyInfo.keyStatus == XSConstantMacro.keyStatusFrozen || keyInfo.keyStatus == XSConstantMacro.keyStatusExpired + if((keyInfo.keyType == XSConstantMacro.keyTypeTime || keyInfo.keyType == XSConstantMacro.keyTypeLoop) && (keyInfo.keyStatus == XSConstantMacro.keyStatusWaitIneffective)){ + logic.showToast("您的钥匙未生效"); + return; + } + if((keyInfo.keyType == XSConstantMacro.keyTypeTime || keyInfo.keyType == XSConstantMacro.keyTypeLoop) && (keyInfo.keyStatus == XSConstantMacro.keyStatusFrozen)){ + logic.showToast("您的钥匙已冻结"); + return; + } + if((keyInfo.keyType == XSConstantMacro.keyTypeTime || keyInfo.keyType == XSConstantMacro.keyTypeLoop) && (keyInfo.keyStatus == XSConstantMacro.keyStatusExpired)){ + logic.showToast("您的钥匙已过期"); + return; + } Get.toNamed(Routers.lockDetailMainPage, arguments: { // "lockMainEntity": widget.lockMainEntity, "keyInfo": keyInfo, @@ -124,7 +139,9 @@ class _LockListPageState extends State { // height: 122.h, margin: isLast ? EdgeInsets.only(left: 20.w, right: 20.w, top: 20.w, bottom: 20.w) : EdgeInsets.only(left: 20.w, right: 20.w, top: 20.w), decoration: BoxDecoration( - color: (DateTool().compareTimeIsOvertime(keyInfo.endDate!) && keyInfo.keyType == XSConstantMacro.keyTypeTime) ? AppColors.greyBackgroundColor : Colors.white, + color: ((keyInfo.keyType == XSConstantMacro.keyTypeTime || keyInfo.keyType == XSConstantMacro.keyTypeLoop) && + (keyInfo.keyStatus == XSConstantMacro.keyStatusWaitIneffective || keyInfo.keyStatus == XSConstantMacro.keyStatusFrozen || keyInfo.keyStatus == XSConstantMacro.keyStatusExpired)) + ? AppColors.greyBackgroundColor : Colors.white, borderRadius: BorderRadius.circular(20.w), ), child: Column( @@ -194,7 +211,11 @@ class _LockListPageState extends State { )), SizedBox(height: 20.h), Visibility( - visible: ((keyInfo.keyType == XSConstantMacro.keyTypeTime || keyInfo.keyType == XSConstantMacro.keyTypeLoop) && (DateTool().compareTimeGetDaysFromNow(keyInfo.endDate!) <= 15 && DateTool().compareTimeGetDaysFromNow(keyInfo.endDate!) >= 0)) ? true : false, + visible: ( + (keyInfo.keyType == XSConstantMacro.keyTypeTime || keyInfo.keyType == XSConstantMacro.keyTypeLoop) && + (keyInfo.keyStatus == XSConstantMacro.keyStatusWaitIneffective || keyInfo.keyStatus == XSConstantMacro.keyStatusFrozen || keyInfo.keyStatus == XSConstantMacro.keyStatusExpired)) + ? true + : false, // visible: true, child:Row( children: [ @@ -216,7 +237,7 @@ class _LockListPageState extends State { children: [ SizedBox(width: 30.w), Text( - "${logic.getUseKeyTypeStr(keyInfo.startDate, keyInfo.endDate, keyInfo.keyType)}/${keyInfo.isLockOwner == 1 ? '超级管理员' : (keyInfo.keyRight == 1 ? "授权管理员" : "普通用户")}", + "${logic.getUseKeyTypeStr(keyInfo.startDate, keyInfo.endDate, keyInfo.keyType)} ${keyInfo.isLockOwner == 1 ? '超级管理员' : (keyInfo.keyRight == 1 ? "授权管理员" : "普通用户")}", style: TextStyle( fontSize: 18.sp, color: AppColors.darkGrayTextColor), ), diff --git a/star_lock/lib/main/lockMian/lockMain/lockMain_page.dart b/star_lock/lib/main/lockMian/lockMain/lockMain_page.dart index f75b807f..b21a469a 100644 --- a/star_lock/lib/main/lockMian/lockMain/lockMain_page.dart +++ b/star_lock/lib/main/lockMian/lockMain/lockMain_page.dart @@ -47,6 +47,7 @@ class _StarLockMainPageState extends State with BaseWidget { void initState() { super.initState(); WidgetsBinding.instance!.addPostFrameCallback((_) { + logic.pageNo = 1; getHttpData(); }); @@ -235,8 +236,10 @@ class _StarLockMainPageState extends State with BaseWidget { late StreamSubscription _teamEvent; void _initLoadDataAction() { + print("监听刷新首页数据消息"); _teamEvent = eventBus.on().listen((event) { // getLockInfo(); + logic.pageNo = 1; getHttpData(); print("收到刷新首页数据消息"); }); diff --git a/star_lock/lib/tools/baseGetXController.dart b/star_lock/lib/tools/baseGetXController.dart index 3c941079..9b62f098 100644 --- a/star_lock/lib/tools/baseGetXController.dart +++ b/star_lock/lib/tools/baseGetXController.dart @@ -11,6 +11,7 @@ import 'package:url_launcher/url_launcher.dart'; import '../common/XSConstantMacro/XSConstantMacro.dart'; import 'NativeInteractionTool.dart'; +import 'dateTool.dart'; import 'manager/client_manager.dart'; import 'showIosTipView.dart'; @@ -172,7 +173,7 @@ class BaseGetXController extends GetxController { DateTime startDateStr = DateTime.fromMillisecondsSinceEpoch(startDate!); DateTime endDateStr = DateTime.fromMillisecondsSinceEpoch(endDate!); useDateStr = - '${startDateStr.toLocal().toString().substring(0, 16)} - ${endDateStr.toLocal().toString().substring(0, 16)}'; + '${startDateStr.toLocal().toString().substring(0, 16)}-${endDateStr.toLocal().toString().substring(0, 16)}'; } else if (keyType == XSConstantMacro.keyTypeLong) { //永久 // DateTime dateStr = DateTime.fromMillisecondsSinceEpoch(indexEntity.date!); @@ -185,7 +186,7 @@ class BaseGetXController extends GetxController { useDateStr = '单次'; } else if (keyType == XSConstantMacro.keyTypeLoop) { //循环 - useDateStr = '循环'; + useDateStr = "${DateTool().dateToYMDString(startDate.toString())}-${DateTool().dateToYMDString(endDate.toString())}"; } return useDateStr; From ec83557954182acf7a5d0a147246af63f68794b0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=AD=8F=E5=B0=91=E9=98=B3?= <786612630@qq.com> Date: Tue, 2 Apr 2024 17:30:44 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E8=80=83=E5=8B=A4?= =?UTF-8?q?=E3=80=81=E6=88=91=E7=9A=84=E6=A8=A1=E5=9D=97bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- star_lock/lib/appRouters.dart | 6 +- .../authorizedAdminManage_tabbar.dart | 7 +- .../authorizedAdmin_logic.dart | 21 +- .../authorizedAdmin/authorizedAdmin_page.dart | 2 +- .../authorizedAdminList_page.dart | 2 +- .../volumeAuthorizationLock_page.dart | 20 +- .../card/cardList/cardList_logic.dart | 15 + .../card/cardList/cardList_page.dart | 2 +- .../checkingInList/checkingInList_logic.dart | 14 + .../checkingInSet/checkingInSet_logic.dart | 18 +- .../checkingInSetWorkdaySet_logic.dart | 4 +- .../checkingInSetWorkdaySet_page.dart | 8 +- .../checkingInSetWorkdaySet_state.dart | 3 + .../checkingInAddStaff_logic.dart | 2 + .../checkingInStaffList_entity.dart | 6 +- .../checkingInStaffList_logic.dart | 3 +- .../checkingInStaffList_page.dart | 21 +- .../checkingInStaffDetail_page.dart | 4 +- .../electronicKeyDetail_logic.dart | 207 +++++++++-- .../electronicKeyDetail_page.dart | 10 +- .../electronicKeyList_logic.dart | 4 +- .../massSendElectronicKey_logic.dart | 123 +++++-- .../sendElectronicKey_logic.dart | 28 +- .../sendElectronicKey_page.dart | 2 +- .../fingerprintListData_entity.dart | 7 +- .../fingerprintList_logic.dart | 15 + .../fingerprintList/fingerprintList_page.dart | 11 +- .../lockDetail/lockDetail_page.dart | 11 +- .../adminOpenLockPassword_logic.dart | 8 +- .../passwordKeyList_logic.dart | 2 +- .../passwordKeyList/passwordKeyList_page.dart | 3 +- .../passwordKeyManage_page.dart | 11 +- .../passwordKeyManage_tabbar.dart | 11 +- .../main/lockMian/lockList/lockList_page.dart | 8 +- .../lib/mine/mine/starLockMine_logic.dart | 15 +- .../lib/mine/mine/starLockMine_page.dart | 2 +- ...addAuthorizedAdministratorManage_page.dart | 37 ++ ...dAuthorizedAdministratorManage_tabbar.dart | 117 +++++++ .../addAuthorizedAdministrator_logic.dart | 138 ++++---- .../addAuthorizedAdministrator_page.dart | 236 +++++++------ .../addAuthorizedAdministrator_state.dart | 16 +- .../administratorDetails_logic.dart | 188 ++++++++++ .../administratorDetails_page.dart | 141 ++------ .../administratorDetails_state.dart | 22 ++ .../authorizedAdminListEntity.dart | 6 +- .../authorizedAdministratorList_logic.dart | 107 ++++++ .../authorizedAdministratorList_page.dart | 324 +++++++----------- .../authorizedAdministratorList_state.dart | 10 + .../expireLockList_logic.dart | 4 +- star_lock/lib/network/api_provider.dart | 51 +-- star_lock/lib/network/api_repository.dart | 85 +++-- star_lock/lib/tools/baseGetXController.dart | 7 +- star_lock/lib/tools/custom_bottom_sheet.dart | 7 +- star_lock/lib/tools/eventBusEventManage.dart | 15 + ...eleteAdministratorIsHaveAllDataWidget.dart | 5 +- star_lock/lib/tools/showTipView.dart | 31 +- star_lock/pubspec.yaml | 2 +- 57 files changed, 1396 insertions(+), 789 deletions(-) rename star_lock/lib/main/lockDetail/passwordKey/{ => passwordKey_perpetual}/passwordKeyManage/passwordKeyManage_page.dart (79%) rename star_lock/lib/main/lockDetail/passwordKey/{ => passwordKey_perpetual}/passwordKeyManage/passwordKeyManage_tabbar.dart (91%) create mode 100644 star_lock/lib/mine/mineSet/authorizedAdministrator/addAuthorizedAdministrator/addAuthorizedAdministratorManage/addAuthorizedAdministratorManage_page.dart create mode 100644 star_lock/lib/mine/mineSet/authorizedAdministrator/addAuthorizedAdministrator/addAuthorizedAdministratorManage/addAuthorizedAdministratorManage_tabbar.dart create mode 100644 star_lock/lib/mine/mineSet/authorizedAdministrator/administratorDetails/administratorDetails_logic.dart create mode 100644 star_lock/lib/mine/mineSet/authorizedAdministrator/administratorDetails/administratorDetails_state.dart create mode 100644 star_lock/lib/mine/mineSet/authorizedAdministrator/authorizedAdministrator/authorizedAdministratorList_logic.dart create mode 100644 star_lock/lib/mine/mineSet/authorizedAdministrator/authorizedAdministrator/authorizedAdministratorList_state.dart diff --git a/star_lock/lib/appRouters.dart b/star_lock/lib/appRouters.dart index 8165b4e2..91b1675e 100644 --- a/star_lock/lib/appRouters.dart +++ b/star_lock/lib/appRouters.dart @@ -107,6 +107,7 @@ import 'main/lockDetail/lockSet/wirelessKeyboard/selectWirelessKeyboard/selectWi import 'main/lockDetail/lockSet/wirelessKeyboard/wirelessKeyboardList/wirelessKeyboard_page.dart'; import 'main/lockDetail/monitoring/monitoring/lockMonitoring_page.dart'; import 'main/lockDetail/monitoring/monitoringRealTimeScreen/monitoringRealTimeScreen_page.dart'; +import 'main/lockDetail/passwordKey/passwordKey_perpetual/passwordKeyManage/passwordKeyManage_page.dart'; import 'main/lockDetail/realTimePicture/realTimePicture_page.dart'; import 'main/lockDetail/remoteControl/addRemoteControl/addRemoteControlManage/addRemoteControlManage_page.dart'; import 'main/lockDetail/remoteControl/remoteControlList/remoteControlList_page.dart'; @@ -130,7 +131,6 @@ import 'main/lockDetail/electronicKey/sendEmailNotification/sendEmailNotificatio import 'main/lockDetail/lockOperatingRecord/lockOperatingRecord_page.dart'; import 'main/lockDetail/passwordKey/passwordKeyDetail/passwordKeyDetail_page.dart'; import 'main/lockDetail/passwordKey/passwordKeyList/passwordKeyList_page.dart'; -import 'main/lockDetail/passwordKey/passwordKeyManage/passwordKeyManage_page.dart'; import 'main/lockMian/lockMain/lockMain_page.dart'; import 'mine/addLock/addLockSelectCountry/addLockSelectCountry_page.dart'; import 'mine/addLock/lockAddress/gaode/lockAddressGaoDe_page.dart'; @@ -161,7 +161,7 @@ import 'mine/mineSet/appUnlockNeedMobileNetworkingLock/appUnlockNeedMobileNetwor import 'mine/mineSet/authorityManagement/authorityManagement_page.dart'; import 'mine/mineSet/authorityManagement/getDeviceList_page.dart'; import 'mine/mineSet/authorityManagement/getNameList_page.dart'; -import 'mine/mineSet/authorizedAdministrator/addAuthorizedAdministrator/addAuthorizedAdministrator_page.dart'; +import 'mine/mineSet/authorizedAdministrator/addAuthorizedAdministrator/addAuthorizedAdministratorManage/addAuthorizedAdministratorManage_page.dart'; import 'mine/mineSet/hideInvalidUnlockPermissions/hideInvalidUnlockPermissions_page.dart'; import 'mine/mineSet/lockGroup/groupEditLock/groupEditLock_page.dart'; import 'mine/mineSet/lockGroup/lockGroupDetailList/lockItemList_page.dart'; @@ -860,7 +860,7 @@ abstract class AppRouters { page: () => const MineBindPhoneOrEmailPage()), GetPage( name: Routers.addAuthorizedAdministratorPage, - page: () => const AddAuthorizedAdministratorPage()), + page: () => const AddAuthorizedAdministratorManagePage()), GetPage( name: Routers.safetyVerificationPage, page: () => const SafetyVerificationPage(), diff --git a/star_lock/lib/main/lockDetail/authorizedAdmin/authorizedAdmin/authorizedAdminManage/authorizedAdminManage_tabbar.dart b/star_lock/lib/main/lockDetail/authorizedAdmin/authorizedAdmin/authorizedAdminManage/authorizedAdminManage_tabbar.dart index ad81a669..47e36caf 100644 --- a/star_lock/lib/main/lockDetail/authorizedAdmin/authorizedAdmin/authorizedAdminManage/authorizedAdminManage_tabbar.dart +++ b/star_lock/lib/main/lockDetail/authorizedAdmin/authorizedAdmin/authorizedAdminManage/authorizedAdminManage_tabbar.dart @@ -11,17 +11,14 @@ import '../authorizedAdmin_page.dart'; class AuthorizedAdminManageTabbar extends StatefulWidget { var initialIndex = 1; - AuthorizedAdminManageTabbar({Key? key, required this.initialIndex}) - : super(key: key); + AuthorizedAdminManageTabbar({Key? key, required this.initialIndex}) : super(key: key); @override State createState() => _AuthorizedAdminManageTabbarState(); } -class _AuthorizedAdminManageTabbarState - extends State - with SingleTickerProviderStateMixin { +class _AuthorizedAdminManageTabbarState extends State with SingleTickerProviderStateMixin { late TabController _tabController; final List _itemTabs = [ diff --git a/star_lock/lib/main/lockDetail/authorizedAdmin/authorizedAdmin/authorizedAdmin_logic.dart b/star_lock/lib/main/lockDetail/authorizedAdmin/authorizedAdmin/authorizedAdmin_logic.dart index 84c5906a..30dab475 100644 --- a/star_lock/lib/main/lockDetail/authorizedAdmin/authorizedAdmin/authorizedAdmin_logic.dart +++ b/star_lock/lib/main/lockDetail/authorizedAdmin/authorizedAdmin/authorizedAdmin_logic.dart @@ -298,6 +298,7 @@ class AuthorizedAdminLogic extends BaseGetXController { } else { if (entity.errorCode == 425) { //用户未注册 + state.isCreateUser.value = true; _showDialog('${entity.errorMsg}'); } } @@ -320,7 +321,7 @@ class AuthorizedAdminLogic extends BaseGetXController { context: Get.context!, builder: (context) { return CupertinoAlertDialog( - title: const Text('接收者号码未注册,请选择号码所在的国家并重新发送'), + title: const Text('接收者号码未注册,请重新发送'), actions: [ CupertinoDialogAction( child: Text(TranslationLoader.lanKeys!.cancel!.tr), @@ -329,18 +330,18 @@ class AuthorizedAdminLogic extends BaseGetXController { }, ), CupertinoDialogAction( - child: Text(TranslationLoader.lanKeys!.select!.tr), + child: Text(TranslationLoader.lanKeys!.sure!.tr), onPressed: () async { //选择国家代码 - state.isCreateUser.value = true; - Navigator.of(context).pop(); + Get.back(); - var result = await Get.toNamed(Routers.selectCountryRegionPage); - if (result != null) { - result as Map; - state.countryCode.value = result['code']; - state.countryName.value = result['countryName']; - } + // var result = await Get.toNamed(Routers.selectCountryRegionPage); + // if (result != null) { + // result as Map; + // state.countryCode.value = result['code']; + // state.countryName.value = result['countryName']; + // } + sendElectronicKeyRequest(); }, ), ], diff --git a/star_lock/lib/main/lockDetail/authorizedAdmin/authorizedAdmin/authorizedAdmin_page.dart b/star_lock/lib/main/lockDetail/authorizedAdmin/authorizedAdmin/authorizedAdmin_page.dart index fd9ad3d1..aa15fe5a 100644 --- a/star_lock/lib/main/lockDetail/authorizedAdmin/authorizedAdmin/authorizedAdmin_page.dart +++ b/star_lock/lib/main/lockDetail/authorizedAdmin/authorizedAdmin/authorizedAdmin_page.dart @@ -175,7 +175,7 @@ class _AuthorizedAdminPageState extends State { rightTitle: "", isTipsImg: true, tipsImgAction: () { - ShowTipView().showSureAlertDialog("人脸实名认证指的是用户在使用手机APP或小程序开锁时,需要先进行本人人脸验证,验证通过才能开锁。"); + ShowTipView().showSureAlertDialog("人脸实名认证指的是用户在使用手机APP开锁时,需要先进行本人人脸验证,验证通过才能开锁。"); }, isHaveRightWidget: true, rightWidget: SizedBox(width: 60.w, height: 50.h, child: _switch()), diff --git a/star_lock/lib/main/lockDetail/authorizedAdmin/authorizedAdminList/authorizedAdminList_page.dart b/star_lock/lib/main/lockDetail/authorizedAdmin/authorizedAdminList/authorizedAdminList_page.dart index 5e0e9784..05a14171 100644 --- a/star_lock/lib/main/lockDetail/authorizedAdmin/authorizedAdminList/authorizedAdminList_page.dart +++ b/star_lock/lib/main/lockDetail/authorizedAdmin/authorizedAdminList/authorizedAdminList_page.dart @@ -126,7 +126,7 @@ class _AuthorizedAdminListPageState extends State { children: [ SlidableAction( onPressed: (BuildContext context){ - ShowTipView().showDeleteAdministratorIsHaveAllDataDialog((isAllData) { + ShowTipView().showDeleteAdministratorIsHaveAllDataDialog('同时删除其发送的所有钥匙,钥匙删除后不能恢复', (isAllData) { logic.deleteKeyRequest(indexEntity.keyId.toString(), isAllData ? 1 : 0); }); }, diff --git a/star_lock/lib/main/lockDetail/authorizedAdmin/volumeAuthorizationLock/volumeAuthorizationLock_page.dart b/star_lock/lib/main/lockDetail/authorizedAdmin/volumeAuthorizationLock/volumeAuthorizationLock_page.dart index 5a8191c0..99a6ffbe 100644 --- a/star_lock/lib/main/lockDetail/authorizedAdmin/volumeAuthorizationLock/volumeAuthorizationLock_page.dart +++ b/star_lock/lib/main/lockDetail/authorizedAdmin/volumeAuthorizationLock/volumeAuthorizationLock_page.dart @@ -333,16 +333,16 @@ class _VolumeAuthorizationLockPageState _effectiveDateTime.millisecondsSinceEpoch.toString(); } var entity = await ApiRepository.to.addAuthorizedAdmin( - _isCreateUser ? "1" : "0", - getFailureDateTime, - _isRemoteUnlock == true ? '1' : '2', - [], - _lockIdList, - _keyNameController.text, - getEffectiveDateTime, - _emailOrPhoneController.text, - countryCode, - '1', + createUser:_isCreateUser ? "1" : "0", + endDate:getFailureDateTime, + isRemoteUnlock:_isRemoteUnlock == true ? '1' : '2', + keyGroupIdList:[], + lockIdList:_lockIdList, + name:_keyNameController.text, + startDate:getEffectiveDateTime, + userid:_emailOrPhoneController.text, + countryCode:countryCode, + usernameType:'1', ); if (entity.errorCode!.codeIsSuccessful) { print('发送电子钥匙成功'); diff --git a/star_lock/lib/main/lockDetail/card/cardList/cardList_logic.dart b/star_lock/lib/main/lockDetail/card/cardList/cardList_logic.dart index 7b6525e8..844fc8e5 100644 --- a/star_lock/lib/main/lockDetail/card/cardList/cardList_logic.dart +++ b/star_lock/lib/main/lockDetail/card/cardList/cardList_logic.dart @@ -365,6 +365,21 @@ class CardListLogic extends BaseGetXController { }); } + String getKeyType(FingerprintItemData fingerprintItemData){ + // fingerprintStatus 1:正常 2:失效 + var keyTypeStr = "";// + // (fingerprintItemData.fingerprintType! != 1) ? (fingerprintItemData.endDate! < DateTime.now().millisecondsSinceEpoch ? "已失效" : "") : "" + if(fingerprintItemData.cardStatus == 1){ + if(fingerprintItemData.startDate! > DateTime.now().millisecondsSinceEpoch){ + keyTypeStr = "未生效"; + } + + }else if(fingerprintItemData.cardStatus == 2){ + keyTypeStr = "已失效"; + } + return keyTypeStr; + } + String getKeyDateType(FingerprintItemData fingerprintItemData){ var keyDateTypeStr = "";// 永久:1;限时2,单次3,循环:4 if(fingerprintItemData.cardType! == 1){ diff --git a/star_lock/lib/main/lockDetail/card/cardList/cardList_page.dart b/star_lock/lib/main/lockDetail/card/cardList/cardList_page.dart index c1b6aaf9..741dcdda 100644 --- a/star_lock/lib/main/lockDetail/card/cardList/cardList_page.dart +++ b/star_lock/lib/main/lockDetail/card/cardList/cardList_page.dart @@ -144,7 +144,7 @@ class _CardListPageState extends State with RouteAware { child: _keyItem( 'images/icon_card.png', fingerprintItemData.cardName!, - (fingerprintItemData.cardType! != 1) ? (fingerprintItemData.endDate! < DateTime.now().millisecondsSinceEpoch ? "已失效" : "") : "", + logic.getKeyType(fingerprintItemData), logic.getKeyDateType(fingerprintItemData), () async { var data = await Get.toNamed( Routers.cardDetailPage, arguments: { diff --git a/star_lock/lib/main/lockDetail/checkingIn/checkingInList/checkingInList_logic.dart b/star_lock/lib/main/lockDetail/checkingIn/checkingInList/checkingInList_logic.dart index e16e4fbc..3b3ef16a 100644 --- a/star_lock/lib/main/lockDetail/checkingIn/checkingInList/checkingInList_logic.dart +++ b/star_lock/lib/main/lockDetail/checkingIn/checkingInList/checkingInList_logic.dart @@ -1,8 +1,11 @@ +import 'dart:async'; + import 'package:star_lock/main/lockDetail/checkingIn/checkingInList/checkingInListDay_entity.dart'; import 'package:star_lock/tools/baseGetXController.dart'; import '../../../../network/api_repository.dart'; +import '../../../../tools/eventBusEventManage.dart'; import '../../../../tools/storage.dart'; import 'checkingInList_state.dart'; @@ -101,6 +104,13 @@ class CheckingInListLogic extends BaseGetXController{ } } + late StreamSubscription _teamEvent; + void _initLoadDataAction() { + _teamEvent = eventBus.on().listen((event) { + loadDataByType(); + }); + } + @override Future onReady() async { // TODO: implement onReady @@ -110,6 +120,8 @@ class CheckingInListLogic extends BaseGetXController{ // 获取是否是演示模式 演示模式不获取接口 var isDemoMode = await Storage.getBool(ifIsDemoModeOrNot); if(isDemoMode == false){ + _initLoadDataAction(); + openCheckingInData(); } } @@ -125,7 +137,9 @@ class CheckingInListLogic extends BaseGetXController{ @override void onClose() { // TODO: implement onClose + super.onClose(); + _teamEvent.cancel(); } } \ No newline at end of file diff --git a/star_lock/lib/main/lockDetail/checkingIn/checkingInSet/checkingInSet_logic.dart b/star_lock/lib/main/lockDetail/checkingIn/checkingInSet/checkingInSet_logic.dart index 8d93cd34..ec07ca77 100644 --- a/star_lock/lib/main/lockDetail/checkingIn/checkingInSet/checkingInSet_logic.dart +++ b/star_lock/lib/main/lockDetail/checkingIn/checkingInSet/checkingInSet_logic.dart @@ -1,4 +1,6 @@ +import 'dart:async'; + import 'package:get/get.dart'; import '../../../../network/api_repository.dart'; @@ -71,12 +73,12 @@ class CheckingInSetLogic extends BaseGetXController{ } } - // late StreamSubscription _teamEvent; - // void _initLoadDataAction() { - // _teamEvent = eventBus.on().listen((event) { - // getStaffList(); - // }); - // } + late StreamSubscription _teamEvent; + void _initLoadDataAction() { + _teamEvent = eventBus.on().listen((event) { + getCheckInSetInfoData(); + }); + } @override void onReady() { @@ -84,7 +86,7 @@ class CheckingInSetLogic extends BaseGetXController{ super.onReady(); print("onReady()"); - // _initLoadDataAction(); + _initLoadDataAction(); openCheckingInData(); } @@ -98,6 +100,6 @@ class CheckingInSetLogic extends BaseGetXController{ @override void onClose() { // TODO: implement onClose - // _teamEvent.cancel(); + _teamEvent.cancel(); } } \ No newline at end of file diff --git a/star_lock/lib/main/lockDetail/checkingIn/checkingInSetWorkdaySet/checkingInSetWorkdaySet_logic.dart b/star_lock/lib/main/lockDetail/checkingIn/checkingInSetWorkdaySet/checkingInSetWorkdaySet_logic.dart index 5c62e2c7..8ccc50ff 100644 --- a/star_lock/lib/main/lockDetail/checkingIn/checkingInSetWorkdaySet/checkingInSetWorkdaySet_logic.dart +++ b/star_lock/lib/main/lockDetail/checkingIn/checkingInSetWorkdaySet/checkingInSetWorkdaySet_logic.dart @@ -2,6 +2,7 @@ import 'package:get/get.dart'; import 'package:star_lock/tools/baseGetXController.dart'; import '../../../../network/api_repository.dart'; +import '../../../../tools/eventBusEventManage.dart'; import 'checkingInSetWorkdaySet_state.dart'; class CheckingInSetWorkdaySetLogic extends BaseGetXController{ @@ -12,7 +13,7 @@ class CheckingInSetWorkdaySetLogic extends BaseGetXController{ var entity = await ApiRepository.to.editCheckInSetInfoData( attendanceType: (state.isCustom.value == true) ? "0" : "1", companyId: state.checkingInSetInfo.value.companyId.toString(), - type: "2", + type: (state.isCustom.value == true) ? "3" : "4", companyName: state.checkingInSetInfo.value.companyName ?? "", workEndTime: state.checkingInSetInfo.value.workEndTime.toString(), workStartTime: state.checkingInSetInfo.value.workStartTime.toString(), @@ -20,6 +21,7 @@ class CheckingInSetWorkdaySetLogic extends BaseGetXController{ ); if(entity.errorCode!.codeIsSuccessful){ showToast("修改成功", something: (){ + eventBus.fire(RefreshCheckInSetDataEvent()); Get.back(result: { "attendanceType":state.isCustom.value, "weekDays":state.weekDays.value, diff --git a/star_lock/lib/main/lockDetail/checkingIn/checkingInSetWorkdaySet/checkingInSetWorkdaySet_page.dart b/star_lock/lib/main/lockDetail/checkingIn/checkingInSetWorkdaySet/checkingInSetWorkdaySet_page.dart index eaaf83b2..871c8fb7 100644 --- a/star_lock/lib/main/lockDetail/checkingIn/checkingInSetWorkdaySet/checkingInSetWorkdaySet_page.dart +++ b/star_lock/lib/main/lockDetail/checkingIn/checkingInSetWorkdaySet/checkingInSetWorkdaySet_page.dart @@ -200,7 +200,7 @@ class _CheckingInSetWorkdaySetState extends State { dateStr = ""; break; } - return CommonItem( + return Obx(() => CommonItem( leftTitel: dateStr, rightTitle: "", allHeight: 60.h, @@ -217,12 +217,12 @@ class _CheckingInSetWorkdaySetState extends State { state.weekDays.value.sort(); }); }, - rightWidget: Obx(() => Row( + rightWidget: Row( children: [ Image.asset(state.weekDays.value.contains(index) ? 'images/icon_round_select.png' : 'images/icon_round_unSelect.png', width: 30.w, height: 30.w,), ], - )) - ); + ) + )); } ), ); diff --git a/star_lock/lib/main/lockDetail/checkingIn/checkingInSetWorkdaySet/checkingInSetWorkdaySet_state.dart b/star_lock/lib/main/lockDetail/checkingIn/checkingInSetWorkdaySet/checkingInSetWorkdaySet_state.dart index a7f397e2..c6b4737d 100644 --- a/star_lock/lib/main/lockDetail/checkingIn/checkingInSetWorkdaySet/checkingInSetWorkdaySet_state.dart +++ b/star_lock/lib/main/lockDetail/checkingIn/checkingInSetWorkdaySet/checkingInSetWorkdaySet_state.dart @@ -12,6 +12,8 @@ class CheckingInSetWorkdaySetState{ final checkingInSetInfo = CheckingInSetInfo().obs; final companyId = "".obs; + // var changeType = "3".obs;// 3修改workDay自定义 4修改workDay + var pushType = "".obs;// 2考勤设置信息 1考勤创建公司 CheckingInSetWorkdaySetState() { @@ -24,6 +26,7 @@ class CheckingInSetWorkdaySetState{ weekDays.value = checkingInSetInfo.value.workDay!; isCustom.value = (checkingInSetInfo.value.attendanceType! == 0) ? true : false; + Get.log("weekDays: $weekDays checkingInSetInfo.value.workDay!: ${checkingInSetInfo.value.workDay!} checkingInSetInfo.value.attendanceType!: ${checkingInSetInfo.value.attendanceType!}"); if(isCustom.value == false){ if(checkingInSetInfo.value.workDay!.length == 5){ isSingledayWeekend.value = 1; diff --git a/star_lock/lib/main/lockDetail/checkingIn/checkingInStaff/checkingInSetAddStaff/checkingInAddStaff_logic.dart b/star_lock/lib/main/lockDetail/checkingIn/checkingInStaff/checkingInSetAddStaff/checkingInAddStaff_logic.dart index 305c5d6e..7a73d4d0 100644 --- a/star_lock/lib/main/lockDetail/checkingIn/checkingInStaff/checkingInSetAddStaff/checkingInAddStaff_logic.dart +++ b/star_lock/lib/main/lockDetail/checkingIn/checkingInStaff/checkingInSetAddStaff/checkingInAddStaff_logic.dart @@ -45,6 +45,8 @@ class CheckingInAddStaffLogic extends BaseGetXController{ usernameType:usernameType, ); if(entity.errorCode!.codeIsSuccessful){ + eventBus.fire(RefreshCheckInSetDataEvent()); + eventBus.fire(RefreshCheckInListEvent()); Get.back(result: "addScuess"); }else if(entity.errorCode! == 425){ showToast(entity.errorMsg!); diff --git a/star_lock/lib/main/lockDetail/checkingIn/checkingInStaff/checkingInSetStaffList/checkingInStaffList_entity.dart b/star_lock/lib/main/lockDetail/checkingIn/checkingInStaff/checkingInSetStaffList/checkingInStaffList_entity.dart index 394e3866..46effbe5 100644 --- a/star_lock/lib/main/lockDetail/checkingIn/checkingInStaff/checkingInSetStaffList/checkingInStaffList_entity.dart +++ b/star_lock/lib/main/lockDetail/checkingIn/checkingInStaff/checkingInSetStaffList/checkingInStaffList_entity.dart @@ -39,6 +39,7 @@ class CheckingInAddStaffListItemEntity { int? countryCode; int? cardStatus; String? attendanceWay; + String? reason; CheckingInAddStaffListItemEntity( {this.headurl, @@ -47,7 +48,8 @@ class CheckingInAddStaffListItemEntity { this.attendanceType, this.countryCode, this.cardStatus, - this.attendanceWay}); + this.attendanceWay, + this.reason}); CheckingInAddStaffListItemEntity.fromJson(Map json) { headurl = json['headurl']; @@ -57,6 +59,7 @@ class CheckingInAddStaffListItemEntity { countryCode = json['countryCode']; cardStatus = json['cardStatus']; attendanceWay = json['attendanceWay']; + reason = json['reason']; } Map toJson() { @@ -68,6 +71,7 @@ class CheckingInAddStaffListItemEntity { data['countryCode'] = countryCode; data['cardStatus'] = cardStatus; data['attendanceWay'] = attendanceWay; + data['reason'] = reason; return data; } } \ No newline at end of file diff --git a/star_lock/lib/main/lockDetail/checkingIn/checkingInStaff/checkingInSetStaffList/checkingInStaffList_logic.dart b/star_lock/lib/main/lockDetail/checkingIn/checkingInStaff/checkingInSetStaffList/checkingInStaffList_logic.dart index 5f1ab458..af93f6d1 100644 --- a/star_lock/lib/main/lockDetail/checkingIn/checkingInStaff/checkingInSetStaffList/checkingInStaffList_logic.dart +++ b/star_lock/lib/main/lockDetail/checkingIn/checkingInStaff/checkingInSetStaffList/checkingInStaffList_logic.dart @@ -21,10 +21,11 @@ class CheckingInStaffManageLogic extends BaseGetXController{ } // 删除员工 - void deletStaff(int staffId) async{ + void deletStaff(int staffId, int deleteKey) async{ var entity = await ApiRepository.to.deletStaffData( lockId: state.getKeyInfosData.value.lockId!, staffId:staffId, + deleteKey:deleteKey ); if(entity.errorCode!.codeIsSuccessful){ getStaffList(); diff --git a/star_lock/lib/main/lockDetail/checkingIn/checkingInStaff/checkingInSetStaffList/checkingInStaffList_page.dart b/star_lock/lib/main/lockDetail/checkingIn/checkingInStaff/checkingInSetStaffList/checkingInStaffList_page.dart index e1f15705..0ab9411d 100644 --- a/star_lock/lib/main/lockDetail/checkingIn/checkingInStaff/checkingInSetStaffList/checkingInStaffList_page.dart +++ b/star_lock/lib/main/lockDetail/checkingIn/checkingInStaff/checkingInSetStaffList/checkingInStaffList_page.dart @@ -2,6 +2,7 @@ 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/showTipView.dart'; import '../../../../../appRouters.dart'; import '../../../../../app_settings/app_colors.dart'; @@ -71,7 +72,14 @@ class _CheckingInStaffListPageState extends State { children: [ SlidableAction( onPressed: (BuildContext context){ - showIosTipViewDialog(staffListItem.staffId!, context); + // 1APP 2密码 3卡 4指纹 5人脸 + if(staffListItem.attendanceType == 1){ + ShowTipView().showDeleteAdministratorIsHaveAllDataDialog('同时删除员工钥匙', (isAllData) { + logic.deletStaff(staffListItem.staffId!, (isAllData ? 1 : 0)); + }); + }else{ + showIosTipViewDialog(staffListItem.staffId!, context); + } }, backgroundColor: Colors.red, foregroundColor: Colors.white, @@ -130,9 +138,12 @@ class _CheckingInStaffListPageState extends State { style: TextStyle(fontSize: 24.sp) ) ), - Visibility(visible: staffListItem.cardStatus == 0, child: SizedBox(height: 5.h,)), Visibility( - visible: staffListItem.cardStatus == 0, + visible: staffListItem.cardStatus == 1 ? true : false, + child: SizedBox(height: 5.h,) + ), + Visibility( + visible: staffListItem.cardStatus == 1 ? true : false, child: Container( padding: EdgeInsets.only(right: 5.w, left: 5.w), decoration: BoxDecoration( @@ -182,10 +193,10 @@ class _CheckingInStaffListPageState extends State { builder: (BuildContext context) { return ShowIosTipView( title: "提示", - tipTitle: "确定要删除吗?", + tipTitle: "确定要删除员工吗?", sureClick: () async { Get.back(); - logic.deletStaff(staffId); + logic.deletStaff(staffId, 0); }, cancelClick: () { Get.back(); diff --git a/star_lock/lib/main/lockDetail/checkingIn/checkingInStaff/checkingInStaffDetail/checkingInStaffDetail_page.dart b/star_lock/lib/main/lockDetail/checkingIn/checkingInStaff/checkingInStaffDetail/checkingInStaffDetail_page.dart index c945b6cb..c637a394 100644 --- a/star_lock/lib/main/lockDetail/checkingIn/checkingInStaff/checkingInStaffDetail/checkingInStaffDetail_page.dart +++ b/star_lock/lib/main/lockDetail/checkingIn/checkingInStaff/checkingInStaffDetail/checkingInStaffDetail_page.dart @@ -60,13 +60,13 @@ class _CheckingInStaffDetailPageState extends State { // rightTitle: state.staffListItemData.value.attendanceWay, // isHaveLine: true)), Obx(() => Visibility( - visible: state.staffListItemData.value.cardStatus == 0, + visible: state.staffListItemData.value.cardStatus == 1 ? true : false, child: Row( children: [ Container( height: 50.h, padding: EdgeInsets.only(left: 20.w), - child: Text("钥匙已被删除,打卡方式无效", style: TextStyle(fontSize: 22.sp, color: AppColors.openPassageModeColor))) + child: Text("${state.staffListItemData.value.reason}," "打卡方式无效", style: TextStyle(fontSize: 22.sp, color: AppColors.openPassageModeColor))) ], ), )), 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 695f7ea1..d2d34a79 100644 --- a/star_lock/lib/main/lockDetail/electronicKey/electronicKeyDetail/electronicKeyDetail/electronicKeyDetail_logic.dart +++ b/star_lock/lib/main/lockDetail/electronicKey/electronicKeyDetail/electronicKeyDetail/electronicKeyDetail_logic.dart @@ -1,5 +1,7 @@ import 'dart:ffi'; +import 'package:flutter/cupertino.dart'; +import 'package:flutter/material.dart'; import 'package:get/get.dart'; import 'package:star_lock/main/lockDetail/electronicKey/electronicKeyDetail/electronicKeyDetail/electronicKeyDetail_state.dart'; import 'package:star_lock/main/lockDetail/electronicKey/electronicKeyDetail/keyOperationRecord/keyOperationRecord_entity.dart'; @@ -7,10 +9,15 @@ import 'package:star_lock/main/lockDetail/electronicKey/electronicKeyList/entity import 'package:star_lock/network/api_repository.dart'; import 'package:star_lock/tools/baseGetXController.dart'; +import '../../../../../tools/custom_bottom_sheet.dart'; import '../../../../../tools/dateTool.dart'; import '../../../../../tools/eventBusEventManage.dart'; import '../../../../../tools/jh_pop_menus.dart'; +import '../../../../../tools/showDeleteAdministratorIsHaveAllDataWidget.dart'; import '../../../../../tools/showTipView.dart'; +import '../../../../../translations/trans_lib.dart'; + +typedef BlockIsHaveAllDataCallback = void Function(bool isAllData); class ElectronicKeyDetailLogic extends BaseGetXController { final ElectronicKeyDetailState state = ElectronicKeyDetailState(); @@ -35,13 +42,13 @@ class ElectronicKeyDetailLogic extends BaseGetXController { } } - //编辑电子钥匙有效期请求 - Future updateKeyDateRequest() async { + //编辑电子钥匙有效期请求 updateType 1:仅管理自己创建的用户 2:远程开锁 + Future updateKeyDateRequest(int updateType) async { KeyOperationRecordEntity entity = await ApiRepository.to.updateKeyDate( keyId:state.itemData.value.keyId.toString(), lockId:state.itemData.value.lockId.toString(), - endDate:state.starDate.value.toString(), - startDate:state.endDate.value.toString(), + endDate:state.endDate.value.toString(), + startDate:state.starDate.value.toString(), weekDays:state.itemData.value.weekDays!, keyType:state.itemData.value.keyType!, startTime:int.parse(state.starTime.value), @@ -49,6 +56,11 @@ class ElectronicKeyDetailLogic extends BaseGetXController { isOnlyManageSelf: state.onlyManageYouCreatesUser.value ? 1 : 0, remoteEnable: state.isRemoteUnlock.value ? 1 : 0); if (entity.errorCode!.codeIsSuccessful) { + // if(updateType == 1){ + // state.onlyManageYouCreatesUser.value = !state.onlyManageYouCreatesUser.value; + // }else if(updateType == 2){ + // state.isRemoteUnlock.value = !state.isRemoteUnlock.value; + // } showToast("修改成功", something: () { eventBus.fire(ElectronicKeyListRefreshUI()); eventBus.fire(AuthorizedAdminPageRefreshUI()); @@ -101,9 +113,10 @@ class ElectronicKeyDetailLogic extends BaseGetXController { } //冻结 - Future freezeKey() async { + Future freezeKey(int includeUnderlings) async { ElectronicKeyListEntity entity = await ApiRepository.to.freezeKey( - keyId:state.itemData.value.keyId.toString(), + keyId:state.itemData.value.keyId.toString(), + includeUnderlings: includeUnderlings ); if (entity.errorCode!.codeIsSuccessful) { showToast("设置成功", something: () { @@ -115,9 +128,10 @@ class ElectronicKeyDetailLogic extends BaseGetXController { } //取消冻结 - Future cancelFreeze() async { + Future cancelFreeze(int includeUnderlings) async { ElectronicKeyListEntity entity = await ApiRepository.to.cancelFreeze( keyId:state.itemData.value.keyId.toString(), + includeUnderlings: includeUnderlings ); if (entity.errorCode!.codeIsSuccessful) { showToast("设置成功", something: () { @@ -142,49 +156,170 @@ class ElectronicKeyDetailLogic extends BaseGetXController { return useDateStr; } - showPopMenus(){ - var textList = []; - // keyType // 永久:1;限时2,单次3,循环:4 - // itemData.keyRight == 1 // 1:管理员 2:普通用户 - // indexEntity.keyStatus! 110405:已冻结 110412:已过期 110408:已删除 110410:已重置 + Future openModalBottomSheet(BuildContext context) async { + var textList = []; if(state.keyType.value == 1 || state.keyType.value == 2){ - textList = [{'text': state.itemData.value.keyStatus == 110405 ? '取消冻结' : "冻结"}, {'text': state.itemData.value.keyRight == 1 ? '取消授权' : '授权'}]; + textList = [state.itemData.value.keyStatus == 110405 ? '取消冻结' : "冻结", state.itemData.value.keyRight == 1 ? '取消授权' : '授权']; } else if(state.keyType.value == 4){ - textList = [{'text': state.itemData.value.keyStatus == 110405 ? '取消冻结' : "冻结"}]; + textList = [state.itemData.value.keyStatus == 110405 ? '取消冻结' : "冻结"]; } - JhPopMenus.showLinePop(Get.context!, clickCallback: (index, selText) { - print('选中index: $index'); - print('选中text: $selText'); - if(index == 0){ - if(state.itemData.value.keyStatus == 110405){ - // 取消冻结 - cancelFreeze(); - }else{ - freezeKey(); - } - }else{ - // 取消/授权管理员 - if(state.itemData.value.keyRight == 1){ - // 管理员 - cancelAdministrator(); - }else{ - setAdministrator(); - } - } - }, listData: textList); + showModalBottomSheet( + context: context, + shape: RoundedRectangleBorder( + borderRadius: BorderRadiusDirectional.circular(10)), + builder: (BuildContext context) { + return AlertBottomWidget( + topTitle: '', + items: textList, + chooseCallback: (value) { + int index = value; + if(index == 0){ + if(state.itemData.value.keyStatus == 110405){ + // 取消冻结 + if(state.itemData.value.keyRight == 1){ + // 管理员 + print("管理员 调用取消冻结"); + ShowTipView().showDeleteAdministratorIsHaveAllDataDialog('同时解冻其发送的钥匙', (isAllData) { + cancelFreeze(isAllData ? 1 : 0); + }); + }else{ + print("普通用户 调用取消冻结"); + ShowTipView().showIosTipWithContentDialog("取消冻结会在用户APP连网后生效", (){ + cancelFreeze(0); + }); + } + }else{ + if(state.itemData.value.keyRight == 1){ + // 管理员 + print("管理员 调用冻结"); + ShowTipView().showDeleteAdministratorIsHaveAllDataDialog('同时解冻其发送的钥匙', (isAllData) { + freezeKey(isAllData ? 1 : 0); + }); + }else{ + print("普通用户 调用冻结"); + ShowTipView().showIosTipWithContentDialog("冻结会在用户APP连网后生效", (){ + freezeKey(0); + }); + } + } + }else{ + // 取消/授权管理员 + if(state.itemData.value.keyRight == 1){ + // 管理员 + print("管理员 调用取消授权管理员接口"); + ShowTipView().showIosTipWithContentDialog("取消授权会在用户APP连网后生效", (){ + cancelAdministrator(); + }); + }else{ + print("普通用户 调用授权管理员接口"); + ShowTipView().showIosTipWithContentDialog("授权用户拥有管理员的大部分权限,比如发送钥匙、发送密码", (){ + setAdministrator(); + }); + } + } + }, + ); + }); } + // showPopMenus(BuildContext context){ + // var textList = []; + // // keyType // 永久:1;限时2,单次3,循环:4 + // // itemData.keyRight == 1 // 1:管理员 2:普通用户 + // // indexEntity.keyStatus! 110405:已冻结 110412:已过期 110408:已删除 110410:已重置 + // if(state.keyType.value == 1 || state.keyType.value == 2){ + // textList = [{'text': state.itemData.value.keyStatus == 110405 ? '取消冻结' : "冻结"}, {'text': state.itemData.value.keyRight == 1 ? '取消授权' : '授权'}]; + // } else if(state.keyType.value == 4){ + // textList = [{'text': state.itemData.value.keyStatus == 110405 ? '取消冻结' : "冻结"}]; + // } + // JhPopMenus.showLinePop(context, clickCallback: (index, selText) { + // print('选中index: $index'); + // print('选中text: $selText'); + // Navigator.pop(context, true); + // Future.delayed(const Duration(seconds: 1)); + // + // if(index == 0){ + // if(state.itemData.value.keyStatus == 110405){ + // // 取消冻结 + // if(state.itemData.value.keyRight == 1){ + // // 管理员 + // print("管理员 调用取消冻结"); + // ShowTipView().showDeleteAdministratorIsHaveAllDataDialog('同时解冻其发送的钥匙', (isAllData) { + // cancelFreeze(); + // }); + // }else{ + // print("普通用户 调用取消冻结"); + // ShowTipView().showIosTipWithContentDialog("取消冻结会在用户APP连网后生效", (){ + // cancelFreeze(); + // }); + // } + // }else{ + // if(state.itemData.value.keyRight == 1){ + // // 管理员 + // print("管理员 调用冻结"); + // // ShowTipView().showDeleteAdministratorIsHaveAllDataDialog('同时解冻其发送的钥匙', (isAllData) { + // // freezeKey(); + // // }); + // // showDeleteAdministratorIsHaveAllDataDialog('同时解冻其发送的钥匙', (isAllData) { + // // freezeKey(); + // // }); + // showToast("fasdfasdfasdf"); + // }else{ + // print("普通用户 调用冻结"); + // ShowTipView().showIosTipWithContentDialog("冻结会在用户APP连网后生效", (){ + // freezeKey(); + // }); + // } + // } + // }else{ + // // 取消/授权管理员 + // if(state.itemData.value.keyRight == 1){ + // // 管理员 + // print("管理员 调用取消授权管理员接口"); + // ShowTipView().showIosTipWithContentDialog("取消授权会在用户APP连网后生效", (){ + // cancelAdministrator(); + // }); + // }else{ + // print("普通用户 调用授权管理员接口"); + // ShowTipView().showIosTipWithContentDialog("授权用户拥有管理员的大部分权限,比如发送钥匙、发送密码", (){ + // setAdministrator(); + // }); + // } + // } + // }, listData: textList); + // } + deletKeyLogic(){ if(state.itemData.value.keyRight == 1){ // 授权管理员 - ShowTipView().showDeleteAdministratorIsHaveAllDataDialog((isAllData) { + ShowTipView().showDeleteAdministratorIsHaveAllDataDialog('同时删除其发送的所有钥匙,钥匙删除后不能恢复', (isAllData) { deleteKeyRequest(isAllData ? 1 : 0); }); }else{ // 普通用户 - ShowTipView().showDeleteKeyDataDialogDialog((){ + ShowTipView().showIosTipWithContentDialog("删除钥匙会在用户APP连网后生效",(){ deleteKeyRequest(0); }); } } + + @override + void onReady() { + // TODO: implement onReady + super.onReady(); + + } + + @override + void onInit() { + // TODO: implement onInit + super.onInit(); + } + + @override + void onClose() { + // TODO: implement onClose + super.onClose(); + + } } diff --git a/star_lock/lib/main/lockDetail/electronicKey/electronicKeyDetail/electronicKeyDetail/electronicKeyDetail_page.dart b/star_lock/lib/main/lockDetail/electronicKey/electronicKeyDetail/electronicKeyDetail/electronicKeyDetail_page.dart index 5ea355d5..7d6d65a1 100644 --- a/star_lock/lib/main/lockDetail/electronicKey/electronicKeyDetail/electronicKeyDetail/electronicKeyDetail_page.dart +++ b/star_lock/lib/main/lockDetail/electronicKey/electronicKeyDetail/electronicKeyDetail/electronicKeyDetail_page.dart @@ -41,9 +41,9 @@ class _ElectronicKeyDetailPageState extends State { height: 30.h, width: 10.w, ), - onPressed: state.keyType.value != 3 ? () { - logic.showPopMenus(); - } : null, + onPressed: () { + logic.openModalBottomSheet(context); + }, ), ]:null, backgroundColor: AppColors.mainColor), @@ -384,7 +384,7 @@ class _ElectronicKeyDetailPageState extends State { onChanged: (value) { setState(() { state.isRemoteUnlock.value = !state.isRemoteUnlock.value; - logic.updateKeyDateRequest(); + logic.updateKeyDateRequest(2); }); }, ); @@ -399,7 +399,7 @@ class _ElectronicKeyDetailPageState extends State { onChanged: (value) { setState(() { state.onlyManageYouCreatesUser.value = !state.onlyManageYouCreatesUser.value; - logic.updateKeyDateRequest(); + logic.updateKeyDateRequest(1); }); }, ); diff --git a/star_lock/lib/main/lockDetail/electronicKey/electronicKeyList/electronicKeyList_logic.dart b/star_lock/lib/main/lockDetail/electronicKey/electronicKeyList/electronicKeyList_logic.dart index 2fe92c68..5dc7c44f 100644 --- a/star_lock/lib/main/lockDetail/electronicKey/electronicKeyList/electronicKeyList_logic.dart +++ b/star_lock/lib/main/lockDetail/electronicKey/electronicKeyList/electronicKeyList_logic.dart @@ -69,12 +69,12 @@ class ElectronicKeyListLogic extends BaseGetXController { deletKeyLogic(ElectronicKeyListItem electronicKeyListItem){ if(electronicKeyListItem.keyRight == 1){ // 授权管理员 - ShowTipView().showDeleteAdministratorIsHaveAllDataDialog((isAllData) { + ShowTipView().showDeleteAdministratorIsHaveAllDataDialog('同时删除其发送的所有钥匙,钥匙删除后不能恢复', (isAllData) { deleteKeyRequest(electronicKeyListItem.keyId.toString(), isAllData ? 1 : 0); }); }else{ // 普通用户 - ShowTipView().showDeleteKeyDataDialogDialog((){ + ShowTipView().showIosTipWithContentDialog("删除钥匙会在用户APP连网后生效",(){ deleteKeyRequest(electronicKeyListItem.keyId.toString(), 0); }); } diff --git a/star_lock/lib/main/lockDetail/electronicKey/massSendElectronicKey/massSendElectronicKey/massSendElectronicKey_logic.dart b/star_lock/lib/main/lockDetail/electronicKey/massSendElectronicKey/massSendElectronicKey/massSendElectronicKey_logic.dart index 6a98b013..e59aa43a 100644 --- a/star_lock/lib/main/lockDetail/electronicKey/massSendElectronicKey/massSendElectronicKey/massSendElectronicKey_logic.dart +++ b/star_lock/lib/main/lockDetail/electronicKey/massSendElectronicKey/massSendElectronicKey/massSendElectronicKey_logic.dart @@ -1,5 +1,6 @@ import 'package:star_lock/tools/baseGetXController.dart'; +import '../../../../../common/XSConstantMacro/XSConstantMacro.dart'; import '../../../../../network/api_repository.dart'; import '../../../../../tools/dateTool.dart'; import '../massSendLockGroupList/lockUserList/lockUserListEntity.dart'; @@ -14,37 +15,117 @@ class MassSendElectronicKeyLogic extends BaseGetXController{ if (int.parse(state.type.value) != 1) { getFailureDateTime = DateTool().dateToTimestamp(state.endTime.value, 1).toString(); } - var entity = await ApiRepository.to.canSendKey(getFailureDateTime, state.lockIdList); + if(state.lockIdList.isEmpty){ + showToast("请选择锁"); + return; + } + + if(state.receiverList.isEmpty){ + showToast("请选择接收者"); + return; + } + var entity = await ApiRepository.to.canSendKey( + getFailureDateTime, + state.lockIdList + ); if (entity.errorCode!.codeIsSuccessful) { for (int i = 0; i < state.receiverList.length; i++) { LockUserData data = state.receiverList[i]; - batchSendElectronicKeyRequest(data.userid ?? ''); + batchSendElectronicKeyRequest(data.userid ?? '', data.nickname ?? ''); } } else { - showToast("检查失败"); + showToast(entity.errorMsg!); } } //批处理群发钥匙 - Future batchSendElectronicKeyRequest(String receiverUserID) async { - String getFailureDateTime = '0'; - String getEffectiveDateTime = '0'; - if (state.type.value == '0') { - getFailureDateTime = DateTool().dateToTimestamp(state.endTime.value, 1).toString(); - getEffectiveDateTime = DateTool().dateToTimestamp(state.beginTime.value, 1).toString(); + Future batchSendElectronicKeyRequest(String receiverUserID, String receiverUserName) async { + //发送钥匙请求 + var startDate = "0"; + var endDate = "0"; + var startTime = "0"; + var endTime = "0"; + int typeValue = int.parse(state.type.value); + switch (typeValue) { + case 0: + { + typeValue = XSConstantMacro.keyTypeTime; + startDate = DateTool().dateToTimestamp(state.beginTime.value, 1).toString(); + endDate = DateTool().dateToTimestamp(state.endTime.value, 1).toString(); + startTime = "0"; + endTime = "0"; + + if (startDate.isEmpty) { + showToast("请选择开始时间"); + return; + } + if (endDate.isEmpty) { + showToast("请选择结束时间"); + return; + } + + // if(DateTime.now().millisecondsSinceEpoch > int.parse(state.beginTimeTimestamp.value)){ + // Toast.show(msg: "生效时间要大于当前时间"); + // return; + // } + + if (int.parse(startDate) >= int.parse(endDate)) { + showToast("失效时间要大于生效时间"); + return; + } + } + break; + case 1: + typeValue = XSConstantMacro.keyTypeLong; + break; + // case 2: + // typeValue = XSConstantMacro.keyTypeOnce; + // break; + case 3: + typeValue = XSConstantMacro.keyTypeLoop; + if (state.beginTime.value.isEmpty) { + showToast("请选择有效期"); + return; + } + startDate = DateTool().dateToTimestamp(state.beginTime.value, 1).toString(); + endDate = DateTool().dateToTimestamp(state.endTime.value, 1).toString(); + startTime = DateTool().dateToTimestamp(state.effectiveDateTime.value, 0).toString(); + endTime = DateTool().dateToTimestamp(state.failureDateTime.value, 0).toString(); + break; + default: + typeValue = XSConstantMacro.keyTypeTime; + break; } + // String getKeyType = typeValue.toString(); + var entity = await ApiRepository.to.batchSendKey( - endDate:getFailureDateTime, - keyGroupIdList:[], - lockIdList:state.lockIdList, - createUser:state.isCreateUser.value == true ? '1' : '0', - isRemoteUnlock:state.isRemoteUnlock.value ? '1' : '2', - keyNameForAdmin:receiverUserID, - receiverUsername:receiverUserID, - startDate:getEffectiveDateTime, - countryCode:state.countryCode.value, - usernameType:'1', - weekDays:state.weekdaysList); + lockIds: state.lockIdList, + createUser: state.isCreateUser.value == true ? 1 : 0, + countryCode: state.countryCode.value, + receiverUsername: receiverUserID, + keyName: receiverUserName, + keyType: typeValue, + weekDays: state.weekdaysList, + startDate: int.parse(startDate), + endDate: int.parse(endDate), + startTime: int.parse(startTime), + endTime: int.parse(endTime), + remoteUnlockSwitch: state.isRemoteUnlock.value ? 1 : 2, + keyRight: 0 + ); + + // var entity = await ApiRepository.to.batchSendKey( + // endDate:getFailureDateTime, + // keyGroupIdList:[], + // lockIdList:state.lockIdList, + // createUser:state.isCreateUser.value == true ? '1' : '0', + // isRemoteUnlock:state.isRemoteUnlock.value ? '1' : '2', + // keyNameForAdmin:receiverUserID, + // receiverUsername:receiverUserID, + // startDate:getEffectiveDateTime, + // countryCode:state.countryCode.value, + // usernameType:'1', + // weekDays:state.weekdaysList); if (entity.errorCode!.codeIsSuccessful) { print('群发电子钥匙成功'); state.isSendSuccess.value = true; @@ -54,7 +135,7 @@ class MassSendElectronicKeyLogic extends BaseGetXController{ if (entity.errorCode == 425) { //用户未注册 state.isCreateUser.value = true; - batchSendElectronicKeyRequest(receiverUserID); + batchSendElectronicKeyRequest(receiverUserID, receiverUserName); } } } diff --git a/star_lock/lib/main/lockDetail/electronicKey/sendElectronicKey/sendElectronicKey/sendElectronicKey_logic.dart b/star_lock/lib/main/lockDetail/electronicKey/sendElectronicKey/sendElectronicKey/sendElectronicKey_logic.dart index c870c4aa..1b408983 100644 --- a/star_lock/lib/main/lockDetail/electronicKey/sendElectronicKey/sendElectronicKey/sendElectronicKey_logic.dart +++ b/star_lock/lib/main/lockDetail/electronicKey/sendElectronicKey/sendElectronicKey/sendElectronicKey_logic.dart @@ -115,6 +115,7 @@ class SendElectronicKeyLogic extends BaseGetXController { } else { if (entity.errorCode == 425) { //用户未注册 + state.isCreateUser.value = true; if (isPhoneNumber(state.emailOrPhoneController.text) == true) { _showPhoneDialog(Get.context, '${entity.errorMsg}'); } else { @@ -143,7 +144,7 @@ class SendElectronicKeyLogic extends BaseGetXController { context: widgetContext, builder: (context) { return CupertinoAlertDialog( - title: const Text('接收者号码未注册,请选择号码所在的国家并重新发送'), + title: const Text('接收者号码未注册,请重新发送'), actions: [ CupertinoDialogAction( child: Text( @@ -151,25 +152,25 @@ class SendElectronicKeyLogic extends BaseGetXController { style: TextStyle(color: AppColors.mainColor), ), onPressed: () { - Navigator.of(context).pop(); + Get.back(); }, ), CupertinoDialogAction( child: Text( - TranslationLoader.lanKeys!.select!.tr, + TranslationLoader.lanKeys!.sure!.tr, style: TextStyle(color: AppColors.mainColor), ), onPressed: () async { //选择国家代码 - state.isCreateUser.value = true; - Navigator.of(context).pop(); + Get.back(); - var result = await Get.toNamed(Routers.selectCountryRegionPage); - if (result != null) { - result as Map; - state.countryCode.value = result['code']; - state.countryName.value = result['countryName']; - } + // var result = await Get.toNamed(Routers.selectCountryRegionPage); + // if (result != null) { + // result as Map; + // state.countryCode.value = result['code']; + // state.countryName.value = result['countryName']; + // } + sendElectronicKeyRequest(); }, ), ], @@ -192,7 +193,7 @@ class SendElectronicKeyLogic extends BaseGetXController { style: TextStyle(color: AppColors.mainColor), ), onPressed: () { - Navigator.of(context).pop(); + Get.back(); }, ), CupertinoDialogAction( @@ -201,8 +202,7 @@ class SendElectronicKeyLogic extends BaseGetXController { style: TextStyle(color: AppColors.mainColor), ), onPressed: () { - state.isCreateUser.value = true; - Navigator.of(context).pop(); + Get.back(); sendElectronicKeyRequest(); }, diff --git a/star_lock/lib/main/lockDetail/electronicKey/sendElectronicKey/sendElectronicKey/sendElectronicKey_page.dart b/star_lock/lib/main/lockDetail/electronicKey/sendElectronicKey/sendElectronicKey/sendElectronicKey_page.dart index b286da62..d21d111e 100644 --- a/star_lock/lib/main/lockDetail/electronicKey/sendElectronicKey/sendElectronicKey/sendElectronicKey_page.dart +++ b/star_lock/lib/main/lockDetail/electronicKey/sendElectronicKey/sendElectronicKey/sendElectronicKey_page.dart @@ -202,7 +202,7 @@ class _SendElectronicKeyPageState extends State { rightTitle: "", isTipsImg: true, tipsImgAction: () { - ShowTipView().showSureAlertDialog("人脸实名认证指的是用户在使用手机APP或小程序开锁时,需要先进行本人人脸验证,验证通过才能开锁。"); + ShowTipView().showSureAlertDialog("人脸实名认证指的是用户在使用手机APP开锁时,需要先进行本人人脸验证,验证通过才能开锁。"); }, isHaveRightWidget: true, rightWidget: SizedBox( diff --git a/star_lock/lib/main/lockDetail/fingerprint/fingerprintList/fingerprintListData_entity.dart b/star_lock/lib/main/lockDetail/fingerprint/fingerprintList/fingerprintListData_entity.dart index 1fe16714..fa6cefc7 100644 --- a/star_lock/lib/main/lockDetail/fingerprint/fingerprintList/fingerprintListData_entity.dart +++ b/star_lock/lib/main/lockDetail/fingerprint/fingerprintList/fingerprintListData_entity.dart @@ -82,6 +82,7 @@ class FingerprintItemData { String? cardNumber; int? cardType; int? cardId; + int? cardStatus; int? faceId; String? faceName; @@ -121,7 +122,8 @@ class FingerprintItemData { this.faceType, this.cyclicConfig, this.featureData, - this.faceRight}); + this.faceRight, + this.cardStatus}); FingerprintItemData.fromJson(Map json) { fingerprintStatus = json['fingerprintStatus']; @@ -152,6 +154,7 @@ class FingerprintItemData { cyclicConfig = json['cyclicConfig']; featureData = json['featureData']; faceRight = json['faceRight']; + cardStatus = json['cardStatus']; } Map toJson() { @@ -184,7 +187,7 @@ class FingerprintItemData { data['cyclicConfig'] = cyclicConfig; data['featureData'] = featureData; data['faceRight'] = faceRight; - + data['cardStatus'] = cardStatus; return data; } } diff --git a/star_lock/lib/main/lockDetail/fingerprint/fingerprintList/fingerprintList_logic.dart b/star_lock/lib/main/lockDetail/fingerprint/fingerprintList/fingerprintList_logic.dart index cdcc484f..1b7edb5b 100644 --- a/star_lock/lib/main/lockDetail/fingerprint/fingerprintList/fingerprintList_logic.dart +++ b/star_lock/lib/main/lockDetail/fingerprint/fingerprintList/fingerprintList_logic.dart @@ -398,6 +398,21 @@ class FingerprintListLogic extends BaseGetXController{ }); } + String getKeyType(FingerprintItemData fingerprintItemData){ + // fingerprintStatus 1:正常 2:失效 + var keyTypeStr = "";// + // (fingerprintItemData.fingerprintType! != 1) ? (fingerprintItemData.endDate! < DateTime.now().millisecondsSinceEpoch ? "已失效" : "") : "" + if(fingerprintItemData.fingerprintStatus == 1){ + if(fingerprintItemData.startDate! > DateTime.now().millisecondsSinceEpoch){ + keyTypeStr = "未生效"; + } + + }else if(fingerprintItemData.fingerprintStatus == 2){ + keyTypeStr = "已失效"; + } + return keyTypeStr; + } + String getKeyDateType(FingerprintItemData fingerprintItemData){ var keyDateTypeStr = "";// 永久:1;限时2,单次3,循环:4 if(fingerprintItemData.fingerprintType! == 1){ diff --git a/star_lock/lib/main/lockDetail/fingerprint/fingerprintList/fingerprintList_page.dart b/star_lock/lib/main/lockDetail/fingerprint/fingerprintList/fingerprintList_page.dart index 30262758..485fd4ee 100644 --- a/star_lock/lib/main/lockDetail/fingerprint/fingerprintList/fingerprintList_page.dart +++ b/star_lock/lib/main/lockDetail/fingerprint/fingerprintList/fingerprintList_page.dart @@ -146,12 +146,8 @@ class _FingerprintListPageState extends State with RouteAwa child: _keyItem( 'images/icon_fingerprint.png', fingerprintItemData.fingerprintName!, - (fingerprintItemData.fingerprintType! != 1) ? (fingerprintItemData.endDate! < DateTime.now().millisecondsSinceEpoch ? "已失效" : "") : "", - logic.getKeyDateType(fingerprintItemData), - // fingerprintItemData.fingerprintType! == 1 - // ? "永久" - // : "${DateTool().dateToYMDHNString(fingerprintItemData.startDate.toString())} - ${DateTool().dateToYMDHNString(fingerprintItemData.endDate.toString())}", - () async { + logic.getKeyType(fingerprintItemData), + logic.getKeyDateType(fingerprintItemData), () async { var data = await Get.toNamed( Routers.fingerprintDetailPage, arguments: { @@ -197,8 +193,7 @@ class _FingerprintListPageState extends State with RouteAwa ); } - Widget _keyItem(String lockTypeIcon, String lockTypeTitle, String ifInvalidation, String showTime, - Function() action) { + Widget _keyItem(String lockTypeIcon, String lockTypeTitle, String ifInvalidation, String showTime, Function() action) { return GestureDetector( onTap: action, child: Container( diff --git a/star_lock/lib/main/lockDetail/lockDetail/lockDetail_page.dart b/star_lock/lib/main/lockDetail/lockDetail/lockDetail_page.dart index c6988dd0..166f34d8 100644 --- a/star_lock/lib/main/lockDetail/lockDetail/lockDetail_page.dart +++ b/star_lock/lib/main/lockDetail/lockDetail/lockDetail_page.dart @@ -566,8 +566,8 @@ class _LockDetailPageState extends State showWidgetArr.add(bottomItem( 'images/main/icon_main_set.png', TranslationLoader.lanKeys!.set!.tr, - state.openDoorBtnisUneable.value, - state.bottomBtnisEable.value, () { + true, + true, () { Get.toNamed(Routers.lockSetPage, arguments: { "lockId": state.keyInfos.value.lockId, "isOnlyOneData": state.isOnlyOneData @@ -740,8 +740,8 @@ class _LockDetailPageState extends State bottomItem( 'images/main/icon_main_set.png', TranslationLoader.lanKeys!.set!.tr, - state.openDoorBtnisUneable.value, - state.bottomBtnisEable.value, () { + true, + true, () { // logic.clickItemBtnAction(10); Get.toNamed(Routers.lockSetPage, arguments: { "lockId": state.keyInfos.value.lockId, @@ -754,8 +754,7 @@ class _LockDetailPageState extends State } // - Widget bottomItem(String iconUrl, String name, bool openDoorBtnisUneable, - bool bottomBtnisEable, Function() onClick) { + Widget bottomItem(String iconUrl, String name, bool openDoorBtnisUneable, bool bottomBtnisEable, Function() onClick) { var width = 42.w; var height = 42.h; return GestureDetector( diff --git a/star_lock/lib/main/lockDetail/lockSet/basicInformation/adminOpenLockPassword/adminOpenLockPassword_logic.dart b/star_lock/lib/main/lockDetail/lockSet/basicInformation/adminOpenLockPassword/adminOpenLockPassword_logic.dart index 6764f3c5..735ef13e 100644 --- a/star_lock/lib/main/lockDetail/lockSet/basicInformation/adminOpenLockPassword/adminOpenLockPassword_logic.dart +++ b/star_lock/lib/main/lockDetail/lockSet/basicInformation/adminOpenLockPassword/adminOpenLockPassword_logic.dart @@ -124,10 +124,10 @@ class AdminOpenLockPasswordLogic extends BaseGetXController{ var pwdStr = utf8String(pwd); print("pwd:$pwd pwdStr:$pwdStr state.adminPwd.value:${state.adminPwd.value}"); - // if(pwdStr == state.adminPwd.value){ - // showToast(""); - // return; - // } + if(pwdStr == state.adminPwd.value){ + showToast("管理员密码相同,无需修改"); + return; + } state.adminPwd.value = pwdStr; addLockAdminPassword(false); } diff --git a/star_lock/lib/main/lockDetail/passwordKey/passwordKeyList/passwordKeyList_logic.dart b/star_lock/lib/main/lockDetail/passwordKey/passwordKeyList/passwordKeyList_logic.dart index 0d805459..9f9b225d 100644 --- a/star_lock/lib/main/lockDetail/passwordKey/passwordKeyList/passwordKeyList_logic.dart +++ b/star_lock/lib/main/lockDetail/passwordKey/passwordKeyList/passwordKeyList_logic.dart @@ -87,7 +87,7 @@ class PasswordKeyListLogic extends BaseGetXController { break; case 4: //删除 4 在锁上使用后会删除之前在锁上使用过的密码 - useDateStr = '${sendDateStr.toLocal().toString().substring(0, 16)} 清空码'; + useDateStr = '${startDateStr.toLocal().toString().substring(0, 16)} 清空码'; break; case 5: //周未循环 5 在周未开始和结束时间指定时间段内有效 diff --git a/star_lock/lib/main/lockDetail/passwordKey/passwordKeyList/passwordKeyList_page.dart b/star_lock/lib/main/lockDetail/passwordKey/passwordKeyList/passwordKeyList_page.dart index 1fb9e65c..4384d1b9 100644 --- a/star_lock/lib/main/lockDetail/passwordKey/passwordKeyList/passwordKeyList_page.dart +++ b/star_lock/lib/main/lockDetail/passwordKey/passwordKeyList/passwordKeyList_page.dart @@ -184,8 +184,7 @@ class _PasswordKeyListPageState extends State { }); } - Widget _electronicKeyItem(int itemIndex, String lockTypeIcon, - String lockTypeTitle, String useDateStr, Function()? action) { + Widget _electronicKeyItem(int itemIndex, String lockTypeIcon, String lockTypeTitle, String useDateStr, Function()? action) { PasswordKeyListItem passwordKeyListItem = state.itemDataList[itemIndex]; return GestureDetector( diff --git a/star_lock/lib/main/lockDetail/passwordKey/passwordKeyManage/passwordKeyManage_page.dart b/star_lock/lib/main/lockDetail/passwordKey/passwordKey_perpetual/passwordKeyManage/passwordKeyManage_page.dart similarity index 79% rename from star_lock/lib/main/lockDetail/passwordKey/passwordKeyManage/passwordKeyManage_page.dart rename to star_lock/lib/main/lockDetail/passwordKey/passwordKey_perpetual/passwordKeyManage/passwordKeyManage_page.dart index a4510e09..d8df9501 100644 --- a/star_lock/lib/main/lockDetail/passwordKey/passwordKeyManage/passwordKeyManage_page.dart +++ b/star_lock/lib/main/lockDetail/passwordKey/passwordKey_perpetual/passwordKeyManage/passwordKeyManage_page.dart @@ -1,11 +1,12 @@ + import 'package:flutter/material.dart'; import 'package:get/get.dart'; -import 'package:star_lock/main/lockDetail/passwordKey/passwordKeyManage/passwordKeyManage_tabbar.dart'; +import 'package:star_lock/main/lockDetail/passwordKey/passwordKey_perpetual/passwordKeyManage/passwordKeyManage_tabbar.dart'; -import '../../../../app_settings/app_colors.dart'; -import '../../../../tools/titleAppBar.dart'; -import '../../../../translations/trans_lib.dart'; -import '../../../lockMian/entity/lockListInfo_entity.dart'; +import '../../../../../app_settings/app_colors.dart'; +import '../../../../../tools/titleAppBar.dart'; +import '../../../../../translations/trans_lib.dart'; +import '../../../../lockMian/entity/lockListInfo_entity.dart'; class PasswordKeyManagePage extends StatefulWidget { const PasswordKeyManagePage({Key? key}) : super(key: key); diff --git a/star_lock/lib/main/lockDetail/passwordKey/passwordKeyManage/passwordKeyManage_tabbar.dart b/star_lock/lib/main/lockDetail/passwordKey/passwordKey_perpetual/passwordKeyManage/passwordKeyManage_tabbar.dart similarity index 91% rename from star_lock/lib/main/lockDetail/passwordKey/passwordKeyManage/passwordKeyManage_tabbar.dart rename to star_lock/lib/main/lockDetail/passwordKey/passwordKey_perpetual/passwordKeyManage/passwordKeyManage_tabbar.dart index 0c533073..75d41a9a 100644 --- a/star_lock/lib/main/lockDetail/passwordKey/passwordKeyManage/passwordKeyManage_tabbar.dart +++ b/star_lock/lib/main/lockDetail/passwordKey/passwordKey_perpetual/passwordKeyManage/passwordKeyManage_tabbar.dart @@ -1,13 +1,12 @@ import 'package:flutter/material.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:get/get.dart'; -import 'package:star_lock/tools/eventBusEventManage.dart'; +import 'package:star_lock/main/lockMian/entity/lockListInfo_entity.dart'; -import '../../../../app_settings/app_colors.dart'; -import '../../../../tools/CustomUnderlineTabIndicator.dart'; -import '../../../../translations/trans_lib.dart'; -import '../../../lockMian/entity/lockListInfo_entity.dart'; -import '../passwordKey_Perpetual/passwordKey_perpetual_page.dart'; +import '../../../../../app_settings/app_colors.dart'; +import '../../../../../tools/CustomUnderlineTabIndicator.dart'; +import '../../../../../translations/trans_lib.dart'; +import '../passwordKey_perpetual_page.dart'; class PasswordKeyManageTabbarPage extends StatefulWidget { var initialIndex = 1; diff --git a/star_lock/lib/main/lockMian/lockList/lockList_page.dart b/star_lock/lib/main/lockMian/lockList/lockList_page.dart index 9e0ef8f2..0c573457 100644 --- a/star_lock/lib/main/lockMian/lockList/lockList_page.dart +++ b/star_lock/lib/main/lockMian/lockList/lockList_page.dart @@ -112,15 +112,15 @@ class _LockListPageState extends State { // || keyInfo.keyStatus == XSConstantMacro.keyStatusFrozen || keyInfo.keyStatus == XSConstantMacro.keyStatusExpired if((keyInfo.keyType == XSConstantMacro.keyTypeTime || keyInfo.keyType == XSConstantMacro.keyTypeLoop) && (keyInfo.keyStatus == XSConstantMacro.keyStatusWaitIneffective)){ logic.showToast("您的钥匙未生效"); - return; + // return; } if((keyInfo.keyType == XSConstantMacro.keyTypeTime || keyInfo.keyType == XSConstantMacro.keyTypeLoop) && (keyInfo.keyStatus == XSConstantMacro.keyStatusFrozen)){ logic.showToast("您的钥匙已冻结"); - return; + // return; } if((keyInfo.keyType == XSConstantMacro.keyTypeTime || keyInfo.keyType == XSConstantMacro.keyTypeLoop) && (keyInfo.keyStatus == XSConstantMacro.keyStatusExpired)){ logic.showToast("您的钥匙已过期"); - return; + // return; } Get.toNamed(Routers.lockDetailMainPage, arguments: { // "lockMainEntity": widget.lockMainEntity, @@ -237,7 +237,7 @@ class _LockListPageState extends State { children: [ SizedBox(width: 30.w), Text( - "${logic.getUseKeyTypeStr(keyInfo.startDate, keyInfo.endDate, keyInfo.keyType)} ${keyInfo.isLockOwner == 1 ? '超级管理员' : (keyInfo.keyRight == 1 ? "授权管理员" : "普通用户")}", + "${logic.getUseKeyTypeStr(keyInfo.startDate, keyInfo.endDate, keyInfo.keyType)}/${keyInfo.isLockOwner == 1 ? '超级管理员' : (keyInfo.keyRight == 1 ? "授权管理员" : "普通用户")}", style: TextStyle( fontSize: 18.sp, color: AppColors.darkGrayTextColor), ), diff --git a/star_lock/lib/mine/mine/starLockMine_logic.dart b/star_lock/lib/mine/mine/starLockMine_logic.dart index 2c4a5fa2..03fde9b7 100644 --- a/star_lock/lib/mine/mine/starLockMine_logic.dart +++ b/star_lock/lib/mine/mine/starLockMine_logic.dart @@ -15,10 +15,17 @@ class StarLockMineLogic extends BaseGetXController { } @override - Future onReady() async { + void onReady() { print("ready home"); super.onReady(); + } + + @override + Future onInit() async { + print("init home"); + super.onInit(); + final data = await Storage.getString(saveUserLoginData); if (data != null && data.isNotEmpty) { state.userNickName.value = (await Storage.getNickname())!; @@ -27,12 +34,6 @@ class StarLockMineLogic extends BaseGetXController { } } - @override - void onInit() { - print("init home"); - super.onInit(); - } - @override void onClose() { print("close home"); diff --git a/star_lock/lib/mine/mine/starLockMine_page.dart b/star_lock/lib/mine/mine/starLockMine_page.dart index d8d14814..df777daa 100644 --- a/star_lock/lib/mine/mine/starLockMine_page.dart +++ b/star_lock/lib/mine/mine/starLockMine_page.dart @@ -86,7 +86,7 @@ class StarLockMinePageState extends State with BaseWidget { SizedBox( height: 20.h, ), - Text(state.userNickName.value ?? "-", + Text(state.userNickName.value.isNotEmpty ? state.userNickName.value : (state.userMobile.value.isNotEmpty ? state.userMobile.value : state.userEmail.value), style: TextStyle( fontSize: 22.sp, color: Colors.white, diff --git a/star_lock/lib/mine/mineSet/authorizedAdministrator/addAuthorizedAdministrator/addAuthorizedAdministratorManage/addAuthorizedAdministratorManage_page.dart b/star_lock/lib/mine/mineSet/authorizedAdministrator/addAuthorizedAdministrator/addAuthorizedAdministratorManage/addAuthorizedAdministratorManage_page.dart new file mode 100644 index 00000000..5b623a1f --- /dev/null +++ b/star_lock/lib/mine/mineSet/authorizedAdministrator/addAuthorizedAdministrator/addAuthorizedAdministratorManage/addAuthorizedAdministratorManage_page.dart @@ -0,0 +1,37 @@ + +import 'package:flutter/material.dart'; +import 'package:get/get.dart'; + +import '../../../../../app_settings/app_colors.dart'; +import '../../../../../tools/titleAppBar.dart'; +import '../../../../../translations/trans_lib.dart'; +import 'addAuthorizedAdministratorManage_tabbar.dart'; + +class AddAuthorizedAdministratorManagePage extends StatefulWidget { + const AddAuthorizedAdministratorManagePage({Key? key}) : super(key: key); + + @override + State createState() => _AddAuthorizedAdministratorManagePageState(); +} + +class _AddAuthorizedAdministratorManagePageState extends State { + var index = 0; + + @override + Widget build(BuildContext context) { + return Scaffold( + backgroundColor: AppColors.mainBackgroundColor, + appBar: TitleAppBar( + barTitle: TranslationLoader.lanKeys!.authorizedAdmin!.tr, + haveBack: true, + backgroundColor: AppColors.mainColor), + body: Column( + children: [ + AddAuthorizedAdministratorManageTabbar( + initialIndex: index, + ), + ], + ), + ); + } +} \ No newline at end of file diff --git a/star_lock/lib/mine/mineSet/authorizedAdministrator/addAuthorizedAdministrator/addAuthorizedAdministratorManage/addAuthorizedAdministratorManage_tabbar.dart b/star_lock/lib/mine/mineSet/authorizedAdministrator/addAuthorizedAdministrator/addAuthorizedAdministratorManage/addAuthorizedAdministratorManage_tabbar.dart new file mode 100644 index 00000000..eaa0d59e --- /dev/null +++ b/star_lock/lib/mine/mineSet/authorizedAdministrator/addAuthorizedAdministrator/addAuthorizedAdministratorManage/addAuthorizedAdministratorManage_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/tools/CustomUnderlineTabIndicator.dart'; + +import '../../../../../app_settings/app_colors.dart'; +import '../../../../../translations/trans_lib.dart'; +import '../addAuthorizedAdministrator_page.dart'; + +class AddAuthorizedAdministratorManageTabbar extends StatefulWidget { + var initialIndex = 1; + + AddAuthorizedAdministratorManageTabbar({Key? key, required this.initialIndex}) : super(key: key); + + @override + State createState() => _AddAuthorizedAdministratorManageTabbarState(); +} + +class _AddAuthorizedAdministratorManageTabbarState extends State with SingleTickerProviderStateMixin { + late TabController _tabController; + + final List _itemTabs = [ + ItemView(title: TranslationLoader.lanKeys!.timeLimit!.tr, type: "0"), + ItemView(title: TranslationLoader.lanKeys!.permanent!.tr, type: "1"), + ]; + + @override + void initState() { + // TODO: implement initState + super.initState(); + _tabController = TabController( + vsync: this, + length: _itemTabs.length, + initialIndex: widget.initialIndex); + + _tabController.addListener(() { + // print("_tabController.animation!.value:${_tabController.animation!.value} _tabController.index:${_tabController.index}"); + 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, + tabs: _itemTabs.map((ItemView item) => _tab(item)).toList(), + onTap: (index){ + FocusScope.of(context).requestFocus(FocusNode()); + }, + 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( + // text: item.title, + child: Container( + width: 1.sw / 4, + margin: EdgeInsets.all(10.w), + // color: Colors.red, + child: Text( + item.title, + textAlign: TextAlign.center, + ), + ), + ); + } + + Widget _pageWidget() { + return Expanded( + child: TabBarView( + controller: _tabController, + children: _itemTabs + .map((ItemView item) => AddAuthorizedAdministratorPage( + type: item.type, + )) + .toList(), + ), + ); + } +} + +class ItemView { + const ItemView({required this.title, required this.type}); + + final String title; + final String type; +} diff --git a/star_lock/lib/mine/mineSet/authorizedAdministrator/addAuthorizedAdministrator/addAuthorizedAdministrator_logic.dart b/star_lock/lib/mine/mineSet/authorizedAdministrator/addAuthorizedAdministrator/addAuthorizedAdministrator_logic.dart index aa830bf5..3dcefc4e 100644 --- a/star_lock/lib/mine/mineSet/authorizedAdministrator/addAuthorizedAdministrator/addAuthorizedAdministrator_logic.dart +++ b/star_lock/lib/mine/mineSet/authorizedAdministrator/addAuthorizedAdministrator/addAuthorizedAdministrator_logic.dart @@ -5,6 +5,8 @@ import 'package:star_lock/network/api_repository.dart'; import 'package:star_lock/tools/baseGetXController.dart'; import 'package:star_lock/translations/trans_lib.dart'; +import '../../../../tools/dateTool.dart'; +import '../../../../tools/eventBusEventManage.dart'; import 'addAuthorizedAdministrator_state.dart'; class AddAuthorizedAdministratorLogic extends BaseGetXController { @@ -12,107 +14,97 @@ class AddAuthorizedAdministratorLogic extends BaseGetXController { //发送批量授权管理员 Future addAuthorizedAdminRequest() async { - String getFailureDateTime = '0'; - String getEffectiveDateTime = '0'; - if (state.tabController!.index == 1) { - getFailureDateTime = - state.failureDate.value.millisecondsSinceEpoch.toString(); - getEffectiveDateTime = - state.effectiveDate.value.millisecondsSinceEpoch.toString(); + if (state.emailOrPhoneController.text.isEmpty) { + showToast("请输入接收者账号"); + return; + } + if (state.keyNameController.text.isEmpty) { + showToast("请输入接收者姓名"); + return; + } + + if(state.lockIdList.isEmpty){ + showToast("请选择锁"); + return; + } + + var startDate = "0"; + var endDate = "0"; + Get.log("state.type.value:${state.type.value}"); + if (state.type.value == '0') { + startDate = DateTool().dateToTimestamp(state.beginDate.value, 1).toString(); + endDate = DateTool().dateToTimestamp(state.endDate.value, 1).toString(); + + if (startDate.isEmpty) { + showToast("请选择开始时间"); + return; + } + if (endDate.isEmpty) { + showToast("请选择结束时间"); + return; + } + + if (int.parse(startDate) >= int.parse(endDate)) { + showToast("失效时间要大于生效时间"); + return; + } } var entity = await ApiRepository.to.addAuthorizedAdmin( - state.isCreateUser.value ? "1" : "0", - getFailureDateTime, - state.isRemoteUnlock.value == true ? '1' : '2', - [], - state.lockIdList, - state.keyNameController.text, - getEffectiveDateTime, - state.emailOrPhoneController.text, - state.countryCode.value, - '1', + createUser: state.isCreateUser.value ? "1" : "0", + endDate: endDate, + isRemoteUnlock: state.isRemoteUnlock.value == true ? '1' : '2', + keyGroupIdList: [], + lockIdList: state.lockIdList, + name: state.keyNameController.text, + startDate: startDate, + userid: state.emailOrPhoneController.text, + countryCode: state.countryCode.value, + usernameType:'1', ); if (entity.errorCode!.codeIsSuccessful) { print('发送电子钥匙成功'); state.isSendSuccess.value = true; + state.isCreateUser.value = false; + // Toast.show(msg: "添加成功"); + + eventBus.fire(AuthorizedAdministratorListPageRefreshUI()); } else { - showToast("${entity.errorMsg}"); + // showToast("${entity.errorMsg}"); if (entity.errorCode == 425) { //用户未注册 state.isCreateUser.value = true; - addAuthorizedAdminRequest(); + _showDialog("${entity.errorMsg}"); } } } - // //发送钥匙请求 - // Future sendElectronicKeyRequest(BuildContext widgetContext) async { - // String lockID = state.keyInfo.value.lockId.toString(); - // String getKeyType = (int.parse(state.type.value) + 1).toString(); - // if (state.type.value == '0') { - // // getFailureDateTime = - // // state.failureDateTime.value.millisecondsSinceEpoch.toString(); - // // getEffectiveDateTime = - // // state.effectiveDateTime.value.millisecondsSinceEpoch.toString(); - // } - - // var entity = await ApiRepository.to.sendElectronicKey( - // createUser: state.isCreateUser.value ? "1" : "0", - // countryCode: state.countryCode.value, - // usernameType: '1', - // endDate: state.failureDateTime.value.millisecondsSinceEpoch, - // faceAuthentication: state.isAuthentication.value == true ? '1' : '2', - // isCameraEnable: '2', - // isRemoteUnlock: state.isRemoteUnlock.value == true ? '1' : '2', - // keyNameForAdmin: state.keyNameController.text, - // keyRight: '0', - // keyType: getKeyType, - // lockId: lockID, - // operatorUid: '', - // receiverUsername: state.emailOrPhoneController.text, - // remarks: '', - // startDate: state.effectiveDateTime.value.millisecondsSinceEpoch, - // weekDays: state.weekdaysList, - // startTime: state.st.value, - // endTime: state.endTime.value); - // if (entity.errorCode!.codeIsSuccessful) { - // print('发送电子钥匙成功'); - // state.isSendSuccess.value = true; - // } else { - // if (entity.errorCode == 425) { - // //用户未注册 - // _showDialog(widgetContext, '${entity.errorMsg}'); - // } - // } - // } - //用户未注册确认弹窗 - void _showDialog(widgetContext, String errMsg) { + void _showDialog(String errMsg) { showCupertinoDialog( - context: widgetContext, + context: Get.context!, builder: (context) { return CupertinoAlertDialog( - title: const Text('接收者号码未注册,请选择号码所在的国家并重新发送'), + title: const Text('接收者号码未注册,请重新发送'), actions: [ CupertinoDialogAction( child: Text(TranslationLoader.lanKeys!.cancel!.tr), onPressed: () { - Navigator.of(context).pop(); + Get.back(); }, ), CupertinoDialogAction( - child: Text(TranslationLoader.lanKeys!.select!.tr), + child: Text(TranslationLoader.lanKeys!.sure!.tr), onPressed: () async { //选择国家代码 - state.isCreateUser.value = true; - Navigator.of(context).pop(); + Get.back(); - var result = await Get.toNamed(Routers.selectCountryRegionPage); - if (result != null) { - result as Map; - state.countryCode.value = result['code']; - state.countryName.value = result['countryName']; - } + // var result = await Get.toNamed(Routers.selectCountryRegionPage); + // if (result != null) { + // result as Map; + // state.countryCode.value = result['code']; + // state.countryName.value = result['countryName']; + // } + addAuthorizedAdminRequest(); }, ), ], diff --git a/star_lock/lib/mine/mineSet/authorizedAdministrator/addAuthorizedAdministrator/addAuthorizedAdministrator_page.dart b/star_lock/lib/mine/mineSet/authorizedAdministrator/addAuthorizedAdministrator/addAuthorizedAdministrator_page.dart index 87176c77..aea0a6b0 100644 --- a/star_lock/lib/mine/mineSet/authorizedAdministrator/addAuthorizedAdministrator/addAuthorizedAdministrator_page.dart +++ b/star_lock/lib/mine/mineSet/authorizedAdministrator/addAuthorizedAdministrator/addAuthorizedAdministrator_page.dart @@ -7,16 +7,19 @@ 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/commonItem.dart'; -import 'package:star_lock/tools/dateUtils.dart'; import 'package:star_lock/tools/pickers/pickers.dart'; import 'package:star_lock/tools/pickers/time_picker/model/date_mode.dart'; import 'package:star_lock/tools/submitBtn.dart'; import 'package:star_lock/translations/trans_lib.dart'; +import '../../../../tools/NativeInteractionTool.dart'; +import '../../../../tools/dateTool.dart'; import 'addAuthorizedAdministrator_logic.dart'; class AddAuthorizedAdministratorPage extends StatefulWidget { - const AddAuthorizedAdministratorPage({Key? key}) : super(key: key); + String type; + + AddAuthorizedAdministratorPage({Key? key, required this.type}) : super(key: key); @override State createState() { @@ -28,71 +31,16 @@ class _AddAuthorizedAdministratorPageState extends State().state; - TabController? _tabController; - - List tabs = [ - TranslationLoader.lanKeys!.permanent!.tr, - TranslationLoader.lanKeys!.timeLimit!.tr - ]; - @override void initState() { super.initState(); - _tabController = TabController(length: 2, vsync: this); } @override Widget build(BuildContext context) { - return DefaultTabController( - length: 2, - child: Scaffold( - appBar: AppBar( - backgroundColor: AppColors.mainColor, - title: Text( - TranslationLoader.lanKeys!.addAuthorizedAdmin!.tr, - style: TextStyle( - color: Colors.white, - fontSize: 28.sp, - fontWeight: FontWeight.w600), - ), - elevation: 0, - leading: IconButton( - icon: const Icon(Icons.arrow_back_ios, color: Colors.white), - onPressed: () => Navigator.pop(context, true), - ), - bottom: PreferredSize( - preferredSize: const Size.fromHeight(45), - child: Material( - color: Colors.white, - child: Theme( - data: ThemeData( - ///点击的背景高亮颜色,处理阴影 - highlightColor: Colors.transparent, - - ///点击水波纹颜色 - splashColor: Colors.transparent, - ), - child: TabBar( - controller: _tabController, - indicatorSize: TabBarIndicatorSize.label, - indicatorColor: AppColors.mainColor, - unselectedLabelColor: AppColors.blackColor, - labelColor: AppColors.mainColor, - // isScrollable: true, - tabs: tabs.map((e) => Tab(text: e)).toList()), - )), - ), - ), - body: TabBarView(controller: _tabController, children: [ - SingleChildScrollView( - child: _permanentAdministrator(), - ), - SingleChildScrollView( - child: _timeLimitAdministrator(), - ) - ]), - )); + state.type.value = widget.type; + return Obx(() => SingleChildScrollView(child: widget.type == '0' ? _timeLimitAdministrator() : _permanentAdministrator())); } //永久 @@ -102,9 +50,6 @@ class _AddAuthorizedAdministratorPageState extends State initBottomSheetList() { + List widgetList = []; + + widgetList.add(buildCenter3('images/icon_wechat.png', '微信好友', 0)); + widgetList.add(buildCenter3('images/icon_message.png', '短信', 1)); + widgetList.add(buildCenter3('images/icon_email.png', '邮件', 2)); + widgetList.add(buildCenter3('images/icon_more.png', '更多', 3)); + + return widgetList; + } + + GestureDetector buildCenter3( + String imageName, String titleStr, int itemIndex) { + return GestureDetector( + child: Container( + width: 120.w, + // height: 64.h, + margin: + EdgeInsets.only(top: 20.w, bottom: 20.w, left: 10.w, right: 10.w), + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Image.asset( + imageName, + width: 50.w, + height: 50.h, + ), + SizedBox( + height: 16.w, + ), + Text( + titleStr, + style: TextStyle( + fontSize: ScreenUtil().setSp(20), color: Colors.black), + ), + ], + ), + ), + onTap: () => _jumpSmartDeviceRoute(itemIndex), ); } - Widget _buildSureBtn() { - return SubmitBtn( - btnName: TranslationLoader.lanKeys!.sure!.tr, - onClick: () { - logic.addAuthorizedAdminRequest(); - }, - ); +//\n生效时间:${itemData.startDate}\n类型:永久\n锁名:${itemData.keyboardPwdName} + _jumpSmartDeviceRoute(int itemIndex) { + Get.back(); + switch (itemIndex) { + case 0: + //微信好友 + { + NativeInteractionTool().loadNativeShare(shareText: state.pwdShareStr); + } + break; + case 1: + //短信 + { + NativeInteractionTool().loadNativeShare(shareText: state.pwdShareStr); + } + break; + case 2: + //邮件 + { + Navigator.pushNamed(context, Routers.sendEmailNotificationPage); + } + break; + case 3: + //更多 + { + NativeInteractionTool().loadNativeShare(shareText: state.pwdShareStr); + } + break; + default: + } } + } diff --git a/star_lock/lib/mine/mineSet/authorizedAdministrator/addAuthorizedAdministrator/addAuthorizedAdministrator_state.dart b/star_lock/lib/mine/mineSet/authorizedAdministrator/addAuthorizedAdministrator/addAuthorizedAdministrator_state.dart index c3e9eea3..f8344c44 100644 --- a/star_lock/lib/mine/mineSet/authorizedAdministrator/addAuthorizedAdministrator/addAuthorizedAdministrator_state.dart +++ b/star_lock/lib/mine/mineSet/authorizedAdministrator/addAuthorizedAdministrator/addAuthorizedAdministrator_state.dart @@ -4,6 +4,7 @@ import 'package:flutter_native_contact_picker/flutter_native_contact_picker.dart import 'package:get/get.dart'; import '../../../../main/lockMian/entity/lockListInfo_entity.dart'; +import '../../../../tools/dateTool.dart'; class AddAuthorizedAdministratorState { late TabController? tabController; @@ -17,16 +18,10 @@ class AddAuthorizedAdministratorState { var lockIdList = [].obs; var weekdaysList = [].obs; var isCreateUser = false.obs; //用户未注册时传1 已注册传0 - var selectEffectiveDate = - '${DateTime.now().year}-${DateTime.now().month}-${DateTime.now().day} ${DateTime.now().hour}:${DateTime.now().minute}' - .obs; //默认为当前时间 - var selectFailureDate = - '${DateTime.now().year}-${DateTime.now().month}-${DateTime.now().day} ${DateTime.now().hour}:${DateTime.now().minute}' - .obs; //默认为当前时间 - final effectiveDate = DateTime.now().obs; - final failureDate = DateTime.now().obs; - var startTime = 0.obs; - var endTime = 0.obs; + + var beginDate = DateTool().dateToYMDHNString(DateTime.now().millisecondsSinceEpoch.toString()).obs; //默认为当前时间 开始时间 + var endDate = DateTool().dateToYMDHNString(DateTime.now().millisecondsSinceEpoch.toString()).obs;// + var countryName = '中国'.obs; var countryCode = '86'.obs; var isSendSuccess = false.obs; @@ -34,6 +29,7 @@ class AddAuthorizedAdministratorState { final isAuthentication = false.obs; //是否允许实名认证 final keyInfo = LockListInfoItemEntity().obs; + String pwdShareStr = '您好,您的授权管理员生成成功'; AddAuthorizedAdministratorState() { // Map map = Get.arguments; // if ((map["keyInfo"] != null)) { diff --git a/star_lock/lib/mine/mineSet/authorizedAdministrator/administratorDetails/administratorDetails_logic.dart b/star_lock/lib/mine/mineSet/authorizedAdministrator/administratorDetails/administratorDetails_logic.dart new file mode 100644 index 00000000..63a42f2a --- /dev/null +++ b/star_lock/lib/mine/mineSet/authorizedAdministrator/administratorDetails/administratorDetails_logic.dart @@ -0,0 +1,188 @@ + +import 'package:flutter/material.dart'; +import 'package:get/get.dart'; +import 'package:star_lock/common/XSConstantMacro/XSConstantMacro.dart'; +import 'package:star_lock/tools/baseGetXController.dart'; +import '../../../../main/lockDetail/electronicKey/electronicKeyList/entity/ElectronicKeyListEntity.dart'; +import '../../../../network/api_repository.dart'; +import '../../../../tools/custom_bottom_sheet.dart'; +import '../../../../tools/eventBusEventManage.dart'; +import '../../../../tools/jh_pop_menus.dart'; +import '../../../../tools/showTipView.dart'; +import '../authorizedAdministrator/authorizedAdminListEntity.dart'; +import 'administratorDetailEntity.dart'; +import 'administratorDetails_state.dart'; + +class AdministratorDetailsLogic extends BaseGetXController{ + AdministratorDetailsState state = AdministratorDetailsState(); + + + //管理员详情请求 + Future administratorDetailRequest() async { + AdministratorDetailEntity entity = await ApiRepository.to.authorizedAdminDetail(state.itemData.value.uid ?? 0); + if (entity.errorCode!.codeIsSuccessful) { + print("管理员详情请求成功啦啦啦啦啦"); + state.lockItemList.value = entity.data!.lockList!; + } + } + + //更新管理员信息请求 + Future updateAdministratorRequest(bool isRemote) async { + String isRemoteUnlock = state.isOnRemote.value == true ? '1' : '2'; + ElectronicKeyListEntity entity = await ApiRepository.to.updateAdministrator( + state.itemData.value.uid.toString(), + state.changeNameController.text, + '', + '', + isRemoteUnlock); + if (entity.errorCode!.codeIsSuccessful) { + print("修改管理员信息成功啦啦啦啦啦"); + showToast("修改成功", something: (){ + Get.back(); + }); + } + } + + //删除授权管理员请求 是否删除授权管理员发送的钥匙。 1是,0否 + Future deleteAdministratorRequest(int includeUnderlings) async { + AuthorizedAdminListEntity entity = await ApiRepository.to.deleteAuthorizedAdmin( + state.itemData.value.uid.toString(), + includeUnderlings.toString() + ); + if (entity.errorCode!.codeIsSuccessful) { + print("删除授权管理员成功"); + showToast("删除成功", something: (){ + // eventBus.fire(AuthorizedAdministratorListPageRefreshUI()); + Get.back(); + }); + } + } + + //冻结 + Future freezeKey(int includeUnderlings) async { + ElectronicKeyListEntity entity = await ApiRepository.to.freezeKey( + keyId:state.itemData.value.keyId.toString(), + includeUnderlings: includeUnderlings + ); + if (entity.errorCode!.codeIsSuccessful) { + showToast("设置成功", something: () { + eventBus.fire(ElectronicKeyListRefreshUI()); + eventBus.fire(AuthorizedAdminPageRefreshUI()); + Get.back(); + }); + } + } + + //取消冻结 + Future cancelFreeze(int includeUnderlings) async { + ElectronicKeyListEntity entity = await ApiRepository.to.cancelFreeze( + keyId:state.itemData.value.keyId.toString(), + includeUnderlings: includeUnderlings + ); + if (entity.errorCode!.codeIsSuccessful) { + showToast("设置成功", something: () { + eventBus.fire(ElectronicKeyListRefreshUI()); + eventBus.fire(AuthorizedAdminPageRefreshUI()); + Get.back(); + }); + } + } + + //取消授权管理员 + Future cancelAdministrator() async { + ElectronicKeyListEntity entity = await ApiRepository.to.cancelAdministrator( + keyId:state.itemData.value.keyId.toString(), + ); + if (entity.errorCode!.codeIsSuccessful) { + showToast("设置成功", something: () { + eventBus.fire(ElectronicKeyListRefreshUI()); + eventBus.fire(AuthorizedAdminPageRefreshUI()); + Get.back(); + }); + } + } + + Future openModalBottomSheet() async { + var textList = [state.itemData.value.keyStatus == 110405 ? '取消冻结' : "冻结", '取消授权']; + + showModalBottomSheet( + context: Get.context!, + shape: RoundedRectangleBorder( + borderRadius: BorderRadiusDirectional.circular(10)), + builder: (BuildContext context) { + return AlertBottomWidget( + topTitle: '', + items: textList, + chooseCallback: (value) { + int index = value; + if(index == 0){ + if(state.itemData.value.keyStatus == 110405){ + // 取消冻结 + ShowTipView().showDeleteAdministratorIsHaveAllDataDialog('同时解冻其发送的钥匙', (isAllData) { + cancelFreeze(isAllData ? 1 : 0); + }); + }else{ + ShowTipView().showDeleteAdministratorIsHaveAllDataDialog('同时解冻其发送的钥匙', (isAllData) { + freezeKey(isAllData ? 1 : 0); + }); + } + }else{ + // 取消/授权管理员 + // 管理员 + ShowTipView().showIosTipWithContentDialog("取消授权会在用户APP连网后生效", (){ + cancelAdministrator(); + }); + } + }, + ); + }); + } + + //使用期限 + String getUseDateStr(AuthorizedAdminListItem indexEntity) { + String useDateStr = ''; + if (indexEntity.keyType == XSConstantMacro.keyTypeTime) { + //限期 + DateTime startDateStr = + DateTime.fromMillisecondsSinceEpoch(indexEntity.startDate!); + DateTime endDateStr = + DateTime.fromMillisecondsSinceEpoch(indexEntity.endDate!); + useDateStr = + '${startDateStr.toLocal().toString().substring(0, 16)}\n${endDateStr.toLocal().toString().substring(0, 16)}'; + } else if (indexEntity.keyType == XSConstantMacro.keyTypeLong) { + //永久 + DateTime dateStr = DateTime.fromMillisecondsSinceEpoch(indexEntity.date!); + useDateStr = '${dateStr.toLocal().toString().substring(0, 16)}\n永久'; + } else if (indexEntity.keyType == XSConstantMacro.keyTypeOnce) { + //单次 + DateTime dateStr = DateTime.fromMillisecondsSinceEpoch(indexEntity.date!); + useDateStr = '${dateStr.toLocal().toString().substring(0, 16)} \n单次'; + } else if (indexEntity.keyType == XSConstantMacro.keyTypeLoop) { + //循环 + useDateStr = '循环'; + } + return useDateStr; + } + + @override + void onReady() { + // TODO: implement onReady + super.onReady(); + + administratorDetailRequest(); + } + + @override + void onInit() { + // TODO: implement onInit + super.onInit(); + } + + @override + void onClose() { + // TODO: implement onClose + super.onClose(); + + } + +} \ No newline at end of file diff --git a/star_lock/lib/mine/mineSet/authorizedAdministrator/administratorDetails/administratorDetails_page.dart b/star_lock/lib/mine/mineSet/authorizedAdministrator/administratorDetails/administratorDetails_page.dart index 692b7294..3fe94722 100644 --- a/star_lock/lib/mine/mineSet/authorizedAdministrator/administratorDetails/administratorDetails_page.dart +++ b/star_lock/lib/mine/mineSet/authorizedAdministrator/administratorDetails/administratorDetails_page.dart @@ -1,15 +1,8 @@ import 'package:flutter/cupertino.dart'; 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/common/XSConstantMacro/XSConstantMacro.dart'; -import 'package:star_lock/main/lockDetail/electronicKey/electronicKeyList/entity/ElectronicKeyListEntity.dart'; -import 'package:star_lock/mine/mineSet/authorizedAdministrator/administratorDetails/administratorDetailEntity.dart'; -import 'package:star_lock/network/api_repository.dart'; -import 'package:star_lock/tools/baseGetXController.dart'; import 'package:star_lock/tools/jh_pop_menus.dart'; -import 'package:star_lock/mine/mineSet/authorizedAdministrator/authorizedAdministrator/authorizedAdminListEntity.dart'; import '../../../../../appRouters.dart'; import '../../../../../app_settings/app_colors.dart'; @@ -18,6 +11,8 @@ import '../../../../../tools/showTFView.dart'; import '../../../../../tools/submitBtn.dart'; import '../../../../../tools/titleAppBar.dart'; import '../../../../../translations/trans_lib.dart'; +import '../../../../tools/showTipView.dart'; +import 'administratorDetails_logic.dart'; class AdministratorDetailsPage extends StatefulWidget { const AdministratorDetailsPage({Key? key}) : super(key: key); @@ -28,11 +23,8 @@ class AdministratorDetailsPage extends StatefulWidget { } class _AdministratorDetailsPageState extends State { - final TextEditingController _changeNameController = TextEditingController(); - AuthorizedAdminListItem itemData = AuthorizedAdminListItem(); - bool _isOnRemote = false; - List lockItemList = []; - bool _isFirst = true; + final logic = Get.put(AdministratorDetailsLogic()); + final state = Get.find().state; @override void initState() { @@ -41,15 +33,6 @@ class _AdministratorDetailsPageState extends State { @override Widget build(BuildContext context) { - if (_isFirst == true) { - dynamic obj = ModalRoute.of(context)?.settings.arguments; - if (obj != null && (obj["itemData"] != null)) { - itemData = obj["itemData"]; - } - administratorDetailRequest(); - - _isOnRemote = itemData.isRemoteUnlock == 1 ? true : false; - } return Scaffold( resizeToAvoidBottomInset: false, @@ -65,25 +48,18 @@ class _AdministratorDetailsPageState extends State { width: 10.w, ), onPressed: () { - JhPopMenus.showLinePop(context, - clickCallback: (index, selText) { - print('选中index: $index'); - print('选中text: $selText'); - }, listData: [ - {'text': '冻结'}, - {'text': '取消授权'} - ]); + logic.openModalBottomSheet(); }, ), ], backgroundColor: AppColors.mainColor), - body: Column( + body: Obx(()=>Column( children: [ CommonItem( leftTitel: TranslationLoader.lanKeys!.name!.tr, - rightTitle: _changeNameController.text.isNotEmpty - ? _changeNameController.text - : itemData.name, + rightTitle: state.changeNameController.text.isNotEmpty + ? state.changeNameController.text + : state.itemData.value.name, isHaveDirection: true, isHaveLine: true, action: () { @@ -92,21 +68,21 @@ class _AdministratorDetailsPageState extends State { CommonItem( leftTitel: TranslationLoader.lanKeys!.effectiveTime!.tr, allHeight: 90.h, - rightTitle: getUseDateStr(itemData), + rightTitle: logic.getUseDateStr(state.itemData.value), isHaveDirection: true, action: () { Navigator.pushNamed(context, Routers.adminDetailChangeDatePage, - arguments: {"itemData": itemData}); + arguments: {"itemData": state.itemData.value}); }), Container(height: 10.h), CommonItem( leftTitel: TranslationLoader.lanKeys!.lock!.tr, - rightTitle: itemData.lockNum.toString(), + rightTitle: state.itemData.value.lockNum.toString(), isHaveDirection: false, action: () { - //锁列表页面 + // //锁列表页面 // Navigator.pushNamed(context, Routers.lockItemListPage, - // arguments: {'lockList': lockItemList}); + // arguments: {'lockList': state.lockItemList}); }), Container(height: 10.h), CommonItem( @@ -124,40 +100,15 @@ class _AdministratorDetailsPageState extends State { left: 30.w, right: 30.w, top: 30.w, bottom: 30.w), padding: EdgeInsets.only(top: 25.w, bottom: 25.w), onClick: () { - deleteAdministratorRequest(); + ShowTipView().showDeleteAdministratorIsHaveAllDataDialog('同时删除其发送的所有钥匙,钥匙删除后不能恢复', (isAllData) { + logic.deleteAdministratorRequest(isAllData ? 1 : 0); + }); }), ], - ), + )), ); } - //使用期限 - String getUseDateStr(AuthorizedAdminListItem indexEntity) { - String useDateStr = ''; - if (indexEntity.keyType == XSConstantMacro.keyTypeTime) { - //限期 - DateTime startDateStr = - DateTime.fromMillisecondsSinceEpoch(indexEntity.startDate!); - DateTime endDateStr = - DateTime.fromMillisecondsSinceEpoch(indexEntity.endDate!); - useDateStr = - '${startDateStr.toLocal().toString().substring(0, 16)}\n${endDateStr.toLocal().toString().substring(0, 16)}'; - } else if (indexEntity.keyType == XSConstantMacro.keyTypeLong) { - //永久 - DateTime dateStr = DateTime.fromMillisecondsSinceEpoch(indexEntity.date!); - useDateStr = '${dateStr.toLocal().toString().substring(0, 16)}\n永久'; - } else if (indexEntity.keyType == XSConstantMacro.keyTypeOnce) { - //单次 - DateTime dateStr = DateTime.fromMillisecondsSinceEpoch(indexEntity.date!); - useDateStr = '${dateStr.toLocal().toString().substring(0, 16)} \n单次'; - } else if (indexEntity.keyType == XSConstantMacro.keyTypeLoop) { - //循环 - useDateStr = '循环'; - } - - return useDateStr; - } - Widget commonItem(String leftTitle, String rightTitle, {bool isHaveDirection = false, bool isHaveLine = false, @@ -226,60 +177,16 @@ class _AdministratorDetailsPageState extends State { activeColor: CupertinoColors.activeBlue, trackColor: CupertinoColors.systemGrey5, thumbColor: CupertinoColors.white, - value: _isOnRemote, + value: state.isOnRemote.value, onChanged: (value) { setState(() { - _isOnRemote = !_isOnRemote; - updateAdministratorRequest(true); + state.isOnRemote.value = !state.isOnRemote.value; + logic.updateAdministratorRequest(true); }); }, ); } - //管理员详情请求 - Future administratorDetailRequest() async { - _isFirst = false; - AdministratorDetailEntity entity = - await ApiRepository.to.authorizedAdminDetail(itemData.uid ?? 0); - if (entity.errorCode!.codeIsSuccessful) { - print("管理员详情请求成功啦啦啦啦啦"); - lockItemList = entity.data!.lockList!; - } - } - - //更新管理员信息请求 - Future updateAdministratorRequest(bool isRemote) async { - String isRemoteUnlock = _isOnRemote == true ? '1' : '2'; - ElectronicKeyListEntity entity = await ApiRepository.to.updateAdministrator( - itemData.uid.toString(), - _changeNameController.text, - '', - '', - isRemoteUnlock); - if (entity.errorCode!.codeIsSuccessful) { - print("修改管理员信息成功啦啦啦啦啦"); - EasyLoading.showToast("修改成功",duration: 2000.milliseconds); - setState(() { - if (isRemote) { - Navigator.pop(context); - } - }); - } - } - - //删除授权管理员请求 是否删除授权管理员发送的钥匙。 1是,0否 - Future deleteAdministratorRequest() async { - AuthorizedAdminListEntity entity = await ApiRepository.to - .deleteAuthorizedAdmin(itemData.uid.toString(), '0'); - if (entity.errorCode!.codeIsSuccessful) { - print("删除电子钥匙成功"); - EasyLoading.showToast("删除成功",duration: 2000.milliseconds); - setState(() { - Navigator.pop(context, true); - }); - } - } - void showCupertinoAlertDialog(BuildContext context) { showDialog( context: context, @@ -288,11 +195,11 @@ class _AdministratorDetailsPageState extends State { title: "${TranslationLoader.lanKeys!.amend!.tr} ${TranslationLoader.lanKeys!.name!.tr}", tipTitle: "请输入", - controller: _changeNameController, + controller: state.changeNameController, sureClick: () { //发送编辑钥匙名称请求 - if (_changeNameController.text.isNotEmpty) { - updateAdministratorRequest(false); + if (state.changeNameController.text.isNotEmpty) { + logic.updateAdministratorRequest(false); } }, cancelClick: () { diff --git a/star_lock/lib/mine/mineSet/authorizedAdministrator/administratorDetails/administratorDetails_state.dart b/star_lock/lib/mine/mineSet/authorizedAdministrator/administratorDetails/administratorDetails_state.dart new file mode 100644 index 00000000..c0a20dbf --- /dev/null +++ b/star_lock/lib/mine/mineSet/authorizedAdministrator/administratorDetails/administratorDetails_state.dart @@ -0,0 +1,22 @@ + + +import 'package:flutter/material.dart'; +import 'package:get/get.dart'; + +import '../../../../main/lockDetail/electronicKey/massSendElectronicKey/massSendLockGroupList/massSendLockGroupListEntity.dart'; +import '../authorizedAdministrator/authorizedAdminListEntity.dart'; + +class AdministratorDetailsState{ + final TextEditingController changeNameController = TextEditingController(); + final itemData = AuthorizedAdminListItem().obs; + var isOnRemote = false.obs; + var lockItemList = [].obs; + + AdministratorDetailsState(){ + Map map = Get.arguments; + if (map != null && (map["itemData"] != null)) { + itemData.value = map["itemData"]; + isOnRemote.value = itemData.value.isRemoteUnlock == 1 ? true : false; + } + } +} \ No newline at end of file diff --git a/star_lock/lib/mine/mineSet/authorizedAdministrator/authorizedAdministrator/authorizedAdminListEntity.dart b/star_lock/lib/mine/mineSet/authorizedAdministrator/authorizedAdministrator/authorizedAdminListEntity.dart index 47a035e5..b24895df 100644 --- a/star_lock/lib/mine/mineSet/authorizedAdministrator/authorizedAdministrator/authorizedAdminListEntity.dart +++ b/star_lock/lib/mine/mineSet/authorizedAdministrator/authorizedAdministrator/authorizedAdminListEntity.dart @@ -76,6 +76,7 @@ class AuthorizedAdminListItem { int? keyType; int? date; int? isRemoteUnlock; + int? keyId; AuthorizedAdminListItem( {this.uid, @@ -88,7 +89,8 @@ class AuthorizedAdminListItem { this.userid, this.keyType, this.date, - this.isRemoteUnlock}); + this.isRemoteUnlock, + this.keyId}); AuthorizedAdminListItem.fromJson(Map json) { uid = json['uid']; @@ -102,6 +104,7 @@ class AuthorizedAdminListItem { keyType = json['keyType']; date = json['date']; isRemoteUnlock = json['isRemoteUnlock']; + keyId = json['keyId']; } Map toJson() { @@ -117,6 +120,7 @@ class AuthorizedAdminListItem { data['keyType'] = keyType; data['date'] = date; data['isRemoteUnlock'] = isRemoteUnlock; + data['keyId'] = keyId; return data; } } diff --git a/star_lock/lib/mine/mineSet/authorizedAdministrator/authorizedAdministrator/authorizedAdministratorList_logic.dart b/star_lock/lib/mine/mineSet/authorizedAdministrator/authorizedAdministrator/authorizedAdministratorList_logic.dart new file mode 100644 index 00000000..39f30052 --- /dev/null +++ b/star_lock/lib/mine/mineSet/authorizedAdministrator/authorizedAdministrator/authorizedAdministratorList_logic.dart @@ -0,0 +1,107 @@ + +import 'dart:async'; + +import 'package:star_lock/tools/baseGetXController.dart'; + +import '../../../../common/XSConstantMacro/XSConstantMacro.dart'; +import '../../../../network/api_repository.dart'; +import '../../../../tools/eventBusEventManage.dart'; +import 'authorizedAdminListEntity.dart'; +import 'authorizedAdministratorList_state.dart'; + +class AuthorizedAdministratorListLogic extends BaseGetXController{ + AuthorizedAdministratorListState state = AuthorizedAdministratorListState(); + + //请求授权管理员列表 + Future mockNetworkDataRequest() async { + AuthorizedAdminListEntity entity = await ApiRepository.to.authorizedAdminList( + pageNo.toString(), + pageSize.toString() + ); + if (entity.errorCode!.codeIsSuccessful) { + if (pageNo == 1) { + state.itemDataList.value = entity.data!.itemList!; + pageNo++; + } else { + if (entity.data!.itemList!.isNotEmpty) { + state.itemDataList.value.addAll(entity.data!.itemList!); + print("state.itemDataList.value.length:${state.itemDataList.value.length}"); + pageNo++; + } + } + } + + return entity; + } + + //删除授权管理员请求 是否删除授权管理员发送的钥匙。 1是,0否 + Future deleteAdministratorRequest(String uid, int includeUnderlings) async { + AuthorizedAdminListEntity entity = await ApiRepository.to + .deleteAuthorizedAdmin(uid, includeUnderlings.toString()); + if (entity.errorCode!.codeIsSuccessful) { + showToast("删除成功", something: (){ + pageNo = 1; + mockNetworkDataRequest(); + }); + } + } + + //使用期限 + String getUseDateStr(AuthorizedAdminListItem indexEntity) { + String useDateStr = ''; + if (indexEntity.keyType == XSConstantMacro.keyTypeTime) { + //限期 + if (indexEntity.startDate != null && indexEntity.endDate != null) { + DateTime startDateStr = + DateTime.fromMillisecondsSinceEpoch(indexEntity.startDate!); + DateTime endDateStr = + DateTime.fromMillisecondsSinceEpoch(indexEntity.endDate!); + useDateStr = + '${startDateStr.toLocal().toString().substring(0, 16)}-${endDateStr.toLocal().toString().substring(0, 16)}'; + } else { + useDateStr = '限期'; + } + } else if (indexEntity.keyType == XSConstantMacro.keyTypeLong) { + //永久 + useDateStr = '永久'; + } else if (indexEntity.keyType == XSConstantMacro.keyTypeOnce) { + //单次 + useDateStr = '单次'; + } else if (indexEntity.keyType == XSConstantMacro.keyTypeLoop) { + //循环 + useDateStr = '循环'; + } + return useDateStr; + } + + /// 刷新电子钥匙列表 + StreamSubscription? _authorizedAdministratorListPageRefreshUIEvent; + void _authorizedAdministratorListPageRefreshUIAction() { + // 蓝牙协议通知传输跟蓝牙之外的数据传输类不一样 eventBus + _authorizedAdministratorListPageRefreshUIEvent = eventBus.on().listen((event) { + pageNo = 1; + mockNetworkDataRequest(); + }); + } + + @override + void onReady() { + // TODO: implement onReady + super.onReady(); + _authorizedAdministratorListPageRefreshUIAction(); + } + + @override + void onInit() { + // TODO: implement onInit + super.onInit(); + } + + @override + void onClose() { + // TODO: implement onClose + super.onClose(); + _authorizedAdministratorListPageRefreshUIEvent?.cancel(); + } + +} \ No newline at end of file diff --git a/star_lock/lib/mine/mineSet/authorizedAdministrator/authorizedAdministrator/authorizedAdministratorList_page.dart b/star_lock/lib/mine/mineSet/authorizedAdministrator/authorizedAdministrator/authorizedAdministratorList_page.dart index da80271a..f1b54bf9 100644 --- a/star_lock/lib/mine/mineSet/authorizedAdministrator/authorizedAdministrator/authorizedAdministratorList_page.dart +++ b/star_lock/lib/mine/mineSet/authorizedAdministrator/authorizedAdministrator/authorizedAdministratorList_page.dart @@ -1,19 +1,19 @@ import 'package:flutter/material.dart'; -import 'package:flutter_easyloading/flutter_easyloading.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; +import 'package:flutter_slidable/flutter_slidable.dart'; import 'package:get/get.dart'; -import 'package:star_lock/common/XSConstantMacro/XSConstantMacro.dart'; import 'package:star_lock/mine/mineSet/authorizedAdministrator/authorizedAdministrator/authorizedAdminListEntity.dart'; -import 'package:star_lock/network/api_repository.dart'; -import 'package:star_lock/tools/baseGetXController.dart'; import 'package:star_lock/tools/noData.dart'; import '../../../../../appRouters.dart'; import '../../../../../app_settings/app_colors.dart'; import '../../../../../tools/titleAppBar.dart'; import '../../../../../translations/trans_lib.dart'; -import '../../../../tools/left_slide_actions.dart'; -import '../../../../tools/showIosTipView.dart'; +import '../../../../common/XSConstantMacro/XSConstantMacro.dart'; +import '../../../../tools/EasyRefreshTool.dart'; +import '../../../../tools/showTipView.dart'; +import '../../../../tools/storage.dart'; +import 'authorizedAdministratorList_logic.dart'; class AuthorizedAdministratorListPage extends StatefulWidget { const AuthorizedAdministratorListPage({Key? key}) : super(key: key); @@ -23,11 +23,24 @@ class AuthorizedAdministratorListPage extends StatefulWidget { _AuthorizedAdministratorListPageState(); } -class _AuthorizedAdministratorListPageState - extends State { +class _AuthorizedAdministratorListPageState extends State { + final logic = Get.put(AuthorizedAdministratorListLogic()); + final state = Get.find().state; + + Future getHttpData() async { + var isDemoMode = await Storage.getBool(ifIsDemoModeOrNot); + if (isDemoMode == false) { + logic.mockNetworkDataRequest().then((AuthorizedAdminListEntity value){ + setState(() {}); + }); + } + } + @override void initState() { super.initState(); + + getHttpData(); } @override @@ -49,156 +62,130 @@ class _AuthorizedAdministratorListPageState // 处理操作按钮的点击事件 Navigator.pushNamed(context, Routers.addAuthorizedAdministratorPage).then((value) { setState(() { - mockNetworkDataRequest(); + logic.pageNo = 1; + getHttpData(); }); }); }, ), ], ), - body: FutureBuilder>( - future: 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: [ - // _searchWidget(), - Expanded(child: _buildMainUI(itemList)), - ], - ); - } - } else { - //请求未结束 显示loading - return Container(); - } - }), + body: EasyRefreshTool( + onRefresh: (){ + logic.pageNo = 1; + getHttpData(); + }, + onLoad: (){ + getHttpData(); + }, + child: Column( + children: [ + // _searchWidget(), + Expanded(child: _buildMainUI()), + ], + )), ); } - //请求授权管理员列表 - Future> mockNetworkDataRequest() async { - AuthorizedAdminListEntity entity = - await ApiRepository.to.authorizedAdminList('1', '20'); - List dataList = []; - if (entity.errorCode!.codeIsSuccessful) { - print("授权管理员列表成功:${entity.data?.itemList}"); - if (entity.data != null) { - dataList = entity.data!.itemList!; - // setState(() {}); - } - } - return dataList; - } + // Widget _searchWidget() { + // return Container( + // height: 60.h, + // margin: EdgeInsets.only(top: 20.w, left: 20.w, right: 10.w), + // decoration: BoxDecoration( + // color: Colors.white, borderRadius: BorderRadius.circular(5)), + // child: TextField( + // //输入框一行 + // maxLines: 1, + // // controller: _controller, + // autofocus: false, + // + // decoration: InputDecoration( + // //输入里面输入文字内边距设置 + // contentPadding: const EdgeInsets.only( + // top: 12.0, left: -19.0, right: -15.0, bottom: 8.0), + // hintText: TranslationLoader.lanKeys!.pleaseEnter!.tr, + // hintStyle: TextStyle(fontSize: 22.sp, height: 3.0), + // //不需要输入框下划线 + // border: InputBorder.none, + // //左边图标设置 + // icon: Padding( + // padding: EdgeInsets.only( + // top: 20.h, bottom: 20.h, right: 20.w, left: 10.w), + // child: Image.asset( + // 'images/main/icon_main_search.png', + // width: 40.w, + // height: 40.w, + // ), + // ), + // ), + // ), + // ); + // } - //删除授权管理员请求 是否删除授权管理员发送的钥匙。 1是,0否 - Future deleteAdministratorRequest(String uid) async { - AuthorizedAdminListEntity entity = await ApiRepository.to - .deleteAuthorizedAdmin(uid, '0'); - if (entity.errorCode!.codeIsSuccessful) { - EasyLoading.showToast("删除成功",duration: 2000.milliseconds); - mockNetworkDataRequest(); - } - } + Widget _buildMainUI() { + return Obx(() => state.itemDataList.value.isEmpty + ? NoData(noDataHeight: 1.sh - ScreenUtil().statusBarHeight - ScreenUtil().bottomBarHeight - 190.h - 64.h) + : SlidableAutoCloseBehavior( + child: ListView.separated( + itemCount: state.itemDataList.value.length, + itemBuilder: (c, index) { + AuthorizedAdminListItem authorizedAdminListItem = state.itemDataList.value[index]; - Widget _searchWidget() { - return Container( - height: 60.h, - margin: EdgeInsets.only(top: 20.w, left: 20.w, right: 10.w), - decoration: BoxDecoration( - color: Colors.white, borderRadius: BorderRadius.circular(5)), - child: TextField( - //输入框一行 - maxLines: 1, - // controller: _controller, - autofocus: false, - - decoration: InputDecoration( - //输入里面输入文字内边距设置 - contentPadding: const EdgeInsets.only( - top: 12.0, left: -19.0, right: -15.0, bottom: 8.0), - hintText: TranslationLoader.lanKeys!.pleaseEnter!.tr, - hintStyle: TextStyle(fontSize: 22.sp, height: 3.0), - //不需要输入框下划线 - border: InputBorder.none, - //左边图标设置 - icon: Padding( - padding: EdgeInsets.only( - top: 20.h, bottom: 20.h, right: 20.w, left: 10.w), - child: Image.asset( - 'images/main/icon_main_search.png', - width: 40.w, - height: 40.w, + return Slidable( + key:ValueKey(authorizedAdminListItem.uid), + endActionPane: ActionPane( + extentRatio: 0.2, + motion: const ScrollMotion(), + children: [ + SlidableAction( + onPressed: (BuildContext context){ + ShowTipView().showDeleteAdministratorIsHaveAllDataDialog('同时删除其发送的所有钥匙,钥匙删除后不能恢复', (isAllData) { + logic.deleteAdministratorRequest(authorizedAdminListItem.uid.toString(), isAllData ? 1 : 0); + }); + }, + backgroundColor: Colors.red, + foregroundColor: Colors.white, + label: '删除', + padding: EdgeInsets.only(left: 5.w, right: 5.w), + ), + ], ), - ), - ), + child: _electronicKeyItem(authorizedAdminListItem), + ); + }, + separatorBuilder: (BuildContext context, int index) { + return const Divider( + height: 1, + color: AppColors.greyLineColor, + ); + }, ), - ); - } - - Widget _buildMainUI(List itemList) { - return itemList.isEmpty - ? NoData() - : ListView.builder( - itemCount: itemList.length, - itemBuilder: (c, index) { - AuthorizedAdminListItem itemData = itemList[index]; - if (index < itemList.length) { - return LeftSlideActions( - key: Key(itemData.name!), - actionsWidth: 60, - actions: [ - _buildDeleteBtn(itemData.uid.toString()), - ], - decoration: const BoxDecoration( - borderRadius: BorderRadius.all(Radius.circular(1)), - ), - child: _electronicKeyItem(itemData), - ); - } - return const SizedBox.shrink(); - return _electronicKeyItem(itemData); - }); + )); } Widget _electronicKeyItem(AuthorizedAdminListItem itemData) { return GestureDetector( onTap: () { - Navigator.pushNamed(context, Routers.administratorDetailsPage, - arguments: {'itemData': itemData}).then((value) { + Navigator.pushNamed(context, Routers.administratorDetailsPage, arguments: {'itemData': itemData}).then((value) { setState(() { - mockNetworkDataRequest(); + logic.pageNo = 1; + getHttpData(); }); }); }, child: Container( height: 100.h, + color: Colors.white, // margin: EdgeInsets.only(left: 20.w, right: 20.w, top: 20.w), - decoration: BoxDecoration( - color: Colors.white, + // decoration: const BoxDecoration( + // color: Colors.white, // borderRadius: BorderRadius.circular(10.w), - ), + // ), child: Row( children: [ - SizedBox( - width: 30.w, - ), - Image.asset( - 'images/controls_user.png', - width: 60.w, - height: 60.w, - ), - SizedBox( - width: 20.w, - ), + 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, @@ -227,6 +214,11 @@ class _AuthorizedAdministratorListPageState ], ), ), + SizedBox(width: 10.w), + Text( + XSConstantMacro.getKeyStatusStr(itemData.keyStatus!), + style: TextStyle(fontSize: 18.sp, color: Colors.red), + ), ], ), SizedBox(height: 5.h), @@ -234,7 +226,7 @@ class _AuthorizedAdministratorListPageState mainAxisAlignment: MainAxisAlignment.start, children: [ Text( - getUseDateStr(itemData), + logic.getUseDateStr(itemData), style: TextStyle( fontSize: 18.sp, color: AppColors.placeholderTextColor), @@ -252,74 +244,4 @@ class _AuthorizedAdministratorListPageState ); } - //使用期限 - String getUseDateStr(AuthorizedAdminListItem indexEntity) { - String useDateStr = ''; - if (indexEntity.keyType == XSConstantMacro.keyTypeTime) { - //限期 - if (indexEntity.startDate != null && indexEntity.endDate != null) { - DateTime startDateStr = - DateTime.fromMillisecondsSinceEpoch(indexEntity.startDate!); - DateTime endDateStr = - DateTime.fromMillisecondsSinceEpoch(indexEntity.endDate!); - useDateStr = - '${startDateStr.toLocal().toString().substring(0, 16)}-${endDateStr.toLocal().toString().substring(0, 16)}'; - } else { - useDateStr = '限期'; - } - } else if (indexEntity.keyType == XSConstantMacro.keyTypeLong) { - //永久 - useDateStr = '永久'; - } else if (indexEntity.keyType == XSConstantMacro.keyTypeOnce) { - //单次 - useDateStr = '单次'; - } else if (indexEntity.keyType == XSConstantMacro.keyTypeLoop) { - //循环 - useDateStr = '循环'; - } - - return useDateStr; - } - - void showIosTipViewDialog(BuildContext context, String keyId) { - showDialog( - context: context, - builder: (BuildContext context) { - return ShowIosTipView( - title: "提示", - tipTitle: "确定要删除吗?", - sureClick: () { - Get.back(); - deleteAdministratorRequest(keyId); - }, - cancelClick: () { - Get.back(); - }, - ); - }, - ); - } - - Widget _buildDeleteBtn(String keyId) { - return GestureDetector( - onTap: () { - // 省略: 弹出是否删除的确认对话框。 - showIosTipViewDialog(context, keyId); - }, - 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, - ), - ), - ), - ); - } } diff --git a/star_lock/lib/mine/mineSet/authorizedAdministrator/authorizedAdministrator/authorizedAdministratorList_state.dart b/star_lock/lib/mine/mineSet/authorizedAdministrator/authorizedAdministrator/authorizedAdministratorList_state.dart new file mode 100644 index 00000000..75020042 --- /dev/null +++ b/star_lock/lib/mine/mineSet/authorizedAdministrator/authorizedAdministrator/authorizedAdministratorList_state.dart @@ -0,0 +1,10 @@ + + +import 'package:get/get.dart'; + +import 'authorizedAdminListEntity.dart'; + +class AuthorizedAdministratorListState{ + final itemDataList = [].obs; + // final TextEditingController searchController = TextEditingController(); +} \ No newline at end of file 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 index 96b7e618..e192c555 100644 --- a/star_lock/lib/mine/mineSet/lockUserManage/expireLockList/expireElectronicKey/expireLockList_logic.dart +++ b/star_lock/lib/mine/mineSet/lockUserManage/expireLockList/expireElectronicKey/expireLockList_logic.dart @@ -60,12 +60,12 @@ class ExpireLockListLogic extends BaseGetXController{ deletKeyLogic(ExpireLockItem expireLockItem){ if(expireLockItem.keyRight == 1){ // 授权管理员 - ShowTipView().showDeleteAdministratorIsHaveAllDataDialog((isAllData) { + ShowTipView().showDeleteAdministratorIsHaveAllDataDialog('同时删除其发送的所有钥匙,钥匙删除后不能恢复', (isAllData) { deleteKeyRequest(isAllData ? 1 : 0, expireLockItem); }); }else{ // 普通用户 - ShowTipView().showDeleteKeyDataDialogDialog((){ + ShowTipView().showIosTipWithContentDialog("删除钥匙会在用户APP连网后生效", (){ deleteKeyRequest(0, expireLockItem); }); } diff --git a/star_lock/lib/network/api_provider.dart b/star_lock/lib/network/api_provider.dart index 3b09af3d..886923cf 100644 --- a/star_lock/lib/network/api_provider.dart +++ b/star_lock/lib/network/api_provider.dart @@ -566,17 +566,19 @@ class ApiProvider extends BaseProvider { })); // 冻结 - Future freezeKey(String keyId) => post( + Future freezeKey(String keyId, int includeUnderlings) => post( freezeKeyURL.toUrl, jsonEncode({ 'keyId': keyId, + 'includeUnderlings': includeUnderlings, })); // 取消冻结 - Future cancelFreeze(String keyId) => post( + Future cancelFreeze(String keyId, int includeUnderlings) => post( cancelFreezeURL.toUrl, jsonEncode({ 'keyId': keyId, + 'includeUnderlings': includeUnderlings, })); Future expireLockList(String pageNo, String pageSize) => post( @@ -847,11 +849,12 @@ class ApiProvider extends BaseProvider { })); // 删除 - Future deletStaffData(int lockId, int staffId) => post( + Future deletStaffData(int lockId, int staffId, int deleteKey) => post( deleteStaffURL.toUrl, jsonEncode({ 'lockId': lockId, 'staffId': staffId, + 'deleteKey': deleteKey, })); // 添加员工 @@ -1446,31 +1449,35 @@ class ApiProvider extends BaseProvider { jsonEncode({'endDate': endDate, 'lockIdList': lockIdList})); Future batchSendKey( - String endDate, - List keyGroupIdList, - List lockIdList, - String createUser, - String isRemoteUnlock, - String keyNameForAdmin, - String receiverUsername, - String startDate, - String countryCode, - String usernameType, - List weekDays) => + List lockIds, + int createUser, + String countryCode, + String receiverUsername, + String keyName, + int keyType, + List weekDays, + int startDate, + int endDate, + int startTime, + int endTime, + int remoteUnlockSwitch, + int keyRight) => post( batchSendKeyURL.toUrl, jsonEncode({ - 'endDate': endDate, - 'keyGroupIdList': keyGroupIdList, - 'lockIdList': lockIdList, + 'lockIds': lockIds, 'createUser': createUser, - 'isRemoteUnlock': isRemoteUnlock, - 'keyNameForAdmin': keyNameForAdmin, - 'receiverUsername': receiverUsername, - 'startDate': startDate, 'countryCode': countryCode, - 'usernameType': usernameType, + 'receiverUsername': receiverUsername, + 'keyName': keyName, + 'keyType': keyType, 'weekDays': weekDays, + 'startDate': startDate, + 'endDate': endDate, + 'startTime': startTime, + 'endTime': endTime, + 'remoteUnlockSwitch': remoteUnlockSwitch, + 'keyRight': keyRight, })); Future addAuthorizedAdmin( diff --git a/star_lock/lib/network/api_repository.dart b/star_lock/lib/network/api_repository.dart index 19c3cc07..c05b4b7d 100644 --- a/star_lock/lib/network/api_repository.dart +++ b/star_lock/lib/network/api_repository.dart @@ -578,14 +578,20 @@ class ApiRepository { } //冻结 - Future freezeKey({required String keyId}) async { - final res = await apiProvider.freezeKey(keyId); + Future freezeKey({ + required String keyId, + required int includeUnderlings + }) async { + final res = await apiProvider.freezeKey(keyId, includeUnderlings); return ElectronicKeyListEntity.fromJson(res.body); } //取消冻结 - Future cancelFreeze({required String keyId}) async { - final res = await apiProvider.cancelFreeze(keyId); + Future cancelFreeze({ + required String keyId, + required int includeUnderlings, + }) async { + final res = await apiProvider.cancelFreeze(keyId, includeUnderlings); return ElectronicKeyListEntity.fromJson(res.body); } @@ -852,45 +858,51 @@ class ApiRepository { //群发电子钥匙 Future batchSendKey( { - required String endDate, - required List keyGroupIdList, - required List lockIdList, - required String createUser, - required String isRemoteUnlock, - required String keyNameForAdmin, - required String receiverUsername, - required String startDate, + required List lockIds, + required int createUser, required String countryCode, - required String usernameType, - required List weekDays + required String receiverUsername, + required String keyName, + required int keyType, + required List weekDays, + required int startDate, + required int endDate, + required int startTime, + required int endTime, + required int remoteUnlockSwitch, + required int keyRight }) async { final res = await apiProvider.batchSendKey( - endDate, - keyGroupIdList, - lockIdList, + lockIds, createUser, - isRemoteUnlock, - keyNameForAdmin, - receiverUsername, - startDate, countryCode, - usernameType, - weekDays); + receiverUsername, + keyName, + keyType, + weekDays, + startDate, + endDate, + startTime, + endTime, + remoteUnlockSwitch, + keyRight); return KeyDetailEntity.fromJson(res.body); } //增加授权管理员 Future addAuthorizedAdmin( - String createUser, - String endDate, - String isRemoteUnlock, - List keyGroupIdList, - List lockIdList, - String name, - String startDate, - String userid, - String countryCode, - String usernameType) async { + { + required String createUser, + required String endDate, + required String isRemoteUnlock, + required List keyGroupIdList, + required List lockIdList, + required String name, + required String startDate, + required String userid, + required String countryCode, + required String usernameType + }) async { final res = await apiProvider.addAuthorizedAdmin( createUser, endDate, @@ -920,7 +932,9 @@ class ApiRepository { //删除授权管理员 Future deleteAuthorizedAdmin( - String uid, String includeUnderlings) async { + String uid, + String includeUnderlings + ) async { final res = await apiProvider.deleteAuthorizedAdmin(uid, includeUnderlings); return AuthorizedAdminListEntity.fromJson(res.body); } @@ -1074,8 +1088,9 @@ class ApiRepository { Future deletStaffData({ required int lockId, required int staffId, + required int deleteKey }) async { - final res = await apiProvider.deletStaffData(lockId, staffId); + final res = await apiProvider.deletStaffData(lockId, staffId, deleteKey); return LoginEntity.fromJson(res.body); } diff --git a/star_lock/lib/tools/baseGetXController.dart b/star_lock/lib/tools/baseGetXController.dart index 9b62f098..cc652a39 100644 --- a/star_lock/lib/tools/baseGetXController.dart +++ b/star_lock/lib/tools/baseGetXController.dart @@ -170,10 +170,7 @@ class BaseGetXController extends GetxController { String useDateStr = ''; if (keyType == XSConstantMacro.keyTypeTime) { //限期 - DateTime startDateStr = DateTime.fromMillisecondsSinceEpoch(startDate!); - DateTime endDateStr = DateTime.fromMillisecondsSinceEpoch(endDate!); - useDateStr = - '${startDateStr.toLocal().toString().substring(0, 16)}-${endDateStr.toLocal().toString().substring(0, 16)}'; + useDateStr = "${DateTool().dateToYMDHNString(startDate.toString())}-${DateTool().dateToYMDHNString(endDate.toString())}"; } else if (keyType == XSConstantMacro.keyTypeLong) { //永久 // DateTime dateStr = DateTime.fromMillisecondsSinceEpoch(indexEntity.date!); @@ -186,7 +183,7 @@ class BaseGetXController extends GetxController { useDateStr = '单次'; } else if (keyType == XSConstantMacro.keyTypeLoop) { //循环 - useDateStr = "${DateTool().dateToYMDString(startDate.toString())}-${DateTool().dateToYMDString(endDate.toString())}"; + useDateStr = "循环"; } return useDateStr; diff --git a/star_lock/lib/tools/custom_bottom_sheet.dart b/star_lock/lib/tools/custom_bottom_sheet.dart index a0b47a2b..bbee62f2 100644 --- a/star_lock/lib/tools/custom_bottom_sheet.dart +++ b/star_lock/lib/tools/custom_bottom_sheet.dart @@ -73,15 +73,16 @@ class AlertBottomWidget extends StatelessWidget { ), ), ); - list.add(const Divider( - height: 1, + list.add(Container( + height: 1.h, + color: AppColors.greyBackgroundColor, )); } list.add( Container( color: AppColors.greyBackgroundColor, - height: 8, + height: 5.h, ), ); diff --git a/star_lock/lib/tools/eventBusEventManage.dart b/star_lock/lib/tools/eventBusEventManage.dart index d7c7dbe7..cf1d39e2 100644 --- a/star_lock/lib/tools/eventBusEventManage.dart +++ b/star_lock/lib/tools/eventBusEventManage.dart @@ -20,6 +20,16 @@ class RefreshCheckInStaffListDataEvent { RefreshCheckInStaffListDataEvent(); } +/// 刷新考勤设置 +class RefreshCheckInSetDataEvent { + RefreshCheckInSetDataEvent(); +} + +/// 刷新考勤列表 +class RefreshCheckInListEvent { + RefreshCheckInListEvent(); +} + /// 传递当前锁信息 class PassCurrentLockInformationEvent { LockSetInfoData lockSetInfoData; @@ -115,3 +125,8 @@ class DoorLockLogListRefreshUI { class LockUserManageListRefreshUI { LockUserManageListRefreshUI(); } + +/// 刷新我的更多设置授权管理员列表 +class AuthorizedAdministratorListPageRefreshUI { + AuthorizedAdministratorListPageRefreshUI(); +} \ No newline at end of file diff --git a/star_lock/lib/tools/showDeleteAdministratorIsHaveAllDataWidget.dart b/star_lock/lib/tools/showDeleteAdministratorIsHaveAllDataWidget.dart index c0c48b9a..b5cda199 100644 --- a/star_lock/lib/tools/showDeleteAdministratorIsHaveAllDataWidget.dart +++ b/star_lock/lib/tools/showDeleteAdministratorIsHaveAllDataWidget.dart @@ -6,8 +6,9 @@ typedef BlockIsHaveAllDataCallback = void Function(bool isAllData); class ShowDeleteAdministratorIsHaveAllDataWidget extends StatefulWidget { BlockIsHaveAllDataCallback? blockIsHaveAllDataCallback; + String? contentStr; - ShowDeleteAdministratorIsHaveAllDataWidget({Key? key, this.blockIsHaveAllDataCallback}) : super(key: key); + ShowDeleteAdministratorIsHaveAllDataWidget({Key? key, this.contentStr, this.blockIsHaveAllDataCallback}) : super(key: key); @override State createState() => _ShowDeleteAdministratorIsHaveAllDataWidgetState(); @@ -33,7 +34,7 @@ class _ShowDeleteAdministratorIsHaveAllDataWidgetState extends State=2.12.0 <3.0.0' From 990f2033c2290e94752d19afeca489db3cd62a83 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=AD=8F=E5=B0=91=E9=98=B3?= <786612630@qq.com> Date: Wed, 3 Apr 2024 09:51:26 +0800 Subject: [PATCH 3/3] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E7=89=88=E6=9C=AC?= =?UTF-8?q?=E5=8F=B7=EF=BC=8C=E6=89=93=E5=8C=85=E7=BB=99=E6=AC=A7=E9=98=B3?= =?UTF-8?q?=E6=B5=8B=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../checkingInDetail_page.dart | 29 +++++++++---------- .../recipientInformation_logic.dart | 5 ++++ .../recipientInformation_page.dart | 27 +++++++++-------- star_lock/lib/network/api_provider_base.dart | 1 + star_lock/pubspec.yaml | 3 +- 5 files changed, 36 insertions(+), 29 deletions(-) diff --git a/star_lock/lib/main/lockDetail/checkingIn/checkingInDetail/checkingInDetail_page.dart b/star_lock/lib/main/lockDetail/checkingIn/checkingInDetail/checkingInDetail_page.dart index cee73291..d4e9f3b6 100644 --- a/star_lock/lib/main/lockDetail/checkingIn/checkingInDetail/checkingInDetail_page.dart +++ b/star_lock/lib/main/lockDetail/checkingIn/checkingInDetail/checkingInDetail_page.dart @@ -180,9 +180,10 @@ class _CheckingInDetailPageState extends State { child: Text( array[index], style: TextStyle( - color: index == 5 || index == 6 - ? const Color(0xFFC4C8D0) - : const Color(0xFF3C3E43), + color: + // index == 5 || index == 6 + // ? const Color(0xFFC4C8D0) : + const Color(0xFF3C3E43), fontSize: 26.sp), )); }, @@ -212,14 +213,14 @@ class _CheckingInDetailPageState extends State { Color backColor = Colors.white; // Color textColor = const Color(0xFFFFFFFF); if(_datas[index].workType == "1"){ - backColor = const Color(0xFFE83523); - // textColor = Colors.white; + // 迟到 + backColor = const Color(0xFFE83523); }else if( _datas[index].workType == "2"){ + // 早退 backColor = const Color(0xFFEDB459); - // textColor = Colors.white; }else if( _datas[index].workType == "3"){ + // 未打卡 backColor = const Color(0xFF666666); - // textColor = Colors.white; } return GestureDetector( onTap: () { @@ -263,17 +264,13 @@ class _CheckingInDetailPageState extends State { ? _datas[index].day.toString() : "", textAlign: TextAlign.center, - //设置选中字体颜色,以及周末和工作日颜色 + //设置选中字体颜色 休息的颜色都是黑色 其余的都是白色因为有背景色 style: (int.parse(_datas[index].workType!) > 0) ? TextStyle( fontSize: 24.sp, color: const Color(0xFFFFFFFF)) - : (index % 7 == 5 || index % 7 == 6 - ? TextStyle( - fontSize: 24.sp, - color: const Color(0xFFC4C8D0)) - : TextStyle( - fontSize: 24.sp, - color: const Color(0xFF3C3E43))), + : TextStyle( + fontSize: 24.sp, + color: Colors.black), ), ), ), @@ -336,7 +333,7 @@ class _CheckingInDetailPageState extends State { return Column( children: [ Container( - height: 70.h, + // height: 70.h, padding: EdgeInsets.only(left: 20.w, right: 10.w, top: 20.w, bottom: 20.w), child: Row( diff --git a/star_lock/lib/mine/mineSet/transferSmartLock/recipientInformation/recipientInformation_logic.dart b/star_lock/lib/mine/mineSet/transferSmartLock/recipientInformation/recipientInformation_logic.dart index 74bf3c62..548f0756 100644 --- a/star_lock/lib/mine/mineSet/transferSmartLock/recipientInformation/recipientInformation_logic.dart +++ b/star_lock/lib/mine/mineSet/transferSmartLock/recipientInformation/recipientInformation_logic.dart @@ -20,6 +20,10 @@ class RecipientInformationLogic extends BaseGetXController{ ); if(entity.errorCode!.codeIsSuccessful){ action(entity.data!); + }else { + if(entity.errorCode! == 425){ + showToast(entity.errorMsg!); + } } } @@ -32,6 +36,7 @@ class RecipientInformationLogic extends BaseGetXController{ ); if(entity.errorCode!.codeIsSuccessful){ Get.back(result: "scuess"); + eventBus.fire(RefreshLockListInfoDataEvent()); } } 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 4365d8e1..020b4c37 100644 --- a/star_lock/lib/mine/mineSet/transferSmartLock/recipientInformation/recipientInformation_page.dart +++ b/star_lock/lib/mine/mineSet/transferSmartLock/recipientInformation/recipientInformation_page.dart @@ -227,12 +227,13 @@ class _RecipientInformationPageState extends State { showCupertinoAlertDialog(context, v); }); } else { - Get.toNamed(Routers.selectBranchPage, arguments: { - "idList": state.idList.value, - "countryCode": state.countryCode.value, - "number": state.numberController.text, - "isFromType": state.isFromType.value, - }); + logic.showToast("暂不支持跨平台转移,敬请期待"); + // Get.toNamed(Routers.selectBranchPage, arguments: { + // "idList": state.idList.value, + // "countryCode": state.countryCode.value, + // "number": state.numberController.text, + // "isFromType": state.isFromType.value, + // }); } } else { // 转移网关 @@ -241,12 +242,14 @@ class _RecipientInformationPageState extends State { showCupertinoAlertDialog(context, v); }); } else { - Get.toNamed(Routers.selectBranchPage, arguments: { - "idList": state.idList.value, - "countryCode": state.countryCode.value, - "number": state.numberController.text, - "isFromType": state.isFromType.value - }); + logic.showToast("暂不支持跨平台转移,敬请期待"); + + // Get.toNamed(Routers.selectBranchPage, arguments: { + // "idList": state.idList.value, + // "countryCode": state.countryCode.value, + // "number": state.numberController.text, + // "isFromType": state.isFromType.value + // }); } } }); diff --git a/star_lock/lib/network/api_provider_base.dart b/star_lock/lib/network/api_provider_base.dart index 668add51..fcecaa40 100644 --- a/star_lock/lib/network/api_provider_base.dart +++ b/star_lock/lib/network/api_provider_base.dart @@ -40,6 +40,7 @@ class BaseProvider extends GetConnect with Api { query: query, decoder: decoder, uploadProgress: uploadProgress); + // print('res.body======>${res.body}'); if (res.body == null) { if (EasyLoading.isShow) EasyLoading.dismiss(animation: true); var rs = { diff --git a/star_lock/pubspec.yaml b/star_lock/pubspec.yaml index e7c169ae..03ba9fa1 100644 --- a/star_lock/pubspec.yaml +++ b/star_lock/pubspec.yaml @@ -24,7 +24,8 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev # 1.0.20+2024032102:修复Apple Store App Tracking Transparency权限问题 # 1.0.21+2024032801:同为斯凯环境也区分删减版和完整版,通过main_sky_lite.dart/main_sky_full.dart切换 # 1.0.21+2024032802:1、打包斯凯、预发布环境给欧阳测试 -version: 1.0.21+20240401 +# 1.0.22+20240403:1、打包预发布环境给欧阳测试 +version: 1.0.22+20240403 environment: sdk: '>=2.12.0 <3.0.0'