完善添加锁流程,调试锁信息列表

This commit is contained in:
魏少阳 2023-08-29 11:02:52 +08:00
parent 239ea064f6
commit 2ec3ac16c7
32 changed files with 609 additions and 559 deletions

View File

@ -2,6 +2,7 @@ import 'package:get/get.dart';
import 'package:star_lock/common/safetyVerification/safetyVerification_binding.dart'; import 'package:star_lock/common/safetyVerification/safetyVerification_binding.dart';
import 'package:star_lock/login/register/starLock_register_binding.dart'; import 'package:star_lock/login/register/starLock_register_binding.dart';
import 'package:star_lock/main/lockDetail/electronicKey/electronicKeyList/entity/ElectronicKeyListEntity.dart'; import 'package:star_lock/main/lockDetail/electronicKey/electronicKeyList/entity/ElectronicKeyListEntity.dart';
import 'package:star_lock/main/lockDetail/lockDetail/lockDetail_main_page.dart';
import 'package:star_lock/mine/minePersonInfo/minePersonInfoEmail/minePersonInfoEmail_page.dart'; import 'package:star_lock/mine/minePersonInfo/minePersonInfoEmail/minePersonInfoEmail_page.dart';
import 'package:star_lock/mine/mineSet/authorizedAdministrator/addAuthorizedAdministrator_page.dart'; import 'package:star_lock/mine/mineSet/authorizedAdministrator/addAuthorizedAdministrator_page.dart';
import 'package:star_lock/mine/mineSet/lockGroup/lockGroupList_page.dart'; import 'package:star_lock/mine/mineSet/lockGroup/lockGroupList_page.dart';
@ -74,7 +75,7 @@ import 'main/lockDetail/otherTypeKey/otherTypeKeyManage/otherTypeKeyManage_page.
import 'main/lockDetail/passwordKey/passwordKeyDetail/passwordKeyDetail_page.dart'; import 'main/lockDetail/passwordKey/passwordKeyDetail/passwordKeyDetail_page.dart';
import 'main/lockDetail/passwordKey/passwordKeyList/passwordKeyList_page.dart'; import 'main/lockDetail/passwordKey/passwordKeyList/passwordKeyList_page.dart';
import 'main/lockDetail/passwordKey/passwordKeyManage/passwordKeyManage_page.dart'; import 'main/lockDetail/passwordKey/passwordKeyManage/passwordKeyManage_page.dart';
import 'main/lockMian/lockMain_page.dart'; import 'main/lockMian/lockMain/lockMain_page.dart';
import 'mine/addLock/lockAddress/lockAddress_page.dart'; import 'mine/addLock/lockAddress/lockAddress_page.dart';
import 'mine/addLock/nearbyLock/nearbyLock_page.dart'; import 'mine/addLock/nearbyLock/nearbyLock_page.dart';
import 'mine/addLock/saveLock/saveLock_page.dart'; import 'mine/addLock/saveLock/saveLock_page.dart';
@ -127,7 +128,7 @@ abstract class Routers {
static const nearbyLockPage = '/NearbyLockPage'; // static const nearbyLockPage = '/NearbyLockPage'; //
static const lockAddressPage = '/LockAddressPage'; // static const lockAddressPage = '/LockAddressPage'; //
static const saveLockPage = '/SaveLockPage'; // static const saveLockPage = '/SaveLockPage'; //
static const lockDetailPage = '/LockDetailPage'; // static const lockDetailMainPage = '/LockDetailMainPage'; //
static const electronicKeyListPage = '/ElectronicKeyListPage'; // static const electronicKeyListPage = '/ElectronicKeyListPage'; //
static const electronicKeyDetailPage = '/ElectronicKeyDetailPage'; // static const electronicKeyDetailPage = '/ElectronicKeyDetailPage'; //
static const electronicKeyDetailChangeDate = static const electronicKeyDetailChangeDate =
@ -314,8 +315,8 @@ abstract class AppRouters {
page: () => const SaveLockPage(), page: () => const SaveLockPage(),
), ),
GetPage( GetPage(
name: Routers.lockDetailPage, name: Routers.lockDetailMainPage,
page: () => const LockDetailPage(), page: () => const LockDetailMainPage(),
), ),
GetPage( GetPage(
name: Routers.electronicKeyListPage, name: Routers.electronicKeyListPage,

View File

@ -25,7 +25,7 @@ class BlueManage{
Uuid serviceId = Uuid.parse('0000FFF0-0000-1000-8000-00805F9B34FB'); Uuid serviceId = Uuid.parse('0000FFF0-0000-1000-8000-00805F9B34FB');
Uuid characteristicIdSubscription = Uuid.parse("fff1");//id Uuid characteristicIdSubscription = Uuid.parse("fff1");//id
Uuid characteristicIdWrite = Uuid.parse("fff2");// id Uuid characteristicIdWrite = Uuid.parse("fff2");// id
String connectDeviceId = ""; String connectDeviceMacAddress = "";
String connectDeviceName = ""; String connectDeviceName = "";
final int _limitLen = 20; final int _limitLen = 20;
@ -72,7 +72,7 @@ class BlueManage{
return; return;
} }
// print("startScanDevice:${device}"); // print("startScanDevice:${device}");
if (((device.serviceUuids.isNotEmpty ? device.serviceUuids[0] : "").toString().contains("758824")) && (device.rssi >= -100)) { 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); final knownDeviceIndex = _scanDevices.indexWhere((d) => d.id == device.id);
if (knownDeviceIndex >= 0) { if (knownDeviceIndex >= 0) {
@ -90,16 +90,18 @@ class BlueManage{
/// ///
Future<void> connect(String deviceMAC, String deviceName, {ConnectStateCallBack? connectStateCallBack, bool? isFrist = false}) async { Future<void> connect(String deviceMAC, String deviceName, {ConnectStateCallBack? connectStateCallBack, bool? isFrist = false}) async {
connectDeviceId = deviceMAC; connectDeviceMacAddress = deviceMAC;
connectDeviceName = deviceName; connectDeviceName = deviceName;
print("connectDeviceId:$connectDeviceId connectDeviceName:$connectDeviceName"); print("connectDeviceId:$connectDeviceMacAddress connectDeviceName:$connectDeviceName");
EasyLoading.show(); EasyLoading.show();
Future.delayed(const Duration(seconds: 30), () { //asynchronous delay Future.delayed(const Duration(seconds: 30), () { //asynchronous delay
print("30s之后 菊花没有隐藏的话,强制隐藏菊花"); print("30s之后 菊花没有隐藏的话,强制隐藏菊花");
EasyLoading.dismiss(); if(EasyLoading.isShow){
EasyLoading.dismiss();
}
}); });
_flutterReactiveBle!.connectToDevice(id: connectDeviceId, connectionTimeout: const Duration(seconds: 15)).listen((connectionStateUpdate) async { _flutterReactiveBle!.connectToDevice(id: connectDeviceMacAddress, connectionTimeout: const Duration(seconds: 15)).listen((connectionStateUpdate) async {
// //
deviceConnectionState = connectionStateUpdate.connectionState; deviceConnectionState = connectionStateUpdate.connectionState;
print('ConnectionState for device $deviceMAC : ${connectionStateUpdate.connectionState}'); print('ConnectionState for device $deviceMAC : ${connectionStateUpdate.connectionState}');
@ -180,7 +182,9 @@ class BlueManage{
EasyLoading.show(); EasyLoading.show();
Future.delayed(const Duration(seconds: 30), () { //asynchronous delay Future.delayed(const Duration(seconds: 30), () { //asynchronous delay
print("30s之后 菊花没有隐藏的话,强制隐藏菊花"); print("30s之后 菊花没有隐藏的话,强制隐藏菊花");
EasyLoading.dismiss(); if(EasyLoading.isShow){
EasyLoading.dismiss();
}
}); });
connectStateCallBack!(deviceConnectionState!); connectStateCallBack!(deviceConnectionState!);
}else{ }else{
@ -250,9 +254,10 @@ class BlueManage{
// //
Future<void> writeCharacteristicWithResponse(List<int> value) async { Future<void> writeCharacteristicWithResponse(List<int> value) async {
QualifiedCharacteristic characteristic = QualifiedCharacteristic(characteristicId: characteristicIdWrite, serviceId: serviceId, deviceId: connectDeviceId); 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)}'); 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);
print("mtuLength:$mtuLength");
try { try {
List<int> valueList = value; List<int> valueList = value;
List subData = splitList(valueList, _limitLen); List subData = splitList(valueList, _limitLen);

View File

@ -22,3 +22,9 @@ class EventBusManager {
eventBus?.fire(event); eventBus?.fire(event);
} }
} }
///
class RefreshLockListInfoDataEvent{
RefreshLockListInfoDataEvent();
}

View File

@ -52,7 +52,7 @@ class _SafetyVerificationPageState extends State<SafetyVerificationPage> with Ti
}); });
print("countryCode:${state.getData["countryCode"]} getAccount:${state.getData["getAccount"]}"); print("countryCode:${state.getData["countryCode"]} getAccount:${state.getData["getAccount"]}");
var entity = await ApiRepository.to.getSliderVerifyImg(state.getData["countryCode"], state.getData["account"]); var entity = await ApiRepository.to.getSliderVerifyImg(state.getData["countryCode"].toString(), state.getData["account"].toString());
if(entity.errorCode! == 0){ if(entity.errorCode! == 0){
state.sliderXMoved.value = 0; state.sliderXMoved.value = 0;
sliderStartX = 0; sliderStartX = 0;
@ -81,7 +81,7 @@ class _SafetyVerificationPageState extends State<SafetyVerificationPage> with Ti
sliderMoveFinish = true; sliderMoveFinish = true;
}); });
var entity = await ApiRepository.to.checkSliderVerifyImg(state.getData["countryCode"], state.getData["account"], sliderMovedX.toString()); var entity = await ApiRepository.to.checkSliderVerifyImg(state.getData["countryCode"].toString(), state.getData["account"].toString(), sliderMovedX.toString());
if(entity.errorCode! == 0){ if(entity.errorCode! == 0){
checkSuccess("captchaVerification"); checkSuccess("captchaVerification");
}else{ }else{

View File

@ -74,4 +74,5 @@ class _CheckingInSetWorkTimePageState extends State<CheckingInSetWorkTimePage> {
// print("组合 $year-$month-$day $hour:$minute:$millisecond"); // print("组合 $year-$month-$day $hour:$minute:$millisecond");
return dateSlug; return dateSlug;
} }
} }

View File

@ -412,7 +412,7 @@ class LockDetailLogic extends BaseGetXController{
}); });
} }
// //
Future<void> connectBlue() async { Future<void> connectBlue() async {
// //
BlueManage().connect("AD01447A-30B5-A780-E778-DED3BDCB613E", "TMH_c3570480da8d", connectStateCallBack: (DeviceConnectionState state) async { BlueManage().connect("AD01447A-30B5-A780-E778-DED3BDCB613E", "TMH_c3570480da8d", connectStateCallBack: (DeviceConnectionState state) async {
@ -435,21 +435,21 @@ class LockDetailLogic extends BaseGetXController{
print("onReady()"); print("onReady()");
_initReplySubscription(); _initReplySubscription();
BlueManage().startScan((v){ // BlueManage().startScan((v){
//
}); // });
} }
@override @override
void onInit() { void onInit() {
// TODO: implement onInit // TODO: implement onInit
super.onInit(); super.onInit();
print("onInit()"); print("lockDetail_onInit()");
BlueManage().connectDeviceName = "TMH_c3570480da8d"; BlueManage().connectDeviceName = "TMH_c3570480da8d";
BlueManage().connectDeviceId = "AD01447A-30B5-A780-E778-DED3BDCB613E"; BlueManage().connectDeviceMacAddress = "AD01447A-30B5-A780-E778-DED3BDCB613E";
// //
// connectBlue(); // connectBlue();
} }

View File

@ -0,0 +1,32 @@
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import '../../../app_settings/app_colors.dart';
import '../../../tools/titleAppBar.dart';
import '../../../translations/trans_lib.dart';
import '../../lockMian/entity/lockInfoEntity.dart';
import 'lockDetail_page.dart';
class LockDetailMainPage extends StatefulWidget {
const LockDetailMainPage({Key? key}) : super(key: key);
@override
State<LockDetailMainPage> createState() => _LockDetailMainPageState();
}
class _LockDetailMainPageState extends State<LockDetailMainPage> {
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: Colors.white,
appBar: TitleAppBar(
barTitle: TranslationLoader.lanKeys!.starLock!.tr,
haveBack: true,
backgroundColor: AppColors.mainColor),
// body: LockDetailPage(lockMainEntity: widget.lockMainEntity),
body: Container(),
);
}
}

View File

@ -4,14 +4,14 @@ import 'package:get/get.dart';
import '../../../appRouters.dart'; import '../../../appRouters.dart';
import '../../../app_settings/app_colors.dart'; import '../../../app_settings/app_colors.dart';
import '../../../blue/io_tool/io_manager.dart';
import '../../../tools/storage.dart';
import '../../../tools/titleAppBar.dart';
import '../../../translations/trans_lib.dart'; import '../../../translations/trans_lib.dart';
import '../../lockMian/entity/lockInfoEntity.dart';
import 'lockDetail_logic.dart'; import 'lockDetail_logic.dart';
class LockDetailPage extends StatefulWidget { class LockDetailPage extends StatefulWidget {
const LockDetailPage({Key? key}) : super(key: key); final LockMainEntity lockMainEntity;
const LockDetailPage({Key? key, required this.lockMainEntity}) : super(key: key);
@override @override
State<LockDetailPage> createState() => _LockDetailPageState(); State<LockDetailPage> createState() => _LockDetailPageState();
@ -23,20 +23,21 @@ class _LockDetailPageState extends State<LockDetailPage> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Container(
return Scaffold( width: 1.sw,
backgroundColor: Colors.white, height: 1.sh,
appBar: TitleAppBar( color: Colors.white,
barTitle: TranslationLoader.lanKeys!.starLock!.tr, child: Column(
haveBack: true, children: [
backgroundColor: AppColors.mainColor), topWidget(),
body: Column( Expanded(child: bottomWidget())
children: [topWidget(), Expanded(child: bottomWidget())], ],
), ),
); );
} }
Widget topWidget() { Widget topWidget() {
KeyInfos keyInfo = widget.lockMainEntity.data!.keyInfos![0];
return Column( return Column(
children: [ children: [
SizedBox(height: 30.h), SizedBox(height: 30.h),
@ -46,7 +47,7 @@ class _LockDetailPageState extends State<LockDetailPage> {
Align( Align(
alignment: Alignment.center, alignment: Alignment.center,
child: Text( child: Text(
"MCBN01-ea9240", keyInfo.lockAlias!,
style: style:
TextStyle(fontSize: 22.sp, fontWeight: FontWeight.w400), TextStyle(fontSize: 22.sp, fontWeight: FontWeight.w400),
)), )),
@ -80,9 +81,9 @@ class _LockDetailPageState extends State<LockDetailPage> {
child: GestureDetector( child: GestureDetector(
onTap: (){ onTap: (){
// logic.transferPermissionsAction(); // logic.transferPermissionsAction();
// logic.openDoorAction(); logic.openDoorAction();
// logic.editLockUserAction(); // logic.editLockUserAction();
logic.factoryDataResetAction(); // logic.factoryDataResetAction();
}, },
child: Image.asset('images/main/icon_main_openLockBtn.png', child: Image.asset('images/main/icon_main_openLockBtn.png',
width: 268.w, height: 268.w), width: 268.w, height: 268.w),

View File

@ -215,7 +215,7 @@ class KeyInfos {
int? autoUnlock; int? autoUnlock;
String? noKeyPwd; String? noKeyPwd;
int? isAttendance; int? isAttendance;
String? keyStatus; int? keyStatus;
int? faceAuthentication; int? faceAuthentication;
int? sensitivity; int? sensitivity;
int? date; int? date;
@ -253,7 +253,7 @@ class KeyInfos {
String? adminPwd; String? adminPwd;
String? deletePwd; String? deletePwd;
int? timezoneRawOffSet; int? timezoneRawOffSet;
String? userType; int? userType;
int? validPwdNum; int? validPwdNum;
String? featureValue; String? featureValue;
int? adminUid; int? adminUid;

View File

@ -0,0 +1,5 @@
import 'package:star_lock/tools/baseGetXController.dart';
class LockListLogic extends BaseGetXController{
}

View File

@ -0,0 +1,105 @@
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:star_lock/mine/mine/starLockMine_page.dart';
import '../../../appRouters.dart';
import '../../../app_settings/app_colors.dart';
import '../entity/lockInfoEntity.dart';
class LockListPage extends StatefulWidget {
final LockMainEntity lockMainEntity;
const LockListPage({Key? key, required this.lockMainEntity}) : super(key: key);
@override
State<LockListPage> createState() => _LockListPageState();
}
class _LockListPageState extends State<LockListPage> {
var dataList = <KeyInfos>[];
@override
Widget build(BuildContext context) {
if(widget.lockMainEntity.data!.pageNo == 1){
dataList = <KeyInfos>[];
}
dataList.addAll(widget.lockMainEntity.data!.keyInfos as Iterable<KeyInfos>);
return ListView.builder(
itemCount: dataList.length,
itemBuilder: (c, index) {
KeyInfos keyInfo = dataList[index];
return lockInfoListItem('images/icon_lock.png', keyInfo.lockAlias, () {
Navigator.pushNamed(context, Routers.lockDetailMainPage);
});
});
}
Widget lockInfoListItem(
String lockTypeIcon, String? lockTypeTitle, Function() action) {
return GestureDetector(
onTap: action,
child: Container(
height: 122.h,
margin: EdgeInsets.only(left: 20.w, right: 20.w, top: 20.w),
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(20.w),
),
child: Column(
// mainAxisAlignment: MainAxisAlignment.center,
children: [
SizedBox(
height: 20.h,
),
Row(
children: [
SizedBox(width: 30.w),
Expanded(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
lockTypeTitle!,
style: TextStyle(
fontSize: 24.sp, fontWeight: FontWeight.w500),
),
],
),
),
SizedBox(width: 20.w),
Text(
"100%",
style: TextStyle(
fontSize: 18.sp, color: AppColors.darkGrayTextColor),
),
SizedBox(width: 2.w),
Image.asset(
'images/main/icon_main_cell.png',
width: 30.w,
height: 24.w,
),
SizedBox(width: 30.w),
],
),
SizedBox(
height: 20.h,
),
Row(
children: [
SizedBox(width: 30.w),
Text(
"永久/管理员",
style: TextStyle(
fontSize: 18.sp, color: AppColors.darkGrayTextColor),
),
],
),
],
),
),
);
}
}

View File

@ -0,0 +1,5 @@
class LockListState{
}

View File

@ -0,0 +1,62 @@
import 'dart:async';
import '../../../blue/io_tool/manager_event_bus.dart';
import '../../../network/api_repository.dart';
import '../../../tools/baseGetXController.dart';
import 'lockMain_state.dart';
class LockMainLogic extends BaseGetXController {
final LockMainState state = LockMainState();
void getLockInfo() async{
var entity = await ApiRepository.to.getLockInfo(
lastUpdateDate:DateTime.now().millisecondsSinceEpoch.toString(),
pageNo:"1",
);
if(entity.errorCode!.codeIsSuccessful){
if(entity.data!.keyInfos!.isEmpty){
state.dataLength.value = 0;
}else if(entity.data!.keyInfos!.length == 1){
state.dataLength.value = 1;
}else{
state.dataLength.value = 2;
}
state.lockMainEntity.value = entity;
}
}
//
late StreamSubscription<RefreshLockListInfoDataEvent> _addLockSubscription;
void _initAddLockSubscription() {
_addLockSubscription = EventBusManager().eventBus!.on<RefreshLockListInfoDataEvent>().listen((event) async {
getLockInfo();
});
}
@override
void onReady() {
// TODO: implement onReady
super.onReady();
print("onReady()");
_initAddLockSubscription();
}
@override
void onInit() {
// TODO: implement onInit
super.onInit();
print("onInit()");
getLockInfo();
}
@override
void onClose() {
// TODO: implement onClose
super.onClose();
_addLockSubscription.cancel();
}
}

View File

@ -0,0 +1,146 @@
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';
import 'package:star_lock/app_settings/app_colors.dart';
import '../../../appRouters.dart';
import '../../../baseWidget.dart';
import '../../../mine/mine/starLockMine_page.dart';
import '../../../tools/titleAppBar.dart';
import '../../../translations/trans_lib.dart';
import '../../lockDetail/lockDetail/lockDetail_page.dart';
import '../lockList/lockList_page.dart';
import 'lockMain_logic.dart';
class StarLockMainPage extends StatefulWidget {
const StarLockMainPage({Key? key}) : super(key: key);
@override
State<StarLockMainPage> createState() => _StarLockMainPageState();
}
// GlobalKey<_StarLockMainPageState> starLockMainKey = GlobalKey();
class _StarLockMainPageState extends State<StarLockMainPage> with BaseWidget {
final logic = Get.put(LockMainLogic());
final state = Get.find<LockMainLogic>().state;
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: const Color(0xFFF5F5F5),
appBar: TitleAppBar(
barTitle: TranslationLoader.lanKeys!.starLock!.tr,
haveBack: false,
haveOtherLeftWidget: true,
leftWidget: Builder(
builder: (context) => IconButton(
icon: Image.asset(
"images/main/mainLeft_menu_icon.png",
color: Colors.white,
width: 44.w,
height: 44.w,
),
onPressed: () {
// _globalKey.currentState!.openDrawer();
Scaffold.of(context).openDrawer();
},
)),
backgroundColor: AppColors.mainColor,
// actionsList: [
// TextButton(
// child: const Text("", style: TextStyle(color: Colors.white)),
// onPressed: () {
// Navigator.pushNamed(context, Routers.starLockLoginPage);
// },
// ),
// ],
),
drawer: Drawer(
width: 1.sw / 3 * 2,
child: const StarLockMinePage(),
),
body: Obx(() => getDataReturnUI(state.dataLength.value, )),
// body: getLockList(),
// body: unHaveData(),
);
}
Widget getDataReturnUI(int type){
Widget returnWidget;
switch(type){
case 0:
returnWidget = unHaveData();
break;
case 1:
returnWidget = LockDetailPage(lockMainEntity: logic.state.lockMainEntity.value);
break;
case 2:
returnWidget = LockListPage(lockMainEntity:logic.state.lockMainEntity.value);
break;
default:
returnWidget = unHaveData();
break;
}
return returnWidget;
}
Widget unHaveData() {
return Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Container(
width: 220.w,
height: 220.w,
decoration: BoxDecoration(
border: Border.all(width: 4.w, color: AppColors.mainColor),
borderRadius: BorderRadius.circular(110.w),
),
child: InkWell(
child: Padding(
padding: const EdgeInsets.all(30.0),
child: Image.asset(
'images/main/icon_main_addLock.png',
width: 150.w,
height: 150.w,
),
),
onTap: () {
//
Navigator.pushNamed(
context, Routers.seletLockTypePage,
// arguments: {
// "url": ConstConfig.privacAgreementUrl,
// "title": '隐私政策'
// }
);
},
)),
],
),
SizedBox(
height: h(50.h),
),
Container(
padding: EdgeInsets.all(30.w),
child: Text(
TranslationLoader
.lanKeys!.whenAddingLockThePhoneMustBeNextToTheLock!.tr,
style: TextStyle(
fontSize: 26.sp,
fontWeight: FontWeight.w800,
color: AppColors.mainColor),
))
],
);
}
void onShow() {}
void onHide() {}
}

View File

@ -0,0 +1,11 @@
import 'package:get/get.dart';
import '../entity/lockInfoEntity.dart';
class LockMainState {
// 0 1 2
var dataLength = 0.obs;
Rx<LockMainEntity> lockMainEntity = LockMainEntity().obs;
}

View File

@ -1,41 +0,0 @@
import '../../network/api_repository.dart';
import '../../tools/baseGetXController.dart';
import 'lockMain_state.dart';
class LockMainLogic extends BaseGetXController {
final LockMainState state = LockMainState();
void getLockInfo() async{
var entity = await ApiRepository.to.getLockInfo(
lastUpdateDate:DateTime.now().millisecondsSinceEpoch.toString(),
pageNo:"1",
);
if(entity.errorCode!.codeIsSuccessful){
}
}
@override
void onReady() {
// TODO: implement onReady
super.onReady();
print("onReady()");
}
@override
void onInit() {
// TODO: implement onInit
super.onInit();
print("onInit()");
getLockInfo();
}
@override
void onClose() {
// TODO: implement onClose
super.onClose();
}
}

View File

@ -1,199 +0,0 @@
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';
import 'package:star_lock/app_settings/app_colors.dart';
import '../../appRouters.dart';
import '../../baseWidget.dart';
import '../../mine/mine/starLockMine_page.dart';
import '../../tools/titleAppBar.dart';
import '../../translations/trans_lib.dart';
import 'lockMain_logic.dart';
class StarLockMainPage extends StatefulWidget {
const StarLockMainPage({Key? key}) : super(key: key);
@override
State<StarLockMainPage> createState() => _StarLockMainPageState();
}
// GlobalKey<_StarLockMainPageState> starLockMainKey = GlobalKey();
class _StarLockMainPageState extends State<StarLockMainPage> with BaseWidget {
@override
Widget build(BuildContext context) {
final logic = Get.put(LockMainLogic());
// final state = Get.find<LockMainLogic>().state;
return Scaffold(
backgroundColor: const Color(0xFFF5F5F5),
appBar: TitleAppBar(
barTitle: TranslationLoader.lanKeys!.starLock!.tr,
haveBack: false,
haveOtherLeftWidget: true,
leftWidget: Builder(
builder: (context) => IconButton(
icon: Image.asset(
"images/main/mainLeft_menu_icon.png",
color: Colors.white,
width: 44.w,
height: 44.w,
),
onPressed: () {
// _globalKey.currentState!.openDrawer();
Scaffold.of(context).openDrawer();
},
)),
backgroundColor: AppColors.mainColor,
actionsList: [
TextButton(
child: const Text("", style: TextStyle(color: Colors.white)),
onPressed: () {
Navigator.pushNamed(context, Routers.starLockLoginPage);
},
),
],
),
drawer: Drawer(
width: 1.sw / 3 * 2,
child: const StarLockMinePage(),
),
body: getLockList(),
// body: unHaveData(),
);
}
Widget getLockList() {
return ListView.builder(
itemCount: 5,
itemBuilder: (c, index) {
return nearbyLockItem('images/icon_lock.png', "MCBN01-ea9240", () {
Navigator.pushNamed(context, Routers.lockDetailPage);
});
});
}
Widget nearbyLockItem(
String lockTypeIcon, String lockTypeTitle, Function() action) {
return GestureDetector(
onTap: action,
child: Container(
height: 122.h,
margin: EdgeInsets.only(left: 20.w, right: 20.w, top: 20.w),
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(20.w),
),
child: Column(
// mainAxisAlignment: MainAxisAlignment.center,
children: [
SizedBox(
height: 20.h,
),
Row(
children: [
SizedBox(width: 30.w),
Expanded(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
lockTypeTitle,
style: TextStyle(
fontSize: 24.sp, fontWeight: FontWeight.w500),
),
],
),
),
SizedBox(width: 20.w),
Text(
"100%",
style: TextStyle(
fontSize: 18.sp, color: AppColors.darkGrayTextColor),
),
SizedBox(width: 2.w),
Image.asset(
'images/main/icon_main_cell.png',
width: 30.w,
height: 24.w,
),
SizedBox(width: 30.w),
],
),
SizedBox(
height: 20.h,
),
Row(
children: [
SizedBox(width: 30.w),
Text(
"永久/管理员",
style: TextStyle(
fontSize: 18.sp, color: AppColors.darkGrayTextColor),
),
],
),
],
),
),
);
}
Widget unHaveData() {
return Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Container(
decoration: BoxDecoration(
border: Border.all(width: 4, color: AppColors.mainColor),
borderRadius: BorderRadius.circular(75),
),
child: InkWell(
child: Padding(
padding: const EdgeInsets.all(30.0),
child: Image.asset(
'images/main/icon_main_addLock.png',
width: 150.w,
height: 150.w,
),
),
onTap: () {
//
Navigator.pushNamed(
context, Routers.seletLockTypePage,
// arguments: {
// "url": ConstConfig.privacAgreementUrl,
// "title": '隐私政策'
// }
);
},
)),
],
),
SizedBox(
height: h(50.h),
),
Container(
padding: EdgeInsets.all(30.w),
child: Text(
TranslationLoader
.lanKeys!.whenAddingLockThePhoneMustBeNextToTheLock!.tr,
style: TextStyle(
fontSize: 30.sp,
fontWeight: FontWeight.w800,
color: AppColors.mainColor),
))
],
);
}
void onShow() {}
void onHide() {}
}

