Merge branch 'master' of gitee.com:starlock-cn/app-starlock
This commit is contained in:
commit
1c77010803
@ -102,12 +102,12 @@ class SenderAddStressFingerprintCommand extends SenderProtocol {
|
||||
} else {
|
||||
List<int> authCodeData = [];
|
||||
|
||||
//authUserID
|
||||
authCodeData.addAll(utf8.encode(userID!));
|
||||
|
||||
//KeyID
|
||||
authCodeData.addAll(utf8.encode(keyID!));
|
||||
|
||||
//authUserID
|
||||
authCodeData.addAll(utf8.encode(userID!));
|
||||
|
||||
//token 4 首次请求 Token 填 0,如果锁需要鉴权操作者身份,则会分配动态口令并在应答消息中返回,二次请求时带上。
|
||||
authCodeData.addAll(token!);
|
||||
|
||||
|
||||
@ -26,6 +26,7 @@ class SenderAddStressICCardCommand extends SenderProtocol {
|
||||
int? needAuthor;
|
||||
List<int>? publicKey;
|
||||
List<int>? privateKey;
|
||||
List<int>? signKey;
|
||||
|
||||
SenderAddStressICCardCommand({
|
||||
this.keyID,
|
||||
@ -39,6 +40,7 @@ class SenderAddStressICCardCommand extends SenderProtocol {
|
||||
this.needAuthor,
|
||||
this.publicKey,
|
||||
this.privateKey,
|
||||
this.signKey
|
||||
}) : super(CommandType.generalExtendedCommond);
|
||||
|
||||
@override
|
||||
@ -100,16 +102,16 @@ class SenderAddStressICCardCommand extends SenderProtocol {
|
||||
} else {
|
||||
List<int> authCodeData = [];
|
||||
|
||||
//authUserID
|
||||
authCodeData.addAll(utf8.encode(userID!));
|
||||
|
||||
//KeyID
|
||||
authCodeData.addAll(utf8.encode(keyID!));
|
||||
|
||||
//authUserID
|
||||
authCodeData.addAll(utf8.encode(userID!));
|
||||
|
||||
//token 4 首次请求 Token 填 0,如果锁需要鉴权操作者身份,则会分配动态口令并在应答消息中返回,二次请求时带上。
|
||||
authCodeData.addAll(token!);
|
||||
|
||||
authCodeData.addAll(publicKey!);
|
||||
authCodeData.addAll(signKey!);
|
||||
|
||||
print("${commandType!.typeValue}-authCodeData:$authCodeData");
|
||||
|
||||
|
||||
@ -584,6 +584,7 @@ class IoSenderManage {
|
||||
required int? needAuthor,
|
||||
required List<int>? publicKey,
|
||||
required List<int>? privateKey,
|
||||
required List<int>? signKey,
|
||||
CommandSendCallBack? callBack}) {
|
||||
CommandSenderManager().managerSendData(
|
||||
command: SenderAddStressICCardCommand(
|
||||
@ -598,6 +599,7 @@ class IoSenderManage {
|
||||
needAuthor: needAuthor,
|
||||
publicKey: publicKey,
|
||||
privateKey: privateKey,
|
||||
signKey: signKey
|
||||
), callBack:callBack);
|
||||
}
|
||||
|
||||
|
||||
@ -18,6 +18,8 @@ class AddCardTypeLogic extends BaseGetXController{
|
||||
var endDate = "";
|
||||
if (state.seletType.value == "0") {
|
||||
fingerprintType = 1;
|
||||
startDate = "0";
|
||||
endDate = "0";
|
||||
} else if (state.seletType.value == "1") {
|
||||
fingerprintType = 2;
|
||||
if (state.beginTimeTimestamp.value.isEmpty) {
|
||||
@ -78,7 +80,7 @@ class AddCardTypeLogic extends BaseGetXController{
|
||||
"endDate": endDate,
|
||||
"addType": "1",
|
||||
"cardName": state.nameController.text,
|
||||
"cardNumber": (Random().nextInt(100000000) + 10000000).floor().toString(),
|
||||
"cardNumber": "123456",
|
||||
"cardType": fingerprintType.toString(),
|
||||
"isCoerced": isCoerced,
|
||||
"startDate": startDate,
|
||||
|
||||
@ -19,7 +19,7 @@ class AddCardTypeState{
|
||||
var weekdaysList = [].obs;
|
||||
|
||||
final TextEditingController nameController = TextEditingController();
|
||||
AddCardState() {
|
||||
AddCardTypeState() {
|
||||
// Map map = Get.arguments;
|
||||
// lockId.value = map["lockId"];
|
||||
// fromType.value = map["fromType"];
|
||||
|
||||
@ -45,11 +45,6 @@ class AddICCardLogic extends BaseGetXController{
|
||||
}
|
||||
|
||||
Future<void> _replyAddICCardBegin(Reply reply) async {
|
||||
var token = reply.data.sublist(5, 9);
|
||||
var saveStrList = changeIntListToStringList(token);
|
||||
print("_replyAddFingerprintReplyToken:$token");
|
||||
Storage.setStringList(saveBlueToken, saveStrList);
|
||||
|
||||
int status = reply.data[2];
|
||||
print("_replyAddFingerprintStatus:$status");
|
||||
|
||||
@ -69,15 +64,20 @@ class AddICCardLogic extends BaseGetXController{
|
||||
var publicKey = await Storage.getStringList(saveBluePublicKey);
|
||||
List<int> publicKeyDataList = changeStringListToIntList(publicKey!);
|
||||
|
||||
var token = reply.data.sublist(5, 9);
|
||||
var saveStrList = changeIntListToStringList(token);
|
||||
print("_replyAddFingerprintReplyToken:$token");
|
||||
Storage.setStringList(saveBlueToken, saveStrList);
|
||||
|
||||
IoSenderManage.senderAddFingerprintCommand(
|
||||
keyID:"1",
|
||||
userID:await Storage.getUid(),
|
||||
fingerNo:1,
|
||||
useCountLimit:0xff,
|
||||
startTime:0x11223344,
|
||||
endTime:0x11223344,
|
||||
// startTime:int.parse(state.startDate.value)~/1000,
|
||||
// endTime:int.parse(state.endDate.value)~/1000,
|
||||
// startTime:0x11223344,
|
||||
// endTime:0x11223344,
|
||||
startTime:int.parse(state.startDate.value)~/1000,
|
||||
endTime:int.parse(state.endDate.value)~/1000,
|
||||
needAuthor:1,
|
||||
publicKey:publicKeyDataList,
|
||||
privateKey:getPrivateKeyList,
|
||||
@ -103,11 +103,6 @@ class AddICCardLogic extends BaseGetXController{
|
||||
}
|
||||
|
||||
Future<void> _replyAddICCardConfirmation(Reply reply) async {
|
||||
var token = reply.data.sublist(2, 6);
|
||||
// var saveStrList = changeIntListToStringList(token);
|
||||
// print("_replyAddICCardConfirmationReplyToken:$token");
|
||||
// Storage.setStringList(saveBlueToken, saveStrList);
|
||||
|
||||
int status = reply.data[2];
|
||||
print("_replyAddFingerprintstatus:$status");
|
||||
|
||||
@ -117,11 +112,11 @@ class AddICCardLogic extends BaseGetXController{
|
||||
print("${reply.commandType!.typeValue} 数据解析成功");
|
||||
// print("添加指纹确认成功,调用添加指纹接口");
|
||||
if(state.isCoerced.value == "1"){
|
||||
// 非胁迫指纹
|
||||
// 非胁迫
|
||||
int addResultStatus = reply.data[5];
|
||||
if(addResultStatus == 0){
|
||||
// 成功更新序列号
|
||||
state.cardNumber.value = (reply.data[6]+1).toString();
|
||||
state.cardNumber.value = (reply.data[6]).toString();
|
||||
addICCardData();
|
||||
}else if(addResultStatus == 255){
|
||||
// 255 自动退出
|
||||
@ -155,10 +150,6 @@ class AddICCardLogic extends BaseGetXController{
|
||||
}
|
||||
|
||||
Future<void> _replyAddICStressCard(Reply reply) async {
|
||||
var token = reply.data.sublist(2, 6);
|
||||
var saveStrList = changeIntListToStringList(token);
|
||||
print("_replyAddICCardConfirmationReplyToken:$token");
|
||||
Storage.setStringList(saveBlueToken, saveStrList);
|
||||
|
||||
int status = reply.data[2];
|
||||
print("_replyAddFingerprintstatus:$status");
|
||||
@ -178,18 +169,29 @@ class AddICCardLogic extends BaseGetXController{
|
||||
var privateKey = await Storage.getStringList(saveBluePrivateKey);
|
||||
List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
|
||||
|
||||
var signKey = await Storage.getStringList(saveBlueSignKey);
|
||||
List<int> getSignKeyList = changeStringListToIntList(signKey!);
|
||||
|
||||
var token = reply.data.sublist(5, 9);
|
||||
var saveStrList = changeIntListToStringList(token);
|
||||
print("_replyAddICCardConfirmationReplyToken:$token");
|
||||
Storage.setStringList(saveBlueToken, saveStrList);
|
||||
|
||||
IoSenderManage.senderAddStressICCardCommand(
|
||||
keyID:"1",
|
||||
userID:await Storage.getUid(),
|
||||
icCardNo:1,
|
||||
cardType:1,
|
||||
useCountLimit:1,
|
||||
startTime:0x11223344,
|
||||
endTime:0x11223344,
|
||||
// startTime:0x11223344,
|
||||
// endTime:0x11223344,
|
||||
startTime:int.parse(state.startDate.value)~/1000,
|
||||
endTime:int.parse(state.endDate.value)~/1000,
|
||||
needAuthor:1,
|
||||
publicKey:publicKeyDataList,
|
||||
privateKey:getPrivateKeyList,
|
||||
token: token,
|
||||
signKey: getSignKeyList,
|
||||
);
|
||||
break;
|
||||
case 0x07:
|
||||
@ -210,7 +212,7 @@ class AddICCardLogic extends BaseGetXController{
|
||||
}
|
||||
}
|
||||
|
||||
// 添加卡片开始
|
||||
// 添加卡片
|
||||
Future<void> senderAddICCard() async {
|
||||
BlueManage().judgeReconnect(BlueManage().connectDeviceMacAddress, BlueManage().connectDeviceName, (DeviceConnectionState deviceConnectionState) async {
|
||||
if (deviceConnectionState == DeviceConnectionState.connected){
|
||||
@ -229,8 +231,10 @@ class AddICCardLogic extends BaseGetXController{
|
||||
userID:await Storage.getUid(),
|
||||
cardNo:1,
|
||||
useCountLimit:0xff,
|
||||
startTime:0x11223344,
|
||||
endTime:0x11223344,
|
||||
// startTime:0x11223344,
|
||||
// endTime:0x11223344,
|
||||
startTime:int.parse(state.startDate.value)~/1000,
|
||||
endTime:int.parse(state.endDate.value)~/1000,
|
||||
needAuthor:1,
|
||||
publicKey:publicKeyDataList,
|
||||
privateKey:getPrivateKeyList,
|
||||
@ -250,6 +254,9 @@ class AddICCardLogic extends BaseGetXController{
|
||||
var privateKey = await Storage.getStringList(saveBluePrivateKey);
|
||||
List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
|
||||
|
||||
var signKey = await Storage.getStringList(saveBlueSignKey);
|
||||
List<int> getSignKeyList = changeStringListToIntList(signKey!);
|
||||
|
||||
var token = await Storage.getStringList(saveBlueToken);
|
||||
List<int> getTokenList = changeStringListToIntList(token!);
|
||||
print("openDoorTokenPubToken:$getTokenList");
|
||||
@ -268,6 +275,7 @@ class AddICCardLogic extends BaseGetXController{
|
||||
publicKey:publicKeyDataList,
|
||||
privateKey:getPrivateKeyList,
|
||||
token: getTokenList,
|
||||
signKey: getSignKeyList,
|
||||
);
|
||||
}
|
||||
});
|
||||
@ -287,6 +295,13 @@ class AddICCardLogic extends BaseGetXController{
|
||||
);
|
||||
if (entity.errorCode!.codeIsSuccessful) {
|
||||
Toast.show(msg: "添加成功");
|
||||
if(state.fromType.value == 2){
|
||||
// 回调指纹号
|
||||
eventBus.fire(ChickInAddStaffCardAndFingerprintBlockNumberEvent(entity.data!.cardId.toString()));
|
||||
}else if(state.fromType.value == 1){
|
||||
eventBus.fire(OtherTypeRefreshListEvent());
|
||||
}
|
||||
Get.close(2);
|
||||
updateIdCardUserNoLoadData(entity.data!.cardId.toString());
|
||||
}
|
||||
}
|
||||
@ -298,14 +313,14 @@ class AddICCardLogic extends BaseGetXController{
|
||||
cardUserNo: state.cardNumber.value,
|
||||
);
|
||||
if(entity.errorCode!.codeIsSuccessful){
|
||||
Toast.show(msg: "添加成功");
|
||||
if(state.fromType.value == 2){
|
||||
// 回调指纹号
|
||||
eventBus.fire(ChickInAddStaffCardAndFingerprintBlockNumberEvent(cardId));
|
||||
}else if(state.fromType.value == 1){
|
||||
eventBus.fire(OtherTypeRefreshListEvent());
|
||||
}
|
||||
Get.close(2);
|
||||
// Toast.show(msg: "添加成功");
|
||||
// if(state.fromType.value == 2){
|
||||
// // 回调指纹号
|
||||
// eventBus.fire(ChickInAddStaffCardAndFingerprintBlockNumberEvent(cardId));
|
||||
// }else if(state.fromType.value == 1){
|
||||
// eventBus.fire(OtherTypeRefreshListEvent());
|
||||
// }
|
||||
// Get.close(2);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -54,13 +54,14 @@ class CardDetailLogic extends BaseGetXController{
|
||||
var token = await Storage.getStringList(saveBlueToken);
|
||||
List<int> getTokenList = changeStringListToIntList(token!);
|
||||
|
||||
String? userID = await Storage.getUid();
|
||||
IoSenderManage.senderAddICCardCommand(
|
||||
keyID:"1",
|
||||
userID:"DeleteAll!@#",
|
||||
cardNo:255,
|
||||
keyID:state.keyId.value.toString(),
|
||||
userID:userID,
|
||||
cardNo:int.parse(state.typeNumber.value),
|
||||
useCountLimit:0,
|
||||
startTime:0x11223344,
|
||||
endTime:0x11223344,
|
||||
startTime:state.effectiveDateTime.value,
|
||||
endTime:state.failureDateTime.value,
|
||||
needAuthor:1,
|
||||
publicKey:publicKeyDataList,
|
||||
privateKey:getPrivateKeyList,
|
||||
@ -86,9 +87,9 @@ class CardDetailLogic extends BaseGetXController{
|
||||
}
|
||||
|
||||
// 删除卡片
|
||||
Future<void> senderAddICCard(String keyId, String userID, int cardNo) async {
|
||||
BlueManage().judgeReconnect(BlueManage().connectDeviceMacAddress, BlueManage().connectDeviceName, (DeviceConnectionState state) async {
|
||||
if (state == DeviceConnectionState.connected){
|
||||
Future<void> senderAddICCard() async {
|
||||
BlueManage().judgeReconnect(BlueManage().connectDeviceMacAddress, BlueManage().connectDeviceName, (DeviceConnectionState deviceConnectionState) async {
|
||||
if (deviceConnectionState == DeviceConnectionState.connected){
|
||||
var publicKey = await Storage.getStringList(saveBluePublicKey);
|
||||
List<int> publicKeyDataList = changeStringListToIntList(publicKey!);
|
||||
|
||||
@ -99,16 +100,14 @@ class CardDetailLogic extends BaseGetXController{
|
||||
List<int> getTokenList = changeStringListToIntList(token!);
|
||||
print("openDoorTokenPubToken:$getTokenList");
|
||||
|
||||
String? userID = await Storage.getUid();
|
||||
IoSenderManage.senderAddICCardCommand(
|
||||
// keyID:"1",
|
||||
// userID:"DeleteAll!@#",
|
||||
// cardNo:255,
|
||||
keyID:keyId,
|
||||
keyID:state.keyId.value.toString(),
|
||||
userID:userID,
|
||||
cardNo:cardNo,
|
||||
cardNo:int.parse(state.typeNumber.value),
|
||||
useCountLimit:0,
|
||||
startTime:0x11223344,
|
||||
endTime:0x11223344,
|
||||
startTime:state.effectiveDateTime.value,
|
||||
endTime:state.failureDateTime.value,
|
||||
needAuthor:1,
|
||||
publicKey:publicKeyDataList,
|
||||
privateKey:getPrivateKeyList,
|
||||
@ -128,6 +127,7 @@ class CardDetailLogic extends BaseGetXController{
|
||||
endDate: state.failureDateTime.value.toString(),
|
||||
isCoerced: state.isStressFingerprint.value ? "2" : "1",
|
||||
cardName: state.changeNameController.text,
|
||||
changeType: "1",
|
||||
);
|
||||
if(entity.errorCode!.codeIsSuccessful){
|
||||
Toast.show(msg: "修改成功");
|
||||
|
||||
@ -349,7 +349,7 @@ class _CardDetailPageState extends State<CardDetailPage> {
|
||||
sureClick: () async {
|
||||
Get.back();
|
||||
String? idStr = await Storage.getUid();
|
||||
logic.senderAddICCard(state.fingerprintItemData.value.cardId.toString(), idStr ?? "", 0);
|
||||
logic.senderAddICCard();
|
||||
},
|
||||
cancelClick: () {
|
||||
Get.back();
|
||||
|
||||
@ -19,7 +19,7 @@ class CardDetailState{
|
||||
var weekDay = [].obs;// 有效日
|
||||
var adder = "".obs;// 添加者
|
||||
var addTime = 0.obs;// 添加时间
|
||||
var keyId = 0.obs;// 添加时间
|
||||
var keyId = 0.obs;// 卡id
|
||||
|
||||
final isStressFingerprint = false.obs;
|
||||
CardDetailState() {
|
||||
@ -34,7 +34,7 @@ class CardDetailState{
|
||||
keyType.value = fingerprintItemData.value.cardType!;
|
||||
adder.value = fingerprintItemData.value.senderUsername!;
|
||||
addTime.value = fingerprintItemData.value.createDate!;
|
||||
isStressFingerprint.value = fingerprintItemData.value.isCoerced! == 1 ? true : false;
|
||||
isStressFingerprint.value = fingerprintItemData.value.isCoerced! == 2 ? true : false;
|
||||
weekDay.value = fingerprintItemData.value.weekDay!;
|
||||
}
|
||||
}
|
||||
@ -27,7 +27,7 @@ class CardListLogic extends BaseGetXController {
|
||||
_replySubscription = EventBusManager().eventBus!.on<Reply>().listen((reply) {
|
||||
|
||||
// 添加卡片开始(重置锁里面所有卡)
|
||||
if((reply is SenderAddICCardReply) && (state.isDeletICCardData == true)) {
|
||||
if((reply is SenderAddICCardReply) && (state.isDeletCardData == true)) {
|
||||
_replyAddICCardBegin(reply);
|
||||
}
|
||||
|
||||
@ -50,7 +50,7 @@ class CardListLogic extends BaseGetXController {
|
||||
case 0x00:
|
||||
//成功
|
||||
print("${reply.commandType!.typeValue} 数据解析成功");
|
||||
state.isDeletICCardData = false;
|
||||
state.isDeletCardData = false;
|
||||
deletICCardData();
|
||||
break;
|
||||
case 0x06:
|
||||
@ -66,9 +66,9 @@ class CardListLogic extends BaseGetXController {
|
||||
List<int> getTokenList = changeStringListToIntList(token!);
|
||||
|
||||
IoSenderManage.senderAddICCardCommand(
|
||||
keyID:"1",
|
||||
userID:"DeleteAll!@#",
|
||||
cardNo:255,
|
||||
keyID:state.deletKeyID,
|
||||
userID:state.deletUserID,
|
||||
cardNo:state.deletCardNo,
|
||||
useCountLimit:0,
|
||||
startTime:0x11223344,
|
||||
endTime:0x11223344,
|
||||
@ -259,9 +259,9 @@ class CardListLogic extends BaseGetXController {
|
||||
}
|
||||
|
||||
// 删除卡片
|
||||
Future<void> senderAddICCard(String keyId, String userID, int cardNo) async {
|
||||
BlueManage().judgeReconnect(BlueManage().connectDeviceMacAddress, BlueManage().connectDeviceName, (DeviceConnectionState state) async {
|
||||
if (state == DeviceConnectionState.connected){
|
||||
Future<void> senderAddICCard() async {
|
||||
BlueManage().judgeReconnect(BlueManage().connectDeviceMacAddress, BlueManage().connectDeviceName, (DeviceConnectionState deviceConnectionState) async {
|
||||
if (deviceConnectionState == DeviceConnectionState.connected){
|
||||
var publicKey = await Storage.getStringList(saveBluePublicKey);
|
||||
List<int> publicKeyDataList = changeStringListToIntList(publicKey!);
|
||||
|
||||
@ -273,12 +273,9 @@ class CardListLogic extends BaseGetXController {
|
||||
print("openDoorTokenPubToken:$getTokenList");
|
||||
|
||||
IoSenderManage.senderAddICCardCommand(
|
||||
// keyID:"1",
|
||||
// userID:"DeleteAll!@#",
|
||||
// cardNo:255,
|
||||
keyID:keyId,
|
||||
userID:userID,
|
||||
cardNo:cardNo,
|
||||
keyID:state.deletKeyID,
|
||||
userID:state.deletUserID,
|
||||
cardNo:state.deletCardNo,
|
||||
useCountLimit:0,
|
||||
startTime:0x11223344,
|
||||
endTime:0x11223344,
|
||||
@ -306,14 +303,27 @@ class CardListLogic extends BaseGetXController {
|
||||
|
||||
// 删除所有IC卡
|
||||
void deletICCardData() async{
|
||||
var cardId = "";
|
||||
var type = "1";
|
||||
if(state.isDeletAll == false){
|
||||
cardId = state.deletKeyID;
|
||||
type = "0";
|
||||
}
|
||||
print("delet fingerprintId $cardId");
|
||||
var entity = await ApiRepository.to.deletIcCardData(
|
||||
cardId: "",
|
||||
cardId: cardId,
|
||||
lockId: state.lockId.value.toString(),
|
||||
type: "1",
|
||||
type: type,
|
||||
deleteType:"1"
|
||||
);
|
||||
if(entity.errorCode!.codeIsSuccessful){
|
||||
Toast.show(msg: "重置成功");
|
||||
if(state.isDeletAll == false){
|
||||
Toast.show(msg: "删除成功");
|
||||
}else{
|
||||
Toast.show(msg: "重置成功");
|
||||
}
|
||||
|
||||
state.isDeletCardData = false;
|
||||
getICCardListData();
|
||||
}
|
||||
}
|
||||
|
||||
@ -82,27 +82,6 @@ class _CardListPageState extends State<CardListPage> {
|
||||
);
|
||||
}
|
||||
|
||||
String getAppBarTitle(int type) {
|
||||
String title = "";
|
||||
switch (type) {
|
||||
case 0:
|
||||
title = TranslationLoader.lanKeys!.card!.tr;
|
||||
break;
|
||||
case 1:
|
||||
title = TranslationLoader.lanKeys!.fingerprint!.tr;
|
||||
break;
|
||||
case 2:
|
||||
title = TranslationLoader.lanKeys!.remoteControl!.tr;
|
||||
break;
|
||||
case 3:
|
||||
title = TranslationLoader.lanKeys!.face!.tr;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return title;
|
||||
}
|
||||
|
||||
Widget _searchWidget() {
|
||||
return Container(
|
||||
height: 60.h,
|
||||
@ -157,7 +136,7 @@ class _CardListPageState extends State<CardListPage> {
|
||||
key: Key(fingerprintItemData.cardName!),
|
||||
actionsWidth: 60,
|
||||
actions: [
|
||||
_buildDeleteBtn(fingerprintItemData.cardId.toString()),
|
||||
_buildDeleteBtn(fingerprintItemData),
|
||||
],
|
||||
decoration: const BoxDecoration(
|
||||
borderRadius: BorderRadius.all(Radius.circular(1)),
|
||||
@ -190,11 +169,13 @@ class _CardListPageState extends State<CardListPage> {
|
||||
) : const NoData());
|
||||
}
|
||||
|
||||
Widget _buildDeleteBtn(String idStr) {
|
||||
Widget _buildDeleteBtn(FingerprintItemData fingerprintItemData) {
|
||||
return GestureDetector(
|
||||
onTap: () {
|
||||
// 省略: 弹出是否删除的确认对话框。
|
||||
showIosTipViewDialog(context, idStr);
|
||||
state.deletKeyID = fingerprintItemData.cardId.toString();
|
||||
state.deletCardNo = int.parse(fingerprintItemData.cardNumber!);
|
||||
showIosTipViewDialog(context);
|
||||
},
|
||||
child: Container(
|
||||
width: 60,
|
||||
@ -213,7 +194,7 @@ class _CardListPageState extends State<CardListPage> {
|
||||
);
|
||||
}
|
||||
|
||||
void showIosTipViewDialog(BuildContext context, String keyId) {
|
||||
void showIosTipViewDialog(BuildContext context) {
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (BuildContext context) {
|
||||
@ -222,9 +203,10 @@ class _CardListPageState extends State<CardListPage> {
|
||||
tipTitle: "确定要删除吗?",
|
||||
sureClick: () async {
|
||||
Get.back();
|
||||
String? idStr = await Storage.getUid();
|
||||
state.isDeletICCardData = true;
|
||||
logic.senderAddICCard(keyId, idStr ?? "", 0);
|
||||
state.isDeletCardData = true;
|
||||
state.isDeletAll = false;
|
||||
state.deletUserID = (await Storage.getUid())!;
|
||||
logic.senderAddICCard();
|
||||
},
|
||||
cancelClick: () {
|
||||
Get.back();
|
||||
@ -306,8 +288,12 @@ class _CardListPageState extends State<CardListPage> {
|
||||
child: Text(TranslationLoader.lanKeys!.sure!.tr),
|
||||
onPressed: () {
|
||||
Navigator.pop(context);
|
||||
state.isDeletICCardData = true;
|
||||
logic.senderAddICCard("1", "DeleteAll!@#", 255);
|
||||
state.isDeletCardData = true;
|
||||
state.isDeletAll = true;
|
||||
state.deletKeyID = "1";
|
||||
state.deletUserID = "DeleteAll!@#";
|
||||
state.deletCardNo = 255;
|
||||
logic.senderAddICCard();
|
||||
},
|
||||
),
|
||||
],
|
||||
|
||||
@ -6,8 +6,12 @@ import '../../fingerprint/fingerprintList/fingerprintListData_entity.dart';
|
||||
class CardListState {
|
||||
final lockId = 0.obs;
|
||||
|
||||
var isDeletFingerprintData = false;
|
||||
var isDeletICCardData = false;
|
||||
// 因为删除跟添加指纹用的同一个协议 所以这里用做判断
|
||||
var isDeletCardData = false;
|
||||
var isDeletAll = false;
|
||||
var deletKeyID = "";
|
||||
var deletUserID = "DeleteAll!@#";
|
||||
var deletCardNo = 0;
|
||||
|
||||
final fingerprintItemListData = <FingerprintItemData>[].obs;
|
||||
final TextEditingController searchController = TextEditingController();
|
||||
|
||||
@ -41,6 +41,7 @@ class OtherTypeKeyChangeDateLogic extends BaseGetXController{
|
||||
endDate: state.endTimeTimestamp.value.toString(),
|
||||
isCoerced: state.fingerprintItemData.value.isCoerced == 1 ? "2" : "1",
|
||||
cardName: state.fingerprintItemData.value.cardName!,
|
||||
changeType: '1',
|
||||
);
|
||||
if(entity.errorCode!.codeIsSuccessful){
|
||||
Toast.show(msg: "修改成功");
|
||||
|
||||
@ -43,6 +43,7 @@ class OtherTypeKeyChangeValidityDateLogic extends BaseGetXController{
|
||||
endDate: state.endTimeTimestamp.value.toString(),
|
||||
isCoerced: state.fingerprintItemData.value.isCoerced == 1 ? "2" : "1",
|
||||
cardName: state.fingerprintItemData.value.cardName!,
|
||||
changeType: '1',
|
||||
);
|
||||
if(entity.errorCode!.codeIsSuccessful){
|
||||
Toast.show(msg: "修改成功");
|
||||
|
||||
@ -59,7 +59,7 @@ class AddFingerprintLogic extends BaseGetXController {
|
||||
//成功
|
||||
print("${reply.commandType!.typeValue} 数据解析成功");
|
||||
state.ifConnectScuess.value = true;
|
||||
state.fingerprintNumber.value = reply.data.last.toString();
|
||||
// state.fingerprintNumber.value = reply.data.last.toString();
|
||||
break;
|
||||
case 0x06:
|
||||
//无权限
|
||||
@ -128,31 +128,7 @@ class AddFingerprintLogic extends BaseGetXController {
|
||||
break;
|
||||
case 0x06:
|
||||
//需要权限
|
||||
// var token = reply.data.sublist(5, 9);
|
||||
// var saveStrList = changeIntListToStringList(token);
|
||||
// print("_replyAddFingerprintReplyToken:$token");
|
||||
// Storage.setStringList(saveBlueToken, saveStrList);
|
||||
//
|
||||
// var privateKey = await Storage.getStringList(saveBluePrivateKey);
|
||||
// List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
|
||||
//
|
||||
// var publicKey = await Storage.getStringList(saveBluePublicKey);
|
||||
// List<int> publicKeyDataList = changeStringListToIntList(publicKey!);
|
||||
//
|
||||
// IoSenderManage.senderAddStressFingerprintCommand(
|
||||
// keyID:"1",
|
||||
// userID:await Storage.getUid(),
|
||||
// fingerNo:1,
|
||||
// useCountLimit:1,
|
||||
// // startTime:0x11223344,
|
||||
// // endTime:0x11223344,
|
||||
// startTime:int.parse(state.startDate.value)~/1000,
|
||||
// endTime:int.parse(state.endDate.value)~/1000,
|
||||
// needAuthor:1,
|
||||
// publicKey:publicKeyDataList,
|
||||
// privateKey:getPrivateKeyList,
|
||||
// token: token,
|
||||
// );
|
||||
|
||||
break;
|
||||
case 0x07:
|
||||
//无权限
|
||||
|
||||
@ -8,7 +8,7 @@ class AddFingerprintState{
|
||||
final endDate = "".obs;
|
||||
final addType = "".obs;
|
||||
final fingerprintName = "".obs;
|
||||
final fingerprintNumber = "".obs;
|
||||
// final fingerprintNumber = "".obs;
|
||||
final fingerprintType = "".obs;
|
||||
final isCoerced = "".obs;
|
||||
final startDate = "".obs;
|
||||
@ -21,7 +21,7 @@ class AddFingerprintState{
|
||||
endDate.value = map["endDate"];
|
||||
addType.value = map["addType"];
|
||||
fingerprintName.value = map["fingerprintName"];
|
||||
fingerprintNumber.value = map["fingerprintNumber"];
|
||||
// fingerprintNumber.value = map["fingerprintNumber"];
|
||||
fingerprintType.value = map["fingerprintType"];
|
||||
isCoerced.value = map["isCoerced"];
|
||||
print("isCoerced.valueisCoerced.value:${isCoerced.value}");
|
||||
|
||||
@ -55,13 +55,14 @@ class FingerprintDetailLogic extends BaseGetXController{
|
||||
var token = await Storage.getStringList(saveBlueToken);
|
||||
List<int> getTokenList = changeStringListToIntList(token!);
|
||||
|
||||
String? userID = await Storage.getUid();
|
||||
IoSenderManage.senderAddFingerprintCommand(
|
||||
keyID:"1",
|
||||
userID:"DeleteAll!@#",
|
||||
fingerNo:255,
|
||||
keyID:state.keyId.value.toString(),
|
||||
userID:userID,
|
||||
fingerNo:int.parse(state.typeNumber.value),
|
||||
useCountLimit:0,
|
||||
startTime:0x11223344,
|
||||
endTime:0x11223344,
|
||||
startTime:state.effectiveDateTime.value,
|
||||
endTime:state.failureDateTime.value,
|
||||
needAuthor:1,
|
||||
publicKey:publicKeyDataList,
|
||||
privateKey:getPrivateKeyList,
|
||||
@ -104,7 +105,7 @@ class FingerprintDetailLogic extends BaseGetXController{
|
||||
IoSenderManage.senderAddFingerprintCommand(
|
||||
keyID:state.keyId.value.toString(),
|
||||
userID:userID,
|
||||
fingerNo:1,
|
||||
fingerNo:int.parse(state.typeNumber.value),
|
||||
useCountLimit:0,
|
||||
startTime:state.effectiveDateTime.value,
|
||||
endTime:state.failureDateTime.value,
|
||||
@ -117,6 +118,20 @@ class FingerprintDetailLogic extends BaseGetXController{
|
||||
});
|
||||
}
|
||||
|
||||
// 删除指纹
|
||||
void deletFingerprintsData() async{
|
||||
var entity = await ApiRepository.to.deletFingerprintsData(
|
||||
fingerprintId: state.fingerprintItemData.value.fingerprintId.toString(),
|
||||
lockId: state.fingerprintItemData.value.lockId.toString(),
|
||||
type: "0",
|
||||
deleteType:"1"
|
||||
);
|
||||
if(entity.errorCode!.codeIsSuccessful){
|
||||
Toast.show(msg: "删除成功");
|
||||
Get.back(result: "addScuess");
|
||||
}
|
||||
}
|
||||
|
||||
// 编辑指纹
|
||||
void editFingerprintsData() async{
|
||||
var entity = await ApiRepository.to.editFingerprintsData(
|
||||
@ -135,20 +150,6 @@ class FingerprintDetailLogic extends BaseGetXController{
|
||||
}
|
||||
}
|
||||
|
||||
// 删除指纹
|
||||
void deletFingerprintsData() async{
|
||||
var entity = await ApiRepository.to.deletFingerprintsData(
|
||||
fingerprintId: state.fingerprintItemData.value.fingerprintId.toString(),
|
||||
lockId: state.fingerprintItemData.value.lockId.toString(),
|
||||
type: "0",
|
||||
deleteType:"1"
|
||||
);
|
||||
if(entity.errorCode!.codeIsSuccessful){
|
||||
Toast.show(msg: "删除成功");
|
||||
Get.back(result: "addScuess");
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
void onReady() {
|
||||
// TODO: implement onReady
|
||||
|
||||
@ -17,7 +17,7 @@ class FingerprintDetailState{
|
||||
var weekDay = [].obs;// 有效日
|
||||
var adder = "".obs;// 添加者
|
||||
var addTime = 0.obs;// 添加时间
|
||||
var keyId = 0.obs;// 添加时间
|
||||
var keyId = 0.obs;
|
||||
|
||||
final isStressFingerprint = false.obs;
|
||||
FingerprintDetailState() {
|
||||
|
||||
@ -67,9 +67,9 @@ class FingerprintListLogic extends BaseGetXController{
|
||||
List<int> getTokenList = changeStringListToIntList(token!);
|
||||
|
||||
IoSenderManage.senderAddFingerprintCommand(
|
||||
keyID:"1",
|
||||
userID:"DeleteAll!@#",
|
||||
fingerNo:255,
|
||||
keyID:state.deletKeyID,
|
||||
userID:state.deletUserID,
|
||||
fingerNo:state.deletFingerNo,
|
||||
useCountLimit:0,
|
||||
startTime:0x11223344,
|
||||
endTime:0x11223344,
|
||||
@ -292,7 +292,7 @@ class FingerprintListLogic extends BaseGetXController{
|
||||
}
|
||||
|
||||
// 删除指纹
|
||||
Future<void> senderAddFingerprint(String keyId, String userID, int cardNo) async {
|
||||
Future<void> senderAddFingerprint() async {
|
||||
BlueManage().judgeReconnect(BlueManage().connectDeviceMacAddress, BlueManage().connectDeviceName, (DeviceConnectionState deviceConnectionState) async {
|
||||
if (deviceConnectionState == DeviceConnectionState.connected){
|
||||
var publicKey = await Storage.getStringList(saveBluePublicKey);
|
||||
@ -305,12 +305,9 @@ class FingerprintListLogic extends BaseGetXController{
|
||||
List<int> getTokenList = changeStringListToIntList(token!);
|
||||
|
||||
IoSenderManage.senderAddFingerprintCommand(
|
||||
// keyID:"1",
|
||||
// userID:"DeleteAll!@#",
|
||||
// fingerNo:255,
|
||||
keyID:keyId,
|
||||
userID:userID,
|
||||
fingerNo:cardNo,
|
||||
keyID:state.deletKeyID,
|
||||
userID:state.deletUserID,
|
||||
fingerNo:state.deletFingerNo,
|
||||
useCountLimit:0,
|
||||
startTime:0x11223344,
|
||||
endTime:0x11223344,
|
||||
@ -339,17 +336,25 @@ class FingerprintListLogic extends BaseGetXController{
|
||||
// 重置所有的指纹
|
||||
void deletAllFingerprintsData() async{
|
||||
var fingerprintId = "";
|
||||
var type = "1";
|
||||
if(state.isDeletAll == false){
|
||||
// fingerprintId =
|
||||
fingerprintId = state.deletKeyID;
|
||||
type = "0";
|
||||
}
|
||||
print("delet fingerprintId $fingerprintId");
|
||||
var entity = await ApiRepository.to.deletFingerprintsData(
|
||||
fingerprintId: fingerprintId,
|
||||
lockId: state.lockId.value.toString(),
|
||||
type: "1",
|
||||
type: type,
|
||||
deleteType:"1"
|
||||
);
|
||||
if(entity.errorCode!.codeIsSuccessful){
|
||||
Toast.show(msg: "重置成功");
|
||||
if(state.isDeletAll == false){
|
||||
Toast.show(msg: "删除成功");
|
||||
}else{
|
||||
Toast.show(msg: "重置成功");
|
||||
}
|
||||
|
||||
state.isDeletFingerprintData = false;
|
||||
getFingerprintsListData();
|
||||
}
|
||||
|
||||
@ -125,7 +125,6 @@ class _FingerprintListPageState extends State<FingerprintListPage> {
|
||||
}
|
||||
|
||||
Widget _buildMainUI() {
|
||||
|
||||
return Obx(() => state.fingerprintItemListData.value.isNotEmpty
|
||||
? ListView.separated(
|
||||
itemCount: state.fingerprintItemListData.value.length,
|
||||
@ -137,7 +136,7 @@ class _FingerprintListPageState extends State<FingerprintListPage> {
|
||||
key: Key(fingerprintItemData.fingerprintName!),
|
||||
actionsWidth: 60,
|
||||
actions: [
|
||||
_buildDeleteBtn(fingerprintItemData.fingerprintId.toString()),
|
||||
_buildDeleteBtn(fingerprintItemData),
|
||||
],
|
||||
decoration: const BoxDecoration(
|
||||
borderRadius: BorderRadius.all(Radius.circular(1)),
|
||||
@ -172,12 +171,13 @@ class _FingerprintListPageState extends State<FingerprintListPage> {
|
||||
: const NoData());
|
||||
}
|
||||
|
||||
Widget _buildDeleteBtn(String idStr) {
|
||||
Widget _buildDeleteBtn(FingerprintItemData fingerprintItemData) {
|
||||
return GestureDetector(
|
||||
onTap: () {
|
||||
// 省略: 弹出是否删除的确认对话框。
|
||||
state.deletFingerprintId = idStr;
|
||||
showIosTipViewDialog(context, idStr);
|
||||
state.deletKeyID = fingerprintItemData.fingerprintId.toString();
|
||||
state.deletFingerNo = int.parse(fingerprintItemData.fingerprintNumber!);
|
||||
showIosTipViewDialog(context);
|
||||
},
|
||||
child: Container(
|
||||
width: 60,
|
||||
@ -196,7 +196,7 @@ class _FingerprintListPageState extends State<FingerprintListPage> {
|
||||
);
|
||||
}
|
||||
|
||||
void showIosTipViewDialog(BuildContext context, String keyId) {
|
||||
void showIosTipViewDialog(BuildContext context) {
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (BuildContext context) {
|
||||
@ -205,10 +205,10 @@ class _FingerprintListPageState extends State<FingerprintListPage> {
|
||||
tipTitle: "确定要删除吗?",
|
||||
sureClick: () async {
|
||||
Get.back();
|
||||
String? idStr = await Storage.getUid();
|
||||
state.isDeletFingerprintData = true;
|
||||
state.isDeletAll = false;
|
||||
logic.senderAddFingerprint(keyId, idStr ?? "", 0);
|
||||
state.deletUserID = (await Storage.getUid())!;
|
||||
logic.senderAddFingerprint();
|
||||
},
|
||||
cancelClick: () {
|
||||
Get.back();
|
||||
@ -290,7 +290,10 @@ class _FingerprintListPageState extends State<FingerprintListPage> {
|
||||
Navigator.pop(context);
|
||||
state.isDeletFingerprintData = true;
|
||||
state.isDeletAll = true;
|
||||
logic.senderAddFingerprint("1", "DeleteAll!@#", 255);
|
||||
state.deletKeyID = "1";
|
||||
state.deletUserID = "DeleteAll!@#";
|
||||
state.deletFingerNo = 255;
|
||||
logic.senderAddFingerprint();
|
||||
},
|
||||
),
|
||||
],
|
||||
|
||||
@ -10,7 +10,9 @@ class FingerprintListState{
|
||||
// 因为删除跟添加指纹用的同一个协议 所以这里用做判断
|
||||
var isDeletFingerprintData = false;
|
||||
var isDeletAll = false;
|
||||
var deletFingerprintId = "0";
|
||||
var deletKeyID = "";
|
||||
var deletUserID = "DeleteAll!@#";
|
||||
var deletFingerNo = 0;
|
||||
|
||||
final fingerprintItemListData = <FingerprintItemData>[].obs;
|
||||
final TextEditingController searchController = TextEditingController();
|
||||
|
||||
@ -31,16 +31,18 @@ class _AutomaticBlockingPageState extends State<AutomaticBlockingPage> {
|
||||
barTitle: TranslationLoader.lanKeys!.automaticBlocking!.tr,
|
||||
haveBack: true,
|
||||
actionsList: [
|
||||
TextButton(
|
||||
Obx(() => TextButton(
|
||||
child: Text(
|
||||
TranslationLoader.lanKeys!.save!.tr,
|
||||
state.isJustForShow.value == true ? "" : TranslationLoader.lanKeys!.save!.tr,
|
||||
style: TextStyle(color: Colors.white, fontSize: 24.sp),
|
||||
),
|
||||
onPressed: () {
|
||||
// logic.sendAutoLock();
|
||||
if(state.isJustForShow.value == true){
|
||||
return;
|
||||
}
|
||||
logic.sendAutoLock();
|
||||
},
|
||||
),
|
||||
)),
|
||||
],
|
||||
backgroundColor: AppColors.mainColor),
|
||||
body: ListView(
|
||||
@ -60,6 +62,9 @@ class _AutomaticBlockingPageState extends State<AutomaticBlockingPage> {
|
||||
isHaveLine: false,
|
||||
isHaveDirection: true,
|
||||
action: () {
|
||||
if(state.isJustForShow.value == true){
|
||||
return;
|
||||
}
|
||||
var list = [
|
||||
"5",
|
||||
"10",
|
||||
@ -110,11 +115,12 @@ class _AutomaticBlockingPageState extends State<AutomaticBlockingPage> {
|
||||
),
|
||||
],
|
||||
),
|
||||
TextField(
|
||||
Obx(() => TextField(
|
||||
//输入框一行
|
||||
maxLines: 1,
|
||||
controller: state.timeController,
|
||||
autofocus: false,
|
||||
readOnly: state.isJustForShow.value == true ? false : true,
|
||||
decoration: InputDecoration(
|
||||
//输入里面输入文字内边距设置
|
||||
contentPadding:
|
||||
@ -125,7 +131,7 @@ class _AutomaticBlockingPageState extends State<AutomaticBlockingPage> {
|
||||
//不需要输入框下划线
|
||||
border: InputBorder.none,
|
||||
),
|
||||
),
|
||||
)),
|
||||
Container(
|
||||
height: 0.5.h,
|
||||
color: Colors.grey,
|
||||
|
||||
@ -7,6 +7,9 @@ import '../lockSet/lockSetInfo_entity.dart';
|
||||
|
||||
class AutomaticBlockingState {
|
||||
var lockSetInfoData = LockSetInfoData().obs;
|
||||
final lockBasicInfo = LockBasicInfo().obs;
|
||||
|
||||
var isJustForShow = false.obs;// 是否只是作为展示作用,因为普通用户只是展示,不可修改
|
||||
|
||||
var isOpen = false.obs;// 是否开启自动落锁
|
||||
var autoLockTime = "5".obs;
|
||||
@ -16,10 +19,17 @@ class AutomaticBlockingState {
|
||||
AutomaticBlockingState() {
|
||||
var map = Get.arguments;
|
||||
lockSetInfoData.value = map["lockSetInfoData"];
|
||||
lockBasicInfo.value = map["lockBasicInfo"];
|
||||
|
||||
isOpen.value = lockSetInfoData.value.lockSettingInfo!.autoLock! == 1 ? true : false;
|
||||
autoLockTime.value = lockSetInfoData.value.lockSettingInfo!.autoLockSecond!.toString();
|
||||
|
||||
if(lockBasicInfo.value.isLockOwner == 1 || lockBasicInfo.value.keyRight == 1){
|
||||
isJustForShow.value = false;
|
||||
}else{
|
||||
isJustForShow.value = true;
|
||||
}
|
||||
|
||||
if((lockSetInfoData.value.lockSettingInfo!.autoLock! > 0)
|
||||
&& (lockSetInfoData.value.lockSettingInfo!.autoLockSecond! != 5)
|
||||
&& (lockSetInfoData.value.lockSettingInfo!.autoLockSecond! != 10)
|
||||
|
||||
@ -107,15 +107,17 @@ class _BasicInformationPageState extends State<BasicInformationPage> {
|
||||
}
|
||||
});
|
||||
}),
|
||||
CommonItem(
|
||||
leftTitel: TranslationLoader.lanKeys!.adminOpenLockPassword!.tr,
|
||||
rightTitle: "",
|
||||
isHaveLine: true,
|
||||
isHaveDirection: true,
|
||||
action: () {
|
||||
Navigator.pushNamed(context,
|
||||
Routers.adminOpenLockPasswordPage);
|
||||
}),
|
||||
Visibility(
|
||||
visible: (state.lockBasicInfo.value.isLockOwner == 1 || state.lockBasicInfo.value.keyRight == 1) ? true : false,
|
||||
child: CommonItem(
|
||||
leftTitel: TranslationLoader.lanKeys!.adminOpenLockPassword!.tr,
|
||||
rightTitle: "",
|
||||
isHaveLine: true,
|
||||
isHaveDirection: true,
|
||||
action: () {
|
||||
Navigator.pushNamed(context, Routers.adminOpenLockPasswordPage);
|
||||
}),
|
||||
),
|
||||
CommonItem(
|
||||
leftTitel:
|
||||
TranslationLoader.lanKeys!.unlockQRCode!.tr,
|
||||
|
||||
@ -314,6 +314,8 @@ class LockBasicInfo {
|
||||
int? startDate;
|
||||
int? endDate;
|
||||
String? mac;
|
||||
int? keyRight;
|
||||
int? senderUserId;
|
||||
|
||||
LockBasicInfo(
|
||||
{this.keyId,
|
||||
@ -328,7 +330,9 @@ class LockBasicInfo {
|
||||
this.keyType,
|
||||
this.startDate,
|
||||
this.endDate,
|
||||
this.mac});
|
||||
this.mac,
|
||||
this.keyRight,
|
||||
this.senderUserId});
|
||||
|
||||
LockBasicInfo.fromJson(Map<String, dynamic> json) {
|
||||
keyId = json['keyId'];
|
||||
@ -349,6 +353,9 @@ class LockBasicInfo {
|
||||
startDate = json['startDate'];
|
||||
endDate = json['endDate'];
|
||||
mac = json['mac'];
|
||||
keyRight = json['keyRight'];
|
||||
senderUserId = json['senderUserId'];
|
||||
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
@ -368,6 +375,8 @@ class LockBasicInfo {
|
||||
data['startDate'] = startDate;
|
||||
data['endDate'] = endDate;
|
||||
data['mac'] = mac;
|
||||
data['keyRight'] = keyRight;
|
||||
data['senderUserId'] = senderUserId;
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter_reactive_ble/flutter_reactive_ble.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:star_lock/blue/io_protocol/io_deletUser.dart';
|
||||
@ -19,6 +20,7 @@ import '../../../../tools/baseGetXController.dart';
|
||||
import '../../../../tools/eventBusEventManage.dart';
|
||||
import '../../../../tools/storage.dart';
|
||||
import '../../../../tools/toast.dart';
|
||||
import '../../../../translations/trans_lib.dart';
|
||||
import 'checkingInInfoData_entity.dart';
|
||||
import 'lockSet_state.dart';
|
||||
|
||||
@ -248,9 +250,7 @@ class LockSetLogic extends BaseGetXController {
|
||||
|
||||
// 删除用户
|
||||
Future<void> deletUserAction() async {
|
||||
BlueManage().judgeReconnect(
|
||||
BlueManage().connectDeviceMacAddress, BlueManage().connectDeviceName,
|
||||
(DeviceConnectionState connectionState) async {
|
||||
BlueManage().judgeReconnect(BlueManage().connectDeviceMacAddress, BlueManage().connectDeviceName, (DeviceConnectionState connectionState) async {
|
||||
if (connectionState == DeviceConnectionState.connected) {
|
||||
var privateKey = await Storage.getStringList(saveBluePrivateKey);
|
||||
List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
|
||||
@ -263,13 +263,18 @@ class LockSetLogic extends BaseGetXController {
|
||||
|
||||
IoSenderManage.deletUser(
|
||||
lockID: BlueManage().connectDeviceName,
|
||||
authUserID: "100001",
|
||||
keyID: "1",
|
||||
delUserID: "100001",
|
||||
authUserID:state.lockBasicInfo.value.senderUserId.toString(),
|
||||
keyID:state.lockBasicInfo.value.keyId.toString(),
|
||||
delUserID:await Storage.getUid(),
|
||||
// authUserID: "100001",
|
||||
// keyID: "1",
|
||||
// delUserID: "100001",
|
||||
needAuthor: 1,
|
||||
publicKey: publicKeyDataList,
|
||||
privateKey: getPrivateKeyList,
|
||||
token: getTokenList);
|
||||
}else{
|
||||
showDeletAlertTipDialog(Get.context!);
|
||||
}
|
||||
});
|
||||
}
|
||||
@ -296,6 +301,8 @@ class LockSetLogic extends BaseGetXController {
|
||||
privateKey:getPrivateKeyList,
|
||||
token: getTokenList
|
||||
);
|
||||
}else{
|
||||
showDeletAlertTipDialog(Get.context!);
|
||||
}
|
||||
});
|
||||
}
|
||||
@ -378,6 +385,8 @@ class LockSetLogic extends BaseGetXController {
|
||||
state.lockSettingInfo.value = state.lockSetInfoData.value.lockSettingInfo!;
|
||||
state.lockFeature.value = state.lockSetInfoData.value.lockFeature!;
|
||||
state.lockStatus.value = state.lockSetInfoData.value.lockStatus!;
|
||||
state.lockBasicInfo.value = state.lockSetInfoData.value.lockBasicInfo!;
|
||||
|
||||
state.isAttendance.value = state.lockSettingInfo.value.attendance!;
|
||||
state.isOpenLockNeedOnline.value = state.lockSettingInfo.value.appUnlockOnline!;
|
||||
|
||||
@ -395,6 +404,7 @@ class LockSetLogic extends BaseGetXController {
|
||||
lockId: state.lockSetInfoData.value.lockId.toString(),
|
||||
);
|
||||
if (entity.errorCode!.codeIsSuccessful) {
|
||||
BlueManage().connectDeviceMacAddress = "";
|
||||
Get.offAllNamed(Routers.starLockMain);
|
||||
}
|
||||
}
|
||||
@ -406,6 +416,7 @@ class LockSetLogic extends BaseGetXController {
|
||||
keyId: state.lockSetInfoData.value.lockBasicInfo!.keyId.toString(),
|
||||
);
|
||||
if (entity.errorCode!.codeIsSuccessful) {
|
||||
BlueManage().connectDeviceMacAddress = "";
|
||||
Get.offAllNamed(Routers.starLockMain);
|
||||
}
|
||||
}
|
||||
@ -416,7 +427,7 @@ class LockSetLogic extends BaseGetXController {
|
||||
password: state.passwordTF.text,
|
||||
);
|
||||
if (entity.errorCode!.codeIsSuccessful) {
|
||||
deletLockInfoData();
|
||||
// deletLockInfoData();
|
||||
|
||||
blockDeletNumberCheckPasswordCallback();
|
||||
// if(state.currentDeviceUUid.value.isEmpty){
|
||||
@ -425,13 +436,23 @@ class LockSetLogic extends BaseGetXController {
|
||||
// }
|
||||
// if(state.currentDeviceUUid.value[31] == "1"){
|
||||
|
||||
// 已配对
|
||||
// 判断是否是锁的拥有者
|
||||
if(state.lockSetInfoData.value.lockBasicInfo!.isLockOwner == 1){
|
||||
// 调用删除锁协议
|
||||
factoryDataResetAction();
|
||||
// 判断是否扫描到当前设备
|
||||
if(BlueManage().connectDeviceMacAddress.isNotEmpty){
|
||||
// 调用删除锁协议
|
||||
factoryDataResetAction();
|
||||
}else{
|
||||
showDeletAlertTipDialog(Get.context!);
|
||||
}
|
||||
}else{
|
||||
// 调用删除钥匙协议
|
||||
deletUserAction();
|
||||
// 判断是否扫描到当前设备
|
||||
if(BlueManage().connectDeviceMacAddress.isNotEmpty){
|
||||
// 调用删除钥匙协议
|
||||
deletUserAction();
|
||||
}else{
|
||||
showDeletAlertTipDialog(Get.context!);
|
||||
}
|
||||
}
|
||||
|
||||
// }else if(state.currentDeviceUUid.value[31] == "0"){
|
||||
@ -528,6 +549,39 @@ class LockSetLogic extends BaseGetXController {
|
||||
});
|
||||
}
|
||||
|
||||
void showDeletAlertTipDialog(BuildContext context) {
|
||||
showCupertinoDialog(
|
||||
context: context,
|
||||
builder: (context) {
|
||||
return CupertinoAlertDialog(
|
||||
title: const Text("提示"),
|
||||
content: const Text('删除门锁后如需重新添加需要在门锁设置的"蓝牙功能"选项下先"清除配对",确定吗?'),
|
||||
actions: [
|
||||
CupertinoDialogAction(
|
||||
child: Text(TranslationLoader.lanKeys!.cancel!.tr),
|
||||
onPressed: () {
|
||||
Navigator.pop(context);
|
||||
},
|
||||
),
|
||||
CupertinoDialogAction(
|
||||
child: Text(TranslationLoader.lanKeys!.sure!.tr),
|
||||
onPressed: () {
|
||||
Navigator.pop(context);
|
||||
if(state.lockSetInfoData.value.lockBasicInfo!.isLockOwner == 1){
|
||||
// 直接调用删除锁接口
|
||||
deletLockInfoData();
|
||||
}else{
|
||||
// 直接调用删除要是接口
|
||||
deletKeyData();
|
||||
}
|
||||
},
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
void onReady() {
|
||||
// TODO: implement onReady
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@ -8,6 +8,7 @@ class LockSetState {
|
||||
final lockFeature = LockFeature().obs;
|
||||
final lockSettingInfo = LockSettingInfo().obs;
|
||||
final lockStatus = LockStatus().obs;
|
||||
final lockBasicInfo = LockBasicInfo().obs;
|
||||
|
||||
final lockId = 0.obs;
|
||||
|
||||
|
||||
@ -109,14 +109,14 @@ class _NormallyOpenModePageState extends State<NormallyOpenModePage> {
|
||||
],
|
||||
),
|
||||
)),
|
||||
Container(
|
||||
Obx(() => Container(
|
||||
margin: EdgeInsets.only(left: 20.w, right: 20.w, top: 30.h),
|
||||
child: SubmitBtn(
|
||||
child: state.isJustForShow.value == true ? Container() :SubmitBtn(
|
||||
btnName: TranslationLoader.lanKeys!.save!.tr,
|
||||
onClick: () {
|
||||
logic.sendAutoLock();
|
||||
}),
|
||||
),
|
||||
)),
|
||||
],
|
||||
)));
|
||||
}
|
||||
|
||||
@ -4,6 +4,8 @@ import '../lockSet/lockSetInfo_entity.dart';
|
||||
|
||||
class NormallyOpenModeState{
|
||||
var lockSetInfoData = LockSetInfoData().obs;
|
||||
final lockBasicInfo = LockBasicInfo().obs;
|
||||
var isJustForShow = false.obs;// 是否只是作为展示作用,因为普通用户只是展示,不可修改
|
||||
|
||||
// var getPassageModeConfigData = GetPassageModeConfigEntity().obs;
|
||||
var isOpenNormallyOpenMode = false.obs;// 是否开启常开模式 常开模式:1-开启、2-关闭
|
||||
@ -20,6 +22,12 @@ class NormallyOpenModeState{
|
||||
lockSetInfoData.value = map["lockSetInfoData"];
|
||||
isOpenNormallyOpenMode.value = lockSetInfoData.value.lockSettingInfo!.passageMode! == 1 ? true : false;
|
||||
|
||||
if(lockBasicInfo.value.isLockOwner == 1 || lockBasicInfo.value.keyRight == 1){
|
||||
isJustForShow.value = false;
|
||||
}else{
|
||||
isJustForShow.value = true;
|
||||
}
|
||||
|
||||
if((isOpenNormallyOpenMode.value == true) && (lockSetInfoData.value.lockSettingInfo!.passageModeConfig!.isNotEmpty)){
|
||||
isAllDay.value = lockSetInfoData.value.lockSettingInfo!.passageModeConfig![0].isAllDay!;
|
||||
weekDays.value = lockSetInfoData.value.lockSettingInfo!.passageModeConfig![0].weekDays!;
|
||||
|
||||
@ -11,6 +11,7 @@ import 'package:star_lock/blue/io_type.dart';
|
||||
import 'package:star_lock/tools/toast.dart';
|
||||
|
||||
import '../../../blue/blue_manage.dart';
|
||||
import '../../../blue/io_protocol/io_addUser.dart';
|
||||
import '../../../blue/io_protocol/io_getStarLockStatusInfo.dart';
|
||||
import '../../../blue/io_protocol/io_openLock.dart';
|
||||
import '../../../blue/io_protocol/io_referEventRecordTime.dart';
|
||||
@ -53,6 +54,11 @@ class LockDetailLogic extends BaseGetXController{
|
||||
if(reply is SenderReferEventRecordTimeReply) {
|
||||
_replyReferEventRecordTime(reply);
|
||||
}
|
||||
|
||||
// 添加用户
|
||||
if(reply is AddUserReply) {
|
||||
_replyAddUserKey(reply);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@ -60,7 +66,7 @@ class LockDetailLogic extends BaseGetXController{
|
||||
Future<void> _replyOpenLock(Reply reply) async {
|
||||
var tokenData = reply.data.sublist(2, 6);
|
||||
var saveStrList = changeIntListToStringList(tokenData);
|
||||
// print("openDoorToken:$tokenData");
|
||||
print("openDoorToken:$tokenData");
|
||||
Storage.setStringList(saveBlueToken, saveStrList);
|
||||
|
||||
int status = reply.data[6];
|
||||
@ -122,66 +128,6 @@ class LockDetailLogic extends BaseGetXController{
|
||||
}
|
||||
}
|
||||
|
||||
// 编辑用户数据解析
|
||||
// Future<void> _replyEditUserKey(Reply reply) async {
|
||||
// var token = reply.data.sublist(2, 6);
|
||||
// var saveStrList = changeIntListToStringList(token);
|
||||
// print("_replyEditUserKeyToken:$token");
|
||||
// Storage.setStringList(saveBlueToken, saveStrList);
|
||||
//
|
||||
// int status = reply.data[6];
|
||||
// print("status:$status");
|
||||
//
|
||||
// switch(status){
|
||||
// case 0x00:
|
||||
// //成功
|
||||
// print("${reply.commandType!.typeValue} 数据解析成功");
|
||||
//
|
||||
// break;
|
||||
// case 0x06:
|
||||
// //无权限
|
||||
// print("${reply.commandType!.typeValue} 需要鉴权");
|
||||
// var privateKey = await Storage.getStringList(saveBluePrivateKey);
|
||||
// List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
|
||||
//
|
||||
// var publicKey = await Storage.getStringList(saveBluePublicKey);
|
||||
// List<int> publicKeyDataList = changeStringListToIntList(publicKey!);
|
||||
//
|
||||
// IoSenderManage.senderEditUser(
|
||||
// lockID:BlueManage().connectDeviceName,
|
||||
// authUserID:await Storage.getUid(),
|
||||
// keyID:"1",
|
||||
// userID:await Storage.getUid(),
|
||||
// openMode:1,
|
||||
// keyType:1,
|
||||
// startDate:0x11223344,
|
||||
// expireDate:0x11223344,
|
||||
// role:255,
|
||||
// password:"123456",
|
||||
// needAuthor:1,
|
||||
// publicKey:publicKeyDataList,
|
||||
// privateKey:getPrivateKeyList,
|
||||
// token: token
|
||||
// );
|
||||
// break;
|
||||
// case 0x07:
|
||||
// //无权限
|
||||
// print("${reply.commandType!.typeValue} 用户无权限");
|
||||
//
|
||||
// break;
|
||||
// case 0x09:
|
||||
// // 权限校验错误
|
||||
// print("${reply.commandType!.typeValue} 权限校验错误");
|
||||
//
|
||||
// break;
|
||||
// default:
|
||||
// //失败
|
||||
// print("${reply.commandType!.typeValue} 失败");
|
||||
//
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
|
||||
// 获取锁状态数据解析
|
||||
Future<void> _replyGetStarLockStatusInfo(Reply reply) async {
|
||||
int status = reply.data[2];
|
||||
@ -325,6 +271,78 @@ class LockDetailLogic extends BaseGetXController{
|
||||
}
|
||||
}
|
||||
|
||||
// 添加用户
|
||||
Future<void> _replyAddUserKey(Reply reply) async {
|
||||
var lockId = reply.data.sublist(2, 42);
|
||||
// print("lockId:$lockId");
|
||||
|
||||
var token = reply.data.sublist(42, 46);
|
||||
List<String> strTokenList = changeIntListToStringList(token);
|
||||
Storage.setStringList(saveBlueToken, strTokenList);
|
||||
// print("token:$token");
|
||||
|
||||
int status = reply.data[46];
|
||||
// print("status:$status reply.data:${reply.data}");
|
||||
|
||||
print("status:$status");
|
||||
switch(status){
|
||||
case 0x00:
|
||||
//成功
|
||||
print("添加用户数据解析成功");
|
||||
state.lockUserNo = reply.data[47] + 1;
|
||||
// updateLockUserNo();
|
||||
|
||||
if(state.isOpenLockNeedOnline.value == 0){
|
||||
openDoorAction();
|
||||
}else{
|
||||
getLockNetToken();
|
||||
}
|
||||
|
||||
break;
|
||||
case 0x06:
|
||||
//无权限
|
||||
print("需要鉴权");
|
||||
var privateKey = await Storage.getStringList(saveBluePrivateKey);
|
||||
List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
|
||||
|
||||
var publicKey = await Storage.getStringList(saveBluePublicKey);
|
||||
List<int> publicKeyDataList = changeStringListToIntList(publicKey!);
|
||||
|
||||
IoSenderManage.senderAddUser(
|
||||
lockID: BlueManage().connectDeviceName,
|
||||
authUserID:state.senderUserId.toString(),
|
||||
keyID:state.keyInfos.value.keyId.toString(),
|
||||
userID:await Storage.getUid(),
|
||||
openMode:1,
|
||||
keyType:0,
|
||||
startDate:DateTime.now().millisecondsSinceEpoch,
|
||||
expireDate:0x11223344,
|
||||
role:0,
|
||||
password:"123456",
|
||||
needAuthor:1,
|
||||
publicKey:publicKeyDataList,
|
||||
privateKey:getPrivateKeyList,
|
||||
token: token
|
||||
);
|
||||
break;
|
||||
case 0x07:
|
||||
//无权限
|
||||
print("用户无权限");
|
||||
|
||||
break;
|
||||
case 0x09:
|
||||
// 权限校验错误
|
||||
print("添加用户权限校验错误");
|
||||
|
||||
break;
|
||||
default:
|
||||
//失败
|
||||
print("领锁失败");
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// 点击开门事件
|
||||
Future<void> openDoorAction() async {
|
||||
// if(BlueManage().connectDeviceMacAddress.isEmpty){
|
||||
@ -366,39 +384,39 @@ class LockDetailLogic extends BaseGetXController{
|
||||
}
|
||||
|
||||
// 编辑用户事件
|
||||
Future<void> editLockUserAction() async {
|
||||
BlueManage().judgeReconnect(BlueManage().connectDeviceMacAddress, BlueManage().connectDeviceName, (DeviceConnectionState state) async {
|
||||
if (state == DeviceConnectionState.connected){
|
||||
var publicKey = await Storage.getStringList(saveBluePublicKey);
|
||||
List<int> publicKeyDataList = changeStringListToIntList(publicKey!);
|
||||
|
||||
var privateKey = await Storage.getStringList(saveBluePrivateKey);
|
||||
List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
|
||||
|
||||
var token = await Storage.getStringList(saveBlueToken);
|
||||
List<int> getTokenList = changeStringListToIntList(token!);
|
||||
print("openDoorTokenPubToken:$getTokenList");
|
||||
|
||||
print("publicKey:$publicKey publicKeyDataList:$publicKeyDataList privateKey:$privateKey getPrivateKeyList:$getPrivateKeyList token:$token getTokenList:$getTokenList");
|
||||
IoSenderManage.senderEditUser(
|
||||
lockID:BlueManage().connectDeviceName,
|
||||
authUserID:await Storage.getUid(),
|
||||
keyID:"1",
|
||||
userID:await Storage.getUid(),
|
||||
openMode:1,
|
||||
keyType:1,
|
||||
startDate:0x11223344,
|
||||
expireDate:0x11223344,
|
||||
role:255,
|
||||
password:"123456",
|
||||
needAuthor:1,
|
||||
publicKey:publicKeyDataList,
|
||||
privateKey:getPrivateKeyList,
|
||||
token: getTokenList
|
||||
);
|
||||
}
|
||||
});
|
||||
}
|
||||
// Future<void> editLockUserAction() async {
|
||||
// BlueManage().judgeReconnect(BlueManage().connectDeviceMacAddress, BlueManage().connectDeviceName, (DeviceConnectionState state) async {
|
||||
// if (state == DeviceConnectionState.connected){
|
||||
// var publicKey = await Storage.getStringList(saveBluePublicKey);
|
||||
// List<int> publicKeyDataList = changeStringListToIntList(publicKey!);
|
||||
//
|
||||
// var privateKey = await Storage.getStringList(saveBluePrivateKey);
|
||||
// List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
|
||||
//
|
||||
// var token = await Storage.getStringList(saveBlueToken);
|
||||
// List<int> getTokenList = changeStringListToIntList(token!);
|
||||
// print("openDoorTokenPubToken:$getTokenList");
|
||||
//
|
||||
// print("publicKey:$publicKey publicKeyDataList:$publicKeyDataList privateKey:$privateKey getPrivateKeyList:$getPrivateKeyList token:$token getTokenList:$getTokenList");
|
||||
// IoSenderManage.senderEditUser(
|
||||
// lockID:BlueManage().connectDeviceName,
|
||||
// authUserID:await Storage.getUid(),
|
||||
// keyID:"1",
|
||||
// userID:await Storage.getUid(),
|
||||
// openMode:1,
|
||||
// keyType:1,
|
||||
// startDate:0x11223344,
|
||||
// expireDate:0x11223344,
|
||||
// role:255,
|
||||
// password:"123456",
|
||||
// needAuthor:1,
|
||||
// publicKey:publicKeyDataList,
|
||||
// privateKey:getPrivateKeyList,
|
||||
// token: getTokenList
|
||||
// );
|
||||
// }
|
||||
// });
|
||||
// }
|
||||
|
||||
|
||||
// 备用逻辑,进入管理钥匙界面获取锁状态
|
||||
@ -453,6 +471,44 @@ class LockDetailLogic extends BaseGetXController{
|
||||
}, isShowLoading: false);
|
||||
}
|
||||
|
||||
// 添加用户(普通用户接收电子钥匙)
|
||||
Future<void> addUserConnectBlue() async {
|
||||
// 进来之后首先连接
|
||||
BlueManage().judgeReconnect(BlueManage().connectDeviceMacAddress, BlueManage().connectDeviceName, (DeviceConnectionState deviceConnectionState) async {
|
||||
if (deviceConnectionState == DeviceConnectionState.connected){
|
||||
// 私钥
|
||||
var privateKey = await Storage.getStringList(saveBluePrivateKey);
|
||||
List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
|
||||
|
||||
var publicKey = await Storage.getStringList(saveBluePublicKey);
|
||||
List<int> publicKeyDataList = changeStringListToIntList(publicKey!);
|
||||
|
||||
var token = await Storage.getStringList(saveBlueToken);
|
||||
List<int> getTokenList = [0,0,0,0];
|
||||
if(token != null){
|
||||
getTokenList = changeStringListToIntList(token);
|
||||
}
|
||||
print("BlueManage().connectDeviceName:${BlueManage().connectDeviceName} authUserID:${state.senderUserId.toString()} keyID:${state.keyInfos.value.keyId.toString()} userID:${await Storage.getUid()}");
|
||||
IoSenderManage.senderAddUser(
|
||||
lockID: BlueManage().connectDeviceName,
|
||||
authUserID:state.senderUserId.toString(),
|
||||
keyID:state.keyInfos.value.keyId.toString(),
|
||||
userID:await Storage.getUid(),
|
||||
openMode:1,
|
||||
keyType:0,
|
||||
startDate:DateTime.now().millisecondsSinceEpoch,
|
||||
expireDate:0x11223344,
|
||||
role:0,
|
||||
password:"123456",
|
||||
needAuthor:1,
|
||||
publicKey:publicKeyDataList,
|
||||
privateKey:getPrivateKeyList,
|
||||
token: getTokenList
|
||||
);
|
||||
}
|
||||
}, isShowLoading: false);
|
||||
}
|
||||
|
||||
void startScanAction(){
|
||||
BlueManage().startScan(true, (v){
|
||||
// print("startScanAllDevice:${v}");
|
||||
@ -472,10 +528,14 @@ class LockDetailLogic extends BaseGetXController{
|
||||
state.lockState.value = 1;
|
||||
state.animationController.forward();
|
||||
|
||||
if(state.isOpenLockNeedOnline.value == 0){
|
||||
openDoorAction();
|
||||
if(state.lockUserNo == 0){
|
||||
addUserConnectBlue();
|
||||
}else{
|
||||
getLockNetToken();
|
||||
if(state.isOpenLockNeedOnline.value == 0){
|
||||
openDoorAction();
|
||||
}else{
|
||||
getLockNetToken();
|
||||
}
|
||||
}
|
||||
|
||||
Future.delayed(const Duration(seconds: 10), () {
|
||||
@ -504,10 +564,21 @@ class LockDetailLogic extends BaseGetXController{
|
||||
}
|
||||
}
|
||||
|
||||
// 普通用户接收电子钥匙之后 更新锁用户NO
|
||||
void updateLockUserNo() async {
|
||||
LockNetTokenEntity entity = await ApiRepository.to.updateLockUserNo(keyId: state.keyInfos.value.keyId.toString(), lockUserNo: state.lockUserNo.toString());
|
||||
if (entity.errorCode!.codeIsSuccessful) {
|
||||
if(state.isOpenLockNeedOnline.value == 0){
|
||||
openDoorAction();
|
||||
}else{
|
||||
getLockNetToken();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 查询锁记录最后时间
|
||||
void getLockRecordLastUploadDataTime() async {
|
||||
LockOperatingRecordGetLastRecordTimeEntity entity =
|
||||
await ApiRepository.to.getLockRecordLastUploadDataTime(lockId: state.keyInfos.value.lockId.toString());
|
||||
LockOperatingRecordGetLastRecordTimeEntity entity = await ApiRepository.to.getLockRecordLastUploadDataTime(lockId: state.keyInfos.value.lockId.toString());
|
||||
if (entity.errorCode!.codeIsSuccessful) {
|
||||
senderReferEventRecordTime(entity.data!.operateDate!~/1000);
|
||||
}
|
||||
@ -546,10 +617,11 @@ class LockDetailLogic extends BaseGetXController{
|
||||
// TODO: implement onReady
|
||||
super.onReady();
|
||||
print("onReady()");
|
||||
|
||||
_initReplySubscription();
|
||||
initLockSetOpenOrCloseCheckInRefreshLockDetailWithAttendanceAction();
|
||||
|
||||
EasyLoading.show(status: "正在连接设备,请稍等。", maskType: EasyLoadingMaskType.black, dismissOnTap: true);
|
||||
EasyLoading.show(status: "正在连接设备,请稍等。", maskType: EasyLoadingMaskType.none, dismissOnTap: true);
|
||||
Future.delayed(const Duration(seconds: 12), () {
|
||||
if(EasyLoading.isShow){
|
||||
EasyLoading.dismiss();
|
||||
|
||||
@ -3,15 +3,12 @@ import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
|
||||
import '../../../app_settings/app_colors.dart';
|
||||
import '../../../network/api_repository.dart';
|
||||
import '../../../tools/titleAppBar.dart';
|
||||
import '../../../translations/trans_lib.dart';
|
||||
// import '../../lockMian/entity/lockInfoEntity.dart';
|
||||
import '../../lockMian/entity/lockListInfo_entity.dart';
|
||||
import 'lockDetail_page.dart';
|
||||
|
||||
class LockDetailMainPage extends StatefulWidget {
|
||||
|
||||
const LockDetailMainPage({Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
@ -19,19 +16,6 @@ class LockDetailMainPage extends StatefulWidget {
|
||||
}
|
||||
|
||||
class _LockDetailMainPageState extends State<LockDetailMainPage> {
|
||||
|
||||
// void getLockInfo() async{
|
||||
// var entity = await ApiRepository.to.getLockInfo(
|
||||
// lastUpdateDate:DateTime.now().millisecondsSinceEpoch.toString(),
|
||||
// pageNo:"1",
|
||||
// );
|
||||
// if(entity.errorCode!.codeIsSuccessful){
|
||||
//
|
||||
// }else{
|
||||
//
|
||||
// }
|
||||
// }
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
// TODO: implement initState
|
||||
|
||||
@ -37,6 +37,8 @@ class _LockDetailPageState extends State<LockDetailPage> with TickerProviderStat
|
||||
super.initState();
|
||||
|
||||
state.keyInfos.value = widget.lockListInfoItemEntity;
|
||||
state.lockUserNo = state.keyInfos.value.lockUserNo!;
|
||||
state.senderUserId = state.keyInfos.value.senderUserId!;
|
||||
state.isAttendance.value = state.keyInfos.value.lockSetting!.attendance!;
|
||||
state.isOpenLockNeedOnline.value = state.keyInfos.value.lockSetting!.appUnlockOnline!;
|
||||
state.electricQuantity.value = state.keyInfos.value.electricQuantity!;
|
||||
@ -94,10 +96,8 @@ class _LockDetailPageState extends State<LockDetailPage> with TickerProviderStat
|
||||
SizedBox(
|
||||
width: 1.sw - 120.w * 2,
|
||||
child: Center(
|
||||
child: Text(
|
||||
widget.lockListInfoItemEntity!.lockAlias!,
|
||||
style:
|
||||
TextStyle(fontSize: 22.sp, fontWeight: FontWeight.w400),
|
||||
child:
|
||||
Text(widget.lockListInfoItemEntity.lockAlias!, style: TextStyle(fontSize: 22.sp, fontWeight: FontWeight.w400),
|
||||
))),
|
||||
Positioned(
|
||||
child: Obx(() => Row(
|
||||
@ -124,14 +124,11 @@ class _LockDetailPageState extends State<LockDetailPage> with TickerProviderStat
|
||||
child: Obx(() => Stack(
|
||||
children: [
|
||||
Image.asset(
|
||||
state.lockState.value == 4
|
||||
? 'images/main/icon_main_openLockBtn_grey.png'
|
||||
: 'images/main/icon_main_openLockBtn_center.png',
|
||||
state.lockState.value == 4 ? 'images/main/icon_main_openLockBtn_grey.png' : 'images/main/icon_main_openLockBtn_center.png',
|
||||
width: 330.w,
|
||||
height: 330.w,
|
||||
),
|
||||
(state.lockState.value == 1 ||
|
||||
state.lockState.value == 3)
|
||||
(state.lockState.value == 1 || state.lockState.value == 3)
|
||||
? buildRotationTransition()
|
||||
: Positioned(
|
||||
child: Image.asset(
|
||||
@ -267,11 +264,42 @@ class _LockDetailPageState extends State<LockDetailPage> with TickerProviderStat
|
||||
crossAxisSpacing: 20.w,
|
||||
mainAxisSpacing: 0.h,
|
||||
physics: const NeverScrollableScrollPhysics(),
|
||||
children: getShowWidget()),
|
||||
children: getBottomWidget()),
|
||||
);
|
||||
}
|
||||
|
||||
List<Widget> getShowWidget() {
|
||||
// 根据权限显示不同的底部按钮
|
||||
List<Widget> getBottomWidget(){
|
||||
if(state.keyInfos.value.isLockOwner == 1 || state.keyInfos.value.keyRight == 1){
|
||||
// 超级管理员、授权管理员
|
||||
return getAllWidget();
|
||||
}else{
|
||||
return getNormalWidget();
|
||||
}
|
||||
}
|
||||
|
||||
// 普通用户
|
||||
List<Widget> getNormalWidget() {
|
||||
var showWidgetArr = [
|
||||
// 操作记录
|
||||
bottomItem('images/main/icon_main_operatingRecord.png',
|
||||
TranslationLoader.lanKeys!.operatingRecord!.tr, () {
|
||||
Get.toNamed(Routers.lockOperatingRecordPage,
|
||||
arguments: {"keyInfo": widget.lockListInfoItemEntity});
|
||||
}),
|
||||
|
||||
// 设置
|
||||
bottomItem('images/main/icon_main_set.png', TranslationLoader.lanKeys!.set!.tr, () {
|
||||
BlueManage().stopScan();
|
||||
Get.toNamed(Routers.lockSetPage,
|
||||
arguments: {"lockId": widget.lockListInfoItemEntity.lockId});
|
||||
}),
|
||||
];
|
||||
return showWidgetArr;
|
||||
}
|
||||
|
||||
// 授权管理员、超级管理员字段
|
||||
List<Widget> getAllWidget() {
|
||||
var showWidgetArr = <Widget>[];
|
||||
// 考勤
|
||||
if (state.isAttendance.value == 1) {
|
||||
|
||||
@ -17,6 +17,8 @@ class LockDetailState {
|
||||
Rx<LockListInfoItemEntity> keyInfos = LockListInfoItemEntity().obs;
|
||||
|
||||
String lockNetToken = "";
|
||||
var lockUserNo = 0;
|
||||
var senderUserId = 0;
|
||||
|
||||
var isAttendance = 0.obs;// 是否开启考勤
|
||||
var isOpenLockNeedOnline = 0.obs; // APP开锁时是否需联网
|
||||
|
||||
@ -115,6 +115,8 @@ class LockListInfoItemEntity {
|
||||
int? keyStatus;
|
||||
int? isLockOwner;
|
||||
int? sendDate;
|
||||
int? lockUserNo;
|
||||
int? senderUserId;
|
||||
Bluetooth? bluetooth;
|
||||
LockFeature? lockFeature;
|
||||
LockSetting? lockSetting;
|
||||
@ -142,7 +144,9 @@ class LockListInfoItemEntity {
|
||||
this.bluetooth,
|
||||
this.lockFeature,
|
||||
this.lockSetting,
|
||||
this.sendDate});
|
||||
this.sendDate,
|
||||
this.lockUserNo,
|
||||
this.senderUserId});
|
||||
|
||||
LockListInfoItemEntity.fromJson(Map<String, dynamic> json) {
|
||||
keyId = json['keyId'];
|
||||
@ -165,6 +169,8 @@ class LockListInfoItemEntity {
|
||||
keyStatus = json['keyStatus'];
|
||||
isLockOwner = json['isLockOwner'];
|
||||
sendDate = json['sendDate'];
|
||||
lockUserNo = json['lockUserNo'];
|
||||
senderUserId = json['senderUserId'];
|
||||
bluetooth = json['bluetooth'] != null
|
||||
? Bluetooth.fromJson(json['bluetooth'])
|
||||
: null;
|
||||
@ -198,6 +204,8 @@ class LockListInfoItemEntity {
|
||||
data['keyStatus'] = keyStatus;
|
||||
data['isLockOwner'] = isLockOwner;
|
||||
data['sendDate'] = sendDate;
|
||||
data['lockUserNo'] = lockUserNo;
|
||||
data['senderUserId'] = senderUserId;
|
||||
if (bluetooth != null) {
|
||||
data['bluetooth'] = bluetooth!.toJson();
|
||||
}
|
||||
|
||||
@ -38,7 +38,7 @@ class _AbountPageState extends State<AbountPage> {
|
||||
),
|
||||
SizedBox(height: 20.h),
|
||||
Text(
|
||||
"星锁 1.0.0.02(preRelease-20231124)",
|
||||
"星锁 1.0.0.03(preRelease-20231216)",
|
||||
style: TextStyle(fontSize: 24.sp, color: AppColors.blackColor),
|
||||
),
|
||||
SizedBox(
|
||||
|
||||
@ -49,7 +49,7 @@ class SaveLockLogic extends BaseGetXController {
|
||||
case 0x00:
|
||||
//成功
|
||||
print("添加用户数据解析成功");
|
||||
state.lockUserNo = reply.data[47];
|
||||
state.lockUserNo = reply.data[47] + 1;
|
||||
|
||||
bindBlueAdmin();
|
||||
break;
|
||||
|
||||
@ -7,6 +7,7 @@ import 'package:star_lock/mine/mineSet/mineSet/mineSet_state.dart';
|
||||
import 'package:star_lock/tools/storage.dart';
|
||||
import '../../../../network/api_repository.dart';
|
||||
import '../../../../tools/baseGetXController.dart';
|
||||
import '../../../blue/blue_manage.dart';
|
||||
import '../../../tools/eventBusEventManage.dart';
|
||||
import '../../../tools/toast.dart';
|
||||
|
||||
@ -52,13 +53,16 @@ class MineSetLogic extends BaseGetXController {
|
||||
LoginEntity entity = await ApiRepository.to.userLogout();
|
||||
if (entity.errorCode!.codeIsSuccessful) {
|
||||
logOut();
|
||||
BlueManage().stopScan();
|
||||
BlueManage().disconnect(BlueManage().connectDeviceMacAddress);
|
||||
Get.offNamedUntil(Routers.starLockLoginPage, (route) => false);
|
||||
}
|
||||
}
|
||||
|
||||
///退出登录
|
||||
void logOut() async {
|
||||
await Storage.setString('userLoginData', '');
|
||||
Storage.clearAll();
|
||||
// await Storage.setString('userLoginData', '');
|
||||
}
|
||||
|
||||
//更新触摸开锁
|
||||
|
||||
@ -27,6 +27,7 @@ abstract class Api {
|
||||
final String getLockRecordLastUploadDataTimeURL = '/lockRecords/getLastRecordTime'; //查询锁记录最后时间
|
||||
|
||||
final String getLockNetTokenURL = '/lock/getLockNetToken'; //获取手机联网token
|
||||
final String updateLockUserNoURL = '/key/updateLockUserNo'; //更新锁用户NO
|
||||
|
||||
final String bindingBlueAdminURL = '/lock/bindAdmin'; //绑定蓝牙管理员
|
||||
final String modifyKeyNameURL = '/key/modifyKeyName'; //修改锁名称
|
||||
|
||||
@ -279,6 +279,15 @@ class ApiProvider extends BaseProvider {
|
||||
}),
|
||||
isUnShowLoading: true);
|
||||
|
||||
// 更新锁用户NO
|
||||
Future<Response> updateLockUserNo(String keyId, String lockUserNo) => post(
|
||||
updateLockUserNoURL.toUrl,
|
||||
jsonEncode({
|
||||
'keyId': keyId,
|
||||
'lockUserNo': lockUserNo,
|
||||
}),
|
||||
isUnShowLoading: true);
|
||||
|
||||
// 绑定蓝牙管理员
|
||||
Future<Response> bindingBlueAdmin(
|
||||
String lockAlias,
|
||||
@ -336,7 +345,7 @@ class ApiProvider extends BaseProvider {
|
||||
|
||||
// 删除拥有的当前钥匙
|
||||
Future<Response> deletOwnerKeyInfo(String lockId, String keyId) => post(
|
||||
deletLockURL.toUrl,
|
||||
deleteElectronicKeyURL.toUrl,
|
||||
jsonEncode({
|
||||
'lockId': lockId,
|
||||
'keyId': keyId
|
||||
@ -1036,7 +1045,7 @@ class ApiProvider extends BaseProvider {
|
||||
|
||||
// 编辑ICCard
|
||||
Future<Response> editICCardData(String lockId, String cardId, String cardName,
|
||||
String startDate, String endDate, String isCoerced, List weekDay) =>
|
||||
String startDate, String endDate, String isCoerced, List weekDay, String changeType) =>
|
||||
post(
|
||||
editICCardURL.toUrl,
|
||||
jsonEncode({
|
||||
@ -1046,7 +1055,8 @@ class ApiProvider extends BaseProvider {
|
||||
'startDate': startDate,
|
||||
'endDate': endDate,
|
||||
'isCoerced': isCoerced,
|
||||
'weekDay': weekDay
|
||||
'weekDay': weekDay,
|
||||
'changeType': changeType
|
||||
}));
|
||||
|
||||
// 删除卡
|
||||
|
||||
@ -217,8 +217,7 @@ class ApiRepository {
|
||||
}
|
||||
|
||||
//操作记录上传
|
||||
Future<KeyOperationRecordEntity> lockRecordUploadData(
|
||||
{required String lockId, required List records}) async {
|
||||
Future<KeyOperationRecordEntity> lockRecordUploadData({required String lockId, required List records}) async {
|
||||
final res = await apiProvider.lockRecordUploadData(lockId, records);
|
||||
return KeyOperationRecordEntity.fromJson(res.body);
|
||||
}
|
||||
@ -236,6 +235,12 @@ class ApiRepository {
|
||||
return LockNetTokenEntity.fromJson(res.body);
|
||||
}
|
||||
|
||||
// 更新锁用户NO
|
||||
Future<LockNetTokenEntity> updateLockUserNo({required String keyId, required String lockUserNo}) async {
|
||||
final res = await apiProvider.updateLockUserNo(keyId, lockUserNo);
|
||||
return LockNetTokenEntity.fromJson(res.body);
|
||||
}
|
||||
|
||||
// 绑定蓝牙管理员
|
||||
Future<SaveLockEntity> bindingBlueAdmin(
|
||||
{ required String lockAlias,
|
||||
@ -1180,9 +1185,10 @@ class ApiRepository {
|
||||
required String startDate,
|
||||
required String endDate,
|
||||
required String isCoerced,
|
||||
required List weekDay}) async {
|
||||
required List weekDay,
|
||||
required String changeType}) async {
|
||||
final res = await apiProvider.editICCardData(
|
||||
lockId, cardId, cardName, startDate, endDate, isCoerced, weekDay);
|
||||
lockId, cardId, cardName, startDate, endDate, isCoerced, weekDay, changeType);
|
||||
return LoginEntity.fromJson(res.body);
|
||||
}
|
||||
|
||||
|
||||
@ -139,7 +139,7 @@ class Storage {
|
||||
String? userId = '';
|
||||
final data = await Storage.getString('userLoginData');
|
||||
if (data != null && data.isNotEmpty) {
|
||||
userId = LoginData.fromJson(jsonDecode(data)).userid.toString();
|
||||
userId = LoginData.fromJson(jsonDecode(data)).uid.toString();
|
||||
}
|
||||
print("pubUserId:$userId");
|
||||
return userId;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user