Merge branch 'master' of gitee.com:starlock-cn/app-starlock
This commit is contained in:
commit
e078a67af5
@ -27,6 +27,8 @@ PODS:
|
||||
- AMapFoundation (1.8.2)
|
||||
- AMapLocation (2.10.0):
|
||||
- AMapFoundation (>= 1.8.0)
|
||||
- audio_service (0.0.1):
|
||||
- Flutter
|
||||
- audio_session (0.0.1):
|
||||
- Flutter
|
||||
- audioplayers_darwin (0.0.1):
|
||||
@ -46,10 +48,6 @@ PODS:
|
||||
- Flutter
|
||||
- flutter_pcm_sound (0.0.1):
|
||||
- Flutter
|
||||
- flutter_sound (9.2.13):
|
||||
- Flutter
|
||||
- flutter_sound_core (= 9.2.13)
|
||||
- flutter_sound_core (9.2.13)
|
||||
- flutter_voice_processor (1.1.1):
|
||||
- Flutter
|
||||
- ios-voice-processor (~> 1.1.0)
|
||||
@ -111,6 +109,7 @@ DEPENDENCIES:
|
||||
- aliyun_push (from `.symlinks/plugins/aliyun_push/ios`)
|
||||
- amap_flutter_location (from `.symlinks/plugins/amap_flutter_location/ios`)
|
||||
- amap_flutter_map (from `.symlinks/plugins/amap_flutter_map/ios`)
|
||||
- audio_service (from `.symlinks/plugins/audio_service/ios`)
|
||||
- audio_session (from `.symlinks/plugins/audio_session/ios`)
|
||||
- audioplayers_darwin (from `.symlinks/plugins/audioplayers_darwin/ios`)
|
||||
- auto_orientation (from `.symlinks/plugins/auto_orientation/ios`)
|
||||
@ -120,7 +119,6 @@ DEPENDENCIES:
|
||||
- Flutter (from `Flutter`)
|
||||
- flutter_native_contact_picker (from `.symlinks/plugins/flutter_native_contact_picker/ios`)
|
||||
- flutter_pcm_sound (from `.symlinks/plugins/flutter_pcm_sound/ios`)
|
||||
- flutter_sound (from `.symlinks/plugins/flutter_sound/ios`)
|
||||
- flutter_voice_processor (from `.symlinks/plugins/flutter_voice_processor/ios`)
|
||||
- fluttertoast (from `.symlinks/plugins/fluttertoast/ios`)
|
||||
- g711_flutter (from `.symlinks/plugins/g711_flutter/ios`)
|
||||
@ -152,7 +150,6 @@ SPEC REPOS:
|
||||
- AMap3DMap
|
||||
- AMapFoundation
|
||||
- AMapLocation
|
||||
- flutter_sound_core
|
||||
- GoogleMaps
|
||||
- ios-voice-processor
|
||||
- Protobuf
|
||||
@ -169,6 +166,8 @@ EXTERNAL SOURCES:
|
||||
:path: ".symlinks/plugins/amap_flutter_location/ios"
|
||||
amap_flutter_map:
|
||||
:path: ".symlinks/plugins/amap_flutter_map/ios"
|
||||
audio_service:
|
||||
:path: ".symlinks/plugins/audio_service/ios"
|
||||
audio_session:
|
||||
:path: ".symlinks/plugins/audio_session/ios"
|
||||
audioplayers_darwin:
|
||||
@ -187,8 +186,6 @@ EXTERNAL SOURCES:
|
||||
:path: ".symlinks/plugins/flutter_native_contact_picker/ios"
|
||||
flutter_pcm_sound:
|
||||
:path: ".symlinks/plugins/flutter_pcm_sound/ios"
|
||||
flutter_sound:
|
||||
:path: ".symlinks/plugins/flutter_sound/ios"
|
||||
flutter_voice_processor:
|
||||
:path: ".symlinks/plugins/flutter_voice_processor/ios"
|
||||
fluttertoast:
|
||||
@ -239,6 +236,7 @@ SPEC CHECKSUMS:
|
||||
amap_flutter_map: 979e54d227cedac6c7504a2151bfbf3bcf96760a
|
||||
AMapFoundation: 9885c48fc3a78fdfb84a0299a2293e56ea3c9fec
|
||||
AMapLocation: 5248aec2455ebb5d104b367813c946430a2ee033
|
||||
audio_service: f509d65da41b9521a61f1c404dd58651f265a567
|
||||
audio_session: 4f3e461722055d21515cf3261b64c973c062f345
|
||||
audioplayers_darwin: 877d9a4d06331c5c374595e46e16453ac7eafa40
|
||||
auto_orientation: 102ed811a5938d52c86520ddd7ecd3a126b5d39d
|
||||
@ -249,8 +247,6 @@ SPEC CHECKSUMS:
|
||||
Flutter: f04841e97a9d0b0a8025694d0796dd46242b2854
|
||||
flutter_native_contact_picker: bd430ba0fbf82768bb50c2c52a69a65759a8f907
|
||||
flutter_pcm_sound: de0572ca4f99091cc2abfcc31601b8a4ddd33c0e
|
||||
flutter_sound: c60effa2a350fb977885f0db2fbc4c1ad5160900
|
||||
flutter_sound_core: 26c10e5832e76aaacfae252d8925232281c486ae
|
||||
flutter_voice_processor: 2b89b93d69b02227ae3fd58589ee0bcfa3ca2a82
|
||||
fluttertoast: 31b00dabfa7fb7bacd9e7dbee580d7a2ff4bf265
|
||||
g711_flutter: 8f2769052d2cf3549f83d11e1c42d81d94441123
|
||||
|
||||
@ -16,6 +16,8 @@ import 'baseWidget.dart';
|
||||
import 'tools/appRouteObserver.dart';
|
||||
import 'dart:io';
|
||||
|
||||
import 'versionUndate/versionUndateTool.dart';
|
||||
|
||||
class MyApp extends StatefulWidget {
|
||||
const MyApp({GlobalKey? key}) : super(key: key);
|
||||
|
||||
@ -99,7 +101,6 @@ class _MyAppState extends State<MyApp> with WidgetsBindingObserver, BaseWidget {
|
||||
super.initState();
|
||||
WidgetsBinding.instance.addObserver(this);
|
||||
|
||||
// openBlueScan();
|
||||
}
|
||||
|
||||
@override
|
||||
@ -127,10 +128,6 @@ void openBlueScan() {
|
||||
}
|
||||
}
|
||||
|
||||
// void startScanAction() {
|
||||
// BlueManage().startScan();
|
||||
// }
|
||||
|
||||
///请求蓝牙权限
|
||||
Future<bool> getMicrophonePermission() async {
|
||||
// You can request multiple permissions at once.
|
||||
|
||||
@ -106,7 +106,6 @@ class BlueManage {
|
||||
Get.log("开始扫描 蓝牙未开启,不能进行蓝牙操作");
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
/// 调用发送数据
|
||||
|
||||
@ -13,10 +13,6 @@ enum CommandType {
|
||||
getLockPublicKey, // 获取锁公钥 = 0x3090
|
||||
getLockPrivateKey, // 获取锁私钥 = 0x3091
|
||||
calibrationTime, // 校时 = 0x30f0
|
||||
synchronizingLocationInformation, // 同步位置信息 = 0x30f1
|
||||
opsUnlocks, // 运维开锁 0x30f2
|
||||
writeHotelInfo, // 写酒店信息 = 0x3016
|
||||
readHotelInfo, //读酒店信息 0x3017
|
||||
readStarLockStatusInfo, //读星锁状态信息 0x3040
|
||||
}
|
||||
|
||||
@ -85,31 +81,16 @@ extension ExtensionCommandType on CommandType {
|
||||
type = CommandType.calibrationTime;
|
||||
}
|
||||
break;
|
||||
case 0x30f1:
|
||||
{
|
||||
type = CommandType.synchronizingLocationInformation;
|
||||
}
|
||||
break;
|
||||
case 0x30f2:
|
||||
{
|
||||
type = CommandType.opsUnlocks;
|
||||
}
|
||||
break;
|
||||
case 0x3016:
|
||||
{
|
||||
type = CommandType.writeHotelInfo;
|
||||
}
|
||||
break;
|
||||
case 0x3017:
|
||||
{
|
||||
type = CommandType.readHotelInfo;
|
||||
}
|
||||
break;
|
||||
case 0x3040:
|
||||
{
|
||||
type = CommandType.readStarLockStatusInfo;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
{
|
||||
type = CommandType.readLockStatusInfo;
|
||||
}
|
||||
break;
|
||||
}
|
||||
return type;
|
||||
}
|
||||
@ -153,21 +134,12 @@ extension ExtensionCommandType on CommandType {
|
||||
case CommandType.calibrationTime:
|
||||
type = 0x30f0;
|
||||
break;
|
||||
case CommandType.synchronizingLocationInformation:
|
||||
type = 0x30f1;
|
||||
break;
|
||||
case CommandType.opsUnlocks:
|
||||
type = 0x30f2;
|
||||
break;
|
||||
case CommandType.writeHotelInfo:
|
||||
type = 0x3016;
|
||||
break;
|
||||
case CommandType.readHotelInfo:
|
||||
type = 0x3017;
|
||||
break;
|
||||
case CommandType.readStarLockStatusInfo:
|
||||
type = 0x3040;
|
||||
break;
|
||||
default:
|
||||
type = 0x300A;
|
||||
break;
|
||||
}
|
||||
// AppLog.log('数组组装指令类型:$name commandIndex:${IoManager
|
||||
// ().commandIndex}');
|
||||
@ -244,7 +216,9 @@ extension ExtensionCommandType on CommandType {
|
||||
case 0x3040:
|
||||
t = '读星锁状态信息';
|
||||
break;
|
||||
|
||||
default:
|
||||
t = '读星锁状态信息';
|
||||
break;
|
||||
}
|
||||
return t;
|
||||
}
|
||||
|
||||
@ -109,9 +109,12 @@ class CommandReciverManager {
|
||||
print("SM4 oriDataList:$oriDataList");
|
||||
break;
|
||||
}
|
||||
parseData(oriDataList).then((value) {
|
||||
parseData(oriDataList).then((value) async {
|
||||
print("parseData222 data:$value");
|
||||
EasyLoading.dismiss();
|
||||
EventBusManager().eventBusFir(value);
|
||||
await EventBusManager().eventBusFir(value);
|
||||
}).catchError((error) {
|
||||
print("Error occurred while parsing data: $error");
|
||||
});
|
||||
}
|
||||
// print('✅ 执行结束 _buffer:${_buffer.length}');
|
||||
@ -123,7 +126,7 @@ class CommandReciverManager {
|
||||
CommandType commandType = ExtensionCommandType.getCommandType(cmd);
|
||||
await IoManager().increaseCommandIndex();
|
||||
// data.removeRange(0, 2);
|
||||
// print("111111data cmd:$cmd commandType:$commandType data:$data");
|
||||
print("parseData cmd:$cmd commandType:$commandType data:$data");
|
||||
var reply;
|
||||
switch (commandType) {
|
||||
case CommandType.getLockPublicKey:
|
||||
@ -148,6 +151,7 @@ class CommandReciverManager {
|
||||
break;
|
||||
case CommandType.openLock:
|
||||
{
|
||||
print("openLockReply data:$data");
|
||||
reply = OpenDoorReply.parseData(commandType, data);
|
||||
}
|
||||
break;
|
||||
@ -381,6 +385,11 @@ class CommandReciverManager {
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
{
|
||||
reply = GetStarLockStatuInfoReply.parseData(commandType, data);
|
||||
}
|
||||
break;
|
||||
}
|
||||
return reply;
|
||||
}
|
||||
|
||||
@ -10,6 +10,8 @@ import 'app_settings/app_settings.dart';
|
||||
import 'tools/store_service.dart';
|
||||
import 'package:get/get.dart';
|
||||
|
||||
import 'versionUndate/versionUndateTool.dart';
|
||||
|
||||
// 该文件不可作为编译入口,请查看 flavorizr.yaml 中的说明
|
||||
FutureOr<void> main() async {
|
||||
await _setCommonServices();
|
||||
|
||||
@ -1,18 +1,14 @@
|
||||
import 'dart:async';
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_reactive_ble/flutter_reactive_ble.dart';
|
||||
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:intl/intl.dart';
|
||||
import 'package:permission_handler/permission_handler.dart';
|
||||
import 'package:star_lock/main/lockDetail/electronicKey/electronicKeyDetail/keyOperationRecord/keyOperationRecord_entity.dart';
|
||||
|
||||
import '../../../app_settings/app_colors.dart';
|
||||
import '../../../blue/blue_manage.dart';
|
||||
import '../../../blue/io_protocol/io_addUser.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';
|
||||
@ -46,9 +42,9 @@ class LockDetailLogic extends BaseGetXController {
|
||||
// }
|
||||
|
||||
// 获取星锁状态信息
|
||||
if (reply is GetStarLockStatuInfoReply && state.ifCurrentScreen.value == true) {
|
||||
_replyGetStarLockStatusInfo(reply);
|
||||
}
|
||||
// if (reply is GetStarLockStatuInfoReply && state.ifCurrentScreen.value == true) {
|
||||
// _replyGetStarLockStatusInfo(reply);
|
||||
// }
|
||||
|
||||
// 开完锁之后上传记录
|
||||
if (reply is SenderReferEventRecordTimeReply && state.ifCurrentScreen.value == true) {
|
||||
@ -65,7 +61,7 @@ class LockDetailLogic extends BaseGetXController {
|
||||
// 开门数据解析
|
||||
Future<void> _replyOpenLock(Reply reply) async {
|
||||
int status = reply.data[6];
|
||||
print("status:$status");
|
||||
print("replyOpenLock status:$status");
|
||||
|
||||
switch (status) {
|
||||
case 0x00:
|
||||
@ -74,7 +70,7 @@ class LockDetailLogic extends BaseGetXController {
|
||||
// _showFullScreenOverlay(Get.context!);
|
||||
|
||||
state.iSClosedUnlockSuccessfulPopup.value = true;
|
||||
if (state.closedUnlockSuccessfulTimer != null) {
|
||||
if (state.closedUnlockSuccessfulTimer != null ) {
|
||||
state.closedUnlockSuccessfulTimer!.cancel();
|
||||
state.closedUnlockSuccessfulTimer = null;
|
||||
}
|
||||
@ -82,6 +78,7 @@ class LockDetailLogic extends BaseGetXController {
|
||||
state.closedUnlockSuccessfulTimer = Timer.periodic(3.seconds, (timer) {
|
||||
state.iSClosedUnlockSuccessfulPopup.value = false;
|
||||
timer.cancel();
|
||||
eventBus.fire(RefreshLockDetailInfoDataEvent());
|
||||
});
|
||||
// Future.delayed(const Duration(seconds: 3), () {
|
||||
// state.iSClosedUnlockSuccessfulPopup.value = false;
|
||||
@ -94,8 +91,8 @@ class LockDetailLogic extends BaseGetXController {
|
||||
cancelBlueConnetctToastTimer();
|
||||
getLockRecordLastUploadDataTime();
|
||||
state.openLockBtnState.value = 0;
|
||||
// state.animationController.reset();
|
||||
// state.animationController.forward();
|
||||
|
||||
eventBus.fire(RefreshLockDetailInfoDataEvent());
|
||||
break;
|
||||
case 0x06:
|
||||
//无权限
|
||||
@ -139,6 +136,7 @@ class LockDetailLogic extends BaseGetXController {
|
||||
// 正在开锁中...
|
||||
print("${reply.commandType}正在开锁中...");
|
||||
state.openLockBtnState.value = 0;
|
||||
eventBus.fire(RefreshLockDetailInfoDataEvent());
|
||||
showToast("正在开锁中...", something: () {
|
||||
cancelBlueConnetctToastTimer();
|
||||
});
|
||||
@ -152,90 +150,90 @@ class LockDetailLogic extends BaseGetXController {
|
||||
}
|
||||
|
||||
// 获取锁状态数据解析
|
||||
Future<void> _replyGetStarLockStatusInfo(Reply reply) async {
|
||||
int status = reply.data[2];
|
||||
switch (status) {
|
||||
case 0x00:
|
||||
//成功
|
||||
print("${reply.commandType}数据解析成功");
|
||||
dismissEasyLoading();
|
||||
cancelBlueConnetctToastTimer();
|
||||
|
||||
// 厂商名称
|
||||
var vendor = reply.data.sublist(3, 23);
|
||||
// print("vendor:$vendor");
|
||||
|
||||
// 锁设备类型
|
||||
var product = reply.data[23];
|
||||
// print("product:$product");
|
||||
|
||||
// 产品名称
|
||||
var model = reply.data.sublist(24, 44);
|
||||
// print("model:$model");
|
||||
|
||||
// 软件版本
|
||||
var fwVersion = reply.data.sublist(44, 64);
|
||||
// print("fwVersion:$fwVersion");
|
||||
|
||||
// 硬件版本
|
||||
var hwVersion = reply.data.sublist(64, 84);
|
||||
// print("hwVersion:$hwVersion");
|
||||
|
||||
// 厂商序列号
|
||||
var serialNum0 = reply.data.sublist(84, 100);
|
||||
// print("serialNum0:$serialNum0");
|
||||
|
||||
// 成品商序列号
|
||||
var serialNum1 = reply.data.sublist(100, 116);
|
||||
// print("serialNum1:$serialNum1");
|
||||
|
||||
// 蓝牙名称
|
||||
var btDeviceName = reply.data.sublist(116, 132);
|
||||
// print("btDeviceName:$btDeviceName");
|
||||
|
||||
// 电池剩余电量
|
||||
var battRemCap = reply.data[132];
|
||||
// print("battRemCap:$battRemCap");
|
||||
uploadElectricQuantityRequest(battRemCap.toString());
|
||||
// 重置次数
|
||||
var restoreCounter = reply.data.sublist(133, 135);
|
||||
// print("restoreCounter:$restoreCounter");
|
||||
|
||||
// 重置时间
|
||||
var restoreDate = reply.data.sublist(135, 139);
|
||||
// print("restoreDate:$restoreDate");
|
||||
|
||||
// 主控芯片型号
|
||||
var icPartNo = reply.data.sublist(139, 149);
|
||||
// print("icPartNo:$icPartNo");
|
||||
|
||||
// 有效时间
|
||||
var indate = reply.data.sublist(149, 153);
|
||||
// print("indate:$indate");
|
||||
|
||||
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> _replyGetStarLockStatusInfo(Reply reply) async {
|
||||
// int status = reply.data[2];
|
||||
// switch (status) {
|
||||
// case 0x00:
|
||||
// //成功
|
||||
// print("${reply.commandType}数据解析成功");
|
||||
// dismissEasyLoading();
|
||||
// cancelBlueConnetctToastTimer();
|
||||
//
|
||||
// // 厂商名称
|
||||
// var vendor = reply.data.sublist(3, 23);
|
||||
// // print("vendor:$vendor");
|
||||
//
|
||||
// // 锁设备类型
|
||||
// var product = reply.data[23];
|
||||
// // print("product:$product");
|
||||
//
|
||||
// // 产品名称
|
||||
// var model = reply.data.sublist(24, 44);
|
||||
// // print("model:$model");
|
||||
//
|
||||
// // 软件版本
|
||||
// var fwVersion = reply.data.sublist(44, 64);
|
||||
// // print("fwVersion:$fwVersion");
|
||||
//
|
||||
// // 硬件版本
|
||||
// var hwVersion = reply.data.sublist(64, 84);
|
||||
// // print("hwVersion:$hwVersion");
|
||||
//
|
||||
// // 厂商序列号
|
||||
// var serialNum0 = reply.data.sublist(84, 100);
|
||||
// // print("serialNum0:$serialNum0");
|
||||
//
|
||||
// // 成品商序列号
|
||||
// var serialNum1 = reply.data.sublist(100, 116);
|
||||
// // print("serialNum1:$serialNum1");
|
||||
//
|
||||
// // 蓝牙名称
|
||||
// var btDeviceName = reply.data.sublist(116, 132);
|
||||
// // print("btDeviceName:$btDeviceName");
|
||||
//
|
||||
// // 电池剩余电量
|
||||
// var battRemCap = reply.data[132];
|
||||
// // print("battRemCap:$battRemCap");
|
||||
// // uploadElectricQuantityRequest(battRemCap.toString());
|
||||
// // 重置次数
|
||||
// var restoreCounter = reply.data.sublist(133, 135);
|
||||
// // print("restoreCounter:$restoreCounter");
|
||||
//
|
||||
// // 重置时间
|
||||
// var restoreDate = reply.data.sublist(135, 139);
|
||||
// // print("restoreDate:$restoreDate");
|
||||
//
|
||||
// // 主控芯片型号
|
||||
// var icPartNo = reply.data.sublist(139, 149);
|
||||
// // print("icPartNo:$icPartNo");
|
||||
//
|
||||
// // 有效时间
|
||||
// var indate = reply.data.sublist(149, 153);
|
||||
// // print("indate:$indate");
|
||||
//
|
||||
// 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> _replyReferEventRecordTime(Reply reply) async {
|
||||
@ -324,6 +322,7 @@ class LockDetailLogic extends BaseGetXController {
|
||||
} else {
|
||||
getLockNetToken();
|
||||
}
|
||||
eventBus.fire(RefreshLockDetailInfoDataEvent());
|
||||
// clickPushBtnAction();
|
||||
break;
|
||||
case 0x06:
|
||||
@ -373,8 +372,7 @@ class LockDetailLogic extends BaseGetXController {
|
||||
Future<void> addUserConnectBlue() async {
|
||||
showBlueConnetctToastTimer(action: () {
|
||||
state.openLockBtnState.value = 0;
|
||||
// state.animationController.reset();
|
||||
// state.animationController.forward();
|
||||
eventBus.fire(RefreshLockDetailInfoDataEvent());
|
||||
});
|
||||
|
||||
BlueManage()
|
||||
@ -417,8 +415,7 @@ class LockDetailLogic extends BaseGetXController {
|
||||
}
|
||||
|
||||
state.openLockBtnState.value = 0;
|
||||
// state.animationController.reset();
|
||||
// state.animationController.forward();
|
||||
eventBus.fire(RefreshLockDetailInfoDataEvent());
|
||||
}
|
||||
});
|
||||
}
|
||||
@ -428,9 +425,7 @@ class LockDetailLogic extends BaseGetXController {
|
||||
showBlueConnetctToastTimer(action: () {
|
||||
state.openLockBtnState.value = 0;
|
||||
BlueManage().stopScan();
|
||||
|
||||
// state.animationController.reset();
|
||||
// state.animationController.forward();
|
||||
eventBus.fire(RefreshLockDetailInfoDataEvent());
|
||||
});
|
||||
var privateKey = await Storage.getStringList(saveBluePrivateKey);
|
||||
List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
|
||||
@ -441,8 +436,7 @@ class LockDetailLogic extends BaseGetXController {
|
||||
var token = await Storage.getStringList(saveBlueToken);
|
||||
List<int> getTokenList = changeStringListToIntList(token!);
|
||||
|
||||
print(
|
||||
"openDoorTokenPubToken:$getTokenList getPrivateKeyList:$getPrivateKeyList");
|
||||
print("调用了开锁事件 openDoorTokenPubToken:$getTokenList getPrivateKeyList:$getPrivateKeyList");
|
||||
// List<int>listData = await IoSenderManage.senderOpenLock(
|
||||
// keyID: BlueManage().connectDeviceName,
|
||||
// userID: await Storage.getUid(),
|
||||
@ -476,8 +470,7 @@ class LockDetailLogic extends BaseGetXController {
|
||||
}
|
||||
|
||||
state.openLockBtnState.value = 0;
|
||||
// state.animationController.reset();
|
||||
// state.animationController.forward();
|
||||
eventBus.fire(RefreshLockDetailInfoDataEvent());
|
||||
}
|
||||
});
|
||||
}
|
||||
@ -542,31 +535,31 @@ class LockDetailLogic extends BaseGetXController {
|
||||
// }
|
||||
|
||||
// 获取锁状态 更新电量
|
||||
Future<void> getStarLockStatus() async {
|
||||
showEasyLoading();
|
||||
showBlueConnetctToastTimer(action: () {
|
||||
dismissEasyLoading();
|
||||
});
|
||||
BlueManage().bludSendData(BlueManage().connectDeviceName,
|
||||
(DeviceConnectionState deviceConnectionState) async {
|
||||
if (deviceConnectionState == DeviceConnectionState.connected) {
|
||||
dismissEasyLoading();
|
||||
var privateKey = await Storage.getStringList(saveBluePrivateKey);
|
||||
List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
|
||||
IoSenderManage.senderGetStarLockStatuInfo(
|
||||
lockID: BlueManage().connectDeviceName,
|
||||
userID: await Storage.getUid(),
|
||||
privateKey: getPrivateKeyList,
|
||||
);
|
||||
} else if (deviceConnectionState == DeviceConnectionState.disconnected) {
|
||||
dismissEasyLoading();
|
||||
cancelBlueConnetctToastTimer();
|
||||
if (state.ifCurrentScreen.value == true) {
|
||||
showBlueConnetctToast();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
// Future<void> getStarLockStatus() async {
|
||||
// showEasyLoading();
|
||||
// showBlueConnetctToastTimer(action: () {
|
||||
// dismissEasyLoading();
|
||||
// });
|
||||
// BlueManage().bludSendData(BlueManage().connectDeviceName,
|
||||
// (DeviceConnectionState deviceConnectionState) async {
|
||||
// if (deviceConnectionState == DeviceConnectionState.connected) {
|
||||
// dismissEasyLoading();
|
||||
// var privateKey = await Storage.getStringList(saveBluePrivateKey);
|
||||
// List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
|
||||
// IoSenderManage.senderGetStarLockStatuInfo(
|
||||
// lockID: BlueManage().connectDeviceName,
|
||||
// userID: await Storage.getUid(),
|
||||
// privateKey: getPrivateKeyList,
|
||||
// );
|
||||
// } else if (deviceConnectionState == DeviceConnectionState.disconnected) {
|
||||
// dismissEasyLoading();
|
||||
// cancelBlueConnetctToastTimer();
|
||||
// if (state.ifCurrentScreen.value == true) {
|
||||
// showBlueConnetctToast();
|
||||
// }
|
||||
// }
|
||||
// });
|
||||
// }
|
||||
|
||||
// 查询事件记录(时间查询)
|
||||
Future<void> senderReferEventRecordTime(int time) async {
|
||||
@ -597,52 +590,6 @@ class LockDetailLogic extends BaseGetXController {
|
||||
});
|
||||
}
|
||||
|
||||
//
|
||||
startOpenLock() {
|
||||
print("11111111");
|
||||
// checkBlueIsOpen((){
|
||||
print("33333333");
|
||||
if (state.openLockBtnState.value == 1) {
|
||||
return;
|
||||
}
|
||||
state.iSOpenLock.value = true;
|
||||
state.iSClosedUnlockSuccessfulPopup.value = false;
|
||||
state.openLockBtnState.value = 1;
|
||||
state.animationController.forward();
|
||||
|
||||
if (state.lockUserNo == 0) {
|
||||
// 电子钥匙lockUserNo为0 要先添加用户
|
||||
addUserConnectBlue();
|
||||
} else {
|
||||
print("state.isOpenLockNeedOnline.value:${state.isOpenLockNeedOnline.value}");
|
||||
if (state.isOpenLockNeedOnline.value == 0) {
|
||||
// 不需要联网
|
||||
openDoorAction(1);
|
||||
} else {
|
||||
// 需要联网
|
||||
getLockNetToken();
|
||||
}
|
||||
}
|
||||
// });
|
||||
}
|
||||
|
||||
startUnLock() {
|
||||
if (state.openLockBtnState.value == 1) {
|
||||
return;
|
||||
}
|
||||
state.iSOpenLock.value = false;
|
||||
state.iSClosedUnlockSuccessfulPopup.value = false;
|
||||
state.openLockBtnState.value = 1;
|
||||
state.animationController.forward();
|
||||
|
||||
if (state.lockUserNo == 0) {
|
||||
// 电子钥匙lockUserNo为0 要先添加用户
|
||||
addUserConnectBlue();
|
||||
} else {
|
||||
openDoorAction(32);
|
||||
}
|
||||
}
|
||||
|
||||
// // 0开锁 1长按闭锁 2密码 3卡 4指纹 5遥控 6人脸 7监控 8操作记录 9消息提醒 10设置
|
||||
// clickItemBtnAction(int type){
|
||||
// state.clickNextType = type;
|
||||
@ -731,16 +678,16 @@ class LockDetailLogic extends BaseGetXController {
|
||||
}
|
||||
|
||||
//电量更新请求
|
||||
Future<void> uploadElectricQuantityRequest(String electricQuantity) async {
|
||||
KeyOperationRecordEntity entity = await ApiRepository.to
|
||||
.uploadElectricQuantity(
|
||||
electricQuantity, state.keyInfos.value.lockId.toString());
|
||||
if (entity.errorCode!.codeIsSuccessful) {
|
||||
showToast("电量更新成功", something: () {
|
||||
eventBus.fire(RefreshLockListInfoDataEvent());
|
||||
});
|
||||
}
|
||||
}
|
||||
// Future<void> uploadElectricQuantityRequest(String electricQuantity) async {
|
||||
// KeyOperationRecordEntity entity = await ApiRepository.to
|
||||
// .uploadElectricQuantity(
|
||||
// electricQuantity, state.keyInfos.value.lockId.toString());
|
||||
// if (entity.errorCode!.codeIsSuccessful) {
|
||||
// showToast("电量更新成功", something: () {
|
||||
// eventBus.fire(RefreshLockListInfoDataEvent());
|
||||
// });
|
||||
// }
|
||||
// }
|
||||
|
||||
/// 锁设置里面开启关闭考勤刷新锁详情
|
||||
StreamSubscription?
|
||||
@ -771,91 +718,84 @@ class LockDetailLogic extends BaseGetXController {
|
||||
state.electricQuantity.value = int.parse(event.setResult);
|
||||
state.keyInfos.value.electricQuantity = int.parse(event.setResult);
|
||||
}
|
||||
eventBus.fire(RefreshLockDetailInfoDataEvent());
|
||||
});
|
||||
}
|
||||
|
||||
late StreamSubscription<List<DiscoveredDevice>>
|
||||
_scanListDiscoveredDeviceSubscription;
|
||||
void _scanListDiscoveredDeviceSubscriptionAction() {
|
||||
_scanListDiscoveredDeviceSubscription = EventBusManager()
|
||||
.eventBus!
|
||||
.on<List<DiscoveredDevice>>()
|
||||
.listen((List<DiscoveredDevice> list) {
|
||||
final knownDeviceIndex = list.indexWhere((d) =>
|
||||
d.name == state.keyInfos.value.bluetooth!.bluetoothDeviceName!);
|
||||
if (knownDeviceIndex >= 0) {
|
||||
// 存在的时候赋值
|
||||
state.currentDeviceUUid.value =
|
||||
(list[knownDeviceIndex].serviceUuids.isNotEmpty
|
||||
? list[knownDeviceIndex].serviceUuids[0]
|
||||
: "")
|
||||
.toString();
|
||||
}
|
||||
});
|
||||
}
|
||||
// late StreamSubscription<List<DiscoveredDevice>>
|
||||
// _scanListDiscoveredDeviceSubscription;
|
||||
// void _scanListDiscoveredDeviceSubscriptionAction() {
|
||||
// _scanListDiscoveredDeviceSubscription = EventBusManager().eventBus!.on<List<DiscoveredDevice>>().listen((List<DiscoveredDevice> list) {
|
||||
// final knownDeviceIndex = list.indexWhere((d) => d.name == state.keyInfos.value.bluetooth!.bluetoothDeviceName!);
|
||||
// if (knownDeviceIndex >= 0) {
|
||||
// // 存在的时候赋值
|
||||
// state.currentDeviceUUid.value = (list[knownDeviceIndex].serviceUuids.isNotEmpty ? list[knownDeviceIndex].serviceUuids[0] : "").toString();
|
||||
// }
|
||||
// });
|
||||
// }
|
||||
|
||||
//开锁成功弹出的小界面
|
||||
void _showFullScreenOverlay(BuildContext context) {
|
||||
Future.delayed(const Duration(seconds: 3), () {
|
||||
if (state.iSClosedUnlockSuccessfulPopup.value != true) {
|
||||
state.iSClosedUnlockSuccessfulPopup.value = true;
|
||||
Get.back();
|
||||
}
|
||||
});
|
||||
showModalBottomSheet(
|
||||
context: context,
|
||||
isScrollControlled: true,
|
||||
backgroundColor: Colors.transparent,
|
||||
builder: (BuildContext context) {
|
||||
return GestureDetector(
|
||||
onTap: () {
|
||||
if (state.iSClosedUnlockSuccessfulPopup.value != true) {
|
||||
state.iSClosedUnlockSuccessfulPopup.value = true;
|
||||
Get.back();
|
||||
}
|
||||
},
|
||||
child: Container(
|
||||
height: MediaQuery.of(context).size.height,
|
||||
width: MediaQuery.of(context).size.width,
|
||||
color: Colors.black.withOpacity(0.2),
|
||||
child: _unlockSuccessWidget(),
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
// void _showFullScreenOverlay(BuildContext context) {
|
||||
// Future.delayed(const Duration(seconds: 3), () {
|
||||
// if (state.iSClosedUnlockSuccessfulPopup.value != true) {
|
||||
// state.iSClosedUnlockSuccessfulPopup.value = true;
|
||||
// Get.back();
|
||||
// }
|
||||
// });
|
||||
// showModalBottomSheet(
|
||||
// context: context,
|
||||
// isScrollControlled: true,
|
||||
// backgroundColor: Colors.transparent,
|
||||
// builder: (BuildContext context) {
|
||||
// return GestureDetector(
|
||||
// onTap: () {
|
||||
// if (state.iSClosedUnlockSuccessfulPopup.value != true) {
|
||||
// state.iSClosedUnlockSuccessfulPopup.value = true;
|
||||
// Get.back();
|
||||
// }
|
||||
// },
|
||||
// child: Container(
|
||||
// height: MediaQuery.of(context).size.height,
|
||||
// width: MediaQuery.of(context).size.width,
|
||||
// color: Colors.black.withOpacity(0.2),
|
||||
// child: _unlockSuccessWidget(),
|
||||
// ),
|
||||
// );
|
||||
// },
|
||||
// );
|
||||
// }
|
||||
|
||||
Widget _unlockSuccessWidget() {
|
||||
return Stack(
|
||||
alignment: Alignment.center,
|
||||
children: [
|
||||
Image.asset(
|
||||
'images/main/unlocked_bg.png',
|
||||
width: 358.w,
|
||||
height: 348.h,
|
||||
),
|
||||
Positioned(
|
||||
top: ScreenUtil().screenHeight / 2,
|
||||
child: Column(
|
||||
children: [
|
||||
Text(
|
||||
state.keyInfos.value.lockAlias!,
|
||||
style: TextStyle(
|
||||
color: AppColors.placeholderTextColor, fontSize: 24.sp),
|
||||
),
|
||||
SizedBox(
|
||||
height: 10.h,
|
||||
),
|
||||
Text(
|
||||
getCurrentFormattedTime(),
|
||||
style: TextStyle(
|
||||
color: AppColors.darkGrayTextColor, fontSize: 24.sp),
|
||||
)
|
||||
],
|
||||
))
|
||||
],
|
||||
);
|
||||
}
|
||||
// Widget _unlockSuccessWidget() {
|
||||
// return Stack(
|
||||
// alignment: Alignment.center,
|
||||
// children: [
|
||||
// Image.asset(
|
||||
// 'images/main/unlocked_bg.png',
|
||||
// width: 358.w,
|
||||
// height: 348.h,
|
||||
// ),
|
||||
// Positioned(
|
||||
// top: ScreenUtil().screenHeight / 2,
|
||||
// child: Column(
|
||||
// children: [
|
||||
// Text(
|
||||
// state.keyInfos.value.lockAlias!,
|
||||
// style: TextStyle(
|
||||
// color: AppColors.placeholderTextColor, fontSize: 24.sp),
|
||||
// ),
|
||||
// SizedBox(
|
||||
// height: 10.h,
|
||||
// ),
|
||||
// Text(
|
||||
// getCurrentFormattedTime(),
|
||||
// style: TextStyle(
|
||||
// color: AppColors.darkGrayTextColor, fontSize: 24.sp),
|
||||
// )
|
||||
// ],
|
||||
// ))
|
||||
// ],
|
||||
// );
|
||||
// }
|
||||
|
||||
String getCurrentFormattedTime() {
|
||||
// 获取当前时间
|
||||
@ -905,10 +845,7 @@ class LockDetailLogic extends BaseGetXController {
|
||||
|
||||
_initReplySubscription();
|
||||
_initLockSetOpenOrCloseCheckInRefreshLockDetailWithAttendanceAction();
|
||||
_scanListDiscoveredDeviceSubscriptionAction();
|
||||
// Future.delayed(const Duration(seconds: 1)).then((value) {
|
||||
//
|
||||
// });
|
||||
// _scanListDiscoveredDeviceSubscriptionAction();
|
||||
}
|
||||
|
||||
@override
|
||||
@ -926,6 +863,7 @@ class LockDetailLogic extends BaseGetXController {
|
||||
|
||||
_replySubscription.cancel();
|
||||
_lockSetOpenOrCloseCheckInRefreshLockDetailWithAttendanceEvent!.cancel();
|
||||
_scanListDiscoveredDeviceSubscription.cancel();
|
||||
// _scanListDiscoveredDeviceSubscription.cancel();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -1,3 +1,5 @@
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
@ -11,6 +13,7 @@ import '../../../blue/blue_manage.dart';
|
||||
import '../../../blue/io_tool/io_tool.dart';
|
||||
import '../../../tools/appRouteObserver.dart';
|
||||
import '../../../tools/dateTool.dart';
|
||||
import '../../../tools/eventBusEventManage.dart';
|
||||
import '../../../tools/jh_pop_menus.dart';
|
||||
import '../../../tools/storage.dart';
|
||||
import '../../../translations/trans_lib.dart';
|
||||
@ -31,8 +34,7 @@ class LockDetailPage extends StatefulWidget {
|
||||
State<LockDetailPage> createState() => _LockDetailPageState();
|
||||
}
|
||||
|
||||
class _LockDetailPageState extends State<LockDetailPage>
|
||||
with TickerProviderStateMixin, RouteAware {
|
||||
class _LockDetailPageState extends State<LockDetailPage> with TickerProviderStateMixin, RouteAware {
|
||||
// with RouteAware
|
||||
final logic = Get.put(LockDetailLogic());
|
||||
final state = Get.find<LockDetailLogic>().state;
|
||||
@ -87,6 +89,16 @@ class _LockDetailPageState extends State<LockDetailPage>
|
||||
state.pageController.addListener(() {
|
||||
state.currentPage.value = state.pageController.page!.round();
|
||||
});
|
||||
|
||||
_initRefreshLockDetailInfoDataEventAction();
|
||||
}
|
||||
|
||||
StreamSubscription? _lockRefreshLockDetailInfoDataEvent;
|
||||
void _initRefreshLockDetailInfoDataEventAction() {
|
||||
// 蓝牙协议通知传输跟蓝牙之外的数据传输类不一样 eventBus
|
||||
_lockRefreshLockDetailInfoDataEvent = eventBus.on<RefreshLockDetailInfoDataEvent>().listen((event) {
|
||||
setState(() {});
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
@ -120,7 +132,7 @@ class _LockDetailPageState extends State<LockDetailPage>
|
||||
SizedBox(
|
||||
height: 10.h,
|
||||
),
|
||||
Obx(() => buildPageIndicator()),
|
||||
buildPageIndicator(),
|
||||
Expanded(
|
||||
child: Container(
|
||||
margin: EdgeInsets.only(left: 10.w, right: 10.w, top: 30.h),
|
||||
@ -129,8 +141,8 @@ class _LockDetailPageState extends State<LockDetailPage>
|
||||
controller: state.pageController,
|
||||
// child: Row(
|
||||
children: [
|
||||
Obx(() => bottomWidget()),
|
||||
Obx(() => attachmentWidget()),
|
||||
bottomWidget(),
|
||||
attachmentWidget(),
|
||||
],
|
||||
// ),
|
||||
),
|
||||
@ -138,12 +150,14 @@ class _LockDetailPageState extends State<LockDetailPage>
|
||||
],
|
||||
),
|
||||
),
|
||||
Obx(() => Visibility(
|
||||
Visibility(
|
||||
visible: state.iSClosedUnlockSuccessfulPopup.value,
|
||||
// visible: true,
|
||||
child: GestureDetector(
|
||||
onTap: () {
|
||||
state.iSClosedUnlockSuccessfulPopup.value = false;
|
||||
setState(() {
|
||||
state.iSClosedUnlockSuccessfulPopup.value = false;
|
||||
});
|
||||
},
|
||||
child: Container(
|
||||
width: 1.sw,
|
||||
@ -151,7 +165,7 @@ class _LockDetailPageState extends State<LockDetailPage>
|
||||
color: Colors.black.withOpacity(0.3),
|
||||
child: _unlockSuccessWidget()),
|
||||
),
|
||||
))
|
||||
)
|
||||
]),
|
||||
],
|
||||
);
|
||||
@ -166,7 +180,7 @@ class _LockDetailPageState extends State<LockDetailPage>
|
||||
children: [
|
||||
SizedBox(
|
||||
width: 1.sw - 120.w * 2,
|
||||
child: Obx(() => Center(
|
||||
child: Center(
|
||||
child: Text(
|
||||
state.lockAlias.value,
|
||||
style: TextStyle(
|
||||
@ -175,9 +189,9 @@ class _LockDetailPageState extends State<LockDetailPage>
|
||||
color: state.isOpenPassageMode.value == 1
|
||||
? AppColors.openPassageModeColor
|
||||
: AppColors.darkGrayTextColor),
|
||||
)))),
|
||||
))),
|
||||
Positioned(
|
||||
child: Obx(() => Column(
|
||||
child: Column(
|
||||
children: [
|
||||
GestureDetector(
|
||||
onTap: () {
|
||||
@ -233,7 +247,7 @@ class _LockDetailPageState extends State<LockDetailPage>
|
||||
],
|
||||
),
|
||||
],
|
||||
)))
|
||||
))
|
||||
],
|
||||
),
|
||||
SizedBox(height: 30.h),
|
||||
@ -245,7 +259,7 @@ class _LockDetailPageState extends State<LockDetailPage>
|
||||
children: [
|
||||
Center(
|
||||
child: GestureDetector(
|
||||
child: Obx(() => Stack(
|
||||
child: Stack(
|
||||
children: [
|
||||
Image.asset(
|
||||
// state.connectState.value == 0 ? 'images/main/icon_main_openLockBtn_grey.png' : 'images/main/icon_main_openLockBtn_center.png',
|
||||
@ -267,14 +281,19 @@ class _LockDetailPageState extends State<LockDetailPage>
|
||||
height: 330.w,
|
||||
)),
|
||||
],
|
||||
)),
|
||||
),
|
||||
onTap: () {
|
||||
// Get.log("点击开锁");
|
||||
logic.startOpenLock();
|
||||
setState(() {
|
||||
startOpenLock();
|
||||
});
|
||||
},
|
||||
onLongPressStart: (details) {
|
||||
Get.log("长按闭锁");
|
||||
logic.startUnLock();
|
||||
setState(() {
|
||||
startUnLock();
|
||||
});
|
||||
// startUnLock();
|
||||
},
|
||||
)),
|
||||
],
|
||||
@ -301,7 +320,7 @@ class _LockDetailPageState extends State<LockDetailPage>
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Obx(() => Text(
|
||||
Text(
|
||||
state.isOpenPassageMode.value == 1
|
||||
? "常开模式启动!长按闭锁"
|
||||
: TranslationLoader
|
||||
@ -310,7 +329,7 @@ class _LockDetailPageState extends State<LockDetailPage>
|
||||
fontSize: 22.sp,
|
||||
color: AppColors.btnDisableColor,
|
||||
fontWeight: FontWeight.w500),
|
||||
)),
|
||||
),
|
||||
],
|
||||
),
|
||||
SizedBox(
|
||||
@ -377,7 +396,7 @@ class _LockDetailPageState extends State<LockDetailPage>
|
||||
//设置动画的旋转中心
|
||||
alignment: Alignment.center,
|
||||
//动画控制器
|
||||
turns: state.animationController,
|
||||
turns: state.animationController!,
|
||||
//将要执行动画的子view
|
||||
child: Image.asset(
|
||||
state.isOpenPassageMode.value == 1
|
||||
@ -714,18 +733,17 @@ class _LockDetailPageState extends State<LockDetailPage>
|
||||
|
||||
listeningAnimations() async {
|
||||
await Future.delayed(Duration.zero, () {
|
||||
state.animationController = AnimationController(
|
||||
duration: const Duration(seconds: 1), vsync: this);
|
||||
state.animationController.repeat();
|
||||
state.animationController = AnimationController(duration: const Duration(seconds: 1), vsync: this);
|
||||
state.animationController!.repeat();
|
||||
//动画开始、结束、向前移动或向后移动时会调用StatusListener
|
||||
state.animationController.addStatusListener((status) {
|
||||
state.animationController!.addStatusListener((status) {
|
||||
// print("AnimationStatus:$status");
|
||||
if (status == AnimationStatus.completed) {
|
||||
state.animationController.reset();
|
||||
state.animationController.forward();
|
||||
state.animationController!.reset();
|
||||
state.animationController!.forward();
|
||||
} else if (status == AnimationStatus.dismissed) {
|
||||
state.animationController.reset();
|
||||
state.animationController.forward();
|
||||
state.animationController!.reset();
|
||||
state.animationController!.forward();
|
||||
}
|
||||
});
|
||||
});
|
||||
@ -831,6 +849,51 @@ class _LockDetailPageState extends State<LockDetailPage>
|
||||
);
|
||||
}
|
||||
|
||||
startOpenLock() {
|
||||
print("11111111");
|
||||
// checkBlueIsOpen((){
|
||||
print("33333333");
|
||||
if (state.openLockBtnState.value == 1) {
|
||||
return;
|
||||
}
|
||||
state.iSOpenLock.value = true;
|
||||
state.iSClosedUnlockSuccessfulPopup.value = false;
|
||||
state.openLockBtnState.value = 1;
|
||||
// state.animationController!.forward();
|
||||
|
||||
if (state.lockUserNo == 0) {
|
||||
// 电子钥匙lockUserNo为0 要先添加用户
|
||||
logic.addUserConnectBlue();
|
||||
} else {
|
||||
print("state.isOpenLockNeedOnline.value:${state.isOpenLockNeedOnline.value}");
|
||||
if (state.isOpenLockNeedOnline.value == 0) {
|
||||
// 不需要联网
|
||||
logic.openDoorAction(1);
|
||||
} else {
|
||||
// 需要联网
|
||||
logic.getLockNetToken();
|
||||
}
|
||||
}
|
||||
// });
|
||||
}
|
||||
|
||||
startUnLock() {
|
||||
if (state.openLockBtnState.value == 1) {
|
||||
return;
|
||||
}
|
||||
state.iSOpenLock.value = false;
|
||||
state.iSClosedUnlockSuccessfulPopup.value = false;
|
||||
state.openLockBtnState.value = 1;
|
||||
state.animationController!.forward();
|
||||
|
||||
if (state.lockUserNo == 0) {
|
||||
// 电子钥匙lockUserNo为0 要先添加用户
|
||||
logic.addUserConnectBlue();
|
||||
} else {
|
||||
logic.openDoorAction(32);
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
void didChangeDependencies() {
|
||||
// TODO: implement didChangeDependencies
|
||||
@ -844,13 +907,13 @@ class _LockDetailPageState extends State<LockDetailPage>
|
||||
void dispose() {
|
||||
// TODO: implement dispose
|
||||
/// 取消路由订阅
|
||||
// print("LockDetailPage===dispose");
|
||||
print("LockDetailPage===dispose");
|
||||
AppRouteObserver().routeObserver.unsubscribe(this);
|
||||
state.closedUnlockSuccessfulTimer?.cancel();
|
||||
_lockRefreshLockDetailInfoDataEvent?.cancel();
|
||||
if (state.animationController != null) {
|
||||
state.animationController.reset();
|
||||
state.animationController.forward();
|
||||
state.animationController.dispose();
|
||||
state.animationController!.dispose();
|
||||
// state.animationController = null;
|
||||
}
|
||||
super.dispose();
|
||||
}
|
||||
@ -886,20 +949,22 @@ class _LockDetailPageState extends State<LockDetailPage>
|
||||
void didPopNext() {
|
||||
super.didPopNext();
|
||||
state.ifCurrentScreen.value = true;
|
||||
// print("LockDetailPage===didPopNext");
|
||||
print("LockDetailPage===didPopNext");
|
||||
}
|
||||
|
||||
/// 进入下级界面 当前界面即将消失
|
||||
@override
|
||||
void didPushNext() {
|
||||
super.didPushNext();
|
||||
// print("LockDetailPage===didPushNext");
|
||||
print("LockDetailPage===didPushNext");
|
||||
state.ifCurrentScreen.value = false;
|
||||
logic.cancelBlueConnetctToastTimer();
|
||||
BlueManage().stopScan();
|
||||
state.openLockBtnState.value = 0;
|
||||
|
||||
state.animationController.reset();
|
||||
state.animationController.forward();
|
||||
if (state.animationController!.isAnimating) {
|
||||
state.animationController!.stop();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -28,7 +28,7 @@ class LockDetailState {
|
||||
var isOpenPassageMode = 0.obs; // 是否开启了常开模式
|
||||
var lockAlias = "".obs; // 锁名字
|
||||
|
||||
var currentDeviceUUid = "".obs; // 当前设备的uuid
|
||||
// var currentDeviceUUid = "".obs; // 当前设备的uuid
|
||||
|
||||
var ifCurrentScreen = true.obs; // 是否是当前界面,用于判断是否需要针对当前界面进行展示
|
||||
var iSClosedUnlockSuccessfulPopup = false.obs; // 是否关闭了开锁成功弹窗
|
||||
@ -38,7 +38,7 @@ class LockDetailState {
|
||||
var bottomBtnisUneable = false.obs; // 是否不可用 用于限制底部按钮是否可用
|
||||
|
||||
//过渡动画控制器
|
||||
late AnimationController animationController;
|
||||
AnimationController? animationController;
|
||||
// var lockState = 0.obs;// 0未连接普通状态 1连接开锁中(展示动画) 2已连接开锁成功 3检测可用性 4连接失败 5连接失败重连中
|
||||
var openLockBtnState = 0.obs; // 0普通状态(未转动) 1连接中(转动状态)
|
||||
// var connectState = 0.obs;// 0未连接 1连接
|
||||
|
||||
@ -59,7 +59,7 @@ class _UploadElectricQuantityPageState extends State<UploadElectricQuantityPage>
|
||||
)),
|
||||
],
|
||||
)),
|
||||
Obx(() => Row(
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
children: [
|
||||
Expanded(
|
||||
@ -68,7 +68,7 @@ class _UploadElectricQuantityPageState extends State<UploadElectricQuantityPage>
|
||||
style: TextStyle(fontSize: 20.sp),
|
||||
)),
|
||||
],
|
||||
)),
|
||||
),
|
||||
SizedBox(height: 10.h),
|
||||
Obx(() => Row(
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
|
||||
@ -1,7 +1,9 @@
|
||||
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:flutter_easyloading/flutter_easyloading.dart';
|
||||
import 'package:flutter_reactive_ble/flutter_reactive_ble.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:star_lock/blue/io_protocol/io_setSupportFunctionsNoParameters.dart';
|
||||
import 'package:star_lock/tools/baseGetXController.dart';
|
||||
import '../../../../blue/blue_manage.dart';
|
||||
@ -145,7 +147,7 @@ class BurglarAlarmLogic extends BaseGetXController{
|
||||
}
|
||||
state.sureBtnState.value = 1;
|
||||
|
||||
showEasyLoading();
|
||||
EasyLoading.show();
|
||||
showBlueConnetctToastTimer(action: (){
|
||||
dismissEasyLoading();
|
||||
state.sureBtnState.value = 0;
|
||||
@ -181,6 +183,32 @@ class BurglarAlarmLogic extends BaseGetXController{
|
||||
});
|
||||
}
|
||||
|
||||
Timer? _timer;
|
||||
// CancelableOperation? _operation;
|
||||
void showBlueConnetctToastTimer({bool isShowBlueConnetctToast = true, Function? action}) {
|
||||
if (_timer != null && _timer!.isActive) {
|
||||
_timer!.cancel();
|
||||
_timer = null;
|
||||
}
|
||||
_timer = Timer.periodic(15.seconds, (timer) {
|
||||
if (action != null) {
|
||||
action();
|
||||
}
|
||||
cancelBlueConnetctToastTimer();
|
||||
if (isShowBlueConnetctToast == true) {
|
||||
showBlueConnetctToast();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
void cancelBlueConnetctToastTimer() {
|
||||
Get.log('cancelBlueConnetctToastTimer');
|
||||
if (_timer != null && _timer!.isActive) {
|
||||
_timer!.cancel();
|
||||
_timer = null;
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
void onReady() {
|
||||
// TODO: implement onReady
|
||||
|
||||
@ -2,11 +2,14 @@ import 'dart:async';
|
||||
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/scheduler.dart';
|
||||
import 'package:flutter_reactive_ble/flutter_reactive_ble.dart';
|
||||
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:star_lock/blue/io_protocol/io_deletUser.dart';
|
||||
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_setSupportFunctionsNoParameters.dart';
|
||||
@ -14,6 +17,7 @@ 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 '../../../../mine/mineSet/authorizedAdministrator/authorizedAdminListEntity.dart';
|
||||
import '../../../../network/api_repository.dart';
|
||||
import '../../../../tools/baseGetXController.dart';
|
||||
import '../../../../tools/eventBusEventManage.dart';
|
||||
@ -36,9 +40,9 @@ class LockSetLogic extends BaseGetXController {
|
||||
_replySubscription =
|
||||
EventBusManager().eventBus!.on<Reply>().listen((reply) async {
|
||||
// 删除用户
|
||||
if (reply is DeletUserReply) {
|
||||
_replyDeletUserKey(reply);
|
||||
}
|
||||
// if (reply is DeletUserReply) {
|
||||
// _replyDeletUserKey(reply);
|
||||
// }
|
||||
|
||||
// 恢复出厂设置
|
||||
if (reply is FactoryDataResetReply) {
|
||||
@ -58,62 +62,62 @@ class LockSetLogic extends BaseGetXController {
|
||||
}
|
||||
|
||||
// 删除用户
|
||||
Future<void> _replyDeletUserKey(Reply reply) async {
|
||||
var tokenData = reply.data.sublist(2, 6);
|
||||
var saveStrList = changeIntListToStringList(tokenData);
|
||||
print("openDoorToken:$tokenData");
|
||||
Storage.setStringList(saveBlueToken, saveStrList);
|
||||
|
||||
int status = reply.data[6];
|
||||
print("status:$status");
|
||||
switch (status) {
|
||||
case 0x00:
|
||||
//成功
|
||||
print("${reply.commandType}解析成功");
|
||||
dismissEasyLoading();
|
||||
cancelBlueConnetctToastTimer();
|
||||
deletKeyData();
|
||||
break;
|
||||
case 0x06:
|
||||
//无权限
|
||||
print("${reply.commandType}需要鉴权");
|
||||
|
||||
var privateKey = await Storage.getStringList(saveBluePrivateKey);
|
||||
List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
|
||||
|
||||
var publicKey = await Storage.getStringList(saveBluePublicKey);
|
||||
List<int> publicKeyDataList = changeStringListToIntList(publicKey!);
|
||||
|
||||
IoSenderManage.deletUser(
|
||||
lockID: BlueManage().connectDeviceName,
|
||||
authUserID: await Storage.getUid(),
|
||||
keyID: "1",
|
||||
delUserID: await Storage.getUid(),
|
||||
needAuthor: 1,
|
||||
publicKey: publicKeyDataList,
|
||||
privateKey: getPrivateKeyList,
|
||||
token: tokenData);
|
||||
break;
|
||||
case 0x07:
|
||||
//无权限
|
||||
print("${reply.commandType!.typeValue} 用户无权限");
|
||||
dismissEasyLoading();
|
||||
showToast("用户无权限");
|
||||
break;
|
||||
case 0x09:
|
||||
// 权限校验错误
|
||||
print("${reply.commandType!.typeValue} ");
|
||||
dismissEasyLoading();
|
||||
showToast("权限校验错误");
|
||||
break;
|
||||
default:
|
||||
//失败
|
||||
print("${reply.commandType!.typeValue} 失败");
|
||||
dismissEasyLoading();
|
||||
showToast("删除失败");
|
||||
break;
|
||||
}
|
||||
}
|
||||
// Future<void> _replyDeletUserKey(Reply reply) async {
|
||||
// var tokenData = reply.data.sublist(2, 6);
|
||||
// var saveStrList = changeIntListToStringList(tokenData);
|
||||
// print("openDoorToken:$tokenData");
|
||||
// Storage.setStringList(saveBlueToken, saveStrList);
|
||||
//
|
||||
// int status = reply.data[6];
|
||||
// print("status:$status");
|
||||
// switch (status) {
|
||||
// case 0x00:
|
||||
// //成功
|
||||
// print("${reply.commandType}解析成功");
|
||||
// dismissEasyLoading();
|
||||
// cancelBlueConnetctToastTimer();
|
||||
// deletKeyData();
|
||||
// break;
|
||||
// case 0x06:
|
||||
// //无权限
|
||||
// print("${reply.commandType}需要鉴权");
|
||||
//
|
||||
// var privateKey = await Storage.getStringList(saveBluePrivateKey);
|
||||
// List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
|
||||
//
|
||||
// var publicKey = await Storage.getStringList(saveBluePublicKey);
|
||||
// List<int> publicKeyDataList = changeStringListToIntList(publicKey!);
|
||||
//
|
||||
// IoSenderManage.deletUser(
|
||||
// lockID: BlueManage().connectDeviceName,
|
||||
// authUserID: await Storage.getUid(),
|
||||
// keyID: "1",
|
||||
// delUserID: await Storage.getUid(),
|
||||
// needAuthor: 1,
|
||||
// publicKey: publicKeyDataList,
|
||||
// privateKey: getPrivateKeyList,
|
||||
// token: tokenData);
|
||||
// break;
|
||||
// case 0x07:
|
||||
// //无权限
|
||||
// print("${reply.commandType!.typeValue} 用户无权限");
|
||||
// dismissEasyLoading();
|
||||
// showToast("用户无权限");
|
||||
// break;
|
||||
// case 0x09:
|
||||
// // 权限校验错误
|
||||
// print("${reply.commandType!.typeValue} ");
|
||||
// dismissEasyLoading();
|
||||
// showToast("权限校验错误");
|
||||
// break;
|
||||
// default:
|
||||
// //失败
|
||||
// print("${reply.commandType!.typeValue} 失败");
|
||||
// dismissEasyLoading();
|
||||
// showToast("删除失败");
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
|
||||
// 恢复出厂设置数据解析
|
||||
Future<void> _replyFactoryDataResetKey(Reply reply) async {
|
||||
@ -264,46 +268,46 @@ class LockSetLogic extends BaseGetXController {
|
||||
}
|
||||
|
||||
// 删除用户
|
||||
Future<void> deletUserAction() async {
|
||||
showEasyLoading();
|
||||
showBlueConnetctToastTimer(isShowBlueConnetctToast: false, action: (){
|
||||
dismissEasyLoading();
|
||||
// print("1111111");
|
||||
showDeletAlertTipDialog();
|
||||
});
|
||||
BlueManage().bludSendData(BlueManage().connectDeviceName, (DeviceConnectionState connectionState) async {
|
||||
if (connectionState == DeviceConnectionState.connected) {
|
||||
var privateKey = await Storage.getStringList(saveBluePrivateKey);
|
||||
List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
|
||||
|
||||
var publicKey = await Storage.getStringList(saveBluePublicKey);
|
||||
List<int> publicKeyDataList = changeStringListToIntList(publicKey!);
|
||||
|
||||
var token = await Storage.getStringList(saveBlueToken);
|
||||
List<int> getTokenList = changeStringListToIntList(token!);
|
||||
|
||||
IoSenderManage.deletUser(
|
||||
lockID: BlueManage().connectDeviceName,
|
||||
authUserID: state.lockBasicInfo.value.senderUserId.toString(),
|
||||
keyID: state.lockBasicInfo.value.keyId.toString(),
|
||||
delUserID: await Storage.getUid(),
|
||||
// authUserID: "100001",
|
||||
// keyID: "1",
|
||||
// delUserID: "100001",
|
||||
needAuthor: 1,
|
||||
publicKey: publicKeyDataList,
|
||||
privateKey: getPrivateKeyList,
|
||||
token: getTokenList);
|
||||
} else if (connectionState == DeviceConnectionState.disconnected) {
|
||||
dismissEasyLoading();
|
||||
cancelBlueConnetctToastTimer();
|
||||
print("222222");
|
||||
if(state.ifCurrentScreen.value == true){
|
||||
showDeletAlertTipDialog();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
// Future<void> deletUserAction() async {
|
||||
// showEasyLoading();
|
||||
// showBlueConnetctToastTimer(isShowBlueConnetctToast: false, action: (){
|
||||
// dismissEasyLoading();
|
||||
// // print("1111111");
|
||||
// showDeletAlertTipDialog();
|
||||
// });
|
||||
// BlueManage().bludSendData(BlueManage().connectDeviceName, (DeviceConnectionState connectionState) async {
|
||||
// if (connectionState == DeviceConnectionState.connected) {
|
||||
// var privateKey = await Storage.getStringList(saveBluePrivateKey);
|
||||
// List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
|
||||
//
|
||||
// var publicKey = await Storage.getStringList(saveBluePublicKey);
|
||||
// List<int> publicKeyDataList = changeStringListToIntList(publicKey!);
|
||||
//
|
||||
// var token = await Storage.getStringList(saveBlueToken);
|
||||
// List<int> getTokenList = changeStringListToIntList(token!);
|
||||
//
|
||||
// IoSenderManage.deletUser(
|
||||
// lockID: BlueManage().connectDeviceName,
|
||||
// authUserID: state.lockBasicInfo.value.senderUserId.toString(),
|
||||
// keyID: state.lockBasicInfo.value.keyId.toString(),
|
||||
// delUserID: await Storage.getUid(),
|
||||
// // authUserID: "100001",
|
||||
// // keyID: "1",
|
||||
// // delUserID: "100001",
|
||||
// needAuthor: 1,
|
||||
// publicKey: publicKeyDataList,
|
||||
// privateKey: getPrivateKeyList,
|
||||
// token: getTokenList);
|
||||
// } else if (connectionState == DeviceConnectionState.disconnected) {
|
||||
// dismissEasyLoading();
|
||||
// cancelBlueConnetctToastTimer();
|
||||
// print("222222");
|
||||
// if(state.ifCurrentScreen.value == true){
|
||||
// showDeletAlertTipDialog();
|
||||
// }
|
||||
// }
|
||||
// });
|
||||
// }
|
||||
|
||||
// 恢复出厂设置
|
||||
Future<void> factoryDataResetAction() async {
|
||||
@ -445,177 +449,6 @@ class LockSetLogic extends BaseGetXController {
|
||||
return entity;
|
||||
}
|
||||
|
||||
// 当是锁拥有者的时候,删除锁
|
||||
void deletLockInfoData() async {
|
||||
var entity = await ApiRepository.to.deletOwnerLockData(
|
||||
lockId: state.lockSetInfoData.value.lockId.toString(),
|
||||
);
|
||||
if (entity.errorCode!.codeIsSuccessful) {
|
||||
BlueManage().connectDeviceMacAddress = "";
|
||||
eventBus.fire(RefreshLockListInfoDataEvent());
|
||||
if(state.isOnlyOneData.value == true){
|
||||
Future.delayed(const Duration(milliseconds: 200)).then((e) {
|
||||
Get.close(1);
|
||||
});
|
||||
}else{
|
||||
Future.delayed(const Duration(milliseconds: 200)).then((e) {
|
||||
Get.close(2);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 当不是锁拥有者的时候,删除钥匙
|
||||
void deletKeyData() async {
|
||||
var entity = await ApiRepository.to.deletOwnerKeyData(
|
||||
lockId: state.lockSetInfoData.value.lockId.toString(),
|
||||
keyId: state.lockSetInfoData.value.lockBasicInfo!.keyId.toString(),
|
||||
);
|
||||
if (entity.errorCode!.codeIsSuccessful) {
|
||||
BlueManage().connectDeviceMacAddress = "";
|
||||
eventBus.fire(RefreshLockListInfoDataEvent());
|
||||
if(state.isOnlyOneData.value == true){
|
||||
Future.delayed(const Duration(milliseconds: 200)).then((e) {
|
||||
Get.close(1);
|
||||
});
|
||||
}else{
|
||||
Future.delayed(const Duration(milliseconds: 200)).then((e) {
|
||||
Get.close(2);
|
||||
});
|
||||
}
|
||||
// Get.offAllNamed(Routers.starLockMain);
|
||||
}
|
||||
}
|
||||
|
||||
void showDeletPasswordAlertDialog(BuildContext context) {
|
||||
// 点击删除 开始扫描
|
||||
BlueManage().startScan();
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (BuildContext context) {
|
||||
return ShowTFView(
|
||||
title: "请输入登录密码",
|
||||
tipTitle: "",
|
||||
controller: state.passwordTF,
|
||||
sureClick: () {
|
||||
//发送删除锁请求
|
||||
if (state.passwordTF.text.isEmpty) {
|
||||
showToast("请输入登录密码");
|
||||
return;
|
||||
}
|
||||
checkLoginPassword();
|
||||
},
|
||||
cancelClick: () {
|
||||
// 取消的时候停止扫描
|
||||
BlueManage().stopScan();
|
||||
Get.back();
|
||||
},
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
// 查询账户密码
|
||||
void checkLoginPassword() async {
|
||||
var entity = await ApiRepository.to.checkLoginPassword(
|
||||
password: state.passwordTF.text,
|
||||
);
|
||||
if (entity.errorCode!.codeIsSuccessful) {
|
||||
Get.back();
|
||||
|
||||
if(BlueManage().deviceConnectionState == DeviceConnectionState.connected){
|
||||
// 如果是已连接状态 直接调用协议
|
||||
// 已配对 表示这把锁未被初始化,还处于被添加状态
|
||||
if (state.lockSetInfoData.value.lockBasicInfo!.isLockOwner == 1) {
|
||||
// 如果是锁拥有者直接删除锁,调用初始化协议
|
||||
factoryDataResetAction();
|
||||
} else {
|
||||
// 不是锁拥有者
|
||||
if(state.lockSetInfoData.value.lockBasicInfo!.lockUserNo != 0){
|
||||
// 如果已经创建了用户调用协议删除
|
||||
deletUserAction();
|
||||
}else{
|
||||
// 如果没有创建用户 调用接口删除
|
||||
deletKeyData();
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (state.currentDeviceUUid.value.isNotEmpty) {
|
||||
// 已经扫描到了当前设备 停止扫描,直接删除锁
|
||||
BlueManage().stopScan();
|
||||
deletLockLogic();
|
||||
} else {
|
||||
// 未扫描到 然后循环5秒扫秒
|
||||
var index = 0;
|
||||
showEasyLoading();
|
||||
state.deletWaitScanCompleter = Completer();
|
||||
state.deletWaitScanTimer = Timer.periodic(const Duration(seconds: 1), (timer) {
|
||||
//定时任务
|
||||
if(index >= 7){
|
||||
// 当超过10秒的时候还是没有搜索到,完成任务,关闭扫描,取消定时器,弹窗提示
|
||||
if(state.deletWaitScanTimer != null){
|
||||
state.deletWaitScanTimer!.cancel();
|
||||
}
|
||||
if(state.deletWaitScanCompleter != null){
|
||||
state.deletWaitScanCompleter!.complete();
|
||||
}
|
||||
BlueManage().stopScan();
|
||||
dismissEasyLoading();
|
||||
print("555555");
|
||||
showDeletAlertTipDialog();
|
||||
}else{
|
||||
// 每秒判断获取是否搜到了当前设备
|
||||
if (state.currentDeviceUUid.isNotEmpty) {
|
||||
BlueManage().stopScan();
|
||||
// 存在的时候销毁定时器,赋值
|
||||
if(state.deletWaitScanTimer != null){
|
||||
state.deletWaitScanTimer!.cancel();
|
||||
}
|
||||
if(state.deletWaitScanCompleter != null){
|
||||
state.deletWaitScanCompleter!.complete();
|
||||
}
|
||||
dismissEasyLoading();
|
||||
|
||||
deletLockLogic();
|
||||
} else {
|
||||
// 不存在的时候返回-1 然后循环5秒
|
||||
index++;
|
||||
// print("index:$index");
|
||||
}
|
||||
}
|
||||
});
|
||||
// 等待Completer完成
|
||||
await state.deletWaitScanCompleter!.future;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void deletLockLogic() {
|
||||
// 当扫描的数组里面是否有当前设备
|
||||
if(state.currentDeviceUUid.value[31] == "1"){
|
||||
// 已配对 表示这把锁未被初始化,还处于被添加状态
|
||||
if (state.lockSetInfoData.value.lockBasicInfo!.isLockOwner == 1) {
|
||||
// 如果是锁拥有者直接删除锁,调用初始化协议
|
||||
factoryDataResetAction();
|
||||
} else {
|
||||
// 不是锁拥有者
|
||||
if(state.lockSetInfoData.value.lockBasicInfo!.lockUserNo != 0){
|
||||
// 如果已经创建了用户调用协议删除
|
||||
deletUserAction();
|
||||
}else{
|
||||
// 如果没有创建用户 调用接口删除
|
||||
deletKeyData();
|
||||
}
|
||||
}
|
||||
}else if(state.currentDeviceUUid.value[31] == "0"){
|
||||
// 未配对 表示这把锁已被强制初始化 处于可添加状态 直接弹窗删除即可
|
||||
print("666666");
|
||||
showDeletAlertTipDialog(showContent:"当前锁已被强制初始化,可直接添加。");
|
||||
}
|
||||
}
|
||||
|
||||
// 开启考勤获取是否有公司
|
||||
void openCheckingInData(BlockSetCheckInCallback blockSetCheckInCallback) async {
|
||||
var entity = await ApiRepository.to.openCheckingInData(
|
||||
@ -701,8 +534,8 @@ class LockSetLogic extends BaseGetXController {
|
||||
}
|
||||
|
||||
void showDeletAlertTipDialog({String? showContent = ""}) {
|
||||
bool isContains = BlueManage().connectDeviceName!.contains("T9A");
|
||||
var content = showContent!.isEmpty ? "删除设备失败,请确保在设备附近,设备未被连接,设备已打开${isContains == true ? "。如果是全自动锁,请使屏幕变亮" : ""}" : showContent;
|
||||
// bool isContains = BlueManage().connectDeviceName!.contains("T9A");
|
||||
var content = showContent!.isEmpty ? "删除设备失败,请确保在设备附近,设备未被连接,设备已打开${BlueManage().connectDeviceName!.contains("T9A") == true ? "。如果是全自动锁,请使屏幕变亮" : ""}" : showContent;
|
||||
showCupertinoDialog(
|
||||
context: Get.context!,
|
||||
builder: (context) {
|
||||
@ -736,6 +569,305 @@ class LockSetLogic extends BaseGetXController {
|
||||
);
|
||||
}
|
||||
|
||||
//确认弹窗
|
||||
void showCupertinoAlertDialog(widgetContext) {
|
||||
showCupertinoDialog(
|
||||
context: widgetContext,
|
||||
builder: (context) {
|
||||
return CupertinoAlertDialog(
|
||||
title: const Text("提示"),
|
||||
content: const Text('创建公司后,考勤功能才能使用'),
|
||||
actions: [
|
||||
CupertinoDialogAction(
|
||||
child: Text(TranslationLoader.lanKeys!.cancel!.tr),
|
||||
onPressed: () {
|
||||
Get.back();
|
||||
},
|
||||
),
|
||||
CupertinoDialogAction(
|
||||
child: Text(TranslationLoader.lanKeys!.sure!.tr),
|
||||
onPressed: () {
|
||||
Navigator.pop(context);
|
||||
Get.toNamed(Routers.checkInCreatCompanyPage, arguments: {
|
||||
'lockSetInfoData': state.lockSetInfoData.value
|
||||
});
|
||||
},
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
/// 以下为删除逻辑
|
||||
deleyLockLogicOfRoles(){
|
||||
if (state.lockBasicInfo.value.isLockOwner == 1) {
|
||||
// 超级管理员必须通过连接蓝牙删除
|
||||
showDeletAlertDialog();
|
||||
} else if (state.lockBasicInfo.value.keyRight == 1){
|
||||
// 授权管理员弹框提示
|
||||
showDeleteAdministratorIsHaveAllDataDialog();
|
||||
} else{
|
||||
// 普通用户直接删除
|
||||
deletKeyData();
|
||||
}
|
||||
}
|
||||
|
||||
//超级管理员 删除弹窗
|
||||
void showDeletAlertDialog() {
|
||||
showCupertinoDialog(
|
||||
context: Get.context!,
|
||||
builder: (context) {
|
||||
return CupertinoAlertDialog(
|
||||
title: const Text("提示"),
|
||||
content: const Text('删除锁后,所有信息都会一起删除,确定删除锁吗?'),
|
||||
actions: [
|
||||
CupertinoDialogAction(
|
||||
child: Text(TranslationLoader.lanKeys!.cancel!.tr),
|
||||
onPressed: () {
|
||||
Get.back();
|
||||
},
|
||||
),
|
||||
CupertinoDialogAction(
|
||||
child: Text(TranslationLoader.lanKeys!.sure!.tr),
|
||||
onPressed: () {
|
||||
Get.back();
|
||||
showDeletPasswordAlertDialog(context);
|
||||
},
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
void showDeletPasswordAlertDialog(BuildContext context) {
|
||||
// 点击删除 开始扫描
|
||||
BlueManage().startScan();
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (BuildContext context) {
|
||||
return ShowTFView(
|
||||
title: "请输入登录密码",
|
||||
tipTitle: "",
|
||||
controller: state.passwordTF,
|
||||
sureClick: () {
|
||||
//发送删除锁请求
|
||||
if (state.passwordTF.text.isEmpty) {
|
||||
showToast("请输入登录密码");
|
||||
return;
|
||||
}
|
||||
checkLoginPassword();
|
||||
},
|
||||
cancelClick: () {
|
||||
// 取消的时候停止扫描
|
||||
BlueManage().stopScan();
|
||||
Get.back();
|
||||
},
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
// 授权管理员调用删除数据
|
||||
void showDeleteAdministratorIsHaveAllDataDialog() {
|
||||
showDialog(
|
||||
context: Get.context!,
|
||||
builder: (BuildContext context) {
|
||||
return CupertinoAlertDialog(
|
||||
title: const Text("提示"),
|
||||
content: Container(
|
||||
height: 100.h,
|
||||
child: Row(
|
||||
children: [
|
||||
GestureDetector(
|
||||
onTap: () {
|
||||
state.deleteAdministratorIsHaveAllData.value = !state.deleteAdministratorIsHaveAllData.value;
|
||||
},
|
||||
child: Obx(() => Image.asset(
|
||||
state.deleteAdministratorIsHaveAllData.value
|
||||
? 'images/icon_round_select.png'
|
||||
: 'images/icon_round_unSelect.png',
|
||||
width: 30.w,
|
||||
height: 30.w,
|
||||
))),
|
||||
SizedBox(width: 15.w,),
|
||||
Expanded(child: Text('同时删除其发送的所有钥匙,钥匙删除后不能恢复', maxLines: 2, textAlign: TextAlign.start, style: TextStyle(fontSize: 24.sp))),
|
||||
],
|
||||
),
|
||||
),
|
||||
actions: [
|
||||
CupertinoDialogAction(
|
||||
child: Text(TranslationLoader.lanKeys!.cancel!.tr),
|
||||
onPressed: () {
|
||||
Get.back();
|
||||
},
|
||||
),
|
||||
CupertinoDialogAction(
|
||||
child: Text(TranslationLoader.lanKeys!.delete!.tr),
|
||||
onPressed: () {
|
||||
Get.back();
|
||||
deletKeyData();
|
||||
},
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
// 查询账户密码
|
||||
void checkLoginPassword() async {
|
||||
var entity = await ApiRepository.to.checkLoginPassword(
|
||||
password: state.passwordTF.text,
|
||||
);
|
||||
if (entity.errorCode!.codeIsSuccessful) {
|
||||
Get.back();
|
||||
|
||||
if(BlueManage().deviceConnectionState == DeviceConnectionState.connected){
|
||||
// 如果是已连接状态 直接调用协议
|
||||
// 已配对 表示这把锁未被初始化,还处于被添加状态
|
||||
// if (state.lockSetInfoData.value.lockBasicInfo!.isLockOwner == 1) {
|
||||
// 如果是锁拥有者直接删除锁,调用初始化协议
|
||||
factoryDataResetAction();
|
||||
// } else {
|
||||
// // 不是锁拥有者
|
||||
// if(state.lockSetInfoData.value.lockBasicInfo!.lockUserNo != 0){
|
||||
// // 如果已经创建了用户调用协议删除
|
||||
// deletUserAction();
|
||||
// }else{
|
||||
// // 如果没有创建用户 调用接口删除
|
||||
// deletKeyData();
|
||||
// }
|
||||
// }
|
||||
return;
|
||||
}
|
||||
|
||||
if (state.currentDeviceUUid.value.isNotEmpty) {
|
||||
// 已经扫描到了当前设备 停止扫描,直接删除锁
|
||||
BlueManage().stopScan();
|
||||
deletLockLogic();
|
||||
} else {
|
||||
// 未扫描到 然后循环5秒扫秒
|
||||
var index = 0;
|
||||
showEasyLoading();
|
||||
state.deletWaitScanCompleter = Completer();
|
||||
state.deletWaitScanTimer = Timer.periodic(const Duration(seconds: 1), (timer) {
|
||||
//定时任务
|
||||
if(index >= 7){
|
||||
// 当超过10秒的时候还是没有搜索到,完成任务,关闭扫描,取消定时器,弹窗提示
|
||||
if (state.deletWaitScanTimer != null && state.deletWaitScanTimer!.isActive) {
|
||||
state.deletWaitScanTimer!.cancel();
|
||||
state.deletWaitScanTimer = null;
|
||||
}
|
||||
if(state.deletWaitScanCompleter != null){
|
||||
state.deletWaitScanCompleter!.complete();
|
||||
}
|
||||
BlueManage().stopScan();
|
||||
dismissEasyLoading();
|
||||
print("555555");
|
||||
showDeletAlertTipDialog();
|
||||
}else{
|
||||
// 每秒判断获取是否搜到了当前设备
|
||||
if (state.currentDeviceUUid.isNotEmpty) {
|
||||
BlueManage().stopScan();
|
||||
// 存在的时候销毁定时器,赋值
|
||||
if (state.deletWaitScanTimer != null && state.deletWaitScanTimer!.isActive) {
|
||||
state.deletWaitScanTimer!.cancel();
|
||||
state.deletWaitScanTimer = null;
|
||||
}
|
||||
if(state.deletWaitScanCompleter != null){
|
||||
state.deletWaitScanCompleter!.complete();
|
||||
}
|
||||
dismissEasyLoading();
|
||||
|
||||
deletLockLogic();
|
||||
} else {
|
||||
// 不存在的时候返回-1 然后循环5秒
|
||||
index++;
|
||||
// print("index:$index");
|
||||
}
|
||||
}
|
||||
});
|
||||
// 等待Completer完成
|
||||
await state.deletWaitScanCompleter!.future;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 已经扫描到了当前设备 停止扫描,直接调用删除锁逻辑
|
||||
void deletLockLogic() {
|
||||
// 当扫描的数组里面是否有当前设备
|
||||
if(state.currentDeviceUUid.value[31] == "1"){
|
||||
// 已配对 表示这把锁未被初始化,还处于被添加状态
|
||||
// if (state.lockSetInfoData.value.lockBasicInfo!.isLockOwner == 1) {
|
||||
// 如果是锁拥有者直接删除锁,调用初始化协议
|
||||
factoryDataResetAction();
|
||||
// } else {
|
||||
// // 不是锁拥有者
|
||||
// if(state.lockSetInfoData.value.lockBasicInfo!.lockUserNo != 0){
|
||||
// // 如果已经创建了用户调用协议删除
|
||||
// deletUserAction();
|
||||
// }else{
|
||||
// // 如果没有创建用户 调用接口删除
|
||||
// deletKeyData();
|
||||
// }
|
||||
// }
|
||||
}else if(state.currentDeviceUUid.value[31] == "0"){
|
||||
// 未配对 表示这把锁已被强制初始化 处于可添加状态 直接弹窗删除即可
|
||||
print("666666");
|
||||
// showDeletAlertTipDialog(showContent:"当前锁已被强制初始化,可直接添加。");
|
||||
deletLockInfoData();
|
||||
}
|
||||
}
|
||||
|
||||
// 当是锁拥有者的时候,删除锁
|
||||
void deletLockInfoData() async {
|
||||
var entity = await ApiRepository.to.deletOwnerLockData(
|
||||
lockId: state.lockSetInfoData.value.lockId.toString(),
|
||||
);
|
||||
if (entity.errorCode!.codeIsSuccessful) {
|
||||
BlueManage().connectDeviceMacAddress = "";
|
||||
SchedulerBinding.instance.addPostFrameCallback((_) {
|
||||
eventBus.fire(RefreshLockListInfoDataEvent());
|
||||
});
|
||||
if(state.isOnlyOneData.value == true){
|
||||
Future.delayed(const Duration(milliseconds: 200)).then((e) {
|
||||
Get.close(1);
|
||||
});
|
||||
}else{
|
||||
Future.delayed(const Duration(milliseconds: 200)).then((e) {
|
||||
Get.close(2);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 普通用户或者授权管理员删除钥匙
|
||||
void deletKeyData() async {
|
||||
var entity = await ApiRepository.to.deletOwnerKeyData(
|
||||
lockId: state.lockSetInfoData.value.lockId.toString(),
|
||||
keyId: state.lockSetInfoData.value.lockBasicInfo!.keyId.toString(),
|
||||
includeUnderlings: state.deleteAdministratorIsHaveAllData.value == true ? 1 : 0
|
||||
);
|
||||
if (entity.errorCode!.codeIsSuccessful) {
|
||||
BlueManage().connectDeviceMacAddress = "";
|
||||
SchedulerBinding.instance.addPostFrameCallback((_) {
|
||||
eventBus.fire(RefreshLockListInfoDataEvent());
|
||||
});
|
||||
if(state.isOnlyOneData.value == true){
|
||||
Future.delayed(const Duration(milliseconds: 200)).then((e) {
|
||||
Get.close(1);
|
||||
});
|
||||
}else{
|
||||
Future.delayed(const Duration(milliseconds: 200)).then((e) {
|
||||
Get.close(2);
|
||||
});
|
||||
}
|
||||
// Get.offAllNamed(Routers.starLockMain);
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
void onReady() {
|
||||
// TODO: implement onReady
|
||||
|
||||
@ -11,6 +11,7 @@ import '../../../../tools/EasyRefreshTool.dart';
|
||||
import '../../../../tools/appRouteObserver.dart';
|
||||
import '../../../../tools/commonItem.dart';
|
||||
|
||||
import '../../../../tools/showIosTipView.dart';
|
||||
import '../../../../tools/submitBtn.dart';
|
||||
import '../../../../tools/titleAppBar.dart';
|
||||
import '../../../../translations/trans_lib.dart';
|
||||
@ -119,8 +120,7 @@ class _LockSetPageState extends State<LockSetPage> with RouteAware {
|
||||
}))),
|
||||
// 常开模式
|
||||
Obx(() => Visibility(
|
||||
// visible: state.lockFeature.value.passageMode == 1 ? true : false,
|
||||
visible: true,
|
||||
visible: state.lockFeature.value.passageMode == 1 ? true : false,
|
||||
child: CommonItem(
|
||||
leftTitel: TranslationLoader.lanKeys!.normallyOpenMode!.tr,
|
||||
rightTitle: (state.lockSettingInfo.value.passageMode ?? 0) == 1
|
||||
@ -156,8 +156,9 @@ class _LockSetPageState extends State<LockSetPage> with RouteAware {
|
||||
// logic.deletUserAction();
|
||||
|
||||
// logic.deletLockInfoData();
|
||||
showDeletAlertDialog(context);
|
||||
// showDeletAlertDialog(context);
|
||||
// showDeletPasswordAlertDialog(context);
|
||||
logic.deleyLockLogicOfRoles();
|
||||
}),
|
||||
),
|
||||
];
|
||||
@ -301,6 +302,7 @@ class _LockSetPageState extends State<LockSetPage> with RouteAware {
|
||||
// 常开模式
|
||||
Obx(() => Visibility(
|
||||
visible: state.lockFeature.value.passageMode == 1 ? true : false,
|
||||
// visible: true,
|
||||
child: CommonItem(
|
||||
leftTitel: TranslationLoader.lanKeys!.normallyOpenMode!.tr,
|
||||
rightTitle: (state.lockSettingInfo.value.passageMode ?? 0) == 1
|
||||
@ -613,8 +615,9 @@ class _LockSetPageState extends State<LockSetPage> with RouteAware {
|
||||
// logic.deletUserAction();
|
||||
|
||||
// logic.deletLockInfoData();
|
||||
showDeletAlertDialog(context);
|
||||
// showDeletPasswordAlertDialog(context);
|
||||
// showDeletAlertDialog(context);
|
||||
// showDeleteAdministratorIsHaveAllDataDialog(context);
|
||||
logic.deleyLockLogicOfRoles();
|
||||
}),
|
||||
),
|
||||
];
|
||||
@ -639,7 +642,7 @@ class _LockSetPageState extends State<LockSetPage> with RouteAware {
|
||||
onChanged: (value) {
|
||||
logic.openCheckingInData((checkingInInfoDataEntity) {
|
||||
if (checkingInInfoDataEntity.data!.companyId == 0) {
|
||||
showCupertinoAlertDialog(context);
|
||||
logic.showCupertinoAlertDialog(context);
|
||||
} else {
|
||||
logic.setLockSetGeneralSetting();
|
||||
}
|
||||
@ -736,86 +739,6 @@ class _LockSetPageState extends State<LockSetPage> with RouteAware {
|
||||
);
|
||||
}
|
||||
|
||||
//确认弹窗
|
||||
void showCupertinoAlertDialog(widgetContext) {
|
||||
showCupertinoDialog(
|
||||
context: widgetContext,
|
||||
builder: (context) {
|
||||
return CupertinoAlertDialog(
|
||||
title: const Text("提示"),
|
||||
content: const Text('创建公司后,考勤功能才能使用'),
|
||||
actions: [
|
||||
CupertinoDialogAction(
|
||||
child: Text(TranslationLoader.lanKeys!.cancel!.tr),
|
||||
onPressed: () {
|
||||
Get.back();
|
||||
},
|
||||
),
|
||||
CupertinoDialogAction(
|
||||
child: Text(TranslationLoader.lanKeys!.sure!.tr),
|
||||
onPressed: () {
|
||||
Navigator.pop(context);
|
||||
Get.toNamed(Routers.checkInCreatCompanyPage, arguments: {
|
||||
'lockSetInfoData': state.lockSetInfoData.value
|
||||
});
|
||||
},
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
void showDeletAlertDialog(BuildContext context) {
|
||||
showCupertinoDialog(
|
||||
context: context,
|
||||
builder: (context) {
|
||||
return CupertinoAlertDialog(
|
||||
title: const Text("提示"),
|
||||
content: const Text('删除锁后,所有信息都会一起删除,确定删除锁吗?'),
|
||||
actions: [
|
||||
CupertinoDialogAction(
|
||||
child: Text(TranslationLoader.lanKeys!.cancel!.tr),
|
||||
onPressed: () {
|
||||
Navigator.pop(context);
|
||||
},
|
||||
),
|
||||
CupertinoDialogAction(
|
||||
child: Text(TranslationLoader.lanKeys!.sure!.tr),
|
||||
onPressed: () {
|
||||
Get.back();
|
||||
logic.showDeletPasswordAlertDialog(context);
|
||||
},
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
// void showCupertinoAlertDialog(
|
||||
// BuildContext context,
|
||||
// ) {
|
||||
// showDialog(
|
||||
// context: context,
|
||||
// builder: (BuildContext context) {
|
||||
// return ShowIosTipView(
|
||||
// title: "提示",
|
||||
// tipTitle: "创建公司号,考勤功能才能使用",
|
||||
// sureClick: () {
|
||||
// //
|
||||
// Navigator.pop(context);
|
||||
// Get.toNamed(Routers.checkInCreatCompanyPage,
|
||||
// arguments: state.getKeyInfosData.value);
|
||||
// },
|
||||
// cancelClick: () {
|
||||
// Navigator.pop(context);
|
||||
// },
|
||||
// );
|
||||
// },
|
||||
// );
|
||||
// }
|
||||
|
||||
@override
|
||||
void didChangeDependencies() {
|
||||
// TODO: implement didChangeDependencies
|
||||
|
||||
@ -29,6 +29,7 @@ class LockSetState {
|
||||
|
||||
var settingUpSupportFeatures = 0;
|
||||
var ifCurrentScreen = true.obs; // 是否是当前界面,用于判断是否需要针对当前界面进行展示
|
||||
var deleteAdministratorIsHaveAllData = false.obs; // 删除管理员是否有所有数据
|
||||
|
||||
Completer? deletWaitScanCompleter;
|
||||
Timer? deletWaitScanTimer;
|
||||
|
||||
@ -6,6 +6,7 @@ import '../../../network/api_repository.dart';
|
||||
import '../../../talk/udp/udp_help.dart';
|
||||
import '../../../tools/baseGetXController.dart';
|
||||
import '../../../tools/eventBusEventManage.dart';
|
||||
import '../../../versionUndate/versionUndateTool.dart';
|
||||
import '../entity/lockListInfo_entity.dart';
|
||||
import 'lockMain_state.dart';
|
||||
|
||||
@ -39,15 +40,6 @@ class LockMainLogic extends BaseGetXController {
|
||||
return entity;
|
||||
}
|
||||
|
||||
late StreamSubscription _teamEvent;
|
||||
void _initLoadDataAction() {
|
||||
_teamEvent = eventBus.on<RefreshLockListInfoDataEvent>().listen((event) {
|
||||
// getLockInfo();
|
||||
getStarLockInfo();
|
||||
print("收到消息");
|
||||
});
|
||||
}
|
||||
|
||||
/// 获取联网类型
|
||||
void getConnectType() async {
|
||||
var connectResult = await (Connectivity().checkConnectivity());
|
||||
@ -91,8 +83,6 @@ class LockMainLogic extends BaseGetXController {
|
||||
super.onReady();
|
||||
print("onReady()");
|
||||
|
||||
_initLoadDataAction();
|
||||
|
||||
// 开启UDP
|
||||
UdpHelp().openUDP();
|
||||
}
|
||||
@ -116,7 +106,7 @@ class LockMainLogic extends BaseGetXController {
|
||||
super.onClose();
|
||||
|
||||
// refreshController.dispose();
|
||||
_teamEvent.cancel();
|
||||
// _teamEvent.cancel();
|
||||
// state.timer.cancel();
|
||||
}
|
||||
|
||||
|
||||
@ -1,7 +1,9 @@
|
||||
import 'dart:async';
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:aliyun_push/aliyun_push.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/scheduler.dart';
|
||||
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:star_lock/app_settings/app_colors.dart';
|
||||
@ -14,6 +16,7 @@ import '../../../baseWidget.dart';
|
||||
import '../../../flavors.dart';
|
||||
import '../../../mine/mine/starLockMine_page.dart';
|
||||
import '../../../tools/EasyRefreshTool.dart';
|
||||
import '../../../tools/eventBusEventManage.dart';
|
||||
import '../../../tools/storage.dart';
|
||||
import '../../../tools/titleAppBar.dart';
|
||||
import '../../../translations/trans_lib.dart';
|
||||
@ -34,7 +37,9 @@ class _StarLockMainPageState extends State<StarLockMainPage> with BaseWidget {
|
||||
final logic = Get.put(LockMainLogic());
|
||||
final state = Get.find<LockMainLogic>().state;
|
||||
|
||||
void getHttpData() {
|
||||
Future<void> getHttpData() async {
|
||||
// await logic.getStarLockInfo();
|
||||
// setState(() {});
|
||||
logic.getStarLockInfo().then((LockListInfoEntity value) {
|
||||
setState(() {});
|
||||
});
|
||||
@ -43,18 +48,20 @@ class _StarLockMainPageState extends State<StarLockMainPage> with BaseWidget {
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
// WidgetsBinding.instance!.addPostFrameCallback((_) {
|
||||
// getHttpData();
|
||||
// });
|
||||
WidgetsBinding.instance!.addPostFrameCallback((_) {
|
||||
getHttpData();
|
||||
});
|
||||
initAliyunPush();
|
||||
|
||||
_initLoadDataAction();
|
||||
}
|
||||
|
||||
@override
|
||||
void didChangeDependencies() {
|
||||
super.didChangeDependencies();
|
||||
WidgetsBinding.instance!.addPostFrameCallback((_) {
|
||||
getHttpData();
|
||||
});
|
||||
// WidgetsBinding.instance!.addPostFrameCallback((_) {
|
||||
// getHttpData();
|
||||
// });
|
||||
}
|
||||
|
||||
@override
|
||||
@ -108,10 +115,13 @@ class _StarLockMainPageState extends State<StarLockMainPage> with BaseWidget {
|
||||
// ),
|
||||
body: EasyRefreshTool(
|
||||
onRefresh: () {
|
||||
logic.pageNo = 1;
|
||||
getHttpData();
|
||||
SchedulerBinding.instance.addPostFrameCallback((_) {
|
||||
// 更新状态的代码
|
||||
logic.pageNo = 1;
|
||||
getHttpData();
|
||||
});
|
||||
},
|
||||
child: Obx(() => getDataReturnUI(state.dataLength.value))),
|
||||
child: getDataReturnUI(state.dataLength.value)),
|
||||
// body:smartRefresher(
|
||||
// logic.refreshController,
|
||||
// onRefresh:logic.onRefresh,
|
||||
@ -244,4 +254,20 @@ class _StarLockMainPageState extends State<StarLockMainPage> with BaseWidget {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
late StreamSubscription _teamEvent;
|
||||
void _initLoadDataAction() {
|
||||
_teamEvent = eventBus.on<RefreshLockListInfoDataEvent>().listen((event) {
|
||||
// getLockInfo();
|
||||
getHttpData();
|
||||
print("收到刷新首页数据消息");
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
// TODO: implement dispose
|
||||
super.dispose();
|
||||
_teamEvent.cancel();
|
||||
}
|
||||
}
|
||||
|
||||
@ -38,6 +38,7 @@ class _AboutPageState extends State<AboutPage> {
|
||||
packageName = packageInfo.packageName;
|
||||
version = packageInfo.version;
|
||||
buildNumber = packageInfo.buildNumber;
|
||||
print("aboutGetversion:${version}");
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@ -139,7 +139,7 @@ class SaveLockLogic extends BaseGetXController {
|
||||
IoSenderManage.senderCustomPasswordsCommand(
|
||||
keyID: "1",
|
||||
userID: await Storage.getUid(),
|
||||
pwdNo: 1,
|
||||
pwdNo: 254,
|
||||
pwd: "123456",
|
||||
useCountLimit: 0xff,
|
||||
startTime: 0x11223344,
|
||||
@ -197,7 +197,7 @@ class SaveLockLogic extends BaseGetXController {
|
||||
IoSenderManage.changeAdministratorPasswordCommand(
|
||||
keyID: "1",
|
||||
userID: await Storage.getUid(),
|
||||
pwdNo: 0,
|
||||
pwdNo: 254,
|
||||
pwd:state.adminPasswordTF.text,
|
||||
useCountLimit: 0xff,
|
||||
startTime: 0x11223344,
|
||||
@ -300,7 +300,7 @@ class SaveLockLogic extends BaseGetXController {
|
||||
IoSenderManage.senderCustomPasswordsCommand(
|
||||
keyID: "1",
|
||||
userID: await Storage.getUid(),
|
||||
pwdNo: 1,
|
||||
pwdNo: 254,
|
||||
pwd:state.adminPasswordTF.text,
|
||||
useCountLimit: 0xff,
|
||||
startTime: 0x11223344,
|
||||
@ -334,7 +334,7 @@ class SaveLockLogic extends BaseGetXController {
|
||||
IoSenderManage.changeAdministratorPasswordCommand(
|
||||
keyID: "1",
|
||||
userID: await Storage.getUid(),
|
||||
pwdNo: 0,
|
||||
pwdNo: 254,
|
||||
pwd:state.adminPasswordTF.text,
|
||||
useCountLimit: 0xff,
|
||||
startTime: 0x11223344,
|
||||
|
||||
@ -1,7 +1,10 @@
|
||||
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:star_lock/tools/baseGetXController.dart';
|
||||
import '../../../../network/api_repository.dart';
|
||||
import '../../../../tools/eventBusEventManage.dart';
|
||||
import '../../../../translations/trans_lib.dart';
|
||||
import 'recipientInformation_entity.dart';
|
||||
import 'recipientInformation_state.dart';
|
||||
|
||||
@ -32,6 +35,17 @@ class RecipientInformationLogic extends BaseGetXController{
|
||||
}
|
||||
}
|
||||
|
||||
// 移除坏锁
|
||||
Future<void> removeBrokenLockData() async{
|
||||
var entity = await ApiRepository.to.removeBrokenLockData(
|
||||
lockIdList: state.idList.value,
|
||||
);
|
||||
if(entity.errorCode!.codeIsSuccessful){
|
||||
eventBus.fire(RefreshLockListInfoDataEvent());
|
||||
Get.back(result: "scuess");
|
||||
}
|
||||
}
|
||||
|
||||
// 转移网关确认
|
||||
Future<void> transferGateWayConfirmInfoData(void Function(RecipientInformationData recipientInformationData) action) async{
|
||||
var entity = await ApiRepository.to.transferGatewayConfirmInfoData(
|
||||
@ -56,6 +70,34 @@ class RecipientInformationLogic extends BaseGetXController{
|
||||
}
|
||||
}
|
||||
|
||||
// 移除坏锁提示
|
||||
void showDeletAlertDialog() {
|
||||
showCupertinoDialog(
|
||||
context: Get.context!,
|
||||
builder: (context) {
|
||||
return CupertinoAlertDialog(
|
||||
title: const Text("提示"),
|
||||
content: const Text('确定要移除所选中的坏锁吗?'),
|
||||
actions: [
|
||||
CupertinoDialogAction(
|
||||
child: Text(TranslationLoader.lanKeys!.cancel!.tr),
|
||||
onPressed: () {
|
||||
Get.back();
|
||||
},
|
||||
),
|
||||
CupertinoDialogAction(
|
||||
child: Text(TranslationLoader.lanKeys!.sure!.tr),
|
||||
onPressed: () {
|
||||
Get.back();
|
||||
removeBrokenLockData();
|
||||
},
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
void onReady() {
|
||||
// TODO: implement onReady
|
||||
|
||||
@ -42,7 +42,7 @@ class _RecipientInformationPageState extends State<RecipientInformationPage> {
|
||||
_buildNextBtn(context),
|
||||
SizedBox(height: 64.h),
|
||||
Visibility(
|
||||
visible: state.isFromType.value == 2 ? true : false,
|
||||
visible: state.isFromType.value == 1 ? true : false,
|
||||
child: _buildRemoveBadLockBtn()),
|
||||
SizedBox(
|
||||
height: 64.h,
|
||||
@ -245,7 +245,9 @@ class _RecipientInformationPageState extends State<RecipientInformationPage> {
|
||||
children: [
|
||||
const Expanded(child: SizedBox()),
|
||||
TextButton(
|
||||
onPressed: () {},
|
||||
onPressed: () {
|
||||
logic.showDeletAlertDialog();
|
||||
},
|
||||
child: Text(
|
||||
'移除坏锁',
|
||||
style: TextStyle(
|
||||
|
||||
@ -123,6 +123,7 @@ abstract class Api {
|
||||
final String transferLockListURL = '/room/listForTransfer'; // 转移锁锁列表
|
||||
final String transferLockConfirmURL = '/room/transferLockConfirm'; // 转移智能锁确认
|
||||
final String transferLockURL = '/room/transfer'; // 转移智能锁
|
||||
final String removeBadLockURL = '/lock/removeBadLock'; // 移除坏锁
|
||||
|
||||
final String gatewaykListURL = '/plug/list'; // 转网关列表
|
||||
final String transferGatewayConfirmURL =
|
||||
@ -173,4 +174,6 @@ abstract class Api {
|
||||
final String messageListURL = '/notifications/list'; //消息列表
|
||||
final String readMessageURL = '/notifications/markAsRead'; //读取消息
|
||||
final String deletMessageURL = '/notifications/delete'; //删除消息
|
||||
|
||||
final String getVersionURL = '/app/getVersion'; //版本更新
|
||||
}
|
||||
|
||||
@ -356,9 +356,9 @@ class ApiProvider extends BaseProvider {
|
||||
}));
|
||||
|
||||
// 删除拥有的当前钥匙
|
||||
Future<Response> deletOwnerKeyInfo(String lockId, String keyId) => post(
|
||||
Future<Response> deletOwnerKeyInfo(String lockId, String keyId, int includeUnderlings) => post(
|
||||
deleteElectronicKeyURL.toUrl,
|
||||
jsonEncode({'lockId': lockId, 'keyId': keyId}));
|
||||
jsonEncode({'lockId': lockId, 'keyId': keyId, 'includeUnderlings': includeUnderlings}));
|
||||
|
||||
// 检查账户密码
|
||||
Future<Response> checkLoginPassword(String password) => post(
|
||||
@ -1265,6 +1265,14 @@ class ApiProvider extends BaseProvider {
|
||||
'countryCode': countryCode
|
||||
}));
|
||||
|
||||
// 移除坏锁
|
||||
Future<Response> removeBrokenLockData(List lockIdList) =>
|
||||
post(
|
||||
removeBadLockURL.toUrl,
|
||||
jsonEncode({
|
||||
'lockIds': lockIdList
|
||||
}));
|
||||
|
||||
Future<Response> listLockByGroup(String type, String keyGroupId) => post(
|
||||
listLockByGroupURL.toUrl,
|
||||
jsonEncode({'type': type, 'keyGroupId': keyGroupId}));
|
||||
@ -1534,6 +1542,14 @@ class ApiProvider extends BaseProvider {
|
||||
jsonEncode({
|
||||
'id': messageId,
|
||||
}));
|
||||
|
||||
// 获取最新版本号
|
||||
Future<Response> getVersionData(String brandName, String currentVersion) => post(
|
||||
getVersionURL.toUrl,
|
||||
jsonEncode({
|
||||
'brandName': brandName,
|
||||
'currentVersion': currentVersion,
|
||||
}));
|
||||
}
|
||||
|
||||
extension ExtensionString on String {
|
||||
|
||||
@ -48,6 +48,7 @@ import '../mine/minePersonInfo/minePersonInfoPage/minePersonGetUploadFileInfo_en
|
||||
import '../mine/mineSet/transferGateway/selectGetewayList_entity.dart';
|
||||
import '../mine/mineSet/transferSmartLock/recipientInformation/recipientInformation_entity.dart';
|
||||
import '../mine/mineSet/transferSmartLock/transferSmartLockList/transferSmartLock_entity.dart';
|
||||
import '../versionUndate/versionUndate_entity.dart';
|
||||
import 'api_provider.dart';
|
||||
|
||||
class ApiRepository {
|
||||
@ -381,8 +382,8 @@ class ApiRepository {
|
||||
|
||||
// 删除钥匙
|
||||
Future<LockListInfoEntity> deletOwnerKeyData(
|
||||
{required String lockId, required String keyId}) async {
|
||||
final res = await apiProvider.deletOwnerKeyInfo(lockId, keyId);
|
||||
{required String lockId, required String keyId, required int includeUnderlings}) async {
|
||||
final res = await apiProvider.deletOwnerKeyInfo(lockId, keyId, includeUnderlings);
|
||||
return LockListInfoEntity.fromJson(res.body);
|
||||
}
|
||||
|
||||
@ -1398,6 +1399,13 @@ class ApiRepository {
|
||||
return RecipientInformationEntity.fromJson(res.body);
|
||||
}
|
||||
|
||||
// 移除坏锁
|
||||
Future<RecipientInformationEntity> removeBrokenLockData(
|
||||
{required List lockIdList}) async {
|
||||
final res = await apiProvider.removeBrokenLockData(lockIdList);
|
||||
return RecipientInformationEntity.fromJson(res.body);
|
||||
}
|
||||
|
||||
//删除账号
|
||||
Future<LoginEntity> deleteAccount(
|
||||
String channel, String verificationCode) async {
|
||||
@ -1549,4 +1557,13 @@ class ApiRepository {
|
||||
final res = await apiProvider.deletMessageLoadData(messageId);
|
||||
return MessageListEntity.fromJson(res.body);
|
||||
}
|
||||
|
||||
// 获取版本号
|
||||
Future<VersionUndateEntity> getVersionData({
|
||||
required String brandName,
|
||||
required String currentVersion
|
||||
}) async {
|
||||
final res = await apiProvider.getVersionData(brandName, currentVersion);
|
||||
return VersionUndateEntity.fromJson(res.body);
|
||||
}
|
||||
}
|
||||
|
||||
@ -4,6 +4,7 @@ import 'package:star_lock/tools/appFirstEnterHandle.dart';
|
||||
import 'package:star_lock/tools/storage.dart';
|
||||
|
||||
import '../main/lockMian/lockMain/lockMain_page.dart';
|
||||
import '../versionUndate/versionUndateTool.dart';
|
||||
|
||||
class StarLockApplication extends StatefulWidget {
|
||||
const StarLockApplication({Key? key}) : super(key: key);
|
||||
@ -13,10 +14,20 @@ class StarLockApplication extends StatefulWidget {
|
||||
}
|
||||
|
||||
class _StarLockApplicationState extends State<StarLockApplication> {
|
||||
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
// TODO: implement initState
|
||||
super.initState();
|
||||
print("StarLockApplication initState");
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
print("StarLockApplication build");
|
||||
AppFirstEnterHandle().getAppFirstEnter(context, isAgreePrivacy);
|
||||
|
||||
AppFirstEnterHandle().getAppFirstEnter(context, isShowUpdateVersion);
|
||||
return FutureBuilder<bool>(
|
||||
future: getLoginStatus(),
|
||||
builder: (context, snapshot) {
|
||||
|
||||
@ -1,13 +1,21 @@
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:device_info_plus/device_info_plus.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/gestures.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:package_info_plus/package_info_plus.dart';
|
||||
import 'package:star_lock/appRouters.dart';
|
||||
import 'package:star_lock/common/XSConstantMacro/XSConstantMacro.dart';
|
||||
import 'package:star_lock/tools/storage.dart';
|
||||
|
||||
import '../network/api_repository.dart';
|
||||
import '../translations/trans_lib.dart';
|
||||
import '../versionUndate/versionUndateTool.dart';
|
||||
import '../versionUndate/versionUndate_entity.dart';
|
||||
|
||||
class AppFirstEnterHandle {
|
||||
Future getAppFirstEnter(BuildContext widgetContext, String flagStr) async {
|
||||
var getFlag = await Storage.getString(flagStr);
|
||||
@ -28,6 +36,11 @@ class AppFirstEnterHandle {
|
||||
if (getFlag != isAgreeCamera) showCameraAlert(widgetContext);
|
||||
}
|
||||
break;
|
||||
case isShowUpdateVersion: // 版本更新
|
||||
{
|
||||
if (getFlag != isShowUpdateVersion) VersionUndateTool();
|
||||
}
|
||||
break;
|
||||
default:
|
||||
{
|
||||
print('没有匹配的flagStr');
|
||||
|
||||
@ -1,4 +1,3 @@
|
||||
|
||||
import 'dart:async';
|
||||
import 'dart:io';
|
||||
|
||||
@ -15,7 +14,7 @@ import 'NativeInteractionTool.dart';
|
||||
import 'manager/client_manager.dart';
|
||||
import 'showIosTipView.dart';
|
||||
|
||||
class BaseGetXController extends GetxController{
|
||||
class BaseGetXController extends GetxController {
|
||||
int currentTimeSeconds = 0;
|
||||
|
||||
bool currentPage = true;
|
||||
@ -52,7 +51,8 @@ class BaseGetXController extends GetxController{
|
||||
Get.log('onClose -----> $runtimeType');
|
||||
}
|
||||
|
||||
Future delay({Duration? duration,Function? something}) => Future.delayed(duration ?? 500. milliseconds,something as FutureOr Function()?);
|
||||
Future delay({Duration? duration, Function? something}) => Future.delayed(
|
||||
duration ?? 500.milliseconds, something as FutureOr Function()?);
|
||||
|
||||
void showEasyLoading() => EasyLoading.show();
|
||||
|
||||
@ -60,65 +60,61 @@ class BaseGetXController extends GetxController{
|
||||
|
||||
Timer? _timer;
|
||||
// CancelableOperation? _operation;
|
||||
void showBlueConnetctToastTimer({bool isShowBlueConnetctToast = true,Function? action}) {
|
||||
if(_timer != null){
|
||||
void showBlueConnetctToastTimer({bool isShowBlueConnetctToast = true, Function? action}) {
|
||||
if (_timer != null && _timer!.isActive) {
|
||||
_timer!.cancel();
|
||||
_timer = null;
|
||||
}
|
||||
_timer = Timer.periodic(15.seconds, (timer) {
|
||||
if(action != null) {
|
||||
if (action != null) {
|
||||
action();
|
||||
}
|
||||
cancelBlueConnetctToastTimer();
|
||||
if(isShowBlueConnetctToast == true){
|
||||
if (isShowBlueConnetctToast == true) {
|
||||
showBlueConnetctToast();
|
||||
}
|
||||
});
|
||||
// _operation = CancelableOperation.fromFuture(
|
||||
// Future.delayed(const Duration(seconds: 15), () {
|
||||
// print('Operation completed');
|
||||
// showBlueConnetctToast();
|
||||
// }),
|
||||
// );
|
||||
}
|
||||
|
||||
void cancelBlueConnetctToastTimer() {
|
||||
Get.log('cancelBlueConnetctToastTimer');
|
||||
if(_timer != null){
|
||||
if (_timer != null && _timer!.isActive) {
|
||||
_timer!.cancel();
|
||||
_timer = null;
|
||||
}
|
||||
// _operation?.cancel();
|
||||
}
|
||||
|
||||
void showBlueConnetctToast() {
|
||||
bool isContains = BlueManage().connectDeviceName!.contains("T9A");
|
||||
showToast("连接设备失败,请确保在设备附近,设备未被连接,设备已打开${isContains == true ? "。如果是全自动锁,请使屏幕变亮" : ""}");
|
||||
showToast(
|
||||
"连接设备失败,请确保在设备附近,设备未被连接,设备已打开${isContains == true ? "。如果是全自动锁,请使屏幕变亮" : ""}");
|
||||
}
|
||||
|
||||
void showToast(String status,{Function? something}) {
|
||||
EasyLoading.showToast(status,duration: 2000.milliseconds);
|
||||
if(something != null) {
|
||||
delay(duration: 2100.milliseconds,something: something);
|
||||
void showToast(String status, {Function? something}) {
|
||||
EasyLoading.showToast(status, duration: 2000.milliseconds);
|
||||
if (something != null) {
|
||||
delay(duration: 2100.milliseconds, something: something);
|
||||
}
|
||||
}
|
||||
|
||||
void showError(String status,{Function? something}) {
|
||||
EasyLoading.showError(status,duration: 2000.milliseconds);
|
||||
if(something != null) {
|
||||
delay(duration: 2100.milliseconds,something: something);
|
||||
void showError(String status, {Function? something}) {
|
||||
EasyLoading.showError(status, duration: 2000.milliseconds);
|
||||
if (something != null) {
|
||||
delay(duration: 2100.milliseconds, something: something);
|
||||
}
|
||||
}
|
||||
|
||||
void showSuccess(String status,{Function? something}) {
|
||||
EasyLoading.showSuccess(status,duration: 1500.milliseconds);
|
||||
if(something != null) {
|
||||
delay(duration: 2000.milliseconds,something: something);
|
||||
void showSuccess(String status, {Function? something}) {
|
||||
EasyLoading.showSuccess(status, duration: 1500.milliseconds);
|
||||
if (something != null) {
|
||||
delay(duration: 2000.milliseconds, something: something);
|
||||
}
|
||||
}
|
||||
|
||||
void showOperationSuccessful({String? status,Function? something}) => showSuccess( status ?? "成功",something: something);
|
||||
void showOperationFailed({String? status, Function? something}) => showError( status ?? "失败",something: something);
|
||||
void showOperationSuccessful({String? status, Function? something}) =>
|
||||
showSuccess(status ?? "成功", something: something);
|
||||
void showOperationFailed({String? status, Function? something}) =>
|
||||
showError(status ?? "失败", something: something);
|
||||
|
||||
void logOff() async {
|
||||
await ClientManager().logOff();
|
||||
@ -129,16 +125,16 @@ class BaseGetXController extends GetxController{
|
||||
NativeInteractionTool().sendGetBlueStatus();
|
||||
NativeInteractionTool().receiveChannelBlueIsOnEvent((String status) {
|
||||
print("22222222");
|
||||
if(status == "1"){
|
||||
if (status == "1") {
|
||||
// 蓝牙已打开
|
||||
Get.log('蓝牙已打开');
|
||||
action();
|
||||
}else if(status == "0"){
|
||||
} else if (status == "0") {
|
||||
// 蓝牙未打开
|
||||
Get.log('蓝牙未打开');
|
||||
showIosTipViewDialog();
|
||||
return;
|
||||
}else{
|
||||
} else {
|
||||
// 蓝牙未打开
|
||||
Get.log('设备不支持蓝牙');
|
||||
showToast("设备不支持蓝牙");
|
||||
@ -158,7 +154,7 @@ class BaseGetXController extends GetxController{
|
||||
Get.back();
|
||||
if (Platform.isIOS) {
|
||||
launch('App-Prefs:');
|
||||
}else{
|
||||
} else {
|
||||
SystemSettings.system();
|
||||
}
|
||||
},
|
||||
@ -166,20 +162,17 @@ class BaseGetXController extends GetxController{
|
||||
Get.back();
|
||||
},
|
||||
);
|
||||
}
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
String getUseKeyTypeStr(int? startDate, int? endDate,int? keyType) {
|
||||
String getUseKeyTypeStr(int? startDate, int? endDate, int? keyType) {
|
||||
String useDateStr = '';
|
||||
if (keyType == XSConstantMacro.keyTypeTime) {
|
||||
//限期
|
||||
DateTime startDateStr =
|
||||
DateTime.fromMillisecondsSinceEpoch(startDate!);
|
||||
DateTime endDateStr =
|
||||
DateTime.fromMillisecondsSinceEpoch(endDate!);
|
||||
DateTime startDateStr = DateTime.fromMillisecondsSinceEpoch(startDate!);
|
||||
DateTime endDateStr = DateTime.fromMillisecondsSinceEpoch(endDate!);
|
||||
useDateStr =
|
||||
'${startDateStr.toLocal().toString().substring(0, 16)} - ${endDateStr.toLocal().toString().substring(0, 16)}';
|
||||
'${startDateStr.toLocal().toString().substring(0, 16)} - ${endDateStr.toLocal().toString().substring(0, 16)}';
|
||||
} else if (keyType == XSConstantMacro.keyTypeLong) {
|
||||
//永久
|
||||
// DateTime dateStr = DateTime.fromMillisecondsSinceEpoch(indexEntity.date!);
|
||||
@ -217,11 +210,10 @@ class BaseGetXController extends GetxController{
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
///Extension_Int
|
||||
extension Extension_Int on int {
|
||||
bool get codeIsSuccessful => this == 0;
|
||||
bool get msgCodeIsSuccessful => this == 1;
|
||||
}
|
||||
}
|
||||
|
||||
@ -10,6 +10,11 @@ class RefreshLockListInfoDataEvent {
|
||||
RefreshLockListInfoDataEvent();
|
||||
}
|
||||
|
||||
/// 刷新锁详情数据
|
||||
class RefreshLockDetailInfoDataEvent {
|
||||
RefreshLockDetailInfoDataEvent();
|
||||
}
|
||||
|
||||
/// 刷新考勤员工列表
|
||||
class RefreshCheckInStaffListDataEvent {
|
||||
RefreshCheckInStaffListDataEvent();
|
||||
|
||||
@ -19,6 +19,8 @@ const isAgreePrivacy = "isAgreePrivacy"; //是否同意隐私协议弹窗
|
||||
const isAgreePosition = "isAgreePosition"; //是否同意获取位置弹窗
|
||||
const isAgreeCamera = "isAgreeCamera"; //是否同意获取相机/相册弹窗
|
||||
|
||||
const isShowUpdateVersion = "isShowUpdateVersion"; //是否更新弹窗
|
||||
|
||||
const saveUserLoginData = "userLoginData";
|
||||
|
||||
class Storage {
|
||||
|
||||
133
star_lock/lib/versionUndate/versionUndateTool.dart
Normal file
133
star_lock/lib/versionUndate/versionUndateTool.dart
Normal file
@ -0,0 +1,133 @@
|
||||
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:device_info_plus/device_info_plus.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:package_info_plus/package_info_plus.dart';
|
||||
import 'package:url_launcher/url_launcher.dart';
|
||||
|
||||
import '../network/api_repository.dart';
|
||||
import '../tools/storage.dart';
|
||||
import '../translations/trans_lib.dart';
|
||||
import 'versionUndate_entity.dart';
|
||||
|
||||
class VersionUndateTool {
|
||||
static VersionUndateTool? _manager;
|
||||
|
||||
VersionUndateTool._init(){
|
||||
// _initLoadUpdateVersionData();
|
||||
}
|
||||
|
||||
static VersionUndateTool? shareManager() {
|
||||
_manager ??= VersionUndateTool._init();
|
||||
_manager!._initLoadUpdateVersionData();
|
||||
return _manager;
|
||||
}
|
||||
|
||||
factory VersionUndateTool() => shareManager()!;
|
||||
|
||||
VersionUndateTool? get manager => shareManager();
|
||||
|
||||
void _initLoadUpdateVersionData() {
|
||||
|
||||
getVersionData();
|
||||
}
|
||||
|
||||
// 获取版本号
|
||||
void getVersionData() async {
|
||||
DeviceInfoPlugin deviceInfo = DeviceInfoPlugin();
|
||||
String brandName = '';
|
||||
if (Platform.isAndroid) {
|
||||
AndroidDeviceInfo androidInfo = await deviceInfo.androidInfo;
|
||||
Get.log('androidInfo.manufacturer:${androidInfo.manufacturer}'
|
||||
'androidInfo.device:${androidInfo.device}'
|
||||
'androidInfo.model:${androidInfo.model}'
|
||||
'androidInfo.product:${androidInfo.product}'
|
||||
'androidInfo.version.release:${androidInfo.version.release}'
|
||||
'androidInfo.version.sdkInt:${androidInfo.version.sdkInt}'
|
||||
'androidInfo.version.securityPatch:${androidInfo.version.securityPatch}'
|
||||
'androidInfo.version.incremental:${androidInfo.version.incremental}'
|
||||
'androidInfo.version.codename:${androidInfo.version.codename}'
|
||||
'androidInfo.version.baseOS:${androidInfo.version.baseOS}'
|
||||
'androidInfo.board:${androidInfo.board}'
|
||||
'androidInfo.bootloader:${androidInfo.bootloader}');
|
||||
brandName = androidInfo.manufacturer;
|
||||
} else if (Platform.isIOS) {
|
||||
IosDeviceInfo iosInfo = await deviceInfo.iosInfo;
|
||||
brandName = iosInfo.systemName!;
|
||||
}
|
||||
|
||||
PackageInfo packageInfo = await PackageInfo.fromPlatform();
|
||||
var version = packageInfo.version;
|
||||
Get.log("updateGetversion:${version}");
|
||||
var entity = await ApiRepository.to.getVersionData(
|
||||
brandName: brandName,
|
||||
currentVersion: version,
|
||||
);
|
||||
if (entity.errorCode! == 0) {
|
||||
if(entity.data!.isUpdate! == 1){
|
||||
showUpdateAlertDialog(entity);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void showUpdateAlertDialog(VersionUndateEntity versionUndateEntity) {
|
||||
showCupertinoDialog(
|
||||
context: Get.context!,
|
||||
builder: (context) {
|
||||
return CupertinoAlertDialog(
|
||||
content: Column(
|
||||
children: [
|
||||
Container(
|
||||
// color: AppColors.mainColor,
|
||||
alignment: Alignment.topCenter,
|
||||
height: 50.h,
|
||||
child: Text('版本更新', style: TextStyle(fontSize: 28.sp, color: Colors.blue),)
|
||||
),
|
||||
Container(
|
||||
padding: EdgeInsets.only(left:20.w, right: 20.w, top: 10.h),
|
||||
alignment: Alignment.centerLeft,
|
||||
child: Text(versionUndateEntity.data!.description!, textAlign:TextAlign.start, style: TextStyle(fontSize: 20.sp))
|
||||
),
|
||||
],
|
||||
),
|
||||
actions: versionUndateEntity.data!.isForceUpdate == 0 ?
|
||||
[
|
||||
CupertinoDialogAction(
|
||||
child: Text("下次再说"),
|
||||
onPressed: () {
|
||||
Navigator.pop(context);
|
||||
Storage.setString(isShowUpdateVersion, isShowUpdateVersion);
|
||||
},
|
||||
),
|
||||
CupertinoDialogAction(
|
||||
child: Text(TranslationLoader.lanKeys!.sure!.tr),
|
||||
onPressed: () async {
|
||||
if (await canLaunch(versionUndateEntity.data!.appDownloadUrl!)) {
|
||||
await launch(versionUndateEntity.data!.appDownloadUrl!);
|
||||
} else {
|
||||
throw 'Could not launch ${versionUndateEntity.data!.appDownloadUrl}';
|
||||
}
|
||||
},
|
||||
),
|
||||
]:
|
||||
[
|
||||
CupertinoDialogAction(
|
||||
child: Text(TranslationLoader.lanKeys!.sure!.tr),
|
||||
onPressed: () async {
|
||||
if (await canLaunch(versionUndateEntity.data!.appDownloadUrl!)) {
|
||||
await launch(versionUndateEntity.data!.appDownloadUrl!);
|
||||
} else {
|
||||
throw 'Could not launch ${versionUndateEntity.data!.appDownloadUrl}';
|
||||
}
|
||||
},
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
56
star_lock/lib/versionUndate/versionUndate_entity.dart
Normal file
56
star_lock/lib/versionUndate/versionUndate_entity.dart
Normal file
@ -0,0 +1,56 @@
|
||||
class VersionUndateEntity {
|
||||
int? errorCode;
|
||||
String? description;
|
||||
String? errorMsg;
|
||||
Data? data;
|
||||
|
||||
VersionUndateEntity(
|
||||
{this.errorCode, this.description, this.errorMsg, this.data});
|
||||
|
||||
VersionUndateEntity.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? isUpdate;
|
||||
String? appDownloadUrl;
|
||||
String? description;
|
||||
int? isForceUpdate;
|
||||
|
||||
Data(
|
||||
{this.isUpdate,
|
||||
this.appDownloadUrl,
|
||||
this.description,
|
||||
this.isForceUpdate});
|
||||
|
||||
Data.fromJson(Map<String, dynamic> json) {
|
||||
isUpdate = json['isUpdate'];
|
||||
appDownloadUrl = json['appDownloadUrl'];
|
||||
description = json['description'];
|
||||
isForceUpdate = json['isForceUpdate'];
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final Map<String, dynamic> data = <String, dynamic>{};
|
||||
data['isUpdate'] = isUpdate;
|
||||
data['appDownloadUrl'] = appDownloadUrl;
|
||||
data['description'] = description;
|
||||
data['isForceUpdate'] = isForceUpdate;
|
||||
return data;
|
||||
}
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user