View File

@ -1,4 +0,0 @@
class LockMainState {
}

View File

@ -1,20 +1,23 @@
import 'dart:async'; import 'dart:async';
import 'dart:io';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:amap_flutter_location/amap_flutter_location.dart'; import 'package:amap_flutter_location/amap_flutter_location.dart';
import 'package:amap_flutter_location/amap_location_option.dart'; import 'package:amap_flutter_location/amap_location_option.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:permission_handler/permission_handler.dart'; import 'package:permission_handler/permission_handler.dart';
import 'package:amap_flutter_map/amap_flutter_map.dart'; import 'package:amap_flutter_map/amap_flutter_map.dart';
import 'package:amap_flutter_base/amap_flutter_base.dart'; import 'package:amap_flutter_base/amap_flutter_base.dart';
import '../../../app_settings/app_colors.dart'; import '../../../app_settings/app_colors.dart';
import '../../../main.dart';
typedef BlockAddressMapCallback = void Function(dynamic addressMap);
class LockAddressGaoDePage extends StatefulWidget { class LockAddressGaoDePage extends StatefulWidget {
const LockAddressGaoDePage({Key? key}) : super(key: key); BlockAddressMapCallback callback;
LockAddressGaoDePage({Key? key, required this.callback}) : super(key: key);
@override @override
State<LockAddressGaoDePage> createState() => _LockAddressGaoDePageState(); State<LockAddressGaoDePage> createState() => _LockAddressGaoDePageState();
@ -22,95 +25,109 @@ class LockAddressGaoDePage extends StatefulWidget {
class _LockAddressGaoDePageState extends State<LockAddressGaoDePage>{ class _LockAddressGaoDePageState extends State<LockAddressGaoDePage>{
// //
Map<String, Object>? _locationResult; static const AMapApiKey amapApiKeys = AMapApiKey(iosKey: '883a3355d2d77c2fdc2667030dc97ffe', androidKey: '11d49b3f4fc09c04a02bbb7500925ba2');
StreamSubscription<Map<String, Object>>? _locationListener;
final AMapFlutterLocation _locationPlugin = AMapFlutterLocation();
late AMapController _mapController;
static const CameraPosition _kInitialPosition = CameraPosition( AMapController? mapController;
target: LatLng(113.919112, 22.653728), AMapFlutterLocation? location;
zoom: 10.0,
);
List<Widget> get _approvalNumberWidget => <Widget>[]; PermissionStatus? permissionStatus;
Map<String, Object>? addressInfo;
@override @override
void initState() { void initState() {
super.initState(); super.initState();
/// SDK将不会工作 AMapFlutterLocation.setApiKey("11d49b3f4fc09c04a02bbb7500925ba2", "883a3355d2d77c2fdc2667030dc97ffe");
/// AMapFlutterLocation.updatePrivacyAgree(true);
/// SDK合规使用方案请参考官网地址https://lbs.amap.com/news/sdkhgsy
/// <b> App时弹出</b>
///
/// SDK合规使用方案请参考官网地址https://lbs.amap.com/news/sdkhgsy
///
/// [hasContains]
///
/// [hasShow]
AMapFlutterLocation.updatePrivacyShow(true, true); AMapFlutterLocation.updatePrivacyShow(true, true);
/// SDK将不会工作
///
/// SDK合规使用方案请参考官网地址https://lbs.amap.com/news/sdkhgsy
///
/// <b>, App时弹出</b>
///
/// [hasAgree]
AMapFlutterLocation.updatePrivacyAgree(true);
///
requestPermission(); requestPermission();
}
///Android和iOS的apiKey<br> Future<void> requestPermission() async {
///key的申请请参考高德开放平台官网说明<br> final status = await Permission.location.request();
///Android: https://lbs.amap.com/api/android-location-sdk/guide/create-project/get-key permissionStatus = status;
///iOS: https://lbs.amap.com/api/ios-location-sdk/guide/create-project/get-key switch (status) {
AMapFlutterLocation.setApiKey("1dbf56e2e8a4d0e4cdc2df9efd36bc71", "dfb64c0463cb53927914364b5c09aba0"); case PermissionStatus.denied:
print("拒绝");
///iOS native精度类型 break;
if (Platform.isIOS) { case PermissionStatus.granted:
requestAccuracyAuthorization(); requestLocation();
break;
case PermissionStatus.limited:
print("限制");
break;
default:
print("其他状态");
requestLocation();
break;
} }
}
/// void requestLocation() {
_locationListener = _locationPlugin.onLocationChanged().listen((Map<String, Object> result) { location = AMapFlutterLocation()
setState(() { ..setLocationOption(AMapLocationOption())
_locationResult = result; ..onLocationChanged().listen((event) {
if (_locationResult != null) { print("listenLocationChanged$event");
_locationResult?.forEach((key, value) { double? latitude = double.parse(event['latitude'] as String);
print("key:$key value:$value"); 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();
_startLocation();
} }
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
///使 if (addressInfo?['latitude'] == null ||
final AMapWidget map = AMapWidget( addressInfo?['longitude'] == null ||
apiKey: const AMapApiKey(androidKey: '900f72eeee0f21e435cebb0ef155582a', iosKey: '4dfdec97b7bf0b8c13e94777103015a9'), addressInfo?['errorCode'] == 0) {
onMapCreated: onMapCreated, return const Text('Sorry');
// initialCameraPosition: _kInitialPosition }
);
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( return Stack(
children: [ children: [
Container( Container(
height: MediaQuery.of(context).size.height, height: MediaQuery.of(context).size.height,
width: MediaQuery.of(context).size.width, width: MediaQuery.of(context).size.width,
child: map, child: (addressInfo!["address"].toString().isNotEmpty) ? AMapWidget(
), apiKey: amapApiKeys,
Positioned( //
left: 10.w, bottom: 30.h, initialCameraPosition: (
child: Container( CameraPosition(
alignment: Alignment.centerLeft, target: LatLng(latitude, longitude),
child: Column( zoom: 10.0,
mainAxisAlignment: MainAxisAlignment.start, )
children: _approvalNumberWidget), ),
) //
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( Positioned(
left: 20.w, right: 20.w, bottom: 100.h, left: 20.w, right: 20.w, bottom: 100.h,
@ -130,25 +147,25 @@ class _LockAddressGaoDePageState extends State<LockAddressGaoDePage>{
Image.asset('images/main/icon_addUserShowAddress.png', width: 30.w, height: 30.w), Image.asset('images/main/icon_addUserShowAddress.png', width: 30.w, height: 30.w),
SizedBox(width: 10.w), SizedBox(width: 10.w),
Expanded( Expanded(
child: Text("广东省深圳市宏发科技园", style: const TextStyle(color: Colors.white, fontSize: 16, fontWeight: FontWeight.w500, overflow: TextOverflow.clip)) 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("2023.8.22 15.14", style: const TextStyle(color: Colors.white, fontSize: 16, fontWeight: FontWeight.w500),)
), ),
], ],
), ),
), ),
// 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),)
// ),
// ],
// ),
// ),
], ],
) )
),), ),),
@ -156,164 +173,11 @@ class _LockAddressGaoDePageState extends State<LockAddressGaoDePage>{
); );
} }
void onMapCreated(AMapController controller) {
setState(() {
_mapController = controller;
getApprovalNumber();
});
}
///
void getApprovalNumber() async {
//
String? mapContentApprovalNumber =
await _mapController.getMapContentApprovalNumber();
//
String? satelliteImageApprovalNumber =
await _mapController.getSatelliteImageApprovalNumber();
setState(() {
if (null != mapContentApprovalNumber) {
_approvalNumberWidget.add(Text(mapContentApprovalNumber));
}
if (null != satelliteImageApprovalNumber) {
_approvalNumberWidget.add(Text(satelliteImageApprovalNumber));
}
});
print('地图审图号(普通地图): $mapContentApprovalNumber');
print('地图审图号(卫星地图): $satelliteImageApprovalNumber');
}
///
void _setLocationOption() {
AMapLocationOption locationOption = new AMapLocationOption();
///
locationOption.onceLocation = false;
///
locationOption.needAddress = true;
///
locationOption.geoLanguage = GeoLanguage.DEFAULT;
locationOption.desiredLocationAccuracyAuthorizationMode = AMapLocationAccuracyAuthorizationMode.ReduceAccuracy;
locationOption.fullAccuracyPurposeKey = "AMapLocationScene";
///Android端连续定位的定位间隔
locationOption.locationInterval = 2000;
///Android端的定位模式<br>
///<br>
///<li>[AMapLocationMode.Battery_Saving]</li>
///<li>[AMapLocationMode.Device_Sensors]</li>
///<li>[AMapLocationMode.Hight_Accuracy]</li>
locationOption.locationMode = AMapLocationMode.Hight_Accuracy;
///iOS端的定位最小更新距离<br>
locationOption.distanceFilter = -1;
///iOS端期望的定位精度
/// <br>
/// <li>[DesiredAccuracy.Best] </li>
/// <li>[DesiredAccuracy.BestForNavigation] </li>
/// <li>[DesiredAccuracy.NearestTenMeters] 10 </li>
/// <li>[DesiredAccuracy.Kilometer] 1000</li>
/// <li>[DesiredAccuracy.ThreeKilometers] 3000</li>
locationOption.desiredAccuracy = DesiredAccuracy.Best;
///iOS端是否允许系统暂停定位
locationOption.pausesLocationUpdatesAutomatically = false;
///
_locationPlugin.setLocationOption(locationOption);
}
///
void _startLocation() {
///
_setLocationOption();
_locationPlugin.startLocation();
}
///
void _stopLocation() {
_locationPlugin.stopLocation();
}
///iOS native的accuracyAuthorization类型
void requestAccuracyAuthorization() async {
AMapAccuracyAuthorization currentAccuracyAuthorization = await _locationPlugin.getSystemAccuracyAuthorization();
if (currentAccuracyAuthorization == AMapAccuracyAuthorization.AMapAccuracyAuthorizationFullAccuracy) {
print("精确定位类型");
} else if (currentAccuracyAuthorization == AMapAccuracyAuthorization.AMapAccuracyAuthorizationReducedAccuracy) {
print("模糊定位类型");
} else {
print("未知定位类型");
}
}
///
void requestPermission() async {
//
bool hasLocationPermission = await requestLocationPermission();
if (hasLocationPermission) {
print("定位权限申请通过");
} else {
print("定位权限申请不通过");
}
}
///
/// true false
Future<bool> requestLocationPermission() async {
//
var status = await Permission.location.status;
if (status == PermissionStatus.granted) {
//
return true;
} else {
//
status = await Permission.location.request();
if (status == PermissionStatus.granted) {
return true;
} else {
return false;
}
}
}
// @override
// void dispose() {
// super.dispose();
//
// _stopLocation();
//
// ///
// if (null != _locationListener) {
// _locationListener?.cancel();
// }
//
// ///
// _locationPlugin.destroy();
//
// print("高德地图定位销毁了");
// }
@override @override
void dispose() { void dispose() {
super.dispose(); super.dispose();
_stopLocation(); location?.destroy();
///
if (null != _locationListener) {
_locationListener?.cancel();
}
///
_locationPlugin.destroy();
print("地图界面销毁了"); print("地图界面销毁了");
} }
} }

View File

@ -21,6 +21,7 @@ class LockAddressPage extends StatefulWidget {
} }
class _LockAddressPageState extends State<LockAddressPage> with RouteAware{ class _LockAddressPageState extends State<LockAddressPage> with RouteAware{
Map<String, Object>? addressInfo;
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
@ -37,15 +38,17 @@ class _LockAddressPageState extends State<LockAddressPage> with RouteAware{
style: TextStyle(color: Colors.white, fontSize: 24.sp), style: TextStyle(color: Colors.white, fontSize: 24.sp),
), ),
onPressed: () { onPressed: () {
Get.toNamed(Routers.saveLockPage)!.then((value) { Get.toNamed(Routers.saveLockPage, arguments: addressInfo);
dispose();
});
// Navigator.pushNamed(context, Routers.saveLockPage); // Navigator.pushNamed(context, Routers.saveLockPage);
}, },
), ),
], ],
), ),
body: LockAddressGaoDePage()); body: LockAddressGaoDePage(callback: (addressInfoMap){
addressInfo = addressInfoMap;
},)
// body: Container(),
);
} }
@override @override

