添加转移锁功能,修复转移锁模块问题

This commit is contained in:
魏少阳 2024-06-14 15:46:43 +08:00
parent c3d6f208d7
commit 3ff1d01d19
26 changed files with 626 additions and 274 deletions

View File

@ -885,5 +885,22 @@
"请输入时间(秒)": "Please enter the time (seconds)",
"加载数据失败": "Failed to load data",
"重试": "Retry",
"升级中,是否退出": "During the upgrade, whether to exit"
"升级中,是否退出": "During the upgrade, whether to exit",
"下一步": "Next",
"公寓": "Apartment",
"个人用户": "Personal user",
"星寓": "Star apartment",
"账号": "Account",
"请输入手机号或email": "Please enter mobile phone number or email",
"请输入星寓管理员的账号": "Please enter the account of the star apartment administrator",
"选中的智能锁将会转移到您输入的账号中,您将失去锁的管理权": "The selected smart lock will be transferred to the account you entered, and you will lose the management rights of the lock",
"暂不支持跨平台转移,敬请期待": "Cross-platform transfer is not supported for the time being, please look forward to it",
"移除坏锁": "Remove bad lock",
"转移确认": "Transfer confirmation",
"本次共转移": "This time a total of",
"把智能锁": "Smart lock",
"确认": "Confirm",
"移除成功": "Remove successfully",
"转移成功": "Transfer success"
}

View File

@ -917,5 +917,22 @@
"请输入时间(秒)": "请输入时间(秒)",
"加载数据失败": "加载数据失败",
"重试": "重试",
"升级中,是否退出": "升级中,是否退出"
"升级中,是否退出": "升级中,是否退出",
"下一步": "下一步",
"公寓": "公寓",
"个人用户": "个人用户",
"星寓": "星寓",
"账号": "账号",
"请输入手机号或email": "请输入手机号或email",
"请输入星寓管理员的账号": "请输入星寓管理员的账号",
"选中的智能锁将会转移到您输入的账号中,您将失去锁的管理权": "选中的智能锁将会转移到您输入的账号中,您将失去锁的管理权",
"暂不支持跨平台转移,敬请期待": "暂不支持跨平台转移,敬请期待",
"移除坏锁": "移除坏锁",
"转移确认": "转移确认",
"本次共转移": "本次共转移",
"把智能锁": "把智能锁",
"确认": "确认",
"移除成功": "移除成功",
"转移成功": "转移成功"
}

View File

@ -883,5 +883,22 @@
"请输入时间(秒)": "请输入时间(秒)",
"加载数据失败": "加载数据失败",
"重试": "重试",
"升级中,是否退出": "升级中,是否退出"
"升级中,是否退出": "升级中,是否退出",
"下一步": "下一步",
"公寓": "公寓",
"个人用户": "个人用户",
"星寓": "星寓",
"账号": "账号",
"请输入手机号或email": "请输入手机号或email",
"请输入星寓管理员的账号": "请输入星寓管理员的账号",
"选中的智能锁将会转移到您输入的账号中,您将失去锁的管理权": "选中的智能锁将会转移到您输入的账号中,您将失去锁的管理权",
"暂不支持跨平台转移,敬请期待": "暂不支持跨平台转移,敬请期待",
"移除坏锁": "移除坏锁",
"转移确认": "转移确认",
"本次共转移": "本次共转移",
"把智能锁": "把智能锁",
"确认": "确认",
"移除成功": "移除成功",
"转移成功": "转移成功"
}

View File

