添加添加删除重置自定义密码逻辑
This commit is contained in:
parent
b369a9db3f
commit
6df2ae7290
@ -82,6 +82,7 @@ class SenderCustomPasswordsCommand extends SenderProtocol {
|
||||
|
||||
// UseCountLimit
|
||||
subData.add(useCountLimit!);
|
||||
print("useCountLimituseCountLimituseCountLimit:$useCountLimit");
|
||||
|
||||
// token
|
||||
subData.addAll(token!);
|
||||
|
||||
@ -22,21 +22,21 @@ abstract class Reply{
|
||||
break;
|
||||
case 0x01:
|
||||
// 包格式错误
|
||||
Get.log("${commandType!.typeName}包格式错误");
|
||||
Get.log("${commandType!.typeName} 包格式错误");
|
||||
showErrorMessage("包格式错误");
|
||||
break;
|
||||
case 0x02:
|
||||
// 密码错误
|
||||
Get.log("${commandType!.typeName}密码错误");
|
||||
Get.log("${commandType!.typeName} 密码错误");
|
||||
showErrorMessage("密码错误");
|
||||
break;
|
||||
case 0x03:
|
||||
// 网络中断
|
||||
Get.log("${commandType!.typeName}网络中断");
|
||||
Get.log("${commandType!.typeName} 网络中断");
|
||||
break;
|
||||
case 0x04:
|
||||
// 用户未登记
|
||||
Get.log("${commandType!.typeName}用户未登记");
|
||||
Get.log("${commandType!.typeName} 用户未登记");
|
||||
showErrorMessage("用户未登记");
|
||||
break;
|
||||
case 0x05:
|
||||
|
||||
@ -146,14 +146,14 @@ class _BasicInformationPageState extends State<BasicInformationPage> {
|
||||
Obx(() => Visibility(
|
||||
visible: state.lockBasicInfo.value.lockName!.contains("T9A"),
|
||||
child: CommonItem(
|
||||
leftTitel: "当前网络",
|
||||
rightTitle: state.lockBasicInfo.value.lockName ?? "",
|
||||
leftTitel: "当前网络".tr,
|
||||
rightTitle: state.lockBasicInfo.value.network ?? "-",
|
||||
allHeight: 70.h,
|
||||
isHaveLine: true),
|
||||
)),
|
||||
Obx(() => CommonItem(
|
||||
leftTitel: "位置信息",
|
||||
rightTitle: state.lockBasicInfo.value.lockName ?? "",
|
||||
leftTitel: "位置信息".tr,
|
||||
rightTitle: state.lockBasicInfo.value.address ?? "-",
|
||||
allHeight: 70.h,
|
||||
isHaveLine: true)),
|
||||
/* 2024-01-12 会议确定去掉“微信二维码” by DaisyWu
|
||||
|
||||
@ -339,6 +339,8 @@ class LockBasicInfo {
|
||||
int? senderUserId;
|
||||
int? lockUserNo;
|
||||
List? weekDays;
|
||||
String? address;
|
||||
String? network;
|
||||
|
||||
LockBasicInfo(
|
||||
{this.lockId,
|
||||
@ -361,7 +363,9 @@ class LockBasicInfo {
|
||||
this.keyRight,
|
||||
this.senderUserId,
|
||||
this.lockUserNo,
|
||||
this.weekDays});
|
||||
this.weekDays,
|
||||
this.address,
|
||||
this.network});
|
||||
|
||||
LockBasicInfo.fromJson(Map<String, dynamic> json) {
|
||||
lockId = json['lockId'];
|
||||
@ -390,6 +394,8 @@ class LockBasicInfo {
|
||||
senderUserId = json['senderUserId'];
|
||||
lockUserNo = json['lockUserNo'];
|
||||
weekDays = json['weekDays'];
|
||||
address = json['address'];
|
||||
network = json['network'];
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
@ -417,6 +423,8 @@ class LockBasicInfo {
|
||||
data['senderUserId'] = senderUserId;
|
||||
data['lockUserNo'] = lockUserNo;
|
||||
data['weekDays'] = weekDays;
|
||||
data['address'] = address;
|
||||
data['network'] = network;
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,3 +1,6 @@
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:flutter_blue_plus/flutter_blue_plus.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:star_lock/main/lockDetail/passwordKey/passwordKeyDetail/passwordKeyDetail_state.dart';
|
||||
import 'package:star_lock/main/lockDetail/passwordKey/passwordKey_perpetual/passwordKeyEntity.dart';
|
||||
@ -5,15 +8,72 @@ import 'package:star_lock/network/api_repository.dart';
|
||||
import 'package:star_lock/tools/baseGetXController.dart';
|
||||
import 'package:star_lock/tools/eventBusEventManage.dart';
|
||||
|
||||
import '../../../../blue/blue_manage.dart';
|
||||
import '../../../../blue/io_protocol/io_senderCustomPasswords.dart';
|
||||
import '../../../../blue/io_reply.dart';
|
||||
import '../../../../blue/io_tool/io_tool.dart';
|
||||
import '../../../../blue/io_tool/manager_event_bus.dart';
|
||||
import '../../../../blue/sender_manage.dart';
|
||||
import '../../../../tools/storage.dart';
|
||||
|
||||
class PasswordKeyDetailLogic extends BaseGetXController {
|
||||
PasswordKeyDetailState state = PasswordKeyDetailState();
|
||||
|
||||
// 监听设备返回的数据
|
||||
late StreamSubscription<Reply> _replySubscription;
|
||||
void _initReplySubscription() {
|
||||
_replySubscription = EventBusManager().eventBus!.on<Reply>().listen((reply) async {
|
||||
// 设置自定义密码
|
||||
if ((reply is SenderCustomPasswordsReply) && (state.ifCurrentScreen.value == true)) {
|
||||
var token = reply.data.sublist(5, 9);
|
||||
var saveStrList = changeIntListToStringList(token);
|
||||
Storage.setStringList(saveBlueToken, saveStrList);
|
||||
|
||||
int status = reply.data[2];
|
||||
switch (status) {
|
||||
case 0x00:
|
||||
//成功
|
||||
state.sureBtnState.value = 0;
|
||||
dismissEasyLoading();
|
||||
cancelBlueConnetctToastTimer();
|
||||
deletePwdRequest();
|
||||
break;
|
||||
case 0x06:
|
||||
//无权限
|
||||
var privateKey = await Storage.getStringList(saveBluePrivateKey);
|
||||
List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
|
||||
|
||||
var signKey = await Storage.getStringList(saveBlueSignKey);
|
||||
List<int> signKeyDataList = changeStringListToIntList(signKey!);
|
||||
|
||||
IoSenderManage.senderCustomPasswordsCommand(
|
||||
keyID:state.keyId.value.toString(),
|
||||
userID:await Storage.getUid(),
|
||||
pwdNo: state.keyboardUserNo.value,
|
||||
pwd: "000000",
|
||||
useCountLimit: 0,
|
||||
startTime:0x11223344,
|
||||
endTime:0x11223344,
|
||||
needAuthor: 1,
|
||||
signKey: signKeyDataList,
|
||||
privateKey: getPrivateKeyList,
|
||||
token: token);
|
||||
break;
|
||||
default:
|
||||
//失败
|
||||
cancelBlueConnetctToastTimer();
|
||||
break;
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
//删除密码请求 deleteType:1-蓝牙 2-网关
|
||||
Future<void> deletePwdRequest() async {
|
||||
PasswordKeyEntity entity = await ApiRepository.to.deleteKeyboardPwd(
|
||||
state.itemData.value.lockId.toString(),
|
||||
state.itemData.value.keyboardPwdId.toString(),
|
||||
1);
|
||||
lockId:state.itemData.value.lockId.toString(),
|
||||
keyboardPwdId:state.itemData.value.keyboardPwdId.toString(),
|
||||
deleteType:1);
|
||||
if (entity.errorCode!.codeIsSuccessful) {
|
||||
showToast("删除成功".tr, something: (){
|
||||
Get.back(result: "deletScuess");
|
||||
@ -50,6 +110,48 @@ class PasswordKeyDetailLogic extends BaseGetXController {
|
||||
}
|
||||
}
|
||||
|
||||
// 设置自定义密码 这里用作删除密码
|
||||
Future<void> senderCustomPasswords() async {
|
||||
|
||||
showEasyLoading();
|
||||
showBlueConnetctToastTimer(action: (){
|
||||
dismissEasyLoading();
|
||||
state.sureBtnState.value = 0;
|
||||
});
|
||||
BlueManage().bludSendData(BlueManage().connectDeviceName, (BluetoothConnectionState deviceConnectionState) async {
|
||||
if (deviceConnectionState == BluetoothConnectionState.connected) {
|
||||
var signKey = await Storage.getStringList(saveBlueSignKey);
|
||||
List<int> signKeyDataList = changeStringListToIntList(signKey!);
|
||||
|
||||
var privateKey = await Storage.getStringList(saveBluePrivateKey);
|
||||
List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
|
||||
|
||||
var token = await Storage.getStringList(saveBlueToken);
|
||||
List<int> getTokenList = changeStringListToIntList(token!);
|
||||
|
||||
IoSenderManage.senderCustomPasswordsCommand(
|
||||
keyID:state.keyId.value.toString(),
|
||||
userID:await Storage.getUid(),
|
||||
pwdNo: state.keyboardUserNo.value,
|
||||
pwd: "000000",
|
||||
useCountLimit: 0,
|
||||
startTime:0x11223344,
|
||||
endTime:0x11223344,
|
||||
needAuthor: 1,
|
||||
signKey: signKeyDataList,
|
||||
privateKey: getPrivateKeyList,
|
||||
token: getTokenList);
|
||||
} else if (deviceConnectionState == BluetoothConnectionState.disconnected) {
|
||||
dismissEasyLoading();
|
||||
cancelBlueConnetctToastTimer();
|
||||
state.sureBtnState.value = 0;
|
||||
if(state.ifCurrentScreen.value == true){
|
||||
showBlueConnetctToast();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
//使用期限详情显示
|
||||
String getUseDateStr() {
|
||||
int? getPwdType = state.itemData.value.keyboardPwdType;
|
||||
@ -213,4 +315,25 @@ class PasswordKeyDetailLogic extends BaseGetXController {
|
||||
return "您好,您的密码是:${state.itemData.value.keyboardPwd}\n$useDateStr\n密码名字:${state.itemData.value.keyboardPwdName}";
|
||||
}
|
||||
|
||||
@override
|
||||
void onReady() {
|
||||
// TODO: implement onReady
|
||||
super.onReady();
|
||||
|
||||
_initReplySubscription();
|
||||
// getPasswordTypeUpdateIndexAction();
|
||||
}
|
||||
|
||||
@override
|
||||
void onInit() {
|
||||
// TODO: implement onInit
|
||||
super.onInit();
|
||||
}
|
||||
|
||||
@override
|
||||
void onClose() {
|
||||
// TODO: implement onClose
|
||||
_replySubscription.cancel();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -6,12 +6,13 @@ import 'package:star_lock/main/lockDetail/passwordKey/passwordKeyDetail/password
|
||||
import 'package:star_lock/main/lockDetail/passwordKey/passwordKeyList/passwordKeyListEntity.dart';
|
||||
import 'package:star_lock/tools/dateTool.dart';
|
||||
import 'package:star_lock/tools/showTFView.dart';
|
||||
import 'package:star_lock/tools/showTipView.dart';
|
||||
|
||||
import '../../../../appRouters.dart';
|
||||
import '../../../../app_settings/app_colors.dart';
|
||||
import '../../../../tools/NativeInteractionTool.dart';
|
||||
import '../../../../tools/appRouteObserver.dart';
|
||||
import '../../../../tools/commonItem.dart';
|
||||
import '../../../../tools/showIosTipView.dart';
|
||||
import '../../../../tools/submitBtn.dart';
|
||||
import '../../../../tools/titleAppBar.dart';
|
||||
import '../../../../translations/trans_lib.dart';
|
||||
@ -23,7 +24,7 @@ class PasswordKeyDetailPage extends StatefulWidget {
|
||||
State<PasswordKeyDetailPage> createState() => _PasswordKeyDetailPageState();
|
||||
}
|
||||
|
||||
class _PasswordKeyDetailPageState extends State<PasswordKeyDetailPage> {
|
||||
class _PasswordKeyDetailPageState extends State<PasswordKeyDetailPage> with RouteAware {
|
||||
final logic = Get.put(PasswordKeyDetailLogic());
|
||||
final state = Get.find<PasswordKeyDetailLogic>().state;
|
||||
|
||||
@ -200,7 +201,9 @@ class _PasswordKeyDetailPageState extends State<PasswordKeyDetailPage> {
|
||||
left: 30.w, right: 30.w, top: 30.w, bottom: 30.w),
|
||||
padding: EdgeInsets.only(top: 25.w, bottom: 25.w),
|
||||
onClick: () {
|
||||
showIosTipViewDialog(context);
|
||||
ShowTipView().showIosTipWithContentDialog("确定要删除吗?".tr, (){
|
||||
logic.senderCustomPasswords();
|
||||
});
|
||||
}),
|
||||
],
|
||||
),
|
||||
@ -364,21 +367,58 @@ class _PasswordKeyDetailPageState extends State<PasswordKeyDetailPage> {
|
||||
}
|
||||
}
|
||||
|
||||
void showIosTipViewDialog(BuildContext context) {
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (BuildContext context) {
|
||||
return ShowIosTipView(
|
||||
title: "提示",
|
||||
tipTitle: "确定要删除吗?",
|
||||
sureClick: () {
|
||||
Get.back();
|
||||
logic.deletePwdRequest();
|
||||
},
|
||||
cancelClick: () {
|
||||
Get.back();
|
||||
},
|
||||
);
|
||||
});
|
||||
@override
|
||||
void didChangeDependencies() {
|
||||
// TODO: implement didChangeDependencies
|
||||
super.didChangeDependencies();
|
||||
|
||||
/// 路由订阅
|
||||
AppRouteObserver().routeObserver.subscribe(this, ModalRoute.of(context)!);
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
// TODO: implement dispose
|
||||
/// 取消路由订阅
|
||||
AppRouteObserver().routeObserver.unsubscribe(this);
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
/// 从上级界面进入 当前界面即将出现
|
||||
@override
|
||||
void didPush() {
|
||||
super.didPush();
|
||||
Get.log("PasswordKeyDetailPage===didPush");
|
||||
state.ifCurrentScreen.value = true;
|
||||
}
|
||||
|
||||
/// 返回上一个界面 当前界面即将消失
|
||||
@override
|
||||
void didPop() {
|
||||
super.didPop();
|
||||
Get.log("PasswordKeyDetailPage===didPop");
|
||||
logic.cancelBlueConnetctToastTimer();
|
||||
logic.dismissEasyLoading();
|
||||
state.ifCurrentScreen.value = false;
|
||||
state.sureBtnState.value = 0;
|
||||
}
|
||||
|
||||
/// 从下级返回 当前界面即将出现
|
||||
@override
|
||||
void didPopNext() {
|
||||
super.didPopNext();
|
||||
Get.log("PasswordKeyDetailPage===didPopNext");
|
||||
state.ifCurrentScreen.value = true;
|
||||
}
|
||||
|
||||
/// 进入下级界面 当前界面即将消失
|
||||
@override
|
||||
void didPushNext() {
|
||||
super.didPushNext();
|
||||
Get.log("PasswordKeyDetailPage===didPushNext");
|
||||
logic.cancelBlueConnetctToastTimer();
|
||||
logic.dismissEasyLoading();
|
||||
state.ifCurrentScreen.value = false;
|
||||
state.sureBtnState.value = 0;
|
||||
}
|
||||
}
|
||||
|
||||
@ -7,16 +7,17 @@ class PasswordKeyDetailState {
|
||||
final TextEditingController inputPwdController = TextEditingController();
|
||||
final TextEditingController inputNameController = TextEditingController();
|
||||
final changeType = '1'.obs; //1-通过APP走蓝牙修改,不传默认1,必需先通过APP SDK蓝牙修改后调用该接口 2-通过网关或WiFi锁修改,如果是WiFi锁或有连接网关,则可以传2,直接调用该接口修改生效
|
||||
final keyboardPwd = ''.obs;
|
||||
final keyboardPwd = ''.obs;//
|
||||
final keyboardUserNo = 0.obs;//
|
||||
final keyboardPwdName = ''.obs;
|
||||
final keyboardPwdType = ''.obs;// 1单次 2永久 3限时 4删除 5周末循环 6周日循环 7工作日循环 8周一循环 9周二循环 10周三循环 11周四循环 12周五循环 13周六循环 14周天循环
|
||||
final isCirculation = false.obs;// 是否是循环
|
||||
var keyId = 0.obs;// 卡id
|
||||
|
||||
var ifCurrentScreen = true.obs; // 是否是当前界面,用于判断是否需要针对当前界面进行展示
|
||||
var sureBtnState = 0.obs;// 0普通状态(可用) 1连接中(不可用)
|
||||
final passwordKeyNumber = "".obs;// 密码号
|
||||
|
||||
// final hoursStart = 0.obs;
|
||||
// final hoursEnd = 0.obs;
|
||||
// final startDate = 0.obs;
|
||||
// final endDate = 0.obs;
|
||||
//
|
||||
PasswordKeyDetailState() {
|
||||
Map map = Get.arguments;
|
||||
itemData.value = map["itemData"];
|
||||
@ -25,6 +26,9 @@ class PasswordKeyDetailState {
|
||||
keyboardPwdName.value = itemData.value.keyboardPwdName!;
|
||||
inputNameController.text = itemData.value.keyboardPwdName!;
|
||||
inputPwdController.text = itemData.value.keyboardPwd!;
|
||||
keyId.value = itemData.value.keyboardPwdId!;
|
||||
keyboardUserNo.value = itemData.value.pwdUserNo!;
|
||||
|
||||
// startDate.value = itemData.value.startDate!;
|
||||
// endDate.value = itemData.value.endDate!;
|
||||
// hoursStart.value = itemData.value.hoursStart!;
|
||||
|
||||
@ -82,6 +82,7 @@ class PasswordKeyListItem {
|
||||
int? isCoerced;
|
||||
int? hoursStart;
|
||||
int? hoursEnd;
|
||||
int? pwdUserNo;
|
||||
|
||||
PasswordKeyListItem(
|
||||
{this.apiUserId,
|
||||
@ -100,7 +101,8 @@ class PasswordKeyListItem {
|
||||
this.validTimeStr,
|
||||
this.isCoerced,
|
||||
this.hoursStart,
|
||||
this.hoursEnd});
|
||||
this.hoursEnd,
|
||||
this.pwdUserNo});
|
||||
|
||||
PasswordKeyListItem.fromJson(Map<String, dynamic> json) {
|
||||
apiUserId = json['apiUserId'];
|
||||
@ -120,6 +122,7 @@ class PasswordKeyListItem {
|
||||
isCoerced = json['isCoerced'];
|
||||
hoursStart = json['hoursStart'];
|
||||
hoursEnd = json['hoursEnd'];
|
||||
pwdUserNo = json['pwdUserNo'];
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
@ -141,6 +144,7 @@ class PasswordKeyListItem {
|
||||
data['isCoerced'] = isCoerced;
|
||||
data['hoursStart'] = hoursStart;
|
||||
data['hoursEnd'] = hoursEnd;
|
||||
data['pwdUserNo'] = pwdUserNo;
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,17 +1,91 @@
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:flutter_blue_plus/flutter_blue_plus.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:star_lock/blue/io_type.dart';
|
||||
import 'package:star_lock/main/lockDetail/passwordKey/passwordKeyList/passwordKeyListEntity.dart';
|
||||
import 'package:star_lock/main/lockDetail/passwordKey/passwordKeyList/passwordKeyList_state.dart';
|
||||
import 'package:star_lock/network/api_repository.dart';
|
||||
import 'package:star_lock/tools/baseGetXController.dart';
|
||||
|
||||
import '../../../../blue/blue_manage.dart';
|
||||
import '../../../../blue/io_protocol/io_senderCustomPasswords.dart';
|
||||
import '../../../../blue/io_reply.dart';
|
||||
import '../../../../blue/io_tool/io_tool.dart';
|
||||
import '../../../../blue/io_tool/manager_event_bus.dart';
|
||||
import '../../../../blue/sender_manage.dart';
|
||||
import '../../../../tools/eventBusEventManage.dart';
|
||||
import '../../../../tools/storage.dart';
|
||||
import '../passwordKey_perpetual/passwordKeyEntity.dart';
|
||||
|
||||
class PasswordKeyListLogic extends BaseGetXController {
|
||||
final PasswordKeyListState state = PasswordKeyListState();
|
||||
|
||||
// 获取解析后的数据
|
||||
late StreamSubscription<Reply> _replySubscription;
|
||||
void _initReplySubscription() {
|
||||
_replySubscription = EventBusManager().eventBus!.on<Reply>().listen((reply) {
|
||||
|
||||
// 添加卡片开始(重置锁里面所有卡)
|
||||
if((reply is SenderCustomPasswordsReply) && (state.ifCurrentScreen.value == true)) {
|
||||
_replyAddICCardBegin(reply);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// 添加卡片开始(此处用作删除卡片)
|
||||
Future<void> _replyAddICCardBegin(Reply reply) async {
|
||||
int status = reply.data[2];
|
||||
|
||||
switch(status){
|
||||
case 0x00:
|
||||
//成功
|
||||
Get.log("${reply.commandType!.typeValue} 数据解析成功");
|
||||
state.isDeletPWDData = false;
|
||||
cancelBlueConnetctToastTimer();
|
||||
if(state.isDeletAll){
|
||||
resetPasswordKeyListRequest();
|
||||
}else{
|
||||
deletePwdRequest();
|
||||
}
|
||||
break;
|
||||
case 0x06:
|
||||
//无权限
|
||||
Get.log("${reply.commandType!.typeValue} 需要鉴权");
|
||||
var privateKey = await Storage.getStringList(saveBluePrivateKey);
|
||||
List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
|
||||
|
||||
var signKey = await Storage.getStringList(saveBlueSignKey);
|
||||
List<int> signKeyDataList = changeStringListToIntList(signKey!);
|
||||
|
||||
// var publicKey = await Storage.getStringList(saveBluePublicKey);
|
||||
// List<int> publicKeyDataList = changeStringListToIntList(publicKey!);
|
||||
|
||||
var token = reply.data.sublist(5, 9);
|
||||
var saveStrList = changeIntListToStringList(token);
|
||||
Storage.setStringList(saveBlueToken, saveStrList);
|
||||
|
||||
IoSenderManage.senderCustomPasswordsCommand(
|
||||
keyID:state.deletKeyID,
|
||||
userID:state.deletUserID,
|
||||
pwdNo:state.pwdNo,
|
||||
pwd:"000000",//state.deletPWD,
|
||||
useCountLimit: 0,
|
||||
startTime:0x11223344,
|
||||
endTime:0x11223344,
|
||||
needAuthor: 1,
|
||||
signKey: signKeyDataList,
|
||||
privateKey: getPrivateKeyList,
|
||||
token: token);
|
||||
break;
|
||||
default:
|
||||
//失败
|
||||
cancelBlueConnetctToastTimer();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//请求密码钥匙列表
|
||||
Future<PasswordKeyListEntity> mockNetworkDataRequest() async {
|
||||
PasswordKeyListEntity entity = await ApiRepository.to.passwordKeyList(
|
||||
@ -39,7 +113,6 @@ class PasswordKeyListLogic extends BaseGetXController {
|
||||
PasswordKeyListEntity entity = await ApiRepository.to
|
||||
.keyboardPwdReset(state.keyInfo.value.lockId.toString());
|
||||
if (entity.errorCode!.codeIsSuccessful) {
|
||||
// print("重置电子钥匙成功啦啦啦啦啦");
|
||||
showToast("重置成功".tr, something: (){
|
||||
pageNo = 1;
|
||||
mockNetworkDataRequest();
|
||||
@ -48,10 +121,11 @@ class PasswordKeyListLogic extends BaseGetXController {
|
||||
}
|
||||
|
||||
//删除密码请求 deleteType:1-蓝牙 2-网关
|
||||
Future<void> deletePwdRequest(
|
||||
String lockId, String keyboardPwdId, int deleteType) async {
|
||||
PasswordKeyEntity entity = await ApiRepository.to
|
||||
.deleteKeyboardPwd(lockId, keyboardPwdId, deleteType);
|
||||
Future<void> deletePwdRequest() async {
|
||||
PasswordKeyEntity entity = await ApiRepository.to.deleteKeyboardPwd(
|
||||
lockId:state.itemData.lockId!.toString(),
|
||||
keyboardPwdId:state.itemData.keyboardPwdId!.toString(),
|
||||
deleteType:1);
|
||||
if (entity.errorCode!.codeIsSuccessful) {
|
||||
showToast("删除成功".tr, something: (){
|
||||
pageNo = 1;
|
||||
@ -60,6 +134,48 @@ class PasswordKeyListLogic extends BaseGetXController {
|
||||
}
|
||||
}
|
||||
|
||||
// 设置自定义密码 这里用作删除密码
|
||||
Future<void> senderCustomPasswords() async {
|
||||
|
||||
showEasyLoading();
|
||||
showBlueConnetctToastTimer(action: (){
|
||||
dismissEasyLoading();
|
||||
state.sureBtnState.value = 0;
|
||||
});
|
||||
BlueManage().bludSendData(BlueManage().connectDeviceName, (BluetoothConnectionState deviceConnectionState) async {
|
||||
if (deviceConnectionState == BluetoothConnectionState.connected) {
|
||||
var signKey = await Storage.getStringList(saveBlueSignKey);
|
||||
List<int> signKeyDataList = changeStringListToIntList(signKey!);
|
||||
|
||||
var privateKey = await Storage.getStringList(saveBluePrivateKey);
|
||||
List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
|
||||
|
||||
var token = await Storage.getStringList(saveBlueToken);
|
||||
List<int> getTokenList = changeStringListToIntList(token!);
|
||||
|
||||
IoSenderManage.senderCustomPasswordsCommand(
|
||||
keyID:state.deletKeyID,
|
||||
userID:state.deletUserID,
|
||||
pwdNo:state.pwdNo,
|
||||
pwd:"000000",//state.deletPWD,
|
||||
useCountLimit: 0,
|
||||
startTime:0x11223344,
|
||||
endTime:0x11223344,
|
||||
needAuthor: 1,
|
||||
signKey: signKeyDataList,
|
||||
privateKey: getPrivateKeyList,
|
||||
token: getTokenList);
|
||||
} else if (deviceConnectionState == BluetoothConnectionState.disconnected) {
|
||||
dismissEasyLoading();
|
||||
cancelBlueConnetctToastTimer();
|
||||
state.sureBtnState.value = 0;
|
||||
if(state.ifCurrentScreen.value == true){
|
||||
showBlueConnetctToast();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
//使用期限
|
||||
String getUseDateStr(PasswordKeyListItem indexEntity) {
|
||||
int? getPwdType = indexEntity.keyboardPwdType;
|
||||
@ -160,6 +276,7 @@ class PasswordKeyListLogic extends BaseGetXController {
|
||||
// TODO: implement onReady
|
||||
super.onReady();
|
||||
_getPasswordListRefreshUIAction();
|
||||
_initReplySubscription();
|
||||
}
|
||||
|
||||
@override
|
||||
@ -173,5 +290,6 @@ class PasswordKeyListLogic extends BaseGetXController {
|
||||
// TODO: implement onClose
|
||||
super.onClose();
|
||||
_getPasswordListRefreshUIEvent?.cancel();
|
||||
_replySubscription.cancel();
|
||||
}
|
||||
}
|
||||
|
||||
@ -10,6 +10,7 @@ import 'package:star_lock/tools/storage.dart';
|
||||
import '../../../../appRouters.dart';
|
||||
import '../../../../app_settings/app_colors.dart';
|
||||
import '../../../../tools/EasyRefreshTool.dart';
|
||||
import '../../../../tools/appRouteObserver.dart';
|
||||
import '../../../../tools/keySearchWidget.dart';
|
||||
import '../../../../tools/showTipView.dart';
|
||||
import '../../../../tools/submitBtn.dart';
|
||||
@ -23,7 +24,7 @@ class PasswordKeyListPage extends StatefulWidget {
|
||||
State<PasswordKeyListPage> createState() => _PasswordKeyListPageState();
|
||||
}
|
||||
|
||||
class _PasswordKeyListPageState extends State<PasswordKeyListPage> {
|
||||
class _PasswordKeyListPageState extends State<PasswordKeyListPage> with RouteAware {
|
||||
final logic = Get.put(PasswordKeyListLogic());
|
||||
final state = Get.find<PasswordKeyListLogic>().state;
|
||||
|
||||
@ -61,8 +62,14 @@ class _PasswordKeyListPageState extends State<PasswordKeyListPage> {
|
||||
var isDemoMode = await Storage.getBool(ifIsDemoModeOrNot);
|
||||
if (isDemoMode == false) {
|
||||
ShowTipView().showIosTipWithContentDialog('该锁的密码都将被删除'.tr, () {
|
||||
logic.resetPasswordKeyListRequest();
|
||||
setState(() {});
|
||||
state.isDeletPWDData = true;
|
||||
state.isDeletAll = true;
|
||||
state.deletKeyID = "0";
|
||||
state.deletUserID = "DeleteAll!@#";
|
||||
// state.deletPWD = "";
|
||||
state.pwdNo = 255;
|
||||
|
||||
logic.senderCustomPasswords();
|
||||
});
|
||||
} else {
|
||||
logic.showToast("演示模式".tr);
|
||||
@ -134,9 +141,14 @@ class _PasswordKeyListPageState extends State<PasswordKeyListPage> {
|
||||
children: [
|
||||
SlidableAction(
|
||||
onPressed: (BuildContext context){
|
||||
ShowTipView().showIosTipWithContentDialog("确定要删除吗?".tr, () {
|
||||
logic.deletePwdRequest(passwordKeyListItem.lockId.toString(),
|
||||
passwordKeyListItem.keyboardPwdId.toString(), 1);
|
||||
ShowTipView().showIosTipWithContentDialog("确定要删除吗?".tr, () async {
|
||||
state.isDeletAll = false;
|
||||
state.deletUserID = (await Storage.getUid())!;
|
||||
state.deletKeyID = passwordKeyListItem.keyboardPwdId.toString();
|
||||
state.deletPWD = passwordKeyListItem.keyboardPwd!;
|
||||
state.itemData = passwordKeyListItem;
|
||||
state.pwdNo = passwordKeyListItem.pwdUserNo!;
|
||||
logic.senderCustomPasswords();
|
||||
});
|
||||
},
|
||||
backgroundColor: Colors.red,
|
||||
@ -232,4 +244,59 @@ class _PasswordKeyListPageState extends State<PasswordKeyListPage> {
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
void didChangeDependencies() {
|
||||
// TODO: implement didChangeDependencies
|
||||
super.didChangeDependencies();
|
||||
|
||||
/// 路由订阅
|
||||
AppRouteObserver().routeObserver.subscribe(this, ModalRoute.of(context)!);
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
// TODO: implement dispose
|
||||
/// 取消路由订阅
|
||||
AppRouteObserver().routeObserver.unsubscribe(this);
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
/// 从上级界面进入 当前界面即将出现
|
||||
@override
|
||||
void didPush() {
|
||||
super.didPush();
|
||||
Get.log("PasswordKeyDetailPage===didPush");
|
||||
state.ifCurrentScreen.value = true;
|
||||
}
|
||||
|
||||
/// 返回上一个界面 当前界面即将消失
|
||||
@override
|
||||
void didPop() {
|
||||
super.didPop();
|
||||
Get.log("PasswordKeyDetailPage===didPop");
|
||||
logic.cancelBlueConnetctToastTimer();
|
||||
logic.dismissEasyLoading();
|
||||
state.ifCurrentScreen.value = false;
|
||||
state.sureBtnState.value = 0;
|
||||
}
|
||||
|
||||
/// 从下级返回 当前界面即将出现
|
||||
@override
|
||||
void didPopNext() {
|
||||
super.didPopNext();
|
||||
Get.log("PasswordKeyDetailPage===didPopNext");
|
||||
state.ifCurrentScreen.value = true;
|
||||
}
|
||||
|
||||
/// 进入下级界面 当前界面即将消失
|
||||
@override
|
||||
void didPushNext() {
|
||||
super.didPushNext();
|
||||
Get.log("PasswordKeyDetailPage===didPushNext");
|
||||
logic.cancelBlueConnetctToastTimer();
|
||||
logic.dismissEasyLoading();
|
||||
state.ifCurrentScreen.value = false;
|
||||
state.sureBtnState.value = 0;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -7,8 +7,20 @@ import '../../../lockMian/entity/lockListInfo_entity.dart';
|
||||
class PasswordKeyListState {
|
||||
final keyInfo = LockListInfoItemEntity().obs;
|
||||
final itemDataList = <PasswordKeyListItem>[].obs;
|
||||
var itemData = PasswordKeyListItem();
|
||||
final TextEditingController searchController = TextEditingController();
|
||||
|
||||
var ifCurrentScreen = true.obs; // 是否是当前界面,用于判断是否需要针对当前界面进行展示
|
||||
var sureBtnState = 0.obs;// 0普通状态(可用) 1连接中(不可用)
|
||||
|
||||
// 因为删除跟添加指纹用的同一个协议 所以这里用做判断
|
||||
var isDeletPWDData = false;
|
||||
var isDeletAll = false;
|
||||
var deletKeyID = "";
|
||||
var deletUserID = "DeleteAll!@#";
|
||||
var deletPWD = "";
|
||||
var pwdNo = 0;
|
||||
|
||||
PasswordKeyListState() {
|
||||
Map map = Get.arguments;
|
||||
keyInfo.value = map["keyInfo"];
|
||||
|
||||
@ -163,13 +163,23 @@ class PasswordKeyPerpetualLogic extends BaseGetXController {
|
||||
state.pwdController.text = "";
|
||||
if (entity.data != null) {
|
||||
state.getPwdStr.value = entity.data!.keyboardPwd!;
|
||||
updatePWDNumberRequest(entity.data!.keyboardPwdId.toString());
|
||||
}
|
||||
eventBus.fire(GetPasswordListRefreshUI());
|
||||
} else {
|
||||
showToast('${entity.errorMsg}');
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> updatePWDNumberRequest(String pwdNumberId) async {
|
||||
var entity = await ApiRepository.to.updatePWDNumber(
|
||||
lockId: state.keyInfo.value.lockId.toString(),
|
||||
keyboardPwdId: pwdNumberId,
|
||||
pwdUserNo: state.pwdNumber.value.toString());
|
||||
if (entity.errorCode!.codeIsSuccessful) {
|
||||
eventBus.fire(GetPasswordListRefreshUI());
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> checkKeyboardpwdNameRequest() async {
|
||||
if (state.nameController.text.isEmpty) {
|
||||
showToast("请输入姓名");
|
||||
@ -194,8 +204,7 @@ class PasswordKeyPerpetualLogic extends BaseGetXController {
|
||||
// 监听设备返回的数据
|
||||
late StreamSubscription<Reply> _replySubscription;
|
||||
void _initReplySubscription() {
|
||||
_replySubscription =
|
||||
EventBusManager().eventBus!.on<Reply>().listen((reply) async {
|
||||
_replySubscription = EventBusManager().eventBus!.on<Reply>().listen((reply) async {
|
||||
// 设置自定义密码
|
||||
if (reply is SenderCustomPasswordsReply) {
|
||||
var token = reply.data.sublist(5, 9);
|
||||
@ -207,6 +216,7 @@ class PasswordKeyPerpetualLogic extends BaseGetXController {
|
||||
case 0x00:
|
||||
//成功
|
||||
state.sureBtnState.value = 0;
|
||||
state.pwdNumber.value = (reply.data[9]);
|
||||
dismissEasyLoading();
|
||||
cancelBlueConnetctToastTimer();
|
||||
addKeyboardPwdRequest();
|
||||
|
||||
@ -30,4 +30,6 @@ class PasswordKeyPerpetualState {
|
||||
|
||||
var ifCurrentScreen = true.obs; // 是否是当前界面,用于判断是否需要针对当前界面进行展示
|
||||
var sureBtnState = 0.obs;// 0普通状态(可用) 1连接中(不可用)
|
||||
|
||||
var pwdNumber = 0.obs;// 密码编号
|
||||
}
|
||||
|
||||
@ -31,9 +31,9 @@ class ExpirePasswordLogic extends BaseGetXController {
|
||||
//删除密码请求 deleteType:1-蓝牙 2-网关
|
||||
Future<void> deletePwdRequest(ExpirePasswordItemData expirePasswordItemData) async {
|
||||
PasswordKeyEntity entity = await ApiRepository.to.deleteKeyboardPwd(
|
||||
expirePasswordItemData.lockId.toString(),
|
||||
expirePasswordItemData.pwdId.toString(),
|
||||
1);
|
||||
lockId:expirePasswordItemData.lockId.toString(),
|
||||
keyboardPwdId:expirePasswordItemData.pwdId.toString(),
|
||||
deleteType:1);
|
||||
if (entity.errorCode!.codeIsSuccessful) {
|
||||
showToast("删除成功", something: () {
|
||||
pageNo = 1;
|
||||
|
||||
@ -45,9 +45,9 @@ abstract class Api {
|
||||
|
||||
final String passwordKeyGetURL = '/keyboardPwd/get'; //获取密码
|
||||
final String passwordKeyAddURL = '/keyboardPwd/add'; //自定义密码
|
||||
final String passwordKeyCheckKeyboardpwdNameURL =
|
||||
'/keyboardPwd/checkKeyboardpwdName'; //自定义密码校验密码跟名字是否重复
|
||||
final String passwordKeyCheckKeyboardpwdNameURL = '/keyboardPwd/checkKeyboardpwdName'; //自定义密码校验密码跟名字是否重复
|
||||
final String updatePasswordKeyURL = '/keyboardPwd/update'; //修改密码详情
|
||||
final String updatePWDNumberURL = '/keyboardPwd/updatePwdUserNo'; //更新锁用户需要
|
||||
final String clearOperationRecordURL = '/lockRecords/clear'; //清空操作记录
|
||||
final String addlockGroupURL = '/keyGroup/add'; //创建锁分组
|
||||
final String editlockGroupURL = '/keyGroup/modifyGroupName'; //编辑锁分组
|
||||
|
||||
@ -431,6 +431,14 @@ class ApiProvider extends BaseProvider {
|
||||
'isCoerced': isCoerced,
|
||||
}));
|
||||
|
||||
// 更新锁用户序号
|
||||
Future<Response> updatePWDNumber(String lockId, String keyboardPwdId, String pwdUserNo) => post(
|
||||
updatePWDNumberURL.toUrl,
|
||||
jsonEncode({
|
||||
'lockId': lockId,
|
||||
'keyboardPwdId': keyboardPwdId,
|
||||
'pwdUserNo': pwdUserNo}));
|
||||
|
||||
Future<Response> addKeyboardPwd(
|
||||
String lockId,
|
||||
String keyboardPwdName,
|
||||
|
||||
@ -444,6 +444,19 @@ class ApiRepository {
|
||||
return PasswordKeyEntity.fromJson(res.body);
|
||||
}
|
||||
|
||||
// 更新锁用户序号
|
||||
Future<PasswordKeyEntity> updatePWDNumber(
|
||||
{required String lockId,
|
||||
required String keyboardPwdId,
|
||||
required String pwdUserNo}) async {
|
||||
final res = await apiProvider.updatePWDNumber(
|
||||
lockId,
|
||||
keyboardPwdId,
|
||||
pwdUserNo
|
||||
);
|
||||
return PasswordKeyEntity.fromJson(res.body);
|
||||
}
|
||||
|
||||
//自定义密码
|
||||
Future<PasswordKeyEntity> addPasswordKey(
|
||||
String lockId,
|
||||
@ -655,7 +668,11 @@ class ApiRepository {
|
||||
|
||||
//删除密码
|
||||
Future<PasswordKeyEntity> deleteKeyboardPwd(
|
||||
String lockId, String keyboardPwdId, int deleteType) async {
|
||||
{
|
||||
required String lockId,
|
||||
required String keyboardPwdId,
|
||||
required int deleteType
|
||||
}) async {
|
||||
final res =
|
||||
await apiProvider.deleteKeyboardPwd(lockId, keyboardPwdId, deleteType);
|
||||
return PasswordKeyEntity.fromJson(res.body);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user