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