diff --git a/star_lock/android/app/src/main/AndroidManifest.xml b/star_lock/android/app/src/main/AndroidManifest.xml index 43b621ea..b9f62bec 100644 --- a/star_lock/android/app/src/main/AndroidManifest.xml +++ b/star_lock/android/app/src/main/AndroidManifest.xml @@ -42,7 +42,7 @@ + android:icon="@mipmap/ic_logo"> { itemCount: 2, itemBuilder: (c, index) { return _electronicKeyItem('images/icon_round_unSelet.png', "张三", - "2023.6.21 11.15", "2023.6.21 11.15", () { + "2023.6.21 11.15", "2023.6.21 11.15", index,() { // Navigator.pushNamed(context, Routers.electronicKeyDetailPage); }); }, @@ -120,7 +120,7 @@ class _ImportOtherLockDataPageState extends State { } Widget _electronicKeyItem(String lockTypeIcon, String lockTypeTitle, - String beginTime, String endTime, Function() action) { + String beginTime, String endTime, int index,Function() action) { return GestureDetector( onTap: action, child: Container( @@ -144,7 +144,7 @@ class _ImportOtherLockDataPageState extends State { width: 10.w, ), Text( - 'test锁', + '锁${index+1}', style: TextStyle( color: AppColors.blackColor, fontSize: 22.sp, diff --git a/star_lock/lib/main/lockDetail/lcokSet/lockSet/lockSet_logic.dart b/star_lock/lib/main/lockDetail/lcokSet/lockSet/lockSet_logic.dart index 523a9480..e9e6c470 100644 --- a/star_lock/lib/main/lockDetail/lcokSet/lockSet/lockSet_logic.dart +++ b/star_lock/lib/main/lockDetail/lcokSet/lockSet/lockSet_logic.dart @@ -57,7 +57,7 @@ class LockSetLogic extends BaseGetXController { case 0x00: //成功 print("${reply.commandType}解析成功"); - deletLockInfoData(); + deletKeyData(); break; case 0x06: //无权限 @@ -113,7 +113,7 @@ class LockSetLogic extends BaseGetXController { case 0x00: //成功 print("${reply.commandType!.typeValue} 数据解析成功"); - + deletLockInfoData(); break; case 0x06: //无权限 @@ -155,7 +155,7 @@ class LockSetLogic extends BaseGetXController { } } - // 删除用户蓝牙协议 + // 删除用户 Future deletUserAction() async { BlueManage().judgeReconnect( BlueManage().connectDeviceMacAddress, BlueManage().connectDeviceName, @@ -209,9 +209,9 @@ class LockSetLogic extends BaseGetXController { }); } - // 删除锁调用后台接口 + // 当是锁拥有者的时候,删除锁 void deletLockInfoData() async { - var entity = await ApiRepository.to.deletLockData( + var entity = await ApiRepository.to.deletOwnerLockData( lockId: state.getKeyInfosData.value.lockId.toString(), ); if (entity.errorCode!.codeIsSuccessful) { @@ -219,13 +219,28 @@ class LockSetLogic extends BaseGetXController { } } + // 当不是锁拥有者的时候,删除钥匙 + void deletKeyData() async { + var entity = await ApiRepository.to.deletOwnerKeyData( + lockId: state.getKeyInfosData.value.lockId.toString(), + keyId: state.getKeyInfosData.value.keyId.toString(), + ); + if (entity.errorCode!.codeIsSuccessful) { + Get.offAllNamed(Routers.starLockMain); + } + } + // 查询账户密码 void checkLoginPassword() async { var entity = await ApiRepository.to.checkLoginPassword( password: state.passwordTF.text, ); if (entity.errorCode!.codeIsSuccessful) { - + if(state.getKeyInfosData.value.isLockOwner == 1){ + factoryDataResetAction(); + }else{ + deletKeyData(); + } } } diff --git a/star_lock/lib/main/lockDetail/lcokSet/lockSet/lockSet_page.dart b/star_lock/lib/main/lockDetail/lcokSet/lockSet/lockSet_page.dart index 63201932..f124f417 100644 --- a/star_lock/lib/main/lockDetail/lcokSet/lockSet/lockSet_page.dart +++ b/star_lock/lib/main/lockDetail/lcokSet/lockSet/lockSet_page.dart @@ -449,7 +449,8 @@ class _LockSetPageState extends State with RouteAware { onClick: () { // logic.deletUserAction(); - logic.deletLockInfoData(); + // logic.deletLockInfoData(); + showDeletAlertDialog(context); // showDeletPasswordAlertDialog(context); }), ), @@ -521,7 +522,8 @@ class _LockSetPageState extends State with RouteAware { context: widgetContext, builder: (context) { return CupertinoAlertDialog( - title: const Text('创建公司号,考勤功能才能使用'), + title: const Text("提示"), + content: const Text('创建公司号,考勤功能才能使用'), actions: [ CupertinoDialogAction( child: Text(TranslationLoader.lanKeys!.cancel!.tr), @@ -543,6 +545,52 @@ class _LockSetPageState extends State with RouteAware { ); } + + void showDeletAlertDialog( + BuildContext context, + ) { + // showDialog( + // context: context, + // builder: (BuildContext context) { + // return ShowIosTipView( + // title: "提示", + // tipTitle: "删除锁后,所有信息都会一起删除,确定删除锁吗?", + // sureClick: () { + // Navigator.pop(context); + // showDeletPasswordAlertDialog(context); + // }, + // cancelClick: () { + // Navigator.pop(context); + // }, + // ); + // }, + // ); + showCupertinoDialog( + context: context, + builder: (context) { + return CupertinoAlertDialog( + title: const Text("提示"), + content: const Text('删除锁后,所有信息都会一起删除,确定删除锁吗?'), + actions: [ + CupertinoDialogAction( + child: Text(TranslationLoader.lanKeys!.cancel!.tr), + onPressed: () { + Navigator.pop(context); + }, + ), + CupertinoDialogAction( + child: Text(TranslationLoader.lanKeys!.sure!.tr), + onPressed: () { + Navigator.pop(context); + showDeletPasswordAlertDialog(context); + }, + ), + ], + ); + }, + ); + } + // void showCupertinoAlertDialog( // BuildContext context, // ) { @@ -577,8 +625,12 @@ class _LockSetPageState extends State with RouteAware { tipTitle: "", controller: state.passwordTF, sureClick: () { - //发送编辑钥匙名称请求 - if (state.passwordTF.text.isNotEmpty) {} + //发送删除锁请求 + if (state.passwordTF.text.isEmpty) { + Toast.show(msg: "请输入登录密码"); + return; + } + logic.checkLoginPassword(); }, cancelClick: () { Navigator.pop(context); diff --git a/star_lock/lib/main/lockDetail/lockDetail/lockDetail_logic.dart b/star_lock/lib/main/lockDetail/lockDetail/lockDetail_logic.dart index 660da2a2..c5730fab 100644 --- a/star_lock/lib/main/lockDetail/lockDetail/lockDetail_logic.dart +++ b/star_lock/lib/main/lockDetail/lockDetail/lockDetail_logic.dart @@ -423,7 +423,7 @@ class LockDetailLogic extends BaseGetXController{ privateKey:getPrivateKeyList, ); } - }, isShowLoading: true); + }, isShowLoading: false); } void startScanAction(){ diff --git a/star_lock/lib/main/lockDetail/otherTypeKey/addFingerprint/addFingerprint/addFingerprint_logic.dart b/star_lock/lib/main/lockDetail/otherTypeKey/addFingerprint/addFingerprint/addFingerprint_logic.dart index b2ee0dd0..7a753bf1 100644 --- a/star_lock/lib/main/lockDetail/otherTypeKey/addFingerprint/addFingerprint/addFingerprint_logic.dart +++ b/star_lock/lib/main/lockDetail/otherTypeKey/addFingerprint/addFingerprint/addFingerprint_logic.dart @@ -126,7 +126,7 @@ class AddFingerprintLogic extends BaseGetXController { // 注册指纹失败 print("${reply.commandType!.typeValue} 注册指纹失败"); Toast.show(msg: "添加失败"); - Get.close(3); + Get.close(2); }else{ state.addFingerprintProcessNumber.value++; print("state.addFingerprintProcessNumber.value:${state.addFingerprintProcessNumber.value}"); @@ -334,7 +334,7 @@ class AddFingerprintLogic extends BaseGetXController { }else if(state.fromType.value == 1){ eventBus.fire(OtherTypeRefreshListEvent()); } - Get.close(3); + Get.close(2); } } diff --git a/star_lock/lib/main/lockDetail/otherTypeKey/addFingerprint/addFingerprint/addFingerprint_page.dart b/star_lock/lib/main/lockDetail/otherTypeKey/addFingerprint/addFingerprint/addFingerprint_page.dart index c7ffb92e..939be283 100644 --- a/star_lock/lib/main/lockDetail/otherTypeKey/addFingerprint/addFingerprint/addFingerprint_page.dart +++ b/star_lock/lib/main/lockDetail/otherTypeKey/addFingerprint/addFingerprint/addFingerprint_page.dart @@ -86,29 +86,32 @@ class _AddFingerprintPageState extends State { ), )), SizedBox( - height: 50.h, + height: 100.h, ), Obx(() => Image.asset( getIconNumber(state.addFingerprintProcessNumber.value), - width: 270.w, - height: 457.h, + width: 185.w, + height: 295.h, ),), SizedBox( height: 120.h, ), - Row( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - Expanded( - child: Text( - "根据提示,抬起手指后再进行下一次指纹采集,共4次", - // TranslationLoader.lanKeys!.lightTouchScreenTip!.tr, - textAlign: TextAlign.center, - maxLines:null, - style: TextStyle(fontSize: 24.sp), + Container( + margin: EdgeInsets.all(10.w), + child: Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Expanded( + child: Text( + "根据提示,抬起手指后再进行下一次指纹采集", + // TranslationLoader.lanKeys!.lightTouchScreenTip!.tr, + textAlign: TextAlign.center, + maxLines:null, + style: TextStyle(fontSize: 24.sp), + ), ), - ), - ], + ], + ), ), ], ), @@ -126,9 +129,9 @@ class _AddFingerprintPageState extends State { case 3: return 'images/main/icon_addFingerprint_fingerprint_four.png'; break; - // case 4: - // return 'images/main/icon_addFingerprint_fingerprint_four.png'; - // break; + case 4: + return 'images/main/icon_addFingerprint_fingerprint_five.png'; + break; default: return 'images/main/icon_addFingerprint_fingerprint_one.png'; break; diff --git a/star_lock/lib/main/lockDetail/otherTypeKey/addICCard/addICCard_logic.dart b/star_lock/lib/main/lockDetail/otherTypeKey/addICCard/addICCard_logic.dart index 0d1af107..07609645 100644 --- a/star_lock/lib/main/lockDetail/otherTypeKey/addICCard/addICCard_logic.dart +++ b/star_lock/lib/main/lockDetail/otherTypeKey/addICCard/addICCard_logic.dart @@ -57,7 +57,7 @@ class AddICCardLogic extends BaseGetXController{ case 0x00: //成功 print("${reply.commandType!.typeValue} 数据解析成功"); - state.cardNumber.value = reply.data.last.toString(); + // state.cardNumber.value = reply.data.last.toString(); state.ifConnectScuess.value = true; break; case 0x06: @@ -116,7 +116,15 @@ class AddICCardLogic extends BaseGetXController{ // print("添加指纹确认成功,调用添加指纹接口"); if(state.isCoerced.value == "2"){ // 非胁迫指纹 - addICCardData(); + int addResultStatus = reply.data[5]; + if(addResultStatus == 0){ + // 成功更新序列号 + state.cardNumber.value = (reply.data[6]+1).toString(); + addICCardData(); + }else if(addResultStatus == 255){ + // 255 自动退出 + Get.close(2); + } }else{ // 如果是胁迫指纹在 添加完之后以后再调用添加胁迫指纹的 senderAddStressICCard(); @@ -264,7 +272,7 @@ class AddICCardLogic extends BaseGetXController{ var entity = await ApiRepository.to.updateIdCardUserNoLoadData( lockId: state.lockId.value.toString(), cardId: cardId, - cardUserNo: "0", + cardUserNo: state.cardNumber.value, ); if(entity.errorCode!.codeIsSuccessful){ Toast.show(msg: "添加成功"); diff --git a/star_lock/lib/main/lockDetail/otherTypeKey/otherTypeKeyList/otherTypeKeyList_logic.dart b/star_lock/lib/main/lockDetail/otherTypeKey/otherTypeKeyList/otherTypeKeyList_logic.dart index 51b0a7dd..27106467 100644 --- a/star_lock/lib/main/lockDetail/otherTypeKey/otherTypeKeyList/otherTypeKeyList_logic.dart +++ b/star_lock/lib/main/lockDetail/otherTypeKey/otherTypeKeyList/otherTypeKeyList_logic.dart @@ -29,7 +29,7 @@ class OtherTypeKeyListLogic extends BaseGetXController{ void _initReplySubscription() { _replySubscription = EventBusManager().eventBus!.on().listen((reply) { // 添加指纹开始(重置锁里面所有指纹) - if(reply is SenderAddFingerprintReply) { + if((reply is SenderAddFingerprintReply) && (state.isDeletFingerprintData.value == true)) { _replyAddFingerprintBegin(reply); } @@ -62,6 +62,7 @@ class OtherTypeKeyListLogic extends BaseGetXController{ case 0x00: //成功 print("${reply.commandType!.typeValue} 数据解析成功"); + state.isDeletFingerprintData.value = false; deletAllFingerprintsData(); break; case 0x06: @@ -346,7 +347,7 @@ class OtherTypeKeyListLogic extends BaseGetXController{ IoSenderManage.senderAddFingerprintCommand( keyID:"1", - userID:"Delete All !@#", + userID:"DeleteAll!@#", fingerNo:255, useCountLimit:0, startTime:0x11223344, @@ -385,6 +386,7 @@ class OtherTypeKeyListLogic extends BaseGetXController{ ); if(entity.errorCode!.codeIsSuccessful){ Toast.show(msg: "重置成功"); + state.isDeletFingerprintData.value = false; getFingerprintsListData(); } } diff --git a/star_lock/lib/main/lockDetail/otherTypeKey/otherTypeKeyList/otherTypeKeyList_page.dart b/star_lock/lib/main/lockDetail/otherTypeKey/otherTypeKeyList/otherTypeKeyList_page.dart index 92d72aa2..700f8498 100644 --- a/star_lock/lib/main/lockDetail/otherTypeKey/otherTypeKeyList/otherTypeKeyList_page.dart +++ b/star_lock/lib/main/lockDetail/otherTypeKey/otherTypeKeyList/otherTypeKeyList_page.dart @@ -45,11 +45,13 @@ class _OtherTypeKeyListPageState extends State { switch (state.fromType.value) { case 0: // 卡 + state.isDeletICCardData.value = true; logic.deletICCardData(); break; case 1: // 指纹 // logic.deletAllFingerprintsData(); + state.isDeletFingerprintData.value = true; logic.senderAddFingerprint(); break; case 2: diff --git a/star_lock/lib/main/lockDetail/otherTypeKey/otherTypeKeyList/otherTypeKeyList_state.dart b/star_lock/lib/main/lockDetail/otherTypeKey/otherTypeKeyList/otherTypeKeyList_state.dart index 8f14cda6..0e9b1e66 100644 --- a/star_lock/lib/main/lockDetail/otherTypeKey/otherTypeKeyList/otherTypeKeyList_state.dart +++ b/star_lock/lib/main/lockDetail/otherTypeKey/otherTypeKeyList/otherTypeKeyList_state.dart @@ -8,6 +8,9 @@ class OtherTypeKeyListState{ final lockId = 0.obs; final fromType = 0.obs; + var isDeletFingerprintData = false.obs; + var isDeletICCardData = false.obs; + final fingerprintItemListData = [].obs; final TextEditingController searchController = TextEditingController(); diff --git a/star_lock/lib/main/lockMian/entity/lockInfoEntity.dart b/star_lock/lib/main/lockMian/entity/lockInfoEntity.dart index 8bc6bffb..fccb21a8 100644 --- a/star_lock/lib/main/lockMian/entity/lockInfoEntity.dart +++ b/star_lock/lib/main/lockMian/entity/lockInfoEntity.dart @@ -228,6 +228,7 @@ class KeyInfos { int? displayPasscode; int? lockId; int? doubleVerification; + int? isLockOwner; String? keyName; LockVersion? lockVersion; Bluetooth? bluetooth; @@ -283,6 +284,7 @@ class KeyInfos { this.displayPasscode, this.lockId, this.doubleVerification, + this.isLockOwner, this.keyName, this.lockVersion, this.lockName, @@ -339,6 +341,7 @@ class KeyInfos { displayPasscode = json['displayPasscode']; lockId = json['lockId']; doubleVerification = json['doubleVerification']; + isLockOwner = json['isLockOwner']; keyName = json['keyName']; lockVersion = json['lockVersion'] != null ? LockVersion.fromJson(json['lockVersion']) @@ -401,6 +404,7 @@ class KeyInfos { data['displayPasscode'] = displayPasscode; data['lockId'] = lockId; data['doubleVerification'] = doubleVerification; + data['isLockOwner'] = isLockOwner; data['keyName'] = keyName; if (lockVersion != null) { data['lockVersion'] = lockVersion!.toJson(); diff --git a/star_lock/lib/network/api_provider.dart b/star_lock/lib/network/api_provider.dart index b203f9f2..8898310b 100644 --- a/star_lock/lib/network/api_provider.dart +++ b/star_lock/lib/network/api_provider.dart @@ -313,6 +313,14 @@ class ApiProvider extends BaseProvider { 'lockId': lockId, })); + // 删除拥有的当前钥匙 + Future deletOwnerKeyInfo(String lockId, String keyId) => post( + deletLockURL.toUrl, + jsonEncode({ + 'lockId': lockId, + 'keyId': keyId + })); + // 检查账户密码 Future checkLoginPassword(String password) => post( checkPasswordURL.toUrl, diff --git a/star_lock/lib/network/api_repository.dart b/star_lock/lib/network/api_repository.dart index f64e2f05..d4120f3d 100644 --- a/star_lock/lib/network/api_repository.dart +++ b/star_lock/lib/network/api_repository.dart @@ -328,11 +328,17 @@ class ApiRepository { } // 删除锁 - Future deletLockData({required String lockId}) async { + Future deletOwnerLockData({required String lockId}) async { final res = await apiProvider.deletLockInfo(lockId); return LockMainEntity.fromJson(res.body); } + // 删除钥匙 + Future deletOwnerKeyData({required String lockId, required String keyId}) async { + final res = await apiProvider.deletOwnerKeyInfo(lockId, keyId); + return LockMainEntity.fromJson(res.body); + } + // 检查账户密码 Future checkLoginPassword({required String password}) async { final res = await apiProvider.checkLoginPassword(password);