Merge branch 'master' of https://gitee.com/weishaoyang/star_lock
This commit is contained in:
commit
08e36eee3c
@ -43,8 +43,9 @@ android {
|
||||
}
|
||||
|
||||
defaultConfig {
|
||||
|
||||
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
|
||||
applicationId "com.example.star_lock"
|
||||
applicationId "cn.starlock.lock"
|
||||
// You can update the following values to match your application needs.
|
||||
// For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-build-configuration.
|
||||
// minSdkVersion flutter.minSdkVersion
|
||||
@ -53,28 +54,39 @@ android {
|
||||
targetSdkVersion 33
|
||||
versionCode flutterVersionCode.toInteger()
|
||||
versionName flutterVersionName
|
||||
|
||||
ndk {
|
||||
//设置支持的SO库架构(开发者可以根据需要,选择一个或多个平台的so)
|
||||
abiFilters "armeabi", "armeabi-v7a", "arm64-v8a", "x86","x86_64"
|
||||
}
|
||||
}
|
||||
|
||||
// signingConfigs {
|
||||
// release {
|
||||
// storeFile file("key/keystore.jks")
|
||||
// storePassword '123456'
|
||||
// keyAlias = 'key0'
|
||||
// keyPassword '123456'
|
||||
// }
|
||||
// }
|
||||
signingConfigs {
|
||||
release {
|
||||
storeFile file("starlock.keystore")
|
||||
storePassword '123456'
|
||||
keyAlias = 'starlock'
|
||||
keyPassword '123456'
|
||||
}
|
||||
debug {
|
||||
storeFile file("starlock.keystore")
|
||||
storePassword '123456'
|
||||
keyAlias = 'starlock'
|
||||
keyPassword '123456'
|
||||
}
|
||||
}
|
||||
|
||||
buildTypes {
|
||||
release {
|
||||
// TODO: Add your own signing config for the release build.
|
||||
// Signing with the debug keys for now, so `flutter run --release` works.
|
||||
signingConfig signingConfigs.release
|
||||
}
|
||||
debug {
|
||||
// TODO: Add your own signing config for the release build.
|
||||
// Signing with the debug keys for now, so `flutter run --debug` works.
|
||||
signingConfig signingConfigs.debug
|
||||
}
|
||||
// debug {
|
||||
// // TODO: Add your own signing config for the release build.
|
||||
// // Signing with the debug keys for now, so `flutter run --release` works.
|
||||
// signingConfig signingConfigs.release
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
||||
@ -84,4 +96,6 @@ flutter {
|
||||
|
||||
dependencies {
|
||||
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
|
||||
implementation('com.amap.api:location:5.6.0')
|
||||
implementation('com.amap.api:3dmap:8.1.0')
|
||||
}
|
||||
|
||||
@ -13,10 +13,38 @@
|
||||
<!--允许获取粗略位置,粗略定位必选-->
|
||||
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
|
||||
|
||||
<!--允许获取设备和运营商信息,用于问题排查和网络定位(无gps情况下的定位),若需网络定位功能则必选-->
|
||||
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
|
||||
|
||||
<!--允许获取网络状态,用于网络定位(无gps情况下的定位),若需网络定位功能则必选-->
|
||||
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
|
||||
|
||||
<!--允许获取wifi网络信息,用于网络定位(无gps情况下的定位),若需网络定位功能则必选-->
|
||||
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
|
||||
|
||||
<!--允许获取wifi状态改变,用于网络定位(无gps情况下的定位),若需网络定位功能则必选-->
|
||||
<uses-permission android:name="android.permission.CHANGE_WIFI_STATE" />
|
||||
|
||||
<!--后台获取位置信息,若需后台定位则必选-->
|
||||
<!-- <uses-permission android:name="android.permission.ACCESS_BACKGROUND_LOCATION" />-->
|
||||
|
||||
<!--用于申请调用A-GPS模块,卫星定位加速-->
|
||||
<!-- <uses-permission android:name="android.permission.ACCESS_LOCATION_EXTRA_COMMANDS" />-->
|
||||
|
||||
<!--允许写设备缓存,用于问题排查-->
|
||||
<uses-permission android:name="android.permission.WRITE_SETTINGS" />
|
||||
|
||||
<!--允许写入扩展存储,用于写入缓存定位数据-->
|
||||
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
|
||||
|
||||
<!--允许读设备等信息,用于问题排查-->
|
||||
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
|
||||
<application
|
||||
android:label="star_lock"
|
||||
android:name="${applicationName}"
|
||||
android:icon="@mipmap/ic_launcher">
|
||||
<!-- 配置定位Service -->
|
||||
<service android:name="com.amap.api.location.APSService"/>
|
||||
<activity
|
||||
android:name=".MainActivity"
|
||||
android:exported="true"
|
||||
@ -44,9 +72,6 @@
|
||||
<meta-data
|
||||
android:name="flutterEmbedding"
|
||||
android:value="2" />
|
||||
|
||||
<!-- 配置定位Service -->
|
||||
<service android:name="com.amap.api.location.APSService"/>
|
||||
|
||||
<meta-data android:name="com.amap.api.v2.apikey" android:value="11d49b3f4fc09c04a02bbb7500925ba2"> </meta-data>
|
||||
</application>
|
||||
</manifest>
|
||||
|
||||
@ -15,7 +15,8 @@ buildscript {
|
||||
allprojects {
|
||||
repositories {
|
||||
google()
|
||||
mavenCentral()
|
||||
// mavenCentral()
|
||||
jcenter()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -94,7 +94,8 @@ import 'main/lockDetail/passwordKey/passwordKeyDetail/passwordKeyDetail_page.dar
|
||||
import 'main/lockDetail/passwordKey/passwordKeyList/passwordKeyList_page.dart';
|
||||
import 'main/lockDetail/passwordKey/passwordKeyManage/passwordKeyManage_page.dart';
|
||||
import 'main/lockMian/lockMain/lockMain_page.dart';
|
||||
import 'mine/addLock/lockAddress/lockAddress_page.dart';
|
||||
import 'mine/addLock/lockAddress/gaode/lockAddressGaoDe_page.dart';
|
||||
import 'mine/addLock/lockAddress/lockAddress/lockAddress_page.dart';
|
||||
import 'mine/addLock/nearbyLock/nearbyLock_page.dart';
|
||||
import 'mine/addLock/saveLock/saveLock_page.dart';
|
||||
import 'mine/addLock/seletLockType/seletLockType_page.dart';
|
||||
@ -145,6 +146,7 @@ abstract class Routers {
|
||||
static const addLockPage = '/AddLockPage'; // 选择锁类型
|
||||
static const nearbyLockPage = '/NearbyLockPage'; // 附近的锁
|
||||
static const lockAddressPage = '/LockAddressPage'; // 锁地址
|
||||
static const lockAddressGaoDePage = '/LockAddressGaoDePage'; // 锁地址-高德
|
||||
static const saveLockPage = '/SaveLockPage'; // 保存锁
|
||||
static const lockDetailMainPage = '/LockDetailMainPage'; // 锁详情
|
||||
static const electronicKeyListPage = '/ElectronicKeyListPage'; // 电子钥匙列表
|
||||
@ -807,6 +809,9 @@ abstract class AppRouters {
|
||||
GetPage(
|
||||
name: Routers.adminDetailChangeDatePage,
|
||||
page: () => const AdminDetailChangeDatePage()),
|
||||
GetPage(
|
||||
name: Routers.lockAddressGaoDePage,
|
||||
page: () => const LockAddressGaoDePage()),
|
||||
GetPage(
|
||||
name: Routers.expireLockChangeDatePage,
|
||||
page: () => const ExpireLockChangeDatePage()),
|
||||
|
||||
@ -71,7 +71,7 @@ class BlueManage{
|
||||
if(device.name.isEmpty){
|
||||
return;
|
||||
}
|
||||
print("startScanDevice:${device}");
|
||||
// print("startScanDevice:${device}");
|
||||
if (((device.serviceUuids.isNotEmpty ? device.serviceUuids[0] : "").toString().contains("758824")) && ((device.serviceUuids.isNotEmpty ? device.serviceUuids[0] : "").toString()[31] != "1") && (device.rssi >= -100)) {
|
||||
final knownDeviceIndex = _scanDevices.indexWhere((d) => d.id == device.id);
|
||||
|
||||
@ -146,8 +146,20 @@ class BlueManage{
|
||||
print('Discovering services finished');
|
||||
|
||||
if(isFrist == true){
|
||||
// 第一次添加锁的时候需要先获取公钥
|
||||
IoSenderManage.getPublicKey(lockId: deviceName);
|
||||
// var publicKey = await Storage.getStringList(saveBluePublicKey);
|
||||
// List<int> publicKeyDataList = changeStringListToIntList(publicKey!);
|
||||
// if(publicKeyDataList.isNotEmpty ){
|
||||
// IoSenderManage.getPrivateKey(
|
||||
// lockId:BlueManage().connectDeviceName,
|
||||
// keyID:"1",
|
||||
// authUserID:"1",
|
||||
// nowTime:1,
|
||||
// publicKeyData:publicKeyDataList,
|
||||
// needAuthor:1);
|
||||
// }else{
|
||||
// 第一次添加锁的时候需要先获取公钥
|
||||
IoSenderManage.getPublicKey(lockId: deviceName);
|
||||
// }
|
||||
}
|
||||
connectStateCallBack!(connectionStateUpdate.connectionState);
|
||||
} on Exception catch (e) {
|
||||
@ -250,11 +262,12 @@ class BlueManage{
|
||||
_flutterReactiveBle!.subscribeToCharacteristic(characteristic).listen((data) {
|
||||
// code to handle incoming data
|
||||
print("subscribeToCharacteristic: deviceId = ${characteristic.deviceId} characteristicId =${characteristic.characteristicId}---上报来的数据data = $data");
|
||||
var dataLen = data[8] * 256 + data[9];// 高16位用来指示后面数据块内容的长度
|
||||
var dataLen = 0;// 高16位用来指示后面数据块内容的长度
|
||||
if((data[0] != 0xEF)&&(data[1] != 0x01)&&(data[2] != 0xEE)&&(data[3] != 0x02)){
|
||||
// 分包
|
||||
allData.addAll(data);
|
||||
}else{
|
||||
dataLen = data[8] * 256 + data[9];
|
||||
allData = <int>[];
|
||||
// 初始化数组为空
|
||||
if(dataLen > (data.length - 12)){
|
||||
@ -278,7 +291,7 @@ class BlueManage{
|
||||
Future<void> writeCharacteristicWithResponse(List<int> value) async {
|
||||
QualifiedCharacteristic characteristic = QualifiedCharacteristic(characteristicId: characteristicIdWrite, serviceId: serviceId, deviceId: connectDeviceMacAddress);
|
||||
print('Write with characteristicId:${characteristic.characteristicId} serviceId:${characteristic.serviceId} deviceId:${characteristic.deviceId} value : $value \nhexStr:${radixHex16String(value)}');
|
||||
int mtuLength = await _flutterReactiveBle!.requestMtu(deviceId: characteristic.deviceId, mtu: 30);
|
||||
int mtuLength = await _flutterReactiveBle!.requestMtu(deviceId: characteristic.deviceId, mtu: 512);
|
||||
print("mtuLength:$mtuLength");
|
||||
try {
|
||||
List<int> valueList = value;
|
||||
|
||||
@ -74,6 +74,7 @@ class AddUserCommand extends SenderProtocol {
|
||||
data = getFixedLengthList(data, 40 - keyIDLength);
|
||||
|
||||
//userID 要接受钥匙的用户的useid 20
|
||||
print("添加授权管理员userId:${userID}");
|
||||
int userIDLength = utf8.encode(userID!).length;
|
||||
// print("${commandType!.typeValue}userIDLength:$userIDLength utf8.encode(userID!)${utf8.encode(userID!)}");
|
||||
data.addAll(utf8.encode(userID!));
|
||||
|
||||
114
star_lock/lib/blue/io_protocol/io_getStarLockStatusInfo.dart
Normal file
114
star_lock/lib/blue/io_protocol/io_getStarLockStatusInfo.dart
Normal file
@ -0,0 +1,114 @@
|
||||
|
||||
import 'dart:convert';
|
||||
|
||||
import '../io_reply.dart';
|
||||
import '../io_sender.dart';
|
||||
import '../io_tool/io_tool.dart';
|
||||
import '../io_type.dart';
|
||||
import '../sm4Encipher/sm4.dart';
|
||||
|
||||
class GetStarLockStatuInfoCommand extends SenderProtocol {
|
||||
|
||||
String? lockID;
|
||||
String? userID;
|
||||
List<int>? privateKey;
|
||||
GetStarLockStatuInfoCommand({
|
||||
this.lockID,
|
||||
this.userID,
|
||||
this.privateKey
|
||||
}) : super(CommandType.readStarLockStatusInfo);
|
||||
|
||||
@override
|
||||
List<int> messageDetail() {
|
||||
List<int> data = [];
|
||||
List<int> ebcData = [];
|
||||
|
||||
// 指令类型
|
||||
int type = commandType!.typeValue;
|
||||
double typeDouble = type / 256;
|
||||
int type1 = typeDouble.toInt();
|
||||
int type2 = type % 256;
|
||||
data.add(type1);
|
||||
data.add(type2);
|
||||
|
||||
// 锁id 40
|
||||
int lockIDLength = utf8.encode(lockID!).length;
|
||||
// print("addUserLockIDLength:$lockIDLength utf8.encode(lockID!)${utf8.encode(lockID!)}");
|
||||
data.addAll(utf8.encode(lockID!));
|
||||
data = getFixedLengthList(data, 40 - lockIDLength);
|
||||
|
||||
//userID 要接受钥匙的用户的useid 20
|
||||
int userIDLength = utf8.encode(userID!).length;
|
||||
// print("userIDLength:$userIDLength utf8.encode(userID!)${utf8.encode(userID!)}");
|
||||
data.addAll(utf8.encode(userID!));
|
||||
data = getFixedLengthList(data, 20 - userIDLength);
|
||||
|
||||
if ((data.length % 16) != 0) {
|
||||
int add = (16 - data.length % 16);
|
||||
for (int i = 0; i < add; i++) {
|
||||
data.add(0);
|
||||
}
|
||||
}
|
||||
print("${commandType!.typeName} SM4Data:$data");
|
||||
// 拿到数据之后通过LockId进行SM4 ECB加密 key:544d485f633335373034383064613864
|
||||
ebcData = SM4.encrypt(data, key: privateKey, mode: SM4CryptoMode.ECB);
|
||||
return ebcData;
|
||||
}
|
||||
}
|
||||
|
||||
class GetStarLockStatuInfoReply extends Reply {
|
||||
GetStarLockStatuInfoReply.parseData(CommandType commandType, List<int> dataDetail)
|
||||
: super.parseData(commandType, dataDetail) {
|
||||
data = dataDetail;
|
||||
|
||||
int status = data[2];
|
||||
switch(status){
|
||||
case 0x00:
|
||||
//成功
|
||||
print("${commandType.typeValue} 数据解析成功");
|
||||
|
||||
// 厂商名称
|
||||
var vendor = data.sublist(3, 23);
|
||||
// print("softVersion:$softVersion");
|
||||
|
||||
// 锁设备类型
|
||||
var product = data[23];
|
||||
// print("product:product");
|
||||
|
||||
// 产品名称
|
||||
var model = data.sublist(24, 44);
|
||||
// print("model:model");
|
||||
|
||||
// 软件版本
|
||||
var fwVersion = data.sublist(44, 64);
|
||||
// print("fwVersion:fwVersion");
|
||||
|
||||
// 硬件版本
|
||||
var hwVersion = data.sublist(64, 84);
|
||||
// print("hwVersion:hwVersion");
|
||||
|
||||
|
||||
break;
|
||||
case 0x06:
|
||||
//无权限
|
||||
print("${commandType.typeValue} 需要鉴权");
|
||||
|
||||
break;
|
||||
case 0x07:
|
||||
//无权限
|
||||
print("${commandType.typeValue} 用户无权限");
|
||||
|
||||
break;
|
||||
case 0x09:
|
||||
// 权限校验错误
|
||||
print("${commandType.typeValue} 权限校验错误");
|
||||
|
||||
break;
|
||||
default:
|
||||
//失败
|
||||
print("${commandType.typeValue} 领锁失败");
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -47,6 +47,7 @@ class SenderReferEventRecordNumberCommand extends SenderProtocol {
|
||||
|
||||
// 子命令类型
|
||||
data.add(40);
|
||||
print("timeType:${40}");
|
||||
|
||||
// keyID 40
|
||||
int keyIDLength = utf8.encode(keyID!).length;
|
||||
|
||||
@ -9,7 +9,7 @@ import '../io_type.dart';
|
||||
import '../sm4Encipher/sm4.dart';
|
||||
import 'package:crypto/crypto.dart' as crypto;
|
||||
|
||||
class SenderReferEventRecordNumberTimeCommand extends SenderProtocol {
|
||||
class SenderReferEventRecordTimeCommand extends SenderProtocol {
|
||||
|
||||
String? keyID;
|
||||
String? userID;
|
||||
@ -20,7 +20,7 @@ class SenderReferEventRecordNumberTimeCommand extends SenderProtocol {
|
||||
List<int>? publicKey;
|
||||
List<int>? privateKey;
|
||||
|
||||
SenderReferEventRecordNumberTimeCommand({
|
||||
SenderReferEventRecordTimeCommand({
|
||||
this.keyID,
|
||||
this.userID,
|
||||
this.logsCount,
|
||||
@ -47,7 +47,7 @@ class SenderReferEventRecordNumberTimeCommand extends SenderProtocol {
|
||||
|
||||
// 子命令类型
|
||||
data.add(41);
|
||||
|
||||
print("timeType:${41}");
|
||||
// keyID 40
|
||||
int keyIDLength = utf8.encode(keyID!).length;
|
||||
subData.addAll(utf8.encode(keyID!));
|
||||
@ -112,8 +112,8 @@ class SenderReferEventRecordNumberTimeCommand extends SenderProtocol {
|
||||
}
|
||||
}
|
||||
|
||||
class SenderReferEventRecordNumberTimeReply extends Reply {
|
||||
SenderReferEventRecordNumberTimeReply.parseData(CommandType commandType, List<int> dataDetail)
|
||||
class SenderReferEventRecordTimeReply extends Reply {
|
||||
SenderReferEventRecordTimeReply.parseData(CommandType commandType, List<int> dataDetail)
|
||||
: super.parseData(commandType, dataDetail) {
|
||||
data = dataDetail;
|
||||
}
|
||||
@ -17,6 +17,7 @@ enum CommandType {
|
||||
opsUnlocks, // 运维开锁 0x30f2
|
||||
writeHotelInfo, // 写酒店信息 = 0x3016
|
||||
readHotelInfo, //读酒店信息 0x3017
|
||||
readStarLockStatusInfo, //读星锁状态信息 0x3040
|
||||
}
|
||||
|
||||
extension ExtensionCommandType on CommandType {
|
||||
@ -104,6 +105,11 @@ extension ExtensionCommandType on CommandType {
|
||||
type = CommandType.readHotelInfo;
|
||||
}
|
||||
break;
|
||||
case 0x3040:
|
||||
{
|
||||
type = CommandType.readStarLockStatusInfo;
|
||||
}
|
||||
break;
|
||||
}
|
||||
return type;
|
||||
}
|
||||
@ -159,6 +165,9 @@ extension ExtensionCommandType on CommandType {
|
||||
case CommandType.readHotelInfo:
|
||||
type = 0x3017;
|
||||
break;
|
||||
case CommandType.readStarLockStatusInfo:
|
||||
type = 0x3040;
|
||||
break;
|
||||
}
|
||||
// AppLog.log('数组组装指令类型:$name commandIndex:${IoManager
|
||||
// ().commandIndex}');
|
||||
@ -232,6 +241,9 @@ extension ExtensionCommandType on CommandType {
|
||||
case 0x3017:
|
||||
t = '读酒店信息';
|
||||
break;
|
||||
case 0x3040:
|
||||
t = '读星锁状态信息';
|
||||
break;
|
||||
|
||||
}
|
||||
return t;
|
||||
|
||||
@ -8,6 +8,7 @@ import 'package:star_lock/blue/io_protocol/io_deletUser.dart';
|
||||
import 'package:star_lock/blue/io_protocol/io_editUser.dart';
|
||||
import 'package:star_lock/blue/io_protocol/io_factoryDataReset.dart';
|
||||
import 'package:star_lock/blue/io_protocol/io_getLockStatu.dart';
|
||||
import 'package:star_lock/blue/io_protocol/io_referEventRecordTime.dart';
|
||||
import 'package:star_lock/blue/io_protocol/io_timing.dart';
|
||||
import 'package:star_lock/blue/io_protocol/io_transferPermissions.dart';
|
||||
|
||||
@ -234,6 +235,12 @@ class CommandReciverManager {
|
||||
reply = SenderReferEventRecordNumberReply.parseData(commandType, data);
|
||||
}
|
||||
break;
|
||||
case 41:
|
||||
{
|
||||
// 事件查询记录
|
||||
reply = SenderReferEventRecordTimeReply.parseData(commandType, data);
|
||||
}
|
||||
break;
|
||||
case 51:
|
||||
{
|
||||
// wifi配网结果
|
||||
|
||||
@ -19,7 +19,7 @@ import 'io_protocol/io_getPublicKey.dart';
|
||||
import 'io_protocol/io_openLock.dart';
|
||||
import 'io_protocol/io_queryingFingerprintStatus.dart';
|
||||
import 'io_protocol/io_referEventRecordNumber.dart';
|
||||
import 'io_protocol/io_referEventRecordNumberTime.dart';
|
||||
import 'io_protocol/io_referEventRecordTime.dart';
|
||||
import 'io_protocol/io_senderCustomPasswords.dart';
|
||||
import 'io_protocol/io_timing.dart';
|
||||
import 'io_protocol/io_transferPermissions.dart';
|
||||
@ -390,7 +390,7 @@ class IoSenderManage {
|
||||
}
|
||||
|
||||
//todo:事件记录(时间查询)
|
||||
static void senderReferEventRecordNumberTimeCommand({
|
||||
static void senderReferEventRecordTimeCommand({
|
||||
required String? keyID,
|
||||
required String? userID,
|
||||
required int? logsCount,
|
||||
@ -401,7 +401,7 @@ class IoSenderManage {
|
||||
required List<int>? privateKey,
|
||||
CommandSendCallBack? callBack}) {
|
||||
CommandSenderManager().managerSendData(
|
||||
command: SenderReferEventRecordNumberTimeCommand(
|
||||
command: SenderReferEventRecordTimeCommand(
|
||||
keyID: keyID,
|
||||
userID: userID,
|
||||
logsCount: logsCount,
|
||||
|
||||
@ -71,6 +71,11 @@ class AuthorizedAdminLogic extends BaseGetXController {
|
||||
// 权限校验错误
|
||||
print("${reply.commandType!.typeValue} 权限校验错误");
|
||||
|
||||
break;
|
||||
case 0x14:
|
||||
// 权限校验错误
|
||||
print("${reply.commandType!.typeValue} 用户已存在");
|
||||
|
||||
break;
|
||||
default:
|
||||
//失败
|
||||
@ -99,7 +104,7 @@ class AuthorizedAdminLogic extends BaseGetXController {
|
||||
print("status:$status");
|
||||
|
||||
// userNo = reply.data[46];
|
||||
print("status:$status");
|
||||
// print("status:$status");
|
||||
switch(status){
|
||||
case 0x00:
|
||||
//成功
|
||||
@ -118,15 +123,15 @@ class AuthorizedAdminLogic extends BaseGetXController {
|
||||
List<int> publicKeyDataList = changeStringListToIntList(publicKey!);
|
||||
|
||||
IoSenderManage.senderAddUser(
|
||||
lockID:BlueManage().connectDeviceName,
|
||||
lockID: BlueManage().connectDeviceName,
|
||||
authUserID:await Storage.getUid(),
|
||||
keyID:"1",
|
||||
userID:await Storage.getUid(),
|
||||
userID:state.addUserId.value,
|
||||
openMode:1,
|
||||
keyType:1,
|
||||
startDate:0x11223344,
|
||||
expireDate:0x11223344,
|
||||
role:255,
|
||||
keyType:(state.type.value == "1") ? 0 : 1,
|
||||
startDate:state.effectiveDateTime.value.millisecondsSinceEpoch,
|
||||
expireDate:state.failureDateTime.value.millisecondsSinceEpoch,
|
||||
role:0,
|
||||
password:"123456",
|
||||
needAuthor:1,
|
||||
publicKey:publicKeyDataList,
|
||||
@ -251,8 +256,9 @@ class AuthorizedAdminLogic extends BaseGetXController {
|
||||
if (entity.errorCode!.codeIsSuccessful) {
|
||||
print('发送电子钥匙成功');
|
||||
state.isSendSuccess.value = true;
|
||||
Toast.show(msg: "添加成功");
|
||||
// addUserConnectBlue(entity.data!.receiverUser!.id.toString());
|
||||
// Toast.show(msg: "添加成功");
|
||||
state.addUserId.value = entity.data!.receiverUser!.id.toString();
|
||||
addUserConnectBlue(state.addUserId.value);
|
||||
} else {
|
||||
// Toast.show(msg: '${entity.errorMsg}');
|
||||
if (entity.errorCode == 425) {
|
||||
|
||||
@ -29,7 +29,7 @@ class AuthorizedAdminState {
|
||||
var weekdaysList = [].obs;
|
||||
var isCreateUser = false.obs; //用户未注册时传1 已注册传0
|
||||
|
||||
|
||||
var addUserId = ''.obs;
|
||||
AuthorizedAdminState() {
|
||||
Map map = Get.arguments;
|
||||
lockMainEntity.value = map["lockMainEntity"];
|
||||
|
||||
@ -334,8 +334,8 @@ class _LockSetPageState extends State<LockSetPage> with RouteAware {
|
||||
btnName: TranslationLoader.lanKeys!.delete!.tr,
|
||||
isDelete: true,
|
||||
onClick: () {
|
||||
logic.deletUserAction();
|
||||
// logic.deletLockInfoData();
|
||||
// logic.deletUserAction();
|
||||
logic.deletLockInfoData();
|
||||
}),
|
||||
),
|
||||
],
|
||||
|
||||
@ -417,9 +417,9 @@ class LockDetailLogic extends BaseGetXController{
|
||||
print("onReady()");
|
||||
_initReplySubscription();
|
||||
|
||||
// BlueManage().startScan((v){
|
||||
//
|
||||
// });
|
||||
BlueManage().startScan((v){
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
|
||||
@ -0,0 +1,47 @@
|
||||
class LockOperatingRecordGetLastRecordTimeEntity {
|
||||
int? errorCode;
|
||||
String? description;
|
||||
String? errorMsg;
|
||||
Data? data;
|
||||
|
||||
LockOperatingRecordGetLastRecordTimeEntity(
|
||||
{this.errorCode, this.description, this.errorMsg, this.data});
|
||||
|
||||
LockOperatingRecordGetLastRecordTimeEntity.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 {
|
||||
String? lockId;
|
||||
int? operateDate;
|
||||
|
||||
Data(
|
||||
{this.lockId, this.operateDate});
|
||||
|
||||
Data.fromJson(Map<String, dynamic> json) {
|
||||
lockId = json['lockId'];
|
||||
operateDate = json['operateDate'];
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final Map<String, dynamic> data = <String, dynamic>{};
|
||||
data['lockId'] = lockId;
|
||||
data['operateDate'] = operateDate;
|
||||
return data;
|
||||
}
|
||||
}
|
||||
@ -1,17 +1,24 @@
|
||||
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:flutter_easyloading/flutter_easyloading.dart';
|
||||
import 'package:flutter_reactive_ble/flutter_reactive_ble.dart';
|
||||
import 'package:star_lock/tools/toast.dart';
|
||||
|
||||
import '../../../blue/blue_manage.dart';
|
||||
import '../../../blue/io_protocol/io_referEventRecordNumber.dart';
|
||||
import '../../../blue/io_protocol/io_referEventRecordTime.dart';
|
||||
import '../../../blue/io_reply.dart';
|
||||
import '../../../blue/io_tool/io_manager.dart';
|
||||
import '../../../blue/io_tool/io_tool.dart';
|
||||
import '../../../blue/io_tool/manager_event_bus.dart';
|
||||
import '../../../blue/sender_manage.dart';
|
||||
import '../../../network/api_repository.dart';
|
||||
import '../../../tools/baseGetXController.dart';
|
||||
import '../../../tools/dateTool.dart';
|
||||
import '../../../tools/storage.dart';
|
||||
import '../electronicKey/electronicKeyDetail/keyOperationRecordEntity.dart';
|
||||
import 'lockOperatingRecordGetLastRecordTime_entity.dart';
|
||||
import 'lockOperatingRecord_state.dart';
|
||||
|
||||
class LockOperatingRecordLogic extends BaseGetXController{
|
||||
@ -24,10 +31,14 @@ class LockOperatingRecordLogic extends BaseGetXController{
|
||||
if(reply is SenderReferEventRecordNumberReply) {
|
||||
_replyReferEventRecordNumber(reply);
|
||||
}
|
||||
|
||||
if(reply is SenderReferEventRecordTimeReply) {
|
||||
_replyReferEventRecordTime(reply);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// 校时数据解析
|
||||
// 根据数量查解析数据
|
||||
Future<void> _replyReferEventRecordNumber(Reply reply) async {
|
||||
int status = reply.data[2];
|
||||
switch(status){
|
||||
@ -59,6 +70,64 @@ class LockOperatingRecordLogic extends BaseGetXController{
|
||||
}
|
||||
}
|
||||
|
||||
// 根据时间查解析数据
|
||||
Future<void> _replyReferEventRecordTime(Reply reply) async {
|
||||
int status = reply.data[2];
|
||||
switch(status){
|
||||
case 0x00:
|
||||
//成功
|
||||
print("${reply.commandType}数据解析成功");
|
||||
if(reply.data[5] > 0){
|
||||
reply.data.removeRange(0, 6);
|
||||
// 把得到的数据按8位分割成数组 然后塞进一个新的数组里面
|
||||
var getList = splitList(reply.data, 8);
|
||||
var uploadList = [];
|
||||
for(int i = 0; i<getList.length; i++){
|
||||
var indexList = getList[i];
|
||||
var indexMap = {};
|
||||
indexMap["seq"] = indexList[0].toString();
|
||||
indexMap["user"] = indexList[3].toString();
|
||||
indexMap["pwd"] = indexList[2].toString();
|
||||
indexMap["success"] = "1";
|
||||
indexMap["type"] = indexList[1].toString();
|
||||
|
||||
int value = ((0xff & indexList[(4)]) << 24 |
|
||||
(0xff & indexList[5]) << 16 |
|
||||
(0xff & indexList[6]) << 8 |
|
||||
(0xFF & indexList[7]));
|
||||
// indexMap["date"] = DateTool().dateToYMDHNSString("$value");
|
||||
// print("value:${DateTool().dateToYMDHNSString("$value")}");
|
||||
|
||||
indexMap["date"] = value.toString();
|
||||
uploadList.add(indexMap);
|
||||
}
|
||||
lockRecordUploadData(uploadList);
|
||||
// print("reply.data:${reply.data} getList:$getList}");
|
||||
}
|
||||
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> senderReferEventRecordNumber() async {
|
||||
BlueManage().judgeReconnect(BlueManage().connectDeviceMacAddress, BlueManage().connectDeviceName, (DeviceConnectionState state) async {
|
||||
@ -87,7 +156,7 @@ class LockOperatingRecordLogic extends BaseGetXController{
|
||||
}
|
||||
|
||||
// 查询事件记录(时间查询)
|
||||
Future<void> senderReferEventRecordNumberTime() async {
|
||||
Future<void> senderReferEventRecordTime(int time) async {
|
||||
BlueManage().judgeReconnect(BlueManage().connectDeviceMacAddress, BlueManage().connectDeviceName, (DeviceConnectionState state) async {
|
||||
if (state == DeviceConnectionState.connected) {
|
||||
var privateKey = await Storage.getStringList(saveBluePrivateKey);
|
||||
@ -99,11 +168,13 @@ class LockOperatingRecordLogic extends BaseGetXController{
|
||||
var publicKey = await Storage.getStringList(saveBluePublicKey);
|
||||
List<int> getPublicKeyList = changeStringListToIntList(publicKey!);
|
||||
|
||||
IoSenderManage.senderReferEventRecordNumberTimeCommand(
|
||||
EasyLoading.show();
|
||||
IoSenderManage.senderReferEventRecordTimeCommand(
|
||||
keyID:BlueManage().connectDeviceName,
|
||||
userID:await Storage.getUid(),
|
||||
logsCount:20,
|
||||
time:DateTime.now().millisecondsSinceEpoch~/1000,
|
||||
// time:DateTime.now().millisecondsSinceEpoch~/1000,
|
||||
time: time,
|
||||
token:getTokenList,
|
||||
needAuthor:1,
|
||||
publicKey:getPublicKeyList,
|
||||
@ -113,6 +184,60 @@ class LockOperatingRecordLogic extends BaseGetXController{
|
||||
});
|
||||
}
|
||||
|
||||
//请求操作记录列表
|
||||
void mockNetworkDataRequest() async {
|
||||
KeyOperationRecordEntity entity = await ApiRepository.to.lockRecordList(
|
||||
'0',
|
||||
state.keyInfos.value.keyId.toString(),
|
||||
'0',
|
||||
state.keyInfos.value.lockId.toString(),
|
||||
'1',
|
||||
'1',
|
||||
'20',
|
||||
'0',
|
||||
'',
|
||||
'',
|
||||
'',
|
||||
'',
|
||||
'',
|
||||
'');
|
||||
if (entity.errorCode!.codeIsSuccessful) {
|
||||
print("操作记录列表成功:${entity.data?.itemList}");
|
||||
state.lockOperatingRecordListData.value = entity.data!.itemList!;
|
||||
}else{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
// 查询锁记录最后时间
|
||||
void getLockRecordLastUploadDataTime() async {
|
||||
LockOperatingRecordGetLastRecordTimeEntity entity =
|
||||
await ApiRepository.to.getLockRecordLastUploadDataTime(lockId: state.keyInfos.value.lockId.toString());
|
||||
if (entity.errorCode!.codeIsSuccessful) {
|
||||
senderReferEventRecordTime(entity.data!.operateDate!);
|
||||
}
|
||||
}
|
||||
|
||||
// 操作记录上传
|
||||
void lockRecordUploadData(List list) async {
|
||||
KeyOperationRecordEntity entity =
|
||||
await ApiRepository.to.lockRecordUploadData(
|
||||
lockId: state.keyInfos.value.lockId.toString(),
|
||||
records: list);
|
||||
if (entity.errorCode!.codeIsSuccessful) {
|
||||
mockNetworkDataRequest();
|
||||
}
|
||||
}
|
||||
|
||||
//清空操作记录
|
||||
void clearOperationRecordRequest() async {
|
||||
KeyOperationRecordEntity entity =
|
||||
await ApiRepository.to.clearOperationRecord('28');
|
||||
if (entity.errorCode!.codeIsSuccessful) {
|
||||
Toast.show(msg: "清除数据成功");
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
void onReady() {
|
||||
// TODO: implement onReady
|
||||
@ -120,6 +245,8 @@ class LockOperatingRecordLogic extends BaseGetXController{
|
||||
print("onReady()");
|
||||
|
||||
_initReplySubscription();
|
||||
|
||||
mockNetworkDataRequest();
|
||||
}
|
||||
|
||||
@override
|
||||
@ -128,8 +255,9 @@ class LockOperatingRecordLogic extends BaseGetXController{
|
||||
super.onInit();
|
||||
print("onInit()");
|
||||
|
||||
// senderReferEventRecordNumberTime();
|
||||
senderReferEventRecordNumber();
|
||||
getLockRecordLastUploadDataTime();
|
||||
// senderReferEventRecordTime();
|
||||
// senderReferEventRecordNumber();
|
||||
}
|
||||
|
||||
@override
|
||||
|
||||
@ -8,6 +8,7 @@ import 'package:star_lock/main/lockMian/entity/lockInfoEntity.dart';
|
||||
|
||||
import '../../../app_settings/app_colors.dart';
|
||||
import '../../../tools/jh_pop_menus.dart';
|
||||
import '../../../tools/noData.dart';
|
||||
import '../../../tools/titleAppBar.dart';
|
||||
import '../../../translations/trans_lib.dart';
|
||||
import 'lockOperatingRecord_logic.dart';
|
||||
@ -24,18 +25,18 @@ class _LockOperatingRecordPageState extends State<LockOperatingRecordPage> {
|
||||
final logic = Get.put(LockOperatingRecordLogic());
|
||||
final state = Get.find<LockOperatingRecordLogic>().state;
|
||||
|
||||
late KeyInfos keyInfo;
|
||||
late LockMainEntity lockMainEntity;
|
||||
// late KeyInfos keyInfo;
|
||||
// late LockMainEntity lockMainEntity;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
dynamic obj = ModalRoute.of(context)?.settings.arguments;
|
||||
if (obj != null && (obj["lockMainEntity"] != null)) {
|
||||
lockMainEntity = obj["lockMainEntity"];
|
||||
}
|
||||
if (obj != null && (obj["keyInfo"] != null)) {
|
||||
keyInfo = obj["keyInfo"];
|
||||
}
|
||||
// dynamic obj = ModalRoute.of(context)?.settings.arguments;
|
||||
// if (obj != null && (obj["lockMainEntity"] != null)) {
|
||||
// lockMainEntity = obj["lockMainEntity"];
|
||||
// }
|
||||
// if (obj != null && (obj["keyInfo"] != null)) {
|
||||
// keyInfo = obj["keyInfo"];
|
||||
// }
|
||||
|
||||
return Scaffold(
|
||||
backgroundColor: AppColors.mainBackgroundColor,
|
||||
@ -55,9 +56,9 @@ class _LockOperatingRecordPageState extends State<LockOperatingRecordPage> {
|
||||
print('选中index: $index');
|
||||
print('选中text: $selText');
|
||||
if (index == 0) {
|
||||
mockNetworkDataRequest();
|
||||
logic.mockNetworkDataRequest();
|
||||
} else if (index == 1) {
|
||||
clearOperationRecordRequest();
|
||||
logic.clearOperationRecordRequest();
|
||||
}
|
||||
}, listData: [
|
||||
{'text': '读取记录'},
|
||||
@ -68,90 +69,26 @@ class _LockOperatingRecordPageState extends State<LockOperatingRecordPage> {
|
||||
),
|
||||
],
|
||||
),
|
||||
body: FutureBuilder<List<KeyRecordDataItem>>(
|
||||
future: mockNetworkDataRequest(),
|
||||
builder: (BuildContext context,
|
||||
AsyncSnapshot<List<KeyRecordDataItem>> snapshot) {
|
||||
//请求结束
|
||||
if (snapshot.connectionState == ConnectionState.done) {
|
||||
if (snapshot.hasError) {
|
||||
//请求失败
|
||||
return const Text('请求失败');
|
||||
} else {
|
||||
//请求成功
|
||||
final List<KeyRecordDataItem> itemDataList = snapshot.data!;
|
||||
|
||||
return Column(
|
||||
children: [
|
||||
Container(
|
||||
padding: EdgeInsets.all(20.h),
|
||||
child: Text(
|
||||
TranslationLoader.lanKeys!.lockOperatingRecordTip!.tr,
|
||||
textAlign: TextAlign.start,
|
||||
style: TextStyle(fontSize: 20.sp),
|
||||
),
|
||||
),
|
||||
_searchWidget(),
|
||||
SizedBox(
|
||||
height: 10.h,
|
||||
),
|
||||
Expanded(child: _buildMainUI(itemDataList)),
|
||||
],
|
||||
);
|
||||
}
|
||||
} else {
|
||||
//请求未结束 显示loading
|
||||
return Container();
|
||||
}
|
||||
}),
|
||||
body: Column(
|
||||
children: [
|
||||
Container(
|
||||
padding: EdgeInsets.all(20.h),
|
||||
child: Text(
|
||||
TranslationLoader.lanKeys!.lockOperatingRecordTip!.tr,
|
||||
textAlign: TextAlign.start,
|
||||
style: TextStyle(fontSize: 20.sp),
|
||||
),
|
||||
),
|
||||
_searchWidget(),
|
||||
SizedBox(
|
||||
height: 10.h,
|
||||
),
|
||||
Expanded(child: _buildMainUI()),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
//请求操作记录列表
|
||||
Future<List<KeyRecordDataItem>> mockNetworkDataRequest() async {
|
||||
KeyOperationRecordEntity entity = await ApiRepository.to.lockRecordList(
|
||||
'0',
|
||||
keyInfo.keyId.toString(),
|
||||
'0',
|
||||
keyInfo.lockId.toString(),
|
||||
'1',
|
||||
'1',
|
||||
'20',
|
||||
'0',
|
||||
'',
|
||||
'',
|
||||
'',
|
||||
'',
|
||||
'',
|
||||
'');
|
||||
if (entity.errorCode!.codeIsSuccessful) {
|
||||
print("操作记录列表成功:${entity.data?.itemList}");
|
||||
}
|
||||
final data = entity.data;
|
||||
if (data != null) {
|
||||
return data.itemList!;
|
||||
} else {
|
||||
List<KeyRecordDataItem> dataList = [];
|
||||
return dataList;
|
||||
}
|
||||
}
|
||||
|
||||
//清空操作记录
|
||||
Future<List<KeyRecordDataItem>> clearOperationRecordRequest() async {
|
||||
KeyOperationRecordEntity entity =
|
||||
await ApiRepository.to.clearOperationRecord('28');
|
||||
if (entity.errorCode!.codeIsSuccessful) {
|
||||
print("操作记录列表成功:${entity.data?.itemList}");
|
||||
}
|
||||
final data = entity.data;
|
||||
if (data != null) {
|
||||
return data.itemList!;
|
||||
} else {
|
||||
List<KeyRecordDataItem> dataList = [];
|
||||
return dataList;
|
||||
}
|
||||
}
|
||||
|
||||
Widget _searchWidget() {
|
||||
return Container(
|
||||
height: 60.h,
|
||||
@ -187,11 +124,11 @@ class _LockOperatingRecordPageState extends State<LockOperatingRecordPage> {
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildMainUI(List<KeyRecordDataItem> itemDataList) {
|
||||
return ListView.separated(
|
||||
itemCount: itemDataList.length,
|
||||
Widget _buildMainUI() {
|
||||
return Obx(() => state.lockOperatingRecordListData.value.isNotEmpty ? ListView.separated(
|
||||
itemCount: state.lockOperatingRecordListData.length,
|
||||
itemBuilder: (c, index) {
|
||||
KeyRecordDataItem dataItem = itemDataList[index];
|
||||
KeyRecordDataItem dataItem = state.lockOperatingRecordListData[index];
|
||||
int? operateDate = dataItem.operateDate;
|
||||
DateTime dateStr = DateTime.fromMillisecondsSinceEpoch(operateDate!);
|
||||
String operateDateStr =
|
||||
@ -201,7 +138,7 @@ class _LockOperatingRecordPageState extends State<LockOperatingRecordPage> {
|
||||
'images/controls_user.png',
|
||||
dataItem.username ?? "未知",
|
||||
'$operateDateStr用${dataItem.recordTypeName}',
|
||||
() {});
|
||||
() {});
|
||||
},
|
||||
separatorBuilder: (BuildContext context, int index) {
|
||||
return const Divider(
|
||||
@ -209,7 +146,7 @@ class _LockOperatingRecordPageState extends State<LockOperatingRecordPage> {
|
||||
color: AppColors.greyLineColor,
|
||||
);
|
||||
},
|
||||
);
|
||||
) : const NoData());
|
||||
}
|
||||
|
||||
Widget _dateItem(String lockDate) {
|
||||
|
||||
@ -1,4 +1,15 @@
|
||||
|
||||
import 'package:get/get.dart';
|
||||
|
||||
import '../../lockMian/entity/lockInfoEntity.dart';
|
||||
import '../electronicKey/electronicKeyDetail/keyOperationRecordEntity.dart';
|
||||
|
||||
class LockOperatingRecordState{
|
||||
final keyInfos = KeyInfos().obs;
|
||||
final lockOperatingRecordListData = <KeyRecordDataItem>[].obs;
|
||||
|
||||
LockOperatingRecordState() {
|
||||
keyInfos.value = Get.arguments["keyInfo"];
|
||||
}
|
||||
|
||||
}
|
||||
@ -441,13 +441,13 @@ class KeyInfos {
|
||||
}
|
||||
|
||||
class LockVersion {
|
||||
int? scene;
|
||||
int? protocolVersion;
|
||||
String? scene;
|
||||
String? protocolVersion;
|
||||
String? logoUrl;
|
||||
int? orgId;
|
||||
String? orgId;
|
||||
bool? showAdminKbpwdFlag;
|
||||
int? protocolType;
|
||||
int? groupId;
|
||||
String? protocolType;
|
||||
String? groupId;
|
||||
|
||||
LockVersion(
|
||||
{this.scene,
|
||||
|
||||
@ -0,0 +1,81 @@
|
||||
|
||||
|
||||
import 'package:amap_flutter_location/amap_flutter_location.dart';
|
||||
import 'package:amap_flutter_location/amap_location_option.dart';
|
||||
import 'package:permission_handler/permission_handler.dart';
|
||||
import 'package:star_lock/tools/baseGetXController.dart';
|
||||
|
||||
import 'lockAddressGaoDe_state.dart';
|
||||
|
||||
class LockAddressGaoDeLogic extends BaseGetXController{
|
||||
LockAddressGaoDeState state = LockAddressGaoDeState();
|
||||
|
||||
// Future<void> requestPermission() async {
|
||||
// final status = await Permission.location.request();
|
||||
// print("Permission.location.request()=status:$status");
|
||||
// // state.permissionStatus = status;
|
||||
// switch (status) {
|
||||
// case PermissionStatus.denied:
|
||||
// print("拒绝");
|
||||
// break;
|
||||
// case PermissionStatus.granted:
|
||||
// requestLocation();
|
||||
// break;
|
||||
// case PermissionStatus.limited:
|
||||
// print("限制");
|
||||
// break;
|
||||
// default:
|
||||
// print("其他状态");
|
||||
// requestLocation();
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// Future<void> requestLocation() async {
|
||||
// state.location = AMapFlutterLocation()
|
||||
// ..setLocationOption(AMapLocationOption())
|
||||
// ..onLocationChanged().listen((event) {
|
||||
// print("listenLocationChanged$event");
|
||||
// state.latitude.value = double.parse(event['latitude'] as String);
|
||||
// state.longitude.value = double.parse(event['longitude'] as String);
|
||||
// if (state.latitude.value != 0 && state.longitude.value != 0) {
|
||||
// // widget.callback(event);
|
||||
// state.addressInfo.value = event;
|
||||
// // currentLocation = CameraPosition(
|
||||
// // target: LatLng(latitude, longitude),
|
||||
// // zoom: 10,
|
||||
// // );
|
||||
// }
|
||||
// })
|
||||
// ..startLocation();
|
||||
// }
|
||||
|
||||
@override
|
||||
void onReady() {
|
||||
// TODO: implement onReady
|
||||
super.onReady();
|
||||
print("onReady()");
|
||||
|
||||
}
|
||||
|
||||
@override
|
||||
void onInit() {
|
||||
// TODO: implement onInit
|
||||
super.onInit();
|
||||
print("onInit()");
|
||||
|
||||
// AMapFlutterLocation.updatePrivacyAgree(true);
|
||||
// AMapFlutterLocation.updatePrivacyShow(true, true);
|
||||
// AMapFlutterLocation.setApiKey("11d49b3f4fc09c04a02bbb7500925ba2", "883a3355d2d77c2fdc2667030dc97ffe");
|
||||
//
|
||||
// requestPermission();
|
||||
}
|
||||
|
||||
@override
|
||||
void onClose() {
|
||||
// TODO: implement onClose
|
||||
super.onClose();
|
||||
print("地图界面onClose()");
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,212 @@
|
||||
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:amap_flutter_location/amap_flutter_location.dart';
|
||||
import 'package:amap_flutter_location/amap_location_option.dart';
|
||||
|
||||
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:permission_handler/permission_handler.dart';
|
||||
import 'package:amap_flutter_map/amap_flutter_map.dart';
|
||||
import 'package:amap_flutter_base/amap_flutter_base.dart';
|
||||
|
||||
import '../../../../appRouters.dart';
|
||||
import '../../../../app_settings/app_colors.dart';
|
||||
import '../../../../tools/titleAppBar.dart';
|
||||
import '../../../../tools/toast.dart';
|
||||
import '../../../../translations/trans_lib.dart';
|
||||
|
||||
// typedef BlockAddressMapCallback = void Function(dynamic addressMap);
|
||||
|
||||
class LockAddressGaoDePage extends StatefulWidget {
|
||||
// BlockAddressMapCallback callback;
|
||||
|
||||
const LockAddressGaoDePage({Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
State<LockAddressGaoDePage> createState() => _LockAddressGaoDePageState();
|
||||
}
|
||||
|
||||
class _LockAddressGaoDePageState extends State<LockAddressGaoDePage>{
|
||||
// 高德地图
|
||||
static const AMapApiKey amapApiKeys = AMapApiKey(iosKey: '883a3355d2d77c2fdc2667030dc97ffe', androidKey: '11d49b3f4fc09c04a02bbb7500925ba2');
|
||||
|
||||
AMapController? mapController;
|
||||
AMapFlutterLocation? location;
|
||||
|
||||
PermissionStatus? permissionStatus;
|
||||
Map<String, Object>? addressInfo;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
|
||||
AMapFlutterLocation.updatePrivacyAgree(true);
|
||||
AMapFlutterLocation.updatePrivacyShow(true, true);
|
||||
AMapFlutterLocation.setApiKey("11d49b3f4fc09c04a02bbb7500925ba2", "883a3355d2d77c2fdc2667030dc97ffe");
|
||||
|
||||
requestPermission();
|
||||
}
|
||||
|
||||
Future<void> requestPermission() async {
|
||||
final status = await Permission.location.request();
|
||||
print("Permission.location.request()=status:$status");
|
||||
permissionStatus = status;
|
||||
switch (status) {
|
||||
case PermissionStatus.denied:
|
||||
print("拒绝");
|
||||
break;
|
||||
case PermissionStatus.granted:
|
||||
requestLocation();
|
||||
break;
|
||||
case PermissionStatus.limited:
|
||||
print("限制");
|
||||
break;
|
||||
default:
|
||||
print("其他状态");
|
||||
requestLocation();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> requestLocation() async {
|
||||
location = AMapFlutterLocation()
|
||||
..setLocationOption(AMapLocationOption())
|
||||
..onLocationChanged().listen((event) {
|
||||
print("listenLocationChanged$event");
|
||||
// double? latitude = double.parse(event['latitude']);
|
||||
// double? longitude = double.parse(event['longitude'] as String);
|
||||
if (event.isNotEmpty) {
|
||||
// widget.callback(event);
|
||||
setState(() {
|
||||
addressInfo = event;
|
||||
// currentLocation = CameraPosition(
|
||||
// target: LatLng(latitude, longitude),
|
||||
// zoom: 10,
|
||||
// );
|
||||
});
|
||||
}
|
||||
})
|
||||
..startLocation();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
backgroundColor: AppColors.mainBackgroundColor,
|
||||
appBar: TitleAppBar(
|
||||
barTitle: TranslationLoader.lanKeys!.lockAddress!.tr,
|
||||
haveBack: true,
|
||||
backgroundColor: AppColors.mainColor,
|
||||
actionsList: [
|
||||
TextButton(
|
||||
child: Text(
|
||||
TranslationLoader.lanKeys!.next!.tr,
|
||||
style: TextStyle(color: Colors.white, fontSize: 24.sp),
|
||||
),
|
||||
onPressed: () {
|
||||
if(addressInfo!.isEmpty){
|
||||
Toast.show(msg:"还未获取到位置信息哦,请耐心等待一下!");
|
||||
return;
|
||||
}
|
||||
Get.toNamed(Routers.saveLockPage, arguments: addressInfo);
|
||||
// Navigator.pushNamed(context, Routers.saveLockPage);
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
body:
|
||||
addressInfo != null ?
|
||||
Container(
|
||||
width: 1.sw,
|
||||
// height: 1.sh,
|
||||
child: Stack(
|
||||
children: [
|
||||
SizedBox(
|
||||
// height: 1.sh - 40.h,
|
||||
// width: 1.sw,
|
||||
child:
|
||||
(addressInfo!["address"].toString().isNotEmpty) ?
|
||||
AMapWidget(
|
||||
apiKey: amapApiKeys,
|
||||
// 初始化地图中心
|
||||
initialCameraPosition: (
|
||||
CameraPosition(
|
||||
target: LatLng(double.parse(addressInfo!['latitude'] as String), double.parse(addressInfo!['longitude'] as String)),
|
||||
zoom: 10.0,
|
||||
)
|
||||
),
|
||||
//定位小蓝点
|
||||
myLocationStyleOptions: MyLocationStyleOptions(
|
||||
true,
|
||||
),
|
||||
// 普通地图normal,卫星地图satellite,夜间视图night,导航视图 navi,公交视图bus,
|
||||
mapType: MapType.normal,
|
||||
// 缩放级别范围
|
||||
minMaxZoomPreference: const MinMaxZoomPreference(3, 20),
|
||||
// 隐私政策包含高德 必须填写
|
||||
privacyStatement: const AMapPrivacyStatement(hasAgree: true, hasContains: true, hasShow: true),
|
||||
// 地图创建成功时返回AMapController
|
||||
onMapCreated: (AMapController controller) {
|
||||
mapController = controller;
|
||||
},
|
||||
)
|
||||
: Container(),
|
||||
),
|
||||
Positioned(
|
||||
left: 20.w, right: 20.w, bottom: 100.h,
|
||||
child: Container(
|
||||
// height: h(106),
|
||||
decoration: BoxDecoration(
|
||||
color: AppColors.mainColor,
|
||||
borderRadius: BorderRadius.circular(15.w),
|
||||
),
|
||||
child:Column(
|
||||
children: [
|
||||
Container(
|
||||
// height: h(53),
|
||||
padding: EdgeInsets.only(top: 15.h, bottom: 15, left:15.w, right: 15.w),
|
||||
child: Row(
|
||||
children: [
|
||||
Image.asset('images/main/icon_addUserShowAddress.png', width: 30.w, height: 30.w),
|
||||
SizedBox(width: 10.w),
|
||||
Expanded(
|
||||
child: Text(addressInfo!["address"].toString() ?? "", style: const TextStyle(color: Colors.white, fontSize: 16, fontWeight: FontWeight.w500, overflow: TextOverflow.clip))
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
// Container(height: 1.h, color: const Color(0xFF021732),),
|
||||
// Container(
|
||||
// // height: h(52),
|
||||
// padding: EdgeInsets.only(top: 15.h, bottom: 15, left:15.w, right: 15.w),
|
||||
// child: Row(
|
||||
// children: [
|
||||
// Image.asset('images/main/icon_addUserAddressShowTime.png', width: 30.w, height: 30.w),
|
||||
// SizedBox(width: 10.w,),
|
||||
// Expanded(
|
||||
// child: Text(DateTool().getNowDateYMDHM(), style: const TextStyle(color: Colors.white, fontSize: 16, fontWeight: FontWeight.w500),)
|
||||
// ),
|
||||
// ],
|
||||
// ),
|
||||
// ),
|
||||
],
|
||||
)
|
||||
),),
|
||||
],
|
||||
),
|
||||
)
|
||||
: const Center(child: Text('地图加载中,请稍候。。。')),
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
super.dispose();
|
||||
|
||||
location?.destroy();
|
||||
print("地图界面销毁了");
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,17 @@
|
||||
|
||||
import 'package:amap_flutter_location/amap_flutter_location.dart';
|
||||
import 'package:amap_flutter_map/amap_flutter_map.dart';
|
||||
import 'package:amap_flutter_base/amap_flutter_base.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:permission_handler/permission_handler.dart';
|
||||
|
||||
class LockAddressGaoDeState{
|
||||
|
||||
// AMapController? mapController;
|
||||
// AMapFlutterLocation? location;
|
||||
// // PermissionStatus? permissionStatus;
|
||||
//
|
||||
// final addressInfo = {}.obs;
|
||||
// final latitude = 39.909187.obs;
|
||||
// final longitude = 116.397451.obs;
|
||||
}
|
||||
@ -1,5 +1,5 @@
|
||||
|
||||
import '../../../tools/baseGetXController.dart';
|
||||
import '../../../../tools/baseGetXController.dart';
|
||||
import 'lockAddress_state.dart';
|
||||
|
||||
class LockAddressLogic extends BaseGetXController {
|
||||
@ -4,14 +4,15 @@ import 'dart:io';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:star_lock/tools/toast.dart';
|
||||
|
||||
import '../../../appRouters.dart';
|
||||
import '../../../app_settings/app_colors.dart';
|
||||
import '../../../main.dart';
|
||||
import '../../../tools/titleAppBar.dart';
|
||||
import '../../../translations/trans_lib.dart';
|
||||
import '../../../../appRouters.dart';
|
||||
import '../../../../app_settings/app_colors.dart';
|
||||
import '../../../../main.dart';
|
||||
import '../../../../tools/titleAppBar.dart';
|
||||
import '../../../../translations/trans_lib.dart';
|
||||
|
||||
import 'lockAddressGaoDe_page.dart';
|
||||
import '../gaode/lockAddressGaoDe_page.dart';
|
||||
|
||||
class LockAddressPage extends StatefulWidget {
|
||||
const LockAddressPage({Key? key}) : super(key: key);
|
||||
@ -38,23 +39,27 @@ class _LockAddressPageState extends State<LockAddressPage> with RouteAware{
|
||||
style: TextStyle(color: Colors.white, fontSize: 24.sp),
|
||||
),
|
||||
onPressed: () {
|
||||
if(addressInfo!.isEmpty){
|
||||
Toast.show(msg:"请先获取到位置信息哦!");
|
||||
return;
|
||||
}
|
||||
Get.toNamed(Routers.saveLockPage, arguments: addressInfo);
|
||||
// Navigator.pushNamed(context, Routers.saveLockPage);
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
body: LockAddressGaoDePage(callback: (addressInfoMap){
|
||||
addressInfo = addressInfoMap;
|
||||
},)
|
||||
// body: Container(),
|
||||
// body: LockAddressGaoDePage(callback: (addressInfoMap){
|
||||
// addressInfo = addressInfoMap;
|
||||
// },)
|
||||
body: Container(),
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
super.dispose();
|
||||
routeObserver.unsubscribe(this);
|
||||
// routeObserver.unsubscribe(this);
|
||||
print("地图界面销毁了");
|
||||
}
|
||||
|
||||
@ -1,183 +0,0 @@
|
||||
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:amap_flutter_location/amap_flutter_location.dart';
|
||||
import 'package:amap_flutter_location/amap_location_option.dart';
|
||||
|
||||
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
||||
import 'package:permission_handler/permission_handler.dart';
|
||||
import 'package:amap_flutter_map/amap_flutter_map.dart';
|
||||
import 'package:amap_flutter_base/amap_flutter_base.dart';
|
||||
|
||||
import '../../../app_settings/app_colors.dart';
|
||||
|
||||
typedef BlockAddressMapCallback = void Function(dynamic addressMap);
|
||||
|
||||
class LockAddressGaoDePage extends StatefulWidget {
|
||||
BlockAddressMapCallback callback;
|
||||
|
||||
LockAddressGaoDePage({Key? key, required this.callback}) : super(key: key);
|
||||
|
||||
@override
|
||||
State<LockAddressGaoDePage> createState() => _LockAddressGaoDePageState();
|
||||
}
|
||||
|
||||
class _LockAddressGaoDePageState extends State<LockAddressGaoDePage>{
|
||||
// 高德地图
|
||||
static const AMapApiKey amapApiKeys = AMapApiKey(iosKey: '883a3355d2d77c2fdc2667030dc97ffe', androidKey: '11d49b3f4fc09c04a02bbb7500925ba2');
|
||||
|
||||
AMapController? mapController;
|
||||
AMapFlutterLocation? location;
|
||||
|
||||
PermissionStatus? permissionStatus;
|
||||
Map<String, Object>? addressInfo;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
AMapFlutterLocation.setApiKey("11d49b3f4fc09c04a02bbb7500925ba2", "883a3355d2d77c2fdc2667030dc97ffe");
|
||||
AMapFlutterLocation.updatePrivacyAgree(true);
|
||||
AMapFlutterLocation.updatePrivacyShow(true, true);
|
||||
|
||||
requestPermission();
|
||||
}
|
||||
|
||||
Future<void> requestPermission() async {
|
||||
final status = await Permission.location.request();
|
||||
permissionStatus = status;
|
||||
switch (status) {
|
||||
case PermissionStatus.denied:
|
||||
print("拒绝");
|
||||
break;
|
||||
case PermissionStatus.granted:
|
||||
requestLocation();
|
||||
break;
|
||||
case PermissionStatus.limited:
|
||||
print("限制");
|
||||
break;
|
||||
default:
|
||||
print("其他状态");
|
||||
requestLocation();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void requestLocation() {
|
||||
location = AMapFlutterLocation()
|
||||
..setLocationOption(AMapLocationOption())
|
||||
..onLocationChanged().listen((event) {
|
||||
print("listenLocationChanged$event");
|
||||
double? latitude = double.parse(event['latitude'] as String);
|
||||
double? longitude = double.parse(event['longitude'] as String);
|
||||
if (latitude != 0 && longitude != 0) {
|
||||
widget.callback(event);
|
||||
setState(() {
|
||||
addressInfo = event;
|
||||
// currentLocation = CameraPosition(
|
||||
// target: LatLng(latitude, longitude),
|
||||
// zoom: 10,
|
||||
// );
|
||||
});
|
||||
}
|
||||
})
|
||||
..startLocation();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
if (addressInfo?['latitude'] == null ||
|
||||
addressInfo?['longitude'] == null ||
|
||||
addressInfo?['errorCode'] == 0) {
|
||||
return const Center(child: Text('地图加载中,请稍候。。。'));
|
||||
}
|
||||
|
||||
var latitude = 39.909187;
|
||||
var longitude = 116.397451;
|
||||
if(addressInfo!.containsKey('latitude')){
|
||||
latitude = double.parse(addressInfo!['latitude'] as String);
|
||||
longitude = double.parse(addressInfo!['longitude'] as String);
|
||||
}
|
||||
|
||||
return Stack(
|
||||
children: [
|
||||
Container(
|
||||
height: MediaQuery.of(context).size.height,
|
||||
width: MediaQuery.of(context).size.width,
|
||||
child: (addressInfo!["address"].toString().isNotEmpty) ? AMapWidget(
|
||||
apiKey: amapApiKeys,
|
||||
// 初始化地图中心
|
||||
initialCameraPosition: (
|
||||
CameraPosition(
|
||||
target: LatLng(latitude, longitude),
|
||||
zoom: 10.0,
|
||||
)
|
||||
),
|
||||
//定位小蓝点
|
||||
myLocationStyleOptions: MyLocationStyleOptions(
|
||||
true,
|
||||
),
|
||||
// 普通地图normal,卫星地图satellite,夜间视图night,导航视图 navi,公交视图bus,
|
||||
mapType: MapType.normal,
|
||||
// 缩放级别范围
|
||||
minMaxZoomPreference: const MinMaxZoomPreference(3, 20),
|
||||
// 隐私政策包含高德 必须填写
|
||||
privacyStatement: const AMapPrivacyStatement(hasAgree: true, hasContains: true, hasShow: true),
|
||||
// 地图创建成功时返回AMapController
|
||||
onMapCreated: (AMapController controller) {
|
||||
mapController = controller;
|
||||
},
|
||||
): Container(),
|
||||
),
|
||||
Positioned(
|
||||
left: 20.w, right: 20.w, bottom: 100.h,
|
||||
child: Container(
|
||||
// height: h(106),
|
||||
decoration: BoxDecoration(
|
||||
color: AppColors.mainColor,
|
||||
borderRadius: BorderRadius.circular(15.w),
|
||||
),
|
||||
child:Column(
|
||||
children: [
|
||||
Container(
|
||||
// height: h(53),
|
||||
padding: EdgeInsets.only(top: 15.h, bottom: 15, left:15.w, right: 15.w),
|
||||
child: Row(
|
||||
children: [
|
||||
Image.asset('images/main/icon_addUserShowAddress.png', width: 30.w, height: 30.w),
|
||||
SizedBox(width: 10.w),
|
||||
Expanded(
|
||||
child: Text(addressInfo!["address"].toString() ?? "", style: const TextStyle(color: Colors.white, fontSize: 16, fontWeight: FontWeight.w500, overflow: TextOverflow.clip))
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
// Container(height: 1.h, color: const Color(0xFF021732),),
|
||||
// Container(
|
||||
// // height: h(52),
|
||||
// padding: EdgeInsets.only(top: 15.h, bottom: 15, left:15.w, right: 15.w),
|
||||
// child: Row(
|
||||
// children: [
|
||||
// Image.asset('images/main/icon_addUserAddressShowTime.png', width: 30.w, height: 30.w),
|
||||
// SizedBox(width: 10.w,),
|
||||
// Expanded(
|
||||
// child: Text(DateTool().getNowDateYMDHM(), style: const TextStyle(color: Colors.white, fontSize: 16, fontWeight: FontWeight.w500),)
|
||||
// ),
|
||||
// ],
|
||||
// ),
|
||||
// ),
|
||||
],
|
||||
)
|
||||
),),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
super.dispose();
|
||||
|
||||
location?.destroy();
|
||||
print("地图界面销毁了");
|
||||
}
|
||||
}
|
||||
@ -51,8 +51,8 @@ class NearbyLockLogic extends BaseGetXController{
|
||||
//成功
|
||||
print("获取公钥成功");
|
||||
// 储存公钥
|
||||
var tokenData = reply.data.sublist(3);
|
||||
var saveStrList = changeIntListToStringList(tokenData);
|
||||
var publicKey = reply.data.sublist(3);
|
||||
var saveStrList = changeIntListToStringList(publicKey);
|
||||
Storage.setStringList(saveBluePublicKey, saveStrList);
|
||||
|
||||
IoSenderManage.getPrivateKey(
|
||||
@ -60,7 +60,7 @@ class NearbyLockLogic extends BaseGetXController{
|
||||
keyID:"1",
|
||||
authUserID:"1",
|
||||
nowTime:1,
|
||||
publicKeyData:tokenData,
|
||||
publicKeyData:publicKey,
|
||||
needAuthor:1);
|
||||
break;
|
||||
case 0x07:
|
||||
@ -95,7 +95,7 @@ class NearbyLockLogic extends BaseGetXController{
|
||||
var saveSignKeyList = changeIntListToStringList(signKey);
|
||||
Storage.setStringList(saveBlueSignKey, saveSignKeyList);
|
||||
|
||||
Get.toNamed(Routers.lockAddressPage);
|
||||
Get.toNamed(Routers.lockAddressGaoDePage);
|
||||
break;
|
||||
case 0x07:
|
||||
//无权限
|
||||
@ -117,7 +117,7 @@ class NearbyLockLogic extends BaseGetXController{
|
||||
void onReady() {
|
||||
// TODO: implement onReady
|
||||
super.onReady();
|
||||
print("onReady()");
|
||||
print("NearbyLockLogic onReady()");
|
||||
|
||||
_initReplySubscription();
|
||||
}
|
||||
@ -126,7 +126,7 @@ class NearbyLockLogic extends BaseGetXController{
|
||||
void onInit() {
|
||||
// TODO: implement onInit
|
||||
super.onInit();
|
||||
print("onInit()");
|
||||
print("NearbyLockLogic onInit()");
|
||||
|
||||
// 进来第一步开始扫描
|
||||
BlueManage().startScan((v){
|
||||
|
||||
@ -24,8 +24,17 @@ class _NearbyLockPageState extends State<NearbyLockPage> {
|
||||
final logic = Get.put(NearbyLockLogic());
|
||||
final state = Get.find<NearbyLockLogic>().state;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
// TODO: implement initState
|
||||
super.initState();
|
||||
|
||||
print("NearbyLockLogic initState()");
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
print("NearbyLockLogic build()");
|
||||
return Scaffold(
|
||||
backgroundColor: AppColors.mainBackgroundColor,
|
||||
appBar: TitleAppBar(
|
||||
@ -47,6 +56,7 @@ class _NearbyLockPageState extends State<NearbyLockPage> {
|
||||
state.seletLockName.value = state.devices[index].name;
|
||||
// print("connect-lockId:${state.devices[index].id} deviceName:${state.devices[index].name}");
|
||||
logic.connect(state.devices[index].id, state.devices[index].name);
|
||||
// Get.toNamed(Routers.lockAddressGaoDePage);
|
||||
});
|
||||
},
|
||||
separatorBuilder: (BuildContext context, int index) {
|
||||
@ -70,6 +80,7 @@ class _NearbyLockPageState extends State<NearbyLockPage> {
|
||||
children: [
|
||||
Container(
|
||||
height: 89.h,
|
||||
width: 1.sw,
|
||||
color: Colors.white,
|
||||
child: Row(
|
||||
children: [
|
||||
|
||||
@ -275,6 +275,7 @@ class SaveLockLogic extends BaseGetXController {
|
||||
|
||||
// 获取锁状态
|
||||
Future<void> _getLockStatus() async {
|
||||
print("connectDeviceMacAddress:${BlueManage().connectDeviceMacAddress} connectDeviceName:${BlueManage().connectDeviceName}");
|
||||
// 进来之后首先连接
|
||||
BlueManage().judgeReconnect(BlueManage().connectDeviceMacAddress, BlueManage().connectDeviceName, (DeviceConnectionState state) async {
|
||||
if (state == DeviceConnectionState.connected) {
|
||||
|
||||
@ -16,10 +16,13 @@ abstract class Api {
|
||||
final String electronicKeyListURL = '/key/listUser'; //电子钥匙列表
|
||||
final String sendElectronicKeyURL = '/key/send'; //发送电子钥匙
|
||||
final String resetElectronicKeyURL = '/key/reset'; //重置电子钥匙
|
||||
final String keyOperationRecordURL = '/lockRecords/list'; //电子钥匙操作记录
|
||||
final String keyOperationRecordURL = '/lockRecords/list'; //操作记录
|
||||
final String uploadElectricQuantityURL =
|
||||
'/room/uploadElectricQuantity'; //锁电量更新
|
||||
|
||||
final String lockRecordUploadURL = '/lockRecords/fromLock'; //操作上传
|
||||
final String getLockRecordLastUploadDataTimeURL = '/lockRecords/getLastRecordTime'; //查询锁记录最后时间
|
||||
|
||||
final String bindingBlueAdminURL = '/lock/bindAdmin'; //绑定蓝牙管理员
|
||||
final String modifyKeyNameURL = '/key/modifyKeyName'; //修改锁名称
|
||||
final String modifyKeyNameForAdminURL =
|
||||
|
||||
@ -254,6 +254,26 @@ class ApiProvider extends BaseProvider {
|
||||
'fingerprintId': fingerprintId
|
||||
}));
|
||||
|
||||
// 锁记录上传
|
||||
Future<Response> lockRecordUploadData(
|
||||
String lockId,
|
||||
List records) =>
|
||||
post(
|
||||
lockRecordUploadURL.toUrl,
|
||||
jsonEncode({
|
||||
'lockId': lockId,
|
||||
'records': records,
|
||||
}));
|
||||
|
||||
// 查询锁记录最后时间
|
||||
Future<Response> getLockRecordLastUploadDataTime(
|
||||
String lockId) =>
|
||||
post(
|
||||
getLockRecordLastUploadDataTimeURL.toUrl,
|
||||
jsonEncode({
|
||||
'lockId': lockId,
|
||||
}));
|
||||
|
||||
// 绑定蓝牙管理员
|
||||
Future<Response> bindingBlueAdmin(
|
||||
String bindingDate,
|
||||
|
||||
@ -29,6 +29,7 @@ import '../main/lockDetail/lcokSet/configuringWifi/configuringWifiEntity.dart';
|
||||
import '../main/lockDetail/lcokSet/lockSet/CheckingInInfoDataEntity.dart';
|
||||
import '../main/lockDetail/lcokSet/lockTime/GetServerDatetimeEntity.dart';
|
||||
import '../main/lockDetail/lcokSet/normallyOpenMode/GetPassageModeConfigEntity.dart';
|
||||
import '../main/lockDetail/lockOperatingRecord/lockOperatingRecordGetLastRecordTime_entity.dart';
|
||||
import '../main/lockDetail/otherTypeKey/addFingerprint/addFingerprint/addFingerprint_entity.dart';
|
||||
import '../main/lockDetail/otherTypeKey/addICCard/addICCard_entity.dart';
|
||||
import '../main/lockDetail/otherTypeKey/otherTypeKeyList/fingerprintListData_entity.dart';
|
||||
@ -208,6 +209,28 @@ class ApiRepository {
|
||||
return KeyOperationRecordEntity.fromJson(res.body);
|
||||
}
|
||||
|
||||
//操作记录上传
|
||||
Future<KeyOperationRecordEntity> lockRecordUploadData(
|
||||
{
|
||||
required String lockId,
|
||||
required List records
|
||||
}) async {
|
||||
final res = await apiProvider.lockRecordUploadData(
|
||||
lockId,
|
||||
records);
|
||||
return KeyOperationRecordEntity.fromJson(res.body);
|
||||
}
|
||||
|
||||
// 查询锁记录最后时间
|
||||
Future<LockOperatingRecordGetLastRecordTimeEntity> getLockRecordLastUploadDataTime(
|
||||
{
|
||||
required String lockId
|
||||
}) async {
|
||||
final res = await apiProvider.getLockRecordLastUploadDataTime(
|
||||
lockId);
|
||||
return LockOperatingRecordGetLastRecordTimeEntity.fromJson(res.body);
|
||||
}
|
||||
|
||||
// 绑定蓝牙管理员
|
||||
Future<SaveLockEntity> bindingBlueAdmin(
|
||||
{required String bindingDate,
|
||||
|
||||
@ -84,6 +84,28 @@ class BaseGetXController extends GetxController{
|
||||
}
|
||||
|
||||
// Future loginSuccess({LoginEntity? loginEntity, bool byToken = false}) async => ClientManager().loginSuccess(loginEntity: loginEntity,byToken: byToken);
|
||||
|
||||
|
||||
static List splitList(List list, int len) {
|
||||
if (len <= 1) {
|
||||
return [list];
|
||||
}
|
||||
List result = [];
|
||||
int index = 1;
|
||||
while (true) {
|
||||
if (index * len < list.length) {
|
||||
List temp = list.skip((index - 1) * len).take(len).toList();
|
||||
result.add(temp);
|
||||
index++;
|
||||
continue;
|
||||
}
|
||||
List temp = list.skip((index - 1) * len).toList();
|
||||
result.add(temp);
|
||||
break;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user