修改授权管理员逻辑
This commit is contained in:
parent
6ac102422d
commit
3a2e6f3e01
@ -71,7 +71,7 @@ class BlueManage{
|
|||||||
if(device.name.isEmpty){
|
if(device.name.isEmpty){
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// print("startScanDevice:${device}");
|
print("startScanDevice:${device}");
|
||||||
if (((device.serviceUuids.isNotEmpty ? device.serviceUuids[0] : "").toString().contains("758824")) && ((device.serviceUuids.isNotEmpty ? device.serviceUuids[0] : "").toString()[31] != "1") && (device.rssi >= -100)) {
|
if (((device.serviceUuids.isNotEmpty ? device.serviceUuids[0] : "").toString().contains("758824")) && ((device.serviceUuids.isNotEmpty ? device.serviceUuids[0] : "").toString()[31] != "1") && (device.rssi >= -100)) {
|
||||||
final knownDeviceIndex = _scanDevices.indexWhere((d) => d.id == device.id);
|
final knownDeviceIndex = _scanDevices.indexWhere((d) => d.id == device.id);
|
||||||
|
|
||||||
|
|||||||
@ -1,17 +1,16 @@
|
|||||||
//TODO:发送指令类型
|
|
||||||
import 'package:get/get.dart';
|
|
||||||
|
|
||||||
|
//TODO:发送指令类型
|
||||||
enum CommandType {
|
enum CommandType {
|
||||||
addUser, //增加用户 = 0x3001
|
addUser, //增加用户 = 0x3001
|
||||||
deletUser , //删除用户 = 0x3002
|
deletUser, //删除用户 = 0x3002
|
||||||
editUser , //修改用户 = 0x3003
|
editUser, //修改用户 = 0x3003
|
||||||
factoryDataReset , //恢复出厂设置 = 0x3004
|
factoryDataReset, //恢复出厂设置 = 0x3004
|
||||||
openLock , //开门 = 0x3005
|
openLock, //开门 = 0x3005
|
||||||
readLockStatusInfo, //读取锁状态信息 = 0x300A
|
readLockStatusInfo, //读取锁状态信息 = 0x300A
|
||||||
transferPermissions, //转移权限 = 0x300B
|
transferPermissions, //转移权限 = 0x300B
|
||||||
reportDoorOpenRecord, //开门记录上报 = 0x3020
|
reportDoorOpenRecord, //开门记录上报 = 0x3020
|
||||||
generalExtendedCommond , // 通用扩展指令 = 0x3030
|
generalExtendedCommond, // 通用扩展指令 = 0x3030
|
||||||
getLockPublicKey , // 获取锁公钥 = 0x3090
|
getLockPublicKey, // 获取锁公钥 = 0x3090
|
||||||
getLockPrivateKey, // 获取锁私钥 = 0x3091
|
getLockPrivateKey, // 获取锁私钥 = 0x3091
|
||||||
calibrationTime, // 校时 = 0x30f0
|
calibrationTime, // 校时 = 0x30f0
|
||||||
synchronizingLocationInformation, // 同步位置信息 = 0x30f1
|
synchronizingLocationInformation, // 同步位置信息 = 0x30f1
|
||||||
|
|||||||
@ -0,0 +1,188 @@
|
|||||||
|
class AuthorizedAdminSendEntity {
|
||||||
|
int? errorCode;
|
||||||
|
String? description;
|
||||||
|
String? errorMsg;
|
||||||
|
Data? data;
|
||||||
|
|
||||||
|
AuthorizedAdminSendEntity(
|
||||||
|
{this.errorCode, this.description, this.errorMsg, this.data});
|
||||||
|
|
||||||
|
AuthorizedAdminSendEntity.fromJson(Map<String, dynamic> json) {
|
||||||
|
errorCode = json['errorCode'];
|
||||||
|
description = json['description'];
|
||||||
|
errorMsg = json['errorMsg'];
|
||||||
|
data = json['data'] != null ? Data.fromJson(json['data']) : null;
|
||||||
|
}
|
||||||
|
|
||||||
|
Map<String, dynamic> toJson() {
|
||||||
|
final Map<String, dynamic> data = <String, dynamic>{};
|
||||||
|
data['errorCode'] = errorCode;
|
||||||
|
data['description'] = description;
|
||||||
|
data['errorMsg'] = errorMsg;
|
||||||
|
if (this.data != null) {
|
||||||
|
data['data'] = this.data!.toJson();
|
||||||
|
}
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class Data {
|
||||||
|
int? receiverUid;
|
||||||
|
ReceiverUser? receiverUser;
|
||||||
|
int? keyId;
|
||||||
|
|
||||||
|
Data({this.receiverUid, this.receiverUser, this.keyId});
|
||||||
|
|
||||||
|
Data.fromJson(Map<String, dynamic> json) {
|
||||||
|
receiverUid = json['receiverUid'];
|
||||||
|
receiverUser = json['receiverUser'] != null
|
||||||
|
? ReceiverUser.fromJson(json['receiverUser'])
|
||||||
|
: null;
|
||||||
|
keyId = json['keyId'];
|
||||||
|
}
|
||||||
|
|
||||||
|
Map<String, dynamic> toJson() {
|
||||||
|
final Map<String, dynamic> data = <String, dynamic>{};
|
||||||
|
data['receiverUid'] = receiverUid;
|
||||||
|
if (receiverUser != null) {
|
||||||
|
data['receiverUser'] = receiverUser!.toJson();
|
||||||
|
}
|
||||||
|
data['keyId'] = keyId;
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class ReceiverUser {
|
||||||
|
String? email;
|
||||||
|
String? name;
|
||||||
|
String? updatedAt;
|
||||||
|
String? createdAt;
|
||||||
|
int? id;
|
||||||
|
String? profilePhotoUrl;
|
||||||
|
Phone? phone;
|
||||||
|
Cloud? cloud;
|
||||||
|
|
||||||
|
ReceiverUser(
|
||||||
|
{this.email,
|
||||||
|
this.name,
|
||||||
|
this.updatedAt,
|
||||||
|
this.createdAt,
|
||||||
|
this.id,
|
||||||
|
this.profilePhotoUrl,
|
||||||
|
this.phone,
|
||||||
|
this.cloud});
|
||||||
|
|
||||||
|
ReceiverUser.fromJson(Map<String, dynamic> json) {
|
||||||
|
email = json['email'];
|
||||||
|
name = json['name'];
|
||||||
|
updatedAt = json['updated_at'];
|
||||||
|
createdAt = json['created_at'];
|
||||||
|
id = json['id'];
|
||||||
|
profilePhotoUrl = json['profile_photo_url'];
|
||||||
|
phone = json['phone'] != null ? Phone.fromJson(json['phone']) : null;
|
||||||
|
cloud = json['cloud'] != null ? Cloud.fromJson(json['cloud']) : null;
|
||||||
|
}
|
||||||
|
|
||||||
|
Map<String, dynamic> toJson() {
|
||||||
|
final Map<String, dynamic> data = Map<String, dynamic>();
|
||||||
|
data['email'] = email;
|
||||||
|
data['name'] = name;
|
||||||
|
data['updated_at'] = updatedAt;
|
||||||
|
data['created_at'] = createdAt;
|
||||||
|
data['id'] = id;
|
||||||
|
data['profile_photo_url'] = profilePhotoUrl;
|
||||||
|
if (phone != null) {
|
||||||
|
data['phone'] = phone!.toJson();
|
||||||
|
}
|
||||||
|
if (cloud != null) {
|
||||||
|
data['cloud'] = cloud!.toJson();
|
||||||
|
}
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class Phone {
|
||||||
|
int? userId;
|
||||||
|
String? phoneNumberHash;
|
||||||
|
String? phoneNumberEncrypt;
|
||||||
|
String? countryCode;
|
||||||
|
String? phoneNumberVerifiedAt;
|
||||||
|
String? updatedAt;
|
||||||
|
String? createdAt;
|
||||||
|
int? id;
|
||||||
|
|
||||||
|
Phone(
|
||||||
|
{this.userId,
|
||||||
|
this.phoneNumberHash,
|
||||||
|
this.phoneNumberEncrypt,
|
||||||
|
this.countryCode,
|
||||||
|
this.phoneNumberVerifiedAt,
|
||||||
|
this.updatedAt,
|
||||||
|
this.createdAt,
|
||||||
|
this.id});
|
||||||
|
|
||||||
|
Phone.fromJson(Map<String, dynamic> json) {
|
||||||
|
userId = json['user_id'];
|
||||||
|
phoneNumberHash = json['phone_number_hash'];
|
||||||
|
phoneNumberEncrypt = json['phone_number_encrypt'];
|
||||||
|
countryCode = json['country_code'];
|
||||||
|
phoneNumberVerifiedAt = json['phone_number_verified_at'];
|
||||||
|
updatedAt = json['updated_at'];
|
||||||
|
createdAt = json['created_at'];
|
||||||
|
id = json['id'];
|
||||||
|
}
|
||||||
|
|
||||||
|
Map<String, dynamic> toJson() {
|
||||||
|
final Map<String, dynamic> data = <String, dynamic>{};
|
||||||
|
data['user_id'] = userId;
|
||||||
|
data['phone_number_hash'] = phoneNumberHash;
|
||||||
|
data['phone_number_encrypt'] = phoneNumberEncrypt;
|
||||||
|
data['country_code'] = countryCode;
|
||||||
|
data['phone_number_verified_at'] = phoneNumberVerifiedAt;
|
||||||
|
data['updated_at'] = updatedAt;
|
||||||
|
data['created_at'] = createdAt;
|
||||||
|
data['id'] = id;
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class Cloud {
|
||||||
|
String? username;
|
||||||
|
String? password;
|
||||||
|
int? cloudUid;
|
||||||
|
int? userId;
|
||||||
|
String? updatedAt;
|
||||||
|
String? createdAt;
|
||||||
|
int? id;
|
||||||
|
|
||||||
|
Cloud(
|
||||||
|
{this.username,
|
||||||
|
this.password,
|
||||||
|
this.cloudUid,
|
||||||
|
this.userId,
|
||||||
|
this.updatedAt,
|
||||||
|
this.createdAt,
|
||||||
|
this.id});
|
||||||
|
|
||||||
|
Cloud.fromJson(Map<String, dynamic> json) {
|
||||||
|
username = json['username'];
|
||||||
|
password = json['password'];
|
||||||
|
cloudUid = json['cloud_uid'];
|
||||||
|
userId = json['user_id'];
|
||||||
|
updatedAt = json['updated_at'];
|
||||||
|
createdAt = json['created_at'];
|
||||||
|
id = json['id'];
|
||||||
|
}
|
||||||
|
|
||||||
|
Map<String, dynamic> toJson() {
|
||||||
|
final Map<String, dynamic> data = <String, dynamic>{};
|
||||||
|
data['username'] = username;
|
||||||
|
data['password'] = password;
|
||||||
|
data['cloud_uid'] = cloudUid;
|
||||||
|
data['user_id'] = userId;
|
||||||
|
data['updated_at'] = updatedAt;
|
||||||
|
data['created_at'] = createdAt;
|
||||||
|
data['id'] = id;
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -11,8 +11,10 @@ import '../../../../blue/io_tool/io_manager.dart';
|
|||||||
import '../../../../blue/io_tool/io_tool.dart';
|
import '../../../../blue/io_tool/io_tool.dart';
|
||||||
import '../../../../blue/io_tool/manager_event_bus.dart';
|
import '../../../../blue/io_tool/manager_event_bus.dart';
|
||||||
import '../../../../blue/sender_manage.dart';
|
import '../../../../blue/sender_manage.dart';
|
||||||
|
import '../../../../network/api_repository.dart';
|
||||||
import '../../../../tools/baseGetXController.dart';
|
import '../../../../tools/baseGetXController.dart';
|
||||||
import '../../../../tools/storage.dart';
|
import '../../../../tools/storage.dart';
|
||||||
|
import '../../../../tools/toast.dart';
|
||||||
import 'authorizedAdmin_state.dart';
|
import 'authorizedAdmin_state.dart';
|
||||||
|
|
||||||
class AuthorizedAdminLogic extends BaseGetXController {
|
class AuthorizedAdminLogic extends BaseGetXController {
|
||||||
@ -22,7 +24,7 @@ class AuthorizedAdminLogic extends BaseGetXController {
|
|||||||
late StreamSubscription<Reply> _replySubscription;
|
late StreamSubscription<Reply> _replySubscription;
|
||||||
void _initReplySubscription() {
|
void _initReplySubscription() {
|
||||||
_replySubscription = EventBusManager().eventBus!.on<Reply>().listen((reply) async {
|
_replySubscription = EventBusManager().eventBus!.on<Reply>().listen((reply) async {
|
||||||
// 开门
|
// 转移权限
|
||||||
if (reply is TransferPermissionsReply) {
|
if (reply is TransferPermissionsReply) {
|
||||||
var token = reply.data.sublist(2, 6);
|
var token = reply.data.sublist(2, 6);
|
||||||
var saveStrList = changeIntListToStringList(token);
|
var saveStrList = changeIntListToStringList(token);
|
||||||
@ -102,6 +104,8 @@ class AuthorizedAdminLogic extends BaseGetXController {
|
|||||||
case 0x00:
|
case 0x00:
|
||||||
//成功
|
//成功
|
||||||
print("添加用户数据解析成功");
|
print("添加用户数据解析成功");
|
||||||
|
state.isSendSuccess.value = true;
|
||||||
|
Toast.show(msg: "添加成功");
|
||||||
// bindBlueAdmin();
|
// bindBlueAdmin();
|
||||||
break;
|
break;
|
||||||
case 0x06:
|
case 0x06:
|
||||||
@ -179,10 +183,10 @@ class AuthorizedAdminLogic extends BaseGetXController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 添加用户
|
// 添加用户
|
||||||
Future<void> addUserConnectBlue() async {
|
Future<void> addUserConnectBlue(String receiveId) async {
|
||||||
// 进来之后首先连接
|
// 进来之后首先连接
|
||||||
BlueManage().judgeReconnect(BlueManage().connectDeviceMacAddress, BlueManage().connectDeviceName, (DeviceConnectionState state) async {
|
BlueManage().judgeReconnect(BlueManage().connectDeviceMacAddress, BlueManage().connectDeviceName, (DeviceConnectionState connecteState) async {
|
||||||
if (state == DeviceConnectionState.connected){
|
if (connecteState == DeviceConnectionState.connected){
|
||||||
// 私钥
|
// 私钥
|
||||||
var privateKey = await Storage.getStringList(saveBluePrivateKey);
|
var privateKey = await Storage.getStringList(saveBluePrivateKey);
|
||||||
List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
|
List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
|
||||||
@ -200,12 +204,12 @@ class AuthorizedAdminLogic extends BaseGetXController {
|
|||||||
lockID: BlueManage().connectDeviceName,
|
lockID: BlueManage().connectDeviceName,
|
||||||
authUserID:await Storage.getUid(),
|
authUserID:await Storage.getUid(),
|
||||||
keyID:"1",
|
keyID:"1",
|
||||||
userID:await Storage.getUid(),
|
userID:receiveId,
|
||||||
openMode:1,
|
openMode:1,
|
||||||
keyType:1,
|
keyType:(state.type.value == "1") ? 0 : 1,
|
||||||
startDate:DateTime.now().millisecondsSinceEpoch,
|
startDate:state.effectiveDateTime.value.millisecondsSinceEpoch,
|
||||||
expireDate:0x11223344,
|
expireDate:state.failureDateTime.value.millisecondsSinceEpoch,
|
||||||
role:255,
|
role:0,
|
||||||
password:"123456",
|
password:"123456",
|
||||||
needAuthor:1,
|
needAuthor:1,
|
||||||
publicKey:publicKeyDataList,
|
publicKey:publicKeyDataList,
|
||||||
@ -216,6 +220,49 @@ class AuthorizedAdminLogic extends BaseGetXController {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//发送授权管理员列表请求
|
||||||
|
Future<void> sendElectronicKeyRequest() async {
|
||||||
|
String getFailureDateTime = '0';
|
||||||
|
String getEffectiveDateTime = '0';
|
||||||
|
String lockID = state.keyInfo.value.lockId.toString();
|
||||||
|
String getKeyType = (int.parse(state.type.value) + 1).toString();
|
||||||
|
if (state.type.value == '0') {
|
||||||
|
getFailureDateTime = state.failureDateTime.value.millisecondsSinceEpoch.toString();
|
||||||
|
getEffectiveDateTime =
|
||||||
|
state.effectiveDateTime.value.millisecondsSinceEpoch.toString();
|
||||||
|
}
|
||||||
|
var entity = await ApiRepository.to.sendElectronicKey(
|
||||||
|
state.isCreateUser.value ? "1" : "0",
|
||||||
|
state.countryCode.value,
|
||||||
|
'1',
|
||||||
|
getFailureDateTime,
|
||||||
|
state.isAuthentication.value == true ? '1' : '2',
|
||||||
|
'2',
|
||||||
|
'2',
|
||||||
|
state.keyNameController.text,
|
||||||
|
'1',
|
||||||
|
getKeyType,
|
||||||
|
lockID,
|
||||||
|
'',
|
||||||
|
state.emailOrPhoneController.text,
|
||||||
|
'',
|
||||||
|
getEffectiveDateTime,
|
||||||
|
state.weekdaysList);
|
||||||
|
if (entity.errorCode!.codeIsSuccessful) {
|
||||||
|
print('发送电子钥匙成功');
|
||||||
|
state.isSendSuccess.value = true;
|
||||||
|
Toast.show(msg: "添加成功");
|
||||||
|
// addUserConnectBlue(entity.data!.receiverUser!.id.toString());
|
||||||
|
} else {
|
||||||
|
// Toast.show(msg: '${entity.errorMsg}');
|
||||||
|
if (entity.errorCode == 425) {
|
||||||
|
//用户未注册
|
||||||
|
state.isCreateUser.value = true;
|
||||||
|
sendElectronicKeyRequest();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void onReady() {
|
void onReady() {
|
||||||
// TODO: implement onReady
|
// TODO: implement onReady
|
||||||
|
|||||||
@ -30,56 +30,57 @@ class _AuthorizedAdminPageState extends State<AuthorizedAdminPage> {
|
|||||||
final logic = Get.put(AuthorizedAdminLogic());
|
final logic = Get.put(AuthorizedAdminLogic());
|
||||||
final state = Get.find<AuthorizedAdminLogic>().state;
|
final state = Get.find<AuthorizedAdminLogic>().state;
|
||||||
|
|
||||||
final FlutterContactPicker _contactPicker = FlutterContactPicker();
|
// final FlutterContactPicker _contactPicker = FlutterContactPicker();
|
||||||
late Contact _contact;
|
// late Contact _contact;
|
||||||
late KeyInfos keyInfo;
|
// late KeyInfos keyInfo;
|
||||||
late LockMainEntity lockMainEntity;
|
// late LockMainEntity lockMainEntity;
|
||||||
bool _isAuthentication = false; //是否可以实名认证
|
// bool _isAuthentication = false; //是否可以实名认证
|
||||||
var _selectEffectiveDate = ''; //生效时间
|
// var _selectEffectiveDate = ''; //生效时间
|
||||||
var _selectFailureDate = ''; //失效时间
|
// var _selectFailureDate = ''; //失效时间
|
||||||
late DateTime _effectiveDateTime;
|
// late DateTime _effectiveDateTime;
|
||||||
late DateTime _failureDateTime;
|
// late DateTime _failureDateTime;
|
||||||
final TextEditingController _emailOrPhoneController =
|
// final TextEditingController _emailOrPhoneController =
|
||||||
TextEditingController(); //邮箱/手机号输入框
|
// TextEditingController(); //邮箱/手机号输入框
|
||||||
final TextEditingController _keyNameController =
|
// final TextEditingController _keyNameController =
|
||||||
TextEditingController(); //钥匙名输入框
|
// TextEditingController(); //钥匙名输入框
|
||||||
late bool _isSendSuccess;
|
// late bool _isSendSuccess;
|
||||||
String countryName = '中国';
|
// String countryName = '中国';
|
||||||
String countryCode = '86';
|
// String countryCode = '86';
|
||||||
List weekdaysList = [];
|
// List weekdaysList = [];
|
||||||
bool _isCreateUser = false; //用户未注册时传1 已注册传0
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
|
|
||||||
DateTime dateTime = DateTime.now();
|
// DateTime dateTime = DateTime.now();
|
||||||
_effectiveDateTime = dateTime;
|
// _effectiveDateTime = dateTime;
|
||||||
_failureDateTime = dateTime;
|
// _failureDateTime = dateTime;
|
||||||
_selectEffectiveDate =
|
// _selectEffectiveDate =
|
||||||
'${dateTime.year}-${dateTime.month}-${dateTime.day} ${dateTime.hour}:${dateTime.minute}'; //默认为当前时间
|
// '${dateTime.year}-${dateTime.month}-${dateTime.day} ${dateTime.hour}:${dateTime.minute}'; //默认为当前时间
|
||||||
_selectFailureDate =
|
// _selectFailureDate =
|
||||||
'${dateTime.year}-${dateTime.month}-${dateTime.day} ${dateTime.hour}:${dateTime.minute}'; //默认为当前时间
|
// '${dateTime.year}-${dateTime.month}-${dateTime.day} ${dateTime.hour}:${dateTime.minute}'; //默认为当前时间
|
||||||
_isSendSuccess = false;
|
// _isSendSuccess = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
dynamic obj = ModalRoute.of(context)?.settings.arguments;
|
// dynamic obj = ModalRoute.of(context)?.settings.arguments;
|
||||||
if (obj != null && (obj["lockMainEntity"] != null)) {
|
// if (obj != null && (obj["lockMainEntity"] != null)) {
|
||||||
lockMainEntity = obj["lockMainEntity"];
|
// lockMainEntity = obj["lockMainEntity"];
|
||||||
}
|
// }
|
||||||
if (obj != null && (obj["keyInfo"] != null)) {
|
// if (obj != null && (obj["keyInfo"] != null)) {
|
||||||
keyInfo = obj["keyInfo"];
|
// keyInfo = obj["keyInfo"];
|
||||||
}
|
// }
|
||||||
|
|
||||||
|
state.type.value = widget.type;
|
||||||
|
|
||||||
return SingleChildScrollView(
|
return SingleChildScrollView(
|
||||||
child: indexChangeWidget(),
|
child: Obx(() => indexChangeWidget()),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget indexChangeWidget() {
|
Widget indexChangeWidget() {
|
||||||
if (_isSendSuccess) {
|
if (state.isSendSuccess.value) {
|
||||||
return sendElectronicKeySucceed();
|
return sendElectronicKeySucceed();
|
||||||
} else {
|
} else {
|
||||||
switch (int.parse(widget.type)) {
|
switch (int.parse(widget.type)) {
|
||||||
@ -128,7 +129,7 @@ class _AuthorizedAdminPageState extends State<AuthorizedAdminPage> {
|
|||||||
isHaveRightWidget: true,
|
isHaveRightWidget: true,
|
||||||
isHaveDirection: true,
|
isHaveDirection: true,
|
||||||
rightWidget: Text(
|
rightWidget: Text(
|
||||||
'$countryName +$countryCode',
|
'${state.countryName.value} +${state.countryCode.value}',
|
||||||
textAlign: TextAlign.end,
|
textAlign: TextAlign.end,
|
||||||
style:
|
style:
|
||||||
TextStyle(fontSize: 22.sp, color: AppColors.darkGrayTextColor),
|
TextStyle(fontSize: 22.sp, color: AppColors.darkGrayTextColor),
|
||||||
@ -137,8 +138,8 @@ class _AuthorizedAdminPageState extends State<AuthorizedAdminPage> {
|
|||||||
var result = await Navigator.pushNamed(
|
var result = await Navigator.pushNamed(
|
||||||
context, Routers.seletCountryRegionPage);
|
context, Routers.seletCountryRegionPage);
|
||||||
result as Map<String, dynamic>;
|
result as Map<String, dynamic>;
|
||||||
countryCode = result['code'];
|
state.countryCode.value = result['code'];
|
||||||
countryName = result['countryName'];
|
state.countryName.value = result['countryName'];
|
||||||
setState(() {});
|
setState(() {});
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
@ -159,30 +160,30 @@ class _AuthorizedAdminPageState extends State<AuthorizedAdminPage> {
|
|||||||
children: [
|
children: [
|
||||||
CommonItem(
|
CommonItem(
|
||||||
leftTitel: TranslationLoader.lanKeys!.effectiveTime!.tr,
|
leftTitel: TranslationLoader.lanKeys!.effectiveTime!.tr,
|
||||||
rightTitle: _selectEffectiveDate,
|
rightTitle: state.selectEffectiveDate.value,
|
||||||
isHaveLine: true,
|
isHaveLine: true,
|
||||||
isHaveDirection: true,
|
isHaveDirection: true,
|
||||||
action: () {
|
action: () {
|
||||||
Pickers.showDatePicker(context, mode: DateMode.YMDHM,
|
Pickers.showDatePicker(context, mode: DateMode.YMDHM,
|
||||||
onConfirm: (p) {
|
onConfirm: (p) {
|
||||||
setState(() {
|
setState(() {
|
||||||
_selectEffectiveDate =
|
state.selectEffectiveDate.value =
|
||||||
'${p.year}-${intToStr(p.month!)}-${intToStr(p.day!)} ${intToStr(p.hour!)}:${intToStr(p.minute!)}';
|
'${p.year}-${intToStr(p.month!)}-${intToStr(p.day!)} ${intToStr(p.hour!)}:${intToStr(p.minute!)}';
|
||||||
_effectiveDateTime = DateTime.parse(_selectEffectiveDate);
|
state.effectiveDateTime.value = DateTime.parse(state.selectEffectiveDate.value);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}),
|
}),
|
||||||
CommonItem(
|
CommonItem(
|
||||||
leftTitel: TranslationLoader.lanKeys!.failureTime!.tr,
|
leftTitel: TranslationLoader.lanKeys!.failureTime!.tr,
|
||||||
rightTitle: _selectFailureDate,
|
rightTitle: state.selectFailureDate.value,
|
||||||
isHaveDirection: true,
|
isHaveDirection: true,
|
||||||
action: () {
|
action: () {
|
||||||
Pickers.showDatePicker(context, mode: DateMode.YMDHM,
|
Pickers.showDatePicker(context, mode: DateMode.YMDHM,
|
||||||
onConfirm: (p) {
|
onConfirm: (p) {
|
||||||
setState(() {
|
setState(() {
|
||||||
_selectFailureDate =
|
state.selectFailureDate.value =
|
||||||
'${p.year}-${intToStr(p.month!)}-${intToStr(p.day!)} ${intToStr(p.hour!)}:${intToStr(p.minute!)}';
|
'${p.year}-${intToStr(p.month!)}-${intToStr(p.day!)} ${intToStr(p.hour!)}:${intToStr(p.minute!)}';
|
||||||
_failureDateTime = DateTime.parse(_selectFailureDate);
|
state.failureDateTime.value = DateTime.parse(state.selectFailureDate.value);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}),
|
}),
|
||||||
@ -231,9 +232,9 @@ class _AuthorizedAdminPageState extends State<AuthorizedAdminPage> {
|
|||||||
btnName: TranslationLoader.lanKeys!.send!.tr,
|
btnName: TranslationLoader.lanKeys!.send!.tr,
|
||||||
onClick: () {
|
onClick: () {
|
||||||
//发送钥匙请求
|
//发送钥匙请求
|
||||||
if (_emailOrPhoneController.text.isNotEmpty &&
|
if (state.emailOrPhoneController.text.isNotEmpty && state.keyNameController.value.text.isNotEmpty) {
|
||||||
_keyNameController.text.isNotEmpty) {
|
// logic.addUserConnectBlue();
|
||||||
sendElectronicKeyRequest();
|
logic.sendElectronicKeyRequest();
|
||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
Container(
|
Container(
|
||||||
@ -301,7 +302,7 @@ class _AuthorizedAdminPageState extends State<AuthorizedAdminPage> {
|
|||||||
SubmitBtn(
|
SubmitBtn(
|
||||||
btnName: '完成',
|
btnName: '完成',
|
||||||
onClick: () {
|
onClick: () {
|
||||||
_isSendSuccess = false;
|
state.isSendSuccess.value = false;
|
||||||
Navigator.pop(context, true);
|
Navigator.pop(context, true);
|
||||||
}),
|
}),
|
||||||
SizedBox(
|
SizedBox(
|
||||||
@ -336,7 +337,7 @@ class _AuthorizedAdminPageState extends State<AuthorizedAdminPage> {
|
|||||||
//标记房间为已入住 isOn:已入住: 1 空闲:2
|
//标记房间为已入住 isOn:已入住: 1 空闲:2
|
||||||
Future<void> updateRoomCheckIn() async {
|
Future<void> updateRoomCheckIn() async {
|
||||||
var entity = await ApiRepository.to
|
var entity = await ApiRepository.to
|
||||||
.updateSetting(keyInfo.lockId.toString(), '1', '13');
|
.updateSetting(state.keyInfo.value.lockId.toString(), '1', '13');
|
||||||
if (entity.errorCode!.codeIsSuccessful) {
|
if (entity.errorCode!.codeIsSuccessful) {
|
||||||
print("标记为已入住成功啦啦啦啦啦");
|
print("标记为已入住成功啦啦啦啦啦");
|
||||||
Toast.show(msg: "标记成功");
|
Toast.show(msg: "标记成功");
|
||||||
@ -358,7 +359,7 @@ class _AuthorizedAdminPageState extends State<AuthorizedAdminPage> {
|
|||||||
//输入框一行
|
//输入框一行
|
||||||
maxLines: 1,
|
maxLines: 1,
|
||||||
controller:
|
controller:
|
||||||
lineIndex == 1 ? _emailOrPhoneController : _keyNameController,
|
lineIndex == 1 ? state.emailOrPhoneController : state.keyNameController,
|
||||||
autofocus: false,
|
autofocus: false,
|
||||||
textAlign: TextAlign.end,
|
textAlign: TextAlign.end,
|
||||||
decoration: InputDecoration(
|
decoration: InputDecoration(
|
||||||
@ -388,9 +389,9 @@ class _AuthorizedAdminPageState extends State<AuthorizedAdminPage> {
|
|||||||
alignment: Alignment.center,
|
alignment: Alignment.center,
|
||||||
child: InkWell(
|
child: InkWell(
|
||||||
onTap: () async {
|
onTap: () async {
|
||||||
Contact? contact = await _contactPicker.selectContact();
|
Contact? contact = await state.contactPicker.selectContact();
|
||||||
setState(() {
|
setState(() {
|
||||||
_contact = contact!;
|
state.contact = contact!;
|
||||||
// print("object111111111111 ${_contact.fullName} ${_contact.phoneNumbers}");
|
// print("object111111111111 ${_contact.fullName} ${_contact.phoneNumbers}");
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
@ -403,46 +404,46 @@ class _AuthorizedAdminPageState extends State<AuthorizedAdminPage> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//发送授权管理员列表请求
|
//发送授权管理员列表请求
|
||||||
Future<void> sendElectronicKeyRequest() async {
|
// Future<void> sendElectronicKeyRequest() async {
|
||||||
String getFailureDateTime = '0';
|
// String getFailureDateTime = '0';
|
||||||
String getEffectiveDateTime = '0';
|
// String getEffectiveDateTime = '0';
|
||||||
String lockID = keyInfo.lockId.toString();
|
// String lockID = state.keyInfo.value.lockId.toString();
|
||||||
String getKeyType = (int.parse(widget.type) + 1).toString();
|
// String getKeyType = (int.parse(widget.type) + 1).toString();
|
||||||
if (widget.type == '0') {
|
// if (widget.type == '0') {
|
||||||
getFailureDateTime = _failureDateTime.millisecondsSinceEpoch.toString();
|
// getFailureDateTime = state.failureDateTime.value.millisecondsSinceEpoch.toString();
|
||||||
getEffectiveDateTime =
|
// getEffectiveDateTime =
|
||||||
_effectiveDateTime.millisecondsSinceEpoch.toString();
|
// state.effectiveDateTime.value.millisecondsSinceEpoch.toString();
|
||||||
}
|
// }
|
||||||
var entity = await ApiRepository.to.sendElectronicKey(
|
// var entity = await ApiRepository.to.sendElectronicKey(
|
||||||
_isCreateUser ? "1" : "0",
|
// state.isCreateUser.value ? "1" : "0",
|
||||||
countryCode,
|
// state.countryCode.value,
|
||||||
'1',
|
// '1',
|
||||||
getFailureDateTime,
|
// getFailureDateTime,
|
||||||
_isAuthentication == true ? '1' : '2',
|
// state.isAuthentication.value == true ? '1' : '2',
|
||||||
'2',
|
// '2',
|
||||||
'2',
|
// '2',
|
||||||
_keyNameController.text,
|
// state.keyNameController.text,
|
||||||
'1',
|
// '1',
|
||||||
getKeyType,
|
// getKeyType,
|
||||||
lockID,
|
// lockID,
|
||||||
'',
|
// '',
|
||||||
_emailOrPhoneController.text,
|
// state.emailOrPhoneController.text,
|
||||||
'',
|
// '',
|
||||||
getEffectiveDateTime,
|
// getEffectiveDateTime,
|
||||||
weekdaysList);
|
// state.weekdaysList);
|
||||||
if (entity.errorCode!.codeIsSuccessful) {
|
// if (entity.errorCode!.codeIsSuccessful) {
|
||||||
print('发送电子钥匙成功');
|
// print('发送电子钥匙成功');
|
||||||
_isSendSuccess = true;
|
// state.isSendSuccess.value = true;
|
||||||
setState(() {});
|
// setState(() {});
|
||||||
} else {
|
// } else {
|
||||||
Toast.show(msg: '${entity.errorMsg}');
|
// Toast.show(msg: '${entity.errorMsg}');
|
||||||
if (entity.errorCode == 425) {
|
// if (entity.errorCode == 425) {
|
||||||
//用户未注册
|
// //用户未注册
|
||||||
_isCreateUser = true;
|
// state.isCreateUser.value = true;
|
||||||
sendElectronicKeyRequest();
|
// sendElectronicKeyRequest();
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
|
||||||
//实名认证
|
//实名认证
|
||||||
CupertinoSwitch _switch() {
|
CupertinoSwitch _switch() {
|
||||||
@ -450,10 +451,10 @@ class _AuthorizedAdminPageState extends State<AuthorizedAdminPage> {
|
|||||||
activeColor: CupertinoColors.activeBlue,
|
activeColor: CupertinoColors.activeBlue,
|
||||||
trackColor: CupertinoColors.systemGrey5,
|
trackColor: CupertinoColors.systemGrey5,
|
||||||
thumbColor: CupertinoColors.white,
|
thumbColor: CupertinoColors.white,
|
||||||
value: _isAuthentication,
|
value: state.isAuthentication.value,
|
||||||
onChanged: (value) {
|
onChanged: (value) {
|
||||||
setState(() {
|
setState(() {
|
||||||
_isAuthentication = !_isAuthentication;
|
state.isAuthentication.value = !state.isAuthentication.value;
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|||||||
@ -1,4 +1,38 @@
|
|||||||
|
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter_native_contact_picker/flutter_native_contact_picker.dart';
|
||||||
|
import 'package:get/get.dart';
|
||||||
|
|
||||||
|
import '../../../lockMian/entity/lockInfoEntity.dart';
|
||||||
|
|
||||||
class AuthorizedAdminState {
|
class AuthorizedAdminState {
|
||||||
|
final TextEditingController emailOrPhoneController = TextEditingController(); //邮箱/手机号输入框
|
||||||
|
final TextEditingController keyNameController = TextEditingController(); //钥匙名输入框
|
||||||
|
|
||||||
|
final FlutterContactPicker contactPicker = FlutterContactPicker();
|
||||||
|
late Contact contact;
|
||||||
|
|
||||||
|
var type = ''.obs;
|
||||||
|
final keyInfo = KeyInfos().obs;
|
||||||
|
final lockMainEntity = LockMainEntity().obs;
|
||||||
|
final isAuthentication = false.obs; //是否可以实名认证
|
||||||
|
DateTime dateTime = DateTime.now();
|
||||||
|
final effectiveDateTime = DateTime.now().obs;
|
||||||
|
final failureDateTime = DateTime.now().obs;
|
||||||
|
|
||||||
|
var selectEffectiveDate = '${DateTime.now().year}-${DateTime.now().month}-${DateTime.now().day} ${DateTime.now().hour}:${DateTime.now().minute}'.obs; //默认为当前时间
|
||||||
|
var selectFailureDate = '${DateTime.now().year}-${DateTime.now().month}-${DateTime.now().day} ${DateTime.now().hour}:${DateTime.now().minute}'.obs; //默认为当前时间
|
||||||
|
|
||||||
|
var isSendSuccess = false.obs;
|
||||||
|
var countryName = '中国'.obs;
|
||||||
|
var countryCode = '86'.obs;
|
||||||
|
var weekdaysList = [].obs;
|
||||||
|
var isCreateUser = false.obs; //用户未注册时传1 已注册传0
|
||||||
|
|
||||||
|
|
||||||
|
AuthorizedAdminState() {
|
||||||
|
Map map = Get.arguments;
|
||||||
|
lockMainEntity.value = map["lockMainEntity"];
|
||||||
|
keyInfo.value = map["keyInfo"];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@ -417,9 +417,9 @@ class LockDetailLogic extends BaseGetXController{
|
|||||||
print("onReady()");
|
print("onReady()");
|
||||||
_initReplySubscription();
|
_initReplySubscription();
|
||||||
|
|
||||||
// BlueManage().startScan((v){
|
BlueManage().startScan((v){
|
||||||
//
|
|
||||||
// });
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
|||||||
@ -16,6 +16,7 @@ import '../common/safetyVerification/entity/CheckSafetyVerificationEntity.dart';
|
|||||||
import '../common/safetyVerification/entity/SafetyVerificationEntity.dart';
|
import '../common/safetyVerification/entity/SafetyVerificationEntity.dart';
|
||||||
import '../login/login/entity/LoginEntity.dart';
|
import '../login/login/entity/LoginEntity.dart';
|
||||||
import '../login/register/entity/SendValidationCodeEntity.dart';
|
import '../login/register/entity/SendValidationCodeEntity.dart';
|
||||||
|
import '../main/lockDetail/authorizedAdmin/authorizedAdmin/authorizedAdmin_entity.dart';
|
||||||
import '../main/lockDetail/checkingIn/checkingInDetail/checkingInDetail_entity.dart';
|
import '../main/lockDetail/checkingIn/checkingInDetail/checkingInDetail_entity.dart';
|
||||||
import '../main/lockDetail/checkingIn/checkingInHolidays/checkingInSetHolidays/checkingInSetHolidays_entity.dart';
|
import '../main/lockDetail/checkingIn/checkingInHolidays/checkingInSetHolidays/checkingInSetHolidays_entity.dart';
|
||||||
import '../main/lockDetail/checkingIn/checkingInList/checkingInListDay_entity.dart';
|
import '../main/lockDetail/checkingIn/checkingInList/checkingInListDay_entity.dart';
|
||||||
@ -129,7 +130,7 @@ class ApiRepository {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//发送电子钥匙
|
//发送电子钥匙
|
||||||
Future<ElectronicKeyListEntity> sendElectronicKey(
|
Future<AuthorizedAdminSendEntity> sendElectronicKey(
|
||||||
String createUser,
|
String createUser,
|
||||||
String countryCode,
|
String countryCode,
|
||||||
String usernameType,
|
String usernameType,
|
||||||
@ -163,7 +164,7 @@ class ApiRepository {
|
|||||||
remarks,
|
remarks,
|
||||||
startDate,
|
startDate,
|
||||||
weekDays);
|
weekDays);
|
||||||
return ElectronicKeyListEntity.fromJson(res.body);
|
return AuthorizedAdminSendEntity.fromJson(res.body);
|
||||||
}
|
}
|
||||||
|
|
||||||
//重置电子钥匙
|
//重置电子钥匙
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user