1、优化锁设置基本信息功能。2、优化锁设置其他问题
This commit is contained in:
parent
db4978fbbd
commit
8c5355dd93
@ -347,13 +347,13 @@ class BlueManage {
|
||||
// 断开连接
|
||||
Future<void> disconnect(String deviceMAC) async {
|
||||
try {
|
||||
connectDeviceMacAddress = "";
|
||||
connectDeviceMacAddress = "";
|
||||
// if(_currentConnectionStream != null){
|
||||
_currentConnectionStream?.cancel();
|
||||
_currentConnectionStream = null;
|
||||
// }
|
||||
|
||||
print('disconnecting to device: $deviceMAC');
|
||||
print('disconnecting to device: $connectDeviceName');
|
||||
} on Exception catch (e, _) {
|
||||
print("Error disconnecting from a device: $e");
|
||||
} finally {
|
||||
|
||||
@ -0,0 +1,143 @@
|
||||
|
||||
import 'dart:convert';
|
||||
|
||||
import '../io_tool/io_tool.dart';
|
||||
import '../sm4Encipher/sm4.dart';
|
||||
import '../io_reply.dart';
|
||||
import '../io_sender.dart';
|
||||
import '../io_type.dart';
|
||||
import 'package:crypto/crypto.dart' as crypto;
|
||||
|
||||
//TODO:修改管理员密码
|
||||
class ChangeAdministratorPasswordCommand extends SenderProtocol {
|
||||
|
||||
String? keyID;
|
||||
String? userID;
|
||||
int? pwdNo;
|
||||
String? pwd;
|
||||
int? useCountLimit;
|
||||
List<int>? token;
|
||||
int? startTime;
|
||||
int? endTime;
|
||||
int? needAuthor;
|
||||
List<int>? signKey;
|
||||
List<int>? privateKey;
|
||||
|
||||
ChangeAdministratorPasswordCommand({
|
||||
this.keyID,
|
||||
this.userID,
|
||||
this.pwdNo,
|
||||
this.pwd,
|
||||
this.useCountLimit,
|
||||
this.token,
|
||||
this.startTime,
|
||||
this.endTime,
|
||||
this.needAuthor,
|
||||
this.signKey,
|
||||
this.privateKey,
|
||||
}) : super(CommandType.generalExtendedCommond);
|
||||
|
||||
@override
|
||||
List<int> messageDetail() {
|
||||
List<int> data = [];
|
||||
List<int> subData = [];
|
||||
List<int> ebcData = [];
|
||||
|
||||
// 指令类型
|
||||
int type = commandType!.typeValue;
|
||||
double typeDouble = type / 256;
|
||||
int type1 = typeDouble.toInt();
|
||||
int type2 = type % 256;
|
||||
data.add(type1);
|
||||
data.add(type2);
|
||||
|
||||
// 子命令类型
|
||||
data.add(2);
|
||||
|
||||
// keyID 40
|
||||
int keyIDLength = utf8.encode(keyID!).length;
|
||||
// print("${commandType!.typeValue}LockIDLength:$lockIDLength utf8.encode(lockID!)${utf8.encode(lockID!)}");
|
||||
subData.addAll(utf8.encode(keyID!));
|
||||
subData = getFixedLengthList(subData, 40 - keyIDLength);
|
||||
|
||||
//userID 20
|
||||
int userIDLength = utf8.encode(userID!).length;
|
||||
// print("${commandType!.typeValue}IDLength:$authUserIDLength utf8.encode(authUserID!)${utf8.encode(authUserID!)}");
|
||||
subData.addAll(utf8.encode(userID!));
|
||||
subData = getFixedLengthList(subData, 20 - userIDLength);
|
||||
|
||||
// PwdNo
|
||||
subData.add(1);
|
||||
|
||||
// pwd 20
|
||||
int pwdLength = utf8.encode(pwd!).length;
|
||||
// print("${commandType!.typeValue}keyIDLength:$keyIDLength utf8.encode(keyID!)${utf8.encode(keyID!)}");
|
||||
subData.addAll(utf8.encode(pwd!));
|
||||
subData = getFixedLengthList(subData, 20 - pwdLength);
|
||||
|
||||
// UseCountLimit
|
||||
subData.add(0xff);
|
||||
|
||||
// token
|
||||
subData.addAll(token!);
|
||||
|
||||
// startTime 4
|
||||
subData.add((startTime! & 0xff000000) >> 24);
|
||||
subData.add((startTime! & 0xff0000) >> 16);
|
||||
subData.add((startTime! & 0xff00) >> 8);
|
||||
subData.add((startTime! & 0xff));
|
||||
|
||||
// endTime 4
|
||||
subData.add((endTime! & 0xff000000) >> 24);
|
||||
subData.add((endTime! & 0xff0000) >> 16);
|
||||
subData.add((endTime! & 0xff00) >> 8);
|
||||
subData.add((endTime! & 0xff));
|
||||
|
||||
if(needAuthor == 0){
|
||||
//AuthCodeLen 1
|
||||
subData.add(0);
|
||||
} else {
|
||||
List<int> authCodeData = [];
|
||||
|
||||
//KeyID
|
||||
authCodeData.addAll(utf8.encode(keyID!));
|
||||
|
||||
//authUserID
|
||||
authCodeData.addAll(utf8.encode(userID!));
|
||||
|
||||
//token 4 首次请求 Token 填 0,如果锁需要鉴权操作者身份,则会分配动态口令并在应答消息中返回,二次请求时带上。
|
||||
authCodeData.addAll(token!);
|
||||
|
||||
authCodeData.addAll(signKey!);
|
||||
|
||||
print("${commandType!.typeValue}-authCodeData:$authCodeData");
|
||||
|
||||
// 把KeyID、authUserID、时间戳、公钥通过md5加密之后就是authCode
|
||||
var authCode = crypto.md5.convert(authCodeData);
|
||||
|
||||
subData.add(authCode.bytes.length);
|
||||
subData.addAll(authCode.bytes);
|
||||
}
|
||||
|
||||
data.add(subData.length);
|
||||
data.addAll(subData);
|
||||
|
||||
if ((data.length % 16) != 0) {
|
||||
int add = (16 - data.length % 16);
|
||||
for (int i = 0; i < add; i++) {
|
||||
data.add(0);
|
||||
}
|
||||
}
|
||||
print("${commandType!.typeName} SM4Data:$data");
|
||||
// 拿到数据之后通过LockId进行SM4 ECB加密 key:544d485f633335373034383064613864
|
||||
ebcData = SM4.encrypt(data, key: privateKey, mode: SM4CryptoMode.ECB);
|
||||
return ebcData;
|
||||
}
|
||||
}
|
||||
|
||||
class ChangeAdministratorPasswordReply extends Reply {
|
||||
ChangeAdministratorPasswordReply.parseData(CommandType commandType, List<int> dataDetail)
|
||||
: super.parseData(commandType, dataDetail) {
|
||||
data = dataDetail;
|
||||
}
|
||||
}
|
||||
@ -4,6 +4,7 @@ import 'dart:convert';
|
||||
|
||||
import 'package:flutter_easyloading/flutter_easyloading.dart';
|
||||
import 'package:star_lock/blue/blue_manage.dart';
|
||||
import 'package:star_lock/blue/io_protocol/io_changeAdministratorPassword.dart';
|
||||
import 'package:star_lock/blue/io_protocol/io_deletUser.dart';
|
||||
import 'package:star_lock/blue/io_protocol/io_editUser.dart';
|
||||
import 'package:star_lock/blue/io_protocol/io_factoryDataReset.dart';
|
||||
@ -180,6 +181,12 @@ class CommandReciverManager {
|
||||
// 子命令类型
|
||||
int subType = data[3];
|
||||
switch(subType){
|
||||
case 2:
|
||||
{
|
||||
// 修改管理员密码
|
||||
reply = ChangeAdministratorPasswordReply.parseData(commandType, data);
|
||||
}
|
||||
break;
|
||||
case 3:
|
||||
{
|
||||
// 设置开锁密码
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
|
||||
import 'package:star_lock/blue/io_protocol/io_addICCard.dart';
|
||||
import 'package:star_lock/blue/io_protocol/io_addStressICCard.dart';
|
||||
import 'package:star_lock/blue/io_protocol/io_changeAdministratorPassword.dart';
|
||||
import 'package:star_lock/blue/io_protocol/io_deletUser.dart';
|
||||
import 'package:star_lock/blue/io_protocol/io_getLockStatu.dart';
|
||||
import 'package:star_lock/blue/io_protocol/io_readAdminPassword.dart';
|
||||
@ -287,6 +288,36 @@ class IoSenderManage {
|
||||
), callBack:callBack);
|
||||
}
|
||||
|
||||
//todo:修改管理员密码
|
||||
static void changeAdministratorPasswordCommand({
|
||||
required String? keyID,
|
||||
required String? userID,
|
||||
required int? pwdNo,
|
||||
required String? pwd,
|
||||
required int? useCountLimit,
|
||||
required List<int>? token,
|
||||
required int? startTime,
|
||||
required int? endTime,
|
||||
required int? needAuthor,
|
||||
required List<int>? signKey,
|
||||
required List<int>? privateKey,
|
||||
CommandSendCallBack? callBack}) {
|
||||
CommandSenderManager().managerSendData(
|
||||
command: ChangeAdministratorPasswordCommand(
|
||||
keyID: keyID,
|
||||
userID: userID,
|
||||
pwdNo: pwdNo,
|
||||
pwd:pwd,
|
||||
useCountLimit: useCountLimit,
|
||||
token: token,
|
||||
startTime: startTime,
|
||||
endTime: endTime,
|
||||
needAuthor: needAuthor,
|
||||
signKey: signKey,
|
||||
privateKey: privateKey,
|
||||
), callBack:callBack);
|
||||
}
|
||||
|
||||
//todo:添加指纹开始
|
||||
static void senderAddFingerprintCommand({
|
||||
required String? keyID,
|
||||
|
||||
@ -51,6 +51,7 @@ class AddICCardLogic extends BaseGetXController{
|
||||
//成功
|
||||
print("${reply.commandType!.typeValue} 数据解析成功");
|
||||
// state.cardNumber.value = reply.data.last.toString();
|
||||
cancelBlueConnetctToastTimer();
|
||||
state.ifConnectScuess.value = true;
|
||||
break;
|
||||
case 0x06:
|
||||
|
||||
@ -39,6 +39,7 @@ class CardDetailLogic extends BaseGetXController{
|
||||
case 0x00:
|
||||
//成功
|
||||
print("${reply.commandType!.typeValue} 数据解析成功");
|
||||
cancelBlueConnetctToastTimer();
|
||||
dismissEasyLoading();
|
||||
deletICCardData();
|
||||
break;
|
||||
@ -86,7 +87,7 @@ class CardDetailLogic extends BaseGetXController{
|
||||
}
|
||||
}
|
||||
|
||||
// 删除卡片
|
||||
// 添加卡片
|
||||
Future<void> senderAddICCard() async {
|
||||
if(state.sureBtnState.value == 1){
|
||||
return;
|
||||
|
||||
@ -50,6 +50,7 @@ class CardListLogic extends BaseGetXController {
|
||||
//成功
|
||||
print("${reply.commandType!.typeValue} 数据解析成功");
|
||||
state.isDeletCardData = false;
|
||||
cancelBlueConnetctToastTimer();
|
||||
deletICCardData();
|
||||
break;
|
||||
case 0x06:
|
||||
|
||||
@ -40,6 +40,7 @@ class FingerprintDetailLogic extends BaseGetXController{
|
||||
//成功
|
||||
print("${reply.commandType!.typeValue} 数据解析成功");
|
||||
state.sureBtnState.value = 0;
|
||||
cancelBlueConnetctToastTimer();
|
||||
dismissEasyLoading();
|
||||
deletFingerprintsData();
|
||||
break;
|
||||
|
||||
@ -50,6 +50,7 @@ class FingerprintListLogic extends BaseGetXController{
|
||||
//成功
|
||||
print("${reply.commandType!.typeValue} 数据解析成功");
|
||||
state.isDeletFingerprintData = false;
|
||||
cancelBlueConnetctToastTimer();
|
||||
dismissEasyLoading();
|
||||
deletAllFingerprintsData();
|
||||
break;
|
||||
|
||||
@ -43,9 +43,10 @@ class AutomaticBlockingLogic extends BaseGetXController{
|
||||
|
||||
state.autoLockTime.value = autoTime;
|
||||
state.lockSetInfoData.value.lockSettingInfo!.autoLockSecond = int.parse(state.autoLockTime.value);
|
||||
eventBus.fire(RefreshLockListInfoDataEvent());
|
||||
eventBus.fire(PassCurrentLockInformationEvent(state.lockSetInfoData.value));
|
||||
showToast("操作成功");
|
||||
showToast("操作成功", something: (){
|
||||
eventBus.fire(RefreshLockListInfoDataEvent());
|
||||
eventBus.fire(PassCurrentLockInformationEvent(state.lockSetInfoData.value));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@ -104,6 +105,7 @@ class AutomaticBlockingLogic extends BaseGetXController{
|
||||
//成功
|
||||
print("${reply.commandType}数据解析成功");
|
||||
state.sureBtnState.value = 0;
|
||||
cancelBlueConnetctToastTimer();
|
||||
dismissEasyLoading();
|
||||
setAutoUnLock();
|
||||
break;
|
||||
|
||||
@ -1,18 +1,180 @@
|
||||
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:flutter_reactive_ble/flutter_reactive_ble.dart';
|
||||
import 'package:star_lock/blue/io_type.dart';
|
||||
|
||||
import '../../../../../blue/blue_manage.dart';
|
||||
import '../../../../../blue/io_protocol/io_changeAdministratorPassword.dart';
|
||||
import '../../../../../blue/io_protocol/io_readAdminPassword.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 '../../../../../network/api_repository.dart';
|
||||
import '../../../../../tools/baseGetXController.dart';
|
||||
import '../../../../../tools/eventBusEventManage.dart';
|
||||
import '../../../../../tools/storage.dart';
|
||||
import '../basicInformation/basicInformation_state.dart';
|
||||
import 'adminOpenLockPassword_state.dart';
|
||||
|
||||
class AdminOpenLockPasswordLogic extends BaseGetXController{
|
||||
final BasicInformationState state = BasicInformationState();
|
||||
final AdminOpenLockPasswordState state = AdminOpenLockPasswordState();
|
||||
|
||||
// 获取解析后的数据
|
||||
late StreamSubscription<Reply> _replySubscription;
|
||||
void _initReplySubscription() {
|
||||
_replySubscription = EventBusManager().eventBus!.on<Reply>().listen((reply) {
|
||||
if (reply is ChangeAdministratorPasswordReply) {
|
||||
_replyChangeAdministratorPassword(reply);
|
||||
}
|
||||
|
||||
if (reply is SenderReadAdminPasswordReply) {
|
||||
_replyReadAdminPassword(reply);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// 修改管理员密码
|
||||
Future<void> _replyChangeAdministratorPassword(Reply reply) async {
|
||||
var token = reply.data.sublist(5, 9);
|
||||
var saveStrList = changeIntListToStringList(token);
|
||||
print("_replyFactoryDataResetKeyToken:$token");
|
||||
Storage.setStringList(saveBlueToken, saveStrList);
|
||||
|
||||
int status = reply.data[2];
|
||||
print("status:$status");
|
||||
|
||||
switch (status) {
|
||||
case 0x00:
|
||||
//成功
|
||||
print("${reply.commandType!.typeValue} 数据解析成功");
|
||||
state.sureBtnState.value = 0;
|
||||
dismissEasyLoading();
|
||||
cancelBlueConnetctToastTimer();
|
||||
state.adminPwd.value = state.changePwdController.text;
|
||||
addLockAdminPassword(true);
|
||||
break;
|
||||
case 0x06:
|
||||
//无权限
|
||||
print("${reply.commandType!.typeValue} 需要鉴权");
|
||||
|
||||
var signKey = await Storage.getStringList(saveBlueSignKey);
|
||||
List<int> signKeyDataList = changeStringListToIntList(signKey!);
|
||||
|
||||
var privateKey = await Storage.getStringList(saveBluePrivateKey);
|
||||
List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
|
||||
|
||||
IoSenderManage.changeAdministratorPasswordCommand(
|
||||
keyID: "1",
|
||||
userID: await Storage.getUid(),
|
||||
pwdNo: 0,
|
||||
pwd:state.changePwdController.text,
|
||||
useCountLimit: 0xff,
|
||||
startTime: 0x11223344,
|
||||
endTime: 0x11223344,
|
||||
needAuthor: 1,
|
||||
signKey: signKeyDataList,
|
||||
privateKey: getPrivateKeyList,
|
||||
token: token);
|
||||
break;
|
||||
case 0x07:
|
||||
//无权限
|
||||
print("${reply.commandType!.typeValue} 用户无权限");
|
||||
|
||||
break;
|
||||
case 0x09:
|
||||
// 权限校验错误
|
||||
print("${reply.commandType!.typeValue} 权限校验错误");
|
||||
|
||||
break;
|
||||
default:
|
||||
//失败
|
||||
print("${reply.commandType!.typeValue} 失败");
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// 读取管理员密码
|
||||
Future<void> _replyReadAdminPassword(Reply reply) async {
|
||||
var token = reply.data.sublist(5, 9);
|
||||
var saveStrList = changeIntListToStringList(token);
|
||||
Storage.setStringList(saveBlueToken, saveStrList);
|
||||
|
||||
int status = reply.data[2];
|
||||
print("status:$status");
|
||||
|
||||
switch (status) {
|
||||
case 0x00:
|
||||
//成功
|
||||
print("${reply.commandType!.typeValue} 数据解析成功");
|
||||
dismissEasyLoading();
|
||||
cancelBlueConnetctToastTimer();
|
||||
|
||||
if(reply.data[5] > 0){
|
||||
reply.data.removeRange(0, 6);
|
||||
// 把得到的数据按8位分割成数组 然后塞进一个新的数组里面
|
||||
var getList = splitList(reply.data, 13);
|
||||
print("getList:$getList");
|
||||
for(int i = 0; i<getList.length; i++){
|
||||
var indexList = getList[i];
|
||||
print("indexList:$indexList");
|
||||
var pwd = indexList.sublist(1, 11);
|
||||
var pwdStr = utf8String(pwd);
|
||||
print("pwd:$pwd pwdStr:$pwdStr");
|
||||
state.adminPwd.value = pwdStr;
|
||||
addLockAdminPassword(false);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 0x06:
|
||||
//无权限
|
||||
print("${reply.commandType!.typeValue} 需要鉴权");
|
||||
var privateKey = await Storage.getStringList(saveBluePrivateKey);
|
||||
List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
|
||||
|
||||
var token = await Storage.getStringList(saveBlueToken);
|
||||
List<int> getTokenList = changeStringListToIntList(token!);
|
||||
|
||||
var publicKey = await Storage.getStringList(saveBluePublicKey);
|
||||
List<int> getPublicKeyList = changeStringListToIntList(publicKey!);
|
||||
|
||||
IoSenderManage.senderReadAdminPasswordCommand(
|
||||
keyID: state.lockSetInfoData.value.lockBasicInfo!.keyId.toString(),
|
||||
userID: await Storage.getUid(),
|
||||
role:0xff,
|
||||
pwdNum:1,
|
||||
pwdNo: 0,
|
||||
token: getTokenList,
|
||||
needAuthor: 1,
|
||||
publicKey: getPublicKeyList,
|
||||
privateKey: getPrivateKeyList
|
||||
);
|
||||
break;
|
||||
case 0x07:
|
||||
//无权限
|
||||
print("${reply.commandType!.typeValue} 用户无权限");
|
||||
|
||||
break;
|
||||
case 0x09:
|
||||
// 权限校验错误
|
||||
print("${reply.commandType!.typeValue} 权限校验错误");
|
||||
|
||||
break;
|
||||
default:
|
||||
//失败
|
||||
print("${reply.commandType!.typeValue} 失败");
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// 读取支持功能-带参数
|
||||
Future<void> _readAdminPassword() async {
|
||||
Future<void> readAdminPassword() async {
|
||||
showEasyLoading();
|
||||
showBlueConnetctToastTimer(action: (){
|
||||
dismissEasyLoading();
|
||||
});
|
||||
BlueManage().bludSendData(BlueManage().connectDeviceName, (DeviceConnectionState connectionState) async {
|
||||
if (connectionState == DeviceConnectionState.connected) {
|
||||
var privateKey = await Storage.getStringList(saveBluePrivateKey);
|
||||
@ -28,24 +190,98 @@ class AdminOpenLockPasswordLogic extends BaseGetXController{
|
||||
keyID: state.lockSetInfoData.value.lockBasicInfo!.keyId.toString(),
|
||||
userID: await Storage.getUid(),
|
||||
role:0xff,
|
||||
pwdNum:5,
|
||||
pwdNum:1,
|
||||
pwdNo: 0,
|
||||
token: getTokenList,
|
||||
needAuthor: 1,
|
||||
publicKey: getPublicKeyList,
|
||||
privateKey: getPrivateKeyList
|
||||
);
|
||||
} else if (connectionState == DeviceConnectionState.disconnected) {
|
||||
dismissEasyLoading();
|
||||
cancelBlueConnetctToastTimer();
|
||||
if(state.ifCurrentScreen.value == true){
|
||||
showBlueConnetctToast();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// 修改管理员密码(同添加自定义开锁密码,指纹/密码/卡片前5个是管理员)
|
||||
Future<void> changeAdministratorPasswordCommand() async {
|
||||
if(state.sureBtnState.value == 1){
|
||||
return;
|
||||
}
|
||||
state.sureBtnState.value = 1;
|
||||
|
||||
showEasyLoading();
|
||||
showBlueConnetctToastTimer(action: (){
|
||||
dismissEasyLoading();
|
||||
state.sureBtnState.value = 0;
|
||||
});
|
||||
BlueManage().bludSendData(BlueManage().connectDeviceName, (DeviceConnectionState deviceConnectionState) async {
|
||||
if (deviceConnectionState == DeviceConnectionState.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!);
|
||||
print("openDoorTokenPubToken:$getTokenList");
|
||||
|
||||
IoSenderManage.changeAdministratorPasswordCommand(
|
||||
keyID: "1",
|
||||
userID: await Storage.getUid(),
|
||||
pwdNo: 0,
|
||||
pwd:state.changePwdController.text,
|
||||
useCountLimit: 0xff,
|
||||
startTime: 0x11223344,
|
||||
endTime: 0x11223344,
|
||||
needAuthor: 1,
|
||||
signKey: signKeyDataList,
|
||||
privateKey: getPrivateKeyList,
|
||||
token: getTokenList);
|
||||
} else if (deviceConnectionState == DeviceConnectionState.disconnected) {
|
||||
state.sureBtnState.value = 0;
|
||||
dismissEasyLoading();
|
||||
cancelBlueConnetctToastTimer();
|
||||
if(state.ifCurrentScreen.value == true){
|
||||
showBlueConnetctToast();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// 更新管理员密码
|
||||
void addLockAdminPassword(bool isChange) async {
|
||||
var entity = await ApiRepository.to.setAdminPasswordData(
|
||||
lockId: state.lockSetInfoData.value.lockBasicInfo!.lockId!,
|
||||
adminPwd: state.adminPwd.value,
|
||||
);
|
||||
if (entity.errorCode!.codeIsSuccessful) {
|
||||
if(isChange == true){
|
||||
showToast("修改成功", something: (){
|
||||
state.lockBasicInfo.value.adminPwd = state.adminPwd.value;
|
||||
eventBus.fire(PassCurrentLockInformationEvent(state.lockSetInfoData.value));
|
||||
});
|
||||
}else{
|
||||
showToast("上传成功", something: (){
|
||||
state.lockBasicInfo.value.adminPwd = state.adminPwd.value;
|
||||
eventBus.fire(PassCurrentLockInformationEvent(state.lockSetInfoData.value));
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
void onReady() {
|
||||
// TODO: implement onReady
|
||||
super.onReady();
|
||||
print("onReady()");
|
||||
|
||||
_readAdminPassword();
|
||||
_initReplySubscription();
|
||||
}
|
||||
|
||||
@override
|
||||
@ -59,7 +295,8 @@ class AdminOpenLockPasswordLogic extends BaseGetXController{
|
||||
@override
|
||||
void onClose() {
|
||||
// TODO: implement onClose
|
||||
|
||||
super.onClose();
|
||||
_replySubscription.cancel();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:star_lock/tools/showTFView.dart';
|
||||
@ -7,6 +8,7 @@ import '../../../../../app_settings/app_colors.dart';
|
||||
import '../../../../../tools/commonItem.dart';
|
||||
import '../../../../../tools/titleAppBar.dart';
|
||||
import '../../../../../translations/trans_lib.dart';
|
||||
import 'adminOpenLockPassword_logic.dart';
|
||||
|
||||
class AdminOpenLockPasswordPage extends StatefulWidget {
|
||||
const AdminOpenLockPasswordPage({Key? key}) : super(key: key);
|
||||
@ -17,7 +19,8 @@ class AdminOpenLockPasswordPage extends StatefulWidget {
|
||||
}
|
||||
|
||||
class _AdminOpenLockPasswordPageState extends State<AdminOpenLockPasswordPage> {
|
||||
final TextEditingController _changePwdController = TextEditingController();
|
||||
final logic = Get.put(AdminOpenLockPasswordLogic());
|
||||
final state = Get.find<AdminOpenLockPasswordLogic>().state;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
@ -29,14 +32,14 @@ class _AdminOpenLockPasswordPageState extends State<AdminOpenLockPasswordPage> {
|
||||
backgroundColor: AppColors.mainColor),
|
||||
body: Column(
|
||||
children: [
|
||||
CommonItem(
|
||||
Obx(() => CommonItem(
|
||||
leftTitel: TranslationLoader.lanKeys!.password!.tr,
|
||||
rightTitle: "123456",
|
||||
rightTitle: state.adminPwd.value,
|
||||
isHaveLine: false,
|
||||
isHaveDirection: true,
|
||||
action: () {
|
||||
showCupertinoAlertDialog(context);
|
||||
}),
|
||||
})),
|
||||
Container(
|
||||
margin: EdgeInsets.all(30.w),
|
||||
child: Column(
|
||||
@ -55,7 +58,9 @@ class _AdminOpenLockPasswordPageState extends State<AdminOpenLockPasswordPage> {
|
||||
height: 10.h,
|
||||
),
|
||||
GestureDetector(
|
||||
onTap: () {},
|
||||
onTap: () {
|
||||
logic.readAdminPassword();
|
||||
},
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
children: [
|
||||
@ -83,18 +88,29 @@ class _AdminOpenLockPasswordPageState extends State<AdminOpenLockPasswordPage> {
|
||||
context: context,
|
||||
builder: (BuildContext context) {
|
||||
return ShowTFView(
|
||||
title:
|
||||
"${TranslationLoader.lanKeys!.amend!.tr} ${TranslationLoader.lanKeys!.name!.tr}",
|
||||
title: "管理员密码",
|
||||
tipTitle: "请输入",
|
||||
controller: _changePwdController,
|
||||
keyboardType: TextInputType.number,
|
||||
inputFormatters: [
|
||||
FilteringTextInputFormatter.allow(RegExp('[0-9]')),
|
||||
LengthLimitingTextInputFormatter(6),
|
||||
],
|
||||
controller: state.changePwdController,
|
||||
sureClick: () {
|
||||
//发送编辑钥匙名称请求
|
||||
if (_changePwdController.text.isNotEmpty) {
|
||||
// modifyPwdRequest();
|
||||
if(state.changePwdController.text.length < 6){
|
||||
logic.showToast("请输入6位管理员密码");
|
||||
return;
|
||||
}
|
||||
|
||||
if(state.changePwdController.text == state.lockBasicInfo.value.adminPwd!){
|
||||
logic.showToast("请输入新的管理员密码");
|
||||
return;
|
||||
}
|
||||
Get.back();
|
||||
logic.changeAdministratorPasswordCommand();
|
||||
},
|
||||
cancelClick: () {
|
||||
Navigator.pop(context);
|
||||
Get.back();
|
||||
},
|
||||
);
|
||||
},
|
||||
|
||||
@ -1,16 +1,24 @@
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
|
||||
import '../../lockSet/lockSetInfo_entity.dart';
|
||||
|
||||
class BasicInformationState {
|
||||
class AdminOpenLockPasswordState {
|
||||
var lockSetInfoData = LockSetInfoData().obs;
|
||||
var lockBasicInfo = LockBasicInfo().obs;
|
||||
|
||||
final TextEditingController changePwdController = TextEditingController();
|
||||
var adminPwd = "".obs;// 0普通状态可用 1不可用
|
||||
|
||||
BasicInformationState() {
|
||||
var ifCurrentScreen = true.obs; // 是否是当前界面,用于判断是否需要针对当前界面进行展示
|
||||
var sureBtnState = 0.obs;// 0普通状态可用 1不可用
|
||||
|
||||
AdminOpenLockPasswordState() {
|
||||
var map = Get.arguments;
|
||||
lockSetInfoData.value = map["lockSetInfoData"];
|
||||
lockBasicInfo.value = lockSetInfoData.value.lockBasicInfo!;
|
||||
changePwdController.text = lockBasicInfo.value.adminPwd!;
|
||||
adminPwd.value = lockBasicInfo.value.adminPwd!;
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,5 +1,9 @@
|
||||
|
||||
import 'dart:async';
|
||||
|
||||
import '../../../../../tools/baseGetXController.dart';
|
||||
import '../../../../../tools/eventBusEventManage.dart';
|
||||
import '../../lockSet/lockSet_logic.dart';
|
||||
import 'basicInformation_state.dart';
|
||||
|
||||
class BasicInformationLogic extends BaseGetXController{
|
||||
@ -33,13 +37,22 @@ class BasicInformationLogic extends BaseGetXController{
|
||||
// }, isShowLoading: true);
|
||||
// }
|
||||
|
||||
// 下级界面修改成功后传递数据
|
||||
StreamSubscription? _passCurrentLockInformationEvent;
|
||||
void initLoadDataAction(BlockSetStateCallback blockSetStateCallback) {
|
||||
// 蓝牙协议通知传输跟蓝牙之外的数据传输类不一样 eventBus
|
||||
_passCurrentLockInformationEvent = eventBus.on<PassCurrentLockInformationEvent>().listen((event) {
|
||||
state.lockSetInfoData.value = event.lockSetInfoData;
|
||||
blockSetStateCallback();
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
void onReady() {
|
||||
// TODO: implement onReady
|
||||
super.onReady();
|
||||
print("onReady()");
|
||||
|
||||
// _readAdminPassword();
|
||||
}
|
||||
|
||||
@override
|
||||
@ -53,7 +66,8 @@ class BasicInformationLogic extends BaseGetXController{
|
||||
@override
|
||||
void onClose() {
|
||||
// TODO: implement onClose
|
||||
|
||||
super.onClose();
|
||||
_passCurrentLockInformationEvent?.cancel();
|
||||
}
|
||||
|
||||
}
|
||||
@ -22,14 +22,15 @@ class _BasicInformationPageState extends State<BasicInformationPage> {
|
||||
final logic = Get.put(BasicInformationLogic());
|
||||
final state = Get.find<BasicInformationLogic>().state;
|
||||
|
||||
// late String _groupName = "";
|
||||
// late LockData _lockData;
|
||||
//
|
||||
// @override
|
||||
// void initState() {
|
||||
// super.initState();
|
||||
// _groupName = '未分组';
|
||||
// }
|
||||
@override
|
||||
void initState() {
|
||||
// TODO: implement initState
|
||||
super.initState();
|
||||
|
||||
logic.initLoadDataAction(() {
|
||||
setState(() {});
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
@ -49,32 +50,26 @@ class _BasicInformationPageState extends State<BasicInformationPage> {
|
||||
isHaveLine: true),
|
||||
CommonItem(
|
||||
leftTitel: "MAC/ID",
|
||||
rightTitle: state.lockBasicInfo.value.mac,
|
||||
rightTitle: "${state.lockBasicInfo.value.mac}/${state.lockBasicInfo.value.lockId}",
|
||||
allHeight: 70.h,
|
||||
isHaveLine: false),
|
||||
SizedBox(
|
||||
height: 10.h,
|
||||
),
|
||||
CommonItem(
|
||||
leftTitel: TranslationLoader
|
||||
.lanKeys!.electricQuantity!.tr,
|
||||
Obx(() => CommonItem(
|
||||
leftTitel: TranslationLoader.lanKeys!.electricQuantity!.tr,
|
||||
rightTitle: "${state.lockBasicInfo.value.electricQuantity}%",
|
||||
isHaveLine: true,
|
||||
isHaveDirection: true,
|
||||
action: () {
|
||||
Navigator.pushNamed(context,
|
||||
Routers.uploadElectricQuantityPage,
|
||||
arguments: {'lockSetInfoData': state.lockSetInfoData.value});
|
||||
}),
|
||||
Get.toNamed(Routers.uploadElectricQuantityPage, arguments: {'lockSetInfoData': state.lockSetInfoData.value});
|
||||
})),
|
||||
CommonItem(
|
||||
leftTitel: TranslationLoader
|
||||
.lanKeys!.periodValidity!.tr,
|
||||
rightTitle: getUseDateStr(state.lockBasicInfo.value),
|
||||
leftTitel: TranslationLoader.lanKeys!.periodValidity!.tr,
|
||||
rightTitle: logic.getUseKeyTypeStr(state.lockBasicInfo.value.startDate, state.lockBasicInfo.value.startDate, state.lockBasicInfo.value.keyType),
|
||||
allHeight: 70.h,
|
||||
isHaveLine: false),
|
||||
SizedBox(
|
||||
height: 10.h,
|
||||
),
|
||||
SizedBox(height: 10.h),
|
||||
CommonItem(
|
||||
leftTitel:
|
||||
TranslationLoader.lanKeys!.lockName!.tr,
|
||||
@ -89,33 +84,33 @@ class _BasicInformationPageState extends State<BasicInformationPage> {
|
||||
});
|
||||
}
|
||||
}),
|
||||
CommonItem(
|
||||
leftTitel:
|
||||
TranslationLoader.lanKeys!.lockGrouping!.tr,
|
||||
// rightTitle: state.getKeyInfosData.value.groupName == "" ? _groupName : itemData.groupName,
|
||||
Obx(() => CommonItem(
|
||||
leftTitel: TranslationLoader.lanKeys!.lockGrouping!.tr,
|
||||
rightTitle: state.lockBasicInfo.value.groupName,
|
||||
isHaveLine: true,
|
||||
isHaveDirection: true,
|
||||
action: () async {
|
||||
Navigator.pushNamed(
|
||||
context, Routers.lockSeletGroupingPage,
|
||||
Get.toNamed(Routers.lockSeletGroupingPage,
|
||||
arguments: {
|
||||
'lockSetInfoData': state.lockSetInfoData.value
|
||||
}).then((val) {
|
||||
})!.then((val) {
|
||||
if (val != null) {
|
||||
// mockNetworkDataRequest();
|
||||
setState(() {});
|
||||
}
|
||||
});
|
||||
}),
|
||||
})),
|
||||
Visibility(
|
||||
visible: (state.lockBasicInfo.value.isLockOwner == 1 || state.lockBasicInfo.value.keyRight == 1) ? true : false,
|
||||
child: CommonItem(
|
||||
leftTitel: TranslationLoader.lanKeys!.adminOpenLockPassword!.tr,
|
||||
rightTitle: "",
|
||||
rightTitle: state.lockSetInfoData.value!.lockBasicInfo!.adminPwd,
|
||||
isHaveLine: true,
|
||||
isHaveDirection: true,
|
||||
action: () {
|
||||
Navigator.pushNamed(context, Routers.adminOpenLockPasswordPage);
|
||||
Get.toNamed(Routers.adminOpenLockPasswordPage, arguments: {
|
||||
'lockSetInfoData': state.lockSetInfoData.value
|
||||
});
|
||||
}),
|
||||
),
|
||||
CommonItem(
|
||||
@ -132,35 +127,6 @@ class _BasicInformationPageState extends State<BasicInformationPage> {
|
||||
);
|
||||
}
|
||||
|
||||
//使用期限
|
||||
String getUseDateStr(LockBasicInfo indexEntity) {
|
||||
String useDateStr = '';
|
||||
if (indexEntity.keyType == XSConstantMacro.keyTypeTime) {
|
||||
//限期
|
||||
if (indexEntity.startDate != null && indexEntity.endDate != null) {
|
||||
DateTime startDateStr =
|
||||
DateTime.fromMillisecondsSinceEpoch(indexEntity.startDate!);
|
||||
DateTime endDateStr =
|
||||
DateTime.fromMillisecondsSinceEpoch(indexEntity.endDate!);
|
||||
useDateStr =
|
||||
'${startDateStr.toLocal().toString().substring(0, 16)}-${endDateStr.toLocal().toString().substring(0, 16)}';
|
||||
} else {
|
||||
useDateStr = '限期';
|
||||
}
|
||||
} else if (indexEntity.keyType == XSConstantMacro.keyTypeLong) {
|
||||
//永久
|
||||
useDateStr = '永久';
|
||||
} else if (indexEntity.keyType == XSConstantMacro.keyTypeOnce) {
|
||||
//单次
|
||||
useDateStr = '单次';
|
||||
} else if (indexEntity.keyType == XSConstantMacro.keyTypeLoop) {
|
||||
//循环
|
||||
useDateStr = '循环';
|
||||
}
|
||||
|
||||
return useDateStr;
|
||||
}
|
||||
|
||||
//1:限期 2:永久 3:单次 4:循环
|
||||
String getKeyTypeStr(int keyType) {
|
||||
String keyTypeStr = "";
|
||||
|
||||
@ -3,6 +3,7 @@ import 'package:get/get.dart';
|
||||
|
||||
import '../../../../../network/api_repository.dart';
|
||||
import '../../../../../tools/baseGetXController.dart';
|
||||
import '../../../../../tools/eventBusEventManage.dart';
|
||||
import '../../../electronicKey/electronicKeyDetail/keyOperationRecordEntity.dart';
|
||||
import 'editLockName_state.dart';
|
||||
|
||||
@ -17,6 +18,7 @@ class EditLockNameLogic extends BaseGetXController{
|
||||
if (entity.errorCode!.codeIsSuccessful) {
|
||||
showToast("修改成功");
|
||||
state.lockBasicInfo.value.lockAlias = state.changeLockNameController.text;
|
||||
eventBus.fire(LockSetChangeSetRefreshLockDetailWithType(3, state.lockBasicInfo.value.lockAlias!));
|
||||
Get.back(result: {
|
||||
"lockBasicInfo":state.lockBasicInfo.value
|
||||
});
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
|
||||
import '../../../../../network/api_repository.dart';
|
||||
import '../../../../../tools/baseGetXController.dart';
|
||||
import '../../../../../tools/eventBusEventManage.dart';
|
||||
import '../../../electronicKey/massSendElectronicKey/massSendLockGroupList/massSendLockGroupListEntity.dart';
|
||||
import 'lockSeletGrouping_state.dart';
|
||||
|
||||
@ -23,7 +24,12 @@ class LockSeletGroupingLogic extends BaseGetXController {
|
||||
if (entity.errorCode!.codeIsSuccessful) {
|
||||
showToast("设置锁分组成功");
|
||||
state.lockBasicInfo.value.groupId = itemData.keyGroupId;
|
||||
state.lockBasicInfo.value.groupName = itemData.keyGroupName;
|
||||
mockNetworkDataRequest();
|
||||
state.lockSetInfoData.value.lockBasicInfo!.groupId = itemData.keyGroupId;
|
||||
state.lockSetInfoData.value.lockBasicInfo!.groupName = itemData.keyGroupName;
|
||||
eventBus.fire(PassCurrentLockInformationEvent(state.lockSetInfoData.value));
|
||||
eventBus.fire(RefreshLockListInfoDataEvent());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -1,6 +1,18 @@
|
||||
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:flutter_reactive_ble/flutter_reactive_ble.dart';
|
||||
|
||||
import '../../../../../blue/blue_manage.dart';
|
||||
import '../../../../../blue/io_protocol/io_getStarLockStatusInfo.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 '../../../../../network/api_repository.dart';
|
||||
import '../../../../../tools/baseGetXController.dart';
|
||||
import '../../../../../tools/eventBusEventManage.dart';
|
||||
import '../../../../../tools/storage.dart';
|
||||
import '../../../electronicKey/electronicKeyDetail/keyOperationRecordEntity.dart';
|
||||
import 'uploadElectricQuantity_state.dart';
|
||||
|
||||
@ -8,11 +20,123 @@ class UploadElectricQuantityLogic extends BaseGetXController {
|
||||
final UploadElectricQuantityState state = UploadElectricQuantityState();
|
||||
|
||||
//电量更新请求
|
||||
Future<void> uploadElectricQuantityRequest() async {
|
||||
KeyOperationRecordEntity entity = await ApiRepository.to.uploadElectricQuantity('100', state.lockSetInfoData.value.lockId.toString());
|
||||
Future<void> uploadElectricQuantityRequest(String electricQuantity) async {
|
||||
KeyOperationRecordEntity entity = await ApiRepository.to.uploadElectricQuantity(electricQuantity, state.lockSetInfoData.value.lockId.toString());
|
||||
if (entity.errorCode!.codeIsSuccessful) {
|
||||
eventBus.fire(PassCurrentLockInformationEvent(state.lockSetInfoData.value));
|
||||
eventBus.fire(LockSetChangeSetRefreshLockDetailWithType(0, electricQuantity));
|
||||
eventBus.fire(RefreshLockListInfoDataEvent());
|
||||
|
||||
showToast("锁电量更新成功");
|
||||
}
|
||||
}
|
||||
|
||||
// 获取锁状态
|
||||
Future<void> getStarLockStatus() async {
|
||||
if(state.sureBtnState.value == 1){
|
||||
return;
|
||||
}
|
||||
state.sureBtnState.value = 1;
|
||||
|
||||
showEasyLoading();
|
||||
showBlueConnetctToastTimer(action: (){
|
||||
dismissEasyLoading();
|
||||
state.sureBtnState.value = 0;
|
||||
});
|
||||
BlueManage().bludSendData(BlueManage().connectDeviceName, (DeviceConnectionState deviceConnectionState) async {
|
||||
if (deviceConnectionState == DeviceConnectionState.connected) {
|
||||
dismissEasyLoading();
|
||||
var privateKey = await Storage.getStringList(saveBluePrivateKey);
|
||||
List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
|
||||
IoSenderManage.senderGetStarLockStatuInfo(
|
||||
lockID: BlueManage().connectDeviceName,
|
||||
userID: await Storage.getUid(),
|
||||
privateKey: getPrivateKeyList,
|
||||
);
|
||||
} else if (deviceConnectionState == DeviceConnectionState.disconnected) {
|
||||
dismissEasyLoading();
|
||||
cancelBlueConnetctToastTimer();
|
||||
state.sureBtnState.value = 0;
|
||||
if(state.ifCurrentScreen.value == true){
|
||||
showBlueConnetctToast();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// 获取解析后的数据
|
||||
late StreamSubscription<Reply> _replySubscription;
|
||||
void _initReplySubscription() {
|
||||
_replySubscription = EventBusManager().eventBus!.on<Reply>().listen((reply) {
|
||||
// 获取锁状态信息
|
||||
if (reply is GetStarLockStatuInfoReply) {
|
||||
_replyGetStarLockStatusInfo(reply);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// 获取星锁状态
|
||||
Future<void> _replyGetStarLockStatusInfo(Reply reply) async {
|
||||
int status = reply.data[2];
|
||||
switch (status) {
|
||||
case 0x00:
|
||||
//成功
|
||||
print("${reply.commandType}数据解析成功");
|
||||
state.sureBtnState.value = 0;
|
||||
dismissEasyLoading();
|
||||
cancelBlueConnetctToastTimer();
|
||||
|
||||
// 电池剩余电量
|
||||
var battRemCap = reply.data[132];
|
||||
state.lockSetInfoData.value.lockBasicInfo!.electricQuantity = battRemCap;
|
||||
state.uploadElectricQuantityDate.value = DateTime.now().millisecondsSinceEpoch;
|
||||
state.lockSetInfoData.value.lockBasicInfo!.electricQuantityDate = DateTime.now().millisecondsSinceEpoch;
|
||||
uploadElectricQuantityRequest(battRemCap.toString());
|
||||
break;
|
||||
case 0x06:
|
||||
//无权限
|
||||
print("${reply.commandType}需要鉴权");
|
||||
|
||||
break;
|
||||
case 0x07:
|
||||
//无权限
|
||||
print("${reply.commandType}用户无权限");
|
||||
|
||||
break;
|
||||
case 0x09:
|
||||
// 权限校验错误
|
||||
print("${reply.commandType}权限校验错误");
|
||||
|
||||
break;
|
||||
default:
|
||||
//失败
|
||||
print("${reply.commandType}失败");
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
void onReady() {
|
||||
// TODO: implement onReady
|
||||
super.onReady();
|
||||
print("NearbyLockLogic onReady()");
|
||||
|
||||
_initReplySubscription();
|
||||
}
|
||||
|
||||
@override
|
||||
void onInit() {
|
||||
// TODO: implement onInit
|
||||
print("NearbyLockLogic onInit()");
|
||||
super.onInit();
|
||||
}
|
||||
|
||||
@override
|
||||
void onClose() {
|
||||
// TODO: implement onClose
|
||||
super.onClose();
|
||||
_replySubscription.cancel();
|
||||
}
|
||||
|
||||
}
|
||||
@ -1,8 +1,12 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_easyloading/flutter_easyloading.dart';
|
||||
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
||||
import 'package:get/get.dart';
|
||||
|
||||
import '../../../../../app_settings/app_colors.dart';
|
||||
import '../../../../../blue/blue_manage.dart';
|
||||
import '../../../../../tools/appRouteObserver.dart';
|
||||
import '../../../../../tools/dateTool.dart';
|
||||
import '../../../../../tools/submitBtn.dart';
|
||||
import '../../../../../tools/titleAppBar.dart';
|
||||
import '../../../../../translations/trans_lib.dart';
|
||||
@ -16,7 +20,7 @@ class UploadElectricQuantityPage extends StatefulWidget {
|
||||
_UploadElectricQuantityPageState();
|
||||
}
|
||||
|
||||
class _UploadElectricQuantityPageState extends State<UploadElectricQuantityPage> {
|
||||
class _UploadElectricQuantityPageState extends State<UploadElectricQuantityPage> with RouteAware {
|
||||
final logic = Get.put(UploadElectricQuantityLogic());
|
||||
final state = Get.find<UploadElectricQuantityLogic>().state;
|
||||
|
||||
@ -45,16 +49,27 @@ class _UploadElectricQuantityPageState extends State<UploadElectricQuantityPage>
|
||||
SizedBox(
|
||||
height: 40.h,
|
||||
),
|
||||
Row(
|
||||
Obx(() => Row(
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
children: [
|
||||
Expanded(
|
||||
child: Text(
|
||||
"${TranslationLoader.lanKeys!.electricQuantity!.tr} 100%",
|
||||
style: TextStyle(fontSize: 20.sp),
|
||||
)),
|
||||
"${TranslationLoader.lanKeys!.electricQuantity!.tr} ${state.lockSetInfoData.value.lockBasicInfo!.electricQuantity}%",
|
||||
style: TextStyle(fontSize: 20.sp),
|
||||
)),
|
||||
],
|
||||
),
|
||||
)),
|
||||
SizedBox(height: 10.h),
|
||||
Obx(() => Row(
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
children: [
|
||||
Expanded(
|
||||
child: Text(
|
||||
"电量更新时间:${DateTool().dateToYMDHNString(state.uploadElectricQuantityDate.value.toString())}",
|
||||
style: TextStyle(fontSize: 20.sp),
|
||||
)),
|
||||
],
|
||||
)),
|
||||
SizedBox(
|
||||
height: 30.h,
|
||||
),
|
||||
@ -65,10 +80,68 @@ class _UploadElectricQuantityPageState extends State<UploadElectricQuantityPage>
|
||||
// margin: EdgeInsets.only(left: 03.w, right: 30.w, top: 20.w),
|
||||
padding: EdgeInsets.only(top: 20.w, bottom: 20.w),
|
||||
onClick: () {
|
||||
logic.uploadElectricQuantityRequest();
|
||||
logic.getStarLockStatus();
|
||||
}),
|
||||
],
|
||||
),
|
||||
));
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
@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();
|
||||
print("lockSet===didPush");
|
||||
state.ifCurrentScreen.value = true;
|
||||
}
|
||||
|
||||
/// 返回上一个界面 当前界面即将消失
|
||||
@override
|
||||
void didPop() {
|
||||
super.didPop();
|
||||
print("lockSet===didPop");
|
||||
logic.cancelBlueConnetctToastTimer();
|
||||
logic.dismissEasyLoading();
|
||||
BlueManage().stopScan();
|
||||
state.ifCurrentScreen.value = false;
|
||||
state.sureBtnState.value = 0;
|
||||
}
|
||||
|
||||
/// 从下级返回 当前界面即将出现
|
||||
@override
|
||||
void didPopNext() {
|
||||
super.didPopNext();
|
||||
print("lockSet===didPopNext");
|
||||
state.ifCurrentScreen.value = true;
|
||||
}
|
||||
|
||||
/// 进入下级界面 当前界面即将消失
|
||||
@override
|
||||
void didPushNext() {
|
||||
super.didPushNext();
|
||||
print("lockSet===didPushNext");
|
||||
logic.cancelBlueConnetctToastTimer();
|
||||
if (EasyLoading.isShow) EasyLoading.dismiss(animation: true);
|
||||
BlueManage().stopScan();
|
||||
state.ifCurrentScreen.value = false;
|
||||
state.sureBtnState.value = 0;
|
||||
}
|
||||
}
|
||||
|
||||
@ -6,10 +6,15 @@ import '../../lockSet/lockSetInfo_entity.dart';
|
||||
|
||||
class UploadElectricQuantityState {
|
||||
var lockSetInfoData = LockSetInfoData().obs;
|
||||
var uploadElectricQuantityDate = 0.obs;
|
||||
|
||||
var ifCurrentScreen = true.obs; // 是否是当前界面,用于判断是否需要针对当前界面进行展示
|
||||
var sureBtnState = 0.obs;// 0普通状态可用 1不可用
|
||||
|
||||
UploadElectricQuantityState() {
|
||||
var map = Get.arguments;
|
||||
lockSetInfoData.value = map["lockSetInfoData"];
|
||||
uploadElectricQuantityDate.value = lockSetInfoData.value.lockBasicInfo!.electricQuantityDate!;
|
||||
}
|
||||
|
||||
}
|
||||
@ -29,8 +29,9 @@ class BurglarAlarmLogic extends BaseGetXController{
|
||||
|
||||
state.burglarAlarmEnable.value = state.burglarAlarmEnable.value == 1 ? 0 : 1;
|
||||
state.lockSetInfoData.value.lockSettingInfo!.antiPrySwitch = state.burglarAlarmEnable.value;
|
||||
eventBus.fire(PassCurrentLockInformationEvent(state.lockSetInfoData.value));
|
||||
showToast("操作成功");
|
||||
showToast("操作成功", something: (){
|
||||
eventBus.fire(PassCurrentLockInformationEvent(state.lockSetInfoData.value));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@ -86,6 +87,7 @@ class BurglarAlarmLogic extends BaseGetXController{
|
||||
print("${reply.commandType}数据解析成功");
|
||||
state.sureBtnState.value = 0;
|
||||
dismissEasyLoading();
|
||||
cancelBlueConnetctToastTimer();
|
||||
_setLockSetGeneralSetting();
|
||||
break;
|
||||
case 0x06:
|
||||
|
||||
@ -36,7 +36,7 @@ class CheckInCreatCompanyLogic extends BaseGetXController{
|
||||
state.lockSetInfoData.value.lockSettingInfo!.attendance = 1;
|
||||
print("333state.lockSetInfoData.value.lockSettingInfo!.attendance:${state.lockSetInfoData.value.lockSettingInfo!.attendance}");
|
||||
eventBus.fire(PassCurrentLockInformationEvent(state.lockSetInfoData.value));
|
||||
eventBus.fire(LockSetChangeSetRefreshLockDetailWithType(0, 1));
|
||||
eventBus.fire(LockSetChangeSetRefreshLockDetailWithType(0, "1"));
|
||||
Get.back();
|
||||
showToast("设置成功");
|
||||
}
|
||||
|
||||
@ -65,6 +65,7 @@ class ConfiguringWifiLogic extends BaseGetXController{
|
||||
//成功
|
||||
print("${reply.commandType}数据解析成功");
|
||||
state.sureBtnState.value = 0;
|
||||
cancelBlueConnetctToastTimer();
|
||||
dismissEasyLoading();
|
||||
showToast("配网成功");
|
||||
break;
|
||||
|
||||
@ -301,6 +301,8 @@ class LockFeature {
|
||||
}
|
||||
|
||||
class LockBasicInfo {
|
||||
int? lockId;
|
||||
int? electricQuantityDate;
|
||||
int? keyId;
|
||||
String? model;
|
||||
int? electricQuantity;
|
||||
@ -309,6 +311,7 @@ class LockBasicInfo {
|
||||
String? lockAlias;
|
||||
String? lockName;
|
||||
int? groupId;
|
||||
String? groupName;
|
||||
List<GroupData>? groupData;
|
||||
String? adminPwd;
|
||||
int? keyType;
|
||||
@ -320,7 +323,10 @@ class LockBasicInfo {
|
||||
int? lockUserNo;
|
||||
|
||||
LockBasicInfo(
|
||||
{this.keyId,
|
||||
{
|
||||
this.lockId,
|
||||
this.electricQuantityDate,
|
||||
this.keyId,
|
||||
this.model,
|
||||
this.electricQuantity,
|
||||
this.indate,
|
||||
@ -328,6 +334,7 @@ class LockBasicInfo {
|
||||
this.lockAlias,
|
||||
this.lockName,
|
||||
this.groupId,
|
||||
this.groupName,
|
||||
this.groupData,
|
||||
this.adminPwd,
|
||||
this.keyType,
|
||||
@ -339,6 +346,8 @@ class LockBasicInfo {
|
||||
this.lockUserNo});
|
||||
|
||||
LockBasicInfo.fromJson(Map<String, dynamic> json) {
|
||||
lockId = json['lockId'];
|
||||
electricQuantityDate = json['electricQuantityDate'];
|
||||
keyId = json['keyId'];
|
||||
model = json['model'];
|
||||
electricQuantity = json['electricQuantity'];
|
||||
@ -347,6 +356,7 @@ class LockBasicInfo {
|
||||
lockAlias = json['lockAlias'];
|
||||
lockName = json['lockName'];
|
||||
groupId = json['groupId'];
|
||||
groupName = json['groupName'];
|
||||
if (json['groupData'] != null) {
|
||||
groupData = <GroupData>[];
|
||||
json['groupData'].forEach((v) {
|
||||
@ -365,6 +375,8 @@ class LockBasicInfo {
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final Map<String, dynamic> data = <String, dynamic>{};
|
||||
data['lockId'] = lockId;
|
||||
data['electricQuantityDate'] = electricQuantityDate;
|
||||
data['keyId'] = keyId;
|
||||
data['model'] = model;
|
||||
data['electricQuantity'] = electricQuantity;
|
||||
@ -373,6 +385,7 @@ class LockBasicInfo {
|
||||
data['lockAlias'] = lockAlias;
|
||||
data['lockName'] = lockName;
|
||||
data['groupId'] = groupId;
|
||||
data['groupName'] = groupName;
|
||||
if (groupData != null) {
|
||||
data['groupData'] = groupData!.map((v) => v.toJson()).toList();
|
||||
}
|
||||
|
||||
@ -46,13 +46,12 @@ class LockSetLogic extends BaseGetXController {
|
||||
}
|
||||
|
||||
// 设置支持功能(不带参数)
|
||||
if (reply is SetSupportFunctionsNoParametersReply) {
|
||||
if ((reply is SetSupportFunctionsNoParametersReply) && (state.ifCurrentScreen.value == true)) {
|
||||
_replySetSupportFunctionsWithParameters(reply);
|
||||
}
|
||||
|
||||
// 读取支持功能(不带参数)
|
||||
if ((reply is ReadSupportFunctionsNoParametersReply) &&
|
||||
(state.settingUpSupportFeatures == 56)) {
|
||||
if ((reply is ReadSupportFunctionsNoParametersReply) && (state.settingUpSupportFeatures == 56)) {
|
||||
_readSupportFunctionsWithParametersReply(reply);
|
||||
}
|
||||
});
|
||||
@ -214,6 +213,7 @@ class LockSetLogic extends BaseGetXController {
|
||||
print("${reply.commandType}数据解析成功");
|
||||
// Toast.show(msg: "操作成功");featureEnable = state.isOpenStayWarn.value == 1 ? 0 : 1;
|
||||
dismissEasyLoading();
|
||||
cancelBlueConnetctToastTimer();
|
||||
if (state.settingUpSupportFeatures == 55) {
|
||||
// APP开锁时是否需联网
|
||||
// state.isOpenLockNeedOnline.value = state.isOpenLockNeedOnline.value == 1 ? 0 : 1;
|
||||
@ -376,9 +376,7 @@ class LockSetLogic extends BaseGetXController {
|
||||
dismissEasyLoading();
|
||||
});
|
||||
BlueManage().bludSendData(BlueManage().connectDeviceName, (DeviceConnectionState connectionState) async {
|
||||
cancelBlueConnetctToastTimer();
|
||||
if (connectionState == DeviceConnectionState.connected) {
|
||||
dismissEasyLoading();
|
||||
var privateKey = await Storage.getStringList(saveBluePrivateKey);
|
||||
List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
|
||||
|
||||
@ -440,7 +438,7 @@ class LockSetLogic extends BaseGetXController {
|
||||
|
||||
state.isOpenBlueBroadcast.value = state.lockSettingInfo.value.bluetoothBroadcast!;
|
||||
state.isOpenExceptionWarnings.value = state.lockSettingInfo.value.bluetoothBroadcast!;
|
||||
|
||||
Get.log('请求成功333');
|
||||
// await _readSupportFunctionsNoParameters(56);
|
||||
// _readSupportFunctionsNoParameters(62);
|
||||
}
|
||||
@ -455,9 +453,13 @@ class LockSetLogic extends BaseGetXController {
|
||||
BlueManage().connectDeviceMacAddress = "";
|
||||
eventBus.fire(RefreshLockListInfoDataEvent());
|
||||
if(state.isOnlyOneData.value == true){
|
||||
Get.close(1);
|
||||
Future.delayed(const Duration(milliseconds: 200)).then((e) {
|
||||
Get.close(1);
|
||||
});
|
||||
}else{
|
||||
Get.close(2);
|
||||
Future.delayed(const Duration(milliseconds: 200)).then((e) {
|
||||
Get.close(2);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -472,9 +474,13 @@ class LockSetLogic extends BaseGetXController {
|
||||
BlueManage().connectDeviceMacAddress = "";
|
||||
eventBus.fire(RefreshLockListInfoDataEvent());
|
||||
if(state.isOnlyOneData.value == true){
|
||||
Get.close(1);
|
||||
Future.delayed(const Duration(milliseconds: 200)).then((e) {
|
||||
Get.close(1);
|
||||
});
|
||||
}else{
|
||||
Get.close(2);
|
||||
Future.delayed(const Duration(milliseconds: 200)).then((e) {
|
||||
Get.close(2);
|
||||
});
|
||||
}
|
||||
// Get.offAllNamed(Routers.starLockMain);
|
||||
}
|
||||
@ -626,14 +632,13 @@ class LockSetLogic extends BaseGetXController {
|
||||
attendance: state.isAttendance.value == 1 ? 0 : 1,
|
||||
);
|
||||
if (entity.errorCode!.codeIsSuccessful) {
|
||||
eventBus.fire(RefreshLockListInfoDataEvent());
|
||||
|
||||
state.isAttendance.value = (state.isAttendance.value == 1 ? 0 : 1);
|
||||
state.lockSettingInfo.value.attendance = state.isAttendance.value;
|
||||
|
||||
eventBus.fire(LockSetChangeSetRefreshLockDetailWithType(0, state.lockSettingInfo.value.attendance!));
|
||||
showToast("设置成功", something: (){
|
||||
eventBus.fire(RefreshLockListInfoDataEvent());
|
||||
eventBus.fire(LockSetChangeSetRefreshLockDetailWithType(0, state.lockSettingInfo.value.attendance!.toString()));
|
||||
});
|
||||
print("state.lockSettingInfo.value.attendance:${state.lockSettingInfo.value.attendance}");
|
||||
showToast("设置成功");
|
||||
}
|
||||
}
|
||||
|
||||
@ -644,12 +649,12 @@ class LockSetLogic extends BaseGetXController {
|
||||
unlockReminderPush: state.isLockPickingReminder.value == 1 ? 0 : 1,
|
||||
);
|
||||
if (entity.errorCode!.codeIsSuccessful) {
|
||||
eventBus.fire(RefreshLockListInfoDataEvent());
|
||||
|
||||
state.isLockPickingReminder.value = (state.isLockPickingReminder.value == 1 ? 0 : 1);
|
||||
state.lockSettingInfo.value.unlockReminderPush = state.isLockPickingReminder.value;
|
||||
showToast("设置成功");
|
||||
} else {}
|
||||
showToast("设置成功", something: (){
|
||||
eventBus.fire(RefreshLockListInfoDataEvent());
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// 设置是否打开开锁时是否需联网
|
||||
@ -659,14 +664,14 @@ class LockSetLogic extends BaseGetXController {
|
||||
appUnlockOnline: state.isOpenLockNeedOnline.value == 1 ? 0 : 1,
|
||||
);
|
||||
if (entity.errorCode!.codeIsSuccessful) {
|
||||
eventBus.fire(RefreshLockListInfoDataEvent());
|
||||
|
||||
state.isOpenLockNeedOnline.value = (state.isOpenLockNeedOnline.value == 1 ? 0 : 1);
|
||||
state.lockSettingInfo.value.appUnlockOnline = state.isOpenLockNeedOnline.value;
|
||||
|
||||
eventBus.fire(LockSetChangeSetRefreshLockDetailWithType(0, state.lockSettingInfo.value.appUnlockOnline!));
|
||||
print("state.lockSettingInfo.value.appUnlockOnline:${state.lockSettingInfo.value.appUnlockOnline}");
|
||||
showToast("设置成功");
|
||||
eventBus.fire(LockSetChangeSetRefreshLockDetailWithType(0, state.lockSettingInfo.value.appUnlockOnline!.toString()));
|
||||
showToast("设置成功",something: (){
|
||||
eventBus.fire(RefreshLockListInfoDataEvent());
|
||||
print("state.lockSettingInfo.value.appUnlockOnline:${state.lockSettingInfo.value.appUnlockOnline}");
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -645,35 +645,35 @@ class _LockSetPageState extends State<LockSetPage> with RouteAware {
|
||||
}
|
||||
|
||||
// 异常警告
|
||||
CupertinoSwitch _lockExceptionWarningsSwitch() {
|
||||
print("isOpenBlueBroadcast222:${state.isOpenExceptionWarnings.value}");
|
||||
return CupertinoSwitch(
|
||||
activeColor: CupertinoColors.activeBlue,
|
||||
trackColor: CupertinoColors.systemGrey5,
|
||||
thumbColor: CupertinoColors.white,
|
||||
value: (state.isOpenExceptionWarnings.value) == 1 ? true : false,
|
||||
onChanged: (value) {
|
||||
setState(() {
|
||||
logic.sendBurglarAlarm(62);
|
||||
});
|
||||
},
|
||||
);
|
||||
}
|
||||
// CupertinoSwitch _lockExceptionWarningsSwitch() {
|
||||
// print("isOpenBlueBroadcast222:${state.isOpenExceptionWarnings.value}");
|
||||
// return CupertinoSwitch(
|
||||
// activeColor: CupertinoColors.activeBlue,
|
||||
// trackColor: CupertinoColors.systemGrey5,
|
||||
// thumbColor: CupertinoColors.white,
|
||||
// value: (state.isOpenExceptionWarnings.value) == 1 ? true : false,
|
||||
// onChanged: (value) {
|
||||
// setState(() {
|
||||
// logic.sendBurglarAlarm(62);
|
||||
// });
|
||||
// },
|
||||
// );
|
||||
// }
|
||||
|
||||
// 逗留警告
|
||||
CupertinoSwitch _lockStayWarnSwitch() {
|
||||
return CupertinoSwitch(
|
||||
activeColor: CupertinoColors.activeBlue,
|
||||
trackColor: CupertinoColors.systemGrey5,
|
||||
thumbColor: CupertinoColors.white,
|
||||
value: (state.isOpenExceptionWarnings.value) == 1 ? true : false,
|
||||
onChanged: (value) {
|
||||
setState(() {
|
||||
logic.sendBurglarAlarm(61);
|
||||
});
|
||||
},
|
||||
);
|
||||
}
|
||||
// CupertinoSwitch _lockStayWarnSwitch() {
|
||||
// return CupertinoSwitch(
|
||||
// activeColor: CupertinoColors.activeBlue,
|
||||
// trackColor: CupertinoColors.systemGrey5,
|
||||
// thumbColor: CupertinoColors.white,
|
||||
// value: (state.isOpenExceptionWarnings.value) == 1 ? true : false,
|
||||
// onChanged: (value) {
|
||||
// setState(() {
|
||||
// logic.sendBurglarAlarm(61);
|
||||
// });
|
||||
// },
|
||||
// );
|
||||
// }
|
||||
|
||||
// 支持蓝牙广播
|
||||
CupertinoSwitch _lockBlueBroadcastSwitch() {
|
||||
|
||||
@ -92,6 +92,7 @@ class LockSoundSetLogic extends BaseGetXController {
|
||||
//成功
|
||||
print("${reply.commandType}数据解析成功");
|
||||
state.sureBtnState.value = 0;
|
||||
cancelBlueConnetctToastTimer();
|
||||
dismissEasyLoading();
|
||||
_setLockSetGeneralSetting();
|
||||
break;
|
||||
|
||||
@ -99,6 +99,7 @@ class LockTimeLogic extends BaseGetXController{
|
||||
// state.dateTime.value = dataEime;
|
||||
|
||||
state.sureBtnState.value = 0;
|
||||
cancelBlueConnetctToastTimer();
|
||||
dismissEasyLoading();
|
||||
showToast("锁时间更新成功");
|
||||
break;
|
||||
|
||||
@ -51,7 +51,7 @@ class NormallyOpenModeLogic extends BaseGetXController{
|
||||
|
||||
state.lockSetInfoData.value.lockSettingInfo!.passageMode = state.isOpenNormallyOpenMode.value == true ? 1:0;
|
||||
eventBus.fire(PassCurrentLockInformationEvent(state.lockSetInfoData.value));
|
||||
eventBus.fire(LockSetChangeSetRefreshLockDetailWithType(2, state.lockSetInfoData.value.lockSettingInfo!.passageMode!));
|
||||
eventBus.fire(LockSetChangeSetRefreshLockDetailWithType(2, state.lockSetInfoData.value.lockSettingInfo!.passageMode!.toString()));
|
||||
showToast("操作成功");
|
||||
}
|
||||
}
|
||||
@ -112,6 +112,7 @@ class NormallyOpenModeLogic extends BaseGetXController{
|
||||
//成功
|
||||
print("${reply.commandType}数据解析成功");
|
||||
state.sureBtnState.value = 0;
|
||||
cancelBlueConnetctToastTimer();
|
||||
dismissEasyLoading();
|
||||
configPassageMode();
|
||||
break;
|
||||
|
||||
@ -85,6 +85,7 @@ class RemoteUnlockingLogic extends BaseGetXController{
|
||||
//成功
|
||||
print("${reply.commandType}数据解析成功");
|
||||
state.sureBtnState.value = 0;
|
||||
cancelBlueConnetctToastTimer();
|
||||
dismissEasyLoading();
|
||||
_remoteUnlockingOpenOrClose();
|
||||
break;
|
||||
|
||||
@ -86,6 +86,7 @@ class ResetButtonLogic extends BaseGetXController{
|
||||
//成功
|
||||
print("${reply.commandType}数据解析成功");
|
||||
state.sureBtnState.value = 0;
|
||||
cancelBlueConnetctToastTimer();
|
||||
dismissEasyLoading();
|
||||
_setLockSetGeneralSetting();
|
||||
break;
|
||||
|
||||
@ -54,7 +54,7 @@ class LockDetailLogic extends BaseGetXController {
|
||||
}
|
||||
|
||||
// 添加用户
|
||||
if (reply is AddUserReply) {
|
||||
if ((reply is AddUserReply) && (state.ifCurrentScreen.value == true)) {
|
||||
_replyAddUserKey(reply);
|
||||
}
|
||||
});
|
||||
@ -302,6 +302,7 @@ class LockDetailLogic extends BaseGetXController {
|
||||
case 0x00:
|
||||
//成功
|
||||
print("添加用户数据解析成功");
|
||||
cancelBlueConnetctToastTimer();
|
||||
state.lockUserNo = reply.data[47];
|
||||
_updateLockUserNo();
|
||||
|
||||
@ -658,16 +659,24 @@ class LockDetailLogic extends BaseGetXController {
|
||||
_lockSetOpenOrCloseCheckInRefreshLockDetailWithAttendanceEvent = eventBus.on<LockSetChangeSetRefreshLockDetailWithType>().listen((event) {
|
||||
if (event.type == 0) {
|
||||
// 0考勤
|
||||
state.isAttendance.value = event.setResult;
|
||||
state.keyInfos.value.lockSetting!.attendance = event.setResult;
|
||||
state.isAttendance.value = int.parse(event.setResult);
|
||||
state.keyInfos.value.lockSetting!.attendance = int.parse(event.setResult);
|
||||
} else if (event.type == 1) {
|
||||
// 1 开锁时是否需联网
|
||||
state.isOpenLockNeedOnline.value = event.setResult;
|
||||
state.keyInfos.value.lockSetting!.appUnlockOnline = event.setResult;
|
||||
state.isOpenLockNeedOnline.value = int.parse(event.setResult);
|
||||
state.keyInfos.value.lockSetting!.appUnlockOnline = int.parse(event.setResult);
|
||||
} else if (event.type == 2) {
|
||||
// 2 常开模式
|
||||
state.isOpenPassageMode.value = event.setResult;
|
||||
state.keyInfos.value.passageMode = event.setResult;
|
||||
state.isOpenPassageMode.value = int.parse(event.setResult);
|
||||
state.keyInfos.value.passageMode = int.parse(event.setResult);
|
||||
} else if (event.type == 3) {
|
||||
// 3 修改了锁名字
|
||||
state.lockAlias.value = event.setResult;
|
||||
state.keyInfos.value.lockAlias = event.setResult;
|
||||
} else if (event.type == 4) {
|
||||
// 4 更新了电量
|
||||
state.electricQuantity.value = int.parse(event.setResult);
|
||||
state.keyInfos.value.electricQuantity = int.parse(event.setResult);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@ -41,7 +41,7 @@ class _LockDetailMainPageState extends State<LockDetailMainPage> {
|
||||
return Scaffold(
|
||||
backgroundColor: Colors.white,
|
||||
appBar: TitleAppBar(
|
||||
barTitle: TranslationLoader.lanKeys!.starLock!.tr,
|
||||
barTitle: "星锁".tr,
|
||||
haveBack: true,
|
||||
backgroundColor: AppColors.mainColor),
|
||||
body: LockDetailPage(isOnlyOneData:isOnlyOneData, lockListInfoItemEntity: keyInfos),
|
||||
|
||||
@ -50,6 +50,7 @@ class _LockDetailPageState extends State<LockDetailPage>
|
||||
state.keyInfos.value.lockSetting!.appUnlockOnline!;
|
||||
state.electricQuantity.value = state.keyInfos.value.electricQuantity!;
|
||||
state.isOpenPassageMode.value = state.keyInfos.value.passageMode!;
|
||||
state.lockAlias.value = state.keyInfos.value.lockAlias!;
|
||||
|
||||
BlueManage().connectDeviceName = state.keyInfos.value.bluetooth!.bluetoothDeviceName!;
|
||||
|
||||
@ -124,9 +125,8 @@ class _LockDetailPageState extends State<LockDetailPage>
|
||||
width: 1.sw - 120.w * 2,
|
||||
child: Obx(() => Center(
|
||||
child: Text(
|
||||
widget.lockListInfoItemEntity.lockAlias!,
|
||||
style:
|
||||
TextStyle(fontSize: 22.sp, fontWeight: FontWeight.w400, color: state.isOpenPassageMode.value == 1 ? AppColors.openPassageModeColor : AppColors.darkGrayTextColor),
|
||||
state.lockAlias.value,
|
||||
style: TextStyle(fontSize: 22.sp, fontWeight: FontWeight.w400, color: state.isOpenPassageMode.value == 1 ? AppColors.openPassageModeColor : AppColors.darkGrayTextColor),
|
||||
)))
|
||||
),
|
||||
Positioned(
|
||||
|
||||
@ -26,6 +26,7 @@ class LockDetailState {
|
||||
var isOpenLockNeedOnline = 0.obs; // APP开锁时是否需联网
|
||||
var electricQuantity = 0.obs; // 电量
|
||||
var isOpenPassageMode = 0.obs; // 是否开启了常开模式
|
||||
var lockAlias = "".obs; // 锁名字
|
||||
|
||||
var currentDeviceUUid = "".obs;// 当前设备的uuid
|
||||
|
||||
|
||||
@ -7,34 +7,6 @@ import 'lockList_state.dart';
|
||||
class LockListLogic extends BaseGetXController{
|
||||
LockListState state = LockListState();
|
||||
|
||||
String getUseKeyTypeStr(LockListInfoItemEntity indexEntity) {
|
||||
String useDateStr = '';
|
||||
if (indexEntity.keyType == XSConstantMacro.keyTypeTime) {
|
||||
//限期
|
||||
DateTime startDateStr =
|
||||
DateTime.fromMillisecondsSinceEpoch(indexEntity.startDate!);
|
||||
DateTime endDateStr =
|
||||
DateTime.fromMillisecondsSinceEpoch(indexEntity.endDate!);
|
||||
useDateStr =
|
||||
'${startDateStr.toLocal().toString().substring(0, 16)} - ${endDateStr.toLocal().toString().substring(0, 16)}';
|
||||
} else if (indexEntity.keyType == XSConstantMacro.keyTypeLong) {
|
||||
//永久
|
||||
// DateTime dateStr = DateTime.fromMillisecondsSinceEpoch(indexEntity.date!);
|
||||
// useDateStr = '${dateStr.toLocal().toString().substring(0, 16)}\n永久';
|
||||
useDateStr = '永久';
|
||||
} else if (indexEntity.keyType == XSConstantMacro.keyTypeOnce) {
|
||||
//单次
|
||||
// DateTime dateStr = DateTime.fromMillisecondsSinceEpoch(indexEntity.date!);
|
||||
// useDateStr = '${dateStr.toLocal().toString().substring(0, 16)} \n单次';
|
||||
useDateStr = '单次';
|
||||
} else if (indexEntity.keyType == XSConstantMacro.keyTypeLoop) {
|
||||
//循环
|
||||
useDateStr = '循环';
|
||||
}
|
||||
|
||||
return useDateStr;
|
||||
}
|
||||
|
||||
String showElectricIcon (int electricnumber){
|
||||
if(electricnumber >= 100){
|
||||
return 'images/main/icon_lockElectricLevel_5.png';
|
||||
|
||||
@ -202,7 +202,7 @@ class _LockListPageState extends State<LockListPage> {
|
||||
children: [
|
||||
SizedBox(width: 30.w),
|
||||
Text(
|
||||
"${logic.getUseKeyTypeStr(keyInfo)}/${keyInfo.isLockOwner == 1 ? '超级管理员' : (keyInfo.keyRight == 1 ? "授权管理员" : "普通用户")}",
|
||||
"${logic.getUseKeyTypeStr(keyInfo.startDate, keyInfo.endDate, keyInfo.keyType)}/${keyInfo.isLockOwner == 1 ? '超级管理员' : (keyInfo.keyRight == 1 ? "授权管理员" : "普通用户")}",
|
||||
style: TextStyle(
|
||||
fontSize: 18.sp, color: AppColors.darkGrayTextColor),
|
||||
),
|
||||
|
||||
@ -32,7 +32,7 @@ class _StarLockMainPageState extends State<StarLockMainPage> with BaseWidget {
|
||||
return Scaffold(
|
||||
backgroundColor: const Color(0xFFF5F5F5),
|
||||
appBar: TitleAppBar(
|
||||
barTitle: TranslationLoader.lanKeys!.starLock!.tr,
|
||||
barTitle: "星锁".tr,
|
||||
haveBack: false,
|
||||
haveOtherLeftWidget: true,
|
||||
leftWidget: Builder(
|
||||
|
||||
@ -1,24 +1,18 @@
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_reactive_ble/flutter_reactive_ble.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:get_storage/get_storage.dart';
|
||||
import 'package:star_lock/blue/io_protocol/io_getPrivateKey.dart';
|
||||
import 'package:star_lock/blue/io_protocol/io_getPublicKey.dart';
|
||||
import 'package:star_lock/tools/baseGetXController.dart';
|
||||
|
||||
import '../../../appRouters.dart';
|
||||
import '../../../blue/blue_manage.dart';
|
||||
import '../../../blue/io_protocol/io_addUser.dart';
|
||||
import '../../../blue/io_protocol/io_getStarLockStatusInfo.dart';
|
||||
import '../../../blue/io_reply.dart';
|
||||
import '../../../blue/io_tool/io_manager.dart';
|
||||
import '../../../blue/io_tool/io_model.dart';
|
||||
import '../../../blue/io_tool/io_tool.dart';
|
||||
import '../../../blue/io_tool/manager_event_bus.dart';
|
||||
import '../../../blue/sender_manage.dart';
|
||||
import '../../../tools/dateTool.dart';
|
||||
import '../../../tools/storage.dart';
|
||||
import 'nearbyLock_state.dart';
|
||||
|
||||
@ -245,8 +239,7 @@ class NearbyLockLogic extends BaseGetXController {
|
||||
var featureValueLength = reply.data[173];
|
||||
// 锁特征值说明(本机能支持的功能)
|
||||
// 获取到锁给的字符数组
|
||||
var featureValue =
|
||||
reply.data.sublist(index + 1, index + featureValueLength + 1);
|
||||
var featureValue = reply.data.sublist(index + 1, index + featureValueLength + 1);
|
||||
String featureValueStr = asciiString(featureValue);
|
||||
state.featureValue = featureValueStr;
|
||||
// List allFeatureValueTwoList = charListChangeIntList(featureValue);
|
||||
@ -256,9 +249,8 @@ class NearbyLockLogic extends BaseGetXController {
|
||||
// 使能特征值字符串长度
|
||||
var featureEnValLength = reply.data[index];
|
||||
// 使能锁特征值说明(本机启用的功能)
|
||||
var featureEnVal =
|
||||
reply.data.sublist(index + 1, index + featureEnValLength + 1);
|
||||
String featureEnValStr = asciiString(featureValue);
|
||||
var featureEnVal = reply.data.sublist(index + 1, index + featureEnValLength + 1);
|
||||
String featureEnValStr = asciiString(featureEnVal);
|
||||
state.featureSettingValue = featureEnValStr;
|
||||
// List allFeatureEnValTwoList = charListChangeIntList(featureEnVal);
|
||||
// print("featureEnValLength:$featureEnValLength featureEnVal:$featureEnVal \n featureEnValStr:$featureEnValStr");
|
||||
|
||||
@ -1,7 +1,13 @@
|
||||
import 'dart:async';
|
||||
import 'dart:math';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:flutter_reactive_ble/flutter_reactive_ble.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:star_lock/blue/io_protocol/io_changeAdministratorPassword.dart';
|
||||
import 'package:star_lock/blue/io_protocol/io_senderCustomPasswords.dart';
|
||||
import 'package:star_lock/blue/io_type.dart';
|
||||
|
||||
import '../../../blue/blue_manage.dart';
|
||||
import '../../../blue/io_protocol/io_addUser.dart';
|
||||
@ -12,6 +18,7 @@ import '../../../blue/sender_manage.dart';
|
||||
import '../../../network/api_repository.dart';
|
||||
import '../../../tools/baseGetXController.dart';
|
||||
import '../../../tools/eventBusEventManage.dart';
|
||||
import '../../../tools/showTFView.dart';
|
||||
import '../../../tools/storage.dart';
|
||||
import 'saveLock_state.dart';
|
||||
|
||||
@ -21,11 +28,19 @@ class SaveLockLogic extends BaseGetXController {
|
||||
// 获取解析后的数据
|
||||
late StreamSubscription<Reply> _replySubscription;
|
||||
void _initReplySubscription() {
|
||||
_replySubscription =
|
||||
EventBusManager().eventBus!.on<Reply>().listen((reply) {
|
||||
_replySubscription = EventBusManager().eventBus!.on<Reply>().listen((reply) {
|
||||
if (reply is AddUserReply) {
|
||||
_replyAddUserKey(reply);
|
||||
}
|
||||
|
||||
if (reply is SenderCustomPasswordsReply) {
|
||||
_replySenderCustomPasswords(reply);
|
||||
}
|
||||
|
||||
if (reply is ChangeAdministratorPasswordReply) {
|
||||
_replyChangeAdministratorPassword(reply);
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
@ -50,8 +65,6 @@ class SaveLockLogic extends BaseGetXController {
|
||||
state.lockUserNo = reply.data[47];
|
||||
|
||||
cancelBlueConnetctToastTimer();
|
||||
dismissEasyLoading();
|
||||
|
||||
bindBlueAdmin();
|
||||
break;
|
||||
case 0x06:
|
||||
@ -97,10 +110,120 @@ class SaveLockLogic extends BaseGetXController {
|
||||
}
|
||||
}
|
||||
|
||||
// 保存事件,先调用蓝牙,蓝牙调用成功后再调用后台接口
|
||||
// saveLockAction(){
|
||||
// addUserConnectBlue();
|
||||
// }
|
||||
// 添加管理员密码
|
||||
Future<void> _replySenderCustomPasswords(Reply reply) async {
|
||||
var token = reply.data.sublist(5, 9);
|
||||
var saveStrList = changeIntListToStringList(token);
|
||||
print("_replyFactoryDataResetKeyToken:$token");
|
||||
Storage.setStringList(saveBlueToken, saveStrList);
|
||||
|
||||
int status = reply.data[2];
|
||||
print("status:$status");
|
||||
|
||||
switch (status) {
|
||||
case 0x00:
|
||||
//成功
|
||||
print("${reply.commandType!.typeValue} 数据解析成功");
|
||||
dismissEasyLoading();
|
||||
addLockAdminPassword(true);
|
||||
break;
|
||||
case 0x06:
|
||||
//无权限
|
||||
print("${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!);
|
||||
|
||||
IoSenderManage.senderCustomPasswordsCommand(
|
||||
keyID: "1",
|
||||
userID: await Storage.getUid(),
|
||||
pwdNo: 1,
|
||||
pwd: "123456",
|
||||
useCountLimit: 0xff,
|
||||
startTime: 0x11223344,
|
||||
endTime: 0x11223344,
|
||||
needAuthor: 1,
|
||||
signKey: signKeyDataList,
|
||||
privateKey: getPrivateKeyList,
|
||||
token: token);
|
||||
break;
|
||||
case 0x07:
|
||||
//无权限
|
||||
print("${reply.commandType!.typeValue} 用户无权限");
|
||||
|
||||
break;
|
||||
case 0x09:
|
||||
// 权限校验错误
|
||||
print("${reply.commandType!.typeValue} 权限校验错误");
|
||||
|
||||
break;
|
||||
default:
|
||||
//失败
|
||||
print("${reply.commandType!.typeValue} 失败");
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// 修改管理员密码
|
||||
Future<void> _replyChangeAdministratorPassword(Reply reply) async {
|
||||
var token = reply.data.sublist(5, 9);
|
||||
var saveStrList = changeIntListToStringList(token);
|
||||
print("_replyFactoryDataResetKeyToken:$token");
|
||||
Storage.setStringList(saveBlueToken, saveStrList);
|
||||
|
||||
int status = reply.data[2];
|
||||
print("status:$status");
|
||||
|
||||
switch (status) {
|
||||
case 0x00:
|
||||
//成功
|
||||
print("${reply.commandType!.typeValue} 数据解析成功");
|
||||
cancelBlueConnetctToastTimer();
|
||||
addLockAdminPassword(false);
|
||||
break;
|
||||
case 0x06:
|
||||
//无权限
|
||||
print("${reply.commandType!.typeValue} 需要鉴权");
|
||||
|
||||
var signKey = await Storage.getStringList(saveBlueSignKey);
|
||||
List<int> signKeyDataList = changeStringListToIntList(signKey!);
|
||||
|
||||
var privateKey = await Storage.getStringList(saveBluePrivateKey);
|
||||
List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
|
||||
|
||||
IoSenderManage.changeAdministratorPasswordCommand(
|
||||
keyID: "1",
|
||||
userID: await Storage.getUid(),
|
||||
pwdNo: 0,
|
||||
pwd:state.adminPasswordTF.text,
|
||||
useCountLimit: 0xff,
|
||||
startTime: 0x11223344,
|
||||
endTime: 0x11223344,
|
||||
needAuthor: 1,
|
||||
signKey: signKeyDataList,
|
||||
privateKey: getPrivateKeyList,
|
||||
token: token);
|
||||
break;
|
||||
case 0x07:
|
||||
//无权限
|
||||
print("${reply.commandType!.typeValue} 用户无权限");
|
||||
|
||||
break;
|
||||
case 0x09:
|
||||
// 权限校验错误
|
||||
print("${reply.commandType!.typeValue} 权限校验错误");
|
||||
|
||||
break;
|
||||
default:
|
||||
//失败
|
||||
print("${reply.commandType!.typeValue} 失败");
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// 添加用户
|
||||
Future<void> addUserConnectBlue() async {
|
||||
@ -156,6 +279,81 @@ class SaveLockLogic extends BaseGetXController {
|
||||
}, isAddEquipment: true);
|
||||
}
|
||||
|
||||
// 设置管理员密码(同添加自定义开锁密码,指纹/密码/卡片前5个是管理员)
|
||||
Future<void> senderCustomPasswords() async {
|
||||
var rng = Random();
|
||||
var number = rng.nextInt(900000) + 100000; // 生成 100000 到 999999 之间的随机整数
|
||||
state.adminPassword = number.toString();
|
||||
state.adminPasswordTF.text = number.toString();
|
||||
BlueManage().bludSendData(BlueManage().connectDeviceName, (DeviceConnectionState deviceConnectionState) async {
|
||||
if (deviceConnectionState == DeviceConnectionState.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!);
|
||||
print("openDoorTokenPubToken:$getTokenList");
|
||||
|
||||
IoSenderManage.senderCustomPasswordsCommand(
|
||||
keyID: "1",
|
||||
userID: await Storage.getUid(),
|
||||
pwdNo: 1,
|
||||
pwd:state.adminPasswordTF.text,
|
||||
useCountLimit: 0xff,
|
||||
startTime: 0x11223344,
|
||||
endTime: 0x11223344,
|
||||
needAuthor: 1,
|
||||
signKey: signKeyDataList,
|
||||
privateKey: getPrivateKeyList,
|
||||
token: getTokenList);
|
||||
}
|
||||
}, isAddEquipment: true);
|
||||
}
|
||||
|
||||
// 修改管理员密码(同添加自定义开锁密码,指纹/密码/卡片前5个是管理员)
|
||||
Future<void> changeAdministratorPasswordCommand() async {
|
||||
showEasyLoading();
|
||||
showBlueConnetctToastTimer(action: (){
|
||||
dismissEasyLoading();
|
||||
});
|
||||
BlueManage().bludSendData(BlueManage().connectDeviceName, (DeviceConnectionState deviceConnectionState) async {
|
||||
if (deviceConnectionState == DeviceConnectionState.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!);
|
||||
print("openDoorTokenPubToken:$getTokenList");
|
||||
|
||||
IoSenderManage.changeAdministratorPasswordCommand(
|
||||
keyID: "1",
|
||||
userID: await Storage.getUid(),
|
||||
pwdNo: 0,
|
||||
pwd:state.adminPasswordTF.text,
|
||||
useCountLimit: 0xff,
|
||||
startTime: 0x11223344,
|
||||
endTime: 0x11223344,
|
||||
needAuthor: 1,
|
||||
signKey: signKeyDataList,
|
||||
privateKey: getPrivateKeyList,
|
||||
token: getTokenList);
|
||||
} else if (deviceConnectionState == DeviceConnectionState.disconnected) {
|
||||
print("444444");
|
||||
dismissEasyLoading();
|
||||
cancelBlueConnetctToastTimer();
|
||||
state.saveBtnIsUsable.value = true;
|
||||
if(state.ifCurrentScreen.value == true){
|
||||
showBlueConnetctToast();
|
||||
}
|
||||
}
|
||||
}, isAddEquipment: true);
|
||||
}
|
||||
|
||||
void bindBlueAdmin() async{
|
||||
// print("state.lockInfo:${state.lockInfo}");
|
||||
@ -200,12 +398,71 @@ class SaveLockLogic extends BaseGetXController {
|
||||
featureSettingParams: state.featureSettingParams,
|
||||
);
|
||||
if (entity.errorCode!.codeIsSuccessful) {
|
||||
BlueManage().disconnect(BlueManage().connectDeviceMacAddress);
|
||||
eventBus.fire(RefreshLockListInfoDataEvent());
|
||||
Get.close(state.isFromMap == 1 ? 5 : 6);
|
||||
state.lockId = entity.data!.lockId!;
|
||||
senderCustomPasswords();
|
||||
|
||||
// BlueManage().disconnect(BlueManage().connectDeviceMacAddress);
|
||||
// eventBus.fire(RefreshLockListInfoDataEvent());
|
||||
// Get.close(state.isFromMap == 1 ? 5 : 6);
|
||||
}
|
||||
}
|
||||
|
||||
// 更新管理员密码
|
||||
void addLockAdminPassword(bool isAddLockAdminPassword) async {
|
||||
var entity = await ApiRepository.to.setAdminPasswordData(
|
||||
lockId: state.lockId,
|
||||
adminPwd: state.adminPasswordTF.text,
|
||||
);
|
||||
if (entity.errorCode!.codeIsSuccessful) {
|
||||
if(isAddLockAdminPassword == true){
|
||||
showDeletPasswordAlertDialog();
|
||||
}else{
|
||||
backAction();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void showDeletPasswordAlertDialog() {
|
||||
showDialog(
|
||||
context: Get.context!,
|
||||
builder: (BuildContext context) {
|
||||
return ShowTFView(
|
||||
title: "管理员密码",
|
||||
tipTitle: "如需修改,请输入新的管理员密码(6位),点击确定即可修改",
|
||||
leftBtnTitle: "确定",
|
||||
rightBtnTitle: "修改",
|
||||
keyboardType: TextInputType.number,
|
||||
inputFormatters: [
|
||||
FilteringTextInputFormatter.allow(RegExp('[0-9]')),
|
||||
LengthLimitingTextInputFormatter(6),
|
||||
],
|
||||
controller: state.adminPasswordTF,
|
||||
sureClick: () {
|
||||
if(state.adminPasswordTF.text.length < 6){
|
||||
showToast("请输入6位管理员密码");
|
||||
return;
|
||||
}
|
||||
|
||||
if(state.adminPasswordTF.text == state.adminPassword){
|
||||
showToast("请输入新的管理员密码");
|
||||
return;
|
||||
}
|
||||
changeAdministratorPasswordCommand();
|
||||
},
|
||||
cancelClick: () {
|
||||
backAction();
|
||||
},
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
void backAction(){
|
||||
BlueManage().disconnect(BlueManage().connectDeviceMacAddress);
|
||||
eventBus.fire(RefreshLockListInfoDataEvent());
|
||||
Get.close(state.isFromMap == 1 ? 6 : 7);
|
||||
}
|
||||
|
||||
@override
|
||||
void onReady() {
|
||||
// TODO: implement onReady
|
||||
|
||||
@ -9,6 +9,7 @@ class SaveLockState {
|
||||
var aliName = ''.obs;
|
||||
var pwdTimestamp= 0.obs;
|
||||
var addressInfo = {}.obs;
|
||||
|
||||
TextEditingController aliNameController = TextEditingController();
|
||||
|
||||
var lockUserNo = 0;
|
||||
@ -21,6 +22,11 @@ class SaveLockState {
|
||||
var ifCurrentScreen = true.obs; // 是否是当前界面,用于判断是否需要针对当前界面进行展示
|
||||
var saveBtnIsUsable = true.obs; // 保存按钮是否可用
|
||||
|
||||
// 管理员密码
|
||||
var adminPasswordTF = TextEditingController();
|
||||
var adminPassword = '';
|
||||
var lockId = 0;
|
||||
|
||||
SaveLockState() {
|
||||
aliName.value = BlueManage().connectDeviceName;
|
||||
aliNameController.text = aliName.value;
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
abstract class Api {
|
||||
// static String baseAddress = "https://pre.lock.star-lock.cn:8093"; //预发布环境
|
||||
static String baseAddress = "http://192.168.56.101:8099"; //联调环境
|
||||
static String baseAddress = "https://dev.lock.star-lock.cn"; //联调环境
|
||||
// static String baseAddress = "http://192.168.1.15:8022"; //谢总本地
|
||||
|
||||
final String baseUrl = "$baseAddress/api";
|
||||
|
||||
@ -656,6 +656,15 @@ class ApiProvider extends BaseProvider {
|
||||
'lockId': lockId,
|
||||
}));
|
||||
|
||||
// 设置管理员开锁密码
|
||||
Future<Response> setAdminPasswordData(int lockId, String adminPwd) =>
|
||||
post(
|
||||
updateLockSettingUrl.toUrl,
|
||||
jsonEncode({
|
||||
'lockId': lockId,
|
||||
'adminPwd': adminPwd,
|
||||
}));
|
||||
|
||||
// 获取服务器当前时间
|
||||
Future<Response> getServerDatetimeLoadData(String lockId) => post(
|
||||
getServerDatetimeUrl.toUrl,
|
||||
|
||||
@ -703,6 +703,15 @@ class ApiRepository {
|
||||
return GetServerDatetimeEntity.fromJson(res.body);
|
||||
}
|
||||
|
||||
// 设置管理员密码
|
||||
Future<GetServerDatetimeEntity> setAdminPasswordData({
|
||||
required int lockId,
|
||||
required String adminPwd,
|
||||
}) async {
|
||||
final res = await apiProvider.setAdminPasswordData(lockId, adminPwd);
|
||||
return GetServerDatetimeEntity.fromJson(res.body);
|
||||
}
|
||||
|
||||
// 获取服务器当前时间
|
||||
Future<GetServerDatetimeEntity> getServerDatetimeData({
|
||||
required String lockId,
|
||||
|
||||
@ -5,6 +5,7 @@ import 'package:flutter_easyloading/flutter_easyloading.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:star_lock/appRouters.dart';
|
||||
|
||||
import '../common/XSConstantMacro/XSConstantMacro.dart';
|
||||
import 'manager/client_manager.dart';
|
||||
|
||||
class BaseGetXController extends GetxController{
|
||||
@ -86,9 +87,9 @@ class BaseGetXController extends GetxController{
|
||||
}
|
||||
|
||||
void showToast(String status,{Function? something}) {
|
||||
EasyLoading.showToast(status,duration: 2000.milliseconds);
|
||||
EasyLoading.showToast(status,duration: 1000.milliseconds);
|
||||
if(something != null) {
|
||||
delay(duration: 2100.milliseconds,something: something);
|
||||
delay(duration: 1100.milliseconds,something: something);
|
||||
}
|
||||
}
|
||||
|
||||
@ -114,8 +115,33 @@ class BaseGetXController extends GetxController{
|
||||
Get.offAllNamed(Routers.starLockLoginPage);
|
||||
}
|
||||
|
||||
// Future loginSuccess({LoginEntity? loginEntity, bool byToken = false}) async => ClientManager().loginSuccess(loginEntity: loginEntity,byToken: byToken);
|
||||
String getUseKeyTypeStr(int? startDate, int? endDate,int? keyType) {
|
||||
String useDateStr = '';
|
||||
if (keyType == XSConstantMacro.keyTypeTime) {
|
||||
//限期
|
||||
DateTime startDateStr =
|
||||
DateTime.fromMillisecondsSinceEpoch(startDate!);
|
||||
DateTime endDateStr =
|
||||
DateTime.fromMillisecondsSinceEpoch(endDate!);
|
||||
useDateStr =
|
||||
'${startDateStr.toLocal().toString().substring(0, 16)} - ${endDateStr.toLocal().toString().substring(0, 16)}';
|
||||
} else if (keyType == XSConstantMacro.keyTypeLong) {
|
||||
//永久
|
||||
// DateTime dateStr = DateTime.fromMillisecondsSinceEpoch(indexEntity.date!);
|
||||
// useDateStr = '${dateStr.toLocal().toString().substring(0, 16)}\n永久';
|
||||
useDateStr = '永久';
|
||||
} else if (keyType == XSConstantMacro.keyTypeOnce) {
|
||||
//单次
|
||||
// DateTime dateStr = DateTime.fromMillisecondsSinceEpoch(indexEntity.date!);
|
||||
// useDateStr = '${dateStr.toLocal().toString().substring(0, 16)} \n单次';
|
||||
useDateStr = '单次';
|
||||
} else if (keyType == XSConstantMacro.keyTypeLoop) {
|
||||
//循环
|
||||
useDateStr = '循环';
|
||||
}
|
||||
|
||||
return useDateStr;
|
||||
}
|
||||
|
||||
static List splitList(List list, int len) {
|
||||
if (len <= 1) {
|
||||
|
||||
@ -45,8 +45,8 @@ class LockGroupEditGroupLockRefreshEvent {
|
||||
|
||||
/// 锁设置里面开启关闭刷新锁详情
|
||||
class LockSetChangeSetRefreshLockDetailWithType {
|
||||
int type; // 0 考勤 1开锁时是否需联网 2常开模式
|
||||
int setResult;
|
||||
int type; // 0 考勤 1开锁时是否需联网 2常开模式 3修改了锁名字 4修改了电量
|
||||
String setResult;
|
||||
LockSetChangeSetRefreshLockDetailWithType(this.type, this.setResult);
|
||||
}
|
||||
|
||||
|
||||
@ -9,19 +9,25 @@ import '../translations/trans_lib.dart';
|
||||
class ShowTFView extends StatelessWidget {
|
||||
String? title;
|
||||
String? tipTitle;
|
||||
String? leftBtnTitle;
|
||||
String? rightBtnTitle;
|
||||
TextEditingController? controller;
|
||||
List<TextInputFormatter>? inputFormatters;
|
||||
TextInputType? keyboardType;
|
||||
Function()? sureClick;
|
||||
Function()? cancelClick;
|
||||
|
||||
ShowTFView(
|
||||
{Key? key,
|
||||
this.title,
|
||||
this.tipTitle,
|
||||
this.controller,
|
||||
this.inputFormatters,
|
||||
this.sureClick,
|
||||
this.cancelClick})
|
||||
this.title,
|
||||
this.tipTitle,
|
||||
this.leftBtnTitle,
|
||||
this.rightBtnTitle,
|
||||
this.controller,
|
||||
this.inputFormatters,
|
||||
this.keyboardType,
|
||||
this.sureClick,
|
||||
this.cancelClick})
|
||||
: super(key: key);
|
||||
|
||||
@override
|
||||
@ -48,6 +54,7 @@ class ShowTFView extends StatelessWidget {
|
||||
controller: controller,
|
||||
autofocus: false,
|
||||
inputFormatters: inputFormatters,
|
||||
keyboardType: keyboardType,
|
||||
decoration: InputDecoration(
|
||||
contentPadding:
|
||||
const EdgeInsets.only(left: 5, top: -8, bottom: 6),
|
||||
@ -63,7 +70,7 @@ class ShowTFView extends StatelessWidget {
|
||||
actions: <Widget>[
|
||||
CupertinoDialogAction(
|
||||
child: Text(
|
||||
TranslationLoader.lanKeys!.cancel!.tr,
|
||||
leftBtnTitle ?? TranslationLoader.lanKeys!.cancel!.tr,
|
||||
style: const TextStyle(color: Colors.black),
|
||||
),
|
||||
onPressed: () {
|
||||
@ -75,7 +82,8 @@ class ShowTFView extends StatelessWidget {
|
||||
},
|
||||
),
|
||||
CupertinoDialogAction(
|
||||
child: Text(TranslationLoader.lanKeys!.sure!.tr,
|
||||
child: Text(
|
||||
rightBtnTitle ?? TranslationLoader.lanKeys!.sure!.tr,
|
||||
style: const TextStyle(color: Colors.black)),
|
||||
onPressed: () {
|
||||
if (sureClick != null) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user