From bb00af74196c957627509e6fd044b56f291a1e4c Mon Sep 17 00:00:00 2001 From: anfe <448468458@qq.com> Date: Thu, 25 Apr 2024 09:39:31 +0800 Subject: [PATCH 1/2] =?UTF-8?q?feat:=E8=81=94=E8=B0=83=20ota?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../lib/blue/io_protocol/io_otaUpgrade.dart | 20 +++++++---- .../io_protocol/io_processOtaUpgrade.dart | 4 +-- star_lock/lib/blue/sender_manage.dart | 4 +-- .../lockDetail/lockNetToken_entity.dart | 2 +- .../lockEscalation/lockEscalation_logic.dart | 33 +++++++++++-------- 5 files changed, 37 insertions(+), 26 deletions(-) diff --git a/star_lock/lib/blue/io_protocol/io_otaUpgrade.dart b/star_lock/lib/blue/io_protocol/io_otaUpgrade.dart index 23e500dd..b7396a5e 100644 --- a/star_lock/lib/blue/io_protocol/io_otaUpgrade.dart +++ b/star_lock/lib/blue/io_protocol/io_otaUpgrade.dart @@ -22,7 +22,7 @@ class OTAUpgradeCommand extends SenderProtocol { int? fwSize; String? fwMD5; int? needAuthor; - List? publicKey; + List? signKey; List? privateKey; List? token; @@ -37,7 +37,7 @@ class OTAUpgradeCommand extends SenderProtocol { this.fwSize, this.fwMD5, this.needAuthor, - this.publicKey, + this.signKey, this.privateKey, this.token}) : super(CommandType.startOATUpgrade); @@ -101,22 +101,24 @@ class OTAUpgradeCommand extends SenderProtocol { // token 长度4 首次请求 Token 填 0,如果锁需要鉴权 操作者身份,则会分配动态口令并在应答消息中返回,二次请求时带上。 当token失效或者第一次发送的时候token为0 data.addAll(token!); + print('--->1'+data.toString()); + if (needAuthor == 0) { //AuthCodeLen 1 data.add(0); } else { List authCodeData = []; - //authUserID - authCodeData.addAll(utf8.encode(userID!)); - //KeyID authCodeData.addAll(utf8.encode(keyID!)); + //UserID + authCodeData.addAll(utf8.encode(userID!)); + //token 4 首次请求 Token 填 0,如果锁需要鉴权操作者身份,则会分配动态口令并在应答消息中返回,二次请求时带上。 authCodeData.addAll(token!); - authCodeData.addAll(publicKey!); + authCodeData.addAll(signKey!); // 把KeyID、authUserID、时间戳、公钥通过md5加密之后就是authCode var authCode = crypto.md5.convert(authCodeData); @@ -140,10 +142,14 @@ class OTAUpgradeCommand extends SenderProtocol { } class OTAUpgradeReply extends Reply { + List token = []; + OTAUpgradeReply.parseData(CommandType commandType, List dataDetail) : super.parseData(commandType, dataDetail) { data = dataDetail; - int status = data[6]; + token = data.sublist(2, 6); + status = data[6]; + print('--->2'+data.toString()); errorWithStstus(status); } } diff --git a/star_lock/lib/blue/io_protocol/io_processOtaUpgrade.dart b/star_lock/lib/blue/io_protocol/io_processOtaUpgrade.dart index 38b52bac..ef3a438f 100644 --- a/star_lock/lib/blue/io_protocol/io_processOtaUpgrade.dart +++ b/star_lock/lib/blue/io_protocol/io_processOtaUpgrade.dart @@ -58,7 +58,7 @@ class ProcessOtaUpgradeReply extends Reply { CommandType commandType, List dataDetail) : super.parseData(commandType, dataDetail) { data = dataDetail; - int status = data[2]; + status = data[2]; errorWithStstus(status); } } @@ -68,7 +68,7 @@ class ConfirmationOTAUpgradeReply extends Reply { CommandType commandType, List dataDetail) : super.parseData(commandType, dataDetail) { data = dataDetail; - int status = data[2]; + status = data[2]; errorWithStstus(status); } } diff --git a/star_lock/lib/blue/sender_manage.dart b/star_lock/lib/blue/sender_manage.dart index 9f1ee9f5..e64b3bef 100644 --- a/star_lock/lib/blue/sender_manage.dart +++ b/star_lock/lib/blue/sender_manage.dart @@ -992,7 +992,7 @@ class IoSenderManage { required String? fwMD5, required int? needAuthor, required List? token, - required List? publicKey, + required List? signKey, required List? privateKey, CommandSendCallBack? callBack}) { CommandSenderManager().managerSendData( @@ -1008,7 +1008,7 @@ class IoSenderManage { fwMD5: fwMD5, token: token, needAuthor: needAuthor, - publicKey: publicKey, + signKey: signKey, privateKey: privateKey, ), callBack: callBack); diff --git a/star_lock/lib/main/lockDetail/lockDetail/lockNetToken_entity.dart b/star_lock/lib/main/lockDetail/lockDetail/lockNetToken_entity.dart index b1be8d76..fc74063a 100644 --- a/star_lock/lib/main/lockDetail/lockDetail/lockNetToken_entity.dart +++ b/star_lock/lib/main/lockDetail/lockDetail/lockNetToken_entity.dart @@ -27,7 +27,7 @@ class LockNetTokenEntity { } class Data { - int? token; + String? token; Data({this.token}); diff --git a/star_lock/lib/main/lockDetail/lockSet/lockEscalation/lockEscalation_logic.dart b/star_lock/lib/main/lockDetail/lockSet/lockEscalation/lockEscalation_logic.dart index 69eb2bac..f7d327f5 100644 --- a/star_lock/lib/main/lockDetail/lockSet/lockEscalation/lockEscalation_logic.dart +++ b/star_lock/lib/main/lockDetail/lockSet/lockEscalation/lockEscalation_logic.dart @@ -33,6 +33,7 @@ class LockEscalationLogic extends BaseGetXController { int otaIndex = 0; Uint8List? otaBin; int startSecond = 0; + Map? headJson = null; // 锁升级 Future setLockSetGeneralSetting() async { @@ -57,29 +58,28 @@ class LockEscalationLogic extends BaseGetXController { } File file = File(result.files.single.path!); Uint8List data = await file.readAsBytes(); - Map? headJson = await getHeadFile(data); + headJson = await getHeadFile(data); if (headJson is! Map) { return; } - otaBin = await checkFile(data, headJson); + otaBin = await checkFile(data, headJson!); if (otaBin == null) { return; } - startOTAData(); - blueOTAUpgrade(headJson); + String md5Str = md5.convert(otaBin!).toString(); + headJson!['fwMd5'] = md5Str; + blueOTAUpgrade(headJson!, [0,0,0,0]); } //蓝牙操作 ota 升级 - void blueOTAUpgrade(Map data) { + void blueOTAUpgrade(Map data, List token) { BlueManage().bludSendData(BlueManage().connectDeviceName, (BluetoothConnectionState deviceConnectionState) async { if (deviceConnectionState == BluetoothConnectionState.connected) { var privateKey = await Storage.getStringList(saveBluePrivateKey); List getPrivateKeyList = changeStringListToIntList(privateKey!); - var token = await Storage.getStringList(saveBlueToken); - List getTokenList = changeStringListToIntList(token!); - var publicKey = await Storage.getStringList(saveBluePublicKey); - List getPublicKeyList = changeStringListToIntList(publicKey!); + var signKey = await Storage.getStringList(saveBlueSignKey); + List signKeyDataList = changeStringListToIntList(signKey!); String lockID = CommonDataManage.shareManager() ?.currentLockSetInfoData .lockId @@ -99,8 +99,8 @@ class LockEscalationLogic extends BaseGetXController { fwSize: data['fwSize'], fwMD5: data['fwMd5'], needAuthor: 1, - token: getTokenList, - publicKey: getPublicKeyList, + token: token, + signKey: signKeyDataList, privateKey: getPrivateKeyList) .packageData()); } else if (deviceConnectionState == @@ -119,6 +119,7 @@ class LockEscalationLogic extends BaseGetXController { int difference = length % 240; otaCount = length ~/ 240 + (difference > 0 ? 1 : 0); startSecond = DateTime.now().millisecondsSinceEpoch ~/ 1000; + startOTAData(); } if (otaCount <= otaIndex) { int now = DateTime.now().millisecondsSinceEpoch ~/ 1000; @@ -216,9 +217,13 @@ class LockEscalationLogic extends BaseGetXController { super.onInit(); _replySubscription = EventBusManager().eventBus!.on().listen((reply) { - if (reply is OTAUpgradeReply && reply.status == 0x00) { - //验证通过,开始发送数据包 - processOtaUpgrade(); + if (reply is OTAUpgradeReply) { + if (reply.status == 0x00) { + //验证通过,开始发送数据包 + processOtaUpgrade(); + } else if (reply.status == 0x06) { + blueOTAUpgrade(headJson!, reply.token); + } } else if (reply is ProcessOtaUpgradeReply && reply.status == 0x00) { otaIndex++; processOtaUpgrade(); From 1d160c9581f7b88c4ab7924e9831eeded4e504a3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=AD=8F=E5=B0=91=E9=98=B3?= <786612630@qq.com> Date: Thu, 25 Apr 2024 09:41:07 +0800 Subject: [PATCH 2/2] =?UTF-8?q?1=E3=80=81=E4=BF=AE=E6=94=B9=E6=B7=BB?= =?UTF-8?q?=E5=8A=A0=E5=8D=A1=E7=95=8C=E9=9D=A2=EF=BC=8C=E5=B7=A6=E5=8F=B3?= =?UTF-8?q?=E6=BB=91=E5=8A=A8=E6=A6=82=E7=8E=87=E7=B1=BB=E5=9E=8B=E9=80=89?= =?UTF-8?q?=E6=8B=A9=E4=B8=8D=E6=88=90=E5=8A=9F=E9=97=AE=E9=A2=98=E3=80=82?= =?UTF-8?q?2=E3=80=81=E4=BF=AE=E6=94=B9=E5=BC=80=E9=94=81=E3=80=81?= =?UTF-8?q?=E5=85=B3=E9=94=81bit=E4=BD=8D=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- star_lock/lib/appRouters.dart | 10 +- .../card/addICCard/addICCard_logic.dart | 2 +- .../checkingInAddStaff_page.dart | 2 +- .../addFingerprintTypeManage_tabbar.dart | 4 +- .../addFingerprintType_logic.dart | 11 +- .../addFingerprintType_page.dart | 216 +++++++++++------- .../addFingerprintType_state.dart | 20 +- .../fingerprintList/fingerprintList_page.dart | 2 +- .../lockDetail/lockDetail_page.dart | 41 ++-- .../lockDetail/lockDetail_state.dart | 2 +- 10 files changed, 186 insertions(+), 124 deletions(-) diff --git a/star_lock/lib/appRouters.dart b/star_lock/lib/appRouters.dart index af486893..4366b083 100644 --- a/star_lock/lib/appRouters.dart +++ b/star_lock/lib/appRouters.dart @@ -56,7 +56,6 @@ import 'login/forgetPassword/starLock_forgetPassword_page.dart'; import 'login/login/starLock_login_page.dart'; import 'login/register/starLock_register_page.dart'; import 'login/selectCountryRegion/selectCountryRegion_page.dart'; -import 'main/lockDetail/card/addCardType/addCardManage/addCardTypeManage_page.dart'; import 'main/lockDetail/card/addCardType/addCardType_page.dart'; import 'main/lockDetail/card/addICCard/addICCard_page.dart'; import 'main/lockDetail/card/cardDetail/cardDetail_page.dart'; @@ -80,7 +79,7 @@ import 'main/lockDetail/face/addFace/addFace_page.dart'; import 'main/lockDetail/face/addFaceType/addFaceTypeManage/addFaceTypeManage_page.dart'; import 'main/lockDetail/face/faceList/faceList_page.dart'; import 'main/lockDetail/fingerprint/addFingerprint/addFingerprint_page.dart'; -import 'main/lockDetail/fingerprint/addFingerprintSelectType/addFingerprintManage/addFingerprintTypeManage_page.dart'; +import 'main/lockDetail/fingerprint/addFingerprintSelectType/addFingerprintType_page.dart'; import 'main/lockDetail/fingerprint/addFingerprintTip/addFingerprintTip_page.dart'; import 'main/lockDetail/fingerprint/fingerprintDetail/fingerprintDetail_page.dart'; import 'main/lockDetail/fingerprint/fingerprintList/fingerprintList_page.dart'; @@ -421,8 +420,7 @@ abstract class Routers { static const addCardPage = '/AddCardPage'; // 添加卡 static const cardDetailPage = '/CardDetailPage'; // 卡详情 static const fingerprintListPage = '/FingerprintListPage'; // 指纹列表 - static const addFingerprintTypeManagePage = - '/AddFingerprintTypeManagePage'; // 添加指纹 + static const addFingerprintTypePage = '/AddFingerprintTypePage'; // 添加指纹 static const fingerprintDetailPage = '/FingerprintDetailPage'; // 指纹详情 static const faceListPage = '/FaceListPage'; // 人脸列表 static const addFaceTypeManagePage = '/AddFaceTypeManagePage'; // 添加人脸 @@ -1022,8 +1020,8 @@ abstract class AppRouters { name: Routers.fingerprintListPage, page: () => const FingerprintListPage()), GetPage( - name: Routers.addFingerprintTypeManagePage, - page: () => const AddFingerprintTypeManagePage()), + name: Routers.addFingerprintTypePage, + page: () => const AddFingerprintTypePage()), GetPage( name: Routers.fingerprintDetailPage, page: () => const FingerprintDetailPage()), diff --git a/star_lock/lib/main/lockDetail/card/addICCard/addICCard_logic.dart b/star_lock/lib/main/lockDetail/card/addICCard/addICCard_logic.dart index fef8abf5..39d6956b 100644 --- a/star_lock/lib/main/lockDetail/card/addICCard/addICCard_logic.dart +++ b/star_lock/lib/main/lockDetail/card/addICCard/addICCard_logic.dart @@ -105,7 +105,7 @@ class AddICCardLogic extends BaseGetXController{ Future _replyAddICCardConfirmation(Reply reply) async { int status = reply.data[2]; - Get.log("_replyAddFingerprintstatus:$status"); + Get.log("_replyAddCardtatus:$status"); switch(status){ case 0x00: diff --git a/star_lock/lib/main/lockDetail/checkingIn/checkingInStaff/checkingInSetAddStaff/checkingInAddStaff_page.dart b/star_lock/lib/main/lockDetail/checkingIn/checkingInStaff/checkingInSetAddStaff/checkingInAddStaff_page.dart index 385570d5..d8749f88 100644 --- a/star_lock/lib/main/lockDetail/checkingIn/checkingInStaff/checkingInSetAddStaff/checkingInAddStaff_page.dart +++ b/star_lock/lib/main/lockDetail/checkingIn/checkingInStaff/checkingInSetAddStaff/checkingInAddStaff_page.dart @@ -169,7 +169,7 @@ class _CheckingInAddStaffPageState extends State { } var data = await Get.toNamed( - Routers.addFingerprintTypeManagePage, + Routers.addFingerprintTypePage, arguments: { "lockId": state.getKeyInfosData.value.lockId, "fromType": 2, // 1从添加钥匙列表进入 2从考勤添加员工入口进入 diff --git a/star_lock/lib/main/lockDetail/fingerprint/addFingerprintSelectType/addFingerprintManage/addFingerprintTypeManage_tabbar.dart b/star_lock/lib/main/lockDetail/fingerprint/addFingerprintSelectType/addFingerprintManage/addFingerprintTypeManage_tabbar.dart index 6393abf6..b3c51930 100644 --- a/star_lock/lib/main/lockDetail/fingerprint/addFingerprintSelectType/addFingerprintManage/addFingerprintTypeManage_tabbar.dart +++ b/star_lock/lib/main/lockDetail/fingerprint/addFingerprintSelectType/addFingerprintManage/addFingerprintTypeManage_tabbar.dart @@ -101,8 +101,8 @@ class _AddFingerprintTypeManageTabbarState extends State AddFingerprintTypePage(selectType: item.selectType, lockId: widget.lockId, fromType: widget.fromType, fromTypeTwoStaffName:widget.fromTypeTwoStaffName)).toList() - :_itemTabs.map((ItemView item) => AddFingerprintTypePage(selectType: item.selectType, lockId: widget.lockId, fromType: widget.fromType, fromTypeTwoStaffName:widget.fromTypeTwoStaffName)).toList(), + ? _itemTabs.map((ItemView item) => const AddFingerprintTypePage()).toList() + :_itemTabs.map((ItemView item) => const AddFingerprintTypePage()).toList(), ), ); } diff --git a/star_lock/lib/main/lockDetail/fingerprint/addFingerprintSelectType/addFingerprintType_logic.dart b/star_lock/lib/main/lockDetail/fingerprint/addFingerprintSelectType/addFingerprintType_logic.dart index 9d1aca91..c24162f0 100644 --- a/star_lock/lib/main/lockDetail/fingerprint/addFingerprintSelectType/addFingerprintType_logic.dart +++ b/star_lock/lib/main/lockDetail/fingerprint/addFingerprintSelectType/addFingerprintType_logic.dart @@ -24,8 +24,8 @@ class AddFingerprintTypeLogic extends BaseGetXController{ endTime = "0"; } else if (state.selectType.value == "1") { fingerprintType = 2; - startDate = DateTool().dateToTimestamp(state.beginTime.value, 1).toString(); - endDate = DateTool().dateToTimestamp(state.endTime.value, 1).toString(); + startDate = DateTool().dateToTimestamp(state.timeLimitBeginTime.value, 1).toString(); + endDate = DateTool().dateToTimestamp(state.timeLimitEndTime.value, 1).toString(); startTime = "0"; endTime = "0"; @@ -48,17 +48,16 @@ class AddFingerprintTypeLogic extends BaseGetXController{ return; } } else if (state.selectType.value == "2") { - if (state.beginTime.value.isEmpty) { + if (state.cycleBeginTime.value.isEmpty) { showToast("请选择有效期".tr); return; } - startDate = DateTool().dateToTimestamp(state.beginTime.value, 1).toString(); - endDate = DateTool().dateToTimestamp(state.endTime.value, 1).toString(); + startDate = DateTool().dateToTimestamp(state.cycleBeginTime.value, 1).toString(); + endDate = DateTool().dateToTimestamp(state.cycleEndTime.value, 1).toString(); startTime = DateTool().dateToTimestamp(state.effectiveDateTime.value, 0).toString(); endTime = DateTool().dateToTimestamp(state.failureDateTime.value, 0).toString(); fingerprintType = 4; } - // var isCoerced = state.isStressFingerprint.value == false ? "1" : "2"; // 1:非胁迫指纹 2:胁迫指纹 // Get.log("addOtherType startDate:$startDate endDate:$endDate isCoerced:$isCoerced"); diff --git a/star_lock/lib/main/lockDetail/fingerprint/addFingerprintSelectType/addFingerprintType_page.dart b/star_lock/lib/main/lockDetail/fingerprint/addFingerprintSelectType/addFingerprintType_page.dart index 425bb1d4..d591bdf9 100644 --- a/star_lock/lib/main/lockDetail/fingerprint/addFingerprintSelectType/addFingerprintType_page.dart +++ b/star_lock/lib/main/lockDetail/fingerprint/addFingerprintSelectType/addFingerprintType_page.dart @@ -8,32 +8,23 @@ import 'package:star_lock/tools/pickers/time_picker/model/date_mode.dart'; import '../../../../appRouters.dart'; import '../../../../app_settings/app_colors.dart'; +import '../../../../tools/CustomUnderlineTabIndicator.dart'; import '../../../../tools/commonItem.dart'; import '../../../../tools/dateTool.dart'; import '../../../../tools/storage.dart'; import '../../../../tools/submitBtn.dart'; +import '../../../../tools/titleAppBar.dart'; import '../../../../translations/trans_lib.dart'; import 'addFingerprintType_logic.dart'; class AddFingerprintTypePage extends StatefulWidget { - final String selectType; // 永久限时循环下标 - final int lockId; - final int fromType; // // 1从添加钥匙列表进入 2从考勤添加员工入口进入 - final String fromTypeTwoStaffName; // 从添加员工进入 传入员工名字 - - const AddFingerprintTypePage( - {Key? key, - required this.selectType, - required this.lockId, - required this.fromType, - required this.fromTypeTwoStaffName}) - : super(key: key); + const AddFingerprintTypePage({Key? key}) : super(key: key); @override State createState() => _AddFingerprintTypePageState(); } -class _AddFingerprintTypePageState extends State { +class _AddFingerprintTypePageState extends State with SingleTickerProviderStateMixin{ final logic = Get.put(AddFingerprintTypeLogic()); final state = Get.find().state; @@ -42,33 +33,41 @@ class _AddFingerprintTypePageState extends State { // TODO: implement initState super.initState(); - WidgetsBinding.instance.addPostFrameCallback((_) { - if(state.selectType.value == "1"){ - state.beginTime.value = DateTool().dateToYMDHNString(DateTime.now().millisecondsSinceEpoch.toString()); //默认为当前时间 - state.endTime.value = DateTool().dateToYMDHNString(DateTime.now().millisecondsSinceEpoch.toString());//默认为当前时间 - }else{ - state.beginTime.value = ""; //默认为当前时间 - state.endTime.value = "";//默认为当前时间 + state.tabController = TabController( + vsync: this, + length: state.fromType.value == 1 ? _itemTabs.length : _fromCheckInTypeItemTabs.length, + initialIndex: 0); + state.tabController.addListener(() { + WidgetsBinding.instance.addPostFrameCallback((_) { + state.selectType.value = state.tabController.index.toString(); + }); + + if (state.tabController.animation!.value == state.tabController.index) { + FocusScope.of(context).requestFocus(FocusNode()); } }); } @override Widget build(BuildContext context) { - state.selectType.value = widget.selectType; - state.lockId.value = widget.lockId; - if(widget.fromTypeTwoStaffName.isNotEmpty){ - state.nameController.text = widget.fromTypeTwoStaffName; - } - state.fromType.value = widget.fromType; - - return SingleChildScrollView( - child: indexChangeWidget() + return Scaffold( + backgroundColor: AppColors.mainBackgroundColor, + appBar: TitleAppBar( + barTitle: + "${TranslationLoader.lanKeys!.addTip!.tr}${TranslationLoader.lanKeys!.fingerprint!.tr}", + haveBack: true, + backgroundColor: AppColors.mainColor), + body: Column( + children: [ + _tabBar(), + _pageWidget(), + ], + ), ); } Widget indexChangeWidget() { - switch (int.parse(widget.selectType)) { + switch (int.parse(state.selectType.value)) { case 0: { // 永久 @@ -139,22 +138,24 @@ class _AddFingerprintTypePageState extends State { children: [ Obx(() => CommonItem( leftTitel: TranslationLoader.lanKeys!.effectiveTime!.tr, - rightTitle: state.beginTime.value, + rightTitle: state.timeLimitBeginTime.value, isHaveLine: true, isHaveDirection: true, action: () async { - Pickers.showDatePicker(context, mode: DateMode.YMDHM, onConfirm: (p) { - state.beginTime.value = DateTool().getYMDHNDateString(p, 1); - }); + Pickers.showDatePicker(context, mode: DateMode.YMDHM, + onConfirm: (p) { + state.timeLimitBeginTime.value = DateTool().getYMDHNDateString(p, 1); + }); })), Obx(() => CommonItem( leftTitel: TranslationLoader.lanKeys!.failureTime!.tr, - rightTitle: state.endTime.value, + rightTitle: state.timeLimitEndTime.value, isHaveDirection: true, action: () { - Pickers.showDatePicker(context, mode: DateMode.YMDHM, onConfirm: (p) { - state.endTime.value = DateTool().getYMDHNDateString(p, 1); - }); + Pickers.showDatePicker(context, mode: DateMode.YMDHM, + onConfirm: (p) { + state.timeLimitEndTime.value = DateTool().getYMDHNDateString(p, 1); + }); })), Container(height: 10.h), ], @@ -162,30 +163,28 @@ class _AddFingerprintTypePageState extends State { } // 循环顶部选择日期 - Widget keyCyclicDate(){ + Widget keyCyclicDate() { return Column( children: [ Obx(() => CommonItem( leftTitel: TranslationLoader.lanKeys!.periodValidity!.tr, - rightTitle: "${state.beginTime.value}\n${state.endTime.value}", + rightTitle:"${state.cycleBeginTime.value}\n${state.cycleEndTime.value}", isHaveDirection: true, isHaveLine: true, action: () async { - var result = await Get.toNamed(Routers.seletKeyCyclicDatePage, - arguments: { - 'validityValue': state.weekdaysList.value, - 'starDate': state.beginTime.value, - 'endDate': state.endTime.value, - 'starTime': state.effectiveDateTime.value, - 'endTime': state.failureDateTime.value - }); - if(result != null && result.isNotEmpty){ + var result = await Get.toNamed(Routers.seletKeyCyclicDatePage, arguments: { + 'validityValue': state.weekdaysList.value, + 'starDate': state.cycleBeginTime.value, + 'endDate': state.cycleEndTime.value, + 'starTime': state.effectiveDateTime.value, + 'endTime': state.failureDateTime.value + }); + if (result != null && result.isNotEmpty) { state.weekdaysList.value = result['validityValue']; - state.beginTime.value = result['starDate']; - state.endTime.value = result['endDate']; + state.cycleBeginTime.value = result['starDate']; + state.cycleEndTime.value = result['endDate']; state.effectiveDateTime.value = result['starTime']; state.failureDateTime.value = result['endTime']; - Get.log('得到的有效期数据:${state.weekdaysList.value} == ${state.beginTime.value} == ${state.endTime.value}== ${state.effectiveDateTime.value} == ${state.failureDateTime.value}'); } })), Obx(() => Visibility( @@ -196,23 +195,21 @@ class _AddFingerprintTypePageState extends State { isHaveDirection: true, isHaveLine: true, action: () async { - var result = await Get.toNamed(Routers.seletKeyCyclicDatePage, - arguments: { - 'validityValue': state.weekdaysList.value, - 'starDate': state.beginTime.value, - 'endDate': state.endTime.value, - 'starTime': state.effectiveDateTime.value, - 'endTime': state.failureDateTime.value - }); - if(result != null && result.isNotEmpty){ + var result = await Get.toNamed(Routers.seletKeyCyclicDatePage, arguments: { + 'validityValue': state.weekdaysList.value, + 'starDate': state.cycleBeginTime.value, + 'endDate': state.cycleEndTime.value, + 'starTime': state.effectiveDateTime.value, + 'endTime': state.failureDateTime.value + }); + if (result != null && result.isNotEmpty) { state.weekdaysList.value = result['validityValue']; - state.beginTime.value = result['starDate']; - state.endTime.value = result['endDate']; + state.cycleBeginTime.value = result['starDate']; + state.cycleEndTime.value = result['endDate']; state.effectiveDateTime.value = result['starTime']; state.failureDateTime.value = result['endTime']; } - }) - )), + }))), Obx(() => Visibility( visible: state.effectiveDateTime.value.isNotEmpty, child: CommonItem( @@ -220,24 +217,21 @@ class _AddFingerprintTypePageState extends State { rightTitle: "${state.effectiveDateTime.value}-${state.failureDateTime.value}", isHaveDirection: true, action: () async { - var result = await Get.toNamed(Routers.seletKeyCyclicDatePage, - arguments: { - 'validityValue': state.weekdaysList.value, - 'starDate': state.beginTime.value, - 'endDate': state.endTime.value, - 'starTime': state.effectiveDateTime.value, - 'endTime': state.failureDateTime.value - }); - if(result != null && result.isNotEmpty){ + var result = await Get.toNamed(Routers.seletKeyCyclicDatePage, arguments: { + 'validityValue': state.weekdaysList.value, + 'starDate': state.cycleBeginTime.value, + 'endDate': state.cycleEndTime.value, + 'starTime': state.effectiveDateTime.value, + 'endTime': state.failureDateTime.value + }); + if (result != null && result.isNotEmpty) { state.weekdaysList.value = result['validityValue']; - state.beginTime.value = result['starDate']; - state.endTime.value = result['endDate']; + state.cycleBeginTime.value = result['starDate']; + state.cycleEndTime.value = result['endDate']; state.effectiveDateTime.value = result['starTime']; state.failureDateTime.value = result['endTime']; - Get.back(result: result); } - }) - )), + }))), ], ); } @@ -435,4 +429,68 @@ class _AddFingerprintTypePageState extends State { ); } + final List _itemTabs = [ + ItemView(title: TranslationLoader.lanKeys!.permanent!.tr, selectType: "0"), + ItemView(title: TranslationLoader.lanKeys!.timeLimit!.tr, selectType: "1"), + ItemView(title: TranslationLoader.lanKeys!.circulation!.tr, selectType: "2"), + ]; + + final List _fromCheckInTypeItemTabs = [ + ItemView(title: TranslationLoader.lanKeys!.permanent!.tr, selectType: "0"), + ItemView(title: TranslationLoader.lanKeys!.timeLimit!.tr, selectType: "1"), + ]; + + TabBar _tabBar() { + return TabBar( + controller: state.tabController, + onTap: (index) { + FocusScope.of(context).requestFocus(FocusNode()); + }, + tabs: state.fromType.value == 1 ? _itemTabs.map((ItemView item) => _tab(item)).toList() : _fromCheckInTypeItemTabs.map((ItemView item) => _tab(item)).toList(), + isScrollable: true, + indicatorColor: Colors.red, + unselectedLabelColor: Colors.black, + unselectedLabelStyle: TextStyle( + color: AppColors.mainColor, + fontSize: 24.sp, + ), + automaticIndicatorColorAdjustment: true, + labelColor: AppColors.mainColor, + labelStyle: TextStyle( + color: AppColors.mainColor, + fontSize: 24.sp, + fontWeight: FontWeight.w600), + indicator: CustomUnderlineTabIndicator( + borderSide: BorderSide(color: AppColors.mainColor, width: 4.w), + strokeCap: StrokeCap.round, + width: 30.w), + ); + } + + Tab _tab(ItemView item) { + return Tab( + child: SizedBox( + width: 1.sw / 5, + child: Text(item.title, textAlign: TextAlign.center))); + } + + Widget _pageWidget() { + return Expanded( + child: TabBarView( + controller: state.tabController, + children: + state.fromType.value == 1 + ? _itemTabs.map((ItemView item) => Obx(() => indexChangeWidget())).toList() + : _fromCheckInTypeItemTabs.map((ItemView item) => Obx(() => indexChangeWidget())).toList(), + ), + ); + } + +} + +class ItemView { + const ItemView({required this.title, required this.selectType}); + + final String title; + final String selectType; } diff --git a/star_lock/lib/main/lockDetail/fingerprint/addFingerprintSelectType/addFingerprintType_state.dart b/star_lock/lib/main/lockDetail/fingerprint/addFingerprintSelectType/addFingerprintType_state.dart index d8707c3e..e4c498d4 100644 --- a/star_lock/lib/main/lockDetail/fingerprint/addFingerprintSelectType/addFingerprintType_state.dart +++ b/star_lock/lib/main/lockDetail/fingerprint/addFingerprintSelectType/addFingerprintType_state.dart @@ -2,6 +2,8 @@ import 'package:flutter/material.dart'; import 'package:get/get.dart'; +import '../../../../tools/dateTool.dart'; + class AddFingerprintState{ final lockId = 0.obs; final selectType = "0".obs;// 0永久 1显示 2循环 @@ -9,16 +11,24 @@ class AddFingerprintState{ final isStressFingerprint = false.obs; final isAdministrator = false.obs;// 是否是管理员 - var beginTime = "".obs;// 开始时间 - var endTime = "".obs;// 结束时间 + var timeLimitBeginTime = DateTool().dateToYMDHNString(DateTime.now().millisecondsSinceEpoch.toString()).obs;// 限时开始时间 + var timeLimitEndTime = DateTool().dateToYMDHNString(DateTime.now().millisecondsSinceEpoch.toString()).obs;// 限时结束时间 + var cycleBeginTime = "".obs;// 循环开始时间 + var cycleEndTime = "".obs;// 循环结束时间 var effectiveDateTime = "".obs;// 生效时间 var failureDateTime = "".obs;// 失效时间 var weekdaysList = [].obs; + var fromTypeTwoStaffName = "".obs; // 从添加员工进入 传入员工名字 final TextEditingController nameController = TextEditingController(); + late TabController tabController; AddFingerprintState() { - // Map map = Get.arguments; - // lockId.value = map["lockId"]; - // fromType.value = map["fromType"]; + Map map = Get.arguments; + lockId.value = map["lockId"]; + fromType.value = map["fromType"]; + // 1从添加钥匙列表进入 2从考勤添加员工入口进入 + if(fromType.value == 2){ + fromTypeTwoStaffName.value = map["fromTypeTwoStaffName"]; // 从添加员工进入 传入员工名字 + } } } 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 194b10b4..4d637333 100644 --- a/star_lock/lib/main/lockDetail/fingerprint/fingerprintList/fingerprintList_page.dart +++ b/star_lock/lib/main/lockDetail/fingerprint/fingerprintList/fingerprintList_page.dart @@ -108,7 +108,7 @@ class _FingerprintListPageState extends State with RouteAwa btnName: '${TranslationLoader.lanKeys!.add!.tr}${TranslationLoader.lanKeys!.fingerprint!.tr}', onClick: () async { var data = - await Get.toNamed(Routers.addFingerprintTypeManagePage, arguments: { + await Get.toNamed(Routers.addFingerprintTypePage, arguments: { "lockId": state.lockId.value, "fromType": 1 // 1从添加钥匙列表进入 2从考勤添加员工入口进入 }); diff --git a/star_lock/lib/main/lockDetail/lockDetail/lockDetail_page.dart b/star_lock/lib/main/lockDetail/lockDetail/lockDetail_page.dart index 6fceab32..397445e4 100644 --- a/star_lock/lib/main/lockDetail/lockDetail/lockDetail_page.dart +++ b/star_lock/lib/main/lockDetail/lockDetail/lockDetail_page.dart @@ -50,8 +50,9 @@ class _LockDetailPageState extends State // TODO: implement initState super.initState(); - print("openDoor:${DateTool().accordingTheCycleIntoTheCorrespondingNumber([5])}"); - print("onLine:${DateTool().accordingTheCycleIntoTheCorrespondingNumber([1])}"); + // print("openDoor:${DateTool().accordingTheCycleIntoTheCorrespondingNumber([5])}"); + // print("onLine:${DateTool().accordingTheCycleIntoTheCorrespondingNumber([1])}"); + // print("onLine openDoor:${DateTool().accordingTheCycleIntoTheCorrespondingNumber([5, 1])}"); // logic.startScanAction(); listeningAnimations(); @@ -1225,20 +1226,15 @@ class _LockDetailPageState extends State state.openLockBtnState.value = 1; // state.animationController!.forward(); - // if (state.lockUserNo == 0) { - // // 电子钥匙lockUserNo为0 要先添加用户 - // logic.addUserConnectBlue(); - // } else { - // print("state.isOpenLockNeedOnline.value:${state.isOpenLockNeedOnline.value}"); - if (state.isOpenLockNeedOnline.value == 0) { - // 不需要联网 - logic.openDoorAction(); - } else { - // 需要联网 - logic.getLockNetToken(); - } - // } - // }); + if (state.isOpenLockNeedOnline.value == 0) { + // 不需要联网 + state.openDoorModel = 0; + logic.openDoorAction(); + } else { + // 需要联网 + state.openDoorModel = 2; + logic.getLockNetToken(); + } } startUnLock() { @@ -1249,15 +1245,16 @@ class _LockDetailPageState extends State state.iSClosedUnlockSuccessfulPopup.value = false; state.openLockBtnState.value = 1; state.animationController!.forward(); - state.openDoorModel = 32; - // if (state.lockUserNo == 0) { - // // 电子钥匙lockUserNo为0 要先添加用户 - // logic.addUserConnectBlue(); - // } else { + if (state.isOpenLockNeedOnline.value == 0) { + // 不需要联网 state.openDoorModel = 32; logic.openDoorAction(); - // } + } else { + // 需要联网 + state.openDoorModel = 34; + logic.getLockNetToken(); + } } @override diff --git a/star_lock/lib/main/lockDetail/lockDetail/lockDetail_state.dart b/star_lock/lib/main/lockDetail/lockDetail/lockDetail_state.dart index 5a4999d3..2a186430 100644 --- a/star_lock/lib/main/lockDetail/lockDetail/lockDetail_state.dart +++ b/star_lock/lib/main/lockDetail/lockDetail/lockDetail_state.dart @@ -34,7 +34,7 @@ class LockDetailState { var bottomBtnisEable = true.obs; // 是否不可用 用于限制底部按钮是否可用 var openDoorBtnisUneable = true.obs; // 当钥匙状态不能使用的情况下开锁按钮禁止使用,默认可用 - var openDoorModel = 0; + var openDoorModel = 0;// 离线开门0, 在线开门2 离线关门32 在线关门34 //过渡动画控制器 AnimationController? animationController;