diff --git a/star_lock/images/lan/lan_en.json b/star_lock/images/lan/lan_en.json index 42f051fd..eed00e5f 100644 --- a/star_lock/images/lan/lan_en.json +++ b/star_lock/images/lan/lan_en.json @@ -830,5 +830,7 @@ "发送人":"Sender", "发送时间":"Send time", "钥匙详情":"Key details", - "姓名":"Name" + "姓名":"Name", + "发送":"Send", + "请确认姓名全名和身份证号码是否正确":"Please confirm that the full name and ID number are correct" } diff --git a/star_lock/images/lan/lan_keys.json b/star_lock/images/lan/lan_keys.json index 1c6184a5..b1e72ad1 100644 --- a/star_lock/images/lan/lan_keys.json +++ b/star_lock/images/lan/lan_keys.json @@ -858,5 +858,7 @@ "发送人":"发送人", "发送时间":"发送时间", "钥匙详情":"钥匙详情", - "姓名":"姓名" + "姓名":"姓名", + "发送":"发送", + "请确认姓名全名和身份证号码是否正确":"请确认姓名全名和身份证号码是否正确" } diff --git a/star_lock/images/lan/lan_zh.json b/star_lock/images/lan/lan_zh.json index 915cf0b3..fabe850c 100644 --- a/star_lock/images/lan/lan_zh.json +++ b/star_lock/images/lan/lan_zh.json @@ -861,5 +861,7 @@ "发送人":"发送人", "发送时间":"发送时间", "钥匙详情":"钥匙详情", - "姓名":"姓名" + "姓名":"姓名", + "发送":"发送", + "请确认姓名全名和身份证号码是否正确":"请确认姓名全名和身份证号码是否正确" } diff --git a/star_lock/lib/blue/blue_manage.dart b/star_lock/lib/blue/blue_manage.dart index 72c3ebc7..3822e77f 100644 --- a/star_lock/lib/blue/blue_manage.dart +++ b/star_lock/lib/blue/blue_manage.dart @@ -375,7 +375,6 @@ class BlueManage { // AppLog.log('bluetoothConnectDevice: $bluetoothConnectDevice'); scanResult = devicesList[knownDeviceIndex]; - _initGetMtuSubscription(); _initListenConnectionState(); } @@ -478,7 +477,7 @@ class BlueManage { // 当包有头时 // 判断是否需要分包 dataLen = data[8] * 256 + data[9]; // 高16位用来指示后面数据块内容的长度 - // AppLog.log("dataLen1111:$dataLen getDataLength:${data.length} data:$data"); + AppLog.log("dataLen1111:$dataLen getDataLength:${data.length} data:$data"); if (dataLen! + 14 > data.length) { // 当前包的长度小于实际的包时 分包添加 不解析 allData.addAll(data); @@ -494,8 +493,9 @@ class BlueManage { // 当包没有头时 是分包的包 直接添加 allData.addAll(data); // var len = allData[8] * 256 + allData[9]; - AppLog.log("dataLen3333:$dataLen allData.length:${allData.length} allData:$allData"); - if ((dataLen! + 14) <= allData.length) { + AppLog.log( + "dataLen3333:$dataLen allData.length:${allData.length} allData:$allData"); + if (((dataLen ?? 0) + 14) <= allData.length) { // 当长度小于等于当前包的数据时 直接解析数据 CommandReciverManager.appDataReceive(allData); // 发送完解析初始化数组 diff --git a/star_lock/lib/blue/io_sender.dart b/star_lock/lib/blue/io_sender.dart index 3d98678d..f51300b1 100644 --- a/star_lock/lib/blue/io_sender.dart +++ b/star_lock/lib/blue/io_sender.dart @@ -34,8 +34,8 @@ abstract class SenderProtocol extends IOData { } void printLog(List data) { - AppLog.log( - "App -> 锁,指令类型:${commandType!.typeName} \n参数是:\n${toString()} \n加密之前数据是:\n$data 长度是:${data.length}"); + // AppLog.log( + // "App -> 锁,指令类型:${commandType!.typeName} \n参数是:\n${toString()} \n加密之前数据是:\n$data 长度是:${data.length}"); } //TODO:拼装数据Ï diff --git a/star_lock/lib/blue/reciver_data.dart b/star_lock/lib/blue/reciver_data.dart index da86dffe..5ba45b40 100644 --- a/star_lock/lib/blue/reciver_data.dart +++ b/star_lock/lib/blue/reciver_data.dart @@ -5,6 +5,7 @@ import 'package:star_lock/app_settings/app_settings.dart'; import 'package:star_lock/blue/blue_manage.dart'; import 'package:star_lock/blue/io_protocol/io_addFace.dart'; import 'package:star_lock/blue/io_protocol/io_changeAdministratorPassword.dart'; +import 'package:star_lock/blue/io_protocol/io_cleanUpUsers.dart'; import 'package:star_lock/blue/io_protocol/io_deletUser.dart'; import 'package:star_lock/blue/io_protocol/io_editUser.dart'; import 'package:star_lock/blue/io_protocol/io_factoryDataReset.dart'; @@ -107,8 +108,11 @@ class CommandReciverManager { AppLog.log("APP收到的解密后的数据:$oriDataList"); break; } - parseData(oriDataList).then((value) async { + parseData(oriDataList).then((Reply? value) async { EasyLoading.dismiss(); + if (value != null) { + AppLog.log("锁 -> App,指令订阅类型 :${value.commandType?.typeName} \n $value"); + } await EventBusManager().eventBusFir(value); }).catchError((error) { AppLog.log("APP解析数据时发生错误: $error"); @@ -195,6 +199,11 @@ class CommandReciverManager { reply = ProcessOtaUpgradeReply.parseData(commandType, data); } break; + case CommandType.cleanUpUsers: + { + reply = CleanUpUsersReply.parseData(commandType, data); + } + break; case CommandType.generalExtendedCommond: { // 子命令类型 diff --git a/star_lock/lib/blue/sender_beforeDataManage.dart b/star_lock/lib/blue/sender_beforeDataManage.dart index 28e636c5..7ddfe49c 100644 --- a/star_lock/lib/blue/sender_beforeDataManage.dart +++ b/star_lock/lib/blue/sender_beforeDataManage.dart @@ -2,6 +2,7 @@ import 'dart:async'; import 'package:flutter_blue_plus/flutter_blue_plus.dart'; import 'package:get/get.dart'; +import 'package:star_lock/blue/io_protocol/io_cleanUpUsers.dart'; import 'package:star_lock/blue/sender_manage.dart'; import 'package:star_lock/main/lockMian/entity/lockListInfo_entity.dart'; import 'package:star_lock/network/api_provider.dart'; @@ -46,9 +47,12 @@ class SenderBeforeDataManage { _replySubscription ??= EventBusManager().eventBus!.on().listen((reply) async { // 添加用户 - if ((reply is AddUserReply)) { + if (reply is AddUserReply) { _replyAddUserKey(reply); } + if(reply is CleanUpUsersReply){ + + } }); } @@ -104,7 +108,7 @@ class SenderBeforeDataManage { keyID: currentKeyInfo.keyId.toString(), userID: await Storage.getUid(), openMode: 1, - keyType: 0, + keyType: currentKeyInfo.keyType, startDate: currentKeyInfo.startDate! ~/ 1000, expireDate: currentKeyInfo.endDate! ~/ 1000, useCountLimit: 0xFFFF, @@ -144,22 +148,17 @@ class SenderBeforeDataManage { List tokenList = changeStringListToIntList(tokenKey!); AppLog.log('---> ${entity.data?.userNos}'); - BlueManage().bludSendData(BlueManage().connectDeviceName, - (BluetoothConnectionState connectionState) async { - if (connectionState == BluetoothConnectionState.connected) { - IoSenderManage.senderCleanUpUsersCommand( - lockID: BlueManage().connectDeviceName, - authUserID: - CommonDataManage().currentKeyInfo.senderUserId!.toString(), - keyID: CommonDataManage().currentKeyInfo.keyId.toString(), - userID: await Storage.getUid(), - userNoList: entity.data!.userNos!, - needAuthor: 1, - publicKey: publicKeyDataList, - privateKey: getPrivateKeyList, - token: tokenList); - } - }); + IoSenderManage.senderCleanUpUsersCommand( + lockID: BlueManage().connectDeviceName, + authUserID: + CommonDataManage().currentKeyInfo.senderUserId!.toString(), + keyID: CommonDataManage().currentKeyInfo.keyId.toString(), + userID: await Storage.getUid(), + userNoList: entity.data!.userNos!, + needAuthor: 1, + publicKey: publicKeyDataList, + privateKey: getPrivateKeyList, + token: tokenList); break; default: @@ -188,7 +187,7 @@ class SenderBeforeDataManage { keyID: currentKeyInfo.keyId.toString(), userID: await Storage.getUid(), openMode: 1, - keyType: 0, + keyType: currentKeyInfo.keyType, startDate: currentKeyInfo.startDate! ~/ 1000, expireDate: currentKeyInfo.endDate! ~/ 1000, useCountLimit: 0xFFFF, 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 d5a84cd8..4de6dffd 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,11 +1,12 @@ - import 'package:flutter/material.dart'; import 'package:get/get.dart'; +import 'package:star_lock/main/lockDetail/electronicKey/electronicKeyDetail/electronicKeyDetail/electronicKeyDetail_page.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'; import 'package:star_lock/main/lockDetail/electronicKey/electronicKeyList/entity/ElectronicKeyListEntity.dart'; import 'package:star_lock/network/api_repository.dart'; import 'package:star_lock/tools/baseGetXController.dart'; +import 'package:star_lock/tools/showCupertinoAlertView.dart'; import '../../../../../tools/custom_bottom_sheet.dart'; import '../../../../../tools/dateTool.dart'; @@ -40,14 +41,14 @@ class ElectronicKeyDetailLogic extends BaseGetXController { //编辑电子钥匙有效期请求 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.endDate.value.toString(), - startDate:state.starDate.value.toString(), - weekDays:state.itemData.value.weekDays!, - keyType:state.itemData.value.keyType!, - startTime:int.parse(state.starTime.value), - endTime:int.parse(state.endTime.value), + keyId: state.itemData.value.keyId.toString(), + lockId: state.itemData.value.lockId.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), + endTime: int.parse(state.endTime.value), isOnlyManageSelf: state.onlyManageYouCreatesUser.value == true ? 1 : 0, remoteEnable: state.isRemoteUnlock.value == true ? 1 : 2); if (entity.errorCode!.codeIsSuccessful) { @@ -61,9 +62,8 @@ class ElectronicKeyDetailLogic extends BaseGetXController { //删除电子钥匙名称请求 Future deleteKeyRequest(int includeUnderlings) async { ElectronicKeyListEntity entity = await ApiRepository.to.deleteElectronicKey( - keyId:state.itemData.value.keyId.toString(), - includeUnderlings: includeUnderlings - ); + keyId: state.itemData.value.keyId.toString(), + includeUnderlings: includeUnderlings); if (entity.errorCode!.codeIsSuccessful) { showToast("删除成功".tr, something: () { eventBus.fire(ElectronicKeyListRefreshUI()); @@ -76,7 +76,7 @@ class ElectronicKeyDetailLogic extends BaseGetXController { //设置授权管理员 Future setAdministrator() async { ElectronicKeyListEntity entity = await ApiRepository.to.setAdministrator( - keyId:state.itemData.value.keyId.toString(), + keyId: state.itemData.value.keyId.toString(), ); if (entity.errorCode!.codeIsSuccessful) { showToast("设置成功".tr, something: () { @@ -90,7 +90,7 @@ class ElectronicKeyDetailLogic extends BaseGetXController { //取消授权管理员 Future cancelAdministrator() async { ElectronicKeyListEntity entity = await ApiRepository.to.cancelAdministrator( - keyId:state.itemData.value.keyId.toString(), + keyId: state.itemData.value.keyId.toString(), ); if (entity.errorCode!.codeIsSuccessful) { showToast("设置成功".tr, something: () { @@ -104,9 +104,8 @@ class ElectronicKeyDetailLogic extends BaseGetXController { //冻结 Future freezeKey(int includeUnderlings) async { ElectronicKeyListEntity entity = await ApiRepository.to.freezeKey( - keyId:state.itemData.value.keyId.toString(), - includeUnderlings: includeUnderlings - ); + keyId: state.itemData.value.keyId.toString(), + includeUnderlings: includeUnderlings); if (entity.errorCode!.codeIsSuccessful) { showToast("设置成功".tr, something: () { eventBus.fire(ElectronicKeyListRefreshUI()); @@ -119,9 +118,8 @@ class ElectronicKeyDetailLogic extends BaseGetXController { //取消冻结 Future cancelFreeze(int includeUnderlings) async { ElectronicKeyListEntity entity = await ApiRepository.to.cancelFreeze( - keyId:state.itemData.value.keyId.toString(), - includeUnderlings: includeUnderlings - ); + keyId: state.itemData.value.keyId.toString(), + includeUnderlings: includeUnderlings); if (entity.errorCode!.codeIsSuccessful) { showToast("设置成功".tr, something: () { eventBus.fire(ElectronicKeyListRefreshUI()); @@ -131,26 +129,119 @@ class ElectronicKeyDetailLogic extends BaseGetXController { } } - String getKeyTypeShowDateTime(){ + //检查实名认证状态 + Future checkRealNameStatus(int realNameAuthStatus) async { + //打开实名认证 必须输入身份证号和真实姓名 + if (realNameAuthStatus == 1) { + if (state.getRealName.value.isEmpty || + state.getIDCardNumber.value.isEmpty) { + ShowCupertinoAlertView() + .showOpenAuthWithIDCardInfoAlert((idCard, realName) { + if (idCard.isNotEmpty && realName.isNotEmpty) { + state.getIDCardNumber.value = idCard; + state.getRealName.value = realName; + updateRealNameInfoWithAuthStatus(realNameAuthStatus); + } else { + showToast("请输入完整信息".tr); + return; + } + }); + } else { + updateRealNameInfoWithAuthStatus(realNameAuthStatus); + } + } else { + updateRealNameInfoWithAuthStatus(realNameAuthStatus); + } + } + + //更新钥匙实名认证信息--实名认证状态 + Future updateRealNameInfoWithAuthStatus(int realNameAuthStatus) async { + KeyOperationRecordEntity entity = await ApiRepository.to.updateRealNameInfo( + lockId: state.itemData.value.lockId ?? 0, + keyId: state.itemData.value.keyId ?? 0, + uid: state.itemData.value.uid ?? 0, + faceAuthentication: realNameAuthStatus, + realName: state.getRealName.value, + idCardNumber: state.getIDCardNumber.value); + if (entity.errorCode!.codeIsSuccessful) { + state.isRealNameAuth.value = !state.isRealNameAuth.value; + showToast("修改成功".tr, something: () { + eventBus.fire(ElectronicKeyListRefreshUI()); + eventBus.fire(AuthorizedAdminPageRefreshUI()); + Get.back(); + }); + } + } + + //更新钥匙实名认证信息 + Future updateRealNameInfoRequest(ShowAlertEnum alertEnum) async { + switch (alertEnum) { + case ShowAlertEnum.realName: + if (state.changeRealNameController.text.isEmpty) { + showToast("请输入真实姓名".tr); + return; + } + break; + case ShowAlertEnum.idCardNumber: + if (state.changeIDCardController.text.isEmpty) { + showToast("请输入身份证号".tr); + return; + } + break; + default: + } + KeyOperationRecordEntity entity = await ApiRepository.to.updateRealNameInfo( + lockId: state.itemData.value.lockId ?? 0, + keyId: state.itemData.value.keyId ?? 0, + uid: state.itemData.value.uid ?? 0, + faceAuthentication: state.isRealNameAuth.value ? 1 : 2, + realName: state.changeRealNameController.text, + idCardNumber: state.changeIDCardController.text); + if (entity.errorCode!.codeIsSuccessful) { + if (alertEnum == ShowAlertEnum.realName) { + state.itemData.value.userIdCard!.realName = + state.changeRealNameController.text; + state.getRealName.value = state.itemData.value.userIdCard!.realName!; + } else if (alertEnum == ShowAlertEnum.idCardNumber) { + state.itemData.value.userIdCard!.idCardNumber = + state.changeIDCardController.text; + state.getIDCardNumber.value = + state.itemData.value.userIdCard!.idCardNumber!; + } + showToast("修改成功".tr, something: () { + eventBus.fire(ElectronicKeyListRefreshUI()); + eventBus.fire(AuthorizedAdminPageRefreshUI()); + }); + } + } + + String getKeyTypeShowDateTime() { String useDateStr = ''; - if(state.keyType.value == 1){ + if (state.keyType.value == 1) { useDateStr = "永久".tr; - }else if(state.keyType.value == 2){ - useDateStr = "${DateTool().dateToYMDHNString(state.starDate.value)}\n${DateTool().dateToYMDHNString(state.endDate.value)}"; - }else if(state.keyType.value == 3){ + } else if (state.keyType.value == 2) { + useDateStr = + "${DateTool().dateToYMDHNString(state.starDate.value)}\n${DateTool().dateToYMDHNString(state.endDate.value)}"; + } else if (state.keyType.value == 3) { useDateStr = "单次".tr; - }else if(state.keyType.value == 4){ - useDateStr = "${DateTool().dateToYMDString(state.starDate.value)}\n${DateTool().dateToYMDString(state.endDate.value)}"; + } else if (state.keyType.value == 4) { + useDateStr = + "${DateTool().dateToYMDString(state.starDate.value)}\n${DateTool().dateToYMDString(state.endDate.value)}"; } return useDateStr; } Future openModalBottomSheet(BuildContext context) async { var textList = []; - if(state.keyType.value == 1 || state.keyType.value == 2){ - textList = [state.itemData.value.keyStatus == 110405 ? '取消冻结'.tr : "冻结".tr, state.itemData.value.keyRight == 1 ? '取消授权'.tr : '授权'.tr]; - } else if(state.keyType.value == 4){ - textList = [state.itemData.value.keyStatus == 110405 ? '取消冻结'.tr : "冻结".tr]; + if (state.keyType.value == 1 || state.keyType.value == 2) { + textList = [ + state.itemData.value.keyStatus == 110405 ? '取消冻结'.tr : "冻结".tr, + state.itemData.value.keyRight == 1 ? '取消授权'.tr : '授权'.tr + ]; + } else if (state.keyType.value == 4) { + textList = [ + state.itemData.value.keyStatus == 110405 ? '取消冻结'.tr : "冻结".tr + ]; } showModalBottomSheet( context: context, @@ -162,40 +253,46 @@ class ElectronicKeyDetailLogic extends BaseGetXController { items: textList, chooseCallback: (value) { int index = value; - if(index == 0){ - if(state.itemData.value.keyStatus == 110405){ + if (index == 0) { + if (state.itemData.value.keyStatus == 110405) { // 取消冻结 - if(state.itemData.value.keyRight == 1){ + if (state.itemData.value.keyRight == 1) { // 管理员 - ShowTipView().showDeleteAdministratorIsHaveAllDataDialog('同时解冻其发送的钥匙'.tr, (isAllData) { + ShowTipView().showDeleteAdministratorIsHaveAllDataDialog( + '同时解冻其发送的钥匙'.tr, (isAllData) { cancelFreeze(isAllData ? 1 : 0); }); - }else{ - ShowTipView().showIosTipWithContentDialog("取消冻结会在用户APP连网后生效".tr, (){ + } else { + ShowTipView() + .showIosTipWithContentDialog("取消冻结会在用户APP连网后生效".tr, () { cancelFreeze(0); }); } - }else{ - if(state.itemData.value.keyRight == 1){ + } else { + if (state.itemData.value.keyRight == 1) { // 管理员 - ShowTipView().showDeleteAdministratorIsHaveAllDataDialog('同时冻结其发送的钥匙'.tr, (isAllData) { + ShowTipView().showDeleteAdministratorIsHaveAllDataDialog( + '同时冻结其发送的钥匙'.tr, (isAllData) { freezeKey(isAllData ? 1 : 0); }); - }else{ - ShowTipView().showIosTipWithContentDialog("冻结会在用户APP连网后生效".tr, (){ + } else { + ShowTipView() + .showIosTipWithContentDialog("冻结会在用户APP连网后生效".tr, () { freezeKey(0); }); } } - }else{ + } else { // 取消/授权管理员 - if(state.itemData.value.keyRight == 1){ + if (state.itemData.value.keyRight == 1) { // 管理员 - ShowTipView().showIosTipWithContentDialog("取消授权会在用户APP连网后生效".tr, (){ + ShowTipView() + .showIosTipWithContentDialog("取消授权会在用户APP连网后生效".tr, () { cancelAdministrator(); }); - }else{ - ShowTipView().showIosTipWithContentDialog("授权用户拥有管理员的大部分权限,比如发送钥匙、发送密码".tr, (){ + } else { + ShowTipView().showIosTipWithContentDialog( + "授权用户拥有管理员的大部分权限,比如发送钥匙、发送密码".tr, () { setAdministrator(); }); } @@ -205,20 +302,38 @@ class ElectronicKeyDetailLogic extends BaseGetXController { }); } - deletKeyLogic(){ - if(state.itemData.value.keyRight == 1){ + deletKeyLogic() { + if (state.itemData.value.keyRight == 1) { // 授权管理员 - ShowTipView().showDeleteAdministratorIsHaveAllDataDialog('同时删除其发送的所有钥匙,钥匙删除后不能恢复'.tr, (isAllData) { + ShowTipView().showDeleteAdministratorIsHaveAllDataDialog( + '同时删除其发送的所有钥匙,钥匙删除后不能恢复'.tr, (isAllData) { deleteKeyRequest(isAllData ? 1 : 0); }); - }else{ + } else { // 普通用户 - ShowTipView().showIosTipWithContentDialog("删除钥匙会在用户APP连网后生效".tr,(){ + ShowTipView().showIosTipWithContentDialog("删除钥匙会在用户APP连网后生效".tr, () { deleteKeyRequest(0); }); } } + TextEditingController getCurrentController(ShowAlertEnum alertEnum) { + TextEditingController currentController = TextEditingController(); + switch (alertEnum) { + case ShowAlertEnum.name: + currentController = state.changeNameController; + break; + case ShowAlertEnum.realName: + currentController = state.changeRealNameController; + break; + case ShowAlertEnum.idCardNumber: + currentController = state.changeIDCardController; + break; + default: + } + return currentController; + } + @override void onReady() { // TODO: implement onReady 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 082976a8..9d9b339c 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 @@ -2,7 +2,9 @@ import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:get/get.dart'; +import 'package:get/get_rx/src/rx_typedefs/rx_typedefs.dart'; import 'package:star_lock/main/lockDetail/electronicKey/electronicKeyDetail/electronicKeyDetail/electronicKeyDetail_logic.dart'; +import 'package:star_lock/tools/showCupertinoAlertView.dart'; import '../../../../../appRouters.dart'; import '../../../../../app_settings/app_colors.dart'; @@ -14,6 +16,8 @@ import '../../../../../tools/showTFView.dart'; import '../../../../../tools/submitBtn.dart'; import '../../../../../tools/titleAppBar.dart'; +enum ShowAlertEnum { name, realName, idCardNumber } + class ElectronicKeyDetailPage extends StatefulWidget { const ElectronicKeyDetailPage({Key? key}) : super(key: key); @@ -57,8 +61,33 @@ class _ElectronicKeyDetailPageState extends State { isHaveDirection: true, isHaveLine: true, action: () { - showCupertinoAlertDialog(context); + showCupertinoAlertDialog( + tipsTitle: "修改姓名".tr, alertEnum: ShowAlertEnum.name); })), + Obx(() => Visibility( + visible: state.isRealNameAuth.value, + child: CommonItem( + leftTitel: '真实姓名'.tr, + rightTitle: state.getRealName.value, + isHaveDirection: true, + isHaveLine: true, + action: () { + showCupertinoAlertDialog( + tipsTitle: "修改真实姓名".tr, + alertEnum: ShowAlertEnum.realName); + }))), + Obx(() => Visibility( + visible: state.isRealNameAuth.value, + child: CommonItem( + leftTitel: '身份证'.tr, + rightTitle: state.getIDCardNumber.value, + isHaveDirection: true, + isHaveLine: true, + action: () { + showCupertinoAlertDialog( + tipsTitle: "修改身份证号".tr, + alertEnum: ShowAlertEnum.idCardNumber); + }))), Obx(() => CommonItem( leftTitel: '有效期'.tr, allHeight: 70.h, @@ -184,31 +213,31 @@ class _ElectronicKeyDetailPageState extends State { rightWidget: SizedBox( width: 60.w, child: _onlyManageYouCreatesUserSwitch())), ), - Visibility( - // (state.keyInfo.value.lockSetting!.remoteUnlock == 1 ? true : false - visible: - CommonDataManage().currentKeyInfo.lockSetting!.remoteUnlock == + Obx( + () => Visibility( + // (state.keyInfo.value.lockSetting!.remoteUnlock == 1 ? true : false + visible: CommonDataManage() + .currentKeyInfo + .lockSetting! + .remoteUnlock == 1 && state.itemData.value.keyRight != 1 ? true : false, - child: CommonItem( - leftTitel: "远程开锁".tr, - rightTitle: "", - isHaveRightWidget: true, - isHaveLine: true, - rightWidget: - SizedBox(width: 60.w, child: _remoteUnlockingSwitch())), + child: CommonItem( + leftTitel: "远程开锁".tr, + rightTitle: "", + isHaveRightWidget: true, + isHaveLine: true, + rightWidget: SizedBox( + width: 60.w, child: _remoteUnlockingSwitch()))), ), - CommonItem( + Obx(() => CommonItem( leftTitel: '实名认证'.tr, rightTitle: "", isHaveRightWidget: true, - rightWidget: SizedBox( - width: 60.w, - child: _switch(state.itemData.value.faceAuthentication == 1 - ? true - : false))), + rightWidget: + SizedBox(width: 60.w, child: _realNameAuthSwitch()))), Container(height: 10.h), CommonItem( leftTitel: '操作记录'.tr, @@ -221,31 +250,36 @@ class _ElectronicKeyDetailPageState extends State { }); }), Container(height: 40.h), - SubmitBtn( - btnName: '删除'.tr, - borderRadius: 20.w, - isDelete: true, - margin: EdgeInsets.only( - left: 30.w, right: 30.w, top: 30.w, bottom: 30.w), - padding: EdgeInsets.only(top: 25.w, bottom: 25.w), - onClick: () { - logic.deletKeyLogic(); - }), + Container( + margin: EdgeInsets.only(left: 20.w, right: 20.w), + child: SubmitBtn( + btnName: '删除'.tr, + borderRadius: 20.w, + isDelete: true, + margin: EdgeInsets.only( + left: 30.w, right: 30.w, top: 30.w, bottom: 30.w), + padding: EdgeInsets.only(top: 25.w, bottom: 25.w), + onClick: () { + logic.deletKeyLogic(); + }), + ), ], ), ); } - CupertinoSwitch _switch(isOn) { + CupertinoSwitch _realNameAuthSwitch() { return CupertinoSwitch( activeColor: CupertinoColors.activeBlue, trackColor: CupertinoColors.systemGrey5, thumbColor: CupertinoColors.white, - value: isOn, + value: state.isRealNameAuth.value, onChanged: (value) { - setState(() { - isOn = value; - }); + if (!state.isRealNameAuth.value) { + logic.checkRealNameStatus(1); + } else { + logic.checkRealNameStatus(2); + } }, ); } @@ -257,10 +291,8 @@ class _ElectronicKeyDetailPageState extends State { thumbColor: CupertinoColors.white, value: state.isRemoteUnlock.value, onChanged: (value) { - setState(() { - state.isRemoteUnlock.value = !state.isRemoteUnlock.value; - logic.updateKeyDateRequest(2); - }); + state.isRemoteUnlock.value = !state.isRemoteUnlock.value; + logic.updateKeyDateRequest(2); }, ); } @@ -281,18 +313,20 @@ class _ElectronicKeyDetailPageState extends State { ); } - void showCupertinoAlertDialog(BuildContext context) { + void showCupertinoAlertDialog( + {required String tipsTitle, required ShowAlertEnum alertEnum}) { showDialog( context: context, builder: (BuildContext context) { return ShowTFView( - title: "修改姓名".tr, + title: tipsTitle, tipTitle: "请输入".tr, - controller: state.changeNameController, + controller: logic.getCurrentController(alertEnum), sureClick: () { - //发送编辑钥匙名称请求 - if (state.changeNameController.text.isNotEmpty) { + if (alertEnum == ShowAlertEnum.name) { logic.modifyKeyNameRequest(); + } else { + logic.updateRealNameInfoRequest(alertEnum); } }, cancelClick: () { diff --git a/star_lock/lib/main/lockDetail/electronicKey/electronicKeyDetail/electronicKeyDetail/electronicKeyDetail_state.dart b/star_lock/lib/main/lockDetail/electronicKey/electronicKeyDetail/electronicKeyDetail/electronicKeyDetail_state.dart index 79e4f016..5b35050e 100644 --- a/star_lock/lib/main/lockDetail/electronicKey/electronicKeyDetail/electronicKeyDetail/electronicKeyDetail_state.dart +++ b/star_lock/lib/main/lockDetail/electronicKey/electronicKeyDetail/electronicKeyDetail/electronicKeyDetail_state.dart @@ -2,24 +2,28 @@ import 'package:flutter/material.dart'; import 'package:get/get.dart'; import 'package:star_lock/main/lockDetail/electronicKey/electronicKeyList/entity/ElectronicKeyListEntity.dart'; -import '../../../../lockMian/entity/lockListInfo_entity.dart'; - class ElectronicKeyDetailState { final itemData = ElectronicKeyListItem().obs; // final keyInfo = LockListInfoItemEntity().obs; final keyName = "".obs; final TextEditingController changeNameController = TextEditingController(); + final TextEditingController changeRealNameController = + TextEditingController(); + final TextEditingController changeIDCardController = TextEditingController(); - var starDate = "".obs;// 开始时间 - var endDate = "".obs;// 结束时间 - var starTime = "".obs;// 生效时间 - var endTime = "".obs;// 失效时间 - final keyType = 0.obs;// 永久:1;限时2,单次3,循环:4 - var weekDay = [].obs;// 有效日 + var starDate = "".obs; // 开始时间 + var endDate = "".obs; // 结束时间 + var starTime = "".obs; // 生效时间 + var endTime = "".obs; // 失效时间 + final keyType = 0.obs; // 永久:1;限时2,单次3,循环:4 + var weekDay = [].obs; // 有效日 - var onlyManageYouCreatesUser = false.obs;// 0:可以管理所有用户 1:只能管理自己创建的用户 + var onlyManageYouCreatesUser = false.obs; // 0:可以管理所有用户 1:只能管理自己创建的用户 var isRemoteUnlock = false.obs; //是否允许远程开锁 0:不允许 1:允许 + var isRealNameAuth = false.obs; //是否实名认证 0:不需要 1:需要 + var getRealName = ''.obs; //真实姓名 + var getIDCardNumber = ''.obs; //身份证号 ElectronicKeyDetailState() { Map map = Get.arguments; @@ -29,9 +33,16 @@ class ElectronicKeyDetailState { // } changeNameController.text = itemData.value.keyName!; keyName.value = itemData.value.keyName!; + if (itemData.value.userIdCard != null) { + getRealName.value = itemData.value.userIdCard!.realName ?? ""; + getIDCardNumber.value = itemData.value.userIdCard!.idCardNumber ?? ""; + } isRemoteUnlock.value = itemData.value.remoteEnable! == 1 ? true : false; - onlyManageYouCreatesUser.value = itemData.value.isOnlyManageSelf! == 0 ? false : true; + isRealNameAuth.value = + itemData.value.faceAuthentication == 1 ? true : false; + onlyManageYouCreatesUser.value = + itemData.value.isOnlyManageSelf! == 0 ? false : true; starDate.value = itemData.value.startDate!.toString(); endDate.value = itemData.value.endDate!.toString(); diff --git a/star_lock/lib/main/lockDetail/electronicKey/electronicKeyList/entity/ElectronicKeyListEntity.dart b/star_lock/lib/main/lockDetail/electronicKey/electronicKeyList/entity/ElectronicKeyListEntity.dart index af33dbfc..01e23f3c 100644 --- a/star_lock/lib/main/lockDetail/electronicKey/electronicKeyList/entity/ElectronicKeyListEntity.dart +++ b/star_lock/lib/main/lockDetail/electronicKey/electronicKeyList/entity/ElectronicKeyListEntity.dart @@ -88,30 +88,34 @@ class ElectronicKeyListItem { int? appUnlockMustOnline; List? weekDays; int? isOnlyManageSelf; + UserIdCard? userIdCard; + int? uid; - ElectronicKeyListItem( - {this.keyId, - this.lockId, - this.username, - this.lockName, - this.lockAlias, - this.userType, - this.keyName, - this.keyStatus, - this.startDate, - this.endDate, - this.keyRight, - this.keyType, - this.senderUsername, - this.remarks, - this.isCameraEnable, - this.faceAuthentication, - this.sendDate, - this.remoteEnable, - this.appUnlockMustOnline, - this.weekDays, - this.isOnlyManageSelf - }); + ElectronicKeyListItem({ + this.keyId, + this.lockId, + this.username, + this.lockName, + this.lockAlias, + this.userType, + this.keyName, + this.keyStatus, + this.startDate, + this.endDate, + this.keyRight, + this.keyType, + this.senderUsername, + this.remarks, + this.isCameraEnable, + this.faceAuthentication, + this.sendDate, + this.remoteEnable, + this.appUnlockMustOnline, + this.weekDays, + this.isOnlyManageSelf, + this.userIdCard, + this.uid, + }); ElectronicKeyListItem.fromJson(Map json) { keyId = json['keyId']; @@ -139,6 +143,10 @@ class ElectronicKeyListItem { appUnlockMustOnline = json['appUnlockMustOnline']; isOnlyManageSelf = json['isOnlyManageSelf']; json['weekDays'] != null ? weekDays = json['weekDays'] : []; + json['userIdCard'] != null + ? userIdCard = UserIdCard.fromJson(json['userIdCard']) + : null; + uid = json['uid']; } Map toJson() { @@ -164,6 +172,29 @@ class ElectronicKeyListItem { data['appUnlockMustOnline'] = appUnlockMustOnline; data['weekDays'] = weekDays; data['isOnlyManageSelf'] = isOnlyManageSelf; + if (userIdCard != null) { + data['userIdCard'] = userIdCard!.toJson(); + } + data['uid'] = uid; + return data; + } +} + +class UserIdCard { + String? realName; + String? idCardNumber; + + UserIdCard({this.realName, this.idCardNumber}); + + UserIdCard.fromJson(Map json) { + realName = json['realName']; + idCardNumber = json['idCardNumber']; + } + + Map toJson() { + final Map data = {}; + data['realName'] = realName; + data['idCardNumber'] = idCardNumber; return data; } } diff --git a/star_lock/lib/main/lockDetail/electronicKey/massSendElectronicKey/massSendLockGroupList/massSendLockGroupList_page.dart b/star_lock/lib/main/lockDetail/electronicKey/massSendElectronicKey/massSendLockGroupList/massSendLockGroupList_page.dart index a532a258..85040399 100644 --- a/star_lock/lib/main/lockDetail/electronicKey/massSendElectronicKey/massSendLockGroupList/massSendLockGroupList_page.dart +++ b/star_lock/lib/main/lockDetail/electronicKey/massSendElectronicKey/massSendLockGroupList/massSendLockGroupList_page.dart @@ -7,7 +7,7 @@ import 'package:star_lock/main/lockDetail/electronicKey/massSendElectronicKey/ma import 'package:star_lock/main/lockDetail/electronicKey/massSendElectronicKey/massSendLockGroupList/massSendLockGroupListEntity.dart'; import 'package:star_lock/main/lockDetail/electronicKey/massSendElectronicKey/massSendLockGroupList/massSendLockGroupList_logic.dart'; import 'package:star_lock/tools/ExpandedListView.dart'; -import 'package:star_lock/tools/advancedFunctionHandle.dart'; +import 'package:star_lock/tools/showCupertinoAlertView.dart'; import 'package:star_lock/tools/submitBtn.dart'; import 'package:star_lock/translations/trans_lib.dart'; @@ -54,7 +54,7 @@ class _MassSendLockGroupListPageState extends State { children: [ Obx(() => Visibility( visible: state.isVip.value ? false : true, - child: AdvancedFunctionHandle() + child: ShowCupertinoAlertView() .topTipsAdvancedFeatures('开通高级功能后才可以对锁进行管理'.tr))), SizedBox( height: 10.h, diff --git a/star_lock/lib/main/lockDetail/electronicKey/massSendElectronicKey/massSendLockGroupList/massSendReceiver/massSendReceiver_page.dart b/star_lock/lib/main/lockDetail/electronicKey/massSendElectronicKey/massSendLockGroupList/massSendReceiver/massSendReceiver_page.dart index e3b80cb9..dc47a998 100644 --- a/star_lock/lib/main/lockDetail/electronicKey/massSendElectronicKey/massSendLockGroupList/massSendReceiver/massSendReceiver_page.dart +++ b/star_lock/lib/main/lockDetail/electronicKey/massSendElectronicKey/massSendLockGroupList/massSendReceiver/massSendReceiver_page.dart @@ -6,7 +6,7 @@ import 'package:star_lock/app_settings/app_colors.dart'; import 'package:star_lock/main/lockDetail/electronicKey/massSendElectronicKey/massSendLockGroupList/lockUserList/lockUserList_entity.dart'; import 'package:star_lock/main/lockDetail/electronicKey/massSendElectronicKey/massSendLockGroupList/massSendReceiver/massSendReceiverCell.dart'; import 'package:star_lock/main/lockDetail/electronicKey/massSendElectronicKey/massSendLockGroupList/massSendReceiver/massSendReceiver_logic.dart'; -import 'package:star_lock/tools/advancedFunctionHandle.dart'; +import 'package:star_lock/tools/showCupertinoAlertView.dart'; import 'package:star_lock/tools/commonItem.dart'; import 'package:star_lock/translations/trans_lib.dart'; @@ -61,7 +61,7 @@ class _MassSendReceiverPageState extends State { children: [ Obx(() => Visibility( visible: state.isVip.value ? false : true, - child: AdvancedFunctionHandle() + child: ShowCupertinoAlertView() .topTipsAdvancedFeatures('开通高级功能后才可以选择和添加接收者'.tr))), Obx(() => Visibility( visible: state.isVip.value ? true : false, diff --git a/star_lock/lib/main/lockDetail/electronicKey/sendElectronicKey/sendElectronicKey/view/sendElectronicKeyView_logic.dart b/star_lock/lib/main/lockDetail/electronicKey/sendElectronicKey/sendElectronicKey/view/sendElectronicKeyView_logic.dart index 9d039292..5aefa554 100644 --- a/star_lock/lib/main/lockDetail/electronicKey/sendElectronicKey/sendElectronicKey/view/sendElectronicKeyView_logic.dart +++ b/star_lock/lib/main/lockDetail/electronicKey/sendElectronicKey/sendElectronicKey/view/sendElectronicKeyView_logic.dart @@ -5,6 +5,7 @@ import 'package:star_lock/common/XSConstantMacro/XSConstantMacro.dart'; import 'package:star_lock/main/lockDetail/electronicKey/sendElectronicKey/sendElectronicKey/view/sendElectronicKeyView_state.dart'; import 'package:star_lock/mine/valueAddedServices/advancedFunctionRecord/advancedFunctionRecord_entity.dart'; import 'package:star_lock/network/api_repository.dart'; +import 'package:star_lock/tools/showCupertinoAlertView.dart'; import 'package:star_lock/tools/baseGetXController.dart'; import 'package:star_lock/tools/commonDataManage.dart'; import 'package:star_lock/tools/dateTool.dart'; @@ -33,7 +34,6 @@ class SendElectronicKeyViewLogic extends BaseGetXController { return; } - //发送钥匙请求 var startDate = "0"; var endDate = "0"; var startTime = "0"; @@ -91,6 +91,50 @@ class SendElectronicKeyViewLogic extends BaseGetXController { } String getKeyType = typeValue.toString(); + //如果打开了实名认证,需要弹出输入身份证信息框 + if (state.isAuthentication.value == true) { + if (state.realNameController.text.isEmpty) { + showToast("请输入真实姓名".tr); + return; + } + + if (state.idCardController.text.isEmpty) { + showToast("请输入身份证号".tr); + return; + } + //弹出身份证信息确认框 + ShowCupertinoAlertView().realNameIDCardInfoComfirmAlert( + getNameStr: state.realNameController.text, + getIDCardStr: state.idCardController.text, + onConfirm: () { + goSendElectronicKey( + startDate: startDate, + endDate: endDate, + startTime: startTime, + endTime: endTime, + typeValue: typeValue, + getKeyType: getKeyType); + }); + } else { + goSendElectronicKey( + startDate: startDate, + endDate: endDate, + startTime: startTime, + endTime: endTime, + typeValue: typeValue, + getKeyType: getKeyType); + } + } + +//只负责发起发送钥匙请求,数据已经准备好 + Future goSendElectronicKey({ + required String startDate, + required String endDate, + required String startTime, + required String endTime, + required int typeValue, + required String getKeyType, + }) async { var entity = await ApiRepository.to.sendElectronicKey( createUser: state.isCreateUser == true ? "1" : "0", countryCode: state.countryCode, diff --git a/star_lock/lib/main/lockDetail/electronicKey/sendElectronicKey/sendElectronicKey/view/sendElectronicKeyView_page.dart b/star_lock/lib/main/lockDetail/electronicKey/sendElectronicKey/sendElectronicKey/view/sendElectronicKeyView_page.dart index a52bcf78..9020a178 100644 --- a/star_lock/lib/main/lockDetail/electronicKey/sendElectronicKey/sendElectronicKey/view/sendElectronicKeyView_page.dart +++ b/star_lock/lib/main/lockDetail/electronicKey/sendElectronicKey/sendElectronicKey/view/sendElectronicKeyView_page.dart @@ -326,7 +326,7 @@ class _SendElectronicKeyViewState extends State ), ), SubmitBtn( - btnName: TranslationLoader.lanKeys!.send!.tr, + btnName: '发送'.tr, onClick: () { if (logic.state.isDemoMode == false) { logic.sendElectronicKeyRequest(); @@ -545,14 +545,16 @@ class _SendElectronicKeyViewState extends State activeColor: CupertinoColors.activeBlue, trackColor: CupertinoColors.systemGrey5, thumbColor: CupertinoColors.white, - value: - isRemote ? logic.state.isRemoteUnlock : logic.state.isAuthentication, + value: isRemote + ? logic.state.isRemoteUnlock + : logic.state.isAuthentication.value, onChanged: (value) { if (isRemote) { logic.state.isRemoteUnlock = !logic.state.isRemoteUnlock; } else { - logic.state.isAuthentication = !logic.state.isAuthentication; - if (logic.state.isAuthentication) { + logic.state.isAuthentication.value = + !logic.state.isAuthentication.value; + if (logic.state.isAuthentication.value == true) { logic.keyCheckFace(); } else { logic.state.isRequireAuth.value = false; diff --git a/star_lock/lib/main/lockDetail/electronicKey/sendElectronicKey/sendElectronicKey/view/sendElectronicKeyView_state.dart b/star_lock/lib/main/lockDetail/electronicKey/sendElectronicKey/sendElectronicKey/view/sendElectronicKeyView_state.dart index a2262042..596b10e7 100644 --- a/star_lock/lib/main/lockDetail/electronicKey/sendElectronicKey/sendElectronicKey/view/sendElectronicKeyView_state.dart +++ b/star_lock/lib/main/lockDetail/electronicKey/sendElectronicKey/sendElectronicKey/view/sendElectronicKeyView_state.dart @@ -14,7 +14,7 @@ class SendElectronicKeyViewState { late Contact contact; bool isRemoteUnlock = false; //是否允许远程开锁 - bool isAuthentication = false; //是否可以实名认证 + var isAuthentication = false.obs; //是否可以实名认证 var timeLimitBeginTime = DateTool().dateToYMDHNString( DateTime.now().millisecondsSinceEpoch.toString()); // 限时开始时间 diff --git a/star_lock/lib/main/lockDetail/messageWarn/addFamily/addFamily_page.dart b/star_lock/lib/main/lockDetail/messageWarn/addFamily/addFamily_page.dart index 1776822a..1ea9edab 100644 --- a/star_lock/lib/main/lockDetail/messageWarn/addFamily/addFamily_page.dart +++ b/star_lock/lib/main/lockDetail/messageWarn/addFamily/addFamily_page.dart @@ -4,7 +4,7 @@ import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:get/get.dart'; import 'package:star_lock/appRouters.dart'; import 'package:star_lock/main/lockDetail/messageWarn/addFamily/addFamily_logic.dart'; -import 'package:star_lock/tools/advancedFunctionHandle.dart'; +import 'package:star_lock/tools/showCupertinoAlertView.dart'; import 'package:star_lock/tools/commonItem.dart'; import 'package:star_lock/tools/showTFView.dart'; import 'package:star_lock/tools/storage.dart'; @@ -125,7 +125,7 @@ class _AddFamilyPageState extends State { logic.addLockNoticeSetting(); } } else { - AdvancedFunctionHandle().advancedFeatureAlert(); + ShowCupertinoAlertView().advancedFeatureAlert(); } }, )), diff --git a/star_lock/lib/main/lockDetail/messageWarn/msgNotification/coerceOpenDoor/coerceFingerprint/coerceFingerprint_page.dart b/star_lock/lib/main/lockDetail/messageWarn/msgNotification/coerceOpenDoor/coerceFingerprint/coerceFingerprint_page.dart index 0fac4e9c..7f2918c0 100644 --- a/star_lock/lib/main/lockDetail/messageWarn/msgNotification/coerceOpenDoor/coerceFingerprint/coerceFingerprint_page.dart +++ b/star_lock/lib/main/lockDetail/messageWarn/msgNotification/coerceOpenDoor/coerceFingerprint/coerceFingerprint_page.dart @@ -3,7 +3,7 @@ import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:get/get.dart'; import 'package:star_lock/appRouters.dart'; import 'package:star_lock/main/lockDetail/messageWarn/msgNotification/coerceOpenDoor/coerceFingerprint/coerceFingerprint_logic.dart'; -import 'package:star_lock/tools/advancedFunctionHandle.dart'; +import 'package:star_lock/tools/showCupertinoAlertView.dart'; import 'package:star_lock/tools/commonItem.dart'; import 'package:star_lock/tools/storage.dart'; import 'package:star_lock/tools/submitBtn.dart'; @@ -118,7 +118,7 @@ class _CoerceFingerprintPageState extends State { logic.addLockNoticeSetting(); } } else { - AdvancedFunctionHandle().advancedFeatureAlert(); + ShowCupertinoAlertView().advancedFeatureAlert(); } }, )), diff --git a/star_lock/lib/main/lockDetail/messageWarn/msgNotification/lowBatteryReminder/lowBatteryReminder_page.dart b/star_lock/lib/main/lockDetail/messageWarn/msgNotification/lowBatteryReminder/lowBatteryReminder_page.dart index a92037e0..fad9a86d 100644 --- a/star_lock/lib/main/lockDetail/messageWarn/msgNotification/lowBatteryReminder/lowBatteryReminder_page.dart +++ b/star_lock/lib/main/lockDetail/messageWarn/msgNotification/lowBatteryReminder/lowBatteryReminder_page.dart @@ -3,7 +3,7 @@ import 'package:flutter/material.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:get/get.dart'; import 'package:star_lock/appRouters.dart'; -import 'package:star_lock/tools/advancedFunctionHandle.dart'; +import 'package:star_lock/tools/showCupertinoAlertView.dart'; import 'package:star_lock/tools/commonItem.dart'; import 'package:star_lock/tools/storage.dart'; import 'package:star_lock/tools/submitBtn.dart'; @@ -118,7 +118,7 @@ class _LowBatteryReminderPageState extends State { onClick: () async { var isVip = await Storage.getBool(saveIsVip); if (isVip == false) { - AdvancedFunctionHandle().advancedFeatureAlert(); + ShowCupertinoAlertView().advancedFeatureAlert(); } else { logic.lockNoticeSettingAccountList(); } diff --git a/star_lock/lib/main/lockDetail/messageWarn/msgNotification/nDaysUnopened/nDaysUnopened_page.dart b/star_lock/lib/main/lockDetail/messageWarn/msgNotification/nDaysUnopened/nDaysUnopened_page.dart index 9211b19a..709b027d 100644 --- a/star_lock/lib/main/lockDetail/messageWarn/msgNotification/nDaysUnopened/nDaysUnopened_page.dart +++ b/star_lock/lib/main/lockDetail/messageWarn/msgNotification/nDaysUnopened/nDaysUnopened_page.dart @@ -4,7 +4,7 @@ import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:get/get.dart'; import 'package:star_lock/appRouters.dart'; import 'package:star_lock/main/lockDetail/messageWarn/msgNotification/msgNotification/msgNotification_entity.dart'; -import 'package:star_lock/tools/advancedFunctionHandle.dart'; +import 'package:star_lock/tools/showCupertinoAlertView.dart'; import 'package:star_lock/tools/commonItem.dart'; import 'package:star_lock/tools/pickers/pickers.dart'; import 'package:star_lock/tools/pickers/style/default_style.dart'; @@ -69,7 +69,7 @@ class _NDaysUnopenedPageState extends State { onClick: () async { var isVip = await Storage.getBool(saveIsVip); if (isVip == false) { - AdvancedFunctionHandle().advancedFeatureAlert(); + ShowCupertinoAlertView().advancedFeatureAlert(); } else { logic.lockNoticeSettingAccountList(); } diff --git a/star_lock/lib/mine/mineSet/lockGroup/groupEditLock/groupEditLock_page.dart b/star_lock/lib/mine/mineSet/lockGroup/groupEditLock/groupEditLock_page.dart index 659d7a91..4201afa9 100644 --- a/star_lock/lib/mine/mineSet/lockGroup/groupEditLock/groupEditLock_page.dart +++ b/star_lock/lib/mine/mineSet/lockGroup/groupEditLock/groupEditLock_page.dart @@ -2,7 +2,7 @@ import 'package:flutter/material.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:get/get.dart'; import 'package:star_lock/main/lockDetail/electronicKey/massSendElectronicKey/massSendLockGroupList/massSendLockGroupListEntity.dart'; -import 'package:star_lock/tools/advancedFunctionHandle.dart'; +import 'package:star_lock/tools/showCupertinoAlertView.dart'; import 'package:star_lock/tools/noData.dart'; import '../../../../../../app_settings/app_colors.dart'; @@ -36,7 +36,7 @@ class _GroupEditLockPageState extends State { children: [ Obx(() => Visibility( visible: state.isVip.value ? false : true, - child: AdvancedFunctionHandle() + child: ShowCupertinoAlertView() .topTipsAdvancedFeatures('开通高级功能后才可以对锁进行管理'.tr))), Container( margin: EdgeInsets.all(15.w), diff --git a/star_lock/lib/network/api.dart b/star_lock/lib/network/api.dart index e6d110b8..16d06347 100644 --- a/star_lock/lib/network/api.dart +++ b/star_lock/lib/network/api.dart @@ -221,6 +221,7 @@ abstract class Api { final String getFaceCertifyIdURL = '/service/getCertifyId'; //获取人脸认证certifyId final String getServiceCheckCertifyURL = '/service/checkCertify'; //检测certifyId是否完成认证 + final String updateRealNameInfoURL = '/key/updateRealName'; //更新实名认证信息 final String getBuyRecordListURL = '/v2/service/getBuyRecordList'; //获取购买记录列表 final String getUseRecordListURL = '/v2/service/getUseRecordList'; //获取使用记录列表 diff --git a/star_lock/lib/network/api_provider.dart b/star_lock/lib/network/api_provider.dart index cffc2d75..a04080b8 100644 --- a/star_lock/lib/network/api_provider.dart +++ b/star_lock/lib/network/api_provider.dart @@ -236,6 +236,26 @@ class ApiProvider extends BaseProvider { 'remoteEnable': remoteEnable, })); + // 更新钥匙实名认证信息 + Future updateRealNameInfo( + int lockId, + int keyId, + int uid, + int faceAuthentication, + String realName, + String idCardNumber, + ) => + post( + updateRealNameInfoURL.toUrl, + jsonEncode({ + 'lockId': lockId, + 'keyId': keyId, + 'uid': uid, + 'faceAuthentication': faceAuthentication, + 'realName': realName, + 'idCardNumber': idCardNumber, + })); + Future resetElectronicKey(String lockId, String operatorUid) => post(resetElectronicKeyURL.toUrl, jsonEncode({'lockId': lockId, 'operatorUid': operatorUid})); diff --git a/star_lock/lib/network/api_repository.dart b/star_lock/lib/network/api_repository.dart index 1a874a09..1edc2755 100644 --- a/star_lock/lib/network/api_repository.dart +++ b/star_lock/lib/network/api_repository.dart @@ -385,6 +385,19 @@ class ApiRepository { return KeyOperationRecordEntity.fromJson(res.body); } + //更新钥匙实名认证信息 + Future updateRealNameInfo( + {required int lockId, + required int keyId, + required int uid, + required int faceAuthentication, + required String realName, + required String idCardNumber}) async { + final res = await apiProvider.updateRealNameInfo( + lockId, keyId, uid, faceAuthentication, realName, idCardNumber); + return KeyOperationRecordEntity.fromJson(res.body); + } + //密码列表 Future passwordKeyList(String keyStatus, String lockId, String pageNo, String pageSize, String searchStr) async { diff --git a/star_lock/lib/tools/advancedFunctionHandle.dart b/star_lock/lib/tools/advancedFunctionHandle.dart deleted file mode 100644 index 19045565..00000000 --- a/star_lock/lib/tools/advancedFunctionHandle.dart +++ /dev/null @@ -1,88 +0,0 @@ -import 'package:flutter/cupertino.dart'; -import 'package:flutter/material.dart'; -import 'package:flutter_screenutil/flutter_screenutil.dart'; -import 'package:get/get.dart'; -import 'package:star_lock/appRouters.dart'; -import 'package:star_lock/app_settings/app_colors.dart'; - -class AdvancedFunctionHandle { - //高级功能弹窗 - void advancedFeatureAlert() { - showCupertinoDialog( - context: Get.context!, - builder: (context) { - return CupertinoAlertDialog( - title: Container( - margin: EdgeInsets.only(bottom: 20.h), - child: Image.asset( - 'images/icon_gift.png', - width: 50.w, - height: 50.w, - ), - ), - content: Text('该功能是高级功能,请开通后再使用'.tr), - actions: [ - CupertinoDialogAction( - child: Text( - '取消'.tr, - style: TextStyle(color: AppColors.mainColor), - ), - onPressed: () { - Get.back(); - }, - ), - CupertinoDialogAction( - child: Text( - '去开通'.tr, - style: TextStyle(color: AppColors.mainColor), - ), - onPressed: () async { - Get.toNamed(Routers.advancedFeaturesWebPage, - arguments: {'isShop': true}); - }, - ), - ], - ); - }); - } - - //高级功能顶部提示框 - Widget topTipsAdvancedFeatures(String tipsText) { - return Container( - color: AppColors.vipFeatureBgColor, - padding: EdgeInsets.only(left: 20.w), - height: 80.h, - child: Row( - children: [ - Text(tipsText, - style: TextStyle( - color: AppColors.vipFeatureBtnTextColor, fontSize: 22.sp)), - SizedBox( - width: 10.w, - ), - SizedBox( - width: 146.w, - height: 46.h, - child: ElevatedButton( - style: ElevatedButton.styleFrom( - backgroundColor: AppColors.vipFeatureBtnBgColor, - ), - onPressed: () { - Get.toNamed(Routers.advancedFeaturesWebPage, arguments: { - 'isShop': true, - }); - }, - child: Text( - '去开通'.tr, - style: TextStyle(color: Colors.white, fontSize: 22.sp), - )), - ), - Expanded( - child: SizedBox( - width: 2.w, - )) - ], - ), - ); - } -} diff --git a/star_lock/lib/tools/showCupertinoAlert.dart b/star_lock/lib/tools/showCupertinoAlert.dart deleted file mode 100644 index 3550be82..00000000 --- a/star_lock/lib/tools/showCupertinoAlert.dart +++ /dev/null @@ -1,56 +0,0 @@ -import 'dart:async'; -import 'package:flutter/cupertino.dart'; - -//封装一个适合我们项目的,结果返回一个 future -//颜色等受系统默认的值影响,这里面就不填写属性了,primaryColor 更新会影响到所有的默认效果 -Future showCupertinoAlert({ - BuildContext? context, //如果没设置全局,需要传递自己的context - String title = '', - String message = '', - confirmText = '确定', - cancelText = '取消', - isShowCancel = true, - isDestructiveConfirm = false, - isDestructiveCancel = false, -}) { - // context = context ?? DialogConfig.context; - final completer = Completer(); - final actions = [ - CupertinoDialogAction( - isDestructiveAction: isDestructiveConfirm, - onPressed: () { - completer.complete(true); - Navigator.of(context!).pop(); - }, - child: Text(confirmText), - ), - ]; - if (isShowCancel) { - actions.insert( - 0, - CupertinoDialogAction( - isDestructiveAction: isDestructiveCancel, - onPressed: () { - completer.complete(false); - Navigator.of(context!).pop(); - }, - child: Text( - cancelText, - ), - ), - ); - } - // showCupertinoModalPopup( - // context: context, - // barrierDismissible: false, - // builder: (BuildContext context) => CupertinoAlertDialog( - // title: Text(title), - // content: Padding( - // padding: const EdgeInsets.only(top: 10), - // child: Text(message), - // ), - // actions: actions, - // ), - // ); - return completer.future; -} diff --git a/star_lock/lib/tools/showCupertinoAlertView.dart b/star_lock/lib/tools/showCupertinoAlertView.dart new file mode 100644 index 00000000..76c2a799 --- /dev/null +++ b/star_lock/lib/tools/showCupertinoAlertView.dart @@ -0,0 +1,223 @@ +import 'package:flutter/cupertino.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter_screenutil/flutter_screenutil.dart'; +import 'package:get/get.dart'; +import 'package:star_lock/appRouters.dart'; +import 'package:star_lock/app_settings/app_colors.dart'; + +typedef AuthInfoCallback = void Function(String idCard, String name); + +class ShowCupertinoAlertView { + //高级功能弹窗 + void advancedFeatureAlert() { + showCupertinoDialog( + context: Get.context!, + builder: (context) { + return CupertinoAlertDialog( + title: Container( + margin: EdgeInsets.only(bottom: 20.h), + child: Image.asset( + 'images/icon_gift.png', + width: 50.w, + height: 50.w, + ), + ), + content: Text('该功能是高级功能,请开通后再使用'.tr), + actions: [ + CupertinoDialogAction( + child: Text( + '取消'.tr, + style: TextStyle(color: AppColors.mainColor), + ), + onPressed: () { + Get.back(); + }, + ), + CupertinoDialogAction( + child: Text( + '去开通'.tr, + style: TextStyle(color: AppColors.mainColor), + ), + onPressed: () async { + Get.toNamed(Routers.advancedFeaturesWebPage, + arguments: {'isShop': true}); + }, + ), + ], + ); + }); + } + + //高级功能顶部提示框 + Widget topTipsAdvancedFeatures(String tipsText) { + return Container( + color: AppColors.vipFeatureBgColor, + padding: EdgeInsets.only(left: 20.w), + height: 80.h, + child: Row( + children: [ + Text(tipsText, + style: TextStyle( + color: AppColors.vipFeatureBtnTextColor, fontSize: 22.sp)), + SizedBox( + width: 10.w, + ), + SizedBox( + width: 146.w, + height: 46.h, + child: ElevatedButton( + style: ElevatedButton.styleFrom( + backgroundColor: AppColors.vipFeatureBtnBgColor, + ), + onPressed: () { + Get.toNamed(Routers.advancedFeaturesWebPage, arguments: { + 'isShop': true, + }); + }, + child: Text( + '去开通'.tr, + style: TextStyle(color: Colors.white, fontSize: 22.sp), + )), + ), + Expanded( + child: SizedBox( + width: 2.w, + )) + ], + ), + ); + } + + //发送需要实名认证的电子钥匙时身份信息确认框 + void realNameIDCardInfoComfirmAlert( + {required String getNameStr, + required String getIDCardStr, + required VoidCallback onConfirm}) { + showCupertinoDialog( + context: Get.context!, + builder: (context) { + return CupertinoAlertDialog( + title: Text('请确认姓名全名和身份证号码是否正确'.tr), + content: Row( + mainAxisAlignment: MainAxisAlignment.start, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + SizedBox( + height: 10.h, + ), + Column( + mainAxisAlignment: MainAxisAlignment.start, + children: [ + Text( + '姓名 ', + style: TextStyle(fontSize: 22.sp, color: Colors.black), + ), + Text( + '身份证', + style: TextStyle(fontSize: 22.sp, color: Colors.black), + ) + ], + ), + SizedBox( + width: 10.w, + ), + Column( + mainAxisAlignment: MainAxisAlignment.start, + children: [ + Text( + getNameStr, + style: TextStyle(fontSize: 22.sp, color: Colors.black), + ), + Text( + getIDCardStr, + style: TextStyle(fontSize: 22.sp, color: Colors.black), + ) + ], + ) + ], + ), + actions: [ + CupertinoDialogAction( + child: Text( + '取消'.tr, + style: TextStyle(color: AppColors.mainColor), + ), + onPressed: () { + Get.back(); + }, + ), + CupertinoDialogAction( + child: Text( + '确定'.tr, + style: TextStyle(color: AppColors.mainColor), + ), + onPressed: () async { + // 执行回调函数 + onConfirm(); + Get.back(); + }, + ), + ], + ); + }); + } + +//打开实名认证弹出输入身份证信息框 + void showOpenAuthWithIDCardInfoAlert(AuthInfoCallback callback) { + showCupertinoDialog( + context: Get.context!, + builder: (BuildContext context) { + String idCard = ''; + String name = ''; + + return CupertinoAlertDialog( + title: const Text('请输入身份证号和真实姓名'), + content: Column( + children: [ + SizedBox( + height: 10.h, + ), + CupertinoTextField( + placeholder: '请输入身份证号', + onChanged: (value) { + idCard = value; + }, + ), + SizedBox( + height: 10.h, + ), + CupertinoTextField( + placeholder: '请输入真实姓名', + onChanged: (value) { + name = value; + }, + ), + ], + ), + actions: [ + CupertinoDialogAction( + onPressed: () { + Get.back(); + }, + child: Text( + '取消'.tr, + style: TextStyle(color: AppColors.mainColor), + ), + ), + CupertinoDialogAction( + onPressed: () { + // 在这里处理确认按钮的逻辑 + callback(idCard, name); + Get.back(); + }, + child: Text( + '确定'.tr, + style: TextStyle(color: AppColors.mainColor), + ), + ), + ], + ); + }, + ); + } +} diff --git a/star_lock/lib/tools/showTFView.dart b/star_lock/lib/tools/showTFView.dart index 586d0057..a21637c0 100644 --- a/star_lock/lib/tools/showTFView.dart +++ b/star_lock/lib/tools/showTFView.dart @@ -3,6 +3,7 @@ import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:get/get.dart'; +import 'package:star_lock/app_settings/app_colors.dart'; import '../translations/trans_lib.dart'; @@ -70,10 +71,8 @@ class ShowTFView extends StatelessWidget { ), actions: [ CupertinoDialogAction( - child: Text( - leftBtnTitle ?? TranslationLoader.lanKeys!.cancel!.tr, - style: const TextStyle(color: Colors.black), - ), + child: Text(leftBtnTitle ?? TranslationLoader.lanKeys!.cancel!.tr, + style: TextStyle(color: AppColors.mainColor)), onPressed: () { // Navigator.pop(context); if (cancelClick != null) { @@ -82,9 +81,8 @@ class ShowTFView extends StatelessWidget { }, ), CupertinoDialogAction( - child: Text( - rightBtnTitle ?? TranslationLoader.lanKeys!.sure!.tr, - style: const TextStyle(color: Colors.black)), + child: Text(rightBtnTitle ?? TranslationLoader.lanKeys!.sure!.tr, + style: TextStyle(color: AppColors.mainColor)), onPressed: () { if (sureClick != null) { sureClick!();