完成分组功能,调试蓝牙协议
This commit is contained in:
parent
5e920b9ada
commit
79c0b74f36
@ -1,4 +1,3 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:star_lock/common/safetyVerification/safetyVerification_binding.dart';
|
||||
import 'package:star_lock/login/register/starLock_register_binding.dart';
|
||||
@ -20,7 +19,7 @@ import 'package:star_lock/mine/minePersonInfo/minePersonInfoViewSafetyProblem/mi
|
||||
import 'package:star_lock/mine/mineSet/addAuthorizedAdministrator/addAuthorizedAdministrator_page.dart';
|
||||
import 'package:star_lock/mine/mineSet/authorizedAdministrator/administratorDetails/adminDetailChangeDate_page.dart';
|
||||
import 'package:star_lock/mine/mineSet/authorizedAdministrator/administratorDetails/administratorDetails_page.dart';
|
||||
import 'package:star_lock/mine/mineSet/lockGroup/lockGroupList_page.dart';
|
||||
import 'package:star_lock/mine/mineSet/lockGroup/lockGroupList/lockGroupList_page.dart';
|
||||
import 'package:star_lock/mine/mineSet/lockUserManage/expireLockList/expireLockChangeDate_page.dart';
|
||||
import 'package:star_lock/mine/mineSet/lockUserManage/expireLockList/expireLockList_page.dart';
|
||||
import 'package:star_lock/mine/mineSet/mineSet/mineSet_page.dart';
|
||||
@ -130,7 +129,8 @@ import 'mine/mineSet/authorityManagement/authorityManagement_page.dart';
|
||||
import 'mine/mineSet/authorityManagement/getDeviceList_page.dart';
|
||||
import 'mine/mineSet/authorityManagement/getNameList_page.dart';
|
||||
import 'mine/mineSet/hideInvalidUnlockPermissions/hideInvalidUnlockPermissions_page.dart';
|
||||
import 'mine/mineSet/lockGroup/lockItemList_page.dart';
|
||||
import 'mine/mineSet/lockGroup/groupEditLock/groupEditLock_page.dart';
|
||||
import 'mine/mineSet/lockGroup/lockGroupDetailList/lockItemList_page.dart';
|
||||
import 'mine/mineSet/lockScreen/lockScreen_page.dart';
|
||||
import 'mine/mineSet/lockUserManage/lockUserManageList/lockUserManageList_page.dart';
|
||||
import 'mine/mineSet/lockUserManage/ownedKeyList/ownedKeyList_page.dart';
|
||||
@ -201,6 +201,7 @@ abstract class Routers {
|
||||
'/UploadElectricQuantityPage'; // 更新锁电量
|
||||
static const editLockNamePage = '/EditLockNamePage'; // 修改锁名字
|
||||
static const lockSeletGroupingPage = '/LockSeletGroupingPage'; // 锁选择分组
|
||||
static const groupEditLockPage = '/GroupEditLockPage'; // 编辑锁分组里面的锁
|
||||
static const adminOpenLockPasswordPage =
|
||||
'/AdminOpenLockPasswordPage'; // 管理员开锁密码
|
||||
static const wirelessKeyboardPage = '/WirelessKeyboardPage'; // 蓝牙键盘
|
||||
@ -756,6 +757,8 @@ abstract class AppRouters {
|
||||
page: () => const LockUserManageListPage()),
|
||||
GetPage(
|
||||
name: Routers.lockGroupListPage, page: () => const LockGroupListPage()),
|
||||
GetPage(
|
||||
name: Routers.groupEditLockPage, page: () => const GroupEditLockPage()),
|
||||
GetPage(
|
||||
name: Routers.lockItemListPage, page: () => const LockItemListPage()),
|
||||
GetPage(
|
||||
|
||||
@ -1,15 +1,11 @@
|
||||
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_easyloading/flutter_easyloading.dart';
|
||||
import 'package:flutter_reactive_ble/flutter_reactive_ble.dart';
|
||||
import 'package:star_lock/blue/sender_manage.dart';
|
||||
|
||||
import '../app_settings/app_settings.dart';
|
||||
import '../tools/storage.dart';
|
||||
import '../tools/toast.dart';
|
||||
import 'io_tool/io_manager.dart';
|
||||
import 'io_tool/io_model.dart';
|
||||
import 'io_tool/io_tool.dart';
|
||||
import 'io_tool/manager_event_bus.dart';
|
||||
@ -218,6 +214,10 @@ class BlueManage{
|
||||
// 重新连接
|
||||
Future<void> judgeReconnect(String deviceMAC, String deviceName, ConnectStateCallBack? connectStateCallBack, {bool isShowLoading = true}) async {
|
||||
// print("11111111$deviceConnectionState");
|
||||
if(deviceMAC.isEmpty){
|
||||
Toast.show(msg: "未连接到设备,请确保在设备附近,设备未被连接,设备已打开");
|
||||
// return;
|
||||
}
|
||||
if(deviceConnectionState == DeviceConnectionState.connected){
|
||||
// print("2222222:$deviceConnectionState");
|
||||
if(isShowLoading){
|
||||
@ -369,7 +369,6 @@ class BlueManage{
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Future<void> writeCharacteristicWithoutResponse(
|
||||
QualifiedCharacteristic characteristic, List<int> value) async {
|
||||
try {
|
||||
|
||||
121
star_lock/lib/blue/io_protocol/io_readAdminPassword.dart
Normal file
121
star_lock/lib/blue/io_protocol/io_readAdminPassword.dart
Normal file
@ -0,0 +1,121 @@
|
||||
|
||||
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 SenderReadAdminPasswordCommand extends SenderProtocol {
|
||||
|
||||
String? keyID;
|
||||
String? userID;
|
||||
int? role;
|
||||
int? pwdNum;
|
||||
int? pwdNo;
|
||||
List<int>? token;
|
||||
int? needAuthor;
|
||||
List<int>? publicKey;
|
||||
List<int>? privateKey;
|
||||
|
||||
SenderReadAdminPasswordCommand({
|
||||
this.keyID,
|
||||
this.userID,
|
||||
this.role,
|
||||
this.pwdNum,
|
||||
this.pwdNo,
|
||||
this.token,
|
||||
this.needAuthor,
|
||||
this.publicKey,
|
||||
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(74);
|
||||
|
||||
// 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);
|
||||
|
||||
// Role
|
||||
subData.add(role!);
|
||||
|
||||
// PwdNum
|
||||
subData.add(pwdNum!);
|
||||
|
||||
// PwdNo
|
||||
subData.add(pwdNo!);
|
||||
|
||||
if(needAuthor == 0){
|
||||
//AuthCodeLen 1
|
||||
subData.add(0);
|
||||
} else {
|
||||
List<int> authCodeData = [];
|
||||
|
||||
//authUserID
|
||||
authCodeData.addAll(utf8.encode(userID!));
|
||||
|
||||
//KeyID
|
||||
authCodeData.addAll(utf8.encode(keyID!));
|
||||
|
||||
//token 4 首次请求 Token 填 0,如果锁需要鉴权操作者身份,则会分配动态口令并在应答消息中返回,二次请求时带上。
|
||||
authCodeData.addAll(token!);
|
||||
|
||||
authCodeData.addAll(publicKey!);
|
||||
|
||||
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 SenderReadAdminPasswordReply extends Reply {
|
||||
SenderReadAdminPasswordReply.parseData(CommandType commandType, List<int> dataDetail)
|
||||
: super.parseData(commandType, dataDetail) {
|
||||
data = dataDetail;
|
||||
}
|
||||
}
|
||||
@ -1,5 +1,7 @@
|
||||
import 'io_type.dart';
|
||||
|
||||
|
||||
|
||||
abstract class Reply{
|
||||
|
||||
CommandType? commandType;
|
||||
|
||||
@ -37,7 +37,7 @@ int _hexToInt(String hex) {
|
||||
// a..f
|
||||
val += (hexDigit - 87) * (1 << (4 * (len - 1 - i)));
|
||||
} else {
|
||||
throw new FormatException("Invalid hexadecimal value");
|
||||
throw FormatException("Invalid hexadecimal value");
|
||||
}
|
||||
}
|
||||
return val;
|
||||
|
||||
@ -8,6 +8,7 @@ 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';
|
||||
import 'package:star_lock/blue/io_protocol/io_getLockStatu.dart';
|
||||
import 'package:star_lock/blue/io_protocol/io_readAdminPassword.dart';
|
||||
import 'package:star_lock/blue/io_protocol/io_readSupportFunctionsNoParameters.dart';
|
||||
import 'package:star_lock/blue/io_protocol/io_readSupportFunctionsWithParameters.dart';
|
||||
import 'package:star_lock/blue/io_protocol/io_referEventRecordTime.dart';
|
||||
@ -299,6 +300,12 @@ class CommandReciverManager {
|
||||
reply = ReadSupportFunctionsWithParametersReply.parseData(commandType, data);
|
||||
}
|
||||
break;
|
||||
case 74:
|
||||
{
|
||||
// 读取管理员密码
|
||||
reply = SenderReadAdminPasswordReply.parseData(commandType, data);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
@ -3,6 +3,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_deletUser.dart';
|
||||
import 'package:star_lock/blue/io_protocol/io_getLockStatu.dart';
|
||||
import 'package:star_lock/blue/io_protocol/io_readAdminPassword.dart';
|
||||
|
||||
import 'io_protocol/io_addFingerprint.dart';
|
||||
import 'io_protocol/io_addStressFingerprint.dart';
|
||||
@ -714,4 +715,30 @@ class IoSenderManage {
|
||||
), callBack:callBack);
|
||||
}
|
||||
|
||||
//todo:读取管理员密码
|
||||
static void senderReadAdminPasswordCommand({
|
||||
required String? keyID,
|
||||
required String? userID,
|
||||
required int? role,
|
||||
required int? pwdNum,
|
||||
required int? pwdNo,
|
||||
required List<int>? token,
|
||||
required int? needAuthor,
|
||||
required List<int>? publicKey,
|
||||
required List<int>? privateKey,
|
||||
CommandSendCallBack? callBack}) {
|
||||
CommandSenderManager().managerSendData(
|
||||
command: SenderReadAdminPasswordCommand(
|
||||
keyID: keyID,
|
||||
userID: userID,
|
||||
role: role,
|
||||
pwdNum: pwdNum,
|
||||
pwdNo: pwdNo,
|
||||
token: token,
|
||||
needAuthor: needAuthor,
|
||||
publicKey: publicKey,
|
||||
privateKey: privateKey,
|
||||
), callBack:callBack);
|
||||
}
|
||||
|
||||
}
|
||||
@ -52,6 +52,7 @@ class GroupListData {
|
||||
class GroupListItem {
|
||||
int? lockNum;
|
||||
int? keyGroupId;
|
||||
int? groupType; //组类型 0未分组 1非未分组
|
||||
String? keyGroupName;
|
||||
List<LockListItem>? lockList;
|
||||
bool _isChecked = false;
|
||||
@ -60,11 +61,12 @@ class GroupListItem {
|
||||
set isChecked(bool value) => _isChecked = value;
|
||||
|
||||
GroupListItem(
|
||||
{this.lockNum, this.keyGroupId, this.keyGroupName, this.lockList});
|
||||
{this.lockNum, this.keyGroupId, this.groupType, this.keyGroupName, this.lockList});
|
||||
|
||||
GroupListItem.fromJson(Map<String, dynamic> json) {
|
||||
lockNum = json['lockNum'];
|
||||
keyGroupId = json['keyGroupId'];
|
||||
groupType = json['groupType'];
|
||||
keyGroupName = json['keyGroupName'];
|
||||
if (json['lockList'] != null) {
|
||||
lockList = <LockListItem>[];
|
||||
@ -78,6 +80,7 @@ class GroupListItem {
|
||||
final Map<String, dynamic> data = <String, dynamic>{};
|
||||
data['lockNum'] = lockNum;
|
||||
data['keyGroupId'] = keyGroupId;
|
||||
data['groupType'] = groupType;
|
||||
data['keyGroupName'] = keyGroupName;
|
||||
if (lockList != null) {
|
||||
data['lockList'] = lockList!.map((v) => v.toJson()).toList();
|
||||
|
||||
@ -0,0 +1,65 @@
|
||||
|
||||
import 'package:flutter_reactive_ble/flutter_reactive_ble.dart';
|
||||
|
||||
import '../../../../../blue/blue_manage.dart';
|
||||
import '../../../../../blue/io_tool/io_tool.dart';
|
||||
import '../../../../../blue/sender_manage.dart';
|
||||
import '../../../../../tools/baseGetXController.dart';
|
||||
import '../../../../../tools/storage.dart';
|
||||
import '../basicInformation/basicInformation_state.dart';
|
||||
|
||||
class AdminOpenLockPasswordLogic extends BaseGetXController{
|
||||
final BasicInformationState state = BasicInformationState();
|
||||
|
||||
// 读取支持功能-带参数
|
||||
Future<void> _readAdminPassword() async {
|
||||
BlueManage().judgeReconnect(BlueManage().connectDeviceMacAddress, BlueManage().connectDeviceName, (DeviceConnectionState connectionState) async {
|
||||
if (connectionState == DeviceConnectionState.connected) {
|
||||
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:5,
|
||||
pwdNo: 0,
|
||||
token: getTokenList,
|
||||
needAuthor: 1,
|
||||
publicKey: getPublicKeyList,
|
||||
privateKey: getPrivateKeyList
|
||||
);
|
||||
}
|
||||
}, isShowLoading: true);
|
||||
}
|
||||
|
||||
@override
|
||||
void onReady() {
|
||||
// TODO: implement onReady
|
||||
super.onReady();
|
||||
print("onReady()");
|
||||
|
||||
_readAdminPassword();
|
||||
}
|
||||
|
||||
@override
|
||||
void onInit() {
|
||||
// TODO: implement onInit
|
||||
super.onInit();
|
||||
print("onInit()");
|
||||
|
||||
}
|
||||
|
||||
@override
|
||||
void onClose() {
|
||||
// TODO: implement onClose
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,16 @@
|
||||
|
||||
import 'package:get/get.dart';
|
||||
|
||||
import '../../lockSet/lockSetInfo_entity.dart';
|
||||
|
||||
class BasicInformationState {
|
||||
var lockSetInfoData = LockSetInfoData().obs;
|
||||
var lockBasicInfo = LockBasicInfo().obs;
|
||||
|
||||
|
||||
BasicInformationState() {
|
||||
var map = Get.arguments;
|
||||
lockSetInfoData.value = map["lockSetInfoData"];
|
||||
lockBasicInfo.value = lockSetInfoData.value.lockBasicInfo!;
|
||||
}
|
||||
}
|
||||
@ -5,4 +5,55 @@ import 'basicInformation_state.dart';
|
||||
class BasicInformationLogic extends BaseGetXController{
|
||||
final BasicInformationState state = BasicInformationState();
|
||||
|
||||
// 读取支持功能-带参数
|
||||
// Future<void> _readAdminPassword() async {
|
||||
// BlueManage().judgeReconnect(BlueManage().connectDeviceMacAddress, BlueManage().connectDeviceName, (DeviceConnectionState connectionState) async {
|
||||
// if (connectionState == DeviceConnectionState.connected) {
|
||||
// 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:5,
|
||||
// pwdNo: 0,
|
||||
// token: getTokenList,
|
||||
// needAuthor: 1,
|
||||
// publicKey: getPublicKeyList,
|
||||
// privateKey: getPrivateKeyList
|
||||
// );
|
||||
// }
|
||||
// }, isShowLoading: true);
|
||||
// }
|
||||
|
||||
@override
|
||||
void onReady() {
|
||||
// TODO: implement onReady
|
||||
super.onReady();
|
||||
print("onReady()");
|
||||
|
||||
// _readAdminPassword();
|
||||
}
|
||||
|
||||
@override
|
||||
void onInit() {
|
||||
// TODO: implement onInit
|
||||
super.onInit();
|
||||
print("onInit()");
|
||||
|
||||
}
|
||||
|
||||
@override
|
||||
void onClose() {
|
||||
// TODO: implement onClose
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@ -49,7 +49,7 @@ class _BasicInformationPageState extends State<BasicInformationPage> {
|
||||
isHaveLine: true),
|
||||
CommonItem(
|
||||
leftTitel: "MAC/ID",
|
||||
rightTitle: state.lockBasicInfo.value.lockAlias,
|
||||
rightTitle: state.lockBasicInfo.value.mac,
|
||||
allHeight: 70.h,
|
||||
isHaveLine: false),
|
||||
SizedBox(
|
||||
|
||||
@ -313,6 +313,7 @@ class LockBasicInfo {
|
||||
int? keyType;
|
||||
int? startDate;
|
||||
int? endDate;
|
||||
String? mac;
|
||||
|
||||
LockBasicInfo(
|
||||
{this.keyId,
|
||||
@ -326,7 +327,8 @@ class LockBasicInfo {
|
||||
this.adminPwd,
|
||||
this.keyType,
|
||||
this.startDate,
|
||||
this.endDate,});
|
||||
this.endDate,
|
||||
this.mac});
|
||||
|
||||
LockBasicInfo.fromJson(Map<String, dynamic> json) {
|
||||
keyId = json['keyId'];
|
||||
@ -346,6 +348,7 @@ class LockBasicInfo {
|
||||
keyType = json['keyType'];
|
||||
startDate = json['startDate'];
|
||||
endDate = json['endDate'];
|
||||
mac = json['mac'];
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
@ -364,6 +367,7 @@ class LockBasicInfo {
|
||||
data['keyType'] = keyType;
|
||||
data['startDate'] = startDate;
|
||||
data['endDate'] = endDate;
|
||||
data['mac'] = mac;
|
||||
return data;
|
||||
}
|
||||
}
|
||||
@ -410,6 +414,9 @@ class LockSettingInfo {
|
||||
String? adminPwd;
|
||||
int? unlockReminderPush;
|
||||
String? languageSettingLangText;
|
||||
int? motorTorsion;
|
||||
int? stayWarn;
|
||||
int? abnormalWarn;
|
||||
|
||||
LockSettingInfo(
|
||||
{this.remoteUnlock,
|
||||
@ -433,7 +440,10 @@ class LockSettingInfo {
|
||||
this.bluetoothBroadcast,
|
||||
this.adminPwd,
|
||||
this.unlockReminderPush,
|
||||
this.languageSettingLangText});
|
||||
this.languageSettingLangText,
|
||||
this.motorTorsion,
|
||||
this.stayWarn,
|
||||
this.abnormalWarn,});
|
||||
|
||||
LockSettingInfo.fromJson(Map<String, dynamic> json) {
|
||||
remoteUnlock = json['remoteUnlock'];
|
||||
@ -463,6 +473,9 @@ class LockSettingInfo {
|
||||
adminPwd = json['adminPwd'];
|
||||
unlockReminderPush = json['unlockReminderPush'];
|
||||
languageSettingLangText = json['languageSettingLangText'];
|
||||
motorTorsion = json['motorTorsion'];
|
||||
stayWarn = json['stayWarn'];
|
||||
abnormalWarn = json['abnormalWarn'];
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
@ -492,6 +505,9 @@ class LockSettingInfo {
|
||||
data['adminPwd'] = adminPwd;
|
||||
data['unlockReminderPush'] = unlockReminderPush;
|
||||
data['languageSettingLangText'] = languageSettingLangText;
|
||||
data['motorTorsion'] = motorTorsion;
|
||||
data['stayWarn'] = stayWarn;
|
||||
data['abnormalWarn'] = abnormalWarn;
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
||||
@ -8,6 +8,8 @@ import 'package:star_lock/blue/io_type.dart';
|
||||
import '../../../../appRouters.dart';
|
||||
import '../../../../blue/blue_manage.dart';
|
||||
import '../../../../blue/io_protocol/io_factoryDataReset.dart';
|
||||
import '../../../../blue/io_protocol/io_readSupportFunctionsNoParameters.dart';
|
||||
import '../../../../blue/io_protocol/io_setSupportFunctionsNoParameters.dart';
|
||||
import '../../../../blue/io_reply.dart';
|
||||
import '../../../../blue/io_tool/io_tool.dart';
|
||||
import '../../../../blue/io_tool/manager_event_bus.dart';
|
||||
@ -41,6 +43,16 @@ class LockSetLogic extends BaseGetXController {
|
||||
if(reply is FactoryDataResetReply){
|
||||
_replyFactoryDataResetKey(reply);
|
||||
}
|
||||
|
||||
// 设置支持功能(不带参数)
|
||||
if(reply is SetSupportFunctionsNoParametersReply) {
|
||||
_replySetSupportFunctionsWithParameters(reply);
|
||||
}
|
||||
|
||||
// 读取支持功能(不带参数)
|
||||
if((reply is ReadSupportFunctionsNoParametersReply) && (state.settingUpSupportFeatures == 56)) {
|
||||
_readSupportFunctionsWithParametersReply(reply);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@ -153,6 +165,82 @@ class LockSetLogic extends BaseGetXController {
|
||||
}
|
||||
}
|
||||
|
||||
// 读取支持功能带参数数据解析
|
||||
Future<void> _readSupportFunctionsWithParametersReply(Reply reply) async {
|
||||
int status = reply.data[2];
|
||||
switch(status){
|
||||
case 0x00:
|
||||
//成功
|
||||
print("${reply.commandType}数据解析成功");
|
||||
state.isOpenBlueBroadcast.value = reply.data[6];
|
||||
print("isOpenBlueBroadcast:${state.isOpenBlueBroadcast.value}");
|
||||
break;
|
||||
case 0x06:
|
||||
//无权限
|
||||
print("${reply.commandType}需要鉴权");
|
||||
break;
|
||||
case 0x07:
|
||||
//无权限
|
||||
print("${reply.commandType}用户无权限");
|
||||
break;
|
||||
case 0x09:
|
||||
// 权限校验错误
|
||||
print("${reply.commandType}权限校验错误");
|
||||
break;
|
||||
default:
|
||||
//失败
|
||||
print("${reply.commandType}失败");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// 设置自动落锁数据解析
|
||||
Future<void> _replySetSupportFunctionsWithParameters(Reply reply) async {
|
||||
int status = reply.data[2];
|
||||
switch(status){
|
||||
case 0x00:
|
||||
//成功
|
||||
print("${reply.commandType}数据解析成功");
|
||||
// Toast.show(msg: "操作成功");featureEnable = state.isOpenStayWarn.value == 1 ? 0 : 1;
|
||||
if(state.settingUpSupportFeatures == 56){
|
||||
// 蓝牙广播
|
||||
state.isOpenBlueBroadcast.value = state.isOpenBlueBroadcast.value == 1 ? 0 : 1;
|
||||
state.lockSetInfoData.value.lockSettingInfo!.bluetoothBroadcast = state.isOpenBlueBroadcast.value;
|
||||
}else if(state.settingUpSupportFeatures == 61){
|
||||
// 逗留警告
|
||||
state.isOpenStayWarn.value = state.isOpenStayWarn.value == 1 ? 0 : 1;
|
||||
state.lockSetInfoData.value.lockSettingInfo!.stayWarn = state.isOpenStayWarn.value;
|
||||
}else if(state.settingUpSupportFeatures == 62){
|
||||
// 异常警告
|
||||
state.isOpenExceptionWarnings.value = state.isOpenExceptionWarnings.value == 1 ? 0 : 1;
|
||||
state.lockSetInfoData.value.lockSettingInfo!.abnormalWarn = state.isOpenExceptionWarnings.value;
|
||||
}
|
||||
|
||||
print("isOpenBlueBroadcast111:${state.isOpenBlueBroadcast.value}");
|
||||
break;
|
||||
case 0x06:
|
||||
//无权限
|
||||
print("${reply.commandType}需要鉴权");
|
||||
|
||||
break;
|
||||
case 0x07:
|
||||
//无权限
|
||||
print("${reply.commandType}用户无权限");
|
||||
|
||||
break;
|
||||
case 0x09:
|
||||
// 权限校验错误
|
||||
print("${reply.commandType}权限校验错误");
|
||||
|
||||
break;
|
||||
default:
|
||||
//失败
|
||||
print("${reply.commandType}失败");
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// 删除用户
|
||||
Future<void> deletUserAction() async {
|
||||
BlueManage().judgeReconnect(
|
||||
@ -207,6 +295,71 @@ class LockSetLogic extends BaseGetXController {
|
||||
});
|
||||
}
|
||||
|
||||
// 读取支持功能-带参数
|
||||
// Future<void> _readSupportFunctionsNoParameters(int type) async {
|
||||
// BlueManage().judgeReconnect(BlueManage().connectDeviceMacAddress, BlueManage().connectDeviceName, (DeviceConnectionState connectionState) async {
|
||||
// if (connectionState == DeviceConnectionState.connected) {
|
||||
// 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.readSupportFunctionsNoParametersCommand(
|
||||
// keyID: state.lockSetInfoData.value.lockBasicInfo!.keyId.toString(),
|
||||
// userID: await Storage.getUid(),
|
||||
// featureBit: type,
|
||||
// token: getTokenList,
|
||||
// needAuthor: 1,
|
||||
// publicKey: getPublicKeyList,
|
||||
// privateKey: getPrivateKeyList
|
||||
// );
|
||||
// }
|
||||
// }, isShowLoading: true);
|
||||
// }
|
||||
|
||||
// 设置支持功能(带参数)
|
||||
Future<void> sendBurglarAlarm(int type) async {
|
||||
BlueManage().judgeReconnect(BlueManage().connectDeviceMacAddress, BlueManage().connectDeviceName, (DeviceConnectionState connectionState) async {
|
||||
if (connectionState == DeviceConnectionState.connected) {
|
||||
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!);
|
||||
|
||||
state.settingUpSupportFeatures = type;
|
||||
|
||||
var featureEnable = 0;
|
||||
if(type == 56){
|
||||
// 蓝牙广播
|
||||
featureEnable = state.isOpenBlueBroadcast.value == 1 ? 0 : 1;
|
||||
}else if(type == 61){
|
||||
// 逗留警告
|
||||
featureEnable = state.isOpenStayWarn.value == 1 ? 0 : 1;
|
||||
}else if(type == 62){
|
||||
// 异常警告
|
||||
featureEnable = state.isOpenExceptionWarnings.value == 1 ? 0 : 1;
|
||||
}
|
||||
IoSenderManage.setSupportFunctionsNoParametersCommand(
|
||||
keyID: state.lockSetInfoData.value.lockBasicInfo!.keyId.toString(),
|
||||
userID: await Storage.getUid(),
|
||||
featureBit: type,
|
||||
featureEnable: featureEnable,
|
||||
token: getTokenList,
|
||||
needAuthor: 1,
|
||||
publicKey: getPublicKeyList,
|
||||
privateKey: getPrivateKeyList);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// 获取锁设置信息
|
||||
void getLockSettingInfoData() async {
|
||||
var entity = await ApiRepository.to.getLockSettingInfoData(
|
||||
@ -218,6 +371,11 @@ class LockSetLogic extends BaseGetXController {
|
||||
state.lockFeature.value = state.lockSetInfoData.value.lockFeature!;
|
||||
state.lockStatus.value = state.lockSetInfoData.value.lockStatus!;
|
||||
state.isAttendance.value = state.lockSettingInfo.value.attendance!;
|
||||
|
||||
state.isOpenBlueBroadcast.value = state.lockSettingInfo.value.bluetoothBroadcast!;
|
||||
state.isOpenExceptionWarnings.value = state.lockSettingInfo.value.bluetoothBroadcast!;
|
||||
// await _readSupportFunctionsNoParameters(56);
|
||||
// _readSupportFunctionsNoParameters(62);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -336,7 +336,9 @@ class _LockSetPageState extends State<LockSetPage> with RouteAware {
|
||||
isHaveLine: true,
|
||||
action: () {
|
||||
// Toast.show(msg: "功能暂未开放");
|
||||
Get.toNamed(Routers.openDoorDirectionPage);
|
||||
Get.toNamed(Routers.openDoorDirectionPage, arguments: {
|
||||
'lockSetInfoData': state.lockSetInfoData.value
|
||||
});
|
||||
})),
|
||||
// ),
|
||||
// Obx(() =>
|
||||
@ -352,18 +354,19 @@ class _LockSetPageState extends State<LockSetPage> with RouteAware {
|
||||
Get.toNamed(Routers.motorPowerPage);
|
||||
})),
|
||||
// ),
|
||||
// Obx(() =>
|
||||
Visibility(
|
||||
visible: true,
|
||||
child: CommonItem(
|
||||
leftTitel: '逗留警告',
|
||||
rightTitle: "",
|
||||
isHaveLine: true,
|
||||
isHaveRightWidget: true,
|
||||
rightWidget: _otherToDoSwitch(0),
|
||||
)),
|
||||
// ),
|
||||
// Obx(() =>
|
||||
Obx(() =>
|
||||
Visibility(
|
||||
visible: true,
|
||||
child: CommonItem(
|
||||
leftTitel: '逗留警告',
|
||||
rightTitle: "",
|
||||
isHaveLine: true,
|
||||
isHaveRightWidget: true,
|
||||
rightWidget: _lockStayWarnSwitch(),
|
||||
)),
|
||||
),
|
||||
Obx(() =>
|
||||
// 异常警告
|
||||
Visibility(
|
||||
visible: true,
|
||||
child: CommonItem(
|
||||
@ -371,8 +374,17 @@ class _LockSetPageState extends State<LockSetPage> with RouteAware {
|
||||
rightTitle: "",
|
||||
isHaveLine: true,
|
||||
isHaveRightWidget: true,
|
||||
rightWidget: _otherToDoSwitch(1))),
|
||||
// ),
|
||||
rightWidget: _lockExceptionWarningsSwitch())),
|
||||
),
|
||||
// 支持蓝牙广播(关闭则不能使用蓝牙主动开锁)
|
||||
Obx(() => Visibility(
|
||||
visible: true,
|
||||
child: CommonItem(
|
||||
leftTitel: '蓝牙广播',
|
||||
rightTitle: "",
|
||||
isHaveLine: true,
|
||||
isHaveRightWidget: true,
|
||||
rightWidget: _lockBlueBroadcastSwitch()))),
|
||||
SizedBox(height: 10.h),
|
||||
//-----新增至此
|
||||
// 标记房态
|
||||
@ -409,23 +421,18 @@ class _LockSetPageState extends State<LockSetPage> with RouteAware {
|
||||
rightTitle: "",
|
||||
isHaveLine: true,
|
||||
isHaveRightWidget: true,
|
||||
rightWidget: SizedBox(
|
||||
width: 60.w, child: _openCheckInSwitch()))),
|
||||
rightWidget: _openCheckInSwitch())),
|
||||
),
|
||||
// 开锁提醒
|
||||
Obx(
|
||||
() => Visibility(
|
||||
visible: state.lockFeature.value.unlockReminder == 1
|
||||
? true
|
||||
: false,
|
||||
visible: state.lockFeature.value.unlockReminder == 1 ? true : false,
|
||||
child: CommonItem(
|
||||
leftTitel:
|
||||
TranslationLoader.lanKeys!.unlockReminder!.tr,
|
||||
leftTitel: TranslationLoader.lanKeys!.unlockReminder!.tr,
|
||||
rightTitle: "",
|
||||
isHaveLine: false,
|
||||
isHaveRightWidget: true,
|
||||
rightWidget: SizedBox(
|
||||
width: 60.w, child: _lockRemindSwitch()))),
|
||||
rightWidget: _lockRemindSwitch())),
|
||||
),
|
||||
SizedBox(height: 10.h),
|
||||
// wifi配网
|
||||
@ -434,8 +441,7 @@ class _LockSetPageState extends State<LockSetPage> with RouteAware {
|
||||
visible:
|
||||
state.lockFeature.value.wifi == 1 ? true : false,
|
||||
child: CommonItem(
|
||||
leftTitel: TranslationLoader
|
||||
.lanKeys!.wifiDistributionNetwork!.tr,
|
||||
leftTitel: TranslationLoader.lanKeys!.wifiDistributionNetwork!.tr,
|
||||
rightTitle: "",
|
||||
isHaveLine: true,
|
||||
isHaveDirection: true,
|
||||
@ -542,7 +548,7 @@ class _LockSetPageState extends State<LockSetPage> with RouteAware {
|
||||
}
|
||||
|
||||
CupertinoSwitch _openCheckInSwitch() {
|
||||
print("111111state.lockSettingInfo.value.attendance:${state.lockSettingInfo.value.attendance}");
|
||||
// print("111111state.lockSettingInfo.value.attendance:${state.lockSettingInfo.value.attendance}");
|
||||
return CupertinoSwitch(
|
||||
activeColor: CupertinoColors.activeBlue,
|
||||
trackColor: CupertinoColors.systemGrey5,
|
||||
@ -574,6 +580,52 @@ 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 _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() {
|
||||
return CupertinoSwitch(
|
||||
activeColor: CupertinoColors.activeBlue,
|
||||
trackColor: CupertinoColors.systemGrey5,
|
||||
thumbColor: CupertinoColors.white,
|
||||
value: (state.isOpenBlueBroadcast.value) == 1 ? true : false,
|
||||
onChanged: (value) {
|
||||
setState(() {
|
||||
logic.sendBurglarAlarm(56);
|
||||
});
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
CupertinoSwitch _otherUnHaveDoneSwitch() {
|
||||
return CupertinoSwitch(
|
||||
activeColor: CupertinoColors.activeBlue,
|
||||
|
||||
@ -13,9 +13,16 @@ class LockSetState {
|
||||
|
||||
var isAttendance = 0.obs;// 是否开启考勤
|
||||
var currentDeviceUUid = "".obs;// 当前设备的uuid
|
||||
|
||||
var isLockPickingReminder = 0.obs;// 是否开启开锁提醒
|
||||
var isOpenBlueBroadcast = 0.obs;// 是否开启蓝牙广播
|
||||
var isOpenExceptionWarnings = 0.obs;// 是否开启异常警告
|
||||
var isOpenStayWarn = 0.obs;// 是否开启逗留警告
|
||||
|
||||
var passwordTF = TextEditingController();
|
||||
|
||||
var settingUpSupportFeatures = 0;
|
||||
|
||||
LockSetState() {
|
||||
Map map = Get.arguments;
|
||||
lockId.value = map["lockId"];
|
||||
|
||||
@ -0,0 +1,190 @@
|
||||
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:flutter_reactive_ble/flutter_reactive_ble.dart';
|
||||
|
||||
import '../../../../blue/blue_manage.dart';
|
||||
import '../../../../blue/io_protocol/io_readSupportFunctionsNoParameters.dart';
|
||||
import '../../../../blue/io_protocol/io_setSupportFunctionsNoParameters.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 '../../../../tools/toast.dart';
|
||||
import 'motorPower_state.dart';
|
||||
|
||||
class MotorPowerLogic extends BaseGetXController {
|
||||
final MotorPowerState state = MotorPowerState();
|
||||
|
||||
// 配置锁的常开模式设置 -> 防撬报警
|
||||
Future<void> _setLockSetGeneralSetting() async{
|
||||
var entity = await ApiRepository.to.setOpenDoorDirectionData(
|
||||
lockId: state.lockSetInfoData.value.lockId!,
|
||||
openDirectionValue:state.motorTorsion.value, // 1-开启、2-关闭;
|
||||
);
|
||||
if(entity.errorCode!.codeIsSuccessful){
|
||||
|
||||
state.lockSetInfoData.value.lockSettingInfo!.openDirectionValue = state.motorTorsion.value;
|
||||
eventBus.fire(PassCurrentLockInformationEvent(state.lockSetInfoData.value));
|
||||
Toast.show(msg: "操作成功");
|
||||
}
|
||||
}
|
||||
|
||||
// 获取解析后的数据
|
||||
late StreamSubscription<Reply> _replySubscription;
|
||||
void _initReplySubscription() {
|
||||
_replySubscription = EventBusManager().eventBus!.on<Reply>().listen((reply) {
|
||||
if(reply is SetSupportFunctionsNoParametersReply) {
|
||||
_replySetSupportFunctionsWithParameters(reply);
|
||||
}
|
||||
|
||||
// 读取支持功能(带参数)
|
||||
if(reply is ReadSupportFunctionsNoParametersReply) {
|
||||
_readSupportFunctionsWithParametersReply(reply);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// 读取支持功能带参数数据解析
|
||||
Future<void> _readSupportFunctionsWithParametersReply(Reply reply) async {
|
||||
int status = reply.data[2];
|
||||
switch(status){
|
||||
case 0x00:
|
||||
//成功
|
||||
print("${reply.commandType}数据解析成功");
|
||||
state.motorTorsion.value = reply.data[6];
|
||||
break;
|
||||
case 0x06:
|
||||
//无权限
|
||||
print("${reply.commandType}需要鉴权");
|
||||
break;
|
||||
case 0x07:
|
||||
//无权限
|
||||
print("${reply.commandType}用户无权限");
|
||||
break;
|
||||
case 0x09:
|
||||
// 权限校验错误
|
||||
print("${reply.commandType}权限校验错误");
|
||||
break;
|
||||
default:
|
||||
//失败
|
||||
print("${reply.commandType}失败");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// 设置自动落锁数据解析
|
||||
Future<void> _replySetSupportFunctionsWithParameters(Reply reply) async {
|
||||
int status = reply.data[2];
|
||||
switch(status){
|
||||
case 0x00:
|
||||
//成功
|
||||
print("${reply.commandType}数据解析成功");
|
||||
_setLockSetGeneralSetting();
|
||||
break;
|
||||
case 0x06:
|
||||
//无权限
|
||||
print("${reply.commandType}需要鉴权");
|
||||
|
||||
break;
|
||||
case 0x07:
|
||||
//无权限
|
||||
print("${reply.commandType}用户无权限");
|
||||
|
||||
break;
|
||||
case 0x09:
|
||||
// 权限校验错误
|
||||
print("${reply.commandType}权限校验错误");
|
||||
|
||||
break;
|
||||
default:
|
||||
//失败
|
||||
print("${reply.commandType}失败");
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// 读取支持功能-带参数
|
||||
Future<void> _readSupportFunctionsNoParameters() async {
|
||||
BlueManage().judgeReconnect(BlueManage().connectDeviceMacAddress, BlueManage().connectDeviceName, (DeviceConnectionState connectionState) async {
|
||||
if (connectionState == DeviceConnectionState.connected) {
|
||||
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.readSupportFunctionsNoParametersCommand(
|
||||
keyID: state.lockSetInfoData.value.lockBasicInfo!.keyId.toString(),
|
||||
userID: await Storage.getUid(),
|
||||
featureBit: 58,
|
||||
token: getTokenList,
|
||||
needAuthor: 1,
|
||||
publicKey: getPublicKeyList,
|
||||
privateKey: getPrivateKeyList
|
||||
);
|
||||
}
|
||||
}, isShowLoading: true);
|
||||
}
|
||||
|
||||
// 设置支持功能(带参数)
|
||||
Future<void> sendOpenDoorDirection() async {
|
||||
BlueManage().judgeReconnect(BlueManage().connectDeviceMacAddress, BlueManage().connectDeviceName, (DeviceConnectionState connectionState) async {
|
||||
if (connectionState == DeviceConnectionState.connected) {
|
||||
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.setSupportFunctionsWithParametersCommand(
|
||||
keyID: state.lockSetInfoData.value.lockBasicInfo!.keyId.toString(),
|
||||
userID: await Storage.getUid(),
|
||||
featureBit: 58,
|
||||
featureParaLength: 1,
|
||||
featureData: [state.motorTorsion.value],
|
||||
token: getTokenList,
|
||||
needAuthor: 1,
|
||||
publicKey: getPublicKeyList,
|
||||
privateKey: getPrivateKeyList);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
void onReady() {
|
||||
// TODO: implement onReady
|
||||
super.onReady();
|
||||
print("onReady()");
|
||||
|
||||
_initReplySubscription();
|
||||
}
|
||||
|
||||
@override
|
||||
void onInit() {
|
||||
// TODO: implement onInit
|
||||
super.onInit();
|
||||
print("onInit()");
|
||||
|
||||
_readSupportFunctionsNoParameters();
|
||||
}
|
||||
|
||||
@override
|
||||
void onClose() {
|
||||
// TODO: implement onClose
|
||||
super.onClose();
|
||||
_replySubscription.cancel();
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,19 @@
|
||||
|
||||
|
||||
import 'package:get/get.dart';
|
||||
|
||||
import '../lockSet/lockSetInfo_entity.dart';
|
||||
|
||||
class MotorPowerState {
|
||||
|
||||
var lockSetInfoData = LockSetInfoData().obs;
|
||||
var motorTorsion = 1.obs;
|
||||
|
||||
MotorPowerState() {
|
||||
var map = Get.arguments;
|
||||
lockSetInfoData.value = map["lockSetInfoData"];
|
||||
|
||||
motorTorsion.value = lockSetInfoData.value.lockSettingInfo!.motorTorsion!;
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,191 @@
|
||||
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:flutter_reactive_ble/flutter_reactive_ble.dart';
|
||||
|
||||
import '../../../../blue/blue_manage.dart';
|
||||
import '../../../../blue/io_protocol/io_readSupportFunctionsNoParameters.dart';
|
||||
import '../../../../blue/io_protocol/io_setSupportFunctionsNoParameters.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 '../../../../tools/toast.dart';
|
||||
import 'openDoorDirection_state.dart';
|
||||
|
||||
class OpenDoorDirectionLogic extends BaseGetXController {
|
||||
final OpenDoorDirectionState state = OpenDoorDirectionState();
|
||||
|
||||
// 配置锁的常开模式设置 -> 防撬报警
|
||||
Future<void> _setLockSetGeneralSetting() async{
|
||||
var entity = await ApiRepository.to.setOpenDoorDirectionData(
|
||||
lockId: state.lockSetInfoData.value.lockId!,
|
||||
openDirectionValue:state.openDirectionValue.value, // 1-开启、2-关闭;
|
||||
);
|
||||
if(entity.errorCode!.codeIsSuccessful){
|
||||
// eventBus.fire(RefreshLockListInfoDataEvent());
|
||||
|
||||
// state.openDirectionValue.value = state.openDirectionValue.value == 1 ? 0 : 1;
|
||||
state.lockSetInfoData.value.lockSettingInfo!.openDirectionValue = state.openDirectionValue.value;
|
||||
eventBus.fire(PassCurrentLockInformationEvent(state.lockSetInfoData.value));
|
||||
Toast.show(msg: "操作成功");
|
||||
}
|
||||
}
|
||||
|
||||
// 获取解析后的数据
|
||||
late StreamSubscription<Reply> _replySubscription;
|
||||
void _initReplySubscription() {
|
||||
_replySubscription = EventBusManager().eventBus!.on<Reply>().listen((reply) {
|
||||
if(reply is SetSupportFunctionsNoParametersReply) {
|
||||
_replySetSupportFunctionsWithParameters(reply);
|
||||
}
|
||||
|
||||
// 读取支持功能(带参数)
|
||||
if(reply is ReadSupportFunctionsNoParametersReply) {
|
||||
_readSupportFunctionsWithParametersReply(reply);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// 读取支持功能带参数数据解析
|
||||
Future<void> _readSupportFunctionsWithParametersReply(Reply reply) async {
|
||||
int status = reply.data[2];
|
||||
switch(status){
|
||||
case 0x00:
|
||||
//成功
|
||||
print("${reply.commandType}数据解析成功");
|
||||
state.openDirectionValue.value = reply.data[6];
|
||||
break;
|
||||
case 0x06:
|
||||
//无权限
|
||||
print("${reply.commandType}需要鉴权");
|
||||
break;
|
||||
case 0x07:
|
||||
//无权限
|
||||
print("${reply.commandType}用户无权限");
|
||||
break;
|
||||
case 0x09:
|
||||
// 权限校验错误
|
||||
print("${reply.commandType}权限校验错误");
|
||||
break;
|
||||
default:
|
||||
//失败
|
||||
print("${reply.commandType}失败");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// 设置自动落锁数据解析
|
||||
Future<void> _replySetSupportFunctionsWithParameters(Reply reply) async {
|
||||
int status = reply.data[2];
|
||||
switch(status){
|
||||
case 0x00:
|
||||
//成功
|
||||
print("${reply.commandType}数据解析成功");
|
||||
_setLockSetGeneralSetting();
|
||||
break;
|
||||
case 0x06:
|
||||
//无权限
|
||||
print("${reply.commandType}需要鉴权");
|
||||
|
||||
break;
|
||||
case 0x07:
|
||||
//无权限
|
||||
print("${reply.commandType}用户无权限");
|
||||
|
||||
break;
|
||||
case 0x09:
|
||||
// 权限校验错误
|
||||
print("${reply.commandType}权限校验错误");
|
||||
|
||||
break;
|
||||
default:
|
||||
//失败
|
||||
print("${reply.commandType}失败");
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// 读取支持功能-带参数
|
||||
Future<void> _readSupportFunctionsNoParameters() async {
|
||||
BlueManage().judgeReconnect(BlueManage().connectDeviceMacAddress, BlueManage().connectDeviceName, (DeviceConnectionState connectionState) async {
|
||||
if (connectionState == DeviceConnectionState.connected) {
|
||||
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.readSupportFunctionsNoParametersCommand(
|
||||
keyID: state.lockSetInfoData.value.lockBasicInfo!.keyId.toString(),
|
||||
userID: await Storage.getUid(),
|
||||
featureBit: 41,
|
||||
token: getTokenList,
|
||||
needAuthor: 1,
|
||||
publicKey: getPublicKeyList,
|
||||
privateKey: getPrivateKeyList
|
||||
);
|
||||
}
|
||||
}, isShowLoading: true);
|
||||
}
|
||||
|
||||
// 设置支持功能(带参数)
|
||||
Future<void> sendOpenDoorDirection() async {
|
||||
BlueManage().judgeReconnect(BlueManage().connectDeviceMacAddress, BlueManage().connectDeviceName, (DeviceConnectionState connectionState) async {
|
||||
if (connectionState == DeviceConnectionState.connected) {
|
||||
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.setSupportFunctionsNoParametersCommand(
|
||||
keyID: state.lockSetInfoData.value.lockBasicInfo!.keyId.toString(),
|
||||
userID: await Storage.getUid(),
|
||||
featureBit: 41,
|
||||
featureEnable: state.openDirectionValue.value,
|
||||
token: getTokenList,
|
||||
needAuthor: 1,
|
||||
publicKey: getPublicKeyList,
|
||||
privateKey: getPrivateKeyList);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
void onReady() {
|
||||
// TODO: implement onReady
|
||||
super.onReady();
|
||||
print("onReady()");
|
||||
|
||||
_initReplySubscription();
|
||||
}
|
||||
|
||||
@override
|
||||
void onInit() {
|
||||
// TODO: implement onInit
|
||||
super.onInit();
|
||||
print("onInit()");
|
||||
|
||||
_readSupportFunctionsNoParameters();
|
||||
}
|
||||
|
||||
@override
|
||||
void onClose() {
|
||||
// TODO: implement onClose
|
||||
super.onClose();
|
||||
_replySubscription.cancel();
|
||||
}
|
||||
|
||||
}
|
||||
@ -1,8 +1,10 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
||||
import 'package:get/get.dart';
|
||||
|
||||
import '../../../../app_settings/app_colors.dart';
|
||||
import '../../../../tools/titleAppBar.dart';
|
||||
import 'openDoorDirection_logic.dart';
|
||||
|
||||
class OpenDoorDirectionPage extends StatefulWidget {
|
||||
const OpenDoorDirectionPage({Key? key}) : super(key: key);
|
||||
@ -12,9 +14,12 @@ class OpenDoorDirectionPage extends StatefulWidget {
|
||||
}
|
||||
|
||||
class _OpenDoorDirectionPageState extends State<OpenDoorDirectionPage> {
|
||||
bool isCheck = false;
|
||||
int selectIndex = 0;
|
||||
int _selectGroupValue = 1; //默认选中的单选框的值
|
||||
final logic = Get.put(OpenDoorDirectionLogic());
|
||||
final state = Get.find<OpenDoorDirectionLogic>().state;
|
||||
|
||||
// bool isCheck = false;
|
||||
// int selectIndex = 0;
|
||||
// int _selectGroupValue = 1; //默认选中的单选框的值
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
@ -64,7 +69,7 @@ class _OpenDoorDirectionPageState extends State<OpenDoorDirectionPage> {
|
||||
SizedBox(
|
||||
width: 60.w,
|
||||
),
|
||||
_colorfulCheckBox(1),
|
||||
Obx(() => _colorfulCheckBox(1)),
|
||||
Text(
|
||||
"左开",
|
||||
style: TextStyle(fontSize: 24.sp),
|
||||
@ -72,7 +77,7 @@ class _OpenDoorDirectionPageState extends State<OpenDoorDirectionPage> {
|
||||
SizedBox(
|
||||
width: 200.w,
|
||||
),
|
||||
_colorfulCheckBox(2),
|
||||
Obx(() => _colorfulCheckBox(2)),
|
||||
Text(
|
||||
'右开',
|
||||
style: TextStyle(fontSize: 24.sp),
|
||||
@ -85,12 +90,13 @@ class _OpenDoorDirectionPageState extends State<OpenDoorDirectionPage> {
|
||||
return Radio(
|
||||
value: selectIndex,
|
||||
onChanged: (value) {
|
||||
// print(value);
|
||||
_selectGroupValue = value;
|
||||
|
||||
setState(() {});
|
||||
print("selectIndex:$selectIndex valuevaluevaluevalue:$value");
|
||||
// _selectGroupValue = value;
|
||||
state.openDirectionValue.value = value;
|
||||
print("state.openDirectionValue.value:${state.openDirectionValue.value}");
|
||||
logic.sendOpenDoorDirection();
|
||||
},
|
||||
groupValue: _selectGroupValue,
|
||||
groupValue: state.openDirectionValue.value,
|
||||
activeColor: AppColors.mainColor,
|
||||
);
|
||||
}
|
||||
|
||||
@ -0,0 +1,18 @@
|
||||
|
||||
|
||||
import 'package:get/get.dart';
|
||||
import '../lockSet/lockSetInfo_entity.dart';
|
||||
|
||||
class OpenDoorDirectionState {
|
||||
|
||||
var lockSetInfoData = LockSetInfoData().obs;
|
||||
var openDirectionValue = 1.obs;
|
||||
|
||||
OpenDoorDirectionState() {
|
||||
var map = Get.arguments;
|
||||
lockSetInfoData.value = map["lockSetInfoData"];
|
||||
|
||||
openDirectionValue.value = lockSetInfoData.value.lockSettingInfo!.openDirectionValue!;
|
||||
}
|
||||
|
||||
}
|
||||
@ -4,6 +4,7 @@ import 'dart:convert';
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_easyloading/flutter_easyloading.dart';
|
||||
import 'package:flutter_reactive_ble/flutter_reactive_ble.dart';
|
||||
import 'package:permission_handler/permission_handler.dart';
|
||||
import 'package:star_lock/blue/io_protocol/io_editUser.dart';
|
||||
@ -15,6 +16,7 @@ import 'package:star_lock/tools/toast.dart';
|
||||
import '../../../blue/blue_manage.dart';
|
||||
import '../../../blue/io_protocol/io_getStarLockStatusInfo.dart';
|
||||
import '../../../blue/io_protocol/io_openLock.dart';
|
||||
import '../../../blue/io_protocol/io_referEventRecordTime.dart';
|
||||
import '../../../blue/io_reply.dart';
|
||||
import '../../../blue/io_tool/io_manager.dart';
|
||||
import '../../../blue/io_tool/io_tool.dart';
|
||||
@ -26,6 +28,8 @@ import '../../../network/api_repository.dart';
|
||||
import '../../../tools/baseGetXController.dart';
|
||||
import '../../../tools/eventBusEventManage.dart';
|
||||
import '../../../tools/storage.dart';
|
||||
import '../electronicKey/electronicKeyDetail/keyOperationRecordEntity.dart';
|
||||
import '../lockOperatingRecord/lockOperatingRecordGetLastRecordTime_entity.dart';
|
||||
import 'lockDetail_state.dart';
|
||||
|
||||
class LockDetailLogic extends BaseGetXController{
|
||||
@ -54,6 +58,11 @@ class LockDetailLogic extends BaseGetXController{
|
||||
if(reply is GetStarLockStatuInfoReply){
|
||||
_replyGetStarLockStatusInfo(reply);
|
||||
}
|
||||
|
||||
// 开完锁之后上传记录
|
||||
if(reply is SenderReferEventRecordTimeReply) {
|
||||
_replyReferEventRecordTime(reply);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@ -80,6 +89,7 @@ class LockDetailLogic extends BaseGetXController{
|
||||
case 0x00:
|
||||
//成功
|
||||
print("${reply.commandType}数据解析成功");
|
||||
getLockRecordLastUploadDataTime();
|
||||
state.lockState.value = 2;
|
||||
state.animationController.reset();
|
||||
state.animationController.forward();
|
||||
@ -335,6 +345,64 @@ class LockDetailLogic extends BaseGetXController{
|
||||
}
|
||||
}
|
||||
|
||||
// 根据时间查解析数据
|
||||
Future<void> _replyReferEventRecordTime(Reply reply) async {
|
||||
int status = reply.data[2];
|
||||
switch(status){
|
||||
case 0x00:
|
||||
//成功
|
||||
print("${reply.commandType}数据解析成功");
|
||||
if(reply.data[5] > 0){
|
||||
reply.data.removeRange(0, 6);
|
||||
// 把得到的数据按8位分割成数组 然后塞进一个新的数组里面
|
||||
var getList = splitList(reply.data, 8);
|
||||
var uploadList = [];
|
||||
for(int i = 0; i<getList.length; i++){
|
||||
var indexList = getList[i];
|
||||
var indexMap = {};
|
||||
indexMap["seq"] = indexList[0].toString();
|
||||
indexMap["user"] = indexList[3].toString();
|
||||
indexMap["pwd"] = indexList[2].toString();
|
||||
indexMap["success"] = "1";
|
||||
indexMap["type"] = indexList[1].toString();
|
||||
|
||||
int value = ((0xff & indexList[(4)]) << 24 |
|
||||
(0xff & indexList[5]) << 16 |
|
||||
(0xff & indexList[6]) << 8 |
|
||||
(0xFF & indexList[7]));
|
||||
// indexMap["date"] = DateTool().dateToYMDHNSString("$value");
|
||||
// print("value:${DateTool().dateToYMDHNSString("$value")}");
|
||||
|
||||
indexMap["date"] = "${value*1000}";
|
||||
uploadList.add(indexMap);
|
||||
}
|
||||
lockRecordUploadData(uploadList);
|
||||
// print("reply.data:${reply.data} getList:$getList}");
|
||||
}
|
||||
break;
|
||||
case 0x06:
|
||||
//无权限
|
||||
print("${reply.commandType}需要鉴权");
|
||||
|
||||
break;
|
||||
case 0x07:
|
||||
//无权限
|
||||
print("${reply.commandType}用户无权限");
|
||||
|
||||
break;
|
||||
case 0x09:
|
||||
// 权限校验错误
|
||||
print("${reply.commandType}权限校验错误");
|
||||
|
||||
break;
|
||||
default:
|
||||
//失败
|
||||
print("${reply.commandType}失败");
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// 点击开门事件
|
||||
Future<void> openDoorAction() async {
|
||||
// if(BlueManage().connectDeviceMacAddress.isEmpty){
|
||||
@ -431,6 +499,34 @@ class LockDetailLogic extends BaseGetXController{
|
||||
}, isShowLoading: false);
|
||||
}
|
||||
|
||||
// 查询事件记录(时间查询)
|
||||
Future<void> senderReferEventRecordTime(int time) async {
|
||||
BlueManage().judgeReconnect(BlueManage().connectDeviceMacAddress, BlueManage().connectDeviceName, (DeviceConnectionState state) async {
|
||||
if (state == DeviceConnectionState.connected) {
|
||||
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.senderReferEventRecordTimeCommand(
|
||||
keyID:BlueManage().connectDeviceName,
|
||||
userID:await Storage.getUid(),
|
||||
logsCount:20,
|
||||
// time:DateTime.now().millisecondsSinceEpoch~/1000,
|
||||
time: time,
|
||||
token:getTokenList,
|
||||
needAuthor:1,
|
||||
publicKey:getPublicKeyList,
|
||||
privateKey:getPrivateKeyList,
|
||||
);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
void startScanAction(){
|
||||
BlueManage().startScan(true, (v){
|
||||
print("startScanAllDevice:${v}");
|
||||
@ -467,6 +563,26 @@ class LockDetailLogic extends BaseGetXController{
|
||||
|
||||
}
|
||||
|
||||
// 查询锁记录最后时间
|
||||
void getLockRecordLastUploadDataTime() async {
|
||||
LockOperatingRecordGetLastRecordTimeEntity entity =
|
||||
await ApiRepository.to.getLockRecordLastUploadDataTime(lockId: state.keyInfos.value.lockId.toString());
|
||||
if (entity.errorCode!.codeIsSuccessful) {
|
||||
senderReferEventRecordTime(entity.data!.operateDate!~/1000);
|
||||
}
|
||||
}
|
||||
|
||||
// 操作记录上传
|
||||
void lockRecordUploadData(List list) async {
|
||||
KeyOperationRecordEntity entity =
|
||||
await ApiRepository.to.lockRecordUploadData(
|
||||
lockId: state.keyInfos.value.lockId.toString(),
|
||||
records: list);
|
||||
if (entity.errorCode!.codeIsSuccessful) {
|
||||
// mockNetworkDataRequest();
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
void onReady() {
|
||||
// TODO: implement onReady
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
||||
import 'package:get/get.dart';
|
||||
@ -5,6 +6,7 @@ import 'package:star_lock/main/lockDetail/electronicKey/electronicKeyDetail/keyO
|
||||
|
||||
import '../../../appRouters.dart';
|
||||
import '../../../app_settings/app_colors.dart';
|
||||
import '../../../tools/custom_bottom_sheet.dart';
|
||||
import '../../../tools/jh_pop_menus.dart';
|
||||
import '../../../tools/noData.dart';
|
||||
import '../../../tools/storage.dart';
|
||||
@ -44,19 +46,21 @@ class _LockOperatingRecordPageState extends State<LockOperatingRecordPage> {
|
||||
onPressed: () async {
|
||||
var isDemoMode = await Storage.getBool(ifIsDemoModeOrNot);
|
||||
if(isDemoMode == false){
|
||||
JhPopMenus.showLinePop(context, clickCallback: (index, selText) {
|
||||
print('选中index: $index');
|
||||
print('选中text: $selText');
|
||||
if (index == 0) {
|
||||
logic.mockNetworkDataRequest();
|
||||
} else if (index == 1) {
|
||||
logic.clearOperationRecordRequest();
|
||||
}
|
||||
}, listData: [
|
||||
{'text': '读取记录'},
|
||||
{'text': '清空记录'},
|
||||
{'text': '导出记录'},
|
||||
]);
|
||||
// JhPopMenus.showLinePop(context, clickCallback: (index, selText) {
|
||||
// print('选中index: $index');
|
||||
// print('选中text: $selText');
|
||||
// if (index == 0) {
|
||||
// logic.mockNetworkDataRequest();
|
||||
// } else if (index == 1) {
|
||||
// logic.clearOperationRecordRequest();
|
||||
// }
|
||||
// }, listData: [
|
||||
// {'text': '读取记录'},
|
||||
// {'text': '清空记录'},
|
||||
// {'text': '导出记录'},
|
||||
// ]);
|
||||
|
||||
_openModalBottomSheet();
|
||||
}else{
|
||||
// Get.toNamed(Routers.seletLockTypePage);
|
||||
Toast.show(msg: "演示模式");
|
||||
@ -77,7 +81,7 @@ class _LockOperatingRecordPageState extends State<LockOperatingRecordPage> {
|
||||
),
|
||||
_searchWidget(),
|
||||
SizedBox(
|
||||
height: 10.h,
|
||||
height: 10.h
|
||||
),
|
||||
Expanded(child: _buildMainUI()),
|
||||
],
|
||||
@ -128,7 +132,6 @@ class _LockOperatingRecordPageState extends State<LockOperatingRecordPage> {
|
||||
int? operateDate = dataItem.operateDate;
|
||||
DateTime dateStr = DateTime.fromMillisecondsSinceEpoch(operateDate!);
|
||||
String operateDateStr = '${dateStr.toLocal().toString().substring(0, 16)} ';
|
||||
|
||||
return _operatingRecordItem(getTypeIcon(dataItem.recordType!), dataItem.recordTypeName!, operateDateStr, () {
|
||||
|
||||
});
|
||||
@ -238,4 +241,26 @@ class _LockOperatingRecordPageState extends State<LockOperatingRecordPage> {
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Future _openModalBottomSheet() async {
|
||||
showModalBottomSheet(
|
||||
context: context,
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadiusDirectional.circular(10)),
|
||||
builder: (BuildContext context) {
|
||||
return AlertBottomWidget(
|
||||
topTitle: '',
|
||||
items: const ['读取记录', '清空记录', '导出记录'],
|
||||
chooseCallback: (value) {
|
||||
int getSelectIndex = value;
|
||||
if (getSelectIndex == 0) {
|
||||
logic.mockNetworkDataRequest();
|
||||
} else if (getSelectIndex == 1) {
|
||||
logic.clearOperationRecordRequest();
|
||||
}
|
||||
},
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -29,18 +29,6 @@ class _LockListPageState extends State<LockListPage> {
|
||||
}
|
||||
groupDataList.addAll(widget.lockListInfoGroupEntity.groupList as Iterable<GroupList>);
|
||||
|
||||
// return ListView.builder(
|
||||
// itemCount: dataList.length,
|
||||
// itemBuilder: (c, index) {
|
||||
// GroupList keyInfo = dataList[index];
|
||||
// return lockInfoListItem('images/icon_lock.png', keyInfo.groupName, () {
|
||||
// // Get.toNamed(Routers.lockDetailMainPage, arguments: {
|
||||
// // "lockMainEntity": widget.lockMainEntity,
|
||||
// // "keyInfo": keyInfo
|
||||
// // });
|
||||
// });
|
||||
// });
|
||||
|
||||
return ListView.separated(
|
||||
itemCount: groupDataList.length,
|
||||
itemBuilder: (context, index) {
|
||||
@ -48,6 +36,7 @@ class _LockListPageState extends State<LockListPage> {
|
||||
return _buildLockExpandedList(context, index, itemData);
|
||||
},
|
||||
shrinkWrap: true,
|
||||
physics:const AlwaysScrollableScrollPhysics(),
|
||||
separatorBuilder: (context, index) {
|
||||
return const Divider(
|
||||
height: 1,
|
||||
@ -94,12 +83,18 @@ class _LockListPageState extends State<LockListPage> {
|
||||
child: ListView.separated(
|
||||
itemCount: lockItemList.length,
|
||||
shrinkWrap: true,
|
||||
physics:const NeverScrollableScrollPhysics(),
|
||||
separatorBuilder: (context, index) {
|
||||
return const Divider(height: 1, color: AppColors.greyLineColor);
|
||||
},
|
||||
itemBuilder: (c, index) {
|
||||
LockListInfoItemEntity keyInfo = lockItemList[index];
|
||||
return lockInfoListItem(keyInfo, () {
|
||||
bool isLast = false;
|
||||
if (lockItemList.length == index+1){
|
||||
isLast = true;
|
||||
}
|
||||
// print("lockItemList.length:${lockItemList.length} == ${index+1} $isLast");
|
||||
return lockInfoListItem(keyInfo, isLast, () {
|
||||
Get.toNamed(Routers.lockDetailMainPage, arguments: {
|
||||
// "lockMainEntity": widget.lockMainEntity,
|
||||
"keyInfo": keyInfo
|
||||
@ -109,12 +104,12 @@ class _LockListPageState extends State<LockListPage> {
|
||||
);
|
||||
}
|
||||
|
||||
Widget lockInfoListItem(LockListInfoItemEntity keyInfo, Function() action) {
|
||||
Widget lockInfoListItem(LockListInfoItemEntity keyInfo, bool isLast, Function() action) {
|
||||
return GestureDetector(
|
||||
onTap: action,
|
||||
child: Container(
|
||||
// height: 122.h,
|
||||
margin: EdgeInsets.only(left: 20.w, right: 20.w, top: 20.w),
|
||||
margin: isLast ? EdgeInsets.only(left: 20.w, right: 20.w, top: 20.w, bottom: 20.w) : EdgeInsets.only(left: 20.w, right: 20.w, top: 20.w),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
borderRadius: BorderRadius.circular(20.w),
|
||||
|
||||
@ -20,7 +20,6 @@ import '../../../../translations/trans_lib.dart';
|
||||
import 'lockAddressGaoDe_logic.dart';
|
||||
|
||||
class LockAddressGaoDePage extends StatefulWidget {
|
||||
|
||||
const LockAddressGaoDePage({Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
@ -141,7 +140,7 @@ class _LockAddressGaoDePageState extends State<LockAddressGaoDePage>{
|
||||
height: 1.sw/5*4,
|
||||
width: 1.sw,
|
||||
child:
|
||||
(addressInfo!["address"].toString().isNotEmpty) ?
|
||||
(addressInfo!["address"].toString().isNotEmpty) ?
|
||||
AMapWidget(
|
||||
apiKey: amapApiKeys,
|
||||
// 初始化地图中心
|
||||
|
||||
@ -1,7 +1,5 @@
|
||||
|
||||
import 'dart:async';
|
||||
import 'dart:convert';
|
||||
import 'dart:math';
|
||||
|
||||
import 'package:flutter_reactive_ble/flutter_reactive_ble.dart';
|
||||
import 'package:get/get.dart';
|
||||
@ -9,22 +7,18 @@ import 'package:get/get.dart';
|
||||
import '../../../appRouters.dart';
|
||||
import '../../../blue/blue_manage.dart';
|
||||
import '../../../blue/io_protocol/io_addUser.dart';
|
||||
import '../../../blue/io_protocol/io_getLockStatu.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_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/dateTool.dart';
|
||||
import '../../../tools/eventBusEventManage.dart';
|
||||
import '../../../tools/storage.dart';
|
||||
import 'saveLock_state.dart';
|
||||
|
||||
class SaveLockLogic extends BaseGetXController {
|
||||
|
||||
final SaveLockState state = SaveLockState();
|
||||
|
||||
// 获取解析后的数据
|
||||
@ -39,7 +33,6 @@ class SaveLockLogic extends BaseGetXController {
|
||||
if(reply is GetStarLockStatuInfoReply) {
|
||||
_replyGetStarLockStatusInfo(reply);
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
@ -193,9 +186,15 @@ class SaveLockLogic extends BaseGetXController {
|
||||
state.lockInfo["indate"] = indateValue*1000;
|
||||
// print("indate:$indate indateValue:$indateValue");
|
||||
|
||||
var index = 153;
|
||||
// mac地址
|
||||
var macAddress = reply.data.sublist(153, 173);
|
||||
var macAddressStr = utf8String(macAddress);
|
||||
state.lockInfo["mac"] = macAddressStr;
|
||||
print("macAddress:$macAddress macAddressStr:$macAddressStr");
|
||||
|
||||
var index = 173;
|
||||
// 锁特征值字符串长度
|
||||
var featureValueLength = reply.data[153];
|
||||
var featureValueLength = reply.data[173];
|
||||
// 锁特征值说明(本机能支持的功能)
|
||||
// 获取到锁给的字符数组
|
||||
var featureValue = reply.data.sublist(index+1, index + featureValueLength+1);
|
||||
|
||||
@ -42,7 +42,7 @@ class SafeVerifyState {
|
||||
///初始化本地数据
|
||||
void initLoginData() async {
|
||||
final data = await Storage.getString('userLoginData');
|
||||
print("getLoginData:$data");
|
||||
// print("getLoginData:$data");
|
||||
if (data != null && data.isNotEmpty) {
|
||||
loginData.value = LoginData.fromJson(jsonDecode(data));
|
||||
|
||||
|
||||
@ -19,7 +19,7 @@ class StarLockMineState {
|
||||
///初始化本地数据
|
||||
void initLoginData() async {
|
||||
final data = await Storage.getString('userLoginData');
|
||||
print("getLoginData:$data");
|
||||
// print("getLoginData:$data");
|
||||
if (data != null && data.isNotEmpty) {
|
||||
loginData.value = LoginData.fromJson(jsonDecode(data));
|
||||
}
|
||||
|
||||
@ -44,7 +44,7 @@ class PersonInfoEditAccountState {
|
||||
///初始化本地数据
|
||||
void initLoginData() async {
|
||||
final data = await Storage.getString('userLoginData');
|
||||
print("getLoginData:$data");
|
||||
// print("getLoginData:$data");
|
||||
if (data != null && data.isNotEmpty) {
|
||||
loginData.value = LoginData.fromJson(jsonDecode(data));
|
||||
}
|
||||
|
||||
@ -37,15 +37,15 @@ class _APPUnlockNeedMobileNetworkingLockPageState extends State<APPUnlockNeedMob
|
||||
barTitle: TranslationLoader
|
||||
.lanKeys!.appUnlockRequiresMobilePhoneAccessToTheLock!.tr,
|
||||
haveBack: true,
|
||||
actionsList: [
|
||||
IconButton(
|
||||
onPressed: () {},
|
||||
icon: Image.asset(
|
||||
"images/icon_bar_search.png",
|
||||
width: 30.w,
|
||||
height: 30.w,
|
||||
))
|
||||
],
|
||||
// actionsList: [
|
||||
// IconButton(
|
||||
// onPressed: () {},
|
||||
// icon: Image.asset(
|
||||
// "images/icon_bar_search.png",
|
||||
// width: 30.w,
|
||||
// height: 30.w,
|
||||
// ))
|
||||
// ],
|
||||
backgroundColor: AppColors.mainColor),
|
||||
body: Column(
|
||||
children: [
|
||||
@ -99,11 +99,11 @@ class _APPUnlockNeedMobileNetworkingLockPageState extends State<APPUnlockNeedMob
|
||||
itemCount: state.lockItemList.value.length,
|
||||
itemBuilder: (c, index) {
|
||||
LockItemData itemData = state.lockItemList.value[index];
|
||||
if(state.isCheckAll.value == true){
|
||||
itemData.isCheck = true;
|
||||
}else{
|
||||
itemData.isCheck = false;
|
||||
}
|
||||
// if(state.isCheckAll.value == true){
|
||||
// itemData.isCheck = true;
|
||||
// }else{
|
||||
// itemData.isCheck = false;
|
||||
// }
|
||||
return _gatewatListItem(itemData);
|
||||
})),
|
||||
),
|
||||
@ -133,6 +133,12 @@ class _APPUnlockNeedMobileNetworkingLockPageState extends State<APPUnlockNeedMob
|
||||
} else {
|
||||
state.selectLockIdList.remove(itemData.lockId);
|
||||
}
|
||||
|
||||
if(state.selectLockIdList.length == state.lockItemList.length){
|
||||
state.isCheckAll.value = true;
|
||||
}else{
|
||||
state.isCheckAll.value = false;
|
||||
}
|
||||
});
|
||||
},
|
||||
child: Container(
|
||||
|
||||
@ -1,109 +0,0 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:star_lock/main/lockDetail/electronicKey/massSendElectronicKey/massSendLockGroupList/massSendLockGroupListEntity.dart';
|
||||
import 'package:star_lock/tools/noData.dart';
|
||||
import 'package:star_lock/tools/submitBtn.dart';
|
||||
|
||||
import '../../../../../app_settings/app_colors.dart';
|
||||
import '../../../../../tools/titleAppBar.dart';
|
||||
import '../../../../../translations/trans_lib.dart';
|
||||
|
||||
class GroupAddLockPage extends StatefulWidget {
|
||||
const GroupAddLockPage({Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
State<GroupAddLockPage> createState() => _GroupAddLockPageState();
|
||||
}
|
||||
|
||||
class _GroupAddLockPageState extends State<GroupAddLockPage> {
|
||||
List<LockListItem> lockList = [];
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
dynamic obj = ModalRoute.of(context)?.settings.arguments;
|
||||
if (obj != null && (obj["lockList"] != null)) {
|
||||
lockList = obj["lockList"];
|
||||
}
|
||||
|
||||
return Scaffold(
|
||||
backgroundColor: AppColors.mainBackgroundColor,
|
||||
appBar: TitleAppBar(
|
||||
barTitle: TranslationLoader.lanKeys!.lock!.tr,
|
||||
haveBack: true,
|
||||
actionsList: [
|
||||
IconButton(
|
||||
icon: Image.asset(
|
||||
'images/icon_bar_more.png',
|
||||
height: 30.h,
|
||||
width: 10.w,
|
||||
),
|
||||
onPressed: () {
|
||||
// 处理操作按钮的点击事件-添加锁分组
|
||||
},
|
||||
),
|
||||
],
|
||||
backgroundColor: AppColors.mainColor),
|
||||
body: lockList.isNotEmpty
|
||||
? ListView.separated(
|
||||
itemBuilder: (context, index) {
|
||||
LockListItem itemData = lockList[index];
|
||||
return _listItemView(itemData);
|
||||
},
|
||||
itemCount: lockList.length,
|
||||
separatorBuilder: (BuildContext context, int index) {
|
||||
return Divider(
|
||||
height: 1.h,
|
||||
color: AppColors.greyLineColor,
|
||||
);
|
||||
},
|
||||
)
|
||||
: Stack(
|
||||
alignment: Alignment.center,
|
||||
children: [
|
||||
Positioned(
|
||||
bottom: 350.h,
|
||||
left: (ScreenUtil().screenWidth - 200.w) / 2,
|
||||
width: 200.w,
|
||||
child: SubmitBtn(
|
||||
btnName: '添加',
|
||||
onClick: () {
|
||||
//选择要添加到分组的锁
|
||||
},
|
||||
)),
|
||||
const NoData(),
|
||||
],
|
||||
));
|
||||
}
|
||||
|
||||
Widget _listItemView(LockListItem itemData) {
|
||||
return GestureDetector(
|
||||
child: Container(
|
||||
color: Colors.white,
|
||||
height: 80.h,
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: [
|
||||
SizedBox(
|
||||
width: 20.w,
|
||||
),
|
||||
Image.asset(
|
||||
'images/icon_lockGroup_item.png',
|
||||
width: 36,
|
||||
height: 36,
|
||||
fit: BoxFit.fill,
|
||||
),
|
||||
SizedBox(
|
||||
width: 10.w,
|
||||
),
|
||||
Text(
|
||||
itemData.lockAlias ?? '',
|
||||
style: TextStyle(fontSize: 24.sp),
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
onTap: () {},
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,37 @@
|
||||
|
||||
import 'package:get/get.dart';
|
||||
|
||||
import '../../../../network/api_repository.dart';
|
||||
import '../../../../tools/baseGetXController.dart';
|
||||
import '../../../../tools/eventBusEventManage.dart';
|
||||
import '../../../../tools/toast.dart';
|
||||
import 'groupEditLock_state.dart';
|
||||
|
||||
class GroupEditLockLogic extends BaseGetXController {
|
||||
final GroupEditLockState state = GroupEditLockState();
|
||||
|
||||
//锁分组里面添加锁
|
||||
Future<void> lockGroupAddLock(List lockId) async {
|
||||
var entity = await ApiRepository.to.lockGroupAddLock(
|
||||
lockIds: lockId,
|
||||
groupId: state.seletGroupListItem.keyGroupId!);
|
||||
if (entity.errorCode!.codeIsSuccessful) {
|
||||
Toast.show(msg: "添加成功");
|
||||
eventBus.fire(LockGroupEditGroupLockRefreshEvent());
|
||||
eventBus.fire(RefreshLockListInfoDataEvent());
|
||||
Get.close(2);
|
||||
}
|
||||
}
|
||||
|
||||
//锁分组里面添加锁
|
||||
Future<void> lockGroupDeletLock(List lockId) async {
|
||||
var entity = await ApiRepository.to.lockGroupDeletLock(lockIds: lockId);
|
||||
if (entity.errorCode!.codeIsSuccessful) {
|
||||
Toast.show(msg: "删除成功");
|
||||
eventBus.fire(LockGroupEditGroupLockRefreshEvent());
|
||||
eventBus.fire(RefreshLockListInfoDataEvent());
|
||||
Get.close(2);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,117 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:star_lock/main/lockDetail/electronicKey/massSendElectronicKey/massSendLockGroupList/massSendLockGroupListEntity.dart';
|
||||
import 'package:star_lock/tools/noData.dart';
|
||||
|
||||
import '../../../../../../app_settings/app_colors.dart';
|
||||
import '../../../../../../tools/titleAppBar.dart';
|
||||
import '../../../../../../translations/trans_lib.dart';
|
||||
import '../../../../tools/submitBtn.dart';
|
||||
import 'groupEditLock_logic.dart';
|
||||
|
||||
class GroupEditLockPage extends StatefulWidget {
|
||||
const GroupEditLockPage({Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
State<GroupEditLockPage> createState() => _GroupEditLockPageState();
|
||||
}
|
||||
|
||||
class _GroupEditLockPageState extends State<GroupEditLockPage> {
|
||||
final logic = Get.put(GroupEditLockLogic());
|
||||
final state = Get.find<GroupEditLockLogic>().state;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
backgroundColor: AppColors.mainBackgroundColor,
|
||||
appBar: TitleAppBar(
|
||||
barTitle: state.type == 0 ? TranslationLoader.lanKeys!.add!.tr : TranslationLoader.lanKeys!.delete!.tr,
|
||||
haveBack: true,
|
||||
backgroundColor: AppColors.mainColor),
|
||||
body: Column(
|
||||
children: [
|
||||
Container(
|
||||
margin: EdgeInsets.all(15.w),
|
||||
child: Row(
|
||||
children: [
|
||||
Text("选择要加入分组的锁", style: TextStyle(fontSize: 25.sp)),
|
||||
],
|
||||
),
|
||||
),
|
||||
Expanded(child: _buildMainUI()),
|
||||
SubmitBtn(btnName: TranslationLoader.lanKeys!.send!.tr, onClick: () async {
|
||||
var idList = [];
|
||||
for(int i = 0; i<state.lockList.length; i++){
|
||||
LockListItem lockListItem = state.lockList[i];
|
||||
if(lockListItem.isChecked == true){
|
||||
idList.add(lockListItem.lockId);
|
||||
}
|
||||
}
|
||||
if(state.type == 0){
|
||||
// 添加
|
||||
logic.lockGroupAddLock(idList);
|
||||
}else if(state.type == 1){
|
||||
// 删除
|
||||
logic.lockGroupDeletLock(idList);
|
||||
}
|
||||
}),
|
||||
SizedBox(height: 20.h)
|
||||
],
|
||||
));
|
||||
}
|
||||
|
||||
Widget _buildMainUI(){
|
||||
return state.lockList.isNotEmpty
|
||||
? ListView.separated(
|
||||
itemBuilder: (context, index) {
|
||||
LockListItem itemData = state.lockList[index];
|
||||
return _listItemView(itemData);
|
||||
},
|
||||
itemCount: state.lockList.length,
|
||||
separatorBuilder: (BuildContext context, int index) {
|
||||
return Divider(
|
||||
height: 1.h,
|
||||
color: AppColors.greyLineColor,
|
||||
);
|
||||
},
|
||||
) : const NoData();
|
||||
}
|
||||
|
||||
Widget _listItemView(LockListItem itemData) {
|
||||
return Container(
|
||||
color: Colors.white,
|
||||
height: 80.h,
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: [
|
||||
SizedBox(width: 20.w,),
|
||||
Image.asset('images/icon_lockGroup_item.png', width: 36, height: 36, fit: BoxFit.fill,),
|
||||
SizedBox(width: 10.w,),
|
||||
Text(
|
||||
itemData.lockAlias ?? '',
|
||||
style: TextStyle(fontSize: 24.sp),
|
||||
),
|
||||
Expanded(child: SizedBox(width: 10.w)),
|
||||
GestureDetector(
|
||||
child: Image.asset(
|
||||
itemData.isChecked
|
||||
? 'images/icon_round_selet.png'
|
||||
: 'images/icon_round_unSelet.png',
|
||||
width: 35.w,
|
||||
height: 35.w,
|
||||
),
|
||||
onTap: (){
|
||||
setState(() {
|
||||
itemData.isChecked = !itemData.isChecked;
|
||||
});
|
||||
},
|
||||
),
|
||||
SizedBox(width: 30.w)
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,26 @@
|
||||
|
||||
import 'package:get/get.dart';
|
||||
import '../../../../main/lockDetail/electronicKey/massSendElectronicKey/massSendLockGroupList/massSendLockGroupListEntity.dart';
|
||||
|
||||
class GroupEditLockState {
|
||||
var lockList = <LockListItem>[];
|
||||
var type = 0;// 0添加 1删除
|
||||
var seletGroupListItem = GroupListItem();
|
||||
var ungrouped = GroupListItem();
|
||||
GroupEditLockState() {
|
||||
Map map = Get.arguments;
|
||||
type = map["type"];
|
||||
seletGroupListItem = map["groupListItem"];
|
||||
ungrouped = map["ungrouped"];
|
||||
if(type == 0){
|
||||
lockList = ungrouped.lockList!;
|
||||
}else{
|
||||
lockList = seletGroupListItem.lockList!;
|
||||
}
|
||||
|
||||
for(int i = 0; i<lockList.length; i++){
|
||||
LockListItem lockListItem = lockList[i];
|
||||
lockListItem.isChecked = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -5,9 +5,12 @@ import 'package:star_lock/main/lockDetail/electronicKey/massSendElectronicKey/ma
|
||||
import 'package:star_lock/tools/noData.dart';
|
||||
import 'package:star_lock/tools/submitBtn.dart';
|
||||
|
||||
import '../../../../../app_settings/app_colors.dart';
|
||||
import '../../../../../tools/titleAppBar.dart';
|
||||
import '../../../../../translations/trans_lib.dart';
|
||||
import '../../../../../../app_settings/app_colors.dart';
|
||||
import '../../../../../../tools/titleAppBar.dart';
|
||||
import '../../../../../../translations/trans_lib.dart';
|
||||
import '../../../../appRouters.dart';
|
||||
import '../../../../tools/custom_bottom_sheet.dart';
|
||||
import '../../../../tools/jh_pop_menus.dart';
|
||||
|
||||
class LockItemListPage extends StatefulWidget {
|
||||
const LockItemListPage({Key? key}) : super(key: key);
|
||||
@ -18,19 +21,21 @@ class LockItemListPage extends StatefulWidget {
|
||||
|
||||
class _LockItemListPageState extends State<LockItemListPage> {
|
||||
List<LockListItem> lockList = [];
|
||||
var ungrouped = GroupListItem();
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
dynamic obj = ModalRoute.of(context)?.settings.arguments;
|
||||
if (obj != null && (obj["lockList"] != null)) {
|
||||
lockList = obj["lockList"];
|
||||
}
|
||||
Map map = Get.arguments;
|
||||
GroupListItem groupListItem = map["groupListItem"];
|
||||
lockList = groupListItem.lockList!;
|
||||
ungrouped = map["ungrouped"];
|
||||
|
||||
return Scaffold(
|
||||
backgroundColor: AppColors.mainBackgroundColor,
|
||||
appBar: TitleAppBar(
|
||||
barTitle: TranslationLoader.lanKeys!.lock!.tr,
|
||||
haveBack: true,
|
||||
actionsList: [
|
||||
actionsList: (lockList.isNotEmpty && groupListItem.groupType == 0) ? [
|
||||
IconButton(
|
||||
icon: Image.asset(
|
||||
'images/icon_bar_more.png',
|
||||
@ -38,10 +43,26 @@ class _LockItemListPageState extends State<LockItemListPage> {
|
||||
width: 10.w,
|
||||
),
|
||||
onPressed: () {
|
||||
// 处理操作按钮的点击事件-添加锁分组
|
||||
// 处理操作按钮的点击事件
|
||||
_openModalBottomSheet(groupListItem);
|
||||
// JhPopMenus.showLinePop(context, clickCallback: (index, selText) {
|
||||
// print('选中index: $index');
|
||||
// print('选中text: $selText');
|
||||
// if (index == 0) {
|
||||
// Get.back();
|
||||
// // Get.toNamed(Routers.groupEditLockPage, arguments: {'groupListItem': groupListItem, 'ungrouped': ungrouped, 'type': 0});
|
||||
// Get.toNamed(Routers.groupEditLockPage, arguments: {'groupListItem': groupListItem, 'ungrouped': ungrouped, 'type': 0});
|
||||
// } else if (index == 1) {
|
||||
// Get.back();
|
||||
// Get.toNamed(Routers.groupEditLockPage, arguments: {'groupListItem': groupListItem, 'ungrouped': ungrouped, 'type': 1});
|
||||
// }
|
||||
// }, listData: [
|
||||
// {'text': '添加'},
|
||||
// {'text': '删除'},
|
||||
// ]);
|
||||
},
|
||||
),
|
||||
],
|
||||
] :[],
|
||||
backgroundColor: AppColors.mainColor),
|
||||
body: lockList.isNotEmpty
|
||||
? ListView.separated(
|
||||
@ -68,6 +89,7 @@ class _LockItemListPageState extends State<LockItemListPage> {
|
||||
btnName: '添加',
|
||||
onClick: () {
|
||||
//选择要添加到分组的锁
|
||||
Get.toNamed(Routers.groupEditLockPage, arguments: {'groupListItem': groupListItem, 'ungrouped': ungrouped, 'type': 0});
|
||||
},
|
||||
)),
|
||||
const NoData(),
|
||||
@ -106,4 +128,26 @@ class _LockItemListPageState extends State<LockItemListPage> {
|
||||
onTap: () {},
|
||||
);
|
||||
}
|
||||
|
||||
Future _openModalBottomSheet(GroupListItem groupListItem) async {
|
||||
showModalBottomSheet(
|
||||
context: context,
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadiusDirectional.circular(10)),
|
||||
builder: (BuildContext context) {
|
||||
return AlertBottomWidget(
|
||||
topTitle: '',
|
||||
items: const ['添加', '删除'],
|
||||
chooseCallback: (value) {
|
||||
int getSelectIndex = value;
|
||||
if (getSelectIndex == 0) {
|
||||
Get.toNamed(Routers.groupEditLockPage, arguments: {'groupListItem': groupListItem, 'ungrouped': ungrouped, 'type': 0});
|
||||
} else if (getSelectIndex == 1) {
|
||||
Get.toNamed(Routers.groupEditLockPage, arguments: {'groupListItem': groupListItem, 'ungrouped': ungrouped, 'type': 1});
|
||||
}
|
||||
|
||||
},
|
||||
);
|
||||
});
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,82 @@
|
||||
|
||||
import 'dart:async';
|
||||
|
||||
import '../../../../main/lockDetail/electronicKey/massSendElectronicKey/massSendLockGroupList/massSendLockGroupListEntity.dart';
|
||||
import '../../../../network/api_repository.dart';
|
||||
import '../../../../tools/baseGetXController.dart';
|
||||
import '../../../../tools/eventBusEventManage.dart';
|
||||
import '../../../../tools/toast.dart';
|
||||
import 'lockGroupList_state.dart';
|
||||
|
||||
class LockGroupListLogic extends BaseGetXController {
|
||||
final LockGroupListState state = LockGroupListState();
|
||||
|
||||
//分组列表请求
|
||||
void mockNetworkDataRequest() async {
|
||||
var entity = await ApiRepository.to.lockGroupList('1');
|
||||
if (entity.errorCode!.codeIsSuccessful) {
|
||||
if (entity.data != null) {
|
||||
state.lockNum = 0;
|
||||
state.itemDataList.value = entity.data!.groupList!;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//创建锁分组请求
|
||||
Future<void> addLockGroupRequest() async {
|
||||
MassSendLockGroupListEntity entity =
|
||||
await ApiRepository.to.addLockGroup(state.changeNameController.text, '0');
|
||||
if (entity.errorCode!.codeIsSuccessful) {
|
||||
Toast.show(msg: "创建成功");
|
||||
mockNetworkDataRequest();
|
||||
}
|
||||
}
|
||||
|
||||
//编辑锁名字
|
||||
Future<void> editLockGroupRequest(int groupId) async {
|
||||
var entity = await ApiRepository.to.editLockGroupRequest(groupId:groupId, groupName:state.changeNameController.text);
|
||||
if (entity.errorCode!.codeIsSuccessful) {
|
||||
Toast.show(msg: "编辑成功");
|
||||
mockNetworkDataRequest();
|
||||
}
|
||||
}
|
||||
|
||||
//删除组
|
||||
Future<void> deleteLockGroupRequest(int groupId) async {
|
||||
var entity = await ApiRepository.to.deleteGroup(groupId);
|
||||
if (entity.errorCode!.codeIsSuccessful) {
|
||||
Toast.show(msg: "删除成功");
|
||||
mockNetworkDataRequest();
|
||||
}
|
||||
}
|
||||
|
||||
// 监听修改完详情之后刷新列表
|
||||
late StreamSubscription _teamEvent;
|
||||
void _initRefreshAction() {
|
||||
_teamEvent = eventBus.on<LockGroupEditGroupLockRefreshEvent>().listen((event) {
|
||||
mockNetworkDataRequest();
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
void onReady() {
|
||||
// TODO: implement onReady
|
||||
super.onReady();
|
||||
_initRefreshAction();
|
||||
|
||||
mockNetworkDataRequest();
|
||||
}
|
||||
|
||||
@override
|
||||
void onInit() {
|
||||
// TODO: implement onInit
|
||||
super.onInit();
|
||||
}
|
||||
|
||||
@override
|
||||
void onClose() {
|
||||
// TODO: implement onClose
|
||||
_teamEvent.cancel();
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,217 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:star_lock/main/lockDetail/electronicKey/massSendElectronicKey/massSendLockGroupList/massSendLockGroupListEntity.dart';
|
||||
import 'package:star_lock/tools/showTFView.dart';
|
||||
import 'package:star_lock/tools/toast.dart';
|
||||
|
||||
import '../../../../../../appRouters.dart';
|
||||
import '../../../../../../app_settings/app_colors.dart';
|
||||
import '../../../../../../tools/commonItem.dart';
|
||||
import '../../../../../../tools/titleAppBar.dart';
|
||||
import '../../../../../../translations/trans_lib.dart';
|
||||
import '../../../../tools/left_slide_actions.dart';
|
||||
import '../../../../tools/noData.dart';
|
||||
import '../../../../tools/showIosTipView.dart';
|
||||
import 'lockGroupList_logic.dart';
|
||||
|
||||
class LockGroupListPage extends StatefulWidget {
|
||||
const LockGroupListPage({Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
State<LockGroupListPage> createState() => _LockGroupListPageState();
|
||||
}
|
||||
|
||||
class _LockGroupListPageState extends State<LockGroupListPage> {
|
||||
final logic = Get.put(LockGroupListLogic());
|
||||
final state = Get.find<LockGroupListLogic>().state;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
backgroundColor: AppColors.mainBackgroundColor,
|
||||
appBar: TitleAppBar(
|
||||
barTitle: TranslationLoader.lanKeys!.lockGroup!.tr,
|
||||
haveBack: true,
|
||||
actionsList: [
|
||||
IconButton(
|
||||
icon: Image.asset(
|
||||
'images/icon_add_white.png',
|
||||
width: 36.w,
|
||||
height: 36.w,
|
||||
),
|
||||
onPressed: () {
|
||||
// 处理操作按钮的点击事件-添加锁分组
|
||||
showCupertinoAlertDialog(context, true, 0);
|
||||
},
|
||||
),
|
||||
],
|
||||
backgroundColor: AppColors.mainColor),
|
||||
body: Column(
|
||||
children: [
|
||||
Expanded(child: Obx(() => state.itemDataList.value.isEmpty ? const NoData(): _buildMainUI())),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildMainUI() {
|
||||
for (int i = 0; i < state.itemDataList.value.length; i++) {
|
||||
GroupListItem itemData = state.itemDataList.value[i];
|
||||
state.lockNum += itemData.lockList!.length;
|
||||
}
|
||||
return ListView.separated(
|
||||
itemCount: state.itemDataList.value.length + 1,
|
||||
itemBuilder: (c, index) {
|
||||
if (index == state.itemDataList.value.length) {
|
||||
return Center(
|
||||
child: Column(
|
||||
children: [
|
||||
SizedBox(
|
||||
height: 20.h,
|
||||
),
|
||||
SizedBox(
|
||||
height: 40.h,
|
||||
child: Text(
|
||||
'锁数量:${state.lockNum.toString()}',
|
||||
style: TextStyle(
|
||||
color: AppColors.darkGrayTextColor, fontSize: 20.sp),
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
);
|
||||
} else {
|
||||
GroupListItem itemData = state.itemDataList.value[index];
|
||||
if(itemData.groupType == 0){
|
||||
state.ungrouped = itemData;
|
||||
}
|
||||
if (index < state.itemDataList.value.length) {
|
||||
return LeftSlideActions(
|
||||
key: Key(itemData.keyGroupId!.toString()),
|
||||
actionsWidth: itemData.groupType != 0 ? 200.w : 0,
|
||||
actions: itemData.groupType != 0 ? [
|
||||
_buildEditBtn(itemData),
|
||||
_buildDeleteBtn(itemData),
|
||||
] : [],
|
||||
decoration: const BoxDecoration(
|
||||
borderRadius: BorderRadius.all(Radius.circular(1)),
|
||||
),
|
||||
child: CommonItem(
|
||||
leftTitel:
|
||||
'${itemData.keyGroupName}(${itemData.lockList?.length})',
|
||||
rightTitle: "",
|
||||
allHeight: 70.h,
|
||||
action: () {
|
||||
|
||||
Get.toNamed(Routers.lockItemListPage, arguments: {'groupListItem': itemData, "ungrouped": state.ungrouped});
|
||||
}),
|
||||
);
|
||||
}
|
||||
return const SizedBox.shrink();
|
||||
}
|
||||
},
|
||||
separatorBuilder: (BuildContext context, int index) {
|
||||
return const Divider(
|
||||
height: 1,
|
||||
color: AppColors.greyLineColor,
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
void showCupertinoAlertDialog(BuildContext context, bool isAdd, int groupId) {
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (BuildContext context) {
|
||||
return ShowTFView(
|
||||
title: TranslationLoader.lanKeys!.createNewGroup!.tr,
|
||||
tipTitle: TranslationLoader.lanKeys!.pleaseEnter!.tr,
|
||||
controller: state.changeNameController,
|
||||
sureClick: () {
|
||||
//发送编辑钥匙名称请求
|
||||
if (state.changeNameController.text.isNotEmpty) {
|
||||
if(isAdd == true){
|
||||
logic.addLockGroupRequest();
|
||||
}else{
|
||||
logic.editLockGroupRequest(groupId);
|
||||
}
|
||||
Navigator.pop(context);
|
||||
} else {
|
||||
Toast.show(msg: '请输入分组名称');
|
||||
}
|
||||
},
|
||||
cancelClick: () {
|
||||
Navigator.pop(context);
|
||||
},
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildDeleteBtn(GroupListItem groupListItem) {
|
||||
return GestureDetector(
|
||||
onTap: () {
|
||||
// 省略: 弹出是否删除的确认对话框。
|
||||
showIosTipViewDialog(context, groupListItem);
|
||||
},
|
||||
child: Container(
|
||||
width: 100.w,
|
||||
color: const Color(0xFFF20101),
|
||||
alignment: Alignment.center,
|
||||
child: const Text(
|
||||
'删除',
|
||||
style: TextStyle(
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.w500,
|
||||
color: Colors.white,
|
||||
height: 1,
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildEditBtn(GroupListItem groupListItem) {
|
||||
return GestureDetector(
|
||||
onTap: () {
|
||||
// 编辑
|
||||
state.changeNameController.text = groupListItem.keyGroupName!;
|
||||
showCupertinoAlertDialog(context, false, groupListItem.keyGroupId!);
|
||||
},
|
||||
child: Container(
|
||||
width: 100.w,
|
||||
color: AppColors.mainColor,
|
||||
alignment: Alignment.center,
|
||||
child: const Text(
|
||||
'编辑',
|
||||
style: TextStyle(
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.w500,
|
||||
color: Colors.white,
|
||||
height: 1,
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
void showIosTipViewDialog(BuildContext context, GroupListItem groupListItem) {
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (BuildContext context) {
|
||||
return ShowIosTipView(
|
||||
title: "提示",
|
||||
tipTitle: "确定要删除吗?",
|
||||
sureClick: () {
|
||||
Get.back();
|
||||
logic.deleteLockGroupRequest(groupListItem.keyGroupId!);
|
||||
},
|
||||
cancelClick: () {
|
||||
Get.back();
|
||||
},
|
||||
);
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,13 @@
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
import '../../../../main/lockDetail/electronicKey/massSendElectronicKey/massSendLockGroupList/massSendLockGroupListEntity.dart';
|
||||
|
||||
class LockGroupListState {
|
||||
|
||||
TextEditingController changeNameController = TextEditingController();
|
||||
var itemDataList = <GroupListItem>[].obs;
|
||||
int lockNum = 0;
|
||||
var ungrouped = GroupListItem();
|
||||
|
||||
}
|
||||
@ -1,158 +0,0 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:star_lock/main/lockDetail/electronicKey/massSendElectronicKey/massSendLockGroupList/massSendLockGroupListEntity.dart';
|
||||
import 'package:star_lock/network/api_repository.dart';
|
||||
import 'package:star_lock/tools/baseGetXController.dart';
|
||||
import 'package:star_lock/tools/showTFView.dart';
|
||||
import 'package:star_lock/tools/toast.dart';
|
||||
|
||||
import '../../../../../appRouters.dart';
|
||||
import '../../../../../app_settings/app_colors.dart';
|
||||
import '../../../../../tools/commonItem.dart';
|
||||
import '../../../../../tools/titleAppBar.dart';
|
||||
import '../../../../../translations/trans_lib.dart';
|
||||
|
||||
class LockGroupListPage extends StatefulWidget {
|
||||
const LockGroupListPage({Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
State<LockGroupListPage> createState() => _LockGroupListPageState();
|
||||
}
|
||||
|
||||
class _LockGroupListPageState extends State<LockGroupListPage> {
|
||||
TextEditingController _changeNameController = TextEditingController();
|
||||
List<GroupListItem> itemDataList = [];
|
||||
int lockNum = 0;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
|
||||
mockNetworkDataRequest();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
backgroundColor: AppColors.mainBackgroundColor,
|
||||
appBar: TitleAppBar(
|
||||
barTitle: TranslationLoader.lanKeys!.lockGroup!.tr,
|
||||
haveBack: true,
|
||||
actionsList: [
|
||||
IconButton(
|
||||
icon: Image.asset(
|
||||
'images/icon_add_white.png',
|
||||
width: 36.w,
|
||||
height: 36.w,
|
||||
),
|
||||
onPressed: () {
|
||||
// 处理操作按钮的点击事件-添加锁分组
|
||||
showCupertinoAlertDialog(context);
|
||||
},
|
||||
),
|
||||
],
|
||||
backgroundColor: AppColors.mainColor),
|
||||
body: Column(
|
||||
children: [
|
||||
Expanded(child: _buildMainUI()),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildMainUI() {
|
||||
for (int i = 0; i < itemDataList.length; i++) {
|
||||
GroupListItem itemData = itemDataList[i];
|
||||
lockNum += itemData.lockList!.length;
|
||||
}
|
||||
return ListView.builder(
|
||||
itemCount: itemDataList.length + 1,
|
||||
itemBuilder: (c, index) {
|
||||
if (index == itemDataList.length) {
|
||||
return Center(
|
||||
child: Column(
|
||||
children: [
|
||||
SizedBox(
|
||||
height: 20.h,
|
||||
),
|
||||
SizedBox(
|
||||
height: 40.h,
|
||||
child: Text(
|
||||
'锁数量:${lockNum.toString()}',
|
||||
style: TextStyle(
|
||||
color: AppColors.darkGrayTextColor, fontSize: 20.sp),
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
);
|
||||
} else {
|
||||
GroupListItem itemData = itemDataList[index];
|
||||
|
||||
return CommonItem(
|
||||
leftTitel:
|
||||
'${itemData.keyGroupName}(${itemData.lockList?.length})',
|
||||
rightTitle: "",
|
||||
allHeight: 70.h,
|
||||
isHaveLine: true,
|
||||
action: () {
|
||||
Navigator.pushNamed(context, Routers.lockItemListPage,
|
||||
arguments: {'lockList': itemData.lockList});
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
//分组列表请求
|
||||
Future<List<GroupListItem>> mockNetworkDataRequest() async {
|
||||
MassSendLockGroupListEntity entity =
|
||||
await ApiRepository.to.lockGroupList('1');
|
||||
List<GroupListItem> dataList = [];
|
||||
if (entity.errorCode!.codeIsSuccessful) {
|
||||
if (entity.data != null) {
|
||||
dataList = entity.data!.groupList!;
|
||||
}
|
||||
}
|
||||
setState(() {
|
||||
itemDataList = dataList;
|
||||
});
|
||||
return dataList;
|
||||
}
|
||||
|
||||
//创建锁分组请求
|
||||
Future<void> addLockGroupRequest() async {
|
||||
MassSendLockGroupListEntity entity =
|
||||
await ApiRepository.to.addLockGroup(_changeNameController.text, '0');
|
||||
if (entity.errorCode!.codeIsSuccessful) {
|
||||
Toast.show(msg: "创建成功");
|
||||
mockNetworkDataRequest();
|
||||
setState(() {});
|
||||
}
|
||||
}
|
||||
|
||||
void showCupertinoAlertDialog(BuildContext context) {
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (BuildContext context) {
|
||||
return ShowTFView(
|
||||
title: TranslationLoader.lanKeys!.createNewGroup!.tr,
|
||||
tipTitle: TranslationLoader.lanKeys!.pleaseEnter!.tr,
|
||||
controller: _changeNameController,
|
||||
sureClick: () {
|
||||
//发送编辑钥匙名称请求
|
||||
if (_changeNameController.text.isNotEmpty) {
|
||||
addLockGroupRequest();
|
||||
Navigator.pop(context);
|
||||
} else {
|
||||
Toast.show(msg: '请输入分组名称');
|
||||
}
|
||||
},
|
||||
cancelClick: () {
|
||||
Navigator.pop(context);
|
||||
},
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -47,12 +47,17 @@ abstract class Api {
|
||||
final String updatePasswordKeyURL = '/keyboardPwd/update'; //修改密码详情
|
||||
final String clearOperationRecordURL = '/lockRecords/clear'; //清空操作记录
|
||||
final String addlockGroupURL = '/keyGroup/add'; //创建锁分组
|
||||
final String editlockGroupURL = '/keyGroup/modifyGroupName'; //编辑锁分组
|
||||
final String setlockGroupURL = '/keyGroup/setGroup'; //设置锁分组
|
||||
final String lockGroupListURL = '/authorizedAdmin/listGroup'; //锁分组列表
|
||||
final String lockDeletGroupURL = '/keyGroup/delete'; //删除锁分组
|
||||
final String lockGroupAddLockURL = '/keyGroup/addLockGroup'; //锁分组里面添加锁
|
||||
final String lockGroupDeletLockURL = '/keyGroup/deleteLockGroup'; //锁分组里面删除锁
|
||||
|
||||
final String listLockByGroupURL = '/authorizedAdmin/listLockByGroup'; //获取分组下的锁列表
|
||||
final String setRoomStatusURL = '/lock/updateLockStatus'; //标记房态
|
||||
final String keyGroupListURL = '/keyGroup/list'; //分组列表
|
||||
final String lockListByGroupURL = '/room/listByGroup'; //分组下的锁
|
||||
// final String keyGroupListURL = '/keyGroup/list'; //分组列表
|
||||
// final String lockListByGroupURL = '/room/listByGroup'; //分组下的锁
|
||||
final String getWifiServiceIpURL = '/wifiLock/getWifiServiceIp'; // 获取Wifi锁服务器
|
||||
final String updateLockSettingUrl = '/lockSetting/updateLockSetting'; // 锁设置里面所有的设置
|
||||
|
||||
|
||||
@ -444,6 +444,11 @@ class ApiProvider extends BaseProvider {
|
||||
addlockGroupURL.toUrl,
|
||||
jsonEncode({'groupName': groupName, 'operatorUid': operatorUid}));
|
||||
|
||||
// 编辑锁名字
|
||||
Future<Response> editLockGroupRequest(int groupId, String groupName) => post(
|
||||
editlockGroupURL.toUrl,
|
||||
jsonEncode({'groupId': groupId, 'groupName': groupName}));
|
||||
|
||||
Future<Response> setLockGroup(String lockId, String groupId) => post(
|
||||
setlockGroupURL.toUrl,
|
||||
jsonEncode({'lockId': lockId, 'groupId': groupId}));
|
||||
@ -451,6 +456,28 @@ class ApiProvider extends BaseProvider {
|
||||
Future<Response> lockGroupList(String type) =>
|
||||
post(lockGroupListURL.toUrl, jsonEncode({'type': type}));
|
||||
|
||||
// 删除组
|
||||
Future<Response> deleteGroup(int groupId) => post(
|
||||
lockDeletGroupURL.toUrl,
|
||||
jsonEncode({
|
||||
'groupId': groupId,
|
||||
}));
|
||||
|
||||
// 锁分组里面添加锁
|
||||
Future<Response> lockGroupAddLock(List lockIds, int groupId) => post(
|
||||
lockGroupAddLockURL.toUrl,
|
||||
jsonEncode({
|
||||
'lockId': lockIds,
|
||||
'groupId': groupId,
|
||||
}));
|
||||
|
||||
// 锁分组里面删除锁
|
||||
Future<Response> lockGroupDeletLock(List lockIds) => post(
|
||||
lockGroupDeletLockURL.toUrl,
|
||||
jsonEncode({
|
||||
'lockId': lockIds,
|
||||
}));
|
||||
|
||||
Future<Response> selectLockList() =>
|
||||
post(selectLockListURL.toUrl, jsonEncode({}));
|
||||
|
||||
@ -501,12 +528,12 @@ class ApiProvider extends BaseProvider {
|
||||
// post(updateSettingURL.toUrl,
|
||||
// jsonEncode({'lockId': lockId, 'isOn': isOn, 'type': type}));
|
||||
|
||||
Future<Response> keyGroupList(String type) =>
|
||||
post(keyGroupListURL.toUrl, jsonEncode({'type': type}));
|
||||
|
||||
Future<Response> lockListByGroup(String type, String keyGroupId) => post(
|
||||
lockListByGroupURL.toUrl,
|
||||
jsonEncode({'type': type, 'keyGroupId': keyGroupId}));
|
||||
// Future<Response> keyGroupList(String type) =>
|
||||
// post(keyGroupListURL.toUrl, jsonEncode({'type': type}));
|
||||
//
|
||||
// Future<Response> lockListByGroup(String type, String keyGroupId) => post(
|
||||
// lockListByGroupURL.toUrl,
|
||||
// jsonEncode({'type': type, 'keyGroupId': keyGroupId}));
|
||||
|
||||
/// 锁设置模块
|
||||
// 自动闭锁
|
||||
@ -539,6 +566,16 @@ class ApiProvider extends BaseProvider {
|
||||
'antiPrySwitch': antiPrySwitch,
|
||||
}));
|
||||
|
||||
// 开门方向
|
||||
Future<Response> setOpenDoorDirectionData(
|
||||
int lockId, int openDirectionValue) =>
|
||||
post(
|
||||
updateLockSettingUrl.toUrl,
|
||||
jsonEncode({
|
||||
'lockId': lockId,
|
||||
'openDirectionValue': openDirectionValue,
|
||||
}));
|
||||
|
||||
// 远程开锁
|
||||
Future<Response> remoteUnlockingOpenOrCloseLoadData(int lockId, int remoteUnlock) =>
|
||||
post(
|
||||
|
||||
@ -32,7 +32,7 @@ class BaseProvider extends GetConnect with Api {
|
||||
// print("post: url:${url} body:${body} contentType:${contentType} headers:${headers} query:${query}");
|
||||
if (isUnShowLoading == false) EasyLoading.show();
|
||||
|
||||
print('哈喽请求body体为:${body}');
|
||||
print('星锁请求body体为:${body}');
|
||||
var res = await super.post(url, body,
|
||||
contentType: contentType,
|
||||
headers: headers,
|
||||
|
||||
@ -440,6 +440,15 @@ class ApiRepository {
|
||||
return MassSendLockGroupListEntity.fromJson(res.body);
|
||||
}
|
||||
|
||||
// 编辑锁名字
|
||||
Future<MassSendLockGroupListEntity> editLockGroupRequest({
|
||||
required int groupId,
|
||||
required String groupName
|
||||
}) async {
|
||||
final res = await apiProvider.editLockGroupRequest(groupId, groupName);
|
||||
return MassSendLockGroupListEntity.fromJson(res.body);
|
||||
}
|
||||
|
||||
//设置锁分组
|
||||
Future<MassSendLockGroupListEntity> setLockGroup(
|
||||
String lockId, String groupId) async {
|
||||
@ -453,6 +462,34 @@ class ApiRepository {
|
||||
return MassSendLockGroupListEntity.fromJson(res.body);
|
||||
}
|
||||
|
||||
//删除锁分组
|
||||
Future<MassSendLockGroupListEntity> deleteGroup(int groupId) async {
|
||||
final res =
|
||||
await apiProvider.deleteGroup(groupId);
|
||||
return MassSendLockGroupListEntity.fromJson(res.body);
|
||||
}
|
||||
|
||||
//锁分组里面添加锁
|
||||
Future<MassSendLockGroupListEntity> lockGroupAddLock(
|
||||
{
|
||||
required List lockIds,
|
||||
required int groupId
|
||||
}) async {
|
||||
final res =
|
||||
await apiProvider.lockGroupAddLock(lockIds, groupId);
|
||||
return MassSendLockGroupListEntity.fromJson(res.body);
|
||||
}
|
||||
|
||||
//锁分组里面删除锁
|
||||
Future<MassSendLockGroupListEntity> lockGroupDeletLock(
|
||||
{
|
||||
required List lockIds
|
||||
}) async {
|
||||
final res =
|
||||
await apiProvider.lockGroupDeletLock(lockIds);
|
||||
return MassSendLockGroupListEntity.fromJson(res.body);
|
||||
}
|
||||
|
||||
//选择锁列表
|
||||
Future<SelectLockListEntity> selectLockList() async {
|
||||
final res = await apiProvider.selectLockList();
|
||||
@ -505,18 +542,18 @@ class ApiRepository {
|
||||
return PasswordKeyEntity.fromJson(res.body);
|
||||
}
|
||||
|
||||
//分组列表
|
||||
Future<PasswordKeyEntity> keyGroupList(String type) async {
|
||||
final res = await apiProvider.keyGroupList(type);
|
||||
return PasswordKeyEntity.fromJson(res.body);
|
||||
}
|
||||
|
||||
//分组下的锁
|
||||
Future<PasswordKeyEntity> lockListByGroup(
|
||||
String type, String keyGroupId) async {
|
||||
final res = await apiProvider.lockListByGroup(type, keyGroupId);
|
||||
return PasswordKeyEntity.fromJson(res.body);
|
||||
}
|
||||
// //分组列表
|
||||
// Future<PasswordKeyEntity> keyGroupList111(String type) async {
|
||||
// final res = await apiProvider.keyGroupList(type);
|
||||
// return PasswordKeyEntity.fromJson(res.body);
|
||||
// }
|
||||
//
|
||||
// //分组下的锁
|
||||
// Future<PasswordKeyEntity> lockListByGroup111(
|
||||
// String type, String keyGroupId) async {
|
||||
// final res = await apiProvider.lockListByGroup(type, keyGroupId);
|
||||
// return PasswordKeyEntity.fromJson(res.body);
|
||||
// }
|
||||
|
||||
// 获取Wifi锁服务器
|
||||
Future<ConfiguringWifiEntity> getWifiLockServiceIpAndPort() async {
|
||||
@ -585,6 +622,16 @@ class ApiRepository {
|
||||
return LoginEntity.fromJson(res.body);
|
||||
}
|
||||
|
||||
// 设置开门方向
|
||||
Future<LoginEntity> setOpenDoorDirectionData({
|
||||
required int lockId,
|
||||
required int openDirectionValue,
|
||||
}) async {
|
||||
final res =
|
||||
await apiProvider.setOpenDoorDirectionData(lockId, openDirectionValue);
|
||||
return LoginEntity.fromJson(res.body);
|
||||
}
|
||||
|
||||
// 设置房态
|
||||
Future<LoginEntity> setRoomStatusData({
|
||||
required int lockId,
|
||||
|
||||
@ -42,4 +42,9 @@ class ScanAllDeviceFindCurrentDeviceConnectedEvent{
|
||||
class ChangeLanguageBlockLastLanguageEvent{
|
||||
String languageTitle;
|
||||
ChangeLanguageBlockLastLanguageEvent(this.languageTitle);
|
||||
}
|
||||
|
||||
/// 锁分组添加或者删除锁之后刷新首页数据
|
||||
class LockGroupEditGroupLockRefreshEvent{
|
||||
LockGroupEditGroupLockRefreshEvent();
|
||||
}
|
||||
@ -88,8 +88,7 @@ class _LeftSlideActionsState extends State<LeftSlideActions>
|
||||
}
|
||||
|
||||
void _onHorizontalDragUpdate(DragUpdateDetails details) {
|
||||
_translateX =
|
||||
(_translateX + details.delta.dx).clamp(-widget.actionsWidth, 0.0);
|
||||
_translateX = (_translateX + details.delta.dx).clamp(-widget.actionsWidth, 0.0);
|
||||
setState(() {});
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user