From 13ad3117c15c4f60c255be0de7cc07cff22ab2f8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=AD=8F=E5=B0=91=E9=98=B3?= <786612630@qq.com> Date: Thu, 12 Oct 2023 14:00:49 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E8=93=9D=E7=89=99=E5=8A=9F?= =?UTF-8?q?=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- star_lock/lib/blue/blue_manage.dart | 2 +- .../lcokSet/lockSet/lockSet_page.dart | 80 +++++++++++++------ .../lcokSet/lockTime/lockTime_logic.dart | 28 +++++-- .../lockDetail/lockDetail_logic.dart | 39 +++++++-- .../lockDetail/lockDetail_page.dart | 3 + .../mine/addLock/saveLock/saveLock_logic.dart | 2 +- star_lock/lib/tools/dateTool.dart | 2 - 7 files changed, 116 insertions(+), 40 deletions(-) diff --git a/star_lock/lib/blue/blue_manage.dart b/star_lock/lib/blue/blue_manage.dart index d757eba7..ba85c5e1 100644 --- a/star_lock/lib/blue/blue_manage.dart +++ b/star_lock/lib/blue/blue_manage.dart @@ -73,7 +73,7 @@ class BlueManage{ if(device.name.isEmpty){ return; } - print("startScanDevice:${device}"); + // print("startScanDevice:${device}"); // 判断是否 if(isScanAll == true){ if (((device.serviceUuids.isNotEmpty ? device.serviceUuids[0] : "").toString().contains("758824"))&& (device.rssi >= -100)) { diff --git a/star_lock/lib/main/lockDetail/lcokSet/lockSet/lockSet_page.dart b/star_lock/lib/main/lockDetail/lcokSet/lockSet/lockSet_page.dart index 523d4aa4..42600a58 100644 --- a/star_lock/lib/main/lockDetail/lcokSet/lockSet/lockSet_page.dart +++ b/star_lock/lib/main/lockDetail/lcokSet/lockSet/lockSet_page.dart @@ -53,6 +53,7 @@ class _LockSetPageState extends State with RouteAware { Expanded( child: ListView( children: [ + // 基本信息 CommonItem( leftTitel: TranslationLoader.lanKeys!.basicInformation!.tr, @@ -65,18 +66,20 @@ class _LockSetPageState extends State with RouteAware { }); }), SizedBox(height: 10.h,), + // 门磁 Visibility( visible: true, child:CommonItem( - leftTitel: TranslationLoader.lanKeys!.doorMagnetic!.tr, - rightTitle: "", - isHaveLine: true, - isHaveDirection: true, - action: () { - Get.toNamed(Routers.doorMagneticPage); - // Toast.show(msg: "功能暂未开放"); - }) + leftTitel: TranslationLoader.lanKeys!.doorMagnetic!.tr, + rightTitle: "", + isHaveLine: true, + isHaveDirection: true, + action: () { + // Get.toNamed(Routers.doorMagneticPage); + Toast.show(msg: "功能暂未开放"); + }) ), + // 无线键盘 Visibility( visible: true, child: CommonItem( @@ -86,11 +89,12 @@ class _LockSetPageState extends State with RouteAware { isHaveLine: false, isHaveDirection: true, action: () { - Get.toNamed(Routers.wirelessKeyboardPage); - // Toast.show(msg: "功能暂未开放"); + // Get.toNamed(Routers.wirelessKeyboardPage); + Toast.show(msg: "功能暂未开放"); }) ), SizedBox(height: 10.h), + // 自动闭锁 Obx(() => Visibility( visible: true, child: CommonItem( @@ -106,6 +110,7 @@ class _LockSetPageState extends State with RouteAware { arguments: state.getKeyInfosData.value); })) ), + // 锁声音 Obx(() { var titleStr = ""; if (state.getKeyInfosData.value.lockSound == 1) { @@ -142,6 +147,7 @@ class _LockSetPageState extends State with RouteAware { }) ); }), + // 防撬报警 Obx(() => Visibility( visible: true, child: CommonItem( @@ -156,6 +162,7 @@ class _LockSetPageState extends State with RouteAware { arguments: state.getKeyInfosData.value); }))), SizedBox(height: 10.h), + // 常开模式 Obx(() => Visibility( visible: true, child: CommonItem( @@ -171,6 +178,7 @@ class _LockSetPageState extends State with RouteAware { arguments: state.getKeyInfosData.value); })) ), + // 远程开锁 Obx(() => Visibility( visible:true, child: CommonItem( @@ -185,6 +193,7 @@ class _LockSetPageState extends State with RouteAware { arguments: state.getKeyInfosData.value); })) ), + // 重置键 Obx(() => Visibility( visible: true, child: CommonItem( @@ -210,16 +219,19 @@ class _LockSetPageState extends State with RouteAware { isHaveLine: true, isHaveRightWidget: true, rightWidget: - SizedBox(width: 60.w, child: _openCheckInSwitch()))), + SizedBox(width: 60.w, child: _otherUnHaveDoneSwitch()))), // ), // Obx(() => Visibility( - visible: true, - child: CommonItem( - leftTitel: '感应距离', - rightTitle: "远", - isHaveLine: true, - isHaveDirection: true, + visible: true, + child: CommonItem( + leftTitel: '感应距离', + rightTitle: "", + isHaveLine: true, + isHaveDirection: true, + action: () { + Toast.show(msg: "功能暂未开放"); + } )), // ), // Obx(() => @@ -231,7 +243,7 @@ class _LockSetPageState extends State with RouteAware { isHaveLine: true, isHaveRightWidget: true, rightWidget: - SizedBox(width: 60.w, child: _openCheckInSwitch()))), + SizedBox(width: 60.w, child: _otherUnHaveDoneSwitch()))), // ), // Obx(() => Visibility( @@ -242,7 +254,7 @@ class _LockSetPageState extends State with RouteAware { isHaveLine: true, isHaveRightWidget: true, rightWidget: - SizedBox(width: 60.w, child: _openCheckInSwitch()))), + SizedBox(width: 60.w, child: _otherUnHaveDoneSwitch()))), // ), // Obx(() => Visibility( @@ -253,26 +265,32 @@ class _LockSetPageState extends State with RouteAware { isHaveLine: true, isHaveRightWidget: true, rightWidget: - SizedBox(width: 60.w, child: _openCheckInSwitch()))), + SizedBox(width: 60.w, child: _otherUnHaveDoneSwitch()))), // ), // Obx(() => Visibility( visible: true, child: CommonItem( leftTitel: '开门方向设置', - rightTitle: "右开", + rightTitle: "", isHaveDirection: true, isHaveLine: true, + action: () { + Toast.show(msg: "功能暂未开放"); + } )), // ), // Obx(() => Visibility( visible: true, child: CommonItem( - leftTitel: '电机功率设置', - rightTitle: "大", - isHaveLine: true, - isHaveDirection: true, + leftTitel: '电机功率设置', + rightTitle: "", + isHaveLine: true, + isHaveDirection: true, + action: () { + Toast.show(msg: "功能暂未开放"); + } )), // ), SizedBox(height: 10.h), @@ -459,6 +477,18 @@ class _LockSetPageState extends State with RouteAware { ); } + CupertinoSwitch _otherUnHaveDoneSwitch() { + return CupertinoSwitch( + activeColor: CupertinoColors.activeBlue, + trackColor: CupertinoColors.systemGrey5, + thumbColor: CupertinoColors.white, + value: false, + onChanged: (value) { + Toast.show(msg: "功能暂未开放"); + }, + ); + } + void showCupertinoAlertDialog( BuildContext context, ) { diff --git a/star_lock/lib/main/lockDetail/lcokSet/lockTime/lockTime_logic.dart b/star_lock/lib/main/lockDetail/lcokSet/lockTime/lockTime_logic.dart index 2b4df7ae..311e4128 100644 --- a/star_lock/lib/main/lockDetail/lcokSet/lockTime/lockTime_logic.dart +++ b/star_lock/lib/main/lockDetail/lcokSet/lockTime/lockTime_logic.dart @@ -1,6 +1,7 @@ import 'dart:async'; +import 'package:date_format/date_format.dart'; import 'package:flutter_reactive_ble/flutter_reactive_ble.dart'; import '../../../../blue/blue_manage.dart'; @@ -53,8 +54,11 @@ class LockTimeLogic extends BaseGetXController{ (0xff & lockTime[2]) << 8 | (0xFF & lockTime[3])); - String dataEime = DateTool().dateToYMDHNSString("${value}"); + String dataEime = DateTool().dateToYMDHNSString("$value"); state.dateTime.value = dataEime; + + // String dataEime = DateTool().dateToYMDHNSString("${value}"); + // state.dateTime.value = dataEime; print("lockTime:$lockTime value:$value dataEime:$dataEime"); break; case 0x06: @@ -87,6 +91,17 @@ class LockTimeLogic extends BaseGetXController{ case 0x00: //成功 print("${reply.commandType}数据解析成功"); + // var lockTime = reply.data.sublist(4, 8); + // + // int value = ( + // (0xff & lockTime[(0)]) << 24 | + // (0xff & lockTime[1]) << 16 | + // (0xff & lockTime[2]) << 8 | + // (0xFF & lockTime[3])); + // + // String dataEime = DateTool().dateToYMDHNSString("$value"); + // state.dateTime.value = dataEime; + // _getLockStatus(); Toast.show(msg:"锁时间更新成功"); break; @@ -155,7 +170,7 @@ class LockTimeLogic extends BaseGetXController{ }); } - // 获取锁的常开模式设置 + // 从网关获取时间 void getLockTimeFromGateway() async{ var entity = await ApiRepository.to.getLockTimeFromGateway( lockId: state.getKeyInfosData.value.lockId.toString(), @@ -165,13 +180,13 @@ class LockTimeLogic extends BaseGetXController{ } } - // 获取锁的常开模式设置 + // 从服务器获取锁的时间 void getServerDatetime() async{ var entity = await ApiRepository.to.getServerDatetimeData( lockId: state.getKeyInfosData.value.lockId.toString(), ); if(entity.errorCode!.codeIsSuccessful){ - String dataEime = DateTool().dateToYMDHNSString("${int.parse(entity.data!.date.toString())~/1000}"); + String dataEime = DateTool().dateToYMDHNSString("${int.parse(entity.data!.date!)}"); state.dateTime.value = dataEime; sendTiming(); } @@ -184,7 +199,8 @@ class LockTimeLogic extends BaseGetXController{ print("onReady()"); _initReplySubscription(); - getLockTimeFromGateway(); + // getLockTimeFromGateway(); + getServerDatetime(); } @override @@ -193,7 +209,7 @@ class LockTimeLogic extends BaseGetXController{ super.onInit(); print("onInit()"); - _getLockStatus(); + // _getLockStatus(); } @override diff --git a/star_lock/lib/main/lockDetail/lockDetail/lockDetail_logic.dart b/star_lock/lib/main/lockDetail/lockDetail/lockDetail_logic.dart index c525ba4c..42ba20ac 100644 --- a/star_lock/lib/main/lockDetail/lockDetail/lockDetail_logic.dart +++ b/star_lock/lib/main/lockDetail/lockDetail/lockDetail_logic.dart @@ -3,6 +3,7 @@ import 'dart:async'; import 'dart:convert'; 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'; import 'package:star_lock/blue/io_protocol/io_factoryDataReset.dart'; import 'package:star_lock/blue/io_protocol/io_getLockStatu.dart'; @@ -500,17 +501,18 @@ class LockDetailLogic extends BaseGetXController{ privateKey:getPrivateKeyList, ); } - }, isShowLoading: false); + }, isShowLoading: true); } void startScanAction(){ BlueManage().startScan(true, (v){ - // print("startScanAllDevice:${v}"); + print("startScanAllDevice:${v}"); final knownDeviceIndex = v.indexWhere((d) => d.name == state.keyInfos.value.bluetooth!.bluetoothDeviceName!); // 当扫描到的时候 if (knownDeviceIndex >= 0) { - connectBlue(v[knownDeviceIndex].id, state.keyInfos.value.bluetooth!.bluetoothDeviceName!); BlueManage().connectDeviceMacAddress = v[knownDeviceIndex].id; + connectBlue(v[knownDeviceIndex].id, state.keyInfos.value.bluetooth!.bluetoothDeviceName!); + BlueManage().stopScan(); } }); } @@ -521,8 +523,16 @@ class LockDetailLogic extends BaseGetXController{ super.onReady(); print("onReady()"); _initReplySubscription(); - - startScanAction(); + getMicrophonePermission() + .then((value) { + if (value) { + // 有权限 + startScanAction(); + }else{ + //没有权限 + openAppSettings();//打开app系统设置 + } + }); } @override @@ -541,4 +551,23 @@ class LockDetailLogic extends BaseGetXController{ // TODO: implement onClose _replySubscription.cancel(); } + + ///请求录音相机权限 + Future getMicrophonePermission() async { + // You can request multiple permissions at once. + Map statuses = await [ + Permission.bluetoothScan, + Permission.bluetoothConnect, + Permission.location, + ].request(); + + //granted 通过,denied 被拒绝,permanentlyDenied 拒绝且不在提示 + if (statuses[Permission.bluetoothScan]!.isGranted && + statuses[Permission.bluetoothConnect]!.isGranted && + statuses[Permission.location]!.isGranted) { + return true; + } + return false; + } + } \ No newline at end of file diff --git a/star_lock/lib/main/lockDetail/lockDetail/lockDetail_page.dart b/star_lock/lib/main/lockDetail/lockDetail/lockDetail_page.dart index 3207ef57..aa4cf78c 100644 --- a/star_lock/lib/main/lockDetail/lockDetail/lockDetail_page.dart +++ b/star_lock/lib/main/lockDetail/lockDetail/lockDetail_page.dart @@ -61,6 +61,9 @@ class _LockDetailPageState extends State with RouteAware { state.keyInfos.value.bluetooth!.signKey!.cast(); var saveSignKeyList = changeIntListToStringList(signKeyData); Storage.setStringList(saveBlueSignKey, saveSignKeyList); + + // token + Storage.setStringList(saveBlueToken, ["0", "0", "0", "0"]); // print("publicKeyData:$publicKeyData saveStrList:$saveStrList privateKeyData:$privateKeyData savePrivateKeyList:$savePrivateKeyList"); // logic.startScanAction(); diff --git a/star_lock/lib/mine/addLock/saveLock/saveLock_logic.dart b/star_lock/lib/mine/addLock/saveLock/saveLock_logic.dart index 39b98fa2..1ddc88cf 100644 --- a/star_lock/lib/mine/addLock/saveLock/saveLock_logic.dart +++ b/star_lock/lib/mine/addLock/saveLock/saveLock_logic.dart @@ -386,7 +386,7 @@ class SaveLockLogic extends BaseGetXController { List signKeyDataList = changeStringListToIntList(signKey!); bluetooth['signKey'] = signKeyDataList; - print("addUser:publicKeyDataList$publicKeyDataList getPrivateKeyList:$getPrivateKeyList signKeyDataList:$signKeyDataList"); + // print("addUser:publicKeyDataList$publicKeyDataList getPrivateKeyList:$getPrivateKeyList signKeyDataList:$signKeyDataList"); var entity = await ApiRepository.to.bindingBlueAdmin( bindingDate:DateTime.now().millisecondsSinceEpoch.toString(), diff --git a/star_lock/lib/tools/dateTool.dart b/star_lock/lib/tools/dateTool.dart index be4f6473..b0f48d00 100644 --- a/star_lock/lib/tools/dateTool.dart +++ b/star_lock/lib/tools/dateTool.dart @@ -27,9 +27,7 @@ class DateTool { String dateToYMDHNSString(String timeDate){ int time = int.parse(timeDate); DateTime nowDate = DateTime.fromMillisecondsSinceEpoch(time); - String appointmentDate = formatDate(nowDate, [yyyy,'.',mm,'.',dd,' ',HH,':',nn ,':',ss]); - return appointmentDate; }