修改测试部门提出的问题

This commit is contained in:
魏少阳 2024-05-24 10:59:48 +08:00
parent d0174fdf3e
commit 408a077211
16 changed files with 470 additions and 526 deletions

View File

@ -4,12 +4,12 @@ import 'dart:async';
import 'package:flutter_blue_plus/flutter_blue_plus.dart'; import 'package:flutter_blue_plus/flutter_blue_plus.dart';
import 'package:get/get.dart'; import 'package:get/get.dart';
import 'package:star_lock/app_settings/app_settings.dart'; import 'package:star_lock/app_settings/app_settings.dart';
import 'package:star_lock/blue/io_type.dart'; import 'package:star_lock/login/login/entity/LoginEntity.dart';
import 'package:star_lock/main/lockDetail/card/addICCard/addICCard_entity.dart';
import 'package:star_lock/tools/baseGetXController.dart'; import 'package:star_lock/tools/baseGetXController.dart';
import '../../../../blue/blue_manage.dart'; import '../../../../blue/blue_manage.dart';
import '../../../../blue/io_protocol/io_addICCardWithTimeCycleCoercion.dart'; import '../../../../blue/io_protocol/io_addICCardWithTimeCycleCoercion.dart';
// import '../../../../blue/io_protocol/io_addStressICCard.dart';
import '../../../../blue/io_reply.dart'; import '../../../../blue/io_reply.dart';
import '../../../../blue/io_tool/io_tool.dart'; import '../../../../blue/io_tool/io_tool.dart';
import '../../../../blue/io_tool/manager_event_bus.dart'; import '../../../../blue/io_tool/manager_event_bus.dart';
@ -26,7 +26,7 @@ class AddICCardLogic extends BaseGetXController{
// //
late StreamSubscription<Reply> _replySubscription; late StreamSubscription<Reply> _replySubscription;
void _initReplySubscription() { void _initReplySubscription() {
_replySubscription = EventBusManager().eventBus!.on<Reply>().listen((reply) async { _replySubscription = EventBusManager().eventBus!.on<Reply>().listen((Reply reply) async {
// IC卡开始 // IC卡开始
if((reply is SenderAddICCardWithTimeCycleCoercionReply) && (state.ifCurrentScreen.value == true)) { if((reply is SenderAddICCardWithTimeCycleCoercionReply) && (state.ifCurrentScreen.value == true)) {
_replyAddICCardBegin(reply); _replyAddICCardBegin(reply);
@ -40,13 +40,13 @@ class AddICCardLogic extends BaseGetXController{
} }
Future<void> _replyAddICCardBegin(Reply reply) async { Future<void> _replyAddICCardBegin(Reply reply) async {
int status = reply.data[2]; final int status = reply.data[2];
switch(status){ switch(status){
case 0x00: case 0x00:
// //
var cardNumberList = reply.data.sublist(reply.data.length - 2); final List<int> cardNumberList = reply.data.sublist(reply.data.length - 2);
var cardNumber = listChangInt(cardNumberList).toString(); final String cardNumber = listChangInt(cardNumberList).toString();
// AppLog.log("添加卡号:$cardNumberList cardNumber:$cardNumber"); // AppLog.log("添加卡号:$cardNumberList cardNumber:$cardNumber");
state.cardNumber.value = cardNumber.toString(); state.cardNumber.value = cardNumber.toString();
cancelBlueConnetctToastTimer(); cancelBlueConnetctToastTimer();
@ -56,29 +56,29 @@ class AddICCardLogic extends BaseGetXController{
break; break;
case 0x06: case 0x06:
// //
var privateKey = await Storage.getStringList(saveBluePrivateKey); final List<String>? privateKey = await Storage.getStringList(saveBluePrivateKey);
List<int> getPrivateKeyList = changeStringListToIntList(privateKey!); final List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
var signKey = await Storage.getStringList(saveBlueSignKey); final List<String>? signKey = await Storage.getStringList(saveBlueSignKey);
List<int> signKeyDataList = changeStringListToIntList(signKey!); final List<int> signKeyDataList = changeStringListToIntList(signKey!);
// var publicKey = await Storage.getStringList(saveBluePublicKey); // var publicKey = await Storage.getStringList(saveBluePublicKey);
// List<int> publicKeyDataList = changeStringListToIntList(publicKey!); // List<int> publicKeyDataList = changeStringListToIntList(publicKey!);
var token = reply.data.sublist(5, 9); final List<int> token = reply.data.sublist(5, 9);
var saveStrList = changeIntListToStringList(token); final List<String> saveStrList = changeIntListToStringList(token);
Storage.setStringList(saveBlueToken, saveStrList); Storage.setStringList(saveBlueToken, saveStrList);
AppLog.log("添加卡token:$token"); AppLog.log('添加卡token:$token');
IoSenderManage.senderAddCardWithTimeCycleCoercionCommand( IoSenderManage.senderAddCardWithTimeCycleCoercionCommand(
keyID:"1", keyID:'1',
userID:await Storage.getUid(), userID:await Storage.getUid(),
cardNo:0, cardNo:0,
useCountLimit:0xffff, useCountLimit:0xffff,
operate:0, // 0: 1 2: 3 operate:0, // 0: 1 2: 3
isAdmin:state.isAdministrator.value == "2" ? 1 : 0, isAdmin:state.isAdministrator.value == '2' ? 1 : 0,
isForce:state.isCoerced.value == "2" ? 1 : 0, // isForce:state.isCoerced.value == '2' ? 1 : 0, //
isRound:state.selectType.value == "2" ? 1: 0, // isRound:state.selectType.value == '2' ? 1: 0, //
weekRound:DateTool().accordingTheCycleIntoTheCorrespondingNumber(state.weekDay.value), // weekRound:DateTool().accordingTheCycleIntoTheCorrespondingNumber(state.weekDay.value), //
startDate: int.parse(state.startDate.value)~/1000, startDate: int.parse(state.startDate.value)~/1000,
endDate: int.parse(state.endDate.value)~/1000, endDate: int.parse(state.endDate.value)~/1000,
@ -98,7 +98,7 @@ class AddICCardLogic extends BaseGetXController{
} }
Future<void> _replyAddICCardConfirmation(Reply reply) async { Future<void> _replyAddICCardConfirmation(Reply reply) async {
int status = reply.data[2]; final int status = reply.data[2];
state.ifAddState.value = false; state.ifAddState.value = false;
switch(status){ switch(status){
case 0x00: case 0x00:
@ -107,27 +107,27 @@ class AddICCardLogic extends BaseGetXController{
switch(reply.data[5]){ switch(reply.data[5]){
case 0xff: case 0xff:
// //
showToast("退出添加".tr); showToast('退出添加'.tr);
Get.close(1); Get.close(1);
break; break;
case 0xFE: case 0xFE:
// //
showToast("管理员已满".tr); showToast('管理员已满'.tr);
Get.close(1); Get.close(1);
break; break;
case 0xFD: case 0xFD:
// //
showToast("用户已满".tr); showToast('用户已满'.tr);
Get.close(1); Get.close(1);
break; break;
case 0xFC: case 0xFC:
// //
showToast("锁上面添加卡已满".tr); showToast('锁上面添加卡已满'.tr);
Get.close(1); Get.close(1);
break; break;
case 0xFB: case 0xFB:
// //
showToast("卡已存在".tr); showToast('卡已存在'.tr);
break; break;
default: default:
// //
@ -153,24 +153,24 @@ class AddICCardLogic extends BaseGetXController{
// var publicKey = await Storage.getStringList(saveBluePublicKey); // var publicKey = await Storage.getStringList(saveBluePublicKey);
// List<int> publicKeyDataList = changeStringListToIntList(publicKey!); // List<int> publicKeyDataList = changeStringListToIntList(publicKey!);
var signKey = await Storage.getStringList(saveBlueSignKey); final List<String>? signKey = await Storage.getStringList(saveBlueSignKey);
List<int> signKeyDataList = changeStringListToIntList(signKey!); final List<int> signKeyDataList = changeStringListToIntList(signKey!);
var privateKey = await Storage.getStringList(saveBluePrivateKey); final List<String>? privateKey = await Storage.getStringList(saveBluePrivateKey);
List<int> getPrivateKeyList = changeStringListToIntList(privateKey!); final List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
var token = await Storage.getStringList(saveBlueToken); final List<String>? token = await Storage.getStringList(saveBlueToken);
List<int> getTokenList = changeStringListToIntList(token!); final List<int> getTokenList = changeStringListToIntList(token!);
IoSenderManage.senderAddCardWithTimeCycleCoercionCommand( IoSenderManage.senderAddCardWithTimeCycleCoercionCommand(
keyID:"1", keyID:'1',
userID:await Storage.getUid(), userID:await Storage.getUid(),
cardNo:0, cardNo:0,
useCountLimit:0xffff, useCountLimit:0xffff,
operate:0, // 0: 1 2: 3 operate:0, // 0: 1 2: 3
isAdmin:state.isAdministrator.value == "2" ? 1 : 0, isAdmin:state.isAdministrator.value == '2' ? 1 : 0,
isForce:state.isCoerced.value == "2" ? 1 : 0, // isForce:state.isCoerced.value == '2' ? 1 : 0, //
isRound:state.selectType.value == "2" ? 1: 0, // isRound:state.selectType.value == '2' ? 1: 0, //
weekRound:DateTool().accordingTheCycleIntoTheCorrespondingNumber(state.weekDay.value), // weekRound:DateTool().accordingTheCycleIntoTheCorrespondingNumber(state.weekDay.value), //
startDate: int.parse(state.startDate.value)~/1000, startDate: int.parse(state.startDate.value)~/1000,
endDate: int.parse(state.endDate.value)~/1000, endDate: int.parse(state.endDate.value)~/1000,
@ -195,17 +195,17 @@ class AddICCardLogic extends BaseGetXController{
Future<void> senderCancelAddCardCommand() async { Future<void> senderCancelAddCardCommand() async {
BlueManage().blueSendData(BlueManage().connectDeviceName, (BluetoothConnectionState deviceConnectionState) async { BlueManage().blueSendData(BlueManage().connectDeviceName, (BluetoothConnectionState deviceConnectionState) async {
if (deviceConnectionState == BluetoothConnectionState.connected){ if (deviceConnectionState == BluetoothConnectionState.connected){
var privateKey = await Storage.getStringList(saveBluePrivateKey); final List<String>? privateKey = await Storage.getStringList(saveBluePrivateKey);
List<int> getPrivateKeyList = changeStringListToIntList(privateKey!); final List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
var signKey = await Storage.getStringList(saveBlueSignKey); final List<String>? signKey = await Storage.getStringList(saveBlueSignKey);
List<int> signKeyDataList = changeStringListToIntList(signKey!); final List<int> signKeyDataList = changeStringListToIntList(signKey!);
var token = await Storage.getStringList(saveBlueToken); final List<String>? token = await Storage.getStringList(saveBlueToken);
List<int> getTokenList = changeStringListToIntList(token!); final List<int> getTokenList = changeStringListToIntList(token!);
IoSenderManage.senderCancelAddCardCommand( IoSenderManage.senderCancelAddCardCommand(
keyID:"1", keyID:'1',
userID:await Storage.getUid(), userID:await Storage.getUid(),
needAuthor:1, needAuthor:1,
signKey:signKeyDataList, signKey:signKeyDataList,
@ -222,8 +222,8 @@ class AddICCardLogic extends BaseGetXController{
}); });
} }
void addICCardData() async { Future<void> addICCardData() async {
var entity = await ApiRepository.to.addICCardData( final AddICCardEntity entity = await ApiRepository.to.addICCardData(
lockId: state.lockId.value.toString(), lockId: state.lockId.value.toString(),
endDate: state.endDate.value, endDate: state.endDate.value,
cardName: state.cardName.value.toString(), cardName: state.cardName.value.toString(),
@ -235,21 +235,21 @@ class AddICCardLogic extends BaseGetXController{
weekDay: state.weekDay.value, weekDay: state.weekDay.value,
startTime: int.parse(state.effectiveDateTime.value), startTime: int.parse(state.effectiveDateTime.value),
endTime: int.parse(state.failureDateTime.value), endTime: int.parse(state.failureDateTime.value),
cardRight: state.isAdministrator.value == "2" ? 1 : 0, cardRight: state.isAdministrator.value == '2' ? 1 : 0,
); );
if (entity.errorCode!.codeIsSuccessful) { if (entity.errorCode!.codeIsSuccessful) {
updateIdCardUserNoLoadData(entity.data!.cardId.toString()); updateIdCardUserNoLoadData(entity.data!.cardId.toString());
} }
} }
void updateIdCardUserNoLoadData(String cardId) async{ Future<void> updateIdCardUserNoLoadData(String cardId) async{
var entity = await ApiRepository.to.updateIdCardUserNoLoadData( final LoginEntity entity = await ApiRepository.to.updateIdCardUserNoLoadData(
lockId: state.lockId.value.toString(), lockId: state.lockId.value.toString(),
cardId: cardId, cardId: cardId,
cardUserNo: state.cardNumber.value, cardUserNo: state.cardNumber.value,
); );
if(entity.errorCode!.codeIsSuccessful){ if(entity.errorCode!.codeIsSuccessful){
showToast("添加成功".tr, something:(){ showToast('添加成功'.tr, something:(){
if(state.fromType.value == 2){ if(state.fromType.value == 2){
// //
eventBus.fire(ChickInAddStaffCardAndFingerprintBlockNumberEvent(state.cardNumber.value)); eventBus.fire(ChickInAddStaffCardAndFingerprintBlockNumberEvent(state.cardNumber.value));
@ -263,7 +263,6 @@ class AddICCardLogic extends BaseGetXController{
@override @override
void onReady() { void onReady() {
// TODO: implement onReady
super.onReady(); super.onReady();
_initReplySubscription(); _initReplySubscription();
@ -271,7 +270,6 @@ class AddICCardLogic extends BaseGetXController{
@override @override
void onInit() { void onInit() {
// TODO: implement onInit
super.onInit(); super.onInit();
senderAddICCard(); senderAddICCard();
@ -279,7 +277,6 @@ class AddICCardLogic extends BaseGetXController{
@override @override
void onClose() { void onClose() {
// TODO: implement onClose
_replySubscription.cancel(); _replySubscription.cancel();
} }

View File

@ -3,7 +3,7 @@ import 'dart:async';
import 'package:flutter_blue_plus/flutter_blue_plus.dart'; import 'package:flutter_blue_plus/flutter_blue_plus.dart';
import 'package:get/get.dart'; import 'package:get/get.dart';
import 'package:star_lock/blue/io_type.dart'; import 'package:star_lock/login/login/entity/LoginEntity.dart';
import 'package:star_lock/tools/baseGetXController.dart'; import 'package:star_lock/tools/baseGetXController.dart';
import '../../../../blue/blue_manage.dart'; import '../../../../blue/blue_manage.dart';
import '../../../../blue/io_protocol/io_addFace.dart'; import '../../../../blue/io_protocol/io_addFace.dart';
@ -14,7 +14,6 @@ import '../../../../blue/io_tool/io_tool.dart';
import '../../../../blue/io_tool/manager_event_bus.dart'; import '../../../../blue/io_tool/manager_event_bus.dart';
import '../../../../blue/sender_manage.dart'; import '../../../../blue/sender_manage.dart';
import '../../../../network/api_repository.dart'; import '../../../../network/api_repository.dart';
import '../../../../tools/dateTool.dart';
import '../../../../tools/eventBusEventManage.dart'; import '../../../../tools/eventBusEventManage.dart';
import '../../../../tools/storage.dart'; import '../../../../tools/storage.dart';
import 'otherTypeKeyChangeDate_state.dart'; import 'otherTypeKeyChangeDate_state.dart';
@ -25,7 +24,7 @@ class OtherTypeKeyChangeDateLogic extends BaseGetXController{
// //
late StreamSubscription<Reply> _replySubscription; late StreamSubscription<Reply> _replySubscription;
void _initReplySubscription() { void _initReplySubscription() {
_replySubscription = EventBusManager().eventBus!.on<Reply>().listen((reply) async { _replySubscription = EventBusManager().eventBus!.on<Reply>().listen((Reply reply) async {
// () // ()
if((reply is SenderAddICCardWithTimeCycleCoercionReply) && (state.ifCurrentScreen.value == true)) { if((reply is SenderAddICCardWithTimeCycleCoercionReply) && (state.ifCurrentScreen.value == true)) {
_replyAddICCardBegin(reply); _replyAddICCardBegin(reply);
@ -45,7 +44,7 @@ class OtherTypeKeyChangeDateLogic extends BaseGetXController{
// //
Future<void> _replyAddFaceBegin(Reply reply) async { Future<void> _replyAddFaceBegin(Reply reply) async {
int status = reply.data[2]; final int status = reply.data[2];
switch (status) { switch (status) {
case 0x00: case 0x00:
@ -57,14 +56,14 @@ class OtherTypeKeyChangeDateLogic extends BaseGetXController{
break; break;
case 0x06: case 0x06:
// //
var privateKey = await Storage.getStringList(saveBluePrivateKey); final List<String>? privateKey = await Storage.getStringList(saveBluePrivateKey);
List<int> getPrivateKeyList = changeStringListToIntList(privateKey!); final List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
var signKey = await Storage.getStringList(saveBlueSignKey); final List<String>? signKey = await Storage.getStringList(saveBlueSignKey);
List<int> signKeyDataList = changeStringListToIntList(signKey!); final List<int> signKeyDataList = changeStringListToIntList(signKey!);
var token = reply.data.sublist(5, 9); final List<int> token = reply.data.sublist(5, 9);
var saveStrList = changeIntListToStringList(token); final List<String> saveStrList = changeIntListToStringList(token);
Storage.setStringList(saveBlueToken, saveStrList); Storage.setStringList(saveBlueToken, saveStrList);
IoSenderManage.senderAddFaceCommand( IoSenderManage.senderAddFaceCommand(
@ -76,11 +75,11 @@ class OtherTypeKeyChangeDateLogic extends BaseGetXController{
isAdmin:state.fingerprintItemData.value.faceRight!, isAdmin:state.fingerprintItemData.value.faceRight!,
isForce:state.fingerprintItemData.value.isCoerced, // isForce:state.fingerprintItemData.value.isCoerced, //
isRound:0, // isRound:0, //
weekRound:DateTool().accordingTheCycleIntoTheCorrespondingNumber(state.fingerprintItemData.value.weekDay!), // weekRound:0, //
startDate: state.beginTimeTimestamp.value~/1000, startDate: state.beginTimeTimestamp.value~/1000,
endDate: state.endTimeTimestamp.value~/1000, endDate: state.endTimeTimestamp.value~/1000,
startTime:"0", startTime:'0',
endTime:"0", endTime:'0',
needAuthor:1, needAuthor:1,
signKey:signKeyDataList, signKey:signKeyDataList,
privateKey:getPrivateKeyList, privateKey:getPrivateKeyList,
@ -107,14 +106,14 @@ class OtherTypeKeyChangeDateLogic extends BaseGetXController{
}); });
BlueManage().blueSendData(BlueManage().connectDeviceName, (BluetoothConnectionState deviceConnectionState) async { BlueManage().blueSendData(BlueManage().connectDeviceName, (BluetoothConnectionState deviceConnectionState) async {
if (deviceConnectionState == BluetoothConnectionState.connected) { if (deviceConnectionState == BluetoothConnectionState.connected) {
var privateKey = await Storage.getStringList(saveBluePrivateKey); final List<String>? privateKey = await Storage.getStringList(saveBluePrivateKey);
List<int> getPrivateKeyList = changeStringListToIntList(privateKey!); final List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
var token = await Storage.getStringList(saveBlueToken); final List<String>? token = await Storage.getStringList(saveBlueToken);
List<int> getTokenList = changeStringListToIntList(token!); final List<int> getTokenList = changeStringListToIntList(token!);
var signKey = await Storage.getStringList(saveBlueSignKey); final List<String>? signKey = await Storage.getStringList(saveBlueSignKey);
List<int> signKeyDataList = changeStringListToIntList(signKey!); final List<int> signKeyDataList = changeStringListToIntList(signKey!);
IoSenderManage.senderAddFaceCommand( IoSenderManage.senderAddFaceCommand(
keyID:state.fingerprintItemData.value.faceId!.toString(), keyID:state.fingerprintItemData.value.faceId!.toString(),
@ -125,11 +124,11 @@ class OtherTypeKeyChangeDateLogic extends BaseGetXController{
isAdmin:state.fingerprintItemData.value.faceRight!, isAdmin:state.fingerprintItemData.value.faceRight!,
isForce:state.fingerprintItemData.value.isCoerced, // isForce:state.fingerprintItemData.value.isCoerced, //
isRound:0, // isRound:0, //
weekRound:DateTool().accordingTheCycleIntoTheCorrespondingNumber(state.fingerprintItemData.value.weekDay!), // weekRound:0, //
startDate: state.beginTimeTimestamp.value~/1000, startDate: state.beginTimeTimestamp.value~/1000,
endDate: state.endTimeTimestamp.value~/1000, endDate: state.endTimeTimestamp.value~/1000,
startTime:"0", startTime:'0',
endTime:"0", endTime:'0',
needAuthor:1, needAuthor:1,
signKey:signKeyDataList, signKey:signKeyDataList,
privateKey:getPrivateKeyList, privateKey:getPrivateKeyList,
@ -149,7 +148,7 @@ class OtherTypeKeyChangeDateLogic extends BaseGetXController{
// () // ()
Future<void> _replyAddICCardBegin(Reply reply) async { Future<void> _replyAddICCardBegin(Reply reply) async {
int status = reply.data[2]; final int status = reply.data[2];
switch(status){ switch(status){
case 0x00: case 0x00:
@ -160,14 +159,14 @@ class OtherTypeKeyChangeDateLogic extends BaseGetXController{
break; break;
case 0x06: case 0x06:
// //
var privateKey = await Storage.getStringList(saveBluePrivateKey); final List<String>? privateKey = await Storage.getStringList(saveBluePrivateKey);
List<int> getPrivateKeyList = changeStringListToIntList(privateKey!); final List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
var signKey = await Storage.getStringList(saveBlueSignKey); final List<String>? signKey = await Storage.getStringList(saveBlueSignKey);
List<int> signKeyDataList = changeStringListToIntList(signKey!); final List<int> signKeyDataList = changeStringListToIntList(signKey!);
var token = reply.data.sublist(5, 9); final List<int> token = reply.data.sublist(5, 9);
var saveStrList = changeIntListToStringList(token); final List<String> saveStrList = changeIntListToStringList(token);
Storage.setStringList(saveBlueToken, saveStrList); Storage.setStringList(saveBlueToken, saveStrList);
IoSenderManage.senderAddCardWithTimeCycleCoercionCommand( IoSenderManage.senderAddCardWithTimeCycleCoercionCommand(
@ -179,11 +178,11 @@ class OtherTypeKeyChangeDateLogic extends BaseGetXController{
isAdmin:state.fingerprintItemData.value.cardRight!, isAdmin:state.fingerprintItemData.value.cardRight!,
isForce:state.fingerprintItemData.value.isCoerced, // isForce:state.fingerprintItemData.value.isCoerced, //
isRound:0, // isRound:0, //
weekRound:DateTool().accordingTheCycleIntoTheCorrespondingNumber(state.fingerprintItemData.value.weekDay!), // weekRound:0, //
startDate: state.beginTimeTimestamp.value~/1000, startDate: state.beginTimeTimestamp.value~/1000,
endDate: state.endTimeTimestamp.value~/1000, endDate: state.endTimeTimestamp.value~/1000,
startTime:"0", startTime:'0',
endTime:"0", endTime:'0',
needAuthor:1, needAuthor:1,
signKey:signKeyDataList, signKey:signKeyDataList,
privateKey:getPrivateKeyList, privateKey:getPrivateKeyList,
@ -198,7 +197,7 @@ class OtherTypeKeyChangeDateLogic extends BaseGetXController{
// //
Future<void> _replyAddFingerprintBegin(Reply reply) async { Future<void> _replyAddFingerprintBegin(Reply reply) async {
int status = reply.data[2]; final int status = reply.data[2];
switch(status){ switch(status){
case 0x00: case 0x00:
// //
@ -209,14 +208,14 @@ class OtherTypeKeyChangeDateLogic extends BaseGetXController{
break; break;
case 0x06: case 0x06:
// //
var privateKey = await Storage.getStringList(saveBluePrivateKey); final List<String>? privateKey = await Storage.getStringList(saveBluePrivateKey);
List<int> getPrivateKeyList = changeStringListToIntList(privateKey!); final List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
var signKey = await Storage.getStringList(saveBlueSignKey); final List<String>? signKey = await Storage.getStringList(saveBlueSignKey);
List<int> signKeyDataList = changeStringListToIntList(signKey!); final List<int> signKeyDataList = changeStringListToIntList(signKey!);
var token = reply.data.sublist(5, 9); final List<int> token = reply.data.sublist(5, 9);
var saveStrList = changeIntListToStringList(token); final List<String> saveStrList = changeIntListToStringList(token);
Storage.setStringList(saveBlueToken, saveStrList); Storage.setStringList(saveBlueToken, saveStrList);
IoSenderManage.senderAddFingerprintWithTimeCycleCoercionCommand( IoSenderManage.senderAddFingerprintWithTimeCycleCoercionCommand(
@ -228,11 +227,11 @@ class OtherTypeKeyChangeDateLogic extends BaseGetXController{
isAdmin:state.fingerprintItemData.value.fingerRight, isAdmin:state.fingerprintItemData.value.fingerRight,
isForce:state.fingerprintItemData.value.isCoerced, // isForce:state.fingerprintItemData.value.isCoerced, //
isRound:0, // isRound:0, //
weekRound:DateTool().accordingTheCycleIntoTheCorrespondingNumber(state.fingerprintItemData.value.weekDay!), // weekRound:0, //
startDate: state.beginTimeTimestamp.value~/1000, startDate: state.beginTimeTimestamp.value~/1000,
endDate: state.endTimeTimestamp.value~/1000, endDate: state.endTimeTimestamp.value~/1000,
startTime:"0", startTime:'0',
endTime:"0", endTime:'0',
needAuthor:1, needAuthor:1,
signKey:signKeyDataList, signKey:signKeyDataList,
privateKey:getPrivateKeyList, privateKey:getPrivateKeyList,
@ -262,14 +261,14 @@ class OtherTypeKeyChangeDateLogic extends BaseGetXController{
// var publicKey = await Storage.getStringList(saveBluePublicKey); // var publicKey = await Storage.getStringList(saveBluePublicKey);
// List<int> publicKeyDataList = changeStringListToIntList(publicKey!); // List<int> publicKeyDataList = changeStringListToIntList(publicKey!);
var signKey = await Storage.getStringList(saveBlueSignKey); final List<String>? signKey = await Storage.getStringList(saveBlueSignKey);
List<int> signKeyDataList = changeStringListToIntList(signKey!); final List<int> signKeyDataList = changeStringListToIntList(signKey!);
var privateKey = await Storage.getStringList(saveBluePrivateKey); final List<String>? privateKey = await Storage.getStringList(saveBluePrivateKey);
List<int> getPrivateKeyList = changeStringListToIntList(privateKey!); final List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
var token = await Storage.getStringList(saveBlueToken); final List<String>? token = await Storage.getStringList(saveBlueToken);
List<int> getTokenList = changeStringListToIntList(token!); final List<int> getTokenList = changeStringListToIntList(token!);
IoSenderManage.senderAddFingerprintWithTimeCycleCoercionCommand( IoSenderManage.senderAddFingerprintWithTimeCycleCoercionCommand(
keyID:state.fingerprintItemData.value.fingerprintId.toString(), keyID:state.fingerprintItemData.value.fingerprintId.toString(),
@ -280,11 +279,11 @@ class OtherTypeKeyChangeDateLogic extends BaseGetXController{
isAdmin:state.fingerprintItemData.value.fingerRight, isAdmin:state.fingerprintItemData.value.fingerRight,
isForce:state.fingerprintItemData.value.isCoerced, // isForce:state.fingerprintItemData.value.isCoerced, //
isRound:0, // isRound:0, //
weekRound:DateTool().accordingTheCycleIntoTheCorrespondingNumber(state.fingerprintItemData.value.weekDay!), // weekRound:0, //
startDate: state.beginTimeTimestamp.value~/1000, startDate: state.beginTimeTimestamp.value~/1000,
endDate: state.endTimeTimestamp.value~/1000, endDate: state.endTimeTimestamp.value~/1000,
startTime:"0", startTime:'0',
endTime:"0", endTime:'0',
needAuthor:1, needAuthor:1,
signKey:signKeyDataList, signKey:signKeyDataList,
privateKey:getPrivateKeyList, privateKey:getPrivateKeyList,
@ -316,14 +315,14 @@ class OtherTypeKeyChangeDateLogic extends BaseGetXController{
BlueManage().blueSendData(BlueManage().connectDeviceName, (BluetoothConnectionState deviceConnectionState) async { BlueManage().blueSendData(BlueManage().connectDeviceName, (BluetoothConnectionState deviceConnectionState) async {
if (deviceConnectionState == BluetoothConnectionState.connected){ if (deviceConnectionState == BluetoothConnectionState.connected){
var signKey = await Storage.getStringList(saveBlueSignKey); final List<String>? signKey = await Storage.getStringList(saveBlueSignKey);
List<int> signKeyDataList = changeStringListToIntList(signKey!); final List<int> signKeyDataList = changeStringListToIntList(signKey!);
var privateKey = await Storage.getStringList(saveBluePrivateKey); final List<String>? privateKey = await Storage.getStringList(saveBluePrivateKey);
List<int> getPrivateKeyList = changeStringListToIntList(privateKey!); final List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
var token = await Storage.getStringList(saveBlueToken); final List<String>? token = await Storage.getStringList(saveBlueToken);
List<int> getTokenList = changeStringListToIntList(token!); final List<int> getTokenList = changeStringListToIntList(token!);
IoSenderManage.senderAddCardWithTimeCycleCoercionCommand( IoSenderManage.senderAddCardWithTimeCycleCoercionCommand(
keyID:state.fingerprintItemData.value.cardId!.toString(), keyID:state.fingerprintItemData.value.cardId!.toString(),
@ -334,11 +333,11 @@ class OtherTypeKeyChangeDateLogic extends BaseGetXController{
isAdmin:state.fingerprintItemData.value.cardRight!, isAdmin:state.fingerprintItemData.value.cardRight!,
isForce:state.fingerprintItemData.value.isCoerced, // isForce:state.fingerprintItemData.value.isCoerced, //
isRound:0, // isRound:0, //
weekRound:DateTool().accordingTheCycleIntoTheCorrespondingNumber(state.fingerprintItemData.value.weekDay!), // weekRound:0, //
startDate: state.beginTimeTimestamp.value~/1000, startDate: state.beginTimeTimestamp.value~/1000,
endDate: state.endTimeTimestamp.value~/1000, endDate: state.endTimeTimestamp.value~/1000,
startTime:"0", startTime:'0',
endTime:"0", endTime:'0',
needAuthor:1, needAuthor:1,
signKey:signKeyDataList, signKey:signKeyDataList,
privateKey:getPrivateKeyList, privateKey:getPrivateKeyList,
@ -356,38 +355,38 @@ class OtherTypeKeyChangeDateLogic extends BaseGetXController{
} }
// //
void editFingerprintsData() async{ Future<void> editFingerprintsData() async{
var entity = await ApiRepository.to.editFingerprintsData( final LoginEntity entity = await ApiRepository.to.editFingerprintsData(
fingerprintId: state.fingerprintItemData.value.fingerprintId.toString(), fingerprintId: state.fingerprintItemData.value.fingerprintId.toString(),
lockId: state.fingerprintItemData.value.lockId.toString(), lockId: state.fingerprintItemData.value.lockId.toString(),
weekDay: state.fingerprintItemData.value.weekDay!, weekDay: [],
startDate: state.beginTimeTimestamp.value.toString(), startDate: state.beginTimeTimestamp.value.toString(),
endDate: state.endTimeTimestamp.value.toString(), endDate: state.endTimeTimestamp.value.toString(),
isCoerced: state.fingerprintItemData.value.isCoerced.toString(), isCoerced: state.fingerprintItemData.value.isCoerced.toString(),
fingerprintName: state.fingerprintItemData.value.fingerprintName!, fingerprintName: state.fingerprintItemData.value.fingerprintName!,
changeType: "1", changeType: '1',
startTime: 0, startTime: 0,
endTime: 0, endTime: 0,
fingerprintType: state.fingerprintItemData.value.fingerprintType! == 4 ? 4 : 2, fingerprintType: 2,
fingerRight: state.fingerprintItemData.value.fingerRight!, fingerRight: state.fingerprintItemData.value.fingerRight!,
); );
if(entity.errorCode!.codeIsSuccessful){ if(entity.errorCode!.codeIsSuccessful){
showToast("修改成功".tr, something: (){ showToast('修改成功'.tr, something: (){
eventBus.fire(OtherTypeRefreshListEvent()); eventBus.fire(OtherTypeRefreshListEvent());
Get.back(result: { Get.back(result: <String, String>{
"beginTimeTimestamp":state.beginTimeTimestamp.value.toString(), 'beginTimeTimestamp':state.beginTimeTimestamp.value.toString(),
"endTimeTimestamp":state.endTimeTimestamp.value.toString(), 'endTimeTimestamp':state.endTimeTimestamp.value.toString(),
}); });
}); });
} }
} }
// iC卡 // iC卡
void editICCardData() async{ Future<void> editICCardData() async{
var entity = await ApiRepository.to.editICCardData( final LoginEntity entity = await ApiRepository.to.editICCardData(
cardId: state.fingerprintItemData.value.cardId.toString(), cardId: state.fingerprintItemData.value.cardId.toString(),
lockId: state.fingerprintItemData.value.lockId.toString(), lockId: state.fingerprintItemData.value.lockId.toString(),
weekDay: state.fingerprintItemData.value.weekDay!, weekDay: [],
startDate: state.beginTimeTimestamp.value.toString(), startDate: state.beginTimeTimestamp.value.toString(),
endDate: state.endTimeTimestamp.value.toString(), endDate: state.endTimeTimestamp.value.toString(),
isCoerced: state.fingerprintItemData.value.isCoerced.toString(), isCoerced: state.fingerprintItemData.value.isCoerced.toString(),
@ -399,10 +398,10 @@ class OtherTypeKeyChangeDateLogic extends BaseGetXController{
cardRight: state.fingerprintItemData.value.cardRight!, cardRight: state.fingerprintItemData.value.cardRight!,
); );
if(entity.errorCode!.codeIsSuccessful){ if(entity.errorCode!.codeIsSuccessful){
showToast("修改成功".tr, something: (){ showToast('修改成功'.tr, something: (){
Get.back(result: { Get.back(result: <String, String>{
"beginTimeTimestamp":state.beginTimeTimestamp.value.toString(), 'beginTimeTimestamp':state.beginTimeTimestamp.value.toString(),
"endTimeTimestamp":state.endTimeTimestamp.value.toString(), 'endTimeTimestamp':state.endTimeTimestamp.value.toString(),
}); });
eventBus.fire(OtherTypeRefreshListEvent()); eventBus.fire(OtherTypeRefreshListEvent());
}); });
@ -410,23 +409,8 @@ class OtherTypeKeyChangeDateLogic extends BaseGetXController{
} }
// //
void editFaceData() async { Future<void> editFaceData() async {
// var entity = await ApiRepository.to.updateFaceValidity( final LoginEntity entity = await ApiRepository.to.updateFaceValidity(
// lockId: state.faceItemData.value.lockId!,
// faceId: state.faceItemData.value.faceId!,
// startDate: int.parse(state.startDate.value),
// endDate: int.parse(state.endDate.value),
// startTime: int.parse(state.startTime.value),
// endTime: int.parse(state.endTime.value),
// faceType: state.keyType.value,
// weekDay: state.weekDay.value,
// faceName: state.changeNameController.text,
// addType: "1",
// isCoerced: state.isStressFace.value ? 2 : 1,
// faceRight: state.isAdministrator.value ? 1 : 0,
// );
var entity = await ApiRepository.to.updateFaceValidity(
lockId: state.fingerprintItemData.value.lockId!, lockId: state.fingerprintItemData.value.lockId!,
faceId: state.fingerprintItemData.value.faceId!, faceId: state.fingerprintItemData.value.faceId!,
startDate: state.beginTimeTimestamp.value, startDate: state.beginTimeTimestamp.value,
@ -434,17 +418,17 @@ class OtherTypeKeyChangeDateLogic extends BaseGetXController{
startTime: 0, startTime: 0,
endTime: 0, endTime: 0,
faceType: 2, faceType: 2,
weekDay: state.fingerprintItemData.value.weekDay!, weekDay: [],
faceName: state.fingerprintItemData.value.faceName!, faceName: state.fingerprintItemData.value.faceName!,
addType: "1", addType: '1',
isCoerced: state.fingerprintItemData.value.isCoerced!, isCoerced: state.fingerprintItemData.value.isCoerced!,
faceRight: state.fingerprintItemData.value.faceRight!, faceRight: state.fingerprintItemData.value.faceRight!,
); );
if (entity.errorCode!.codeIsSuccessful) { if (entity.errorCode!.codeIsSuccessful) {
showToast("修改成功", something: () { showToast('修改成功', something: () {
Get.back(result: { Get.back(result: <String, String>{
"beginTimeTimestamp":state.beginTimeTimestamp.value.toString(), 'beginTimeTimestamp':state.beginTimeTimestamp.value.toString(),
"endTimeTimestamp":state.endTimeTimestamp.value.toString(), 'endTimeTimestamp':state.endTimeTimestamp.value.toString(),
}); });
eventBus.fire(OtherTypeRefreshListEvent()); eventBus.fire(OtherTypeRefreshListEvent());
}); });
@ -453,7 +437,6 @@ class OtherTypeKeyChangeDateLogic extends BaseGetXController{
@override @override
void onReady() { void onReady() {
// TODO: implement onReady
super.onReady(); super.onReady();
_initReplySubscription(); _initReplySubscription();
@ -461,14 +444,12 @@ class OtherTypeKeyChangeDateLogic extends BaseGetXController{
@override @override
void onInit() { void onInit() {
// TODO: implement onInit
super.onInit(); super.onInit();
} }
@override @override
void onClose() { void onClose() {
// TODO: implement onClose
super.onClose(); super.onClose();
_replySubscription.cancel(); _replySubscription.cancel();

View File

@ -4,29 +4,19 @@ import 'package:star_lock/app_settings/app_settings.dart';
import '../../../../tools/dateTool.dart'; import '../../../../tools/dateTool.dart';
import '../../fingerprint/fingerprintList/fingerprintListData_entity.dart'; import '../../fingerprint/fingerprintList/fingerprintListData_entity.dart';
class OtherTypeKeyChangeDateState{ class OtherTypeKeyChangeDateState{// 0() 1()
final fingerprintItemData = FingerprintItemData().obs;
var beginTime = "".obs;//
var endTime = "".obs;//
var beginTimeTimestamp = 0.obs;//
var endTimeTimestamp = 0.obs;//
var pushType = 0.obs;// 0 1 2 3
var ifCurrentScreen = true.obs; // ,
var sureBtnState = 0.obs;// 0() 1()
OtherTypeKeyChangeDateState() { OtherTypeKeyChangeDateState() {
Map map = Get.arguments; Map map = Get.arguments;
if(map["pushType"] != null){ if(map['pushType'] != null){
pushType.value = map["pushType"]; pushType.value = map['pushType'];
} }
if(map["fingerprintItemData"] != null){ if(map['fingerprintItemData'] != null){
fingerprintItemData.value = map["fingerprintItemData"]; fingerprintItemData.value = map['fingerprintItemData'];
} }
AppLog.log("fingerprintItemData.value.startDate:${fingerprintItemData.value.startDate} fingerprintItemData.value.endDate:${fingerprintItemData.value.endDate}"); AppLog.log('fingerprintItemData.value.startDate:${fingerprintItemData.value.startDate} fingerprintItemData.value.endDate:${fingerprintItemData.value.endDate}');
if(fingerprintItemData.value.startDate == 0){ if(fingerprintItemData.value.startDate == 0){
beginTime.value = DateTool().dateToYMDHNString(DateTime.now().millisecondsSinceEpoch.toString()); beginTime.value = DateTool().dateToYMDHNString(DateTime.now().millisecondsSinceEpoch.toString());
endTime.value = DateTool().dateToYMDHNString(DateTime.now().millisecondsSinceEpoch.toString()); endTime.value = DateTool().dateToYMDHNString(DateTime.now().millisecondsSinceEpoch.toString());
@ -39,6 +29,17 @@ class OtherTypeKeyChangeDateState{
endTimeTimestamp.value = fingerprintItemData.value.endDate!; endTimeTimestamp.value = fingerprintItemData.value.endDate!;
} }
AppLog.log("beginTime.value:${beginTime.value} endTime.value:${endTime.value} beginTimeTimestamp.value:${beginTimeTimestamp.value} endTimeTimestamp.value:${endTimeTimestamp.value}"); AppLog.log('beginTime.value:${beginTime.value} endTime.value:${endTime.value} beginTimeTimestamp.value:${beginTimeTimestamp.value} endTimeTimestamp.value:${endTimeTimestamp.value}');
} }
final Rx<FingerprintItemData> fingerprintItemData = FingerprintItemData().obs;
RxString beginTime = ''.obs;//
RxString endTime = ''.obs;//
RxInt beginTimeTimestamp = 0.obs;//
RxInt endTimeTimestamp = 0.obs;//
RxInt pushType = 0.obs;// 0 1 2 3
RxBool ifCurrentScreen = true.obs; // ,
RxInt sureBtnState = 0.obs;
} }

View File

@ -1,3 +1,4 @@
import 'dart:async'; import 'dart:async';
import 'package:flutter_blue_plus/flutter_blue_plus.dart'; import 'package:flutter_blue_plus/flutter_blue_plus.dart';
@ -22,10 +23,10 @@ class PasswordKeyDetailLogic extends BaseGetXController {
// //
late StreamSubscription<Reply> _replySubscription; late StreamSubscription<Reply> _replySubscription;
void _initReplySubscription() { void _initReplySubscription() {
_replySubscription = EventBusManager().eventBus!.on<Reply>().listen((reply) async { _replySubscription = EventBusManager().eventBus!.on<Reply>().listen((Reply reply) async {
// //
if (reply is SenderCustomPasswordsReply && state.ifCurrentScreen.value == true) { if (reply is SenderCustomPasswordsReply && state.ifCurrentScreen.value == true) {
int status = reply.data[2]; final int status = reply.data[2];
switch (status) { switch (status) {
case 0x00: case 0x00:
// //
@ -40,14 +41,14 @@ class PasswordKeyDetailLogic extends BaseGetXController {
break; break;
case 0x06: case 0x06:
// //
var privateKey = await Storage.getStringList(saveBluePrivateKey); final List<String>? privateKey = await Storage.getStringList(saveBluePrivateKey);
List<int> getPrivateKeyList = changeStringListToIntList(privateKey!); final List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
var signKey = await Storage.getStringList(saveBlueSignKey); final List<String>? signKey = await Storage.getStringList(saveBlueSignKey);
List<int> signKeyDataList = changeStringListToIntList(signKey!); final List<int> signKeyDataList = changeStringListToIntList(signKey!);
var token = reply.data.sublist(5, 9); final List<int> token = reply.data.sublist(5, 9);
var saveStrList = changeIntListToStringList(token); final List<String> saveStrList = changeIntListToStringList(token);
Storage.setStringList(saveBlueToken, saveStrList); Storage.setStringList(saveBlueToken, saveStrList);
IoSenderManage.senderCustomPasswordsCommand( IoSenderManage.senderCustomPasswordsCommand(
@ -77,21 +78,21 @@ class PasswordKeyDetailLogic extends BaseGetXController {
// deleteType:1- 2- // deleteType:1- 2-
Future<void> deletePwdRequest() async { Future<void> deletePwdRequest() async {
PasswordKeyEntity entity = await ApiRepository.to.deleteKeyboardPwd( final PasswordKeyEntity entity = await ApiRepository.to.deleteKeyboardPwd(
lockId:state.itemData.value.lockId.toString(), lockId:state.itemData.value.lockId.toString(),
keyboardPwdId:state.itemData.value.keyboardPwdId.toString(), keyboardPwdId:state.itemData.value.keyboardPwdId.toString(),
deleteType:1); deleteType:1);
if (entity.errorCode!.codeIsSuccessful) { if (entity.errorCode!.codeIsSuccessful) {
showToast("删除成功".tr, something: (){ showToast('删除成功'.tr, something: (){
// eventBus.fire(GetPasswordListRefreshUI()); // eventBus.fire(GetPasswordListRefreshUI());
Get.back(result: "deletScuess"); Get.back(result: 'deletScuess');
}); });
} }
} }
// //
Future<void> updatePwdRequest(int changType) async { Future<void> updatePwdRequest(int changType) async {
PasswordKeyEntity entity = await ApiRepository.to.updatePasswordKey( final PasswordKeyEntity entity = await ApiRepository.to.updatePasswordKey(
lockId: state.itemData.value.lockId!, lockId: state.itemData.value.lockId!,
keyboardPwdId: state.itemData.value.keyboardPwdId.toString(), keyboardPwdId: state.itemData.value.keyboardPwdId.toString(),
keyboardPwdName: state.inputNameController.text, keyboardPwdName: state.inputNameController.text,
@ -106,7 +107,7 @@ class PasswordKeyDetailLogic extends BaseGetXController {
pwdRight: state.isAdministrator.value == true ? 1 : 0); pwdRight: state.isAdministrator.value == true ? 1 : 0);
if (entity.errorCode!.codeIsSuccessful) { if (entity.errorCode!.codeIsSuccessful) {
Get.back(); Get.back();
showToast("修改成功".tr, something: (){ showToast('修改成功'.tr, something: (){
if(changType == 1){ if(changType == 1){
// //
state.keyboardPwdName.value = state.inputNameController.text; state.keyboardPwdName.value = state.inputNameController.text;
@ -129,28 +130,14 @@ class PasswordKeyDetailLogic extends BaseGetXController {
}); });
BlueManage().blueSendData(BlueManage().connectDeviceName, (BluetoothConnectionState deviceConnectionState) async { BlueManage().blueSendData(BlueManage().connectDeviceName, (BluetoothConnectionState deviceConnectionState) async {
if (deviceConnectionState == BluetoothConnectionState.connected) { if (deviceConnectionState == BluetoothConnectionState.connected) {
var signKey = await Storage.getStringList(saveBlueSignKey); final List<String>? signKey = await Storage.getStringList(saveBlueSignKey);
List<int> signKeyDataList = changeStringListToIntList(signKey!); final List<int> signKeyDataList = changeStringListToIntList(signKey!);
var privateKey = await Storage.getStringList(saveBluePrivateKey); final List<String>? privateKey = await Storage.getStringList(saveBluePrivateKey);
List<int> getPrivateKeyList = changeStringListToIntList(privateKey!); final List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
var token = await Storage.getStringList(saveBlueToken); final List<String>? token = await Storage.getStringList(saveBlueToken);
List<int> getTokenList = changeStringListToIntList(token!); final List<int> getTokenList = changeStringListToIntList(token!);
// IoSenderManage.senderCustomPasswordsCommand(
// keyID:state.keyId.value.toString(),
// userID:await Storage.getUid(),
// pwdNo: state.keyboardUserNo.value,
// pwd: "000000",
// useCountLimit: 0,
// startTime:0x11223344,
// endTime:0x11223344,
// needAuthor: 1,
// isBeforeAddUser: false,
// signKey: signKeyDataList,
// privateKey: getPrivateKeyList,
// token: getTokenList);
IoSenderManage.senderCustomPasswordsCommand( IoSenderManage.senderCustomPasswordsCommand(
keyID:state.itemData.value.keyboardPwdId!.toString(), keyID:state.itemData.value.keyboardPwdId!.toString(),
@ -180,12 +167,12 @@ class PasswordKeyDetailLogic extends BaseGetXController {
//使 //使
String getUseDateStr() { String getUseDateStr() {
int? getPwdType = state.itemData.value.keyboardPwdType; final int? getPwdType = state.itemData.value.keyboardPwdType;
String useDateStr = ''; String useDateStr = '';
DateTime startDateStr = DateTime.fromMillisecondsSinceEpoch(state.itemData.value.startDate!); final DateTime startDateStr = DateTime.fromMillisecondsSinceEpoch(state.itemData.value.startDate!);
DateTime endDateStr = DateTime.fromMillisecondsSinceEpoch(state.itemData.value.endDate!); final DateTime endDateStr = DateTime.fromMillisecondsSinceEpoch(state.itemData.value.endDate!);
String starHour = "${state.itemData.value.hoursStart}"; final String starHour = '${state.itemData.value.hoursStart}';
String endHour = "${state.itemData.value.hoursEnd}"; final String endHour = '${state.itemData.value.hoursEnd}';
switch (getPwdType) { switch (getPwdType) {
case 1: case 1:
@ -267,14 +254,14 @@ class PasswordKeyDetailLogic extends BaseGetXController {
} }
String getShareContentStr() { String getShareContentStr() {
int? getPwdType = state.itemData.value.keyboardPwdType; final int? getPwdType = state.itemData.value.keyboardPwdType;
String useDateStr = ''; String useDateStr = '';
DateTime startDateStr = final DateTime startDateStr =
DateTime.fromMillisecondsSinceEpoch(state.itemData.value.startDate!); DateTime.fromMillisecondsSinceEpoch(state.itemData.value.startDate!);
DateTime endDateStr = final DateTime endDateStr =
DateTime.fromMillisecondsSinceEpoch(state.itemData.value.endDate!); DateTime.fromMillisecondsSinceEpoch(state.itemData.value.endDate!);
int starHour = startDateStr.hour; final int starHour = startDateStr.hour;
int endHour = endDateStr.hour; final int endHour = endDateStr.hour;
switch (getPwdType) { switch (getPwdType) {
case 1: case 1:
@ -335,30 +322,21 @@ class PasswordKeyDetailLogic extends BaseGetXController {
// 14 // 14
useDateStr = '类型:循环\n周日 $starHour:00-$endHour:00'; useDateStr = '类型:循环\n周日 $starHour:00-$endHour:00';
break; break;
default: default:
} }
return "您好,您的密码是:${state.itemData.value.keyboardPwd}\n$useDateStr\n密码名字:${state.itemData.value.keyboardPwdName}"; return '您好,您的密码是:${state.itemData.value.keyboardPwd}\n$useDateStr\n密码名字:${state.itemData.value.keyboardPwdName}';
} }
@override @override
void onReady() { void onReady() {
// TODO: implement onReady
super.onReady(); super.onReady();
_initReplySubscription(); _initReplySubscription();
// getPasswordTypeUpdateIndexAction(); // getPasswordTypeUpdateIndexAction();
} }
@override
void onInit() {
// TODO: implement onInit
super.onInit();
}
@override @override
void onClose() { void onClose() {
// TODO: implement onClose
_replySubscription.cancel(); _replySubscription.cancel();
} }

View File

@ -1,28 +1,12 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:get/get.dart'; import 'package:get/get.dart';
import 'package:star_lock/main/lockDetail/passwordKey/passwordKeyList/passwordKeyListEntity.dart'; import 'package:star_lock/main/lockDetail/passwordKey/passwordKeyList/passwordKeyListEntity.dart';
class PasswordKeyDetailState { class PasswordKeyDetailState {
final itemData = PasswordKeyListItem().obs;
final TextEditingController inputPwdController = TextEditingController();
final TextEditingController inputNameController = TextEditingController();
final changeType = '1'.obs; //1-APP走蓝牙修改1APP SDK蓝牙修改后调用该接口 2-WiFi锁修改WiFi锁或有连接网关2
final keyboardPwd = ''.obs;//
final keyboardUserNo = 0.obs;//
final keyboardPwdName = ''.obs;
final keyboardPwdType = ''.obs;// 1 2 3 4 5 6 7 8 9 10 11 12 13 14
final isCirculation = false.obs;//
var keyId = 0.obs;// id
var ifCurrentScreen = true.obs; // ,
var sureBtnState = 0.obs;// 0() 1()
final passwordKeyNumber = "".obs;//
var isDeletPasswordKey = true.obs;//
var isAdministrator = false.obs;//
PasswordKeyDetailState() { PasswordKeyDetailState() {
Map map = Get.arguments; final Map map = Get.arguments;
itemData.value = map["itemData"]; itemData.value = map['itemData'];
// isCoerced.value = itemData.value.isCoerced!.toString(); // isCoerced.value = itemData.value.isCoerced!.toString();
keyboardPwd.value = itemData.value.keyboardPwd!; keyboardPwd.value = itemData.value.keyboardPwd!;
keyboardPwdName.value = itemData.value.keyboardPwdName!; keyboardPwdName.value = itemData.value.keyboardPwdName!;
@ -30,10 +14,27 @@ class PasswordKeyDetailState {
inputPwdController.text = itemData.value.keyboardPwd!; inputPwdController.text = itemData.value.keyboardPwd!;
keyId.value = itemData.value.keyboardPwdId!; keyId.value = itemData.value.keyboardPwdId!;
keyboardUserNo.value = itemData.value.pwdUserNo!; keyboardUserNo.value = itemData.value.pwdUserNo!;
isAdministrator.value = itemData.value.pwdRight! == 1 ? true : false; isAdministrator.value = itemData.value.pwdRight! == 1;
// startDate.value = itemData.value.startDate!; // startDate.value = itemData.value.startDate!;
// endDate.value = itemData.value.endDate!; // endDate.value = itemData.value.endDate!;
// hoursStart.value = itemData.value.hoursStart!; // hoursStart.value = itemData.value.hoursStart!;
// hoursEnd.value = itemData.value.hoursEnd!; // hoursEnd.value = itemData.value.hoursEnd!;
} }
final Rx<PasswordKeyListItem> itemData = PasswordKeyListItem().obs;
final TextEditingController inputPwdController = TextEditingController();
final TextEditingController inputNameController = TextEditingController();
final RxString changeType = '1'.obs; //1-APP走蓝牙修改1APP SDK蓝牙修改后调用该接口 2-WiFi锁修改WiFi锁或有连接网关2
final RxString keyboardPwd = ''.obs;//
final RxInt keyboardUserNo = 0.obs;//
final RxString keyboardPwdName = ''.obs;
final RxString keyboardPwdType = ''.obs;// 1 2 3 4 5 6 7 8 9 10 11 12 13 14
final RxBool isCirculation = false.obs;//
RxInt keyId = 0.obs;// id
RxBool ifCurrentScreen = true.obs; // ,
RxInt sureBtnState = 0.obs;// 0() 1()
final RxString passwordKeyNumber = ''.obs;//
RxBool isDeletPasswordKey = true.obs;//
RxBool isAdministrator = false.obs;//
} }

View File

@ -24,10 +24,10 @@ class PasswordKeyDetailChangeDateLogic extends BaseGetXController {
// //
late StreamSubscription<Reply> _replySubscription; late StreamSubscription<Reply> _replySubscription;
void _initReplySubscription() { void _initReplySubscription() {
_replySubscription = EventBusManager().eventBus!.on<Reply>().listen((reply) async { _replySubscription = EventBusManager().eventBus!.on<Reply>().listen((Reply reply) async {
// //
if ((reply is SenderCustomPasswordsReply) && (state.ifCurrentScreen.value == true)) { if ((reply is SenderCustomPasswordsReply) && (state.ifCurrentScreen.value == true)) {
int status = reply.data[2]; final int status = reply.data[2];
switch (status) { switch (status) {
case 0x00: case 0x00:
// //
@ -38,14 +38,14 @@ class PasswordKeyDetailChangeDateLogic extends BaseGetXController {
break; break;
case 0x06: case 0x06:
// //
var privateKey = await Storage.getStringList(saveBluePrivateKey); final List<String>? privateKey = await Storage.getStringList(saveBluePrivateKey);
List<int> getPrivateKeyList = changeStringListToIntList(privateKey!); final List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
var signKey = await Storage.getStringList(saveBlueSignKey); final List<String>? signKey = await Storage.getStringList(saveBlueSignKey);
List<int> signKeyDataList = changeStringListToIntList(signKey!); final List<int> signKeyDataList = changeStringListToIntList(signKey!);
var token = reply.data.sublist(5, 9); final List<int> token = reply.data.sublist(5, 9);
var saveStrList = changeIntListToStringList(token); final List<String> saveStrList = changeIntListToStringList(token);
Storage.setStringList(saveBlueToken, saveStrList); Storage.setStringList(saveBlueToken, saveStrList);
IoSenderManage.senderCustomPasswordsCommand( IoSenderManage.senderCustomPasswordsCommand(
@ -75,20 +75,20 @@ class PasswordKeyDetailChangeDateLogic extends BaseGetXController {
// //
Future<void> updatePwdRequest() async { Future<void> updatePwdRequest() async {
var beginTimeTimestamp = DateTool().dateToTimestamp(state.selectEffectiveDate.value, 1); final int beginTimeTimestamp = DateTool().dateToTimestamp(state.selectEffectiveDate.value, 1);
var endTimeTimestamp = DateTool().dateToTimestamp(state.selectFailureDate.value, 1); final int endTimeTimestamp = DateTool().dateToTimestamp(state.selectFailureDate.value, 1);
if (beginTimeTimestamp > endTimeTimestamp || if (beginTimeTimestamp > endTimeTimestamp ||
beginTimeTimestamp == endTimeTimestamp) { beginTimeTimestamp == endTimeTimestamp) {
showToast("失效时间需大于生效时间"); showToast('失效时间需大于生效时间');
return; return;
} }
if (endTimeTimestamp < DateTime.now().millisecondsSinceEpoch) { if (endTimeTimestamp < DateTime.now().millisecondsSinceEpoch) {
showToast("生效时间需大于当前时间"); showToast('生效时间需大于当前时间');
return; return;
} }
PasswordKeyEntity entity = await ApiRepository.to.updatePasswordKey( final PasswordKeyEntity entity = await ApiRepository.to.updatePasswordKey(
lockId: state.itemData.value.lockId!, lockId: state.itemData.value.lockId!,
keyboardPwdId: state.itemData.value.keyboardPwdId.toString(), keyboardPwdId: state.itemData.value.keyboardPwdId.toString(),
keyboardPwdName: state.itemData.value.keyboardPwdName!, keyboardPwdName: state.itemData.value.keyboardPwdName!,
@ -98,16 +98,16 @@ class PasswordKeyDetailChangeDateLogic extends BaseGetXController {
changeType: '1', changeType: '1',
hoursStart: state.itemData.value.hoursStart!, hoursStart: state.itemData.value.hoursStart!,
hoursEnd: state.itemData.value.hoursEnd!, hoursEnd: state.itemData.value.hoursEnd!,
isCoerced: "1", isCoerced: '1',
keyboardPwdType: 3, keyboardPwdType: 3,
pwdRight: state.itemData.value.pwdRight!); pwdRight: state.itemData.value.pwdRight!);
if (entity.errorCode!.codeIsSuccessful) { if (entity.errorCode!.codeIsSuccessful) {
showToast("修改成功", something: (){ showToast('修改成功', something: (){
eventBus.fire(GetPasswordListRefreshUI()); eventBus.fire(GetPasswordListRefreshUI());
AppLog.log("beginTimeTimestamp:$beginTimeTimestamp endTimeTimestamp:$endTimeTimestamp"); AppLog.log('beginTimeTimestamp:$beginTimeTimestamp endTimeTimestamp:$endTimeTimestamp');
Get.back(result: { Get.back(result: <String, String>{
"beginTimeTimestamp": beginTimeTimestamp.toString(), 'beginTimeTimestamp': beginTimeTimestamp.toString(),
"endTimeTimestamp": endTimeTimestamp.toString(), 'endTimeTimestamp': endTimeTimestamp.toString(),
}); });
}); });
} }
@ -123,14 +123,14 @@ class PasswordKeyDetailChangeDateLogic extends BaseGetXController {
}); });
BlueManage().blueSendData(BlueManage().connectDeviceName, (BluetoothConnectionState deviceConnectionState) async { BlueManage().blueSendData(BlueManage().connectDeviceName, (BluetoothConnectionState deviceConnectionState) async {
if (deviceConnectionState == BluetoothConnectionState.connected) { if (deviceConnectionState == BluetoothConnectionState.connected) {
var signKey = await Storage.getStringList(saveBlueSignKey); final List<String>? signKey = await Storage.getStringList(saveBlueSignKey);
List<int> signKeyDataList = changeStringListToIntList(signKey!); final List<int> signKeyDataList = changeStringListToIntList(signKey!);
var privateKey = await Storage.getStringList(saveBluePrivateKey); final List<String>? privateKey = await Storage.getStringList(saveBluePrivateKey);
List<int> getPrivateKeyList = changeStringListToIntList(privateKey!); final List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
var token = await Storage.getStringList(saveBlueToken); final List<String>? token = await Storage.getStringList(saveBlueToken);
List<int> getTokenList = changeStringListToIntList(token!); final List<int> getTokenList = changeStringListToIntList(token!);
IoSenderManage.senderCustomPasswordsCommand( IoSenderManage.senderCustomPasswordsCommand(
keyID:state.itemData.value.keyboardPwdId!.toString(), keyID:state.itemData.value.keyboardPwdId!.toString(),
@ -138,7 +138,7 @@ class PasswordKeyDetailChangeDateLogic extends BaseGetXController {
pwdNo: state.itemData.value.pwdUserNo!, pwdNo: state.itemData.value.pwdUserNo!,
pwd: state.itemData.value.keyboardPwd!.toString(), pwd: state.itemData.value.keyboardPwd!.toString(),
operate: 1, operate: 1,
isAdmin: state.itemData.value.pwdUserNo!, isAdmin: state.itemData.value.pwdRight!,
useCountLimit: 0xffff, useCountLimit: 0xffff,
startTime:DateTool().dateToTimestamp(state.selectEffectiveDate.value, 1) ~/ 1000, startTime:DateTool().dateToTimestamp(state.selectEffectiveDate.value, 1) ~/ 1000,
endTime:DateTool().dateToTimestamp(state.selectFailureDate.value, 1) ~/ 1000, endTime:DateTool().dateToTimestamp(state.selectFailureDate.value, 1) ~/ 1000,
@ -160,22 +160,14 @@ class PasswordKeyDetailChangeDateLogic extends BaseGetXController {
@override @override
void onReady() { void onReady() {
// TODO: implement onReady
super.onReady(); super.onReady();
_initReplySubscription(); _initReplySubscription();
// getPasswordTypeUpdateIndexAction(); // getPasswordTypeUpdateIndexAction();
} }
@override
void onInit() {
// TODO: implement onInit
super.onInit();
}
@override @override
void onClose() { void onClose() {
// TODO: implement onClose
_replySubscription.cancel(); _replySubscription.cancel();
} }
} }

View File

@ -1,23 +1,22 @@
import 'package:flutter/material.dart';
import 'package:get/get.dart'; import 'package:get/get.dart';
import 'package:star_lock/main/lockDetail/passwordKey/passwordKeyList/passwordKeyListEntity.dart'; import 'package:star_lock/main/lockDetail/passwordKey/passwordKeyList/passwordKeyListEntity.dart';
import 'package:star_lock/tools/dateTool.dart'; import 'package:star_lock/tools/dateTool.dart';
class PasswordKeyDetailChangeDateState { class PasswordKeyDetailChangeDateState {
final itemData = PasswordKeyListItem().obs;
final selectEffectiveDate = ''.obs; //
final selectFailureDate = ''.obs; //
var ifCurrentScreen = true.obs; // ,
var sureBtnState = 0.obs;// 0() 1()
PasswordKeyDetailChangeDateState() { PasswordKeyDetailChangeDateState() {
Map map = Get.arguments; final Map map = Get.arguments;
if ((map["itemData"] != null)) { if (map['itemData'] != null) {
itemData.value = map["itemData"]; itemData.value = map['itemData'];
selectEffectiveDate.value = itemData.value.startDate == 0 ? DateTool().getNowDateWithType(2) : DateTool().dateToYMDHNString(itemData.value.startDate.toString()); selectEffectiveDate.value = itemData.value.startDate == 0 ? DateTool().getNowDateWithType(2) : DateTool().dateToYMDHNString(itemData.value.startDate.toString());
selectFailureDate.value = itemData.value.endDate == 0 ? DateTool().getNowDateWithType(2) : DateTool().dateToYMDHNString(itemData.value.endDate.toString()); selectFailureDate.value = itemData.value.endDate == 0 ? DateTool().getNowDateWithType(2) : DateTool().dateToYMDHNString(itemData.value.endDate.toString());
} }
} }
final Rx<PasswordKeyListItem> itemData = PasswordKeyListItem().obs;
final RxString selectEffectiveDate = ''.obs; //
final RxString selectFailureDate = ''.obs; //
RxBool ifCurrentScreen = true.obs; // ,
RxInt sureBtnState = 0.obs; // 0() 1()
} }

View File

@ -1,18 +1,17 @@
// ignore_for_file: slash_for_doc_comments
import 'dart:async'; import 'dart:async';
import 'package:flutter_blue_plus/flutter_blue_plus.dart'; import 'package:flutter_blue_plus/flutter_blue_plus.dart';
import 'package:get/get.dart'; import 'package:get/get.dart';
import 'package:star_lock/app_settings/app_settings.dart'; import 'package:star_lock/main/lockDetail/passwordKey/passwordKey_perpetual/passwordKeyEntity.dart';
import 'package:star_lock/main/lockDetail/passwordKey/passwordKey_perpetual/passwordKey_perpetual_state.dart'; import 'package:star_lock/main/lockDetail/passwordKey/passwordKey_perpetual/passwordKey_perpetual_state.dart';
import 'package:star_lock/network/api_repository.dart'; import 'package:star_lock/network/api_repository.dart';
import 'package:star_lock/tools/eventBusEventManage.dart'; import 'package:star_lock/tools/eventBusEventManage.dart';
import '../../../../blue/blue_manage.dart'; import '../../../../blue/blue_manage.dart';
import '../../../../blue/io_modelVendor.dart'; import '../../../../blue/io_modelVendor.dart';
import '../../../../blue/io_reply.dart';
import '../../../../blue/io_protocol/io_senderCustomPasswords.dart'; import '../../../../blue/io_protocol/io_senderCustomPasswords.dart';
import '../../../../blue/io_reply.dart';
import '../../../../blue/io_tool/io_tool.dart'; import '../../../../blue/io_tool/io_tool.dart';
import '../../../../blue/io_tool/manager_event_bus.dart'; import '../../../../blue/io_tool/manager_event_bus.dart';
import '../../../../blue/sender_manage.dart'; import '../../../../blue/sender_manage.dart';
@ -25,18 +24,16 @@ class PasswordKeyPerpetualLogic extends BaseGetXController {
final PasswordKeyPerpetualState state = PasswordKeyPerpetualState(); final PasswordKeyPerpetualState state = PasswordKeyPerpetualState();
/// ///
/** /// getKeyType 1 2 3 4 5 6 7 8 9 10 11 12 13 14
* getKeyType 1 2 3 4 5 6 7 8 9 10 11 12 13 14
*/
// //
Future<void> getKeyboardPwdRequest() async { Future<void> getKeyboardPwdRequest() async {
var startDate = DateTool().dateToTimestamp(state.beginTime.value, 1); final int startDate = DateTool().dateToTimestamp(state.beginTime.value, 1);
var endDate = DateTool().dateToTimestamp(state.endTime.value, 1); final int endDate = DateTool().dateToTimestamp(state.endTime.value, 1);
String lockId = state.keyInfo.value.lockId.toString(); final String lockId = state.keyInfo.value.lockId.toString();
String getKeyType = "0"; String getKeyType = '0';
if (state.nameController.text.isEmpty) { if (state.nameController.text.isEmpty) {
showToast("请输入姓名".tr); showToast('请输入姓名'.tr);
return; return;
} }
@ -48,7 +45,7 @@ class PasswordKeyPerpetualLogic extends BaseGetXController {
// 鸿 // 鸿
if(CommonDataManage().currentKeyInfo.vendor == IoModelVendor.vendor_XHJ && (CommonDataManage().currentKeyInfo.model == IoModelVendor.model_XHJ_SYD || CommonDataManage().currentKeyInfo.model == IoModelVendor.model_XHJ_JL)){ if(CommonDataManage().currentKeyInfo.vendor == IoModelVendor.vendor_XHJ && (CommonDataManage().currentKeyInfo.model == IoModelVendor.model_XHJ_SYD || CommonDataManage().currentKeyInfo.model == IoModelVendor.model_XHJ_JL)){
if (endDate <= DateTool().dateToTimestamp(DateTool().getNowDateWithType(3), 1)) { if (endDate <= DateTool().dateToTimestamp(DateTool().getNowDateWithType(3), 1)) {
showToast("失效时间要大于当前时间".tr); showToast('失效时间要大于当前时间'.tr);
return; return;
} }
} }
@ -57,12 +54,12 @@ class PasswordKeyPerpetualLogic extends BaseGetXController {
if(CommonDataManage().currentKeyInfo.vendor == IoModelVendor.vendor_XL && (CommonDataManage().currentKeyInfo.model == IoModelVendor.model_XL_BLE || CommonDataManage().currentKeyInfo.model == IoModelVendor.model_XL_WIFI)){ if(CommonDataManage().currentKeyInfo.vendor == IoModelVendor.vendor_XL && (CommonDataManage().currentKeyInfo.model == IoModelVendor.model_XL_BLE || CommonDataManage().currentKeyInfo.model == IoModelVendor.model_XL_WIFI)){
// //
if (startDate < DateTool().dateToTimestamp(DateTool().getNowDateWithType(3), 1)) { if (startDate < DateTool().dateToTimestamp(DateTool().getNowDateWithType(3), 1)) {
showToast("生效时间不能小于当前时间".tr); showToast('生效时间不能小于当前时间'.tr);
return; return;
} }
if (startDate >= endDate) { if (startDate >= endDate) {
showToast("失效时间要大于生效时间".tr); showToast('失效时间要大于生效时间'.tr);
return; return;
} }
} }
@ -77,13 +74,13 @@ class PasswordKeyPerpetualLogic extends BaseGetXController {
// //
if(CommonDataManage().currentKeyInfo.vendor == IoModelVendor.vendor_XL && (CommonDataManage().currentKeyInfo.model == IoModelVendor.model_XL_BLE || CommonDataManage().currentKeyInfo.model == IoModelVendor.model_XL_WIFI)){ if(CommonDataManage().currentKeyInfo.vendor == IoModelVendor.vendor_XL && (CommonDataManage().currentKeyInfo.model == IoModelVendor.model_XL_BLE || CommonDataManage().currentKeyInfo.model == IoModelVendor.model_XL_WIFI)){
if (endDate < DateTool().dateToTimestamp(DateTool().getNowDateWithType(3), 1)) { if (endDate < DateTool().dateToTimestamp(DateTool().getNowDateWithType(3), 1)) {
showToast("结束时间不能小于当前时间".tr); showToast('结束时间不能小于当前时间'.tr);
return; return;
} }
} }
if (state.loopStartHours.value >= state.loopEndHours.value) { if (state.loopStartHours.value >= state.loopEndHours.value) {
showToast("失效时间要大于生效时间".tr); showToast('失效时间要大于生效时间'.tr);
return; return;
} }
if (state.loopModeStr.value == '周末') { if (state.loopModeStr.value == '周末') {
@ -111,7 +108,7 @@ class PasswordKeyPerpetualLogic extends BaseGetXController {
// //
getKeyType = '4'; getKeyType = '4';
} }
var entity = await ApiRepository.to.getPasswordKey( final PasswordKeyEntity entity = await ApiRepository.to.getPasswordKey(
endDate: endDate.toString(), endDate: endDate.toString(),
keyboardPwdName: state.nameController.text, keyboardPwdName: state.nameController.text,
keyboardPwdType: getKeyType, keyboardPwdType: getKeyType,
@ -124,8 +121,8 @@ class PasswordKeyPerpetualLogic extends BaseGetXController {
state.isSendSuccess.value = true; state.isSendSuccess.value = true;
state.sendSucceedType.value = state.widgetType.value; state.sendSucceedType.value = state.widgetType.value;
state.pwdNameStr = state.nameController.text; state.pwdNameStr = state.nameController.text;
state.nameController.text = ""; state.nameController.text = '';
state.pwdController.text = ""; state.pwdController.text = '';
if (entity.data != null) { if (entity.data != null) {
state.getPwdStr.value = entity.data!.keyboardPwd!; state.getPwdStr.value = entity.data!.keyboardPwd!;
} }
@ -140,7 +137,7 @@ class PasswordKeyPerpetualLogic extends BaseGetXController {
Future<void> addKeyboardPwdRequest() async { Future<void> addKeyboardPwdRequest() async {
String getEffectiveDateTime = '0'; String getEffectiveDateTime = '0';
String getFailureDateTime = '0'; String getFailureDateTime = '0';
String lockId = state.keyInfo.value.lockId.toString(); final String lockId = state.keyInfo.value.lockId.toString();
String getKeyType = '2'; String getKeyType = '2';
// //
if (state.isPermanent.value == false) { if (state.isPermanent.value == false) {
@ -148,7 +145,7 @@ class PasswordKeyPerpetualLogic extends BaseGetXController {
getEffectiveDateTime = DateTool().dateToTimestamp(state.customBeginTime.value, 1).toString(); getEffectiveDateTime = DateTool().dateToTimestamp(state.customBeginTime.value, 1).toString();
getFailureDateTime = DateTool().dateToTimestamp(state.customEndTime.value, 1).toString(); getFailureDateTime = DateTool().dateToTimestamp(state.customEndTime.value, 1).toString();
} }
var entity = await ApiRepository.to.addPasswordKey( final PasswordKeyEntity entity = await ApiRepository.to.addPasswordKey(
lockId:lockId, lockId:lockId,
keyboardPwdName:state.nameController.text, keyboardPwdName:state.nameController.text,
keyboardPwd:state.pwdController.text, keyboardPwd:state.pwdController.text,
@ -156,13 +153,14 @@ class PasswordKeyPerpetualLogic extends BaseGetXController {
startDate:getEffectiveDateTime, startDate:getEffectiveDateTime,
endDate:getFailureDateTime, endDate:getFailureDateTime,
addType:'1', addType:'1',
pwdRight:state.isAdministrator.value == true ? 1 : 0,); pwdRight:state.isAdministrator.value == true ? 1 : 0
);
if (entity.errorCode!.codeIsSuccessful) { if (entity.errorCode!.codeIsSuccessful) {
state.isSendSuccess.value = true; state.isSendSuccess.value = true;
state.sendSucceedType.value = state.widgetType.value; state.sendSucceedType.value = state.widgetType.value;
state.pwdNameStr = state.nameController.text; state.pwdNameStr = state.nameController.text;
state.nameController.text = ""; state.nameController.text = '';
state.pwdController.text = ""; state.pwdController.text = '';
if (entity.data != null) { if (entity.data != null) {
state.getPwdStr.value = entity.data!.keyboardPwd!; state.getPwdStr.value = entity.data!.keyboardPwd!;
updatePWDNumberRequest(entity.data!.keyboardPwdId.toString()); updatePWDNumberRequest(entity.data!.keyboardPwdId.toString());
@ -173,7 +171,7 @@ class PasswordKeyPerpetualLogic extends BaseGetXController {
} }
Future<void> updatePWDNumberRequest(String pwdNumberId) async { Future<void> updatePWDNumberRequest(String pwdNumberId) async {
var entity = await ApiRepository.to.updatePWDNumber( final PasswordKeyEntity entity = await ApiRepository.to.updatePWDNumber(
lockId: state.keyInfo.value.lockId.toString(), lockId: state.keyInfo.value.lockId.toString(),
keyboardPwdId: pwdNumberId, keyboardPwdId: pwdNumberId,
pwdUserNo: state.pwdNumber.value.toString()); pwdUserNo: state.pwdNumber.value.toString());
@ -184,14 +182,14 @@ class PasswordKeyPerpetualLogic extends BaseGetXController {
Future<void> checkKeyboardpwdNameRequest() async { Future<void> checkKeyboardpwdNameRequest() async {
if (state.nameController.text.isEmpty) { if (state.nameController.text.isEmpty) {
showToast("请输入姓名".tr); showToast('请输入姓名'.tr);
return; return;
} }
if (state.pwdController.text.isEmpty) { if (state.pwdController.text.isEmpty) {
showToast("请输入密码".tr); showToast('请输入密码'.tr);
return; return;
} }
var entity = await ApiRepository.to.checkKeyboardpwdName( final PasswordKeyEntity entity = await ApiRepository.to.checkKeyboardpwdName(
lockId:state.keyInfo.value.lockId.toString(), lockId:state.keyInfo.value.lockId.toString(),
keyboardPwdName:state.nameController.text, keyboardPwdName:state.nameController.text,
keyboardPwd:state.pwdController.text,); keyboardPwd:state.pwdController.text,);
@ -206,10 +204,10 @@ class PasswordKeyPerpetualLogic extends BaseGetXController {
// //
late StreamSubscription<Reply> _replySubscription; late StreamSubscription<Reply> _replySubscription;
void _initReplySubscription() { void _initReplySubscription() {
_replySubscription = EventBusManager().eventBus!.on<Reply>().listen((reply) async { _replySubscription = EventBusManager().eventBus!.on<Reply>().listen((Reply reply) async {
// //
if ((reply is SenderCustomPasswordsReply) && (state.ifCurrentScreen.value == true)) { if ((reply is SenderCustomPasswordsReply) && (state.ifCurrentScreen.value == true)) {
int status = reply.data[2]; final int status = reply.data[2];
switch (status) { switch (status) {
case 0x00: case 0x00:
// //
@ -227,23 +225,23 @@ class PasswordKeyPerpetualLogic extends BaseGetXController {
break; break;
case 0xff: case 0xff:
// //
showToast("退出添加".tr); showToast('退出添加'.tr);
break; break;
case 0xFE: case 0xFE:
// //
showToast("管理员已满".tr); showToast('管理员已满'.tr);
break; break;
case 0xFD: case 0xFD:
// //
showToast("用户已满".tr); showToast('用户已满'.tr);
break; break;
case 0xFC: case 0xFC:
// //
showToast("锁上面添加密码已满".tr); showToast('锁上面添加密码已满'.tr);
break; break;
case 0xFB: case 0xFB:
// //
showToast("密码已存在".tr); showToast('密码已存在'.tr);
break; break;
default: default:
// //
@ -252,26 +250,26 @@ class PasswordKeyPerpetualLogic extends BaseGetXController {
break; break;
case 0x06: case 0x06:
// //
var token = reply.data.sublist(5, 9); final List<int> token = reply.data.sublist(5, 9);
// AppLog.log("token:$token"); // AppLog.log("token:$token");
var saveStrList = changeIntListToStringList(token); final List<String> saveStrList = changeIntListToStringList(token);
Storage.setStringList(saveBlueToken, saveStrList); Storage.setStringList(saveBlueToken, saveStrList);
var privateKey = await Storage.getStringList(saveBluePrivateKey); final List<String>? privateKey = await Storage.getStringList(saveBluePrivateKey);
List<int> getPrivateKeyList = changeStringListToIntList(privateKey!); final List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
var signKey = await Storage.getStringList(saveBlueSignKey); final List<String>? signKey = await Storage.getStringList(saveBlueSignKey);
List<int> signKeyDataList = changeStringListToIntList(signKey!); final List<int> signKeyDataList = changeStringListToIntList(signKey!);
var startDate = DateTool().dateToTimestamp(state.customBeginTime.value, 1); int startDate = DateTool().dateToTimestamp(state.customBeginTime.value, 1);
var endDate = DateTool().dateToTimestamp(state.customEndTime.value, 1); int endDate = DateTool().dateToTimestamp(state.customEndTime.value, 1);
// //
if (state.isPermanent.value == true) { if (state.isPermanent.value == true) {
startDate = 0; startDate = 0;
endDate = 0; endDate = 0;
} }
IoSenderManage.senderCustomPasswordsCommand( IoSenderManage.senderCustomPasswordsCommand(
keyID: "1", keyID: '1',
userID: await Storage.getUid(), userID: await Storage.getUid(),
pwdNo: 0, pwdNo: 0,
pwd:state.pwdController.text, pwd:state.pwdController.text,
@ -309,17 +307,17 @@ class PasswordKeyPerpetualLogic extends BaseGetXController {
// //
Future<void> senderCustomPasswords() async { Future<void> senderCustomPasswords() async {
var startDate = DateTool().dateToTimestamp(state.customBeginTime.value, 1); int startDate = DateTool().dateToTimestamp(state.customBeginTime.value, 1);
var endDate = DateTool().dateToTimestamp(state.customEndTime.value, 1); int endDate = DateTool().dateToTimestamp(state.customEndTime.value, 1);
// //
if (state.isPermanent.value == false) { if (state.isPermanent.value == false) {
if (startDate < DateTool().dateToTimestamp(DateTool().getNowDateWithType(2), 1)) { if (startDate < DateTool().dateToTimestamp(DateTool().getNowDateWithType(2), 1)) {
showToast("生效时间要大于当前时间"); showToast('生效时间要大于当前时间');
return; return;
} }
if (endDate <= startDate) { if (endDate <= startDate) {
showToast("失效时间需大于生效时间"); showToast('失效时间需大于生效时间');
return; return;
} }
}else{ }else{
@ -328,7 +326,7 @@ class PasswordKeyPerpetualLogic extends BaseGetXController {
} }
if (state.pwdController.text.length < 6 || state.pwdController.text.length > 9) { if (state.pwdController.text.length < 6 || state.pwdController.text.length > 9) {
showToast("请输入6-9位数字密码"); showToast('请输入6-9位数字密码');
return; return;
} }
@ -344,17 +342,17 @@ class PasswordKeyPerpetualLogic extends BaseGetXController {
}); });
BlueManage().blueSendData(BlueManage().connectDeviceName, (BluetoothConnectionState deviceConnectionState) async { BlueManage().blueSendData(BlueManage().connectDeviceName, (BluetoothConnectionState deviceConnectionState) async {
if (deviceConnectionState == BluetoothConnectionState.connected) { if (deviceConnectionState == BluetoothConnectionState.connected) {
var signKey = await Storage.getStringList(saveBlueSignKey); final List<String>? signKey = await Storage.getStringList(saveBlueSignKey);
List<int> signKeyDataList = changeStringListToIntList(signKey!); final List<int> signKeyDataList = changeStringListToIntList(signKey!);
var privateKey = await Storage.getStringList(saveBluePrivateKey); final List<String>? privateKey = await Storage.getStringList(saveBluePrivateKey);
List<int> getPrivateKeyList = changeStringListToIntList(privateKey!); final List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
var token = await Storage.getStringList(saveBlueToken); final List<String>? token = await Storage.getStringList(saveBlueToken);
List<int> getTokenList = changeStringListToIntList(token!); final List<int> getTokenList = changeStringListToIntList(token!);
IoSenderManage.senderCustomPasswordsCommand( IoSenderManage.senderCustomPasswordsCommand(
keyID: "1", keyID: '1',
userID: await Storage.getUid(), userID: await Storage.getUid(),
pwdNo: 0, pwdNo: 0,
pwd:state.pwdController.text, pwd:state.pwdController.text,
@ -380,7 +378,7 @@ class PasswordKeyPerpetualLogic extends BaseGetXController {
} }
String getShareContentStr() { String getShareContentStr() {
int? getPwdType = state.widgetType.value; final int getPwdType = state.widgetType.value;
String useDateStr = ''; String useDateStr = '';
// DateTime startDateStr = DateTime.fromMillisecondsSinceEpoch(state.itemData.value.startDate!); // DateTime startDateStr = DateTime.fromMillisecondsSinceEpoch(state.itemData.value.startDate!);
// DateTime endDateStr = DateTime.fromMillisecondsSinceEpoch(state.itemData.value.endDate!); // DateTime endDateStr = DateTime.fromMillisecondsSinceEpoch(state.itemData.value.endDate!);
@ -421,11 +419,11 @@ class PasswordKeyPerpetualLogic extends BaseGetXController {
default: default:
} }
return "您好,您的密码是:${state.getPwdStr.value}\n$useDateStr\n密码名字:${state.pwdNameStr}"; return '您好,您的密码是:${state.getPwdStr.value}\n$useDateStr\n密码名字:${state.pwdNameStr}';
} }
String addSpaces(String input) { String addSpaces(String input) {
return input.replaceAllMapped(RegExp(r'.{4}'), (match) { return input.replaceAllMapped(RegExp(r'.{4}'), (Match match) {
return '${match.group(0)} '; return '${match.group(0)} ';
}).trim(); }).trim();
} }

View File

@ -1,3 +1,4 @@
import 'package:flutter/cupertino.dart'; import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/services.dart'; import 'package:flutter/services.dart';
@ -7,6 +8,7 @@ import 'package:get/get.dart';
import 'package:star_lock/app_settings/app_colors.dart'; import 'package:star_lock/app_settings/app_colors.dart';
import 'package:star_lock/app_settings/app_settings.dart'; import 'package:star_lock/app_settings/app_settings.dart';
import 'package:star_lock/main/lockDetail/passwordKey/passwordKey_perpetual/passwordKey_perpetual_logic.dart'; import 'package:star_lock/main/lockDetail/passwordKey/passwordKey_perpetual/passwordKey_perpetual_logic.dart';
import 'package:star_lock/main/lockDetail/passwordKey/passwordKey_perpetual/passwordKey_perpetual_state.dart';
import 'package:star_lock/tools/commonDataManage.dart'; import 'package:star_lock/tools/commonDataManage.dart';
import 'package:star_lock/tools/pickers/pickers.dart'; import 'package:star_lock/tools/pickers/pickers.dart';
import 'package:star_lock/tools/pickers/style/default_style.dart'; import 'package:star_lock/tools/pickers/style/default_style.dart';
@ -25,7 +27,6 @@ import '../../../../tools/pickers/time_picker/model/pduration.dart';
import '../../../../tools/submitBtn.dart'; import '../../../../tools/submitBtn.dart';
import '../../../../tools/titleAppBar.dart'; import '../../../../tools/titleAppBar.dart';
import '../../../../translations/trans_lib.dart'; import '../../../../translations/trans_lib.dart';
import '../../../lockMian/entity/lockListInfo_entity.dart';
class PasswordKeyPerpetualPage extends StatefulWidget { class PasswordKeyPerpetualPage extends StatefulWidget {
const PasswordKeyPerpetualPage({Key? key}) : super(key: key); const PasswordKeyPerpetualPage({Key? key}) : super(key: key);
@ -37,12 +38,11 @@ class PasswordKeyPerpetualPage extends StatefulWidget {
class _PasswordKeyPerpetualPageState extends State<PasswordKeyPerpetualPage> class _PasswordKeyPerpetualPageState extends State<PasswordKeyPerpetualPage>
with RouteAware, SingleTickerProviderStateMixin { with RouteAware, SingleTickerProviderStateMixin {
final logic = Get.put(PasswordKeyPerpetualLogic()); final PasswordKeyPerpetualLogic logic = Get.put(PasswordKeyPerpetualLogic());
final state = Get.find<PasswordKeyPerpetualLogic>().state; final PasswordKeyPerpetualState state = Get.find<PasswordKeyPerpetualLogic>().state;
@override @override
void initState() { void initState() {
// TODO: implement initState
super.initState(); super.initState();
state.tabController = state.tabController =
@ -67,7 +67,7 @@ class _PasswordKeyPerpetualPageState extends State<PasswordKeyPerpetualPage>
haveBack: true, haveBack: true,
backgroundColor: AppColors.mainColor), backgroundColor: AppColors.mainColor),
body: Column( body: Column(
children: [ children: <Widget>[
_tabBar(), _tabBar(),
_pageWidget(), _pageWidget(),
], ],
@ -86,14 +86,14 @@ class _PasswordKeyPerpetualPageState extends State<PasswordKeyPerpetualPage>
// //
return SingleChildScrollView( return SingleChildScrollView(
child: Column( child: Column(
children: [ children: <Widget>[
perpetualKeyWidget( perpetualKeyWidget(
false, false,
TranslationLoader.lanKeys!.name!.tr, TranslationLoader.lanKeys!.name!.tr,
TranslationLoader.lanKeys!.pleaseNameYourPassword!.tr, TranslationLoader.lanKeys!.pleaseNameYourPassword!.tr,
state.nameController), state.nameController),
keyBottomWidget( keyBottomWidget(
"密码生成后请在当日2359前使用一次进行激活否则过0点后未激活则失效。密码激活后有效期内不限次数使用。" '密码生成后请在当日2359前使用一次进行激活否则过0点后未激活则失效。密码激活后有效期内不限次数使用。'
.tr) .tr)
], ],
), ),
@ -104,7 +104,7 @@ class _PasswordKeyPerpetualPageState extends State<PasswordKeyPerpetualPage>
// //
return SingleChildScrollView( return SingleChildScrollView(
child: Column( child: Column(
children: [ children: <Widget>[
keyTimeLimitWidget(), keyTimeLimitWidget(),
perpetualKeyWidget( perpetualKeyWidget(
false, false,
@ -112,7 +112,7 @@ class _PasswordKeyPerpetualPageState extends State<PasswordKeyPerpetualPage>
TranslationLoader.lanKeys!.pleaseNameYourPassword!.tr, TranslationLoader.lanKeys!.pleaseNameYourPassword!.tr,
state.nameController), state.nameController),
keyBottomWidget( keyBottomWidget(
"密码生成后请在当日2359前使用一次进行激活否则过0点后未激活则失效。密码激活后有效期内不限次数使用。" '密码生成后请在当日2359前使用一次进行激活否则过0点后未激活则失效。密码激活后有效期内不限次数使用。'
.tr) .tr)
], ],
), ),
@ -123,7 +123,7 @@ class _PasswordKeyPerpetualPageState extends State<PasswordKeyPerpetualPage>
// //
return SingleChildScrollView( return SingleChildScrollView(
child: Column( child: Column(
children: [ children: <Widget>[
perpetualKeyWidget( perpetualKeyWidget(
false, false,
TranslationLoader.lanKeys!.name!.tr, TranslationLoader.lanKeys!.name!.tr,
@ -140,11 +140,9 @@ class _PasswordKeyPerpetualPageState extends State<PasswordKeyPerpetualPage>
// //
return SingleChildScrollView( return SingleChildScrollView(
child: Column( child: Column(
children: [ children: <Widget>[
keyIfPerpetualWidget(), keyIfPerpetualWidget(),
state.isPermanent.value == false if (state.isPermanent.value == false) keyCustomTimeLimitWidget() else Container(),
? keyCustomTimeLimitWidget()
: Container(),
perpetualKeyWidget( perpetualKeyWidget(
false, false,
TranslationLoader.lanKeys!.name!.tr, TranslationLoader.lanKeys!.name!.tr,
@ -153,7 +151,7 @@ class _PasswordKeyPerpetualPageState extends State<PasswordKeyPerpetualPage>
perpetualKeyWidget( perpetualKeyWidget(
false, false,
TranslationLoader.lanKeys!.password!.tr, TranslationLoader.lanKeys!.password!.tr,
"请输入6-9位数字", '请输入6-9位数字',
state.pwdController), state.pwdController),
keyIfAdministratorWidget(), keyIfAdministratorWidget(),
keyBottomWidget( keyBottomWidget(
@ -167,7 +165,7 @@ class _PasswordKeyPerpetualPageState extends State<PasswordKeyPerpetualPage>
// //
return SingleChildScrollView( return SingleChildScrollView(
child: Column( child: Column(
children: [ children: <Widget>[
keyCirculationWidget(), keyCirculationWidget(),
perpetualKeyWidget( perpetualKeyWidget(
true, true,
@ -175,7 +173,7 @@ class _PasswordKeyPerpetualPageState extends State<PasswordKeyPerpetualPage>
TranslationLoader.lanKeys!.pleaseNameYourPassword!.tr, TranslationLoader.lanKeys!.pleaseNameYourPassword!.tr,
state.nameController), state.nameController),
keyBottomWidget( keyBottomWidget(
"密码生成后请在当日2359前使用一次进行激活否则过0点后未激活则失效。密码激活后有效期内不限次数使用。" '密码生成后请在当日2359前使用一次进行激活否则过0点后未激活则失效。密码激活后有效期内不限次数使用。'
.tr) .tr)
], ],
), ),
@ -186,14 +184,14 @@ class _PasswordKeyPerpetualPageState extends State<PasswordKeyPerpetualPage>
// //
return SingleChildScrollView( return SingleChildScrollView(
child: Column( child: Column(
children: [ children: <Widget>[
perpetualKeyWidget( perpetualKeyWidget(
false, false,
TranslationLoader.lanKeys!.name!.tr, TranslationLoader.lanKeys!.name!.tr,
TranslationLoader.lanKeys!.pleaseNameYourPassword!.tr, TranslationLoader.lanKeys!.pleaseNameYourPassword!.tr,
state.nameController), state.nameController),
keyBottomWidget( keyBottomWidget(
"清空密码底部提示".tr) '清空密码底部提示'.tr)
], ],
), ),
); );
@ -208,11 +206,11 @@ class _PasswordKeyPerpetualPageState extends State<PasswordKeyPerpetualPage>
Widget perpetualKeyWidget(bool isTopHeight, String titleStr, Widget perpetualKeyWidget(bool isTopHeight, String titleStr,
String rightTitle, TextEditingController controller) { String rightTitle, TextEditingController controller) {
return Column( return Column(
children: [ children: <Widget>[
isTopHeight ? SizedBox(height: 10.h) : Container(), if (isTopHeight) SizedBox(height: 10.h) else Container(),
CommonItem( CommonItem(
leftTitel: titleStr, leftTitel: titleStr,
rightTitle: "", rightTitle: '',
isHaveRightWidget: true, isHaveRightWidget: true,
rightWidget: getTFWidget(rightTitle, controller)), rightWidget: getTFWidget(rightTitle, controller)),
SizedBox(height: 10.h), SizedBox(height: 10.h),
@ -223,17 +221,17 @@ class _PasswordKeyPerpetualPageState extends State<PasswordKeyPerpetualPage>
// //
Widget keyTimeLimitWidget() { Widget keyTimeLimitWidget() {
return Column( return Column(
children: [ children: <Widget>[
Visibility( Visibility(
visible: visible:
CommonDataManage().currentKeyInfo.vendor == "XHJ" ? false : true, CommonDataManage().currentKeyInfo.vendor == 'XHJ' ? false : true,
child: CommonItem( child: CommonItem(
leftTitel: TranslationLoader.lanKeys!.effectiveTime!.tr, leftTitel: TranslationLoader.lanKeys!.effectiveTime!.tr,
rightTitle: state.beginTime.value, rightTitle: state.beginTime.value,
isHaveLine: true, isHaveLine: true,
isHaveDirection: true, isHaveDirection: true,
action: () { action: () {
PDuration selectDate = final PDuration selectDate =
PDuration.parse(DateTime.tryParse(state.beginTime.value)); PDuration.parse(DateTime.tryParse(state.beginTime.value));
Pickers.showDatePicker(context, Pickers.showDatePicker(context,
selectDate: selectDate, selectDate: selectDate,
@ -243,7 +241,7 @@ class _PasswordKeyPerpetualPageState extends State<PasswordKeyPerpetualPage>
day: DateTime.now().day, day: DateTime.now().day,
hour: 24), hour: 24),
// minDate: PDuration.now(), // minDate: PDuration.now(),
mode: DateMode.YMDHM, onConfirm: (p) { mode: DateMode.YMDHM, onConfirm: (PDuration p) {
state.beginTime.value = DateTool().getYMDHNDateString(p, 4); state.beginTime.value = DateTool().getYMDHNDateString(p, 4);
}); });
}), }),
@ -253,7 +251,7 @@ class _PasswordKeyPerpetualPageState extends State<PasswordKeyPerpetualPage>
rightTitle: state.endTime.value, rightTitle: state.endTime.value,
isHaveDirection: true, isHaveDirection: true,
action: () { action: () {
PDuration selectDate = final PDuration selectDate =
PDuration.parse(DateTime.tryParse(state.endTime.value)); PDuration.parse(DateTime.tryParse(state.endTime.value));
Pickers.showDatePicker(context, Pickers.showDatePicker(context,
selectDate: selectDate, selectDate: selectDate,
@ -266,7 +264,7 @@ class _PasswordKeyPerpetualPageState extends State<PasswordKeyPerpetualPage>
year: DateTime.now().year, year: DateTime.now().year,
month: DateTime.now().month, month: DateTime.now().month,
day: DateTime.now().day), day: DateTime.now().day),
mode: DateMode.YMDH, onConfirm: (p) { mode: DateMode.YMDH, onConfirm: (PDuration p) {
state.endTime.value = DateTool().getYMDHNDateString(p, 4); state.endTime.value = DateTool().getYMDHNDateString(p, 4);
}); });
}), }),
@ -278,20 +276,20 @@ class _PasswordKeyPerpetualPageState extends State<PasswordKeyPerpetualPage>
// //
Widget keyCustomTimeLimitWidget() { Widget keyCustomTimeLimitWidget() {
return Column( return Column(
children: [ children: <Widget>[
CommonItem( CommonItem(
leftTitel: TranslationLoader.lanKeys!.effectiveTime!.tr, leftTitel: TranslationLoader.lanKeys!.effectiveTime!.tr,
rightTitle: state.customBeginTime.value, rightTitle: state.customBeginTime.value,
isHaveLine: true, isHaveLine: true,
isHaveDirection: true, isHaveDirection: true,
action: () { action: () {
PDuration selectDate = PDuration.parse( final PDuration selectDate = PDuration.parse(
DateTime.tryParse(state.customBeginTime.value)); DateTime.tryParse(state.customBeginTime.value));
Pickers.showDatePicker(context, Pickers.showDatePicker(context,
selectDate: selectDate, selectDate: selectDate,
// maxDate: PDuration(year: DateTime.now().year + 3, month: DateTime.now().month, day: DateTime.now().day, hour: 24), // maxDate: PDuration(year: DateTime.now().year + 3, month: DateTime.now().month, day: DateTime.now().day, hour: 24),
// minDate: PDuration.now(), // minDate: PDuration.now(),
mode: DateMode.YMDHM, onConfirm: (p) { mode: DateMode.YMDHM, onConfirm: (PDuration p) {
state.customBeginTime.value = state.customBeginTime.value =
DateTool().getYMDHNDateString(p, 1); DateTool().getYMDHNDateString(p, 1);
}); });
@ -301,14 +299,14 @@ class _PasswordKeyPerpetualPageState extends State<PasswordKeyPerpetualPage>
rightTitle: state.customEndTime.value, rightTitle: state.customEndTime.value,
isHaveDirection: true, isHaveDirection: true,
action: () { action: () {
PDuration selectDate = final PDuration selectDate =
PDuration.parse(DateTime.tryParse(state.customEndTime.value)); PDuration.parse(DateTime.tryParse(state.customEndTime.value));
Pickers.showDatePicker(context, Pickers.showDatePicker(context,
selectDate: selectDate, selectDate: selectDate,
// maxDate传入三年以后得今天的时间 // maxDate传入三年以后得今天的时间
// maxDate: PDuration(year: DateTime.now().year + 3, month: DateTime.now().month, day: DateTime.now().day), // maxDate: PDuration(year: DateTime.now().year + 3, month: DateTime.now().month, day: DateTime.now().day),
// minDate: PDuration(year: DateTime.now().year, month: DateTime.now().month, day: DateTime.now().day), // minDate: PDuration(year: DateTime.now().year, month: DateTime.now().month, day: DateTime.now().day),
mode: DateMode.YMDHM, onConfirm: (p) { mode: DateMode.YMDHM, onConfirm: (PDuration p) {
state.customEndTime.value = DateTool().getYMDHNDateString(p, 1); state.customEndTime.value = DateTool().getYMDHNDateString(p, 1);
}); });
}), }),
@ -320,15 +318,13 @@ class _PasswordKeyPerpetualPageState extends State<PasswordKeyPerpetualPage>
// //
Widget keyIfPerpetualWidget() { Widget keyIfPerpetualWidget() {
return Column( return Column(
children: [ children: <Widget>[
CommonItem( CommonItem(
leftTitel: TranslationLoader.lanKeys!.permanent!.tr, leftTitel: TranslationLoader.lanKeys!.permanent!.tr,
rightTitle: "", rightTitle: '',
isHaveRightWidget: true, isHaveRightWidget: true,
rightWidget: SizedBox(width: 60.w, height: 50.h, child: _switch())), rightWidget: SizedBox(width: 60.w, height: 50.h, child: _switch())),
state.isPermanent.value == true if (state.isPermanent.value == true) Container(height: 10.h) else Container(height: 1.h),
? Container(height: 10.h)
: Container(height: 1.h),
], ],
); );
} }
@ -339,11 +335,11 @@ class _PasswordKeyPerpetualPageState extends State<PasswordKeyPerpetualPage>
visible: visible:
CommonDataManage().currentKeyInfo.isLockOwner == 1 ? true : false, CommonDataManage().currentKeyInfo.isLockOwner == 1 ? true : false,
child: Column( child: Column(
children: [ children: <Widget>[
// SizedBox(height: 10.h), // SizedBox(height: 10.h),
Obx(() => CommonItem( Obx(() => CommonItem(
leftTitel: "是否为管理员".tr, leftTitel: '是否为管理员'.tr,
rightTitle: "", rightTitle: '',
isTipsImg: false, isTipsImg: false,
isHaveRightWidget: true, isHaveRightWidget: true,
rightWidget: SizedBox( rightWidget: SizedBox(
@ -357,14 +353,14 @@ class _PasswordKeyPerpetualPageState extends State<PasswordKeyPerpetualPage>
// //
Widget keyCirculationWidget() { Widget keyCirculationWidget() {
return Column( return Column(
children: [ children: <Widget>[
CommonItem( CommonItem(
leftTitel: "有效日", leftTitel: '有效日',
rightTitle: state.loopModeStr.value, rightTitle: state.loopModeStr.value,
isHaveLine: true, isHaveLine: true,
isHaveDirection: true, isHaveDirection: true,
action: () { action: () {
List<String> pickerDataList = [ final List<String> pickerDataList = <String>[
'周末', '周末',
'每日', '每日',
'工作日', '工作日',
@ -393,11 +389,11 @@ class _PasswordKeyPerpetualPageState extends State<PasswordKeyPerpetualPage>
isHaveLine: true, isHaveLine: true,
isHaveDirection: true, isHaveDirection: true,
action: () { action: () {
PDuration selectDate = final PDuration selectDate =
PDuration.parse(DateTime.tryParse(state.endTime.value)); PDuration.parse(DateTime.tryParse(state.endTime.value));
Pickers.showDatePicker(context, Pickers.showDatePicker(context,
selectDate: selectDate, selectDate: selectDate,
mode: DateMode.YMDH, onConfirm: (p) { mode: DateMode.YMDH, onConfirm: (PDuration p) {
state.endTime.value = DateTool().getYMDHNDateString(p, 4); state.endTime.value = DateTool().getYMDHNDateString(p, 4);
}); });
}), }),
@ -408,10 +404,10 @@ class _PasswordKeyPerpetualPageState extends State<PasswordKeyPerpetualPage>
isHaveLine: true, isHaveLine: true,
isHaveDirection: true, isHaveDirection: true,
action: () { action: () {
PDuration selectDate = PDuration.parse( final PDuration selectDate = PDuration.parse(
DateTool().dateToDateTime(state.loopEffectiveDate.value, 0)); DateTool().dateToDateTime(state.loopEffectiveDate.value, 0));
Pickers.showDatePicker(context, Pickers.showDatePicker(context,
selectDate: selectDate, mode: DateMode.H, onConfirm: (p) { selectDate: selectDate, mode: DateMode.H, onConfirm: (PDuration p) {
state.loopEffectiveDate.value = state.loopEffectiveDate.value =
DateTool().getYMDHNDateString(p, 5); DateTool().getYMDHNDateString(p, 5);
state.loopStartHours.value = p.hour!; state.loopStartHours.value = p.hour!;
@ -422,10 +418,10 @@ class _PasswordKeyPerpetualPageState extends State<PasswordKeyPerpetualPage>
rightTitle: state.loopFailureDate.value, rightTitle: state.loopFailureDate.value,
isHaveDirection: true, isHaveDirection: true,
action: () { action: () {
PDuration selectDate = PDuration.parse( final PDuration selectDate = PDuration.parse(
DateTool().dateToDateTime(state.loopFailureDate.value, 0)); DateTool().dateToDateTime(state.loopFailureDate.value, 0));
Pickers.showDatePicker(context, Pickers.showDatePicker(context,
selectDate: selectDate, mode: DateMode.H, onConfirm: (p) { selectDate: selectDate, mode: DateMode.H, onConfirm: (PDuration p) {
state.loopFailureDate.value = state.loopFailureDate.value =
DateTool().getYMDHNDateString(p, 5); DateTool().getYMDHNDateString(p, 5);
state.loopEndHours.value = p.hour!; state.loopEndHours.value = p.hour!;
@ -445,19 +441,19 @@ class _PasswordKeyPerpetualPageState extends State<PasswordKeyPerpetualPage>
showPickerView(BuildContext context, List dataList) { showPickerView(BuildContext context, List dataList) {
Pickers.showSinglePicker(context, Pickers.showSinglePicker(context,
data: dataList, data: dataList,
pickerStyle: DefaultPickerStyle(), onConfirm: (p, position) { pickerStyle: DefaultPickerStyle(), onConfirm: (p, int position) {
state.loopModeStr.value = p; state.loopModeStr.value = p;
}, onChanged: (p, position) {}); }, onChanged: (p, int position) {});
} }
Widget keyBottomWidget(String tipStr) { Widget keyBottomWidget(String tipStr) {
return Column( return Column(
children: [ children: <Widget>[
Container( Container(
padding: EdgeInsets.all(20.w), padding: EdgeInsets.all(20.w),
child: Row( child: Row(
// crossAxisAlignment: CrossAxisAlignment.start, // crossAxisAlignment: CrossAxisAlignment.start,
children: [ children: <Widget>[
Expanded( Expanded(
child: Text( child: Text(
tipStr, tipStr,
@ -472,10 +468,10 @@ class _PasswordKeyPerpetualPageState extends State<PasswordKeyPerpetualPage>
), ),
SubmitBtn( SubmitBtn(
btnName: state.widgetType.value == 3 btnName: state.widgetType.value == 3
? "设置密码" ? '设置密码'
: TranslationLoader.lanKeys!.getPassword!.tr, : TranslationLoader.lanKeys!.getPassword!.tr,
onClick: () async { onClick: () async {
var isDemoMode = await Storage.getBool(ifIsDemoModeOrNot); final bool? isDemoMode = await Storage.getBool(ifIsDemoModeOrNot);
if (isDemoMode == false) { if (isDemoMode == false) {
// //
if (state.widgetType.value == 3) { if (state.widgetType.value == 3) {
@ -484,7 +480,7 @@ class _PasswordKeyPerpetualPageState extends State<PasswordKeyPerpetualPage>
logic.getKeyboardPwdRequest(); logic.getKeyboardPwdRequest();
} }
} else { } else {
logic.showToast("演示模式"); logic.showToast('演示模式');
} }
}), }),
], ],
@ -494,13 +490,13 @@ class _PasswordKeyPerpetualPageState extends State<PasswordKeyPerpetualPage>
// //
Widget sendElectronicKeySucceed() { Widget sendElectronicKeySucceed() {
return Column( return Column(
children: [ children: <Widget>[
Container( Container(
height: 270.h, height: 270.h,
width: 1.sw, width: 1.sw,
color: Colors.white, color: Colors.white,
child: Column( child: Column(
children: [ children: <Widget>[
SizedBox( SizedBox(
height: 30.h, height: 30.h,
), ),
@ -513,7 +509,7 @@ class _PasswordKeyPerpetualPageState extends State<PasswordKeyPerpetualPage>
height: 20.h, height: 20.h,
), ),
Text( Text(
"操作成功,密码为", '操作成功,密码为',
style: TextStyle(fontSize: 22.sp, color: Colors.black), style: TextStyle(fontSize: 22.sp, color: Colors.black),
), ),
SizedBox( SizedBox(
@ -536,8 +532,8 @@ class _PasswordKeyPerpetualPageState extends State<PasswordKeyPerpetualPage>
btnName: '完成'.tr, btnName: '完成'.tr,
onClick: () { onClick: () {
state.isSendSuccess.value = false; state.isSendSuccess.value = false;
state.nameController.text = ""; state.nameController.text = '';
state.pwdController.text = ""; state.pwdController.text = '';
// Navigator.pop(context, true); // Navigator.pop(context, true);
}), }),
SizedBox( SizedBox(
@ -566,7 +562,7 @@ class _PasswordKeyPerpetualPageState extends State<PasswordKeyPerpetualPage>
height: 65.h, height: 65.h,
width: 300.w, width: 300.w,
child: Row( child: Row(
children: [ children: <Widget>[
Expanded( Expanded(
child: TextField( child: TextField(
// //
@ -630,7 +626,7 @@ class _PasswordKeyPerpetualPageState extends State<PasswordKeyPerpetualPage>
trackColor: CupertinoColors.systemGrey5, trackColor: CupertinoColors.systemGrey5,
thumbColor: CupertinoColors.white, thumbColor: CupertinoColors.white,
value: state.isPermanent.value, value: state.isPermanent.value,
onChanged: (value) { onChanged: (bool value) {
state.isPermanent.value = value; state.isPermanent.value = value;
}, },
); );
@ -643,15 +639,15 @@ class _PasswordKeyPerpetualPageState extends State<PasswordKeyPerpetualPage>
trackColor: CupertinoColors.systemGrey5, trackColor: CupertinoColors.systemGrey5,
thumbColor: CupertinoColors.white, thumbColor: CupertinoColors.white,
value: state.isAdministrator.value, value: state.isAdministrator.value,
onChanged: (value) { onChanged: (bool value) {
state.isAdministrator.value = value; state.isAdministrator.value = value;
AppLog.log("isAdministrator:${state.isAdministrator.value}"); AppLog.log('isAdministrator:${state.isAdministrator.value}');
}, },
); );
} }
String intToStr(int v) { String intToStr(int v) {
return (v < 10) ? "0$v" : "$v"; return (v < 10) ? '0$v' : '$v';
} }
Future _openModalBottomSheet() async { Future _openModalBottomSheet() async {
@ -662,7 +658,7 @@ class _PasswordKeyPerpetualPageState extends State<PasswordKeyPerpetualPage>
constraints: BoxConstraints(maxHeight: 270.h), constraints: BoxConstraints(maxHeight: 270.h),
builder: (BuildContext context) { builder: (BuildContext context) {
return Column( return Column(
children: [ children: <Widget>[
SizedBox( SizedBox(
width: ScreenUtil().screenWidth, width: ScreenUtil().screenWidth,
height: 180.h, height: 180.h,
@ -695,7 +691,7 @@ class _PasswordKeyPerpetualPageState extends State<PasswordKeyPerpetualPage>
TabBar _tabBar() { TabBar _tabBar() {
return TabBar( return TabBar(
controller: state.tabController, controller: state.tabController,
onTap: (index) { onTap: (int index) {
FocusScope.of(context).requestFocus(FocusNode()); FocusScope.of(context).requestFocus(FocusNode());
}, },
tabs: _itemTabs.map((ItemView item) => _tab(item)).toList(), tabs: _itemTabs.map((ItemView item) => _tab(item)).toList(),
@ -746,16 +742,16 @@ class _PasswordKeyPerpetualPageState extends State<PasswordKeyPerpetualPage>
} }
final List<ItemView> _itemTabs = <ItemView>[ final List<ItemView> _itemTabs = <ItemView>[
ItemView(title: TranslationLoader.lanKeys!.permanent!.tr, type: "0"), ItemView(title: TranslationLoader.lanKeys!.permanent!.tr, type: '0'),
ItemView(title: TranslationLoader.lanKeys!.timeLimit!.tr, type: "1"), ItemView(title: TranslationLoader.lanKeys!.timeLimit!.tr, type: '1'),
ItemView(title: TranslationLoader.lanKeys!.once!.tr, type: "2"), ItemView(title: TranslationLoader.lanKeys!.once!.tr, type: '2'),
ItemView(title: TranslationLoader.lanKeys!.custom!.tr, type: "3"), ItemView(title: TranslationLoader.lanKeys!.custom!.tr, type: '3'),
ItemView(title: TranslationLoader.lanKeys!.circulation!.tr, type: "4"), ItemView(title: TranslationLoader.lanKeys!.circulation!.tr, type: '4'),
ItemView(title: TranslationLoader.lanKeys!.clearAll!.tr, type: "5"), ItemView(title: TranslationLoader.lanKeys!.clearAll!.tr, type: '5'),
]; ];
List<Widget> initBottomSheetList() { List<Widget> initBottomSheetList() {
List<Widget> widgetList = []; final List<Widget> widgetList = <Widget>[];
widgetList.add(buildCenter3('images/icon_wechat.png', '微信好友'.tr, 0)); widgetList.add(buildCenter3('images/icon_wechat.png', '微信好友'.tr, 0));
widgetList.add(buildCenter3('images/icon_message.png', '短信'.tr, 1)); widgetList.add(buildCenter3('images/icon_message.png', '短信'.tr, 1));
@ -775,7 +771,7 @@ class _PasswordKeyPerpetualPageState extends State<PasswordKeyPerpetualPage>
EdgeInsets.only(top: 20.w, bottom: 20.w, left: 10.w, right: 10.w), EdgeInsets.only(top: 20.w, bottom: 20.w, left: 10.w, right: 10.w),
child: Column( child: Column(
mainAxisAlignment: MainAxisAlignment.center, mainAxisAlignment: MainAxisAlignment.center,
children: [ children: <Widget>[
Image.asset( Image.asset(
imageName, imageName,
width: 50.w, width: 50.w,
@ -799,7 +795,7 @@ class _PasswordKeyPerpetualPageState extends State<PasswordKeyPerpetualPage>
//\n生效时间${itemData.startDate}\n类型\n锁名${itemData.keyboardPwdName} //\n生效时间${itemData.startDate}\n类型\n锁名${itemData.keyboardPwdName}
_jumpSmartDeviceRoute(int itemIndex) { _jumpSmartDeviceRoute(int itemIndex) {
Get.back(); Get.back();
String pwdShareStr = logic.getShareContentStr(); final String pwdShareStr = logic.getShareContentStr();
switch (itemIndex) { switch (itemIndex) {
case 0: case 0:
// //

View File

@ -4,42 +4,42 @@ import 'package:star_lock/main/lockMian/entity/lockListInfo_entity.dart';
import 'package:star_lock/tools/dateTool.dart'; import 'package:star_lock/tools/dateTool.dart';
class PasswordKeyPerpetualState { class PasswordKeyPerpetualState {
PasswordKeyPerpetualState() {
Map map = Get.arguments;
if (map['keyInfo'] != null) {
keyInfo.value = map['keyInfo'];
}
}
final TextEditingController nameController = TextEditingController(); final TextEditingController nameController = TextEditingController();
final TextEditingController pwdController = TextEditingController(); final TextEditingController pwdController = TextEditingController();
// final isInitialized = false.obs; // final isInitialized = false.obs;
final isSendSuccess = false.obs; // final RxBool isSendSuccess = false.obs; //
final isPermanent = true.obs; // final RxBool isPermanent = true.obs; //
var getPwdStr = ''.obs; RxString getPwdStr = ''.obs;
var pwdNameStr = ''; String pwdNameStr = '';
final isAdministrator = false.obs; // final RxBool isAdministrator = false.obs; //
var beginTime = DateTool().getNowDateWithType(3).obs; // RxString beginTime = DateTool().getNowDateWithType(3).obs; //
var endTime = DateTool().getNowDateWithType(3).obs; // RxString endTime = DateTool().getNowDateWithType(3).obs; //
var loopEffectiveDate = DateTool().getNowDateWithType(7).obs; // RxString loopEffectiveDate = DateTool().getNowDateWithType(7).obs; //
var loopFailureDate = DateTool().getNowDateWithType(7).obs; // RxString loopFailureDate = DateTool().getNowDateWithType(7).obs; //
var loopStartHours = DateTime.now().hour.obs; RxInt loopStartHours = DateTime.now().hour.obs;
var loopEndHours = DateTime.now().hour.obs; RxInt loopEndHours = DateTime.now().hour.obs;
var loopModeStr = '周末'.obs; // RxString loopModeStr = '周末'.obs; //
var customBeginTime = DateTool().getNowDateWithType(2).obs; // RxString customBeginTime = DateTool().getNowDateWithType(2).obs; //
var customEndTime = DateTool().getNowDateWithType(2).obs; // RxString customEndTime = DateTool().getNowDateWithType(2).obs; //
final widgetType = 0.obs; final RxInt widgetType = 0.obs;
final sendSucceedType = 0.obs; final RxInt sendSucceedType = 0.obs;
final keyInfo = LockListInfoItemEntity().obs; final Rx<LockListInfoItemEntity> keyInfo = LockListInfoItemEntity().obs;
var ifCurrentScreen = true.obs; // , RxBool ifCurrentScreen = true.obs; // ,
var sureBtnState = 0.obs; // 0() 1() RxInt sureBtnState = 0.obs; // 0() 1()
var pwdNumber = 0.obs; // RxInt pwdNumber = 0.obs; //
late TabController tabController; late TabController tabController;
PasswordKeyPerpetualState() {
Map map = Get.arguments;
if (map["keyInfo"] != null) {
keyInfo.value = map["keyInfo"];
}
}
} }

View File

@ -222,7 +222,7 @@ class _ExpireFacePageState extends State<ExpireFacePage> {
); );
} else { } else {
return Container( return Container(
padding: EdgeInsets.only(left: 5.w, right: 5.w), padding: EdgeInsets.only(left: 5.w, right: 5.w, bottom: 2.h),
decoration: BoxDecoration( decoration: BoxDecoration(
color: Colors.red, color: Colors.red,
borderRadius: BorderRadius.circular(2.0), borderRadius: BorderRadius.circular(2.0),

View File

@ -4,6 +4,7 @@ import 'dart:async';
import 'package:flutter_blue_plus/flutter_blue_plus.dart'; import 'package:flutter_blue_plus/flutter_blue_plus.dart';
import 'package:star_lock/blue/io_tool/io_tool.dart'; import 'package:star_lock/blue/io_tool/io_tool.dart';
import 'package:star_lock/blue/io_type.dart'; import 'package:star_lock/blue/io_type.dart';
import 'package:star_lock/login/login/entity/LoginEntity.dart';
import 'package:star_lock/tools/baseGetXController.dart'; import 'package:star_lock/tools/baseGetXController.dart';
import 'package:star_lock/tools/dateTool.dart'; import 'package:star_lock/tools/dateTool.dart';
@ -24,7 +25,7 @@ class ExpireFingerprintLogic extends BaseGetXController {
// //
late StreamSubscription<Reply> _replySubscription; late StreamSubscription<Reply> _replySubscription;
void _initReplySubscription() { void _initReplySubscription() {
_replySubscription = EventBusManager().eventBus!.on<Reply>().listen((reply) { _replySubscription = EventBusManager().eventBus!.on<Reply>().listen((Reply reply) {
// () // ()
if((reply is SenderAddFingerprintWithTimeCycleCoercionReply) && (state.ifCurrentScreen.value == true)) { if((reply is SenderAddFingerprintWithTimeCycleCoercionReply) && (state.ifCurrentScreen.value == true)) {
_replyAddFingerprintBegin(reply); _replyAddFingerprintBegin(reply);
@ -34,7 +35,7 @@ class ExpireFingerprintLogic extends BaseGetXController {
// //
Future<void> _replyAddFingerprintBegin(Reply reply) async { Future<void> _replyAddFingerprintBegin(Reply reply) async {
int status = reply.data[2]; final int status = reply.data[2];
switch(status){ switch(status){
case 0x00: case 0x00:
@ -46,17 +47,17 @@ class ExpireFingerprintLogic extends BaseGetXController {
break; break;
case 0x06: case 0x06:
// //
var privateKey = await Storage.getStringList(saveBluePrivateKey); final List<String>? privateKey = await Storage.getStringList(saveBluePrivateKey);
List<int> getPrivateKeyList = changeStringListToIntList(privateKey!); final List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
var signKey = await Storage.getStringList(saveBlueSignKey); final List<String>? signKey = await Storage.getStringList(saveBlueSignKey);
List<int> signKeyDataList = changeStringListToIntList(signKey!); final List<int> signKeyDataList = changeStringListToIntList(signKey!);
var publicKey = await Storage.getStringList(saveBluePublicKey); final List<String>? publicKey = await Storage.getStringList(saveBluePublicKey);
List<int> publicKeyDataList = changeStringListToIntList(publicKey!); final List<int> publicKeyDataList = changeStringListToIntList(publicKey!);
var token = await Storage.getStringList(saveBlueToken); final List<String>? token = await Storage.getStringList(saveBlueToken);
List<int> getTokenList = changeStringListToIntList(token!); final List<int> getTokenList = changeStringListToIntList(token!);
IoSenderManage.senderAddFingerprintWithTimeCycleCoercionCommand( IoSenderManage.senderAddFingerprintWithTimeCycleCoercionCommand(
keyID:state.deletExpireFingerprintItemEntity.fingerprintId.toString(), keyID:state.deletExpireFingerprintItemEntity.fingerprintId.toString(),
@ -100,14 +101,14 @@ class ExpireFingerprintLogic extends BaseGetXController {
// var publicKey = await Storage.getStringList(saveBluePublicKey); // var publicKey = await Storage.getStringList(saveBluePublicKey);
// List<int> publicKeyDataList = changeStringListToIntList(publicKey!); // List<int> publicKeyDataList = changeStringListToIntList(publicKey!);
var signKey = await Storage.getStringList(saveBlueSignKey); final List<String>? signKey = await Storage.getStringList(saveBlueSignKey);
List<int> signKeyDataList = changeStringListToIntList(signKey!); final List<int> signKeyDataList = changeStringListToIntList(signKey!);
var privateKey = await Storage.getStringList(saveBluePrivateKey); final List<String>? privateKey = await Storage.getStringList(saveBluePrivateKey);
List<int> getPrivateKeyList = changeStringListToIntList(privateKey!); final List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
var token = await Storage.getStringList(saveBlueToken); final List<String>? token = await Storage.getStringList(saveBlueToken);
List<int> getTokenList = changeStringListToIntList(token!); final List<int> getTokenList = changeStringListToIntList(token!);
IoSenderManage.senderAddFingerprintWithTimeCycleCoercionCommand( IoSenderManage.senderAddFingerprintWithTimeCycleCoercionCommand(
keyID:state.deletExpireFingerprintItemEntity.fingerprintId.toString(), keyID:state.deletExpireFingerprintItemEntity.fingerprintId.toString(),
@ -154,7 +155,7 @@ class ExpireFingerprintLogic extends BaseGetXController {
// //
void deletFingerprintsData() async{ void deletFingerprintsData() async{
var entity = await ApiRepository.to.deletFingerprintsData( final LoginEntity entity = await ApiRepository.to.deletFingerprintsData(
fingerprintId: state.deletExpireFingerprintItemEntity.fingerprintId.toString(), fingerprintId: state.deletExpireFingerprintItemEntity.fingerprintId.toString(),
lockId: state.deletExpireFingerprintItemEntity.lockId.toString(), lockId: state.deletExpireFingerprintItemEntity.lockId.toString(),
type: "0", type: "0",
@ -172,7 +173,7 @@ class ExpireFingerprintLogic extends BaseGetXController {
// //
Future<ExpireFingerprintEntity> expirFingerprintListRequest() async { Future<ExpireFingerprintEntity> expirFingerprintListRequest() async {
ExpireFingerprintEntity entity = await ApiRepository.to.expireFingerprintList(pageNo.toString(), pageSize.toString()); final ExpireFingerprintEntity entity = await ApiRepository.to.expireFingerprintList(pageNo.toString(), pageSize.toString());
if(entity.errorCode!.codeIsSuccessful){ if(entity.errorCode!.codeIsSuccessful){
if (pageNo == 1) { if (pageNo == 1) {
state.dataList.value = entity.data!.list!; state.dataList.value = entity.data!.list!;

View File

@ -226,7 +226,7 @@ class _ExpireFingerprintPageState extends State<ExpireFingerprintPage> {
); );
} else { } else {
return Container( return Container(
padding: EdgeInsets.only(left: 5.w, right: 5.w), padding: EdgeInsets.only(left: 5.w, right: 5.w, bottom: 2.h),
decoration: BoxDecoration( decoration: BoxDecoration(
color: Colors.red, color: Colors.red,
borderRadius: BorderRadius.circular(2.0), borderRadius: BorderRadius.circular(2.0),

View File

@ -39,7 +39,7 @@ class _ExpireLockManageTabbarState extends State<ExpireLockManageTabbar> with Si
_tabController = TabController( _tabController = TabController(
vsync: this, vsync: this,
length: _itemTabs.length, length: _itemTabs.length,
initialIndex: 1); initialIndex: 0);
_tabController.addListener(() { _tabController.addListener(() {
if (_tabController.animation!.value == _tabController.index) { if (_tabController.animation!.value == _tabController.index) {
FocusScope.of(context).requestFocus(FocusNode()); FocusScope.of(context).requestFocus(FocusNode());

View File

@ -117,20 +117,20 @@ class _ExpirePasswordPageState extends State<ExpirePasswordPage> {
// getHttpData(); // getHttpData();
// } // }
// } else { // } else {
// var backData = await Get.toNamed( var backData = await Get.toNamed(
// Routers.passwordKeyDetailChangeDatePage, Routers.passwordKeyDetailChangeDatePage,
// arguments: { arguments: {
// 'itemData': itemData, 'itemData': itemData,
// }); });
// if (backData != null) { if (backData != null) {
// itemData.startDate = itemData.startDate =
// int.parse(backData["beginTimeTimestamp"]) * 1000; int.parse(backData["beginTimeTimestamp"]) * 1000;
// itemData.endDate = int.parse(backData["endTimeTimestamp"]) * 1000; itemData.endDate = int.parse(backData["endTimeTimestamp"]) * 1000;
// // //
// itemData.keyboardPwdType = 3; itemData.keyboardPwdType = 3;
// setState(() {}); setState(() {});
// } }
// } // }
}, },
child: Container( child: Container(
@ -219,7 +219,7 @@ class _ExpirePasswordPageState extends State<ExpirePasswordPage> {
Visibility( Visibility(
visible: itemData.keyboardPwdStatus! == 2 ? true : false, visible: itemData.keyboardPwdStatus! == 2 ? true : false,
child: Container( child: Container(
padding: EdgeInsets.only(left: 5.w, right: 5.w), padding: EdgeInsets.only(left: 5.w, right: 5.w, bottom: 2.h),
decoration: BoxDecoration( decoration: BoxDecoration(
color: Colors.red, color: Colors.red,
borderRadius: BorderRadius.circular(2.0), borderRadius: BorderRadius.circular(2.0),

View File

@ -6,21 +6,21 @@ import 'pickers/time_picker/model/pduration.dart';
class DateTool { class DateTool {
/// ///
String getNowDateWithType(int type) { String getNowDateWithType(int type) {
var dateStr = ''; String dateStr = '';
// //
DateTime now = DateTime.now(); final DateTime now = DateTime.now();
// //
int year = now.year; final int year = now.year;
// //
int month = now.month; final int month = now.month;
// //
int day = now.day; final int day = now.day;
// //
int hour = now.hour; final int hour = now.hour;
// //
int minute = now.minute; final int minute = now.minute;
// //
int millisecond = now.millisecond; final int millisecond = now.millisecond;
switch (type) { switch (type) {
case 1: case 1:
@ -76,13 +76,13 @@ class DateTool {
/// PDuration及时间类型获取时间字符串 /// PDuration及时间类型获取时间字符串
/// type 1: (2023-01-01 12:00) 2: (2023-01-01) 3: (12:00) /// type 1: (2023-01-01 12:00) 2: (2023-01-01) 3: (12:00)
String getYMDHNDateString(PDuration p, int type) { String getYMDHNDateString(PDuration p, int type) {
var year = p.year == 0 ? DateTime.now().year : p.year; final int? year = p.year == 0 ? DateTime.now().year : p.year;
var month = p.month == 0 ? DateTime.now().month : p.month; final int? month = p.month == 0 ? DateTime.now().month : p.month;
var day = p.day == 0 ? DateTime.now().day : p.day; final int? day = p.day == 0 ? DateTime.now().day : p.day;
var hour = p.hour == 0 ? DateTime.now().hour : p.hour; final int? hour = p.hour;
var minute = p.minute; final int? minute = p.minute;
var dateStr = ''; String dateStr = '';
switch (type) { switch (type) {
case 1: case 1:
// (2023-01-01 12:48) // (2023-01-01 12:48)
@ -121,16 +121,16 @@ class DateTool {
int dateToTimestamp(String dateStr, int type) { int dateToTimestamp(String dateStr, int type) {
int timestamp = 0; int timestamp = 0;
if (type == 0) { if (type == 0) {
List<String> timeParts = dateStr.split(":"); final List<String> timeParts = dateStr.split(':');
if (timeParts.length < 2) { if (timeParts.length < 2) {
return 0; return 0;
} }
DateTime now = DateTime.now(); final DateTime now = DateTime.now();
DateTime dateTime = DateTime(now.year, now.month, now.day, final DateTime dateTime = DateTime(now.year, now.month, now.day,
int.parse(timeParts[0]), int.parse(timeParts[1])); int.parse(timeParts[0]), int.parse(timeParts[1]));
timestamp = dateTime.millisecondsSinceEpoch; timestamp = dateTime.millisecondsSinceEpoch;
} else { } else {
DateTime dateTime = DateTime.parse(dateStr); final DateTime dateTime = DateTime.parse(dateStr);
timestamp = dateTime.millisecondsSinceEpoch; timestamp = dateTime.millisecondsSinceEpoch;
} }
return timestamp; return timestamp;
@ -139,7 +139,7 @@ class DateTool {
/// ///
/// type 0: 12:00 1: /// type 0: 12:00 1:
DateTime? dateToDateTime(String dateStr, int type) { DateTime? dateToDateTime(String dateStr, int type) {
int timestamp = dateToTimestamp(dateStr, type); final int timestamp = dateToTimestamp(dateStr, type);
if (timestamp == 0) { if (timestamp == 0) {
return null; return null;
} else { } else {
@ -154,9 +154,9 @@ class DateTool {
if (timestamp.length == 10) { if (timestamp.length == 10) {
time = time * 1000; time = time * 1000;
} }
DateTime nowDate = DateTime.fromMillisecondsSinceEpoch(time); final DateTime nowDate = DateTime.fromMillisecondsSinceEpoch(time);
String appointmentDate = final String appointmentDate =
formatDate(nowDate, [yyyy, '-', mm, '-', dd, ' ', HH, ':', nn]); formatDate(nowDate, <String>[yyyy, '-', mm, '-', dd, ' ', HH, ':', nn]);
return appointmentDate; return appointmentDate;
} }
@ -166,33 +166,33 @@ class DateTool {
if (time.toString().length == 10) { if (time.toString().length == 10) {
time = time * 1000; time = time * 1000;
} }
DateTime nowDate = DateTime.fromMillisecondsSinceEpoch(time); final DateTime nowDate = DateTime.fromMillisecondsSinceEpoch(time);
String appointmentDate = final String appointmentDate =
formatDate(nowDate, [yyyy, '-', mm, '-', dd, ' ', HH, ':', nn]); formatDate(nowDate, <String>[yyyy, '-', mm, '-', dd, ' ', HH, ':', nn]);
return appointmentDate; return appointmentDate;
} }
/// (--) /// (--)
String dateToYMDString(String timestamp) { String dateToYMDString(String timestamp) {
int time = int.parse(timestamp); final int time = int.parse(timestamp);
DateTime nowDate = DateTime.fromMillisecondsSinceEpoch(time); final DateTime nowDate = DateTime.fromMillisecondsSinceEpoch(time);
String appointmentDate = formatDate(nowDate, [yyyy, '-', mm, '-', dd]); final String appointmentDate = formatDate(nowDate, <String>[yyyy, '-', mm, '-', dd]);
return appointmentDate; return appointmentDate;
} }
/// (:) /// (:)
String dateToHNString(String timestamp) { String dateToHNString(String timestamp) {
int time = int.parse(timestamp); final int time = int.parse(timestamp);
DateTime nowDate = DateTime.fromMillisecondsSinceEpoch(time); final DateTime nowDate = DateTime.fromMillisecondsSinceEpoch(time);
String appointmentDate = formatDate(nowDate, [HH, ':', nn]); final String appointmentDate = formatDate(nowDate, <String>[HH, ':', nn]);
return appointmentDate; return appointmentDate;
} }
/// ///
bool compareTimeIsOvertime(int endTiem) { bool compareTimeIsOvertime(int endTiem) {
DateTime dateTime = final DateTime dateTime =
DateTime.fromMillisecondsSinceEpoch(endTiem); // DateTime DateTime.fromMillisecondsSinceEpoch(endTiem); // DateTime
DateTime now = DateTime.now(); // final DateTime now = DateTime.now(); //
if (now.isAfter(dateTime)) { if (now.isAfter(dateTime)) {
// //
return true; return true;
@ -203,25 +203,25 @@ class DateTool {
/// 1705132260000 /// 1705132260000
int compareTimeGetDaysFromNow(int endTiem) { int compareTimeGetDaysFromNow(int endTiem) {
DateTime dateTime = final DateTime dateTime =
DateTime.fromMillisecondsSinceEpoch(endTiem); // DateTime DateTime.fromMillisecondsSinceEpoch(endTiem); // DateTime
DateTime now = DateTime.now(); // final DateTime now = DateTime.now(); //
Duration difference = dateTime.difference(now); // final Duration difference = dateTime.difference(now); //
int days = difference.inDays; // final int days = difference.inDays; //
return days; return days;
} }
// (Bit0 -- 6 -- ) // (Bit0 -- 6 -- )
int accordingTheCycleIntoTheCorrespondingNumber(List weekDay) { int accordingTheCycleIntoTheCorrespondingNumber(List weekDay) {
var weekStr = "00000000"; String weekStr = '00000000';
for (var day in weekDay) { for (var day in weekDay) {
int index = day % 7; // 0 final int index = day % 7; // 0
weekStr = weekStr =
'${weekStr.substring(0, index)}1${weekStr.substring(index + 1)}'; '${weekStr.substring(0, index)}1${weekStr.substring(index + 1)}';
} }
// weekStr // weekStr
weekStr = weekStr.split('').reversed.join(''); weekStr = weekStr.split('').reversed.join('');
int weekRound = int.parse(weekStr, radix: 2); final int weekRound = int.parse(weekStr, radix: 2);
return weekRound; return weekRound;
} }
} }