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