fix:密码分享到微信的纯文本内容修改

This commit is contained in:
liyi 2025-02-25 15:18:42 +08:00
parent 88af212844
commit 53694a0621
3 changed files with 617 additions and 220 deletions

View File

@ -1,4 +1,3 @@
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,68 +21,77 @@ class PasswordKeyDetailLogic extends BaseGetXController {
// //
late StreamSubscription<Reply> _replySubscription; late StreamSubscription<Reply> _replySubscription;
void _initReplySubscription() { void _initReplySubscription() {
_replySubscription = EventBusManager().eventBus!.on<Reply>().listen((Reply reply) async { _replySubscription =
// EventBusManager().eventBus!.on<Reply>().listen((Reply reply) async {
if (reply is SenderCustomPasswordsReply && state.ifCurrentScreen.value == true) { //
final int status = reply.data[2]; if (reply is SenderCustomPasswordsReply &&
switch (status) { state.ifCurrentScreen.value == true) {
case 0x00: final int status = reply.data[2];
// switch (status) {
state.sureBtnState.value = 0; case 0x00:
dismissEasyLoading(); //
cancelBlueConnetctToastTimer(); state.sureBtnState.value = 0;
if(state.isDeletPasswordKey.value == true){ dismissEasyLoading();
deletePwdRequest(); cancelBlueConnetctToastTimer();
}else{ if (state.isDeletPasswordKey.value == true) {
updatePwdRequest(2); deletePwdRequest();
} } else {
break; updatePwdRequest(2);
case 0x06:
//
final List<String>? privateKey = await Storage.getStringList(saveBluePrivateKey);
final List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
final List<String>? signKey = await Storage.getStringList(saveBlueSignKey);
final List<int> signKeyDataList = changeStringListToIntList(signKey!);
final List<int> token = reply.data.sublist(5, 9);
final List<String> saveStrList = changeIntListToStringList(token);
Storage.setStringList(saveBlueToken, saveStrList);
IoSenderManage.senderCustomPasswordsCommand(
keyID:state.itemData.value.keyboardPwdId!.toString(),
userID:await Storage.getUid(),
pwdNo: state.itemData.value.pwdUserNo!,
pwd: state.inputPwdController.text,
useCountLimit: 0xffff,
operate: state.itemData.value.isCustom == 1 ? (state.isDeletPasswordKey.value == true ? 2 : 1) : 3,
isAdmin: state.isAdministrator.value == true ? 1 : 0,
startTime:state.itemData.value.startDate! ~/ 1000,
endTime:state.itemData.value.endDate! ~/ 1000,
needAuthor: 1,
isBeforeAddUser: false,
signKey: signKeyDataList,
privateKey: getPrivateKeyList,
token: token);
break;
default:
//
cancelBlueConnetctToastTimer();
break;
} }
} break;
}); case 0x06:
//
final List<String>? privateKey =
await Storage.getStringList(saveBluePrivateKey);
final List<int> getPrivateKeyList =
changeStringListToIntList(privateKey!);
final List<String>? signKey =
await Storage.getStringList(saveBlueSignKey);
final List<int> signKeyDataList =
changeStringListToIntList(signKey!);
final List<int> token = reply.data.sublist(5, 9);
final List<String> saveStrList = changeIntListToStringList(token);
Storage.setStringList(saveBlueToken, saveStrList);
IoSenderManage.senderCustomPasswordsCommand(
keyID: state.itemData.value.keyboardPwdId!.toString(),
userID: await Storage.getUid(),
pwdNo: state.itemData.value.pwdUserNo!,
pwd: state.inputPwdController.text,
useCountLimit: 0xffff,
operate: state.itemData.value.isCustom == 1
? (state.isDeletPasswordKey.value == true ? 2 : 1)
: 3,
isAdmin: state.isAdministrator.value == true ? 1 : 0,
startTime: state.itemData.value.startDate! ~/ 1000,
endTime: state.itemData.value.endDate! ~/ 1000,
needAuthor: 1,
isBeforeAddUser: false,
signKey: signKeyDataList,
privateKey: getPrivateKeyList,
token: token);
break;
default:
//
cancelBlueConnetctToastTimer();
break;
}
}
});
} }
// deleteType:1- 2- // deleteType:1- 2-
Future<void> deletePwdRequest() async { Future<void> deletePwdRequest() async {
final 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');
}); });
@ -107,12 +115,12 @@ 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;
state.itemData.value.keyboardPwdName = state.keyboardPwdName.value; state.itemData.value.keyboardPwdName = state.keyboardPwdName.value;
}else if(changType == 2){ } else if (changType == 2) {
// //
state.keyboardPwd.value = state.inputPwdController.text; state.keyboardPwd.value = state.inputPwdController.text;
state.itemData.value.keyboardPwd = state.keyboardPwd.value; state.itemData.value.keyboardPwd = state.keyboardPwd.value;
@ -124,43 +132,49 @@ class PasswordKeyDetailLogic extends BaseGetXController {
// //
Future<void> senderCustomPasswords() async { Future<void> senderCustomPasswords() async {
showEasyLoading(); showEasyLoading();
showBlueConnetctToastTimer(action: (){ showBlueConnetctToastTimer(action: () {
dismissEasyLoading(); dismissEasyLoading();
state.sureBtnState.value = 0; state.sureBtnState.value = 0;
}); });
BlueManage().blueSendData(BlueManage().connectDeviceName, (BluetoothConnectionState deviceConnectionState) async { BlueManage().blueSendData(BlueManage().connectDeviceName,
(BluetoothConnectionState deviceConnectionState) async {
if (deviceConnectionState == BluetoothConnectionState.connected) { if (deviceConnectionState == BluetoothConnectionState.connected) {
final List<String>? signKey = await Storage.getStringList(saveBlueSignKey); final List<String>? signKey =
await Storage.getStringList(saveBlueSignKey);
final List<int> signKeyDataList = changeStringListToIntList(signKey!); final List<int> signKeyDataList = changeStringListToIntList(signKey!);
final List<String>? privateKey = await Storage.getStringList(saveBluePrivateKey); final List<String>? privateKey =
final List<int> getPrivateKeyList = changeStringListToIntList(privateKey!); await Storage.getStringList(saveBluePrivateKey);
final List<int> getPrivateKeyList =
changeStringListToIntList(privateKey!);
final List<String>? token = await Storage.getStringList(saveBlueToken); final List<String>? token = await Storage.getStringList(saveBlueToken);
final 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(),
userID:await Storage.getUid(), userID: await Storage.getUid(),
pwdNo: state.itemData.value.pwdUserNo!, pwdNo: state.itemData.value.pwdUserNo!,
pwd: state.inputPwdController.text, pwd: state.inputPwdController.text,
useCountLimit: 0xffff, useCountLimit: 0xffff,
operate: state.itemData.value.isCustom == 1 ? (state.isDeletPasswordKey.value == true ? 2 : 1) : 3, operate: state.itemData.value.isCustom == 1
? (state.isDeletPasswordKey.value == true ? 2 : 1)
: 3,
isAdmin: state.isAdministrator.value == true ? 1 : 0, isAdmin: state.isAdministrator.value == true ? 1 : 0,
startTime:state.itemData.value.startDate! ~/ 1000, startTime: state.itemData.value.startDate! ~/ 1000,
endTime:state.itemData.value.endDate! ~/ 1000, endTime: state.itemData.value.endDate! ~/ 1000,
needAuthor: 1, needAuthor: 1,
isBeforeAddUser: false, isBeforeAddUser: false,
signKey: signKeyDataList, signKey: signKeyDataList,
privateKey: getPrivateKeyList, privateKey: getPrivateKeyList,
token: getTokenList); token: getTokenList);
} else if (deviceConnectionState == BluetoothConnectionState.disconnected) { } else if (deviceConnectionState ==
BluetoothConnectionState.disconnected) {
dismissEasyLoading(); dismissEasyLoading();
cancelBlueConnetctToastTimer(); cancelBlueConnetctToastTimer();
state.sureBtnState.value = 0; state.sureBtnState.value = 0;
if(state.ifCurrentScreen.value == true){ if (state.ifCurrentScreen.value == true) {
showBlueConnetctToast(); showBlueConnetctToast();
} }
} }
@ -171,162 +185,359 @@ class PasswordKeyDetailLogic extends BaseGetXController {
String getUseDateStr() { String getUseDateStr() {
final int? getPwdType = state.itemData.value.keyboardPwdType; final int? getPwdType = state.itemData.value.keyboardPwdType;
String useDateStr = ''; String useDateStr = '';
final DateTime startDateStr = DateTime.fromMillisecondsSinceEpoch(state.itemData.value.startDate!); final DateTime startDateStr =
final DateTime endDateStr = DateTime.fromMillisecondsSinceEpoch(state.itemData.value.endDate!); DateTime.fromMillisecondsSinceEpoch(state.itemData.value.startDate!);
final DateTime endDateStr =
DateTime.fromMillisecondsSinceEpoch(state.itemData.value.endDate!);
final String starHour = '${state.itemData.value.hoursStart}'; final String starHour = '${state.itemData.value.hoursStart}';
final String endHour = '${state.itemData.value.hoursEnd}'; final String endHour = '${state.itemData.value.hoursEnd}';
switch (getPwdType) { switch (getPwdType) {
case 1: case 1:
// 1 6使 // 1 6使
useDateStr = useDateStr = '\n' +
'${startDateStr.toLocal().toString().substring(0, 16)}\n${endDateStr.toLocal().toString().substring(0, 16)}'; '类型'.tr +
state.isCirculation.value = false; ':' +
'单次'.tr +
'\n' +
'\n' +
'有效期'.tr +
':${startDateStr.toLocal().toString().substring(0, 16)} -- ${endDateStr.toLocal().toString().substring(0, 16)}\n\n' +
'这是单次密码,只能使用一次\n';
break; break;
case 2: case 2:
// 2 24使 // 2 24使
useDateStr = '永久'; useDateStr = '\n' +
state.isCirculation.value = false; '类型'.tr +
':' +
'永久'.tr +
'\n' +
'\n注:\n' +
'必需在开始时间24小时内使用一次否则将失效\n';
break; break;
case 3: case 3:
// 3 24使 // 3 24使
useDateStr = useDateStr = '\n' +
'${startDateStr.toLocal().toString().substring(0, 16)}\n${DateTime.fromMillisecondsSinceEpoch(state.itemData.value.endDate!-1).toLocal().toString().substring(0, 16)}'; '类型'.tr +
state.isCirculation.value = false; ':' +
'限时'.tr +
'\n' +
'\n' +
'有效期'.tr +
':${startDateStr.toLocal().toString().substring(0, 16)}-${endDateStr.toLocal().toString().substring(0, 16)}' +
'\n' +
'\n注:\n' +
'必需在开始时间24小时内使用一次否则将失效\n';
break; break;
case 4: case 4:
// 4 使使 // 4 使使
useDateStr = useDateStr = '类型'.tr + ':' + '清空'.tr;
'${startDateStr.toLocal().toString().substring(0, 16)}\n${endDateStr.toLocal().toString().substring(0, 16)}';
state.isCirculation.value = false;
break; break;
case 5: case 5:
// 5 // 5
useDateStr = '周末'.tr + '$starHour:00-$endHour:00'; useDateStr = '\n' +
state.isCirculation.value = true; '类型'.tr +
':' +
'循环'.tr +
'\n' +
'\n' +
'周末'.tr +
' $starHour:00-$endHour:00' +
'\n';
break; break;
case 6: case 6:
// 6 // 6
useDateStr = '每日'.tr + '$starHour:00-$endHour:00'; useDateStr = '\n' +
state.isCirculation.value = true; '类型'.tr +
':' +
'循环'.tr +
'\n' +
'\n' +
'每日'.tr +
' $starHour:00-$endHour:00' +
'\n';
break; break;
case 7: case 7:
// 7 // 7
useDateStr = '工作日'.tr + '$starHour:00-$endHour:00'; useDateStr = '\n' +
state.isCirculation.value = true; '类型'.tr +
':' +
'循环'.tr +
'\n' +
'\n' +
'工作日'.tr +
' $starHour:00-$endHour:00' +
'\n';
break; break;
case 8: case 8:
// 8 // 8
useDateStr = '周一'.tr + '$starHour:00-$endHour:00'; useDateStr = '\n' +
state.isCirculation.value = true; '类型'.tr +
':' +
'循环'.tr +
'\n' +
'\n' +
'周一'.tr +
' $starHour:00-$endHour:00' +
'\n';
break; break;
case 9: case 9:
// 9 // 9
useDateStr = '周二'.tr + '$starHour:00-$endHour:00'; useDateStr = '\n' +
state.isCirculation.value = true; '类型'.tr +
':' +
'循环'.tr +
'\n' +
'\n' +
'周二'.tr +
' $starHour:00-$endHour:00' +
'\n';
break; break;
case 10: case 10:
// 10 // 10
useDateStr = '周三'.tr + '$starHour:00-$endHour:00'; useDateStr = '\n' +
state.isCirculation.value = true; '类型'.tr +
':' +
'循环'.tr +
'\n' +
'\n' +
'周三'.tr +
' $starHour:00-$endHour:00' +
'\n';
break; break;
case 11: case 11:
// 11 // 11
useDateStr = '周四'.tr + '$starHour:00-$endHour:00'; useDateStr = '\n' +
state.isCirculation.value = true; '类型'.tr +
':' +
'循环'.tr +
'\n' +
'\n' +
'周四'.tr +
' $starHour:00 -$endHour:00' +
'\n';
break; break;
case 12: case 12:
// 12 // 12
useDateStr = '周五'.tr + '$starHour:00-$endHour:00'; useDateStr = '\n' +
state.isCirculation.value = true; '类型'.tr +
':' +
'循环'.tr +
'\n' +
'\n' +
'周五'.tr +
' $starHour:00-$endHour:00' +
'\n';
break; break;
case 13: case 13:
// 13 // 13
useDateStr = '周六'.tr + '$starHour:00-$endHour:00'; useDateStr = '\n' +
state.isCirculation.value = true; '类型'.tr +
':' +
'循环'.tr +
'\n' +
'\n' +
'周六'.tr +
' $starHour:00-$endHour:00' +
'\n';
break; break;
case 14: case 14:
// 14 // 14
useDateStr = '周日'.tr + '$starHour:00-$endHour:00'; useDateStr = '\n' +
state.isCirculation.value = true; '类型'.tr +
':' +
'循环'.tr +
'\n' +
'\n' +
'周日'.tr +
' $starHour:00-$endHour:00' +
'\n';
break; break;
default: default:
} }
return useDateStr; // return '您好,您的密码是'.tr + ':${state.itemData.value.keyboardPwd}\n$useDateStr\n${'密码名字'.tr}:${state.itemData.value.keyboardPwdName}';
return '您好' +
',\n您的开门密码是' +
':${state.itemData.value.keyboardPwd}\n$useDateStr\n${'密码名字'.tr}:${state.itemData.value.keyboardPwdName}\n\n开锁时,先激活锁键盘,再输入密码,以#号结束,#号键在键盘右下角,有可能是其他图标';
} }
String getShareContentStr() { String getShareContentStr() {
final int? getPwdType = state.itemData.value.keyboardPwdType; final int? getPwdType = state.itemData.value.keyboardPwdType;
String useDateStr = ''; String useDateStr = '';
final DateTime startDateStr = final DateTime startDateStr =
DateTime.fromMillisecondsSinceEpoch(state.itemData.value.startDate!); DateTime.fromMillisecondsSinceEpoch(state.itemData.value.startDate!);
final DateTime endDateStr = final DateTime endDateStr =
DateTime.fromMillisecondsSinceEpoch(state.itemData.value.endDate!); DateTime.fromMillisecondsSinceEpoch(state.itemData.value.endDate!);
final int starHour = startDateStr.hour; final int starHour = startDateStr.hour;
final int endHour = endDateStr.hour; final int endHour = endDateStr.hour;
switch (getPwdType) { switch (getPwdType) {
case 1: case 1:
// 1 6使 // 1 6使
useDateStr = useDateStr = '\n' +
'类型'.tr + ':' + '永久'.tr + '\n' + '有效期'.tr + ':${startDateStr.toLocal().toString().substring(0, 16)} -- ${endDateStr.toLocal().toString().substring(0, 16)}'; '类型'.tr +
':' +
'单次'.tr +
'\n' +
'\n' +
'有效期'.tr +
':${startDateStr.toLocal().toString().substring(0, 16)} -- ${endDateStr.toLocal().toString().substring(0, 16)}\n\n' +
'这是单次密码,只能使用一次\n';
break; break;
case 2: case 2:
// 2 24使 // 2 24使
useDateStr = '类型'.tr + ':' + '永久'.tr; useDateStr = '\n' +
'类型'.tr +
':' +
'永久'.tr +
'\n' +
'\n注:\n' +
'必需在开始时间24小时内使用一次否则将失效\n';
break; break;
case 3: case 3:
// 3 24使 // 3 24使
useDateStr = useDateStr = '\n' +
'类型'.tr + ':' + '限时'.tr + '\n' + '有效期'.tr + ':${startDateStr.toLocal().toString().substring(0, 16)}-${endDateStr.toLocal().toString().substring(0, 16)}'; '类型'.tr +
':' +
'限时'.tr +
'\n' +
'\n' +
'有效期'.tr +
':${startDateStr.toLocal().toString().substring(0, 16)}-${endDateStr.toLocal().toString().substring(0, 16)}' +
'\n' +
'\n注:\n' +
'必需在开始时间24小时内使用一次否则将失效\n';
break; break;
case 4: case 4:
// 4 使使 // 4 使使
useDateStr = '类型'.tr + ':' + '清空'.tr; useDateStr = '类型'.tr + ':' + '清空'.tr;
break; break;
case 5: case 5:
// 5 // 5
useDateStr = '类型'.tr + ':' + '循环'.tr + '\n' + '周末'.tr + ' $starHour:00-$endHour:00'; useDateStr = '\n' +
'类型'.tr +
':' +
'循环'.tr +
'\n' +
'\n' +
'周末'.tr +
' $starHour:00-$endHour:00' +
'\n';
break; break;
case 6: case 6:
// 6 // 6
useDateStr = '类型'.tr + ':' + '循环'.tr + '\n' + '每日'.tr + ' $starHour:00-$endHour:00'; useDateStr = '\n' +
'类型'.tr +
':' +
'循环'.tr +
'\n' +
'\n' +
'每日'.tr +
' $starHour:00-$endHour:00' +
'\n';
break; break;
case 7: case 7:
// 7 // 7
useDateStr = '类型'.tr + ':' + '循环'.tr + '\n' + '工作日'.tr + ' $starHour:00-$endHour:00'; useDateStr = '\n' +
'类型'.tr +
':' +
'循环'.tr +
'\n' +
'\n' +
'工作日'.tr +
' $starHour:00-$endHour:00' +
'\n';
break; break;
case 8: case 8:
// 8 // 8
useDateStr = '类型'.tr + ':' + '循环'.tr + '\n' + '周一'.tr + ' $starHour:00-$endHour:00'; useDateStr = '\n' +
'类型'.tr +
':' +
'循环'.tr +
'\n' +
'\n' +
'周一'.tr +
' $starHour:00-$endHour:00' +
'\n';
break; break;
case 9: case 9:
// 9 // 9
useDateStr = '类型'.tr + ':' + '循环'.tr + '\n' + '周二'.tr + ' $starHour:00-$endHour:00'; useDateStr = '\n' +
'类型'.tr +
':' +
'循环'.tr +
'\n' +
'\n' +
'周二'.tr +
' $starHour:00-$endHour:00' +
'\n';
break; break;
case 10: case 10:
// 10 // 10
useDateStr = '类型'.tr + ':' + '循环'.tr + '\n' + '周三'.tr + ' $starHour:00-$endHour:00'; useDateStr = '\n' +
'类型'.tr +
':' +
'循环'.tr +
'\n' +
'\n' +
'周三'.tr +
' $starHour:00-$endHour:00' +
'\n';
break; break;
case 11: case 11:
// 11 // 11
useDateStr = '类型'.tr + ':' + '循环'.tr + '\n' + '周四'.tr + ' $starHour:00 -$endHour:00'; useDateStr = '\n' +
'类型'.tr +
':' +
'循环'.tr +
'\n' +
'\n' +
'周四'.tr +
' $starHour:00 -$endHour:00' +
'\n';
break; break;
case 12: case 12:
// 12 // 12
useDateStr = '类型'.tr + ':' + '循环'.tr + '\n' + '周五'.tr + ' $starHour:00-$endHour:00'; useDateStr = '\n' +
'类型'.tr +
':' +
'循环'.tr +
'\n' +
'\n' +
'周五'.tr +
' $starHour:00-$endHour:00' +
'\n';
break; break;
case 13: case 13:
// 13 // 13
useDateStr = '类型'.tr + ':' + '循环'.tr + '\n' + '周六'.tr + ' $starHour:00-$endHour:00'; useDateStr = '\n' +
'类型'.tr +
':' +
'循环'.tr +
'\n' +
'\n' +
'周六'.tr +
' $starHour:00-$endHour:00' +
'\n';
break; break;
case 14: case 14:
// 14 // 14
useDateStr = '类型'.tr + ':' + '循环'.tr + '\n' + '周日'.tr + ' $starHour:00-$endHour:00'; useDateStr = '\n' +
'类型'.tr +
':' +
'循环'.tr +
'\n' +
'\n' +
'周日'.tr +
' $starHour:00-$endHour:00' +
'\n';
break; break;
default: default:
} }
return '您好,您的密码是'.tr + ':${state.itemData.value.keyboardPwd}\n$useDateStr\n${'密码名字'.tr}:${state.itemData.value.keyboardPwdName}'; // return '您好,您的密码是'.tr + ':${state.itemData.value.keyboardPwd}\n$useDateStr\n${'密码名字'.tr}:${state.itemData.value.keyboardPwdName}';
return '您好' +
',\n您的开门密码是' +
':${state.itemData.value.keyboardPwd}\n$useDateStr\n${'密码名字'.tr}:${state.itemData.value.keyboardPwdName}\n\n开锁时,先激活锁键盘,再输入密码,以#号结束,#号键在键盘右下角,有可能是其他图标';
} }
@override @override
@ -341,5 +552,4 @@ class PasswordKeyDetailLogic extends BaseGetXController {
void onClose() { void onClose() {
_replySubscription.cancel(); _replySubscription.cancel();
} }
} }

View File

@ -183,10 +183,11 @@ class PasswordKeyPerpetualLogic extends BaseGetXController {
final String getMobile = (await Storage.getMobile())!; final String getMobile = (await Storage.getMobile())!;
if (entity.errorCode!.codeIsSuccessful) { if (entity.errorCode!.codeIsSuccessful) {
ApmHelper.instance.trackEvent('add_password', { ApmHelper.instance.trackEvent('add_password', {
'lock_name':BlueManage().connectDeviceName, 'lock_name': BlueManage().connectDeviceName,
'account':getMobile.isNotEmpty ? getMobile : (await Storage.getEmail())!, 'account':
'date':DateTool().getNowDateWithType(1), getMobile.isNotEmpty ? getMobile : (await Storage.getEmail())!,
'add_password_result':'成功', 'date': DateTool().getNowDateWithType(1),
'add_password_result': '成功',
}); });
state.isSendSuccess.value = true; state.isSendSuccess.value = true;
@ -200,10 +201,11 @@ class PasswordKeyPerpetualLogic extends BaseGetXController {
} }
} else { } else {
ApmHelper.instance.trackEvent('add_password', { ApmHelper.instance.trackEvent('add_password', {
'lock_name':BlueManage().connectDeviceName, 'lock_name': BlueManage().connectDeviceName,
'account':getMobile.isNotEmpty ? getMobile : (await Storage.getEmail())!, 'account':
'date':DateTool().getNowDateWithType(1), getMobile.isNotEmpty ? getMobile : (await Storage.getEmail())!,
'add_password_result':'${entity.errorMsg}', 'date': DateTool().getNowDateWithType(1),
'add_password_result': '${entity.errorMsg}',
}); });
showToast('${entity.errorMsg}'); showToast('${entity.errorMsg}');
} }
@ -244,15 +246,16 @@ class PasswordKeyPerpetualLogic extends BaseGetXController {
late StreamSubscription<Reply> _replySubscription; late StreamSubscription<Reply> _replySubscription;
void _initReplySubscription() { void _initReplySubscription() {
_replySubscription = EventBusManager().eventBus!.on<Reply>().listen((Reply 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)) {
BuglyTool.uploadException( BuglyTool.uploadException(
message: '添加密码结果,解析数据', message: '添加密码结果,解析数据',
detail: '添加密码结果,解析数据:${reply.data}', detail: '添加密码结果,解析数据:${reply.data}',
eventStr: '添加密码事件结果', eventStr: '添加密码事件结果',
upload: true upload: true);
);
final int status = reply.data[2]; final int status = reply.data[2];
switch (status) { switch (status) {
@ -393,45 +396,45 @@ class PasswordKeyPerpetualLogic extends BaseGetXController {
final List<String>? signKey = await Storage.getStringList(saveBlueSignKey); final List<String>? signKey = await Storage.getStringList(saveBlueSignKey);
final List<int> signKeyDataList = changeStringListToIntList(signKey!); final List<int> signKeyDataList = changeStringListToIntList(signKey!);
final List<String>? privateKey = await Storage.getStringList(saveBluePrivateKey); final List<String>? privateKey =
await Storage.getStringList(saveBluePrivateKey);
final List<int> getPrivateKeyList = changeStringListToIntList(privateKey!); final List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
final List<String>? token = await Storage.getStringList(saveBlueToken); final List<String>? token = await Storage.getStringList(saveBlueToken);
final List<int> getTokenList = changeStringListToIntList(token!); final List<int> getTokenList = changeStringListToIntList(token!);
final String command = SenderCustomPasswordsCommand( final String command = 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,
operate: 0, operate: 0,
isAdmin: state.isAdministrator.value == true ? 1 : 0, isAdmin: state.isAdministrator.value == true ? 1 : 0,
useCountLimit: 0xffff, useCountLimit: 0xffff,
startTime: startDate ~/ 1000, startTime: startDate ~/ 1000,
endTime: endDate ~/ 1000, endTime: endDate ~/ 1000,
needAuthor: 1, needAuthor: 1,
signKey: signKeyDataList, signKey: signKeyDataList,
privateKey: getPrivateKeyList, privateKey: getPrivateKeyList,
token: getTokenList token: getTokenList)
).toString(); .toString();
showEasyLoading(); showEasyLoading();
showBlueConnetctToastTimer(action: () async { showBlueConnetctToastTimer(action: () async {
final String getMobile = (await Storage.getMobile())!; final String getMobile = (await Storage.getMobile())!;
ApmHelper.instance.trackEvent('add_password', { ApmHelper.instance.trackEvent('add_password', {
'lock_name':BlueManage().connectDeviceName, 'lock_name': BlueManage().connectDeviceName,
'account':getMobile.isNotEmpty ? getMobile : (await Storage.getEmail())!, 'account':
'date':DateTool().getNowDateWithType(1), getMobile.isNotEmpty ? getMobile : (await Storage.getEmail())!,
'add_password_result':'添加自定义密码超时', 'date': DateTool().getNowDateWithType(1),
'add_password_result': '添加自定义密码超时',
}); });
BuglyTool.uploadException( BuglyTool.uploadException(
message: '添加密码超时处理-添加密码失败', message: '添加密码超时处理-添加密码失败',
detail: '添加密码超时,添加密码失败--senderCustomPasswordsCommand:$command', detail: '添加密码超时,添加密码失败--senderCustomPasswordsCommand:$command',
eventStr: '添加密码事件超时', eventStr: '添加密码事件超时',
upload: true upload: true);
);
dismissEasyLoading(); dismissEasyLoading();
state.sureBtnState.value = 0; state.sureBtnState.value = 0;
@ -439,11 +442,14 @@ class PasswordKeyPerpetualLogic extends BaseGetXController {
BlueManage().blueSendData(BlueManage().connectDeviceName, BlueManage().blueSendData(BlueManage().connectDeviceName,
(BluetoothConnectionState deviceConnectionState) async { (BluetoothConnectionState deviceConnectionState) async {
if (deviceConnectionState == BluetoothConnectionState.connected) { if (deviceConnectionState == BluetoothConnectionState.connected) {
final List<String>? signKey = await Storage.getStringList(saveBlueSignKey); final List<String>? signKey =
await Storage.getStringList(saveBlueSignKey);
final List<int> signKeyDataList = changeStringListToIntList(signKey!); final List<int> signKeyDataList = changeStringListToIntList(signKey!);
final List<String>? privateKey = await Storage.getStringList(saveBluePrivateKey); final List<String>? privateKey =
final List<int> getPrivateKeyList = changeStringListToIntList(privateKey!); await Storage.getStringList(saveBluePrivateKey);
final List<int> getPrivateKeyList =
changeStringListToIntList(privateKey!);
final List<String>? token = await Storage.getStringList(saveBlueToken); final List<String>? token = await Storage.getStringList(saveBlueToken);
final List<int> getTokenList = changeStringListToIntList(token!); final List<int> getTokenList = changeStringListToIntList(token!);
@ -463,21 +469,22 @@ class PasswordKeyPerpetualLogic extends BaseGetXController {
signKey: signKeyDataList, signKey: signKeyDataList,
privateKey: getPrivateKeyList, privateKey: getPrivateKeyList,
token: getTokenList); token: getTokenList);
} else if (deviceConnectionState == BluetoothConnectionState.disconnected) { } else if (deviceConnectionState ==
BluetoothConnectionState.disconnected) {
final String getMobile = (await Storage.getMobile())!; final String getMobile = (await Storage.getMobile())!;
ApmHelper.instance.trackEvent('add_password', { ApmHelper.instance.trackEvent('add_password', {
'lock_name':BlueManage().connectDeviceName, 'lock_name': BlueManage().connectDeviceName,
'account':getMobile.isNotEmpty ? getMobile : (await Storage.getEmail())!, 'account':
'date':DateTool().getNowDateWithType(1), getMobile.isNotEmpty ? getMobile : (await Storage.getEmail())!,
'add_password_result':'添加自定义密码断开', 'date': DateTool().getNowDateWithType(1),
'add_password_result': '添加自定义密码断开',
}); });
BuglyTool.uploadException( BuglyTool.uploadException(
message: '添加密码断开-添加密码失败', message: '添加密码断开-添加密码失败',
detail: '添加密码断开,添加密码失败--senderCustomPasswordsCommand:$command', detail: '添加密码断开,添加密码失败--senderCustomPasswordsCommand:$command',
eventStr: '添加密码事件断开连接', eventStr: '添加密码事件断开连接',
upload: true upload: true);
);
dismissEasyLoading(); dismissEasyLoading();
cancelBlueConnetctToastTimer(); cancelBlueConnetctToastTimer();
@ -492,27 +499,49 @@ class PasswordKeyPerpetualLogic extends BaseGetXController {
String getShareContentStr() { String getShareContentStr() {
final int getPwdType = state.widgetType.value; final int getPwdType = state.widgetType.value;
String useDateStr = ''; String useDateStr = '';
// DateTime startDateStr = DateTime.fromMillisecondsSinceEpoch(state.itemData.value.startDate!);
// DateTime endDateStr = DateTime.fromMillisecondsSinceEpoch(state.itemData.value.endDate!); DateTime startDateStr = DateTime.parse(state.beginTime.value)!;
// int starHour = startDateStr.hour; DateTime endDateStr = DateTime.parse(state.endTime.value)!;
// int endHour = endDateStr.hour;
int starHour = startDateStr.hour;
int endHour = endDateStr.hour;
switch (getPwdType) { switch (getPwdType) {
case 2:
// 1 6使
useDateStr = '\n' +
'类型'.tr +
':' +
'单次'.tr +
'\n' +
'\n' +
'有效期'.tr +
':${startDateStr.toLocal().toString().substring(0, 16)} -- ${endDateStr.toLocal().toString().substring(0, 16)}\n\n' +
'这是单次密码,只能使用一次\n';
break;
case 0: case 0:
// 24使 // 2 24使
useDateStr = '类型'.tr + ':' + '永久'; useDateStr = '\n' +
'类型'.tr +
':' +
'永久'.tr +
'\n' +
'\n注:\n' +
'必需在开始时间24小时内使用一次否则将失效\n';
break; break;
case 1: case 1:
// 24使 // 3 24使
useDateStr = '类型'.tr + useDateStr = '\n' +
'类型'.tr +
':' + ':' +
'限时\n${'有效期'.tr}:${state.beginTime.value} -- ${state.endTime.value}'; '限时'.tr +
break; '\n' +
case 2: '\n' +
// 6使 '有效期'.tr +
useDateStr = '类型'.tr + ':${startDateStr.toLocal().toString().substring(0, 16)}-${endDateStr.toLocal().toString().substring(0, 16)}' +
':' + '\n' +
'单次\n${'有效期'.tr}:${state.beginTime.value} -- ${state.endTime.value}'; '\n注:\n' +
'必需在开始时间24小时内使用一次否则将失效\n';
break; break;
case 3: case 3:
// //
@ -524,20 +553,177 @@ class PasswordKeyPerpetualLogic extends BaseGetXController {
useDateStr = '类型:自定义-永久'.tr; useDateStr = '类型:自定义-永久'.tr;
} }
break; break;
case 4:
//
useDateStr = '类型'.tr +
':' +
'循环\n${state.loopModeStr.value} ${state.loopEffectiveDate.value}:00-${state.loopFailureDate.value}';
break;
case 5: case 5:
// 4 使使 // 4 使使
useDateStr = '类型:清空'; useDateStr = '类型'.tr + ':' + '清空'.tr;
break;
case 4:
// 5
useDateStr = '\n' +
'类型'.tr +
':' +
'循环'.tr +
'\n' +
'\n' +
'周末'.tr +
' $starHour:00-$endHour:00' +
'\n';
break;
case 6:
// 6
useDateStr = '\n' +
'类型'.tr +
':' +
'循环'.tr +
'\n' +
'\n' +
'每日'.tr +
' $starHour:00-$endHour:00' +
'\n';
break;
case 7:
// 7
useDateStr = '\n' +
'类型'.tr +
':' +
'循环'.tr +
'\n' +
'\n' +
'工作日'.tr +
' $starHour:00-$endHour:00' +
'\n';
break;
case 8:
// 8
useDateStr = '\n' +
'类型'.tr +
':' +
'循环'.tr +
'\n' +
'\n' +
'周一'.tr +
' $starHour:00-$endHour:00' +
'\n';
break;
case 9:
// 9
useDateStr = '\n' +
'类型'.tr +
':' +
'循环'.tr +
'\n' +
'\n' +
'周二'.tr +
' $starHour:00-$endHour:00' +
'\n';
break;
case 10:
// 10
useDateStr = '\n' +
'类型'.tr +
':' +
'循环'.tr +
'\n' +
'\n' +
'周三'.tr +
' $starHour:00-$endHour:00' +
'\n';
break;
case 11:
// 11
useDateStr = '\n' +
'类型'.tr +
':' +
'循环'.tr +
'\n' +
'\n' +
'周四'.tr +
' $starHour:00 -$endHour:00' +
'\n';
break;
case 12:
// 12
useDateStr = '\n' +
'类型'.tr +
':' +
'循环'.tr +
'\n' +
'\n' +
'周五'.tr +
' $starHour:00-$endHour:00' +
'\n';
break;
case 13:
// 13
useDateStr = '\n' +
'类型'.tr +
':' +
'循环'.tr +
'\n' +
'\n' +
'周六'.tr +
' $starHour:00-$endHour:00' +
'\n';
break;
case 14:
// 14
useDateStr = '\n' +
'类型'.tr +
':' +
'循环'.tr +
'\n' +
'\n' +
'周日'.tr +
' $starHour:00-$endHour:00' +
'\n';
break; break;
default: default:
} }
return '${'您好,您的密码是'.tr}:${state.getPwdStr.value}\n$useDateStr\n${'密码名字'.tr}:${state.pwdNameStr}'; // return '您好,您的密码是'.tr + ':${state.itemData.value.keyboardPwd}\n$useDateStr\n${'密码名字'.tr}:${state.itemData.value.keyboardPwdName}';
return '您好' +
',\n您的开门密码是' +
':${state.getPwdStr.value}\n$useDateStr\n${'密码名字'.tr}:${state.pwdNameStr}\n\n开锁时,先激活锁键盘,再输入密码,以#号结束,#号键在键盘右下角,有可能是其他图标';
// switch (getPwdType) {
// case 0:
// // 24使
// useDateStr = '类型'.tr + ':' + '永久';
// break;
// case 1:
// // 24使
// useDateStr = '类型'.tr +
// ':' +
// '限时\n${'有效期'.tr}:${state.beginTime.value} -- ${state.endTime.value}';
// break;
// case 2:
// // 6使
// useDateStr = '类型'.tr +
// ':' +
// '单次\n${'有效期'.tr}:${state.beginTime.value} -- ${state.endTime.value}';
// break;
// case 3:
// //
// if (state.isPermanent.value == false) {
// useDateStr = '类型'.tr +
// ':' +
// '自定义-限时\n${'有效期'.tr}:${state.customBeginTime.value} -- ${state.customEndTime.value}';
// } else {
// useDateStr = '类型:自定义-永久'.tr;
// }
// break;
// case 4:
// //
// useDateStr = '类型'.tr +
// ':' +
// '循环\n${state.loopModeStr.value} ${state.loopEffectiveDate.value}:00-${state.loopFailureDate.value}';
// break;
// case 5:
// // 4 使使
// useDateStr = '类型:清空';
// break;
//
// default:
// }
// return '${'您好,您的密码是'.tr}:${state.getPwdStr.value}\n$useDateStr\n${'密码名字'.tr}:${state.pwdNameStr}';
} }
String addSpaces(String input) { String addSpaces(String input) {

View File

@ -23,6 +23,7 @@ class PasswordKeyPerpetualState {
RxString beginTime = DateTool().getNowDateWithType(3).obs; // RxString beginTime = DateTool().getNowDateWithType(3).obs; //
RxString endTime = DateTool().getNowDateWithType(3).obs; // RxString endTime = DateTool().getNowDateWithType(3).obs; //
RxString loopEffectiveDate = DateTool().getNowDateWithType(7).obs; // RxString loopEffectiveDate = DateTool().getNowDateWithType(7).obs; //
RxString loopFailureDate = DateTool().getNowDateWithType(7).obs; // RxString loopFailureDate = DateTool().getNowDateWithType(7).obs; //
RxInt loopStartHours = DateTime.now().hour.obs; RxInt loopStartHours = DateTime.now().hour.obs;