1、修复密码左右滑动切换添加密码类型不对问题。2、修复添加指纹卡人脸传钥匙号问题。3、取消绑定完锁之后弹框给用户修改管理员密码问题

This commit is contained in:
魏少阳 2024-04-25 16:17:49 +08:00
parent a413d81da8
commit 581311f7d9
11 changed files with 330 additions and 233 deletions

View File

@ -115,7 +115,7 @@ import 'main/lockDetail/lockSet/wirelessKeyboard/selectWirelessKeyboard/selectWi
import 'main/lockDetail/lockSet/wirelessKeyboard/wirelessKeyboardList/wirelessKeyboard_page.dart'; import 'main/lockDetail/lockSet/wirelessKeyboard/wirelessKeyboardList/wirelessKeyboard_page.dart';
import 'main/lockDetail/monitoring/monitoring/lockMonitoring_page.dart'; import 'main/lockDetail/monitoring/monitoring/lockMonitoring_page.dart';
import 'main/lockDetail/monitoring/monitoringRealTimeScreen/monitoringRealTimeScreen_page.dart'; import 'main/lockDetail/monitoring/monitoringRealTimeScreen/monitoringRealTimeScreen_page.dart';
import 'main/lockDetail/passwordKey/passwordKey_perpetual/passwordKeyManage/passwordKeyManage_page.dart'; import 'main/lockDetail/passwordKey/passwordKey_perpetual/passwordKey_perpetual_page.dart';
import 'main/lockDetail/realTimePicture/realTimePicture_page.dart'; import 'main/lockDetail/realTimePicture/realTimePicture_page.dart';
import 'main/lockDetail/remoteControl/addRemoteControl/addRemoteControl_page.dart'; import 'main/lockDetail/remoteControl/addRemoteControl/addRemoteControl_page.dart';
import 'main/lockDetail/remoteControl/remoteControlList/remoteControlList_page.dart'; import 'main/lockDetail/remoteControl/remoteControlList/remoteControlList_page.dart';
@ -214,7 +214,7 @@ abstract class Routers {
'/ElectronicKeyPeriodValidityPage'; // '/ElectronicKeyPeriodValidityPage'; //
static const sendEmailNotificationPage = '/SendEmailNotificationPage'; // static const sendEmailNotificationPage = '/SendEmailNotificationPage'; //
static const passwordKeyListPage = '/PasswordKeyListPage'; // static const passwordKeyListPage = '/PasswordKeyListPage'; //
static const passwordKeyManagePage = '/PasswordKeyManagePage'; // static const passwordKeyPerpetualPage = '/PasswordKeyPerpetualPage'; //
static const passwordKeyDetailPage = '/PasswordKeyDetailPage'; // static const passwordKeyDetailPage = '/PasswordKeyDetailPage'; //
// static const otherTypeKeyListPage = '/OtherTypeKeyListPage'; // // static const otherTypeKeyListPage = '/OtherTypeKeyListPage'; //
// static const otherTypeKeyDetailPage = '/OtherTypeKeyDetailPage'; // // static const otherTypeKeyDetailPage = '/OtherTypeKeyDetailPage'; //
@ -519,8 +519,8 @@ abstract class AppRouters {
page: () => const PasswordKeyListPage(), page: () => const PasswordKeyListPage(),
), ),
GetPage( GetPage(
name: Routers.passwordKeyManagePage, name: Routers.passwordKeyPerpetualPage,
page: () => const PasswordKeyManagePage(), page: () => const PasswordKeyPerpetualPage(),
), ),
GetPage( GetPage(
name: Routers.passwordKeyDetailPage, name: Routers.passwordKeyDetailPage,

View File

@ -114,7 +114,7 @@ class CommandReciverManager {
oriDataList = SM4.decrypt(getDataList, oriDataList = SM4.decrypt(getDataList,
key: getPrivateKeyList, mode: SM4CryptoMode.ECB); key: getPrivateKeyList, mode: SM4CryptoMode.ECB);
oriDataList = oriDataList.sublist(0, oriLen); oriDataList = oriDataList.sublist(0, oriLen);
// print("SM4 oriDataList:$oriDataList"); print("SM4 oriDataList:$oriDataList");
break; break;
} }
parseData(oriDataList).then((value) async { parseData(oriDataList).then((value) async {

View File

@ -81,7 +81,7 @@ class AddICCardLogic extends BaseGetXController{
IoSenderManage.senderAddCardWithTimeCycleCoercionCommand( IoSenderManage.senderAddCardWithTimeCycleCoercionCommand(
keyID:"1", keyID:"1",
userID:await Storage.getUid(), userID:await Storage.getUid(),
cardNo:state.isAdministrator.value == "2" ? 254 : 1, cardNo:state.isAdministrator.value == "2" ? 254 : 0,
useCountLimit:0xff, useCountLimit:0xff,
isForce:state.isCoerced.value == "1" ? 0 : 1, // isForce:state.isCoerced.value == "1" ? 0 : 1, //
isRound:state.selectType.value == "2" ? 1: 0, // isRound:state.selectType.value == "2" ? 1: 0, //
@ -229,7 +229,7 @@ class AddICCardLogic extends BaseGetXController{
IoSenderManage.senderAddCardWithTimeCycleCoercionCommand( IoSenderManage.senderAddCardWithTimeCycleCoercionCommand(
keyID:"1", keyID:"1",
userID:await Storage.getUid(), userID:await Storage.getUid(),
cardNo:state.isAdministrator.value == "2" ? 254 : 1, cardNo:state.isAdministrator.value == "2" ? 254 : 0,
useCountLimit:0xff, useCountLimit:0xff,
isForce:state.isCoerced.value == "2" ? 1 : 0, // isForce:state.isCoerced.value == "2" ? 1 : 0, //
isRound:state.selectType.value == "2" ? 1: 0, // isRound:state.selectType.value == "2" ? 1: 0, //

View File

@ -83,7 +83,7 @@ class AddFaceLogic extends BaseGetXController {
IoSenderManage.senderAddFaceCommand( IoSenderManage.senderAddFaceCommand(
keyID:"1", keyID:"1",
userID:await Storage.getUid(), userID:await Storage.getUid(),
faceNo:state.isAdministrator.value == "2" ? 254 : 1, faceNo:state.isAdministrator.value == "2" ? 254 : 0,
useCountLimit:0xff, useCountLimit:0xff,
isForce:state.isCoerced.value == "2" ? 1 : 0, // isForce:state.isCoerced.value == "2" ? 1 : 0, //
isRound:state.selectType.value == "2" ? 1: 0, // isRound:state.selectType.value == "2" ? 1: 0, //
@ -232,7 +232,7 @@ class AddFaceLogic extends BaseGetXController {
IoSenderManage.senderAddFaceCommand( IoSenderManage.senderAddFaceCommand(
keyID:"1", keyID:"1",
userID:await Storage.getUid(), userID:await Storage.getUid(),
faceNo:state.isAdministrator.value == "2" ? 254 : 1, faceNo:state.isAdministrator.value == "2" ? 254 : 0,
useCountLimit:0xff, useCountLimit:0xff,
isForce:state.isCoerced.value == "2" ? 1 : 0, // isForce:state.isCoerced.value == "2" ? 1 : 0, //
isRound:state.selectType.value == "2" ? 1: 0, // isRound:state.selectType.value == "2" ? 1: 0, //

View File

@ -93,7 +93,7 @@ class AddFingerprintLogic extends BaseGetXController {
IoSenderManage.senderAddFingerprintWithTimeCycleCoercionCommand( IoSenderManage.senderAddFingerprintWithTimeCycleCoercionCommand(
keyID:"1", keyID:"1",
userID:await Storage.getUid(), userID:await Storage.getUid(),
fingerNo:state.isAdministrator.value == "2" ? 254 : 1, fingerNo:state.isAdministrator.value == "2" ? 254 : 0,
useCountLimit:0xff, useCountLimit:0xff,
isForce:state.isCoerced.value == "1" ? 1 : 0, // isForce:state.isCoerced.value == "1" ? 1 : 0, //
isRound:state.selectType.value == "2" ? 1: 0, // isRound:state.selectType.value == "2" ? 1: 0, //
@ -283,7 +283,7 @@ class AddFingerprintLogic extends BaseGetXController {
IoSenderManage.senderAddFingerprintWithTimeCycleCoercionCommand( IoSenderManage.senderAddFingerprintWithTimeCycleCoercionCommand(
keyID:"1", keyID:"1",
userID:await Storage.getUid(), userID:await Storage.getUid(),
fingerNo:state.isAdministrator.value == "2" ? 254 : 1, fingerNo:state.isAdministrator.value == "2" ? 254 : 0,
useCountLimit:0xff, useCountLimit:0xff,
isForce:state.isCoerced.value == "2" ? 1 : 0, // isForce:state.isCoerced.value == "2" ? 1 : 0, //
isRound:state.selectType.value == "2" ? 1: 0, // isRound:state.selectType.value == "2" ? 1: 0, //

View File

@ -107,7 +107,7 @@ class _PasswordKeyListPageState extends State<PasswordKeyListPage> with RouteAwa
AddBottomWhiteBtn( AddBottomWhiteBtn(
btnName: TranslationLoader.lanKeys!.getPassword!.tr, btnName: TranslationLoader.lanKeys!.getPassword!.tr,
onClick: () { onClick: () {
Navigator.pushNamed(context, Routers.passwordKeyManagePage, Navigator.pushNamed(context, Routers.passwordKeyPerpetualPage,
arguments: {"keyInfo": state.keyInfo.value}).then((val) { arguments: {"keyInfo": state.keyInfo.value}).then((val) {
if (val != null) { if (val != null) {
logic.pageNo = 1; logic.pageNo = 1;

View File

@ -115,11 +115,7 @@ class _PasswordKeyManageTabbarPageState extends State<PasswordKeyManageTabbarPag
return Expanded( return Expanded(
child: TabBarView( child: TabBarView(
controller: _tabController, controller: _tabController,
children: _itemTabs.map((ItemView item) => PasswordKeyPerpetualPage( children: _itemTabs.map((ItemView item) => PasswordKeyPerpetualPage()).toList(),
type: item.type,
getKeyInfo: widget.keyInfo,
))
.toList(),
), ),
); );
} }

View File

@ -16,157 +16,178 @@ import 'package:star_lock/tools/storage.dart';
import '../../../../appRouters.dart'; import '../../../../appRouters.dart';
import '../../../../blue/blue_manage.dart'; import '../../../../blue/blue_manage.dart';
import '../../../../blue/io_modelVendor.dart'; import '../../../../blue/io_modelVendor.dart';
import '../../../../tools/CustomUnderlineTabIndicator.dart';
import '../../../../tools/NativeInteractionTool.dart'; import '../../../../tools/NativeInteractionTool.dart';
import '../../../../tools/appRouteObserver.dart'; import '../../../../tools/appRouteObserver.dart';
import '../../../../tools/commonItem.dart'; import '../../../../tools/commonItem.dart';
import '../../../../tools/dateTool.dart'; import '../../../../tools/dateTool.dart';
import '../../../../tools/submitBtn.dart'; import '../../../../tools/submitBtn.dart';
import '../../../../tools/titleAppBar.dart';
import '../../../../translations/trans_lib.dart'; import '../../../../translations/trans_lib.dart';
import '../../../lockMian/entity/lockListInfo_entity.dart'; import '../../../lockMian/entity/lockListInfo_entity.dart';
class PasswordKeyPerpetualPage extends StatefulWidget { class PasswordKeyPerpetualPage extends StatefulWidget {
final String type;
final LockListInfoItemEntity getKeyInfo;
const PasswordKeyPerpetualPage( const PasswordKeyPerpetualPage(
{Key? key, required this.type, required this.getKeyInfo}) {Key? key}) : super(key: key);
: super(key: key);
@override @override
State<PasswordKeyPerpetualPage> createState() => State<PasswordKeyPerpetualPage> createState() =>
_PasswordKeyPerpetualPageState(); _PasswordKeyPerpetualPageState();
} }
class _PasswordKeyPerpetualPageState extends State<PasswordKeyPerpetualPage> with RouteAware{ class _PasswordKeyPerpetualPageState extends State<PasswordKeyPerpetualPage> with RouteAware, SingleTickerProviderStateMixin{
final logic = Get.put(PasswordKeyPerpetualLogic()); final logic = Get.put(PasswordKeyPerpetualLogic());
final state = Get.find<PasswordKeyPerpetualLogic>().state; final state = Get.find<PasswordKeyPerpetualLogic>().state;
@override @override
void initState() { void initState() {
// TODO: implement initState
super.initState(); super.initState();
initData(); state.tabController = TabController(
// state.isSendSuccess.value = false; vsync: this,
} length: _itemTabs.length,
initialIndex: 0);
state.tabController.addListener(() {
WidgetsBinding.instance.addPostFrameCallback((_) {
state.widgetType.value = state.tabController.index;
});
void initData() { if (state.tabController.animation!.value == state.tabController.index) {
// if (!state.isInitialized.value) { FocusScope.of(context).requestFocus(FocusNode());
// state.isInitialized.value = true; }
// state.keyInfo.value = widget.getKeyInfo; });
// }
} }
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
state.keyInfo.value = widget.getKeyInfo; return Scaffold(
state.widgetType.value = int.parse(widget.type); backgroundColor: AppColors.mainBackgroundColor,
print("state.widgetType.value:${state.widgetType.value}"); appBar: TitleAppBar(
barTitle: TranslationLoader.lanKeys!.getPassword!.tr,
return SingleChildScrollView( haveBack: true,
child: Obx(() => indexChangeWidget()), backgroundColor: AppColors.mainColor),
body: Column(
children: [
_tabBar(),
_pageWidget(),
],
),
); );
} }
Widget indexChangeWidget() { Widget indexChangeWidget() {
if (state.isSendSuccess.value == true && state.sendSucceedType.value.toString() == widget.type) { if (state.isSendSuccess.value == true && state.sendSucceedType.value == state.widgetType.value) {
return sendElectronicKeySucceed(); return sendElectronicKeySucceed();
} else { } else {
switch (int.parse(widget.type)) { switch (state.widgetType.value) {
case 0: case 0:
{ {
// //
return Column( return SingleChildScrollView(
children: [ child: Column(
perpetualKeyWidget( children: [
false, perpetualKeyWidget(
TranslationLoader.lanKeys!.name!.tr, false,
TranslationLoader.lanKeys!.pleaseNameYourPassword!.tr, TranslationLoader.lanKeys!.name!.tr,
state.nameController), TranslationLoader.lanKeys!.pleaseNameYourPassword!.tr,
keyBottomWidget(TranslationLoader.lanKeys!.getPasswordTip1!.tr) state.nameController),
], keyBottomWidget(TranslationLoader.lanKeys!.getPasswordTip1!.tr)
],
),
); );
} }
case 1: case 1:
{ {
// //
return Column( return SingleChildScrollView(
children: [ child: Column(
keyTimeLimitWidget(), children: [
perpetualKeyWidget( keyTimeLimitWidget(),
false, perpetualKeyWidget(
TranslationLoader.lanKeys!.name!.tr, false,
TranslationLoader.lanKeys!.pleaseNameYourPassword!.tr, TranslationLoader.lanKeys!.name!.tr,
state.nameController), TranslationLoader.lanKeys!.pleaseNameYourPassword!.tr,
keyBottomWidget(TranslationLoader.lanKeys!.getPasswordTip2!.tr) state.nameController),
], keyBottomWidget(TranslationLoader.lanKeys!.getPasswordTip2!.tr)
],
),
); );
} }
case 2: case 2:
{ {
// //
return Column( return SingleChildScrollView(
children: [ child: Column(
perpetualKeyWidget( children: [
false, perpetualKeyWidget(
TranslationLoader.lanKeys!.name!.tr, false,
TranslationLoader.lanKeys!.pleaseNameYourPassword!.tr, TranslationLoader.lanKeys!.name!.tr,
state.nameController), TranslationLoader.lanKeys!.pleaseNameYourPassword!.tr,
keyBottomWidget(TranslationLoader.lanKeys!.getPasswordTip3!.tr) state.nameController),
], keyBottomWidget(TranslationLoader.lanKeys!.getPasswordTip3!.tr)
],
),
); );
} }
case 3: case 3:
{ {
// //
return Column( return SingleChildScrollView(
children: [ child: Column(
keyIfPerpetualWidget(), children: [
state.isPermanent.value == false keyIfPerpetualWidget(),
? keyTimeLimitWidget() state.isPermanent.value == false
: Container(), ? keyTimeLimitWidget()
perpetualKeyWidget( : Container(),
false, perpetualKeyWidget(
TranslationLoader.lanKeys!.name!.tr, false,
TranslationLoader.lanKeys!.pleaseNameYourPassword!.tr, TranslationLoader.lanKeys!.name!.tr,
state.nameController), TranslationLoader.lanKeys!.pleaseNameYourPassword!.tr,
perpetualKeyWidget( state.nameController),
false, perpetualKeyWidget(
TranslationLoader.lanKeys!.password!.tr, false,
"请输入6-9位数字", state.pwdController TranslationLoader.lanKeys!.password!.tr,
), "请输入6-9位数字", state.pwdController
keyIfAdministratorWidget(), ),
keyBottomWidget(TranslationLoader.lanKeys!.getPasswordTip4!.tr) keyIfAdministratorWidget(),
], keyBottomWidget(TranslationLoader.lanKeys!.getPasswordTip4!.tr)
],
),
); );
} }
case 4: case 4:
{ {
// //
return Column( return SingleChildScrollView(
children: [ child: Column(
keyCirculationWidget(), children: [
perpetualKeyWidget( keyCirculationWidget(),
true, perpetualKeyWidget(
TranslationLoader.lanKeys!.name!.tr, true,
TranslationLoader.lanKeys!.pleaseNameYourPassword!.tr, TranslationLoader.lanKeys!.name!.tr,
state.nameController), TranslationLoader.lanKeys!.pleaseNameYourPassword!.tr,
keyBottomWidget(TranslationLoader.lanKeys!.getPasswordTip2!.tr) state.nameController),
], keyBottomWidget(TranslationLoader.lanKeys!.getPasswordTip2!.tr)
],
),
); );
} }
case 5: case 5:
{ {
// //
return Column( return SingleChildScrollView(
children: [ child: Column(
perpetualKeyWidget( children: [
false, perpetualKeyWidget(
TranslationLoader.lanKeys!.name!.tr, false,
TranslationLoader.lanKeys!.pleaseNameYourPassword!.tr, TranslationLoader.lanKeys!.name!.tr,
state.nameController), TranslationLoader.lanKeys!.pleaseNameYourPassword!.tr,
keyBottomWidget(TranslationLoader.lanKeys!.getPasswordTip6!.tr) state.nameController),
], keyBottomWidget(TranslationLoader.lanKeys!.getPasswordTip6!.tr)
],
),
); );
} }
default: default:
@ -365,7 +386,7 @@ class _PasswordKeyPerpetualPageState extends State<PasswordKeyPerpetualPage> wit
height: 20.h, height: 20.h,
), ),
SubmitBtn( SubmitBtn(
btnName: widget.type == "3" ? "设置密码":TranslationLoader.lanKeys!.getPassword!.tr, btnName: state.widgetType.value == 3 ? "设置密码":TranslationLoader.lanKeys!.getPassword!.tr,
onClick: () async { onClick: () async {
var isDemoMode = await Storage.getBool(ifIsDemoModeOrNot); var isDemoMode = await Storage.getBool(ifIsDemoModeOrNot);
if (isDemoMode == false) { if (isDemoMode == false) {
@ -568,6 +589,66 @@ class _PasswordKeyPerpetualPageState extends State<PasswordKeyPerpetualPage> wit
}); });
} }
TabBar _tabBar() {
return TabBar(
controller: state.tabController,
onTap: (index){
FocusScope.of(context).requestFocus(FocusNode());
},
tabs: _itemTabs.map((ItemView item) => _tab(item)).toList(),
isScrollable: true,
indicatorColor: Colors.red,
unselectedLabelColor: Colors.black,
unselectedLabelStyle: TextStyle(
color: AppColors.mainColor,
fontSize: 24.sp,
),
automaticIndicatorColorAdjustment: true,
labelColor: AppColors.mainColor,
labelStyle: TextStyle(
color: AppColors.mainColor,
fontSize: 24.sp,
fontWeight: FontWeight.w600),
indicator: CustomUnderlineTabIndicator(
borderSide: BorderSide(color: AppColors.mainColor, width: 4.w),
strokeCap: StrokeCap.round,
width: 30.w),
);
}
Tab _tab(ItemView item) {
return Tab(
// text: item.title,
child: Container(
// width: item.title.length > 2 ? 1.sw / 8 : 1.sw / 12,
// margin: EdgeInsets.all(10.w),
// color: Colors.red,
child: Text(
item.title,
textAlign: TextAlign.center,
),
),
);
}
Widget _pageWidget() {
return Expanded(
child: TabBarView(
controller: state.tabController,
children: _itemTabs.map((ItemView item) => Obx(() => indexChangeWidget())).toList(),
),
);
}
final List<ItemView> _itemTabs = <ItemView>[
ItemView(title: TranslationLoader.lanKeys!.permanent!.tr, type: "0"),
ItemView(title: TranslationLoader.lanKeys!.timeLimit!.tr, type: "1"),
ItemView(title: TranslationLoader.lanKeys!.once!.tr, type: "2"),
ItemView(title: TranslationLoader.lanKeys!.custom!.tr, type: "3"),
ItemView(title: TranslationLoader.lanKeys!.circulation!.tr, type: "4"),
ItemView(title: TranslationLoader.lanKeys!.clearAll!.tr, type: "5"),
];
List<Widget> initBottomSheetList() { List<Widget> initBottomSheetList() {
List<Widget> widgetList = []; List<Widget> widgetList = [];
@ -684,3 +765,10 @@ class _PasswordKeyPerpetualPageState extends State<PasswordKeyPerpetualPage> wit
state.sureBtnState.value = 0; state.sureBtnState.value = 0;
} }
} }
class ItemView {
const ItemView({required this.title, required this.type});
final String title;
final String type;
}

View File

@ -1,4 +1,5 @@
import 'package:flutter/material.dart';
import 'package:flutter/widgets.dart'; import 'package:flutter/widgets.dart';
import 'package:get/get.dart'; import 'package:get/get.dart';
import 'package:star_lock/main/lockMian/entity/lockListInfo_entity.dart'; import 'package:star_lock/main/lockMian/entity/lockListInfo_entity.dart';
@ -32,4 +33,13 @@ class PasswordKeyPerpetualState {
var sureBtnState = 0.obs;// 0() 1() var sureBtnState = 0.obs;// 0() 1()
var pwdNumber = 0.obs;// var pwdNumber = 0.obs;//
late TabController tabController;
PasswordKeyPerpetualState() {
Map map = Get.arguments;
if(map["keyInfo"] != null){
keyInfo.value = map["keyInfo"];
}
}
} }

View File

@ -38,10 +38,9 @@ class SaveLockLogic extends BaseGetXController {
_replySenderCustomPasswords(reply); _replySenderCustomPasswords(reply);
} }
if (reply is ChangeAdministratorPasswordReply) { // if (reply is ChangeAdministratorPasswordReply) {
_replyChangeAdministratorPassword(reply); // _replyChangeAdministratorPassword(reply);
} // }
}); });
} }
@ -152,51 +151,51 @@ class SaveLockLogic extends BaseGetXController {
} }
// //
Future<void> _replyChangeAdministratorPassword(Reply reply) async { // Future<void> _replyChangeAdministratorPassword(Reply reply) async {
var token = reply.data.sublist(5, 9); // var token = reply.data.sublist(5, 9);
var saveStrList = changeIntListToStringList(token); // var saveStrList = changeIntListToStringList(token);
Storage.setStringList(saveBlueToken, saveStrList); // Storage.setStringList(saveBlueToken, saveStrList);
//
int status = reply.data[2]; // int status = reply.data[2];
Get.log("status:$status"); // Get.log("status:$status");
//
switch (status) { // switch (status) {
case 0x00: // case 0x00:
// // //
Get.log("${reply.commandType!.typeValue} 数据解析成功"); // Get.log("${reply.commandType!.typeValue} 数据解析成功");
cancelBlueConnetctToastTimer(); // cancelBlueConnetctToastTimer();
addLockAdminPassword(false); // addLockAdminPassword(false);
break; // break;
case 0x06: // case 0x06:
// // //
Get.log("${reply.commandType!.typeValue} 需要鉴权"); // Get.log("${reply.commandType!.typeValue} 需要鉴权");
//
var signKey = await Storage.getStringList(saveBlueSignKey); // var signKey = await Storage.getStringList(saveBlueSignKey);
List<int> signKeyDataList = changeStringListToIntList(signKey!); // List<int> signKeyDataList = changeStringListToIntList(signKey!);
//
var privateKey = await Storage.getStringList(saveBluePrivateKey); // var privateKey = await Storage.getStringList(saveBluePrivateKey);
List<int> getPrivateKeyList = changeStringListToIntList(privateKey!); // List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
//
IoSenderManage.changeAdministratorPasswordCommand( // IoSenderManage.changeAdministratorPasswordCommand(
keyID: "1", // keyID: "1",
userID: await Storage.getUid(), // userID: await Storage.getUid(),
pwdNo: 254, // pwdNo: 254,
pwd:state.adminPasswordTF.text, // pwd:state.adminPasswordTF.text,
useCountLimit: 0xff, // useCountLimit: 0xff,
startTime: 0x11223344, // startTime: 0x11223344,
endTime: 0x11223344, // endTime: 0x11223344,
needAuthor: 1, // needAuthor: 1,
isBeforeAddUser: true, // isBeforeAddUser: true,
signKey: signKeyDataList, // signKey: signKeyDataList,
privateKey: getPrivateKeyList, // privateKey: getPrivateKeyList,
token: token); // token: token);
break; // break;
default: // default:
// // //
Get.log("${reply.commandType!.typeValue} 失败"); // Get.log("${reply.commandType!.typeValue} 失败");
break; // break;
} // }
} // }
// //
Future<void> addUserConnectBlue() async { Future<void> addUserConnectBlue() async {
@ -284,45 +283,45 @@ class SaveLockLogic extends BaseGetXController {
} }
// (//5) // (//5)
Future<void> changeAdministratorPasswordCommand() async { // Future<void> changeAdministratorPasswordCommand() async {
showEasyLoading(); // showEasyLoading();
showBlueConnetctToastTimer(action: (){ // showBlueConnetctToastTimer(action: (){
dismissEasyLoading(); // dismissEasyLoading();
}); // });
BlueManage().bludSendData(BlueManage().connectDeviceName, (BluetoothConnectionState deviceConnectionState) async { // BlueManage().bludSendData(BlueManage().connectDeviceName, (BluetoothConnectionState deviceConnectionState) async {
if (deviceConnectionState == BluetoothConnectionState.connected) { // if (deviceConnectionState == BluetoothConnectionState.connected) {
var signKey = await Storage.getStringList(saveBlueSignKey); // var signKey = await Storage.getStringList(saveBlueSignKey);
List<int> signKeyDataList = changeStringListToIntList(signKey!); // List<int> signKeyDataList = changeStringListToIntList(signKey!);
//
var privateKey = await Storage.getStringList(saveBluePrivateKey); // var privateKey = await Storage.getStringList(saveBluePrivateKey);
List<int> getPrivateKeyList = changeStringListToIntList(privateKey!); // List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
//
var token = await Storage.getStringList(saveBlueToken); // var token = await Storage.getStringList(saveBlueToken);
List<int> getTokenList = changeStringListToIntList(token!); // List<int> getTokenList = changeStringListToIntList(token!);
//
IoSenderManage.changeAdministratorPasswordCommand( // IoSenderManage.changeAdministratorPasswordCommand(
keyID: "1", // keyID: "1",
userID: await Storage.getUid(), // userID: await Storage.getUid(),
pwdNo: 254, // pwdNo: 254,
pwd:state.adminPasswordTF.text, // pwd:state.adminPasswordTF.text,
useCountLimit: 0xff, // useCountLimit: 0xff,
startTime: 0x11223344, // startTime: 0x11223344,
endTime: 0x11223344, // endTime: 0x11223344,
needAuthor: 1, // needAuthor: 1,
isBeforeAddUser: true, // isBeforeAddUser: true,
signKey: signKeyDataList, // signKey: signKeyDataList,
privateKey: getPrivateKeyList, // privateKey: getPrivateKeyList,
token: getTokenList); // token: getTokenList);
} else if (deviceConnectionState == BluetoothConnectionState.disconnected) { // } else if (deviceConnectionState == BluetoothConnectionState.disconnected) {
dismissEasyLoading(); // dismissEasyLoading();
cancelBlueConnetctToastTimer(); // cancelBlueConnetctToastTimer();
state.saveBtnIsUsable.value = true; // state.saveBtnIsUsable.value = true;
if(state.ifCurrentScreen.value == true){ // if(state.ifCurrentScreen.value == true){
showBlueConnetctToast(); // showBlueConnetctToast();
} // }
} // }
}, isAddEquipment: true); // }, isAddEquipment: true);
} // }
void bindBlueAdmin() async{ void bindBlueAdmin() async{
@ -381,52 +380,52 @@ class SaveLockLogic extends BaseGetXController {
adminPwd: state.adminPasswordTF.text, adminPwd: state.adminPasswordTF.text,
); );
if (entity.errorCode!.codeIsSuccessful) { if (entity.errorCode!.codeIsSuccessful) {
if(isAddLockAdminPassword == true){ // if(isAddLockAdminPassword == true){
showDeletPasswordAlertDialog(); // showDeletPasswordAlertDialog();
}else{ // }else{
backAction(); backAction();
} // }
} }
} }
void showDeletPasswordAlertDialog() { // void showDeletPasswordAlertDialog() {
showDialog( // showDialog(
context: Get.context!, // context: Get.context!,
builder: (BuildContext context) { // builder: (BuildContext context) {
return ShowTFView( // return ShowTFView(
title: "管理员密码", // title: "管理员密码",
tipTitle: "如需修改,请输入新的管理员密码(6位),点击确定即可修改", // tipTitle: "如需修改,请输入新的管理员密码(6位),点击确定即可修改",
leftBtnTitle: "确定".tr, // leftBtnTitle: "确定".tr,
rightBtnTitle: "修改", // rightBtnTitle: "修改",
keyboardType: TextInputType.number, // keyboardType: TextInputType.number,
inputFormatters: [ // inputFormatters: [
FilteringTextInputFormatter.allow(RegExp('[0-9]')), // FilteringTextInputFormatter.allow(RegExp('[0-9]')),
LengthLimitingTextInputFormatter(6), // LengthLimitingTextInputFormatter(6),
], // ],
controller: state.adminPasswordTF, // controller: state.adminPasswordTF,
sureClick: () { // sureClick: () {
if(state.adminPasswordTF.text.length < 6){ // if(state.adminPasswordTF.text.length < 6){
showToast("请输入6位管理员密码".tr); // showToast("请输入6位管理员密码".tr);
return; // return;
} // }
//
if(state.adminPasswordTF.text == state.adminPassword){ // if(state.adminPasswordTF.text == state.adminPassword){
showToast("请输入新的管理员密码".tr); // showToast("请输入新的管理员密码".tr);
return; // return;
} // }
changeAdministratorPasswordCommand(); // changeAdministratorPasswordCommand();
}, // },
cancelClick: () { // cancelClick: () {
backAction(); // backAction();
}, // },
); // );
}, // },
); // );
} // }
void backAction(){ void backAction(){
BlueManage().disconnect(); BlueManage().disconnect();
Get.close(state.isFromMap == 1 ? 6 : 7); Get.close(state.isFromMap == 1 ? 5 : 6);
} }
@override @override

View File

@ -3,6 +3,7 @@ import 'package:flutter/material.dart';
import 'package:flutter/services.dart'; import 'package:flutter/services.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart'; import 'package:get/get.dart';
import 'package:star_lock/blue/blue_manage.dart';
import '../../../app_settings/app_colors.dart'; import '../../../app_settings/app_colors.dart';
import '../../../tools/appRouteObserver.dart'; import '../../../tools/appRouteObserver.dart';
@ -134,6 +135,7 @@ class _SaveLockPageState extends State<SaveLockPage> with RouteAware {
/// ///
AppRouteObserver().routeObserver.unsubscribe(this); AppRouteObserver().routeObserver.unsubscribe(this);
super.dispose(); super.dispose();
BlueManage().stopScan();
} }
/// ///
@ -141,6 +143,7 @@ class _SaveLockPageState extends State<SaveLockPage> with RouteAware {
void didPush() { void didPush() {
super.didPush(); super.didPush();
BlueManage().stopScan();
state.ifCurrentScreen.value = true; state.ifCurrentScreen.value = true;
} }
@ -149,6 +152,7 @@ class _SaveLockPageState extends State<SaveLockPage> with RouteAware {
void didPop() { void didPop() {
super.didPop(); super.didPop();
BlueManage().stopScan();
state.ifCurrentScreen.value = false; state.ifCurrentScreen.value = false;
logic.cancelBlueConnetctToastTimer(); logic.cancelBlueConnetctToastTimer();
} }