@ -1,13 +1,14 @@
//TODO:
//TODO:
import 'dart:convert';
import '../io_tool/io_tool.dart';
import '../sm4Encipher/sm4.dart';
import 'package:crypto/crypto.dart' as crypto;
import '../io_reply.dart';
import '../io_sender.dart';
import '../io_tool/io_tool.dart';
import '../io_type.dart';
import 'package:crypto/crypto.dart' as crypto;
import '../sm4Encipher/sm4.dart';
class FactoryDataResetCommand extends SenderProtocol {

View File

@ -0,0 +1,108 @@
//TODO:
import 'dart:convert';
import 'package:crypto/crypto.dart' as crypto;
import '../io_reply.dart';
import '../io_sender.dart';
import '../io_tool/io_tool.dart';
import '../io_type.dart';
import '../sm4Encipher/sm4.dart';
class TransferSmartLockCommand extends SenderProtocol {
String? lockID;
String? userID;
String? keyID;
List<int>? publicKey;
List<int>? privateKey;
List<int>? token;
int? needAuthor;
TransferSmartLockCommand({
this.lockID,
this.userID,
this.keyID,
this.token,
this.needAuthor,
this.publicKey,
this.privateKey,
}) : super(CommandType.transferSmartLock);
@override
String toString() {
return 'TransferSmartLockCommand{lockID: $lockID, userID: $userID, '
'keyID: $keyID, publicKey: $publicKey, privateKey: $privateKey, '
'token: $token, needAuthor: $needAuthor}';
}
@override
List<int> messageDetail() {
List<int> data = <int>[];
List<int> ebcData = <int>[];
//
final int type = commandType!.typeValue;
final double typeDouble = type / 256;
final int type1 = typeDouble.toInt();
final int type2 = type % 256;
data.add(type1);
data.add(type2);
// id 40
final int lockIDLength = utf8.encode(lockID!).length;
data.addAll(utf8.encode(lockID!));
data = getFixedLengthList(data, 40 - lockIDLength);
//userID 20
final int userIDLength = utf8.encode(userID!).length;
data.addAll(utf8.encode(userID!));
data = getFixedLengthList(data, 20 - userIDLength);
// token 4 Token 0 token失效或者第一次发送的时候token为0
data.addAll(token!);
if(needAuthor == 0){
//AuthCodeLen 1
data.add(0);
} else {
final List<int> authCodeData = <int>[];
//userID
authCodeData.addAll(utf8.encode(lockID!));
//token 4 Token 0
authCodeData.addAll(token!);
authCodeData.addAll(publicKey!);
// KeyIDauthUserIDmd5加密之后就是authCode
final crypto.Digest authCode = crypto.md5.convert(authCodeData);
data.add(authCode.bytes.length);
data.addAll(authCode.bytes);
}
if ((data.length % 16) != 0) {
final int add = 16 - data.length % 16;
for (int i = 0; i < add; i++) {
data.add(0);
}
}
printLog(data);
// LockId进行SM4 ECB加密 key:544d485f633335373034383064613864
ebcData = SM4.encrypt(data, key: privateKey, mode: SM4CryptoMode.ECB);
return ebcData;
}
}
class TransferSmartLockReply extends Reply {
TransferSmartLockReply.parseData(CommandType commandType, List<int> dataDetail)
: super.parseData(commandType, dataDetail) {
data = dataDetail;
final int status = data[6];
errorWithStstus(status);
}
}

View File

@ -1,12 +1,12 @@
import 'dart:convert';
import 'package:crypto/crypto.dart' as crypto;
import '../io_reply.dart';
import '../io_sender.dart';
import '../io_tool/io_tool.dart';
import '../io_type.dart';
import 'package:crypto/crypto.dart' as crypto;
import '../sm4Encipher/sm4.dart';
class UpdataLockCardListCommand extends SenderProtocol {

View File

@ -3,6 +3,7 @@ enum CommandType {
addUser, // = 0x3001
deletUser, // = 0x3002
editUser, // = 0x3003
transferSmartLock, // = 0x300D
factoryDataReset, // = 0x3004
openLock, // = 0x3005
readLockStatusInfo, // = 0x300A
@ -84,6 +85,11 @@ extension ExtensionCommandType on CommandType {
type = CommandType.cleanUpUsers;
}
break;
case 0x300D:
{
type = CommandType.transferSmartLock;
}
break;
case 0x300A:
{
type = CommandType.readLockStatusInfo;
@ -199,6 +205,9 @@ extension ExtensionCommandType on CommandType {
case CommandType.cleanUpUsers:
type = 0x300C;
break;
case CommandType.transferSmartLock:
type = 0x300D;
break;
case CommandType.readLockStatusInfo:
type = 0x300A;
break;
@ -299,6 +308,9 @@ extension ExtensionCommandType on CommandType {
case 0x300C:
t = '清理用户';
break;
case 0x300D:
t = '转移智能锁';
break;
case 0x300A:
t = '读取锁状态信息';
break;

View File

@ -22,7 +22,6 @@ import 'package:star_lock/blue/io_protocol/io_timing.dart';
import 'package:star_lock/blue/io_protocol/io_transferPermissions.dart';
import '../tools/storage.dart';
import 'io_protocol/io_addFingerprintWithTimeCycleCoercion.dart';
import 'io_protocol/io_addICCardWithTimeCycleCoercion.dart';
import 'io_protocol/io_addStressPassword.dart';
@ -37,7 +36,9 @@ import 'io_protocol/io_getWifiList.dart';
import 'io_protocol/io_openLock.dart';
import 'io_protocol/io_queryingFingerprintStatus.dart';
import 'io_protocol/io_referEventRecordNumber.dart';
import 'io_protocol/io_senderCustomPasswords.dart';
import 'io_protocol/io_senderResetPasswords.dart';
import 'io_protocol/io_transferSmartLock.dart';
import 'io_protocol/io_updataLockCardList.dart';
import 'io_protocol/io_updataLockFaceList.dart';
import 'io_protocol/io_updataLockFingerprintList.dart';
@ -45,11 +46,10 @@ import 'io_protocol/io_updataLockPalmVeinList.dart';
import 'io_protocol/io_updataLockPasswordList.dart';
import 'io_protocol/io_updataLockSet.dart';
import 'io_reply.dart';
import 'io_protocol/io_senderCustomPasswords.dart';
import 'io_type.dart';
import 'io_tool/io_manager.dart';
import 'io_tool/io_tool.dart';
import 'io_tool/manager_event_bus.dart';
import 'io_type.dart';
import 'sm4Encipher/sm4.dart';
class CommandReciverManager {
@ -172,6 +172,11 @@ class CommandReciverManager {
reply = TransferPermissionsReply.parseData(commandType, data);
}
break;
case CommandType.transferSmartLock:
{
reply = TransferSmartLockReply.parseData(commandType, data);
}
break;
case CommandType.factoryDataReset:
{
reply = FactoryDataResetReply.parseData(commandType, data);

View File

@ -1,6 +1,7 @@
import 'dart:async';
import 'package:star_lock/app_settings/app_settings.dart';
import 'package:star_lock/blue/entity/lock_user_no_list_entity.dart';
import 'package:star_lock/blue/io_protocol/io_cleanUpUsers.dart';
import 'package:star_lock/common/XSConstantMacro/XSConstantMacro.dart';
import 'package:star_lock/main/lockMian/entity/lockListInfo_entity.dart';
@ -14,15 +15,18 @@ import '../tools/commonDataManage.dart';
import '../tools/storage.dart';
import 'blue_manage.dart';
import 'io_protocol/io_addUser.dart';
import 'io_protocol/io_transferSmartLock.dart';
import 'io_reply.dart';
import 'io_tool/io_tool.dart';
import 'io_tool/manager_event_bus.dart';
import 'sender_data.dart';
class SenderBeforeDataManage {
static SenderBeforeDataManage? _manager;
factory SenderBeforeDataManage() => shareManager()!;
SenderBeforeDataManage._init();
static SenderBeforeDataManage? _manager;
static SenderBeforeDataManage? shareManager() {
_manager ??= SenderBeforeDataManage._init();
@ -30,8 +34,6 @@ class SenderBeforeDataManage {
return _manager;
}
factory SenderBeforeDataManage() => shareManager()!;
SenderBeforeDataManage? get manager => shareManager();
void _init() {
@ -40,10 +42,12 @@ class SenderBeforeDataManage {
//
StreamSubscription<Reply>? _replySubscription;
//
bool isBeforeAddUser = true;
//
void _initReplySubscription() {
_replySubscription ??= EventBusManager().eventBus!.on<Reply>().listen((reply) async {
_replySubscription ??= EventBusManager().eventBus!.on<Reply>().listen((Reply reply) async {
//
if (reply is AddUserReply && isBeforeAddUser == false) {
_replyAddUserKey(reply);
@ -52,32 +56,36 @@ class SenderBeforeDataManage {
if (reply is CleanUpUsersReply) {
_cleanUpUsersReply(reply);
}
if (reply is TransferSmartLockReply) {
_transferSmartLockReply(reply);
}
});
}
//
Future<void> _replyAddUserKey(Reply reply) async {
int status = reply.data[46];
final int status = reply.data[46];
switch (status) {
case 0x00:
//
CommonDataManage().currentLockUserNo =
listChangInt(reply.data.sublist(47, 49));
CommonDataManage().currentKeyInfo.lockUserNo =
CommonDataManage().currentLockUserNo;
_updateLockUserNo();
var userNoData = reply.data.sublist(47, 49);
CommonDataManage().currentLockUserNo = listChangInt(userNoData);
CommonDataManage().currentKeyInfo.lockUserNo = CommonDataManage().currentLockUserNo;
_updateLockUserNo(userNoData);
break;
case 0x06:
//
var token = reply.data.sublist(42, 46);
List<String> strTokenList = changeIntListToStringList(token);
final List<int> token = reply.data.sublist(42, 46);
final List<String> strTokenList = changeIntListToStringList(token);
Storage.setStringList(saveBlueToken, strTokenList);
var addUserData = await getAddUserKeyData(tokenList: token);
final List<int> addUserData = await getAddUserKeyData(tokenList: token);
eventBus.fire(LockAddUserSucceedEvent(addUserData, 1));
break;
case 0x0c:
// 32
var addUserData = await getCleanUpUsers();
final List<int> addUserData = await getCleanUpUsers();
CommandSenderManager().sendNormalData(addUserData);
break;
default:
@ -88,20 +96,20 @@ class SenderBeforeDataManage {
//
Future<void> _cleanUpUsersReply(Reply reply) async {
int status = reply.data[6];
final int status = reply.data[6];
switch (status) {
case 0x00:
//
//
var addUserData = await getAddUserKeyData();
final List<int> addUserData = await getAddUserKeyData();
CommandSenderManager().sendNormalData(addUserData);
break;
case 0x06:
//
var token = reply.data.sublist(2, 6);
List<String> strTokenList = changeIntListToStringList(token);
final List<int> token = reply.data.sublist(2, 6);
final List<String> strTokenList = changeIntListToStringList(token);
Storage.setStringList(saveBlueToken, strTokenList);
var addUserData = await getCleanUpUsers(tokenList: token);
final List<int> addUserData = await getCleanUpUsers(tokenList: token);
CommandSenderManager().sendNormalData(addUserData);
break;
default:
@ -110,26 +118,52 @@ class SenderBeforeDataManage {
}
}
//
Future<void> _transferSmartLockReply(Reply reply) async {
final int status = reply.data[6];
switch (status) {
case 0x00:
//
CommonDataManage().initUserNo = 0;
CommonDataManage().currentKeyInfo.initUserNo = 0;
_updateLockInitUserNo();
break;
case 0x06:
//
final List<int> token = reply.data.sublist(2, 6);
final List<String> strTokenList = changeIntListToStringList(token);
Storage.setStringList(saveBlueToken, strTokenList);
final List<int> transferSmartLockData = await getTransferSmartLockData(tokenList: token);
CommandSenderManager().sendNormalData(transferSmartLockData);
break;
default:
//
break;
}
}
//
Future<List<int>> getCleanUpUsers({List<int>? tokenList}) async {
var entity = await ApiRepository.to
final LockUserNoListEntity entity = await ApiRepository.to
.getLockUserNoList(lockId: CommonDataManage().currentKeyInfo.lockId!);
if (!entity.errorCode!.codeIsSuccessful ||
(entity.data?.userNos ?? []).isEmpty) {
(entity.data?.userNos ?? <int>[]).isEmpty) {
throw Exception('ApiRepository.to.getLockUserNoList 访问失败');
}
var privateKey = await Storage.getStringList(saveBluePrivateKey);
List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
final List<String>? privateKey = await Storage.getStringList(saveBluePrivateKey);
final List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
var publicKey = await Storage.getStringList(saveBluePublicKey);
List<int> publicKeyDataList = changeStringListToIntList(publicKey!);
final List<String>? publicKey = await Storage.getStringList(saveBluePublicKey);
final List<int> publicKeyDataList = changeStringListToIntList(publicKey!);
if (tokenList == null) {
var tokenKey = await Storage.getStringList(saveBlueToken);
final List<String>? tokenKey = await Storage.getStringList(saveBlueToken);
tokenList = changeStringListToIntList(tokenKey!);
}
var cleanUpUsersData = CleanUpUsersCommand(
final CleanUpUsersCommand cleanUpUsersData = CleanUpUsersCommand(
lockID: BlueManage().connectDeviceName,
authUserID: CommonDataManage().currentKeyInfo.senderUserId!.toString(),
keyID: CommonDataManage().currentKeyInfo.keyId.toString(),
@ -145,24 +179,24 @@ class SenderBeforeDataManage {
//
Future<List<int>> getAddUserKeyData({List<int>? tokenList}) async {
var privateKey = await Storage.getStringList(saveBluePrivateKey);
List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
final List<String>? privateKey = await Storage.getStringList(saveBluePrivateKey);
final List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
var publicKey = await Storage.getStringList(saveBluePublicKey);
List<int> publicKeyDataList = changeStringListToIntList(publicKey!);
final List<String>? publicKey = await Storage.getStringList(saveBluePublicKey);
final List<int> publicKeyDataList = changeStringListToIntList(publicKey!);
if (tokenList == null) {
var token = await Storage.getStringList(saveBlueToken);
final List<String>? token = await Storage.getStringList(saveBlueToken);
tokenList = changeStringListToIntList(token!);
}
LockListInfoItemEntity currentKeyInfo = CommonDataManage().currentKeyInfo;
final LockListInfoItemEntity currentKeyInfo = CommonDataManage().currentKeyInfo;
DateTime? startTime;
DateTime? endTime;
var startDateTime = 0;
var endDateTime = 0;
int startDateTime = 0;
int endDateTime = 0;
bool isRound = false;
var useCountLimit = 0xffff;
int useCountLimit = 0xffff;
if(currentKeyInfo.keyType == XSConstantMacro.keyTypeTime){
//
startDateTime = currentKeyInfo.startDate! ~/ 1000;
@ -181,7 +215,7 @@ class SenderBeforeDataManage {
}
// AppLog.log("startTime.hour:${startTime!.hour} startTime.minute:${startTime!.minute} endTime.hour:${endTime!.hour} endTime.minute:${endTime!.minute}}");
var addUserData = AddUserCommand(
final AddUserCommand addUserData = AddUserCommand(
lockID: BlueManage().connectDeviceName,
authUserID: currentKeyInfo.senderUserId!.toString(),
keyID: currentKeyInfo.keyId.toString(),
@ -201,7 +235,7 @@ class SenderBeforeDataManage {
endHour: isRound ? endTime!.hour : 0,
endMin: isRound ? endTime!.minute : 0,
role: currentKeyInfo.keyRight == 1 ? 1 : 0,
password: "123456",
password: '123456',
needAuthor: 1,
publicKey: publicKeyDataList,
privateKey: getPrivateKeyList,
@ -209,13 +243,50 @@ class SenderBeforeDataManage {
return addUserData.packageData();
}
//
Future<List<int>> getTransferSmartLockData({List<int>? tokenList}) async {
final List<String>? privateKey = await Storage.getStringList(saveBluePrivateKey);
final List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
final List<String>? publicKey = await Storage.getStringList(saveBluePublicKey);
final List<int> publicKeyDataList = changeStringListToIntList(publicKey!);
if (tokenList == null) {
final List<String>? token = await Storage.getStringList(saveBlueToken);
tokenList = changeStringListToIntList(token!);
}
final LockListInfoItemEntity currentKeyInfo = CommonDataManage().currentKeyInfo;
final TransferSmartLockCommand transferSmartLockData = TransferSmartLockCommand(
lockID: BlueManage().connectDeviceName,
keyID: currentKeyInfo.keyId.toString(),
userID: await Storage.getUid(),
needAuthor: 1,
publicKey: publicKeyDataList,
privateKey: getPrivateKeyList,
token: tokenList);
return transferSmartLockData.packageData();
}
// NO
void _updateLockUserNo() async {
LockNetTokenEntity entity = await ApiRepository.to.updateLockUserNo(
Future<void> _updateLockUserNo(List<int> dataList) async {
final LockNetTokenEntity entity = await ApiRepository.to.updateLockUserNo(
keyId: CommonDataManage().currentKeyInfo.keyId.toString(),
lockUserNo: CommonDataManage().currentKeyInfo.lockUserNo.toString());
if (entity.errorCode!.codeIsSuccessful) {
eventBus.fire(LockAddUserSucceedEvent([0], 0));
eventBus.fire(RefreshLockListInfoDataEvent());
eventBus.fire(LockAddUserSucceedEvent(<int>[0], 0));
}
}
// InitUserNo
Future<void> _updateLockInitUserNo() async {
final LockNetTokenEntity entity = await ApiRepository.to.updateLockInitUserNo(
lockId: CommonDataManage().currentKeyInfo.lockId ?? 0,
initUserNo: CommonDataManage().currentKeyInfo.initUserNo ?? 0);
if (entity.errorCode!.codeIsSuccessful) {
eventBus.fire(RefreshLockListInfoDataEvent());
eventBus.fire(LockInitUserNoEvent());
}
}

View File

@ -1,10 +1,10 @@
import 'dart:async';
import '../app_settings/app_settings.dart';
import '../tools/commonDataManage.dart';
import '../tools/eventBusEventManage.dart';
import 'io_sender.dart';
import 'io_type.dart';
import 'io_tool/io_model.dart';
import 'io_tool/manager_event_bus.dart';
import 'sender_beforeDataManage.dart';
@ -12,27 +12,26 @@ import 'sender_beforeDataManage.dart';
typedef CommandSendCallBack = void Function(ErrorType errorType);
class CommandSenderManager {
static final CommandSenderManager _manager = CommandSenderManager._init();
factory CommandSenderManager() => _manager;
static CommandSenderManager getInstance() => _manager;
CommandSenderManager._init() {
init();
}
static final CommandSenderManager _manager = CommandSenderManager._init();
static CommandSenderManager getInstance() => _manager;
init() {
initLockAddUserSucceedEvent();
_initLockAddUserSucceedEvent();
_initTransferSmartLockSucceedEvent();
}
//
//
StreamSubscription? _passCurrentLockInformationEvent;
List<int> dataBeforeAddTheUser = [];
void initLockAddUserSucceedEvent() {
List<int> dataBeforeAddTheUser = <int>[];
void _initLockAddUserSucceedEvent() {
// eventBus
_passCurrentLockInformationEvent = eventBus.on<LockAddUserSucceedEvent>().listen((event) {
_passCurrentLockInformationEvent = eventBus.on<LockAddUserSucceedEvent>().listen((LockAddUserSucceedEvent event) {
if (event.type == 0) {
sendNormalData(dataBeforeAddTheUser);
} else {
@ -41,10 +40,18 @@ class CommandSenderManager {
});
}
StreamSubscription? _transferSmartLockEvent;
List<int> dataTransferSmartLock = <int>[];
void _initTransferSmartLockSucceedEvent() {
// eventBus
_transferSmartLockEvent = eventBus.on<LockInitUserNoEvent>().listen((LockInitUserNoEvent event) {
sendNormalData(dataTransferSmartLock);
});
}
// CommandType lastCommandType = CommandType.readLockStatusInfo;
bool canSendControlCommand = false;
//TODO:
Future<void> managerSendData(
{required SenderProtocol command,
bool isBeforeAddUser = false,
@ -56,15 +63,22 @@ class CommandSenderManager {
}
SenderBeforeDataManage().isBeforeAddUser = isBeforeAddUser;
List<int> value = command.packageData();
final List<int> value = command.packageData();
if (isBeforeAddUser == true) {
//
sendNormalData(value);
} else {
// userid
if(CommonDataManage().initUserNo == 1){
final List<int> entity = await SenderBeforeDataManage().getTransferSmartLockData();
sendNormalData(entity);
dataTransferSmartLock = value;
return;
}
//
if (CommonDataManage().currentLockUserNo == 0) {
// LockUserNo为0
var entity = await SenderBeforeDataManage().getAddUserKeyData();
final List<int> entity = await SenderBeforeDataManage().getAddUserKeyData();
sendNormalData(entity);
dataBeforeAddTheUser = value;
} else {
@ -73,7 +87,7 @@ class CommandSenderManager {
}
}
void sendNormalData(List<int> data) async {
Future<void> sendNormalData(List<int> data) async {
if (data.isNotEmpty) {
EventBusManager().eventBusFir(
EventSendModel(data: data, sendChannel: DataChannel.ble));
@ -137,5 +151,6 @@ class CommandSenderManager {
dispose() {
_passCurrentLockInformationEvent?.cancel();
_transferSmartLockEvent?.cancel();
}
}

View File

@ -278,6 +278,28 @@ class IoSenderManage {
callBack: callBack);
}
//todo:
static void sendTransferSmartLockCommand(
{required String? lockID,
required String? userID,
required String? keyID,
required List<int>? publicKey,
required List<int>? privateKey,
required List<int>? token,
required int? needAuthor,
CommandSendCallBack? callBack}) {
CommandSenderManager().managerSendData(
command: FactoryDataResetCommand(
lockID: lockID,
userID: userID,
keyID: keyID,
needAuthor: needAuthor,
publicKey: publicKey,
privateKey: privateKey,
token: token),
callBack: callBack);
}
//todo:
static void senderFactoryDataReset(
{required String? lockID,

View File

@ -100,7 +100,6 @@ class _CardDetailPageState extends State<CardDetailPage> with RouteAware {
state.starTime.value = data['starTime'];
state.endTime.value = data['endTime'];
state.weekDay.value = data['weekDay'];
});
}
}

View File

@ -84,6 +84,7 @@ class _LockDetailPageState extends State<LockDetailPage>
Future<void> loadData() async {
state.keyInfos.value = widget.lockListInfoItemEntity;
CommonDataManage().currentLockUserNo = state.keyInfos.value.lockUserNo!;
CommonDataManage().initUserNo = state.keyInfos.value.initUserNo!;
CommonDataManage().currentKeyInfo = state.keyInfos.value;
state.lockUserNo = state.keyInfos.value.lockUserNo!;

View File

@ -5,32 +5,32 @@ import 'package:get/get.dart';
import 'lockSetInfo_entity.dart';
class LockSetState {
final lockSetInfoData = LockSetInfoData().obs;
final lockFeature = LockFeature().obs;
final lockSettingInfo = LockSettingInfo().obs;
final lockStatus = LockStatus().obs;
final lockBasicInfo = LockBasicInfo().obs;
final Rx<LockSetInfoData> lockSetInfoData = LockSetInfoData().obs;
final Rx<LockFeature> lockFeature = LockFeature().obs;
final Rx<LockSettingInfo> lockSettingInfo = LockSettingInfo().obs;
final Rx<LockStatus> lockStatus = LockStatus().obs;
final Rx<LockBasicInfo> lockBasicInfo = LockBasicInfo().obs;
final lockId = 0.obs;
final RxInt lockId = 0.obs;
var isOnlyOneData = false.obs;
var isAttendance = 0.obs; //
var isOpenLockNeedOnline = 0.obs; // APP开锁时是否需联网
RxBool isOnlyOneData = false.obs;
RxInt isAttendance = 0.obs; //
RxInt isOpenLockNeedOnline = 0.obs; // APP开锁时是否需联网
var isUnlockReminder = 0.obs; //
var isOpenBlueBroadcast = 0.obs; // 广
var isOpenExceptionWarnings = 0.obs; //
var isOpenStayWarn = 0.obs; //
RxInt isUnlockReminder = 0.obs; //
RxInt isOpenBlueBroadcast = 0.obs; // 广
RxInt isOpenExceptionWarnings = 0.obs; //
RxInt isOpenStayWarn = 0.obs; //
var passwordTF = TextEditingController();
TextEditingController passwordTF = TextEditingController();
var settingUpSupportFeatures = 0;
var ifCurrentScreen = true.obs; // ,
var deleteAdministratorIsHaveAllData = false.obs; //
int settingUpSupportFeatures = 0;
RxBool ifCurrentScreen = true.obs; // ,
RxBool deleteAdministratorIsHaveAllData = false.obs; //
LockSetState() {
Map map = Get.arguments;
lockId.value = map["lockId"];
isOnlyOneData.value = map["isOnlyOneData"];
lockId.value = map['lockId'];
isOnlyOneData.value = map['isOnlyOneData'];
}
}

View File

@ -143,6 +143,7 @@ class LockListInfoItemEntity {
int? hasGateway;
int? appUnlockOnline;
String? mac;
int? initUserNo;
LockListInfoItemEntity({
this.keyId,
@ -180,6 +181,7 @@ class LockListInfoItemEntity {
this.hasGateway,
this.appUnlockOnline,
this.mac,
this.initUserNo,
});
LockListInfoItemEntity.fromJson(Map<String, dynamic> json) {
@ -224,6 +226,7 @@ class LockListInfoItemEntity {
hasGateway = json['hasGateway'];
appUnlockOnline = json['appUnlockOnline'];
mac = json['mac'];
initUserNo = json['initUserNo'];
}
Map<String, dynamic> toJson() {
@ -269,6 +272,7 @@ class LockListInfoItemEntity {
data['hasGateway'] = hasGateway;
data['appUnlockOnline'] = appUnlockOnline;
data['mac'] = mac;
data['initUserNo'] = initUserNo;
return data;
}

View File

@ -2,6 +2,7 @@
import 'package:flutter/cupertino.dart';
import 'package:get/get.dart';
import 'package:star_lock/tools/baseGetXController.dart';
import '../../../../main/lockMian/entity/lockListInfo_entity.dart';
import '../../../../network/api_repository.dart';
import '../../../../tools/eventBusEventManage.dart';
import '../../../../translations/trans_lib.dart';
@ -13,8 +14,8 @@ class RecipientInformationLogic extends BaseGetXController{
//
Future<void> transferLockConfirmInfoData(void Function(RecipientInformationData recipientInformationData) action) async{
var entity = await ApiRepository.to.transferLockConfirmInfoData(
receiverUserid: state.numberController.text,
final RecipientInformationEntity entity = await ApiRepository.to.transferLockConfirmInfoData(
receiverUsername: state.numberController.text,
type: state.type.value.toString(),
countryCode: state.countryCode.value
);
@ -29,32 +30,51 @@ class RecipientInformationLogic extends BaseGetXController{
//
Future<void> transferLockInfoData() async{
var entity = await ApiRepository.to.transferLockInfoData(
receiverUserid: state.numberController.text,
final RecipientInformationEntity entity = await ApiRepository.to.transferLockInfoData(
receiverUsername: state.numberController.text,
lockIdList: state.idList.value,
countryCode: state.countryCode.value
);
if(entity.errorCode!.codeIsSuccessful){
Get.back(result: "scuess");
eventBus.fire(RefreshLockListInfoDataEvent());
showToast('转移成功'.tr, something: (){
Get.back(result: 'scuess');
});
}
}
//
Future<void> removeBrokenLockData() async{
var entity = await ApiRepository.to.removeBrokenLockData(
final RecipientInformationEntity entity = await ApiRepository.to.removeBrokenLockData(
lockIdList: state.idList.value,
);
if(entity.errorCode!.codeIsSuccessful){
eventBus.fire(RefreshLockListInfoDataEvent());
Get.back(result: "scuess");
showToast('移除成功'.tr, something: (){
Get.back(result: 'scuess');
});
}
}
//
Future<void> checkLoginPassword() async {
final LockListInfoEntity entity = await ApiRepository.to.checkLoginPassword(
password: state.passwordTF.text,
);
if (entity.errorCode!.codeIsSuccessful) {
Get.back();
if (state.isFromType.value == 1) {
// transferGatewayInfoData
transferLockInfoData();
} else {
//
transferGatewayInfoData();
}
}
}
//
Future<void> transferGateWayConfirmInfoData(void Function(RecipientInformationData recipientInformationData) action) async{
var entity = await ApiRepository.to.transferGatewayConfirmInfoData(
receiverUserid: state.numberController.text,
final RecipientInformationEntity entity = await ApiRepository.to.transferGatewayConfirmInfoData(
receiverUsername: state.numberController.text,
type: state.type.value.toString(),
countryCode: state.countryCode.value
);
@ -65,13 +85,13 @@ class RecipientInformationLogic extends BaseGetXController{
//
Future<void> transferGatewayInfoData() async{
var entity = await ApiRepository.to.transferGatewayInfoData(
receiverUserid: state.numberController.text,
final RecipientInformationEntity entity = await ApiRepository.to.transferGatewayInfoData(
receiverUsername: state.numberController.text,
plugIdList: state.idList.value,
countryCode: state.countryCode.value
);
if(entity.errorCode!.codeIsSuccessful){
Get.back(result: "scuess");
Get.back(result: 'scuess');
}
}
@ -79,16 +99,14 @@ class RecipientInformationLogic extends BaseGetXController{
void showDeletAlertDialog() {
showCupertinoDialog(
context: Get.context!,
builder: (context) {
builder: (BuildContext context) {
return CupertinoAlertDialog(
title: const Text("提示"),
title: const Text('提示'),
content: const Text('确定要移除所选中的坏锁吗?'),
actions: [
actions: <Widget>[
CupertinoDialogAction(
child: Text(TranslationLoader.lanKeys!.cancel!.tr),
onPressed: () {
Get.back();
},
onPressed: Get.back,
),
CupertinoDialogAction(
child: Text(TranslationLoader.lanKeys!.sure!.tr),
@ -103,23 +121,4 @@ class RecipientInformationLogic extends BaseGetXController{
);
}
@override
void onReady() {
// TODO: implement onReady
super.onReady();
}
@override
void onInit() {
// TODO: implement onInit
super.onInit();
}
@override
void onClose() {
// TODO: implement onClose
super.onClose();
}
}

View File

@ -1,3 +1,4 @@
import 'package:flutter/material.dart';
import 'package:flutter_native_contact_picker/flutter_native_contact_picker.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
@ -11,6 +12,8 @@ import '../../../../../app_settings/app_colors.dart';
import '../../../../../tools/titleAppBar.dart';
import '../../../../../translations/trans_lib.dart';
import '../../../../tools/commonItem.dart';
import '../../../../tools/customNetworkImage.dart';
import '../../../../tools/showTipView.dart';
import 'recipientInformation_entity.dart';
class RecipientInformationPage extends StatefulWidget {
@ -61,7 +64,7 @@ class _RecipientInformationPageState extends State<RecipientInformationPage> {
state.type.value == 1
? 'images/select_circle.png'
: 'images/normal_circle.png',
'个人用户', () {
'个人用户'.tr, () {
setState(() {
state.type.value = 1;
});
@ -70,7 +73,7 @@ class _RecipientInformationPageState extends State<RecipientInformationPage> {
state.type.value == 2
? 'images/select_circle.png'
: 'images/normal_circle.png',
'星寓', () {
'星寓'.tr, () {
setState(() {
state.type.value = 2;
});
@ -90,9 +93,7 @@ class _RecipientInformationPageState extends State<RecipientInformationPage> {
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.center,
children: <Widget>[
SizedBox(
width: 40.w,
),
SizedBox(width: 20.w),
GestureDetector(
child: Image.asset(
leftIcon,
@ -100,9 +101,7 @@ class _RecipientInformationPageState extends State<RecipientInformationPage> {
height: 20.w,
),
),
SizedBox(
width: 16.w,
),
SizedBox(width: 16.w),
Text(
leftTitle,
style: TextStyle(fontSize: 24.sp),
@ -122,9 +121,9 @@ class _RecipientInformationPageState extends State<RecipientInformationPage> {
Row(
children: <Widget>[
SizedBox(
width: 40.w,
width: 20.w,
),
Text('账号',
Text('账号'.tr,
style: TextStyle(
color: AppColors.darkGrayTextColor, fontSize: 22.sp)),
Expanded(
@ -136,7 +135,7 @@ class _RecipientInformationPageState extends State<RecipientInformationPage> {
decoration: InputDecoration(
border: InputBorder.none,
hintText:
state.type.value == 1 ? '请输入手机号或email' : '请输入星寓管理员的账号',
state.type.value == 1 ? '请输入手机号或email'.tr : '请输入星寓管理员的账号'.tr,
hintStyle: TextStyle(
color: AppColors.placeholderTextColor,
fontSize: ScreenUtil().setSp(22),
@ -205,7 +204,7 @@ class _RecipientInformationPageState extends State<RecipientInformationPage> {
return Padding(
padding: EdgeInsets.only(top: 20.h, bottom: 80.h),
child: Text(
'选中的智能锁将会转移到您输入的账号中,您将失去锁的管理权',
'选中的智能锁将会转移到您输入的账号中,您将失去锁的管理权'.tr,
style:
TextStyle(fontSize: 18.sp, color: AppColors.placeholderTextColor),
textAlign: TextAlign.left,
@ -215,10 +214,10 @@ class _RecipientInformationPageState extends State<RecipientInformationPage> {
Widget _buildNextBtn(BuildContext context) {
return SubmitBtn(
btnName: '下一步',
btnName: '下一步'.tr,
onClick: () {
if (state.numberController.text.isEmpty) {
logic.showToast('请输入手机号或email');
logic.showToast('请输入手机号或email'.tr);
return;
}
if (state.isFromType.value == 1) {
@ -228,7 +227,7 @@ class _RecipientInformationPageState extends State<RecipientInformationPage> {
showCupertinoAlertDialog(context, v);
});
} else {
logic.showToast('暂不支持跨平台转移,敬请期待');
logic.showToast('暂不支持跨平台转移,敬请期待'.tr);
// Get.toNamed(Routers.selectBranchPage, arguments: {
// "idList": state.idList.value,
// "countryCode": state.countryCode.value,
@ -243,7 +242,7 @@ class _RecipientInformationPageState extends State<RecipientInformationPage> {
showCupertinoAlertDialog(context, v);
});
} else {
logic.showToast('暂不支持跨平台转移,敬请期待');
logic.showToast('暂不支持跨平台转移,敬请期待'.tr);
// Get.toNamed(Routers.selectBranchPage, arguments: {
// "idList": state.idList.value,
@ -263,7 +262,7 @@ class _RecipientInformationPageState extends State<RecipientInformationPage> {
TextButton(
onPressed: logic.showDeletAlertDialog,
child: Text(
'移除坏锁',
'移除坏锁'.tr,
style: TextStyle(
fontSize: 22.sp, color: AppColors.darkGrayTextColor),
textAlign: TextAlign.end,
@ -295,14 +294,25 @@ class _RecipientInformationPageState extends State<RecipientInformationPage> {
child: Container(
width: 400.w,
height: 400.h,
color: Colors.white,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(20.w),
color: Colors.white
),
child: Column(
children: <Widget>[
SizedBox(height: 20.h),
Text('转移确认', style: TextStyle(fontSize: 24.sp)),
Text('转移确认'.tr, style: TextStyle(fontSize: 24.sp)),
SizedBox(height: 20.h),
Image.asset('images/icon_lockGroup_item.png',
width: 70.h, height: 70.h, fit: BoxFit.fill),
ClipRRect(
borderRadius: BorderRadius.circular(40.w),
child:CustomNetworkImage(
url: recipientInformationData.headUrl!,
defaultUrl: 'images/controls_user.png',
width: 80.w,
height: 80.w)
),
// Image.asset('images/icon_lockGroup_item.png',
// width: 70.h, height: 70.h, fit: BoxFit.fill),
SizedBox(height: 15.h),
Stack(
alignment: Alignment.center,
@ -310,25 +320,25 @@ class _RecipientInformationPageState extends State<RecipientInformationPage> {
children: <Widget>[
Text(recipientInformationData.nickname!,
style: TextStyle(fontSize: 22.sp)),
Positioned(
left: (recipientInformationData.nickname!.length * 19.w)
.w,
child: Container(
width: 80.w,
color: Colors.red,
child: Center(
child: Text(state.type.value == 1 ? '个人用户' : '星寓',
style: TextStyle(
fontSize: 18.sp, color: Colors.white))),
),
)
// Positioned(
// left: (recipientInformationData.nickname!.length * 19.w)
// .w,
// child: Container(
// width: 80.w,
// color: Colors.red,
// child: Center(
// child: Text(state.type.value == 1 ? '个人用户'.tr : '星寓'.tr,
// style: TextStyle(
// fontSize: 18.sp, color: Colors.white))),
// ),
// )
],
),
SizedBox(height: 8.h),
Text(recipientInformationData.userid!,
style: TextStyle(fontSize: 22.sp)),
SizedBox(height: 8.h),
Text('本次共转移${state.idList.value.length}把智能锁',
Text('本次共转移'.tr + '${state.idList.value.length}' + '把智能锁'.tr,
style: TextStyle(fontSize: 20.sp)),
SizedBox(height: 20.h),
Row(
@ -349,13 +359,7 @@ class _RecipientInformationPageState extends State<RecipientInformationPage> {
ElevatedButton(
onPressed: () {
Get.back();
if (state.isFromType.value == 1) {
// transferGatewayInfoData
logic.transferLockInfoData();
} else {
//
logic.transferGatewayInfoData();
}
ShowTipView().showTFViewAlertDialog(state.passwordTF, '请输入登录密码'.tr, '请输入登录密码'.tr, logic.checkLoginPassword);
},
style: ElevatedButton.styleFrom(
foregroundColor: AppColors.appBarIconColor, backgroundColor: AppColors.mainColor,
@ -365,7 +369,7 @@ class _RecipientInformationPageState extends State<RecipientInformationPage> {
borderRadius: BorderRadius.all(Radius.circular(2)),
),
),
child: Text('确认', style: TextStyle(fontSize: 22.sp)),
child: Text('确认'.tr, style: TextStyle(fontSize: 22.sp)),
),
],
)

View File

@ -4,18 +4,20 @@ import 'package:flutter_native_contact_picker/flutter_native_contact_picker.dart
import 'package:get/get.dart';
class RecipientInformationState{
var type = 1.obs;// 1 2
RecipientInformationState() {
Map map = Get.arguments;
idList.value = map['idList'];
isFromType.value = map['isFromType'];
}
RxInt type = 1.obs;// 1 2
final TextEditingController numberController = TextEditingController();
final FlutterContactPicker contactPicker = FlutterContactPicker();
late Contact contact;
final countryName = "中国".obs;
final countryCode = "86".obs;
final isFromType = 1.obs; // 1 2
final idList = [].obs;
RecipientInformationState() {
Map map = Get.arguments;
idList.value = map["idList"];
isFromType.value = map["isFromType"];
}
TextEditingController passwordTF = TextEditingController();
final RxString countryName = '中国'.obs;
final RxString countryCode = '86'.obs;
final RxInt isFromType = 1.obs; // 1 2
final RxList idList = [].obs;
}

View File

@ -1,6 +1,8 @@
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';
import 'package:star_lock/mine/mineSet/transferSmartLock/selectBranch/selectBranch_state.dart';
import '../../../../../app_settings/app_colors.dart';
import '../../../../../tools/titleAppBar.dart';
@ -16,8 +18,8 @@ class SelectBranchPage extends StatefulWidget {
}
class _SelectBranchPageState extends State<SelectBranchPage> {
final logic = Get.put(SelectBranchLogic());
final state = Get.find<SelectBranchLogic>().state;
final SelectBranchLogic logic = Get.put(SelectBranchLogic());
final SelectBranchState state = Get.find<SelectBranchLogic>().state;
@override
Widget build(BuildContext context) {
@ -29,16 +31,12 @@ class _SelectBranchPageState extends State<SelectBranchPage> {
backgroundColor: AppColors.mainColor,
),
body: Column(
children: [
children: <Widget>[
_buildTopView(),
SizedBox(
height: 20.h,
),
SizedBox(height: 20.h),
Expanded(child: _buildMainUI()),
_buildNextBtn(),
SizedBox(
height: 64.h,
)
SizedBox(height: 64.h)
],
),
);
@ -51,17 +49,17 @@ class _SelectBranchPageState extends State<SelectBranchPage> {
color: Colors.white,
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
children: <Widget>[
Padding(
padding: EdgeInsets.only(left: 40.w, top: 20.h, bottom: 16.h),
child: Text(
'公寓',
'公寓'.tr,
style: TextStyle(fontSize: 28.sp),
),
),
Obx(() => Padding(
padding: EdgeInsets.only(left: 40.w),
child: Text('管理员${state.receiverNumber.value}',
child: Text('管理员'.tr + '${state.receiverNumber.value}',
style: TextStyle(
color: AppColors.darkGrayTextColor, fontSize: 24.sp)),
))
@ -73,7 +71,7 @@ class _SelectBranchPageState extends State<SelectBranchPage> {
Widget _buildMainUI() {
return ListView.separated(
itemCount: 1,
separatorBuilder: (context, index) {
separatorBuilder: (BuildContext context, int index) {
return Divider(
height: 1,
indent: 20.w,
@ -81,8 +79,8 @@ class _SelectBranchPageState extends State<SelectBranchPage> {
color: AppColors.greyLineColor,
);
},
itemBuilder: (c, index) {
return _electronicKeyItem('images/normal_circle.png', "分组一", () {});
itemBuilder: (BuildContext c, int index) {
return _electronicKeyItem('images/normal_circle.png', '分组一', () {});
});
}
@ -95,7 +93,7 @@ class _SelectBranchPageState extends State<SelectBranchPage> {
child: Row(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
children: <Widget>[
SizedBox(
width: 40.w,
),
@ -131,7 +129,7 @@ class _SelectBranchPageState extends State<SelectBranchPage> {
// showCupertinoAlertDialog(context, RecipientInformationData());
},
child: Text(
'下一步',
'下一步'.tr,
style: TextStyle(fontSize: 28.sp, color: Colors.white),
)),
),
@ -159,9 +157,9 @@ class _SelectBranchPageState extends State<SelectBranchPage> {
height: 370.h,
color: Colors.white,
child: Column(
children: [
children: <Widget>[
SizedBox(height: 20.h),
Text("转移确认", style: TextStyle(fontSize: 24.sp)),
Text('转移确认', style: TextStyle(fontSize: 24.sp)),
SizedBox(height: 20.h),
Image.asset('images/icon_lockGroup_item.png', width: 70.h, height: 70.h, fit: BoxFit.fill),
SizedBox(height: 15.h),
@ -175,7 +173,7 @@ class _SelectBranchPageState extends State<SelectBranchPage> {
child: Container(
width: 80.w,
color: Colors.red,
child: Center(child: Text(state.type.value == 1 ? "个人用户" : "星寓", style: TextStyle(fontSize: 18.sp, color: Colors.white))),
child: Center(child: Text(state.type.value == 1 ? '个人用户' : '星寓', style: TextStyle(fontSize: 18.sp, color: Colors.white))),
),
)
],
@ -183,11 +181,11 @@ class _SelectBranchPageState extends State<SelectBranchPage> {
SizedBox(height: 8.h),
Text(recipientInformationData.userid!, style: TextStyle(fontSize: 22.sp)),
SizedBox(height: 8.h),
Text("本次共转移${state.idList.value.length}把智能锁", style: TextStyle(fontSize: 20.sp)),
Text('本次共转移${state.idList.value.length}把智能锁', style: TextStyle(fontSize: 20.sp)),
SizedBox(height: 20.h),
Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
children: <Widget>[
ElevatedButton(
onPressed: Get.back,
style: ElevatedButton.styleFrom(

View File

@ -1,4 +1,6 @@
import 'dart:async';
import 'package:star_lock/tools/baseGetXController.dart';
import '../../../../network/api_repository.dart';
import 'transferSmartLock_entity.dart';
@ -9,30 +11,11 @@ class TransferSmartLockLogic extends BaseGetXController{
//
Future<TransferSmartLockEntity> getTransferLockListData() async{
var entity = await ApiRepository.to.getTransferLockListData();
final TransferSmartLockEntity entity = await ApiRepository.to.getTransferLockListData(searchStr: state.searchController.text);
if(entity.errorCode!.codeIsSuccessful){
state.transferSmartLockListData.value = entity.data!.list!;
}
return entity;
}
@override
void onReady() {
// TODO: implement onReady
super.onReady();
// getTransferLockListData();
}
@override
void onInit() {
// TODO: implement onInit
super.onInit();
}
@override
void onClose() {
// TODO: implement onClose
super.onClose();
}
}

View File

@ -1,12 +1,16 @@
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';
import 'package:star_lock/mine/mineSet/transferSmartLock/transferSmartLockList/transferSmartLock_state.dart';
import '../../../../../appRouters.dart';
import '../../../../../app_settings/app_colors.dart';
import '../../../../../tools/titleAppBar.dart';
import '../../../../../translations/trans_lib.dart';
import '../../../../tools/EasyRefreshTool.dart';
import '../../../../tools/appRouteObserver.dart';
import '../../../../tools/eventBusEventManage.dart';
import '../../../../tools/keySearchWidget.dart';
import '../../../../tools/noData.dart';
import 'transferSmartLock_entity.dart';
@ -19,9 +23,9 @@ class TransferSmartLockPage extends StatefulWidget {
State<TransferSmartLockPage> createState() => _TransferSmartLockPageState();
}
class _TransferSmartLockPageState extends State<TransferSmartLockPage> {
final logic = Get.put(TransferSmartLockLogic());
final state = Get.find<TransferSmartLockLogic>().state;
class _TransferSmartLockPageState extends State<TransferSmartLockPage> with RouteAware {
final TransferSmartLockLogic logic = Get.put(TransferSmartLockLogic());
final TransferSmartLockState state = Get.find<TransferSmartLockLogic>().state;
Future<void> getHttpData() async {
logic.getTransferLockListData().then((TransferSmartLockEntity value){
@ -44,17 +48,17 @@ class _TransferSmartLockPageState extends State<TransferSmartLockPage> {
barTitle: TranslationLoader.lanKeys!.selectiveLock!.tr,
haveBack: true,
backgroundColor: AppColors.mainColor,
actionsList: [
actionsList: <Widget>[
TextButton(
onPressed: () {
setState(() {
if(state.isSelectAll == true){
for (var element in state.transferSmartLockListData.value) {
for (final TransferSmartLockItemData element in state.transferSmartLockListData.value) {
state.isSelectAll = false;
element.select = 0;
}
}else{
for (var element in state.transferSmartLockListData.value) {
for (final TransferSmartLockItemData element in state.transferSmartLockListData.value) {
state.isSelectAll = true;
element.select = 1;
}
@ -68,29 +72,29 @@ class _TransferSmartLockPageState extends State<TransferSmartLockPage> {
onRefresh: (){
getHttpData();
},
child: Obx(() => state.transferSmartLockListData.value.isNotEmpty ? Column(
children: [
// KeySearchWidget(
// editingController: state.searchController,
// onSubmittedAction: () {
// getHttpData();
// },
// ),
child: Column(
children: <Widget>[
KeySearchWidget(
editingController: state.searchController,
onSubmittedAction: () {
getHttpData();
},
),
SizedBox(height: 10.h),
Expanded(child: _buildMainUI()),
SizedBox(height: 20.h),
_buildNextBtn(),
SizedBox(height: 64.h)
],
): NoData()),
),
),
);
}
Widget _buildMainUI() {
return ListView.separated(
return Obx(() => state.transferSmartLockListData.value.isNotEmpty ? ListView.separated(
itemCount: state.transferSmartLockListData.value.length,
separatorBuilder: (context, index) {
separatorBuilder: (BuildContext context, int index) {
return Divider(
height: 1,
indent: 20.w,
@ -98,8 +102,8 @@ class _TransferSmartLockPageState extends State<TransferSmartLockPage> {
color: AppColors.greyLineColor,
);
},
itemBuilder: (c, index) {
TransferSmartLockItemData transferSmartLockItemData = state.transferSmartLockListData.value[index];
itemBuilder: (BuildContext c, int index) {
final TransferSmartLockItemData transferSmartLockItemData = state.transferSmartLockListData.value[index];
return _electronicKeyItem(transferSmartLockItemData, () {
setState(() {
if(transferSmartLockItemData.select == 1){
@ -109,7 +113,7 @@ class _TransferSmartLockPageState extends State<TransferSmartLockPage> {
}
});
});
});
}): NoData());
}
Widget _electronicKeyItem(TransferSmartLockItemData transferSmartLockItemData, Function() action) {
@ -117,17 +121,20 @@ class _TransferSmartLockPageState extends State<TransferSmartLockPage> {
onTap: action,
child: Container(
color: Colors.white,
height: 90.h,
// height: 90.h,
padding: EdgeInsets.only(top: 10.h, bottom: 10.h),
child: Row(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
children: <Widget>[
SizedBox(width: 20.w),
Image.asset((transferSmartLockItemData.select == 1) ? 'images/icon_round_select.png' : 'images/icon_round_unSelect.png', width: 30.w, height: 30.w),
SizedBox(width: 16.w),
Image.asset('images/icon_lockGroup_item.png', width: 50.h, height: 50.h, fit: BoxFit.fill),
SizedBox(width: 10.w),
Text(transferSmartLockItemData.lockAlias!, style: TextStyle(fontSize: 22.sp, color: AppColors.blackColor))
Flexible(
child: Text(transferSmartLockItemData.lockAlias!, style: TextStyle(fontSize: 22.sp, color: AppColors.blackColor)),
)
],
),
),
@ -143,28 +150,72 @@ class _TransferSmartLockPageState extends State<TransferSmartLockPage> {
child: TextButton(
onPressed: () async {
bool isCanNext = false;
var idList = [];
for (var element in state.transferSmartLockListData.value) {
final List idList = [];
for (final TransferSmartLockItemData element in state.transferSmartLockListData.value) {
if(element.select == 1){
isCanNext = true;
idList.add(element.lockId);
}
}
if(isCanNext == false){
logic.showToast("请选择锁".tr);
logic.showToast('请选择锁'.tr);
return;
}
var data = await Get.toNamed(Routers.recipientInformationPage, arguments: {
"idList":idList,
"isFromType":1,
final data = await Get.toNamed(Routers.recipientInformationPage, arguments: <String, Object>{
'idList':idList,
'isFromType':1,
});
if(data != null) {
logic.getTransferLockListData();
await getHttpData();
// eventBus.fire(RefreshLockListInfoDataEvent());
}
},
child: Text('下一步', style: TextStyle(fontSize: 28.sp, color: Colors.white),
child: Text('下一步'.tr, style: TextStyle(fontSize: 28.sp, color: Colors.white),
)),
),
);
}
@override
void didChangeDependencies() {
super.didChangeDependencies();
///
AppRouteObserver().routeObserver.subscribe(this, ModalRoute.of(context)!);
}
@override
void dispose() {
///
AppRouteObserver().routeObserver.unsubscribe(this);
super.dispose();
}
///
@override
void didPush() {
super.didPush();
}
///
@override
void didPop() {
super.didPop();
eventBus.fire(RefreshLockListInfoDataEvent());
}
///
@override
void didPopNext() {
super.didPopNext();
}
///
@override
void didPushNext() {
super.didPushNext();
}
}

View File

@ -5,7 +5,7 @@ import 'package:get/get.dart';
import 'transferSmartLock_entity.dart';
class TransferSmartLockState{
var transferSmartLockListData = <TransferSmartLockItemData>[].obs;
RxList<TransferSmartLockItemData> transferSmartLockListData = <TransferSmartLockItemData>[].obs;
final TextEditingController searchController = TextEditingController();
bool isSelectAll = false;
}

View File

@ -354,6 +354,15 @@ class ApiProvider extends BaseProvider {
}),
isUnShowLoading: true);
// InitUserNo
Future<Response> updateLockInitUserNo(int lockId, int initUserNo) => post(
lockUpdateLockInfo.toUrl,
jsonEncode({
'lockId': lockId,
'initUserNo': initUserNo,
}),
isUnShowLoading: true);
//
Future<Response> bindingBlueAdmin(
String lockAlias,
@ -1449,27 +1458,29 @@ class ApiProvider extends BaseProvider {
jsonEncode({'lockId': lockId, 'cardName': cardName}));
//
Future<Response> getTransferLockListData() =>
post(transferLockListURL.toUrl, jsonEncode({}));
Future<Response> getTransferLockListData(String searchStr) =>
post(transferLockListURL.toUrl, jsonEncode({
"searchStr":searchStr
}));
//
Future<Response> transferLockConfirmInfoData(
String receiverUserid, String type, String countryCode) =>
String receiverUsername, String type, String countryCode) =>
post(
transferLockConfirmURL.toUrl,
jsonEncode({
'receiverUserid': receiverUserid,
'receiverUsername': receiverUsername,
'type': type,
'countryCode': countryCode
}));
//
Future<Response> transferLockInfoData(
String receiverUserid, List lockIdList, String countryCode) =>
String receiverUsername, List lockIdList, String countryCode) =>
post(
transferLockURL.toUrl,
jsonEncode({
'receiverUserid': receiverUserid,
'receiverUsername': receiverUsername,
'lockIdList': lockIdList,
'countryCode': countryCode
}));
@ -1481,22 +1492,22 @@ class ApiProvider extends BaseProvider {
//
Future<Response> transferGatewayConfirmInfoData(
String receiverUserid, String type, String countryCode) =>
String receiverUsername, String type, String countryCode) =>
post(
transferGatewayConfirmURL.toUrl,
jsonEncode({
'receiverUserid': receiverUserid,
'receiverUsername': receiverUsername,
'type': type,
'countryCode': countryCode
}));
//
Future<Response> transferGatewayInfoData(
String receiverUserid, List plugIdList, String countryCode) =>
String receiverUsername, List plugIdList, String countryCode) =>
post(
transferGatewayURL.toUrl,
jsonEncode({
'receiverUserid': receiverUserid,
'receiverUsername': receiverUsername,
'plugIdList': plugIdList,
'countryCode': countryCode
}));

View File

@ -318,6 +318,13 @@ class ApiRepository {
return LockNetTokenEntity.fromJson(res.body);
}
// InitUserNo
Future<LockNetTokenEntity> updateLockInitUserNo(
{required int lockId, required int initUserNo}) async {
final res = await apiProvider.updateLockInitUserNo(lockId, initUserNo);
return LockNetTokenEntity.fromJson(res.body);
}
//
Future<SaveLockEntity> bindingBlueAdmin(
{required String lockAlias,
@ -1639,28 +1646,28 @@ class ApiRepository {
}
//
Future<TransferSmartLockEntity> getTransferLockListData() async {
final res = await apiProvider.getTransferLockListData();
Future<TransferSmartLockEntity> getTransferLockListData({required String searchStr}) async {
final res = await apiProvider.getTransferLockListData(searchStr);
return TransferSmartLockEntity.fromJson(res.body);
}
//
Future<RecipientInformationEntity> transferLockConfirmInfoData(
{required String receiverUserid,
{required String receiverUsername,
required String type,
required String countryCode}) async {
final res = await apiProvider.transferLockConfirmInfoData(
receiverUserid, type, countryCode);
receiverUsername, type, countryCode);
return RecipientInformationEntity.fromJson(res.body);
}
//
Future<RecipientInformationEntity> transferLockInfoData(
{required String receiverUserid,
{required String receiverUsername,
required List lockIdList,
required String countryCode}) async {
final res = await apiProvider.transferLockInfoData(
receiverUserid, lockIdList, countryCode);
receiverUsername, lockIdList, countryCode);
return RecipientInformationEntity.fromJson(res.body);
}
@ -1673,21 +1680,21 @@ class ApiRepository {
//
Future<RecipientInformationEntity> transferGatewayConfirmInfoData(
{required String receiverUserid,
{required String receiverUsername,
required String type,
required String countryCode}) async {
final res = await apiProvider.transferGatewayConfirmInfoData(
receiverUserid, type, countryCode);
receiverUsername, type, countryCode);
return RecipientInformationEntity.fromJson(res.body);
}
//
Future<RecipientInformationEntity> transferGatewayInfoData(
{required String receiverUserid,
{required String receiverUsername,
required List plugIdList,
required String countryCode}) async {
final res = await apiProvider.transferGatewayInfoData(
receiverUserid, plugIdList, countryCode);
receiverUsername, plugIdList, countryCode);
return RecipientInformationEntity.fromJson(res.body);
}

View File

@ -31,6 +31,9 @@ class CommonDataManage {
// set setCurrentLockUserNo(int v) => _currentLockUserNo = v;
// get getCurrentLockUserNo => _currentLockUserNo;
// 1- 0-
int initUserNo = 0;
LockSetInfoData currentLockSetInfoData = LockSetInfoData();
int dayLatestTime = (86400-1)*1000;

View File

@ -23,6 +23,11 @@ class LockAddUserSucceedEvent {
LockAddUserSucceedEvent(this.dataList, this.type);
}
///
class LockInitUserNoEvent {
LockInitUserNoEvent();
}
///
class RefreshLockDetailInfoDataEvent {
RefreshLockDetailInfoDataEvent();