Merge branch 'release_hyx' into release
This commit is contained in:
commit
7bc4d7c02c
@ -5,7 +5,11 @@ import 'package:flutter_blue_plus/flutter_blue_plus.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:star_lock/appRouters.dart';
|
||||
import 'package:star_lock/app_settings/app_settings.dart';
|
||||
import 'package:star_lock/login/login/entity/LoginEntity.dart';
|
||||
import 'package:star_lock/main/lockDetail/authorizedAdmin/authorizedAdmin/authorizedAdmin_entity.dart';
|
||||
import 'package:star_lock/main/lockDetail/authorizedAdmin/authorizedAdmin/notice_template_entity.dart';
|
||||
import 'package:star_lock/mine/valueAddedServices/advancedFunctionRecord/advancedFunctionRecord_entity.dart';
|
||||
import 'package:star_lock/tools/NativeInteractionTool.dart';
|
||||
import 'package:star_lock/tools/dateTool.dart';
|
||||
import 'package:star_lock/tools/showCupertinoAlertView.dart';
|
||||
|
||||
@ -26,18 +30,21 @@ import 'authorizedAdmin_state.dart';
|
||||
class AuthorizedAdminLogic extends BaseGetXController {
|
||||
final AuthorizedAdminState state = AuthorizedAdminState();
|
||||
|
||||
int? keyId;
|
||||
|
||||
// 监听设备返回的数据
|
||||
late StreamSubscription<Reply> _replySubscription;
|
||||
|
||||
void _initReplySubscription() {
|
||||
_replySubscription =
|
||||
EventBusManager().eventBus!.on<Reply>().listen((reply) async {
|
||||
EventBusManager().eventBus!.on<Reply>().listen((Reply reply) async {
|
||||
// 转移权限
|
||||
if (reply is TransferPermissionsReply) {
|
||||
var token = reply.data.sublist(2, 6);
|
||||
var saveStrList = changeIntListToStringList(token);
|
||||
final List<int> token = reply.data.sublist(2, 6);
|
||||
final List<String> saveStrList = changeIntListToStringList(token);
|
||||
Storage.setStringList(saveBlueToken, saveStrList);
|
||||
|
||||
int status = reply.data[6];
|
||||
final int status = reply.data[6];
|
||||
|
||||
switch (status) {
|
||||
case 0x00:
|
||||
@ -45,20 +52,24 @@ class AuthorizedAdminLogic extends BaseGetXController {
|
||||
break;
|
||||
case 0x06:
|
||||
//无权限
|
||||
var privateKey = await Storage.getStringList(saveBluePrivateKey);
|
||||
List<int> getPrivateKeyList =
|
||||
final List<String>? privateKey =
|
||||
await Storage.getStringList(saveBluePrivateKey);
|
||||
final List<int> getPrivateKeyList =
|
||||
changeStringListToIntList(privateKey!);
|
||||
|
||||
var publicKey = await Storage.getStringList(saveBluePublicKey);
|
||||
List<int> publicKeyDataList = changeStringListToIntList(publicKey!);
|
||||
final List<String>? publicKey =
|
||||
await Storage.getStringList(saveBluePublicKey);
|
||||
final List<int> publicKeyDataList =
|
||||
changeStringListToIntList(publicKey!);
|
||||
|
||||
var token = await Storage.getStringList(saveBlueToken);
|
||||
List<int> getTokenList = changeStringListToIntList(token!);
|
||||
final List<String>? token =
|
||||
await Storage.getStringList(saveBlueToken);
|
||||
final List<int> getTokenList = changeStringListToIntList(token!);
|
||||
|
||||
IoSenderManage.senderFactoryDataReset(
|
||||
lockID: BlueManage().connectDeviceName,
|
||||
userID: await Storage.getUid(),
|
||||
keyID: "1",
|
||||
keyID: '1',
|
||||
needAuthor: 1,
|
||||
publicKey: publicKeyDataList,
|
||||
privateKey: getPrivateKeyList,
|
||||
@ -76,21 +87,25 @@ class AuthorizedAdminLogic extends BaseGetXController {
|
||||
BlueManage().blueSendData(BlueManage().connectDeviceName,
|
||||
(BluetoothConnectionState state) async {
|
||||
if (state == BluetoothConnectionState.connected) {
|
||||
var privateKey = await Storage.getStringList(saveBluePrivateKey);
|
||||
List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
|
||||
final List<String>? privateKey =
|
||||
await Storage.getStringList(saveBluePrivateKey);
|
||||
final List<int> getPrivateKeyList =
|
||||
changeStringListToIntList(privateKey!);
|
||||
|
||||
var publicKey = await Storage.getStringList(saveBluePublicKey);
|
||||
List<int> publicKeyDataList = changeStringListToIntList(publicKey!);
|
||||
final List<String>? publicKey =
|
||||
await Storage.getStringList(saveBluePublicKey);
|
||||
final List<int> publicKeyDataList =
|
||||
changeStringListToIntList(publicKey!);
|
||||
|
||||
var token = await Storage.getStringList(saveBlueToken);
|
||||
List<int> getTokenList = changeStringListToIntList(token!);
|
||||
final List<String>? token = await Storage.getStringList(saveBlueToken);
|
||||
final List<int> getTokenList = changeStringListToIntList(token!);
|
||||
|
||||
IoSenderManage.senderTransferPermissions(
|
||||
lockID: BlueManage().connectDeviceName,
|
||||
authUserID: await Storage.getUid(),
|
||||
keyID: "1",
|
||||
keyID: '1',
|
||||
oldUserID: await Storage.getUid(),
|
||||
newUserID: "100002",
|
||||
newUserID: '100002',
|
||||
needAuthor: 1,
|
||||
publicKey: publicKeyDataList,
|
||||
privateKey: getPrivateKeyList,
|
||||
@ -102,40 +117,40 @@ class AuthorizedAdminLogic extends BaseGetXController {
|
||||
//发送授权管理员列表请求
|
||||
Future<void> sendElectronicKeyRequest() async {
|
||||
if (state.emailOrPhoneController.text.isEmpty) {
|
||||
showToast("请输入接收者账号");
|
||||
showToast('请输入接收者账号');
|
||||
return;
|
||||
}
|
||||
if (state.keyNameController.text.isEmpty) {
|
||||
showToast("请输入接收者姓名");
|
||||
showToast('请输入接收者姓名');
|
||||
return;
|
||||
}
|
||||
|
||||
var startDate = "0";
|
||||
var endDate = "0";
|
||||
var startTime = "0";
|
||||
var endTime = "0";
|
||||
AppLog.log("state.type.value:${state.seletType.value}");
|
||||
String getKeyType = "1";
|
||||
String startDate = '0';
|
||||
String endDate = '0';
|
||||
String startTime = '0';
|
||||
String endTime = '0';
|
||||
AppLog.log('state.type.value:${state.seletType.value}');
|
||||
String getKeyType = '1';
|
||||
if (state.seletType.value == 0) {
|
||||
getKeyType = "2";
|
||||
getKeyType = '2';
|
||||
|
||||
startDate =
|
||||
DateTool().dateToTimestamp(state.beginDate.value, 1).toString();
|
||||
endDate = DateTool().dateToTimestamp(state.endDate.value, 1).toString();
|
||||
startTime = "0";
|
||||
endTime = "0";
|
||||
startTime = '0';
|
||||
endTime = '0';
|
||||
|
||||
if (startDate.isEmpty) {
|
||||
showToast("请选择开始时间");
|
||||
showToast('请选择开始时间');
|
||||
return;
|
||||
}
|
||||
if (endDate.isEmpty) {
|
||||
showToast("请选择结束时间");
|
||||
showToast('请选择结束时间');
|
||||
return;
|
||||
}
|
||||
|
||||
if (int.parse(startDate) >= int.parse(endDate)) {
|
||||
showToast("失效时间要大于生效时间");
|
||||
showToast('失效时间要大于生效时间');
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -143,12 +158,12 @@ class AuthorizedAdminLogic extends BaseGetXController {
|
||||
//如果打开了实名认证,需要弹出输入身份证信息框
|
||||
if (state.isAuthentication.value == true) {
|
||||
if (state.realNameController.text.isEmpty) {
|
||||
showToast("请输入真实姓名".tr);
|
||||
showToast('请输入真实姓名'.tr);
|
||||
return;
|
||||
}
|
||||
|
||||
if (state.idCardController.text.isEmpty) {
|
||||
showToast("请输入身份证号".tr);
|
||||
showToast('请输入身份证号'.tr);
|
||||
return;
|
||||
}
|
||||
//弹出身份证信息确认框
|
||||
@ -179,38 +194,39 @@ class AuthorizedAdminLogic extends BaseGetXController {
|
||||
required String startDate,
|
||||
required String startTime,
|
||||
required String endTime}) async {
|
||||
var entity = await ApiRepository.to.sendElectronicKey(
|
||||
createUser: state.isCreateUser.value ? "1" : "0",
|
||||
countryCode: state.countryCode.value,
|
||||
usernameType: '1',
|
||||
endDate: int.parse(endDate),
|
||||
faceAuthentication: state.isAuthentication.value == true ? '1' : '2',
|
||||
isCameraEnable: '2',
|
||||
isRemoteUnlock: '2',
|
||||
keyNameForAdmin: state.keyNameController.text,
|
||||
keyRight: '1',
|
||||
keyType: getKeyType,
|
||||
lockId: CommonDataManage().currentKeyInfo.lockId!.toString(),
|
||||
operatorUid: '',
|
||||
receiverUsername: state.emailOrPhoneController.text,
|
||||
remarks: '',
|
||||
startDate: int.parse(startDate),
|
||||
weekDays: state.weekdaysList,
|
||||
startTime: int.parse(startTime),
|
||||
endTime: int.parse(endTime),
|
||||
isOnlyManageSelf: state.onlyManageYouCreatesUser.value ? 1 : 0,
|
||||
realName: state.isRequireAuth.value == true
|
||||
? state.realNameController.text
|
||||
: "",
|
||||
idCardNumber: state.isRequireAuth.value == true
|
||||
? state.idCardController.text
|
||||
: "");
|
||||
final AuthorizedAdminSendEntity entity = await ApiRepository.to
|
||||
.sendElectronicKey(
|
||||
createUser: state.isCreateUser.value ? '1' : '0',
|
||||
countryCode: state.countryCode.value,
|
||||
usernameType: '1',
|
||||
endDate: int.parse(endDate),
|
||||
faceAuthentication:
|
||||
state.isAuthentication.value == true ? '1' : '2',
|
||||
isCameraEnable: '2',
|
||||
isRemoteUnlock: '2',
|
||||
keyNameForAdmin: state.keyNameController.text,
|
||||
keyRight: '1',
|
||||
keyType: getKeyType,
|
||||
lockId: CommonDataManage().currentKeyInfo.lockId!.toString(),
|
||||
operatorUid: '',
|
||||
receiverUsername: state.emailOrPhoneController.text,
|
||||
remarks: '',
|
||||
startDate: int.parse(startDate),
|
||||
weekDays: state.weekdaysList,
|
||||
startTime: int.parse(startTime),
|
||||
endTime: int.parse(endTime),
|
||||
isOnlyManageSelf: state.onlyManageYouCreatesUser.value ? 1 : 0,
|
||||
realName: state.isRequireAuth.value == true
|
||||
? state.realNameController.text
|
||||
: '',
|
||||
idCardNumber: state.isRequireAuth.value == true
|
||||
? state.idCardController.text
|
||||
: '');
|
||||
if (entity.errorCode!.codeIsSuccessful) {
|
||||
state.isCreateUser.value = false;
|
||||
state.isSendSuccess.value = true;
|
||||
// Toast.show(msg: "添加成功");
|
||||
state.addUserId.value = entity.data!.receiverUser!.id.toString();
|
||||
// addUserConnectBlue(state.addUserId.value);
|
||||
keyId = entity.data!.keyId;
|
||||
eventBus.fire(AuthorizedAdminPageRefreshUI());
|
||||
} else {
|
||||
if (entity.errorCode == 425) {
|
||||
@ -218,16 +234,15 @@ class AuthorizedAdminLogic extends BaseGetXController {
|
||||
state.isCreateUser.value = true;
|
||||
ShowTipView().showIosTipWithContentDialog(
|
||||
'${"是否发送授权管理员给未注册账号".tr}\n${state.emailOrPhoneController.text}',
|
||||
() {
|
||||
sendElectronicKeyRequest();
|
||||
});
|
||||
sendElectronicKeyRequest);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//检测实名认证是否支持开启
|
||||
Future<void> keyCheckFace() async {
|
||||
AdvancedFunctionRecordEntity entity = await ApiRepository.to.keyCheckFace(
|
||||
final AdvancedFunctionRecordEntity entity =
|
||||
await ApiRepository.to.keyCheckFace(
|
||||
lockId: CommonDataManage().currentKeyInfo.lockId ?? 0,
|
||||
);
|
||||
if (entity.errorCode!.codeIsSuccessful) {
|
||||
@ -240,7 +255,7 @@ class AuthorizedAdminLogic extends BaseGetXController {
|
||||
titleStr: '实名认证为付费功能,请购买后再使用'.tr,
|
||||
sureClick: () {
|
||||
Get.toNamed(Routers.advancedFeaturesWebPage,
|
||||
arguments: {'isShop': false});
|
||||
arguments: <String, bool>{'isShop': false});
|
||||
});
|
||||
} else if (entity.errorCode == 433) {
|
||||
//需联系管理员购买
|
||||
@ -250,12 +265,12 @@ class AuthorizedAdminLogic extends BaseGetXController {
|
||||
|
||||
//标记房间为已入住 isOn:已入住: 1 空闲:2
|
||||
Future<void> updateRoomCheckIn() async {
|
||||
var entity = await ApiRepository.to.setRoomStatusData(
|
||||
final LoginEntity entity = await ApiRepository.to.setRoomStatusData(
|
||||
lockId: CommonDataManage().currentKeyInfo.lockId!,
|
||||
roomStatus: 1,
|
||||
);
|
||||
if (entity.errorCode!.codeIsSuccessful) {
|
||||
showToast("标记成功");
|
||||
showToast('标记成功');
|
||||
}
|
||||
}
|
||||
|
||||
@ -279,6 +294,31 @@ class AuthorizedAdminLogic extends BaseGetXController {
|
||||
return currentController;
|
||||
}
|
||||
|
||||
//发送消息
|
||||
Future<void> sendMsg({required bool isPhone}) async {
|
||||
if (keyId == null) {
|
||||
return;
|
||||
}
|
||||
final NoticeTemplateEntity entity = await ApiRepository.to
|
||||
.getNoticeTemplate(
|
||||
lockId: CommonDataManage().currentKeyInfo.lockId!,
|
||||
keyId: keyId!,
|
||||
channelType: isPhone ? 1 : 2);
|
||||
if (entity.errorCode!.codeIsSuccessful) {
|
||||
final List<Item?> list =
|
||||
entity.data!.list!.where((Item item) => item.isUse == 0).toList();
|
||||
if (list.isNotEmpty) {
|
||||
final Item item = list.first!;
|
||||
final String template = item.template ?? '';
|
||||
NativeInteractionTool().loadNativeShare(shareText: template);
|
||||
} else {
|
||||
showToast('获取模板失败 0x02');
|
||||
}
|
||||
} else {
|
||||
showToast('获取模板失败 0x01');
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
void onReady() {
|
||||
// TODO: implement onReady
|
||||
|
||||
@ -362,8 +362,7 @@ class _AuthorizedAdminPageState extends State<AuthorizedAdminPage>
|
||||
if (state.emailOrPhoneController.text.contains('@')) {
|
||||
Get.toNamed(Routers.sendEmailNotificationPage);
|
||||
} else {
|
||||
NativeInteractionTool()
|
||||
.loadNativeShare(shareText: state.pwdShareStr);
|
||||
logic.sendMsg(isPhone: true);
|
||||
}
|
||||
},
|
||||
),
|
||||
@ -373,8 +372,8 @@ class _AuthorizedAdminPageState extends State<AuthorizedAdminPage>
|
||||
OutLineBtn(
|
||||
btnName: '微信通知',
|
||||
onClick: () {
|
||||
NativeInteractionTool()
|
||||
.loadNativeShare(shareText: state.pwdShareStr);
|
||||
logic.sendMsg(
|
||||
isPhone: state.emailOrPhoneController.text.contains('@'));
|
||||
},
|
||||
),
|
||||
SizedBox(
|
||||
|
||||
@ -15,25 +15,25 @@ class AuthorizedAdminState {
|
||||
final FlutterContactPicker contactPicker = FlutterContactPicker();
|
||||
late Contact contact;
|
||||
|
||||
var isAuthentication = false.obs; //是否可以实名认证
|
||||
final onlyManageYouCreatesUser = false.obs; // 只能管理自己创建的用户
|
||||
RxBool isAuthentication = false.obs; //是否可以实名认证
|
||||
final RxBool onlyManageYouCreatesUser = false.obs; // 只能管理自己创建的用户
|
||||
|
||||
var beginDate = DateTool()
|
||||
RxString beginDate = DateTool()
|
||||
.dateToYMDHNString(DateTime.now().millisecondsSinceEpoch.toString())
|
||||
.obs; //默认为当前时间 开始时间
|
||||
var endDate = DateTool()
|
||||
RxString endDate = DateTool()
|
||||
.dateToYMDHNString(DateTime.now().millisecondsSinceEpoch.toString())
|
||||
.obs; //默认为当前时间 结束时间
|
||||
|
||||
var isSendSuccess = false.obs;
|
||||
var countryName = '中国'.obs;
|
||||
var countryCode = '86'.obs;
|
||||
var weekdaysList = [].obs;
|
||||
var isCreateUser = false.obs; //用户未注册时传1 已注册传0
|
||||
RxBool isSendSuccess = false.obs;
|
||||
RxString countryName = '中国'.obs;
|
||||
RxString countryCode = '86'.obs;
|
||||
RxList weekdaysList = [].obs;
|
||||
RxBool isCreateUser = false.obs; //用户未注册时传1 已注册传0
|
||||
|
||||
var seletType = 0.obs;
|
||||
RxInt seletType = 0.obs;
|
||||
String pwdShareStr = '您好,您的授权管理员生成成功';
|
||||
|
||||
var addUserId = ''.obs;
|
||||
var isRequireAuth = false.obs; //是否需要实名认证的必填项
|
||||
RxString addUserId = ''.obs;
|
||||
RxBool isRequireAuth = false.obs; //是否需要实名认证的必填项
|
||||
}
|
||||
|
||||
@ -2,7 +2,7 @@ import 'dart:ffi';
|
||||
|
||||
import 'package:flutter_easyloading/flutter_easyloading.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:star_lock/main/lockDetail/authorizedAdmin/volumeAuthorizationLock/notice_template_entity.dart';
|
||||
import 'package:star_lock/main/lockDetail/authorizedAdmin/authorizedAdmin/notice_template_entity.dart';
|
||||
import 'package:star_lock/main/lockDetail/lockSet/basicInformation/basicInformation/KeyDetailEntity.dart';
|
||||
import 'package:star_lock/network/api_repository.dart';
|
||||
import 'package:star_lock/tools/baseGetXController.dart';
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
import 'package:get/get.dart';
|
||||
import 'package:star_lock/blue/entity/lock_user_no_list_entity.dart';
|
||||
import 'package:star_lock/login/selectCountryRegion/common/countryRegionEntity.dart';
|
||||
import 'package:star_lock/main/lockDetail/authorizedAdmin/volumeAuthorizationLock/notice_template_entity.dart';
|
||||
import 'package:star_lock/main/lockDetail/authorizedAdmin/authorizedAdmin/notice_template_entity.dart';
|
||||
import 'package:star_lock/main/lockDetail/doorLockLog/doorLockLog_entity.dart';
|
||||
import 'package:star_lock/main/lockDetail/electronicKey/electronicKeyList/entity/ElectronicKeyListEntity.dart';
|
||||
import 'package:star_lock/main/lockDetail/electronicKey/massSendElectronicKey/massSendLockGroupList/lockUserList/lockUserList_entity.dart';
|
||||
|
||||
@ -1,34 +1,38 @@
|
||||
|
||||
import 'package:flutter/services.dart';
|
||||
|
||||
import '../app_settings/app_settings.dart';
|
||||
|
||||
///原生交互配置
|
||||
class NativeInteractionConfig{
|
||||
class NativeInteractionConfig {
|
||||
static String methodSendChannel = 'starLockFlutterSend';
|
||||
static String receiveEventChannel = 'starLockFlutterReceive';
|
||||
}
|
||||
|
||||
///原生交互flutter向原生发送消息
|
||||
typedef BlockBlueStatus = void Function(String status);
|
||||
class NativeInteractionTool{
|
||||
var sendChannel = MethodChannel(NativeInteractionConfig.methodSendChannel);
|
||||
var receiveChannel = MethodChannel(NativeInteractionConfig.receiveEventChannel);
|
||||
|
||||
class NativeInteractionTool {
|
||||
MethodChannel sendChannel =
|
||||
MethodChannel(NativeInteractionConfig.methodSendChannel);
|
||||
MethodChannel receiveChannel =
|
||||
MethodChannel(NativeInteractionConfig.receiveEventChannel);
|
||||
|
||||
///加载原生分享
|
||||
loadNativeShare({required String shareText}){
|
||||
sendChannel.invokeMethod('loadNativeShare', {'shareText':shareText});
|
||||
void loadNativeShare({required String shareText}) {
|
||||
sendChannel.invokeMethod(
|
||||
'loadNativeShare', <String, String>{'shareText': shareText});
|
||||
}
|
||||
|
||||
///获取设备蓝牙状态
|
||||
sendGetBlueStatus(){
|
||||
void sendGetBlueStatus() {
|
||||
sendChannel.invokeMethod('sendGetBlueStatus');
|
||||
}
|
||||
|
||||
///获取设备蓝牙是否打开
|
||||
receiveChannelBlueIsOnEvent(BlockBlueStatus blockBlueStatus){
|
||||
void receiveChannelBlueIsOnEvent(BlockBlueStatus blockBlueStatus) {
|
||||
receiveChannel.setMethodCallHandler((MethodCall call) async {
|
||||
AppLog.log('收到原生发送的信息call.method: ${call.method} call.arguments:${call.arguments}');
|
||||
AppLog.log(
|
||||
'收到原生发送的信息call.method: ${call.method} call.arguments:${call.arguments}');
|
||||
switch (call.method) {
|
||||
case 'getBlueStatus':
|
||||
// 获取设备蓝牙开启/关闭状态
|
||||
@ -42,5 +46,3 @@ class NativeInteractionTool{
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user