View File

@ -25,7 +25,7 @@ class NearbyLockLogic extends BaseGetXController{
final NearbyLockState state = NearbyLockState(); final NearbyLockState state = NearbyLockState();
// //
void connect(String lockId, String deviceName){ void connect(String lockId, String deviceName){
BlueManage().connect(lockId, deviceName, isFrist: true); BlueManage().connect(lockId, deviceName, isFrist: true);
} }
@ -81,7 +81,7 @@ class NearbyLockLogic extends BaseGetXController{
Future<void> _replyGetPrivateKeyKey(Reply reply) async { Future<void> _replyGetPrivateKeyKey(Reply reply) async {
switch(reply.status){ switch(reply.status){
case 0x00: case 0x00:
// //
print('获取私钥成功'); print('获取私钥成功');
reply.data.removeAt(0); reply.data.removeAt(0);
@ -90,6 +90,11 @@ class NearbyLockLogic extends BaseGetXController{
var savePrivateKeyList = changeIntListToStringList(privateKey); var savePrivateKeyList = changeIntListToStringList(privateKey);
Storage.setStringList(saveBluePrivateKey, savePrivateKeyList); Storage.setStringList(saveBluePrivateKey, savePrivateKeyList);
// signKey
List<int> signKey = reply.data.sublist(16, 32);
var saveSignKeyList = changeIntListToStringList(signKey);
Storage.setStringList(saveBlueSignKey, saveSignKeyList);
Get.toNamed(Routers.lockAddressPage); Get.toNamed(Routers.lockAddressPage);
break; break;
case 0x07: case 0x07:

View File

@ -26,22 +26,6 @@ class _NearbyLockPageState extends State<NearbyLockPage> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
// var uint8View1 = Uint8List(300);
// uint8View1[0] = 0xEF;
// uint8View1[1] = 0x01;
// uint8View1[2] = 0xEE;
// uint8View1[3] = 0x02;
// // String bar = utf8.decode(uint8View1);
// print("barrrrr:$uint8View1");
//
// for(int i = 0; i<uint8View1.length; i++){
// String hexString = uint8View1[i].toRadixString(16);
// print("666666666:$hexString");
// }
// String hexString = 4009881090.toRadixString(16);
// print("666666666:$hexString");
return Scaffold( return Scaffold(
backgroundColor: AppColors.mainBackgroundColor, backgroundColor: AppColors.mainBackgroundColor,
appBar: TitleAppBar( appBar: TitleAppBar(
@ -100,7 +84,8 @@ class _NearbyLockPageState extends State<NearbyLockPage> {
mainAxisAlignment: MainAxisAlignment.center, mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: [ children: [
Text(discoveredDevice.name, style: TextStyle(fontSize: 20.sp, color: AppColors.blackColor),), // 333400 01
Text(discoveredDevice.name, style: TextStyle(fontSize: 20.sp, color: ((discoveredDevice.serviceUuids.isNotEmpty ? discoveredDevice.serviceUuids[0] : "").toString()[33] == "1") ? AppColors.blackColor : Colors.grey)),
], ],
), ),
SizedBox( SizedBox(

View File

@ -30,9 +30,9 @@ class SaveLockEntity {
} }
class SaveLockEntityData { class SaveLockEntityData {
String? lockId; int? lockId;
String? nbRegisterSuccess; String? nbRegisterSuccess;
String? keyId; int? keyId;
SaveLockEntityData( SaveLockEntityData(
{ this.lockId, { this.lockId,

View File

@ -6,6 +6,7 @@ import 'dart:convert';
import 'package:flutter_reactive_ble/flutter_reactive_ble.dart'; import 'package:flutter_reactive_ble/flutter_reactive_ble.dart';
import 'package:get/get.dart'; import 'package:get/get.dart';
import '../../../appRouters.dart';
import '../../../blue/blue_manage.dart'; import '../../../blue/blue_manage.dart';
import '../../../blue/io_protocol/io_addUser.dart'; import '../../../blue/io_protocol/io_addUser.dart';
import '../../../blue/io_protocol/io_getLockStatu.dart'; import '../../../blue/io_protocol/io_getLockStatu.dart';
@ -174,14 +175,14 @@ class SaveLockLogic extends BaseGetXController {
} }
// //
_saveLockAction(){ saveLockAction(){
addUserConnectBlue(); addUserConnectBlue();
} }
// //
Future<void> addUserConnectBlue() async { Future<void> addUserConnectBlue() async {
// //
BlueManage().connect("AD01447A-30B5-A780-E778-DED3BDCB613E", "TMH_c3570480da8d", connectStateCallBack: (DeviceConnectionState state) async { BlueManage().judgeReconnect("AD01447A-30B5-A780-E778-DED3BDCB613E", "TMH_c3570480da8d", (DeviceConnectionState state) async {
if (state == DeviceConnectionState.connected){ if (state == DeviceConnectionState.connected){
// //
var privateKey = await Storage.getStringList(saveBluePrivateKey); var privateKey = await Storage.getStringList(saveBluePrivateKey);
@ -197,7 +198,8 @@ class SaveLockLogic extends BaseGetXController {
} }
IoSenderManage.senderAddUser( IoSenderManage.senderAddUser(
lockID:BlueManage().connectDeviceName, // lockID:BlueManage().connectDeviceName,
lockID: "TMH_c3570480da8d",
authUserID:"100001", authUserID:"100001",
keyID:"1", keyID:"1",
userID:"100001", userID:"100001",
@ -218,8 +220,30 @@ class SaveLockLogic extends BaseGetXController {
void bindBlueAdmin() async{ void bindBlueAdmin() async{
var lockDataMap = {}; var lockDataMap = {};
lockDataMap['lockId'] = BlueManage().connectDeviceName; lockDataMap['lockName'] = BlueManage().connectDeviceName;
lockDataMap['lockMac'] = BlueManage().connectDeviceId; lockDataMap['lockMac'] = BlueManage().connectDeviceMacAddress;
var positionMap = {};
positionMap['longitude'] = state.addressMap["longitude"];
positionMap['latitude'] = state.addressMap["latitude"];
positionMap['country'] = state.addressMap["country"];
positionMap['province'] = state.addressMap["province"];
positionMap['city'] = state.addressMap["city"];
positionMap['district'] = state.addressMap["district"];
positionMap['township'] = state.addressMap["street"];
positionMap['address'] = state.addressMap["address"];
var bluetooth = {};
bluetooth['bluetoothDeviceId'] = BlueManage().connectDeviceMacAddress;
bluetooth['bluetoothDeviceName'] = BlueManage().connectDeviceName;
var publicKey = await Storage.getStringList(saveBluePublicKey);
List<int> publicKeyDataList = changeStringListToIntList(publicKey!);
bluetooth['publicKey'] = publicKeyDataList;
var privateKey = await Storage.getStringList(saveBluePrivateKey);
List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
bluetooth['privateKey'] = getPrivateKeyList;
var entity = await ApiRepository.to.bindingBlueAdmin( var entity = await ApiRepository.to.bindingBlueAdmin(
bindingDate:DateTime.now().millisecondsSinceEpoch.toString(), bindingDate:DateTime.now().millisecondsSinceEpoch.toString(),
@ -227,11 +251,13 @@ class SaveLockLogic extends BaseGetXController {
lockAlias:state.aliName.value, lockAlias:state.aliName.value,
lockData:lockDataMap, lockData:lockDataMap,
nbInitSuccess:"0", nbInitSuccess:"0",
position:"113.918912, 22.653670", position:positionMap,
bluetooth:bluetooth,
deviceNo:"123456" deviceNo:"123456"
); );
if(entity.errorCode!.codeIsSuccessful){ if(entity.errorCode!.codeIsSuccessful){
Get.close(3); EventBusManager().eventBusFir(RefreshLockListInfoDataEvent);
Get.toNamed(Routers.starLockMain);
} }
} }

View File

@ -100,7 +100,8 @@ class _SaveLockPageState extends State<SaveLockPage> {
bottom: 25.w bottom: 25.w
), ),
onClick: (){ onClick: (){
Navigator.pop(context); // Navigator.pop(context);
logic.saveLockAction();
} }
), ),
], ],

View File

@ -8,11 +8,13 @@ import '../../../blue/blue_manage.dart';
class SaveLockState { class SaveLockState {
var aliName = ''.obs; var aliName = ''.obs;
var addressMap = {}.obs;
TextEditingController aliNameController = TextEditingController(); TextEditingController aliNameController = TextEditingController();
SaveLockState() { SaveLockState() {
aliName.value = BlueManage().connectDeviceName; aliName.value = BlueManage().connectDeviceName;
aliNameController.text = aliName.value; aliNameController.text = aliName.value;
addressMap.value = Get.arguments as Map;
} }
void onClose() { void onClose() {

View File

@ -4,7 +4,7 @@ import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:star_lock/mine/mine/starLockMine_page.dart'; import 'package:star_lock/mine/mine/starLockMine_page.dart';
import '../app_settings/app_colors.dart'; import '../app_settings/app_colors.dart';
import '../main/lockMian/lockMain_page.dart'; import '../main/lockMian/lockMain/lockMain_page.dart';
class NavPages extends StatefulWidget { class NavPages extends StatefulWidget {
const NavPages({Key? key}) : super(key: key); const NavPages({Key? key}) : super(key: key);

View File

@ -233,7 +233,8 @@ class ApiProvider extends BaseProvider {
String lockAlias, String lockAlias,
Map lockData, Map lockData,
String nbInitSuccess, String nbInitSuccess,
String position, Map position,
Map bluetooth,
String deviceNo) => String deviceNo) =>
post( post(
bindingBlueAdminURL.toUrl, bindingBlueAdminURL.toUrl,
@ -244,6 +245,7 @@ class ApiProvider extends BaseProvider {
'lockData': lockData, 'lockData': lockData,
"nbInitSuccess": nbInitSuccess, "nbInitSuccess": nbInitSuccess,
'position': position, 'position': position,
'bluetooth': bluetooth,
'deviceNo': deviceNo 'deviceNo': deviceNo
})); }));

View File

@ -56,7 +56,7 @@ class BaseProvider extends GetConnect with Api {
statusText: res.statusText, statusText: res.statusText,
); );
} }
print('得到的数据======>bodyString:${res.bodyString} body:${res.body} bodyBytes:${res.bodyBytes} status:${res.status} statusText:${res.statusText} statusCode:${res.statusCode}'); // print('得到的数据======>bodyString:${res.bodyString} body:${res.body} bodyBytes:${res.bodyBytes} status:${res.status} statusText:${res.statusText} statusCode:${res.statusCode}');
getDataResult(res.body); getDataResult(res.body);
return res; return res;
} }

View File

@ -182,7 +182,8 @@ class ApiRepository {
required String lockAlias, required String lockAlias,
required Map lockData, required Map lockData,
required String nbInitSuccess, required String nbInitSuccess,
required String position, required Map position,
required Map bluetooth,
required String deviceNo}) async { required String deviceNo}) async {
final res = await apiProvider.bindingBlueAdmin( final res = await apiProvider.bindingBlueAdmin(
bindingDate, bindingDate,
@ -191,6 +192,7 @@ class ApiRepository {
lockData, lockData,
nbInitSuccess, nbInitSuccess,
position, position,
bluetooth,
deviceNo); deviceNo);
return SaveLockEntity.fromJson(res.body); return SaveLockEntity.fromJson(res.body);
} }

View File

@ -1,7 +1,7 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import '../main/lockMian/lockMain_page.dart'; import '../main/lockMian/lockMain/lockMain_page.dart';
class StarLockApplication extends StatefulWidget { class StarLockApplication extends StatefulWidget {

View File

@ -0,0 +1,24 @@
class DateTool {
String getNowDateYMDHM(){
//
DateTime now = DateTime.now();
//
int year = now.year;
//
int month = now.month;
//
int day = now.day;
//
int hour = now.hour;
//
int minute = now.minute;
//
int millisecond = now.millisecond;
// print("组合 $year-$month-$day $hour:$minute:$millisecond");
return "$year.$month.$day $hour:$minute";
}
}