卡、指纹、遥控、拆分,修改bug
This commit is contained in:
parent
1a8d726e2f
commit
d8042672a3
@ -409,6 +409,8 @@
|
||||
"edit":"Edit",
|
||||
"stressFingerprint":"Stress Fingerprint",
|
||||
"effectiveDay":"Effective Day",
|
||||
"stressCard":"Stress Card",
|
||||
"stressPassword":"Stress Password",
|
||||
|
||||
"whetherTheEmployeeHasPassword":"If The Employee Has A Password",
|
||||
"whetherTheEmployeeHasCard":"If The Employee Has A Card",
|
||||
|
||||
@ -409,6 +409,8 @@
|
||||
"edit":"edit",
|
||||
"stressFingerprint":"stressFingerprint",
|
||||
"effectiveDay":"effectiveDay",
|
||||
"stressPassword":"stressPassword",
|
||||
"stressCard":"stressCard",
|
||||
|
||||
"whetherTheEmployeeHasPassword":"whetherTheEmployeeHasPassword",
|
||||
"whetherTheEmployeeHasCard":"whetherTheEmployeeHasCard",
|
||||
|
||||
@ -412,6 +412,8 @@
|
||||
"edit":"编辑",
|
||||
"stressFingerprint":"胁迫指纹",
|
||||
"effectiveDay":"有效日",
|
||||
"stressCard":"胁迫卡",
|
||||
"stressPassword":"胁迫密码",
|
||||
|
||||
"whetherTheEmployeeHasPassword":"员工是否有密码",
|
||||
"whetherTheEmployeeHasCard":"员工是否有卡",
|
||||
|
||||
@ -15,7 +15,6 @@ import 'package:star_lock/main/lockDetail/lcokSet/msgNotification/msgNotificatio
|
||||
import 'package:star_lock/main/lockDetail/lcokSet/notificationMode/notificationMode_page.dart';
|
||||
import 'package:star_lock/main/lockDetail/lcokSet/openDoorDirection/openDoorDirection_page.dart';
|
||||
import 'package:star_lock/main/lockDetail/lockDetail/lockDetail_main_page.dart';
|
||||
import 'package:star_lock/main/lockDetail/otherTypeKey/addFace/addFace_page.dart';
|
||||
import 'package:star_lock/mine/about/webviewShow_page.dart';
|
||||
import 'package:star_lock/mine/mine/safeVerify/safeVerify_page.dart';
|
||||
import 'package:star_lock/mine/minePersonInfo/minePersonInfoEmail/mineBindPhoneOrEmail_page.dart';
|
||||
@ -37,6 +36,12 @@ import 'login/forgetPassword/starLock_forgetPassword_page.dart';
|
||||
import 'login/login/starLock_login_page.dart';
|
||||
import 'login/register/starLock_register_page.dart';
|
||||
import 'login/seletCountryRegion/seletCountryRegion_page.dart';
|
||||
import 'main/lockDetail/card/addCardType/addCardManage/addCardTypeManage_page.dart';
|
||||
import 'main/lockDetail/card/addICCard/addICCard_page.dart';
|
||||
import 'main/lockDetail/card/cardDetail/cardDetail_page.dart';
|
||||
import 'main/lockDetail/card/cardList/cardList_page.dart';
|
||||
import 'main/lockDetail/card/otherTypeKeyChangeDate/otherTypeKeyChangeDate_page.dart';
|
||||
import 'main/lockDetail/card/otherTypeKeyChangeValidityDate/otherTypeKeyChangeValidityDate_page.dart';
|
||||
import 'main/lockDetail/checkingIn/checkingInDetail/checkingInDetail_page.dart';
|
||||
import 'main/lockDetail/checkingIn/checkingInHolidays/checkingInAddHolidays/checkingInAddHolidays_page.dart';
|
||||
import 'main/lockDetail/checkingIn/checkingInHolidays/checkingInDeletHolidays/checkingInDeletHolidays_page.dart';
|
||||
@ -49,6 +54,14 @@ import 'main/lockDetail/checkingIn/checkingInStaff/checkingInSetAddStaff/checkin
|
||||
import 'main/lockDetail/checkingIn/checkingInStaff/checkingInSetStaffList/checkingInStaffList_page.dart';
|
||||
import 'main/lockDetail/checkingIn/checkingInStaff/checkingInStaffDetail/checkingInStaffDetail_page.dart';
|
||||
import 'main/lockDetail/electronicKey/electronicKeyDetail/keyOperationRecord_page.dart';
|
||||
import 'main/lockDetail/face/addFace/addFace_page.dart';
|
||||
import 'main/lockDetail/face/addFaceType/addFaceTypeManage/addFaceTypeManage_page.dart';
|
||||
import 'main/lockDetail/face/faceList/faceList_page.dart';
|
||||
import 'main/lockDetail/fingerprint/addFingerprint/addFingerprint_page.dart';
|
||||
import 'main/lockDetail/fingerprint/addFingerprintSeletType/addFingerprintManage/addFingerprintTypeManage_page.dart';
|
||||
import 'main/lockDetail/fingerprint/addFingerprintTip/addFingerprintTip_page.dart';
|
||||
import 'main/lockDetail/fingerprint/fingerprintDetail/fingerprintDetail_page.dart';
|
||||
import 'main/lockDetail/fingerprint/fingerprintList/fingerprintList_page.dart';
|
||||
import 'main/lockDetail/lcokSet/automaticBlocking/automaticBlocking_page.dart';
|
||||
import 'main/lockDetail/lcokSet/basicInformation/adminOpenLockPassword/adminOpenLockPassword_page.dart';
|
||||
import 'main/lockDetail/lcokSet/basicInformation/basicInformation/basicInformation_page.dart';
|
||||
@ -86,11 +99,8 @@ import 'main/lockDetail/lcokSet/wirelessKeyboard/seletWirelessKeyboard/seletWire
|
||||
import 'main/lockDetail/lcokSet/wirelessKeyboard/wirelessKeyboardList/wirelessKeyboard_page.dart';
|
||||
import 'main/lockDetail/monitoring/monitoring/lockMonitoring_page.dart';
|
||||
import 'main/lockDetail/monitoring/monitoringRealTimeScreen/monitoringRealTimeScreen_page.dart';
|
||||
import 'main/lockDetail/otherTypeKey/addFingerprint/addFingerprint/addFingerprint_page.dart';
|
||||
import 'main/lockDetail/otherTypeKey/addFingerprint/addFingerprintTip/addFingerprintTip_page.dart';
|
||||
import 'main/lockDetail/otherTypeKey/addICCard/addICCard_page.dart';
|
||||
import 'main/lockDetail/otherTypeKey/otherTypeKeyChangeDate/otherTypeKeyChangeDate_page.dart';
|
||||
import 'main/lockDetail/otherTypeKey/otherTypeKeyChangeValidityDate/otherTypeKeyChangeValidityDate_page.dart';
|
||||
import 'main/lockDetail/remoteControl/addRemoteControl/addRemoteControlManage/addRemoteControlManage_page.dart';
|
||||
import 'main/lockDetail/remoteControl/remoteControlList/remoteControlList_page.dart';
|
||||
import 'main/lockDetail/videoLog/editVideoLog/editVideoLog_page.dart';
|
||||
import 'main/lockDetail/videoLog/videoLog/videoLog_page.dart';
|
||||
import 'main/lockDetail/videoLog/videoLogDetail/videoLogDetail_page.dart';
|
||||
@ -111,9 +121,6 @@ import 'main/lockDetail/electronicKey/massSendElectronicKey/massSendElectronicMa
|
||||
import 'main/lockDetail/electronicKey/sendElectronicKey/sendElectronicManageKey/sendElectronicKeyManage_page.dart';
|
||||
import 'main/lockDetail/electronicKey/sendEmailNotification/sendEmailNotification_page.dart';
|
||||
import 'main/lockDetail/lockOperatingRecord/lockOperatingRecord_page.dart';
|
||||
import 'main/lockDetail/otherTypeKey/otherTypeKeyDetail/otherTypeKeyDetail_page.dart';
|
||||
import 'main/lockDetail/otherTypeKey/otherTypeKeyList/otherTypeKeyList_page.dart';
|
||||
import 'main/lockDetail/otherTypeKey/otherTypeKeyManage/otherTypeKeyManage_page.dart';
|
||||
import 'main/lockDetail/passwordKey/passwordKeyDetail/passwordKeyDetail_page.dart';
|
||||
import 'main/lockDetail/passwordKey/passwordKeyList/passwordKeyList_page.dart';
|
||||
import 'main/lockDetail/passwordKey/passwordKeyManage/passwordKeyManage_page.dart';
|
||||
@ -190,11 +197,9 @@ abstract class Routers {
|
||||
static const passwordKeyListPage = '/PasswordKeyListPage'; // 密码钥匙列表
|
||||
static const passwordKeyManagePage = '/PasswordKeyManagePage'; // 密码钥匙
|
||||
static const passwordKeyDetailPage = '/PasswordKeyDetailPage'; // 密码钥匙详情
|
||||
static const otherTypeKeyListPage = '/OtherTypeKeyListPage'; // 卡、指纹、遥控钥匙列表
|
||||
static const otherTypeKeyDetailPage =
|
||||
'/OtherTypeKeyDetailPage'; // 卡、指纹、遥控钥匙详情
|
||||
static const otherTypeKeyManagePage =
|
||||
'/OtherTypeKeyManagePage'; // 卡、指纹、遥控钥匙添加
|
||||
// static const otherTypeKeyListPage = '/OtherTypeKeyListPage'; // 卡、指纹、遥控钥匙列表
|
||||
// static const otherTypeKeyDetailPage = '/OtherTypeKeyDetailPage'; // 卡、指纹、遥控钥匙详情
|
||||
// static const otherTypeKeyManagePage = '/OtherTypeKeyManagePage'; // 卡、指纹、遥控钥匙添加
|
||||
static const otherTypeKeyChangeDatePage =
|
||||
'/OtherTypeKeyChangeDatePage'; // 卡、指纹、遥控钥匙详情修改日期
|
||||
static const otherTypeKeyChangeValidityDatePage =
|
||||
@ -383,6 +388,18 @@ abstract class Routers {
|
||||
static const editVideoLogPage = '/EditVideoLogPage'; // 编辑视频日志
|
||||
static const videoLogDetailPage = '/VideoLogDetailPage'; // 视频日志详情
|
||||
static const videoLogDownLoadPage = '/VideoLogDownLoadPage'; // 视频下载列表
|
||||
|
||||
static const remoteControlListPage = '/RemoteControlListPage'; // 遥控列表
|
||||
static const addRemoteControlManagePage = '/AddRemoteControlManagePage'; // 添加遥控
|
||||
|
||||
static const cardListPage = '/CardListPage'; // 卡列表
|
||||
static const addCardTypeManagePage = '/AddCardTypeManagePage'; // 添加卡
|
||||
static const cardDetailPage = '/CardDetailPage'; // 卡详情
|
||||
static const fingerprintListPage = '/FingerprintListPage'; // 指纹列表
|
||||
static const addFingerprintTypeManagePage = '/AddFingerprintTypeManagePage'; // 添加指纹
|
||||
static const fingerprintDetailPage = '/FingerprintDetailPage'; // 指纹详情
|
||||
static const faceList = '/FaceList'; // 人脸列表
|
||||
static const addFaceTypeManagePage = '/AddFaceTypeManagePage'; // 添加人脸
|
||||
}
|
||||
|
||||
abstract class AppRouters {
|
||||
@ -459,18 +476,18 @@ abstract class AppRouters {
|
||||
name: Routers.passwordKeyDetailPage,
|
||||
page: () => const PasswordKeyDetailPage(),
|
||||
),
|
||||
GetPage(
|
||||
name: Routers.otherTypeKeyListPage,
|
||||
page: () => const OtherTypeKeyListPage(),
|
||||
),
|
||||
GetPage(
|
||||
name: Routers.otherTypeKeyDetailPage,
|
||||
page: () => const OtherTypeKeyDetailPage(),
|
||||
),
|
||||
GetPage(
|
||||
name: Routers.otherTypeKeyManagePage,
|
||||
page: () => const OtherTypeKeyManagePage(),
|
||||
),
|
||||
// GetPage(
|
||||
// name: Routers.otherTypeKeyListPage,
|
||||
// page: () => const OtherTypeKeyListPage(),
|
||||
// ),
|
||||
// GetPage(
|
||||
// name: Routers.otherTypeKeyDetailPage,
|
||||
// page: () => const OtherTypeKeyDetailPage(),
|
||||
// ),
|
||||
// GetPage(
|
||||
// name: Routers.otherTypeKeyManagePage,
|
||||
// page: () => const OtherTypeKeyManagePage(),
|
||||
// ),
|
||||
GetPage(
|
||||
name: Routers.authorizedAdminListPage,
|
||||
page: () => const AuthorizedAdminListPage(),
|
||||
@ -942,5 +959,35 @@ abstract class AppRouters {
|
||||
GetPage(
|
||||
name: Routers.videoLogDownLoadPage,
|
||||
page: () => const VideoLogDownLoadPage()),
|
||||
GetPage(
|
||||
name: Routers.remoteControlListPage,
|
||||
page: () => const RemoteControlListPage()),
|
||||
GetPage(
|
||||
name: Routers.addRemoteControlManagePage,
|
||||
page: () => const AddRemoteControlManagePage()),
|
||||
GetPage(
|
||||
name: Routers.cardListPage,
|
||||
page: () => const CardListPage()),
|
||||
GetPage(
|
||||
name: Routers.addCardTypeManagePage,
|
||||
page: () => const AddCardTypeManagePage()),
|
||||
GetPage(
|
||||
name: Routers.cardDetailPage,
|
||||
page: () => const CardDetailPage()),
|
||||
GetPage(
|
||||
name: Routers.fingerprintListPage,
|
||||
page: () => const FingerprintListPage()),
|
||||
GetPage(
|
||||
name: Routers.addFingerprintTypeManagePage,
|
||||
page: () => const AddFingerprintTypeManagePage()),
|
||||
GetPage(
|
||||
name: Routers.fingerprintDetailPage,
|
||||
page: () => const FingerprintDetailPage()),
|
||||
GetPage(
|
||||
name: Routers.faceList,
|
||||
page: () => const FaceList()),
|
||||
GetPage(
|
||||
name: Routers.addFaceTypeManagePage,
|
||||
page: () => const AddFaceTypeManagePage()),
|
||||
];
|
||||
}
|
||||
|
||||
@ -58,12 +58,12 @@ class CommandReciverManager {
|
||||
print("appDataReceiveData:$data"); // &&(data[4] == 0x11)
|
||||
if((data[0] == 0xEF)&&(data[1] == 0x01)&&(data[2] == 0xEE)&&(data[3] == 0x02)){
|
||||
var tmpType = (data[7] & 0x0f);// 包标识
|
||||
print("temType:$tmpType");
|
||||
// print("temType:$tmpType");
|
||||
|
||||
var dataLen = data[8] * 256 + data[9];// 高16位用来指示后面数据块内容的长度
|
||||
var oriLen = data[10] * 256 + data[11];// 低16位用来指示数据加密前的原长度
|
||||
print("dataLen:$dataLen oriLen:$oriLen");
|
||||
List<int> dataList = [];
|
||||
// print("dataLen:$dataLen oriLen:$oriLen");
|
||||
// List<int> dataList = [];
|
||||
List<int> oriDataList = [];
|
||||
switch(tmpType){
|
||||
case 0: //不加密
|
||||
|
||||
@ -0,0 +1,46 @@
|
||||
|
||||
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 'addCardTypeManage_tabbar.dart';
|
||||
|
||||
class AddCardTypeManagePage extends StatefulWidget {
|
||||
const AddCardTypeManagePage({Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
State<AddCardTypeManagePage> createState() => _AddCardTypeManagePageState();
|
||||
}
|
||||
|
||||
class _AddCardTypeManagePageState extends State<AddCardTypeManagePage> {
|
||||
var index = 0;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
// 0卡 1指纹 2钥匙
|
||||
Map map = Get.arguments;
|
||||
var lockId = map["lockId"];
|
||||
var fromType = map["fromType"]; // 1从添加钥匙列表进入 2从考勤添加员工入口进入
|
||||
var fromTypeTwoStaffName = "";
|
||||
if(fromType == 2){
|
||||
fromTypeTwoStaffName = map["fromTypeTwoStaffName"]; // 从添加员工进入 传入员工名字
|
||||
}
|
||||
|
||||
return Scaffold(
|
||||
backgroundColor: AppColors.mainBackgroundColor,
|
||||
appBar: TitleAppBar(
|
||||
barTitle:
|
||||
"${TranslationLoader.lanKeys!.addTip!.tr}${TranslationLoader.lanKeys!.card!.tr}",
|
||||
haveBack: true,
|
||||
backgroundColor: AppColors.mainColor),
|
||||
body: Column(
|
||||
children: [
|
||||
AddCardManageTabbar(initialIndex: index, lockId: lockId, fromType: fromType, fromTypeTwoStaffName:fromTypeTwoStaffName),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,109 @@
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
||||
import 'package:get/get.dart';
|
||||
|
||||
import '../../../../../app_settings/app_colors.dart';
|
||||
import '../../../../../tools/CustomUnderlineTabIndicator.dart';
|
||||
import '../../../../../translations/trans_lib.dart';
|
||||
import '../addCardType_page.dart';
|
||||
|
||||
class AddCardManageTabbar extends StatefulWidget {
|
||||
var initialIndex = 1;
|
||||
var lockId = 0;
|
||||
var fromType = 0; // 1从添加钥匙列表进入 2从考勤添加员工入口进入
|
||||
var fromTypeTwoStaffName = "";// 从添加员工进入 传入员工名字
|
||||
|
||||
AddCardManageTabbar(
|
||||
{Key? key, required this.initialIndex, required this.lockId, required this.fromType, required this.fromTypeTwoStaffName})
|
||||
: super(key: key);
|
||||
|
||||
@override
|
||||
State<AddCardManageTabbar> createState() => _AddCardManageTabbarState();
|
||||
}
|
||||
|
||||
class _AddCardManageTabbarState extends State<AddCardManageTabbar> with SingleTickerProviderStateMixin {
|
||||
late TabController _tabController;
|
||||
|
||||
final List<ItemView> _itemTabs = <ItemView>[
|
||||
ItemView(title: TranslationLoader.lanKeys!.permanent!.tr, seletType: "0"),
|
||||
ItemView(title: TranslationLoader.lanKeys!.timeLimit!.tr, seletType: "1"),
|
||||
ItemView(title: TranslationLoader.lanKeys!.circulation!.tr, seletType: "2"),
|
||||
];
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
// TODO: implement initState
|
||||
super.initState();
|
||||
|
||||
_tabController = TabController(
|
||||
vsync: this,
|
||||
length: _itemTabs.length,
|
||||
initialIndex: widget.initialIndex);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Expanded(
|
||||
child: Column(
|
||||
children: [
|
||||
_tabBar(),
|
||||
_pageWidget(),
|
||||
],
|
||||
));
|
||||
}
|
||||
|
||||
TabBar _tabBar() {
|
||||
return TabBar(
|
||||
controller: _tabController,
|
||||
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(
|
||||
child: SizedBox(
|
||||
width: 1.sw / 5,
|
||||
child: Text(item.title, textAlign: TextAlign.center)));
|
||||
}
|
||||
|
||||
Widget _pageWidget() {
|
||||
return Expanded(
|
||||
child: TabBarView(
|
||||
controller: _tabController,
|
||||
children: _itemTabs
|
||||
.map((ItemView item) => AddCardPage(
|
||||
seletType: item.seletType,
|
||||
lockId: widget.lockId,
|
||||
fromType: widget.fromType,
|
||||
fromTypeTwoStaffName:widget.fromTypeTwoStaffName
|
||||
))
|
||||
.toList(),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class ItemView {
|
||||
const ItemView({required this.title, required this.seletType});
|
||||
|
||||
final String title;
|
||||
final String seletType;
|
||||
}
|
||||
@ -0,0 +1,95 @@
|
||||
|
||||
import 'dart:math';
|
||||
|
||||
import 'package:get/get.dart';
|
||||
import 'package:star_lock/tools/baseGetXController.dart';
|
||||
|
||||
import '../../../../appRouters.dart';
|
||||
import '../../../../tools/toast.dart';
|
||||
import 'addCardType_state.dart';
|
||||
|
||||
class AddCardTypeLogic extends BaseGetXController{
|
||||
AddCardTypeState state = AddCardTypeState();
|
||||
|
||||
// 添加卡数据
|
||||
void addCardData() async {
|
||||
var fingerprintType = 0; // 永久:1;限时2,单次3,循环:4
|
||||
var startDate = "";
|
||||
var endDate = "";
|
||||
if (state.seletType.value == "0") {
|
||||
fingerprintType = 1;
|
||||
} else if (state.seletType.value == "1") {
|
||||
fingerprintType = 2;
|
||||
if (state.beginTimeTimestamp.value.isEmpty) {
|
||||
Toast.show(msg: "请选择开始时间");
|
||||
return;
|
||||
}
|
||||
if (state.endTimeTimestamp.value.isEmpty) {
|
||||
Toast.show(msg: "请选择开始时间");
|
||||
return;
|
||||
}
|
||||
|
||||
// if(DateTime.now().millisecondsSinceEpoch > int.parse(state.beginTimeTimestamp.value)){
|
||||
// Toast.show(msg: "生效时间要大于当前时间");
|
||||
// return;
|
||||
// }
|
||||
|
||||
if (int.parse(state.beginTimeTimestamp.value) >=
|
||||
int.parse(state.endTimeTimestamp.value)) {
|
||||
Toast.show(msg: "失效时间要大于生效时间");
|
||||
return;
|
||||
}
|
||||
|
||||
startDate = state.beginTimeTimestamp.value;
|
||||
endDate = state.endTimeTimestamp.value;
|
||||
} else if (state.seletType.value == "2") {
|
||||
if (state.effectiveDateTime.value <= 0) {
|
||||
Toast.show(msg: "请选择生效时间");
|
||||
return;
|
||||
}
|
||||
if (state.failureDateTime.value <= 0) {
|
||||
Toast.show(msg: "请选择失效时间");
|
||||
return;
|
||||
}
|
||||
|
||||
if (state.weekdaysList.value.isEmpty) {
|
||||
Toast.show(msg: "请选择有效日");
|
||||
return;
|
||||
}
|
||||
|
||||
// if(DateTime.now().millisecondsSinceEpoch >= state.effectiveDateTime.value){
|
||||
// Toast.show(msg: "生效时间要大于当前时间");
|
||||
// return;
|
||||
// }
|
||||
|
||||
if (state.effectiveDateTime.value >= state.failureDateTime.value) {
|
||||
Toast.show(msg: "失效时间要大于生效时间");
|
||||
return;
|
||||
}
|
||||
startDate = state.effectiveDateTime.value.toString();
|
||||
endDate = state.failureDateTime.value.toString();
|
||||
fingerprintType = 4;
|
||||
}
|
||||
|
||||
print("addOtherType startDate:$startDate endDate:$endDate");
|
||||
Get.toNamed(Routers.addICCardPage, arguments: {
|
||||
"lockId": state.lockId.value,
|
||||
"endDate": endDate,
|
||||
"addType": "1",
|
||||
"cardName": state.nameController.text,
|
||||
"cardNumber": (Random().nextInt(100000000) + 10000000).floor().toString(),
|
||||
"cardType": fingerprintType.toString(),
|
||||
"isCoerced": state.isStressFingerprint.value ? "1" : "2",
|
||||
"startDate": startDate,
|
||||
"weekDay": state.weekdaysList.value,
|
||||
"fromType": state.fromType.value,
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
void onInit() {
|
||||
super.onInit();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@ -0,0 +1,326 @@
|
||||
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_pickers/pickers.dart';
|
||||
import 'package:flutter_pickers/time_picker/model/date_mode.dart';
|
||||
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
||||
import 'package:get/get.dart';
|
||||
|
||||
import '../../../../appRouters.dart';
|
||||
import '../../../../app_settings/app_colors.dart';
|
||||
import '../../../../tools/commonItem.dart';
|
||||
import '../../../../tools/storage.dart';
|
||||
import '../../../../tools/submitBtn.dart';
|
||||
import '../../../../tools/toast.dart';
|
||||
import '../../../../translations/trans_lib.dart';
|
||||
import 'addCardType_logic.dart';
|
||||
|
||||
class AddCardPage extends StatefulWidget {
|
||||
final String seletType;// 永久限时循环下标
|
||||
final int lockId;
|
||||
final int fromType;// // 1从添加钥匙列表进入 2从考勤添加员工入口进入
|
||||
final String fromTypeTwoStaffName;// 从添加员工进入 传入员工名字
|
||||
|
||||
const AddCardPage(
|
||||
{Key? key, required this.seletType, required this.lockId, required this.fromType, required this.fromTypeTwoStaffName}) : super(key: key);
|
||||
|
||||
@override
|
||||
State<AddCardPage> createState() => _AddCardPageState();
|
||||
}
|
||||
|
||||
class _AddCardPageState extends State<AddCardPage> {
|
||||
final logic = Get.put(AddCardTypeLogic());
|
||||
final state = Get.find<AddCardTypeLogic>().state;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
state.seletType.value = widget.seletType;
|
||||
state.lockId.value = widget.lockId;
|
||||
// state.nameController.text = widget.fromTypeTwoStaffName;
|
||||
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
// Your code here
|
||||
});
|
||||
return indexChangeWidget();
|
||||
}
|
||||
|
||||
Widget indexChangeWidget() {
|
||||
switch (int.parse(widget.seletType)) {
|
||||
case 0:
|
||||
{
|
||||
// 永久
|
||||
// return sendElectronicKeySucceed();
|
||||
return Column(
|
||||
children: [
|
||||
perpetualKeyWidget(TranslationLoader.lanKeys!.name!.tr,
|
||||
TranslationLoader.lanKeys!.pleaseEnter!.tr, state.nameController),
|
||||
keyBottomWidget()
|
||||
],
|
||||
);
|
||||
}
|
||||
case 1:
|
||||
{
|
||||
// 限时
|
||||
return Column(
|
||||
children: [
|
||||
perpetualKeyWidget(TranslationLoader.lanKeys!.name!.tr,
|
||||
TranslationLoader.lanKeys!.pleaseEnter!.tr, state.nameController),
|
||||
keyTimeLimitWidget(),
|
||||
SizedBox(height: 10.h),
|
||||
keyBottomWidget()
|
||||
],
|
||||
);
|
||||
}
|
||||
case 2:
|
||||
{
|
||||
// 循环
|
||||
return Column(
|
||||
children: [
|
||||
perpetualKeyWidget(TranslationLoader.lanKeys!.name!.tr,
|
||||
TranslationLoader.lanKeys!.pleaseEnter!.tr, state.nameController),
|
||||
CommonItem(
|
||||
leftTitel: TranslationLoader.lanKeys!.periodValidity!.tr,
|
||||
rightTitle: "",
|
||||
isHaveDirection: true,
|
||||
action: () async {
|
||||
Map result = await Get.toNamed(Routers.electronicKeyPeriodValidityPage);
|
||||
state.weekdaysList.value = result['validityValue'];
|
||||
state.effectiveDateTime.value = result['starDate'].millisecondsSinceEpoch;
|
||||
state.failureDateTime.value = result['endDate'].millisecondsSinceEpoch;
|
||||
print('得到的有效期数据:${state.weekdaysList.value} == ${state.effectiveDateTime.value} == ${state.failureDateTime.value}');
|
||||
}),
|
||||
SizedBox(height: 10.h),
|
||||
keyBottomWidget()
|
||||
],
|
||||
);
|
||||
}
|
||||
default:
|
||||
return Container();
|
||||
}
|
||||
}
|
||||
|
||||
// 密码命名输入框
|
||||
Widget perpetualKeyWidget(
|
||||
String titleStr, String rightTitle, TextEditingController controller) {
|
||||
return Column(
|
||||
children: [
|
||||
Container(height: 10.h),
|
||||
CommonItem(
|
||||
leftTitel: titleStr,
|
||||
rightTitle: "",
|
||||
isHaveRightWidget: true,
|
||||
rightWidget: getTFWidget(rightTitle)),
|
||||
Container(height: 10.h),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
// 限时顶部选择日期
|
||||
Widget keyTimeLimitWidget() {
|
||||
return Column(
|
||||
children: [
|
||||
Obx(() => CommonItem(
|
||||
leftTitel: TranslationLoader.lanKeys!.effectiveTime!.tr,
|
||||
rightTitle: state.beginTime.value,
|
||||
isHaveLine: true,
|
||||
isHaveDirection: true,
|
||||
action: () async {
|
||||
Pickers.showDatePicker(context, mode: DateMode.YMDHM,
|
||||
onConfirm: (p) {
|
||||
setState(() {
|
||||
setState(() {
|
||||
state.beginTime.value = '${p.year}-${p.month!.toString().padLeft(2,'0')}-${p.day!.toString().padLeft(2,'0')} ${p.hour!.toString().padLeft(2,'0')}:${p.minute!.toString().padLeft(2,'0')}';
|
||||
state.beginTimeTimestamp.value = DateTime.parse(state.beginTime.value).millisecondsSinceEpoch.toString();
|
||||
});
|
||||
});
|
||||
});
|
||||
})),
|
||||
Obx(() => CommonItem(
|
||||
leftTitel: TranslationLoader.lanKeys!.failureTime!.tr,
|
||||
rightTitle: state.endTime.value,
|
||||
isHaveDirection: true,
|
||||
action: () {
|
||||
Pickers.showDatePicker(context, mode: DateMode.YMDHM,
|
||||
onConfirm: (p) {
|
||||
setState(() {
|
||||
setState(() {
|
||||
state.endTime.value = '${p.year}-${p.month!.toString().padLeft(2,'0')}-${p.day!.toString().padLeft(2,'0')} ${p.hour!.toString().padLeft(2,'0')}:${p.minute!.toString().padLeft(2,'0')}';
|
||||
state.endTimeTimestamp.value = DateTime.parse(state.endTime.value).millisecondsSinceEpoch.toString();
|
||||
});
|
||||
});
|
||||
});
|
||||
})),
|
||||
Container(height: 10.h),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
Widget keyBottomWidget() {
|
||||
return Column(
|
||||
children: [
|
||||
CommonItem(
|
||||
leftTitel: TranslationLoader.lanKeys!.stressCard!.tr,
|
||||
rightTitle: "",
|
||||
isTipsImg: false,
|
||||
isHaveRightWidget: true,
|
||||
rightWidget: SizedBox(
|
||||
width: 60.w, height: 50.h, child: _isStressFingerprint())),
|
||||
SizedBox(height: 30.h),
|
||||
SubmitBtn(btnName: TranslationLoader.lanKeys!.next!.tr, onClick: () async {
|
||||
|
||||
var isDemoMode = await Storage.getBool(ifIsDemoModeOrNot);
|
||||
if(isDemoMode == false){
|
||||
// print("state.seletType:${state.seletType.value}");
|
||||
if(state.nameController.text.isEmpty){
|
||||
Toast.show(msg: "请输入姓名");
|
||||
return;
|
||||
}
|
||||
|
||||
logic.addCardData();
|
||||
}else{
|
||||
// Get.toNamed(Routers.seletLockTypePage);
|
||||
Toast.show(msg: "演示模式");
|
||||
}
|
||||
|
||||
}),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
// 发送电子钥匙成功
|
||||
Widget sendElectronicKeySucceed() {
|
||||
return Column(
|
||||
children: [
|
||||
Container(
|
||||
height: 300.h,
|
||||
width: 1.sw,
|
||||
color: Colors.white,
|
||||
child: Column(
|
||||
children: [
|
||||
SizedBox(
|
||||
height: 30.h,
|
||||
),
|
||||
Image.asset(
|
||||
'images/main/icon_main_addLock.png',
|
||||
width: 150.w,
|
||||
height: 150.w,
|
||||
color: AppColors.mainColor,
|
||||
),
|
||||
SizedBox(
|
||||
height: 20.h,
|
||||
),
|
||||
Text(
|
||||
"操作成功,密码为",
|
||||
style: TextStyle(
|
||||
fontSize: 32.sp,
|
||||
color: Colors.black,
|
||||
fontWeight: FontWeight.w500),
|
||||
),
|
||||
SizedBox(
|
||||
height: 10.h,
|
||||
),
|
||||
Text(
|
||||
"62689876",
|
||||
style: TextStyle(
|
||||
fontSize: 60.sp,
|
||||
color: Colors.black,
|
||||
fontWeight: FontWeight.w500),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
SizedBox(
|
||||
height: 20.h,
|
||||
),
|
||||
SubmitBtn(
|
||||
btnName: '完成',
|
||||
fontSize: 28.sp,
|
||||
borderRadius: 20.w,
|
||||
margin: EdgeInsets.only(left: 30.w, right: 30.w, top: 30.w),
|
||||
padding: EdgeInsets.only(top: 25.w, bottom: 25.w),
|
||||
onClick: () {}),
|
||||
SubmitBtn(
|
||||
btnName: '分享',
|
||||
fontSize: 28.sp,
|
||||
borderRadius: 20.w,
|
||||
margin: EdgeInsets.only(left: 30.w, right: 30.w, top: 30.w),
|
||||
padding: EdgeInsets.only(top: 25.w, bottom: 25.w),
|
||||
onClick: () {}),
|
||||
SubmitBtn(
|
||||
btnName: '标记为:已入住',
|
||||
fontSize: 28.sp,
|
||||
borderRadius: 20.w,
|
||||
margin: EdgeInsets.only(left: 30.w, right: 30.w, top: 30.w),
|
||||
padding: EdgeInsets.only(top: 25.w, bottom: 25.w),
|
||||
onClick: () {}),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
String getAppBarTitle(int type) {
|
||||
String title;
|
||||
switch (type) {
|
||||
case 0:
|
||||
title = TranslationLoader.lanKeys!.stressCard!.tr;
|
||||
break;
|
||||
case 1:
|
||||
title = TranslationLoader.lanKeys!.stressFingerprint!.tr;
|
||||
break;
|
||||
case 2:
|
||||
title = TranslationLoader.lanKeys!.remoteControl!.tr;
|
||||
break;
|
||||
default:
|
||||
title = "";
|
||||
break;
|
||||
}
|
||||
return title;
|
||||
}
|
||||
|
||||
// 接受者信息输入框
|
||||
Widget getTFWidget(String tfStr) {
|
||||
return Container(
|
||||
height: 50.h,
|
||||
width: 300.w,
|
||||
child: Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: TextField(
|
||||
//输入框一行
|
||||
maxLines: 1,
|
||||
controller: state.nameController,
|
||||
autofocus: false,
|
||||
textAlign: TextAlign.end,
|
||||
decoration: InputDecoration(
|
||||
//输入里面输入文字内边距设置
|
||||
contentPadding: const EdgeInsets.only(top: 12.0, bottom: 8.0),
|
||||
hintText: tfStr,
|
||||
hintStyle: TextStyle(fontSize: 24.sp),
|
||||
//不需要输入框下划线
|
||||
border: InputBorder.none,
|
||||
),
|
||||
),
|
||||
),
|
||||
SizedBox(
|
||||
width: 10.w,
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
//isStressFingerprint false:不是胁迫指纹 ture:胁迫指纹
|
||||
CupertinoSwitch _isStressFingerprint() {
|
||||
return CupertinoSwitch(
|
||||
activeColor: CupertinoColors.activeBlue,
|
||||
trackColor: CupertinoColors.systemGrey5,
|
||||
thumbColor: CupertinoColors.white,
|
||||
value: state.isStressFingerprint.value,
|
||||
onChanged: (value) {
|
||||
setState(() {
|
||||
state.isStressFingerprint.value = value;
|
||||
});
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,27 @@
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
|
||||
class AddCardTypeState{
|
||||
|
||||
final lockId = 0.obs;
|
||||
final seletType = "0".obs;// 0永久 1显示 2循环
|
||||
final fromType = 1.obs; // // 1从添加钥匙列表进入 2从考勤添加员工入口进入
|
||||
final isStressFingerprint = false.obs;
|
||||
|
||||
var beginTime = "".obs;// 开始时间
|
||||
var endTime = "".obs;// 结束时间
|
||||
var beginTimeTimestamp = "".obs;// 开始时间时间戳
|
||||
var endTimeTimestamp = "".obs;// 结束时间时间戳
|
||||
|
||||
var effectiveDateTime = 0.obs;// 生效时间
|
||||
var failureDateTime = 0.obs;// 失效时间
|
||||
var weekdaysList = [].obs;
|
||||
|
||||
final TextEditingController nameController = TextEditingController();
|
||||
AddCardState() {
|
||||
// Map map = Get.arguments;
|
||||
// lockId.value = map["lockId"];
|
||||
// fromType.value = map["fromType"];
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,43 @@
|
||||
class AddICCardEntity {
|
||||
int? errorCode;
|
||||
String? description;
|
||||
String? errorMsg;
|
||||
Data? data;
|
||||
|
||||
AddICCardEntity(
|
||||
{this.errorCode, this.description, this.errorMsg, this.data});
|
||||
|
||||
AddICCardEntity.fromJson(Map<String, dynamic> json) {
|
||||
errorCode = json['errorCode'];
|
||||
description = json['description'];
|
||||
errorMsg = json['errorMsg'];
|
||||
data = json['data'] != null ? Data.fromJson(json['data']) : null;
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final Map<String, dynamic> data = <String, dynamic>{};
|
||||
data['errorCode'] = errorCode;
|
||||
data['description'] = description;
|
||||
data['errorMsg'] = errorMsg;
|
||||
if (this.data != null) {
|
||||
data['data'] = this.data!.toJson();
|
||||
}
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
||||
class Data {
|
||||
int? cardId;
|
||||
|
||||
Data({this.cardId});
|
||||
|
||||
Data.fromJson(Map<String, dynamic> json) {
|
||||
cardId = json['cardId'];
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final Map<String, dynamic> data = <String, dynamic>{};
|
||||
data['cardId'] = cardId;
|
||||
return data;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,311 @@
|
||||
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:flutter_reactive_ble/flutter_reactive_ble.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:star_lock/blue/io_type.dart';
|
||||
import 'package:star_lock/tools/baseGetXController.dart';
|
||||
|
||||
import '../../../../blue/blue_manage.dart';
|
||||
import '../../../../blue/io_protocol/io_addICCard.dart';
|
||||
import '../../../../blue/io_protocol/io_addStressICCard.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/eventBusEventManage.dart';
|
||||
import '../../../../tools/storage.dart';
|
||||
import '../../../../tools/toast.dart';
|
||||
import 'addICCard_state.dart';
|
||||
|
||||
class AddICCardLogic extends BaseGetXController{
|
||||
AddICCardState state = AddICCardState();
|
||||
|
||||
// 监听设备返回的数据
|
||||
late StreamSubscription<Reply> _replySubscription;
|
||||
void _initReplySubscription() {
|
||||
_replySubscription = EventBusManager().eventBus!.on<Reply>().listen((reply) async {
|
||||
// 添加IC卡开始
|
||||
if(reply is SenderAddICCardReply) {
|
||||
_replyAddICCardBegin(reply);
|
||||
}
|
||||
|
||||
// 添加卡确认
|
||||
if(reply is SenderAddICCardConfirmationReply) {
|
||||
_replyAddICCardConfirmation(reply);
|
||||
}
|
||||
|
||||
// 添加胁迫卡
|
||||
if(reply is SenderAddStressICCardReply) {
|
||||
_replyAddICStressCard(reply);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
Future<void> _replyAddICCardBegin(Reply reply) async {
|
||||
var token = reply.data.sublist(2, 6);
|
||||
var saveStrList = changeIntListToStringList(token);
|
||||
print("_replyAddFingerprintReplyToken:$token");
|
||||
Storage.setStringList(saveBlueToken, saveStrList);
|
||||
|
||||
int status = reply.data[2];
|
||||
print("_replyAddFingerprintStatus:$status");
|
||||
|
||||
switch(status){
|
||||
case 0x00:
|
||||
//成功
|
||||
print("${reply.commandType!.typeValue} 数据解析成功");
|
||||
// state.cardNumber.value = reply.data.last.toString();
|
||||
state.ifConnectScuess.value = true;
|
||||
break;
|
||||
case 0x06:
|
||||
//无权限
|
||||
print("${reply.commandType!.typeValue} 需要鉴权");
|
||||
var privateKey = await Storage.getStringList(saveBluePrivateKey);
|
||||
List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
|
||||
|
||||
var publicKey = await Storage.getStringList(saveBluePublicKey);
|
||||
List<int> publicKeyDataList = changeStringListToIntList(publicKey!);
|
||||
|
||||
IoSenderManage.senderAddFingerprintCommand(
|
||||
keyID:"1",
|
||||
userID:await Storage.getUid(),
|
||||
fingerNo:1,
|
||||
useCountLimit:0xff,
|
||||
startTime:0x11223344,
|
||||
endTime:0x11223344,
|
||||
needAuthor:1,
|
||||
publicKey:publicKeyDataList,
|
||||
privateKey:getPrivateKeyList,
|
||||
token: token,
|
||||
);
|
||||
break;
|
||||
case 0x07:
|
||||
//无权限
|
||||
print("${reply.commandType!.typeValue} 用户无权限");
|
||||
|
||||
break;
|
||||
case 0x09:
|
||||
// 权限校验错误
|
||||
print("${reply.commandType!.typeValue} 权限校验错误");
|
||||
|
||||
break;
|
||||
default:
|
||||
//失败
|
||||
print("${reply.commandType!.typeValue} 失败");
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> _replyAddICCardConfirmation(Reply reply) async {
|
||||
var token = reply.data.sublist(2, 6);
|
||||
// var saveStrList = changeIntListToStringList(token);
|
||||
// print("_replyAddICCardConfirmationReplyToken:$token");
|
||||
// Storage.setStringList(saveBlueToken, saveStrList);
|
||||
|
||||
int status = reply.data[2];
|
||||
print("_replyAddFingerprintstatus:$status");
|
||||
|
||||
switch(status){
|
||||
case 0x00:
|
||||
//成功
|
||||
print("${reply.commandType!.typeValue} 数据解析成功");
|
||||
// print("添加指纹确认成功,调用添加指纹接口");
|
||||
if(state.isCoerced.value == "2"){
|
||||
// 非胁迫指纹
|
||||
int addResultStatus = reply.data[5];
|
||||
if(addResultStatus == 0){
|
||||
// 成功更新序列号
|
||||
state.cardNumber.value = (reply.data[6]+1).toString();
|
||||
addICCardData();
|
||||
}else if(addResultStatus == 255){
|
||||
// 255 自动退出
|
||||
Get.close(2);
|
||||
}
|
||||
}else{
|
||||
// 如果是胁迫指纹在 添加完之后以后再调用添加胁迫指纹的
|
||||
senderAddStressICCard();
|
||||
}
|
||||
break;
|
||||
case 0x06:
|
||||
//无权限
|
||||
|
||||
break;
|
||||
case 0x07:
|
||||
//无权限
|
||||
print("${reply.commandType!.typeValue} 用户无权限");
|
||||
|
||||
break;
|
||||
case 0x09:
|
||||
// 权限校验错误
|
||||
print("${reply.commandType!.typeValue} 权限校验错误");
|
||||
|
||||
break;
|
||||
default:
|
||||
//失败
|
||||
print("${reply.commandType!.typeValue} 失败");
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> _replyAddICStressCard(Reply reply) async {
|
||||
var token = reply.data.sublist(2, 6);
|
||||
var saveStrList = changeIntListToStringList(token);
|
||||
print("_replyAddICCardConfirmationReplyToken:$token");
|
||||
Storage.setStringList(saveBlueToken, saveStrList);
|
||||
|
||||
int status = reply.data[2];
|
||||
print("_replyAddFingerprintstatus:$status");
|
||||
|
||||
switch(status){
|
||||
case 0x00:
|
||||
//成功
|
||||
print("${reply.commandType!.typeValue} 数据解析成功");
|
||||
// print("添加指纹确认成功,调用添加指纹接口");
|
||||
addICCardData();
|
||||
break;
|
||||
case 0x06:
|
||||
//无权限
|
||||
|
||||
break;
|
||||
case 0x07:
|
||||
//无权限
|
||||
print("${reply.commandType!.typeValue} 用户无权限");
|
||||
|
||||
break;
|
||||
case 0x09:
|
||||
// 权限校验错误
|
||||
print("${reply.commandType!.typeValue} 权限校验错误");
|
||||
|
||||
break;
|
||||
default:
|
||||
//失败
|
||||
print("${reply.commandType!.typeValue} 失败");
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// 添加卡片开始
|
||||
Future<void> senderAddICCard() async {
|
||||
BlueManage().judgeReconnect(BlueManage().connectDeviceMacAddress, BlueManage().connectDeviceName, (DeviceConnectionState state) async {
|
||||
if (state == DeviceConnectionState.connected){
|
||||
var publicKey = await Storage.getStringList(saveBluePublicKey);
|
||||
List<int> publicKeyDataList = changeStringListToIntList(publicKey!);
|
||||
|
||||
var privateKey = await Storage.getStringList(saveBluePrivateKey);
|
||||
List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
|
||||
|
||||
var token = await Storage.getStringList(saveBlueToken);
|
||||
List<int> getTokenList = changeStringListToIntList(token!);
|
||||
print("openDoorTokenPubToken:$getTokenList");
|
||||
|
||||
IoSenderManage.senderAddICCardCommand(
|
||||
keyID:"1",
|
||||
userID:await Storage.getUid(),
|
||||
cardNo:1,
|
||||
useCountLimit:0xff,
|
||||
startTime:0x11223344,
|
||||
endTime:0x11223344,
|
||||
needAuthor:1,
|
||||
publicKey:publicKeyDataList,
|
||||
privateKey:getPrivateKeyList,
|
||||
token: getTokenList,
|
||||
);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// 添加胁迫卡片
|
||||
Future<void> senderAddStressICCard() async {
|
||||
BlueManage().judgeReconnect(BlueManage().connectDeviceMacAddress, BlueManage().connectDeviceName, (DeviceConnectionState state) async {
|
||||
if (state == DeviceConnectionState.connected){
|
||||
var publicKey = await Storage.getStringList(saveBluePublicKey);
|
||||
List<int> publicKeyDataList = changeStringListToIntList(publicKey!);
|
||||
|
||||
var privateKey = await Storage.getStringList(saveBluePrivateKey);
|
||||
List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
|
||||
|
||||
var token = await Storage.getStringList(saveBlueToken);
|
||||
List<int> getTokenList = changeStringListToIntList(token!);
|
||||
print("openDoorTokenPubToken:$getTokenList");
|
||||
|
||||
IoSenderManage.senderAddStressICCardCommand(
|
||||
keyID:"1",
|
||||
userID:await Storage.getUid(),
|
||||
icCardNo:1,
|
||||
useCountLimit:1,
|
||||
startTime:0x11223344,
|
||||
endTime:0x11223344,
|
||||
needAuthor:1,
|
||||
publicKey:publicKeyDataList,
|
||||
privateKey:getPrivateKeyList,
|
||||
token: getTokenList,
|
||||
);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
void addICCardData() async {
|
||||
var entity = await ApiRepository.to.addICCardData(
|
||||
lockId: state.lockId.value.toString(),
|
||||
endDate: state.endDate.value.toString(),
|
||||
cardName: state.cardName.value.toString(),
|
||||
cardNumber: state.cardNumber.value.toString(),
|
||||
cardType: state.cardType.value.toString(),
|
||||
addType: state.addType.value.toString(),
|
||||
startDate: state.startDate.value.toString(),
|
||||
isCoerced: state.isCoerced.value.toString(),
|
||||
weekDay: state.weekDay.value,
|
||||
);
|
||||
if (entity.errorCode!.codeIsSuccessful) {
|
||||
Toast.show(msg: "添加成功");
|
||||
updateIdCardUserNoLoadData(entity.data!.cardId.toString());
|
||||
}
|
||||
}
|
||||
|
||||
void updateIdCardUserNoLoadData(String cardId) async{
|
||||
var entity = await ApiRepository.to.updateIdCardUserNoLoadData(
|
||||
lockId: state.lockId.value.toString(),
|
||||
cardId: cardId,
|
||||
cardUserNo: state.cardNumber.value,
|
||||
);
|
||||
if(entity.errorCode!.codeIsSuccessful){
|
||||
Toast.show(msg: "添加成功");
|
||||
if(state.fromType.value == 2){
|
||||
// 回调指纹号
|
||||
eventBus.fire(ChickInAddStaffCardAndFingerprintBlockNumberEvent(cardId));
|
||||
}else if(state.fromType.value == 1){
|
||||
eventBus.fire(OtherTypeRefreshListEvent());
|
||||
}
|
||||
Get.close(2);
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
void onReady() {
|
||||
// TODO: implement onReady
|
||||
super.onReady();
|
||||
|
||||
_initReplySubscription();
|
||||
}
|
||||
|
||||
@override
|
||||
void onInit() {
|
||||
// TODO: implement onInit
|
||||
super.onInit();
|
||||
|
||||
senderAddICCard();
|
||||
}
|
||||
|
||||
@override
|
||||
void onClose() {
|
||||
// TODO: implement onClose
|
||||
_replySubscription.cancel();
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,56 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
||||
import 'package:get/get.dart';
|
||||
|
||||
import '../../../../app_settings/app_colors.dart';
|
||||
import '../../../../tools/titleAppBar.dart';
|
||||
import '../../../../translations/trans_lib.dart';
|
||||
import 'addICCard_logic.dart';
|
||||
|
||||
class AddICCardPage extends StatefulWidget {
|
||||
const AddICCardPage({Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
State<AddICCardPage> createState() => _AddICCardPageState();
|
||||
}
|
||||
|
||||
class _AddICCardPageState extends State<AddICCardPage> {
|
||||
final logic = Get.put(AddICCardLogic());
|
||||
final state = Get.find<AddICCardLogic>().state;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
backgroundColor: AppColors.mainBackgroundColor,
|
||||
appBar: TitleAppBar(
|
||||
barTitle: "${TranslationLoader.lanKeys!.add!.tr}${TranslationLoader.lanKeys!.card!.tr}",
|
||||
haveBack: true,
|
||||
backgroundColor: AppColors.mainColor,
|
||||
),
|
||||
body: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
// mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
SizedBox(height: 420.h),
|
||||
CupertinoActivityIndicator(radius: 25.h,),
|
||||
SizedBox(height: 120.h),
|
||||
Container(
|
||||
width: 1.sw,
|
||||
height: 50.h,
|
||||
// padding: EdgeInsets.only(left: 30.w, right: 30.w, top: 10.h, bottom: 10.h),
|
||||
margin: EdgeInsets.only(left: 15.w, right: 15.w, top: 10.h, bottom: 10.h),
|
||||
// color: AppColors.blackColor,
|
||||
decoration: BoxDecoration(
|
||||
color: AppColors.blackColor,
|
||||
borderRadius: BorderRadius.circular(10.w),
|
||||
),
|
||||
child: Center(
|
||||
child: Obx(() => Text(state.ifConnectScuess.value ? "已连接到锁,请将卡靠近锁的读卡区" : "尝试连接设备...", style:TextStyle(color: Colors.white, fontSize: 24.sp)))
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,32 @@
|
||||
|
||||
import 'package:get/get.dart';
|
||||
|
||||
class AddICCardState{
|
||||
var ifConnectScuess = false.obs;
|
||||
var addFingerprintProcessNumber = 0.obs;
|
||||
final lockId = 0.obs;
|
||||
final endDate = "".obs;
|
||||
final addType = "".obs;
|
||||
final cardName = "".obs;
|
||||
final cardNumber = "".obs;
|
||||
final cardType = "".obs;
|
||||
final isCoerced = "".obs;
|
||||
final startDate = "".obs;
|
||||
final weekDay = [].obs;
|
||||
final fromType = 0.obs;
|
||||
|
||||
AddICCardState() {
|
||||
Map map = Get.arguments;
|
||||
lockId.value = map["lockId"];
|
||||
endDate.value = map["endDate"];
|
||||
addType.value = map["addType"];
|
||||
cardName.value = map["cardName"];
|
||||
cardNumber.value = map["cardNumber"];
|
||||
cardType.value = map["cardType"];
|
||||
isCoerced.value = map["isCoerced"];
|
||||
startDate.value = map["startDate"];
|
||||
lockId.value = map["lockId"];
|
||||
weekDay.value = map["weekDay"];
|
||||
fromType.value = map["fromType"];
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,175 @@
|
||||
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:flutter_reactive_ble/flutter_reactive_ble.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:star_lock/blue/io_type.dart';
|
||||
import 'package:star_lock/tools/baseGetXController.dart';
|
||||
|
||||
import '../../../../blue/blue_manage.dart';
|
||||
import '../../../../blue/io_protocol/io_addICCard.dart';
|
||||
import '../../../../blue/io_reply.dart';
|
||||
import '../../../../blue/io_tool/io_tool.dart';
|
||||
import '../../../../blue/io_tool/manager_event_bus.dart';
|
||||
import '../../../../blue/sender_manage.dart';
|
||||
import '../../../../network/api_repository.dart';
|
||||
import '../../../../tools/storage.dart';
|
||||
import '../../../../tools/toast.dart';
|
||||
import 'cardDetail_state.dart';
|
||||
|
||||
class CardDetailLogic extends BaseGetXController{
|
||||
CardDetailState state = CardDetailState();
|
||||
|
||||
// 监听设备返回的数据
|
||||
late StreamSubscription<Reply> _replySubscription;
|
||||
void _initReplySubscription() {
|
||||
_replySubscription = EventBusManager().eventBus!.on<Reply>().listen((reply) async {
|
||||
// 添加卡片开始(重置锁里面所有卡)
|
||||
if((reply is SenderAddICCardReply)) {
|
||||
_replyAddICCardBegin(reply);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// 添加卡片开始(此处用作删除卡片)
|
||||
Future<void> _replyAddICCardBegin(Reply reply) async {
|
||||
int status = reply.data[2];
|
||||
print("_replyAddFingerprintStatus:$status");
|
||||
|
||||
switch(status){
|
||||
case 0x00:
|
||||
//成功
|
||||
print("${reply.commandType!.typeValue} 数据解析成功");
|
||||
deletICCardData();
|
||||
break;
|
||||
case 0x06:
|
||||
//无权限
|
||||
print("${reply.commandType!.typeValue} 需要鉴权");
|
||||
var privateKey = await Storage.getStringList(saveBluePrivateKey);
|
||||
List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
|
||||
|
||||
var publicKey = await Storage.getStringList(saveBluePublicKey);
|
||||
List<int> publicKeyDataList = changeStringListToIntList(publicKey!);
|
||||
|
||||
var token = await Storage.getStringList(saveBlueToken);
|
||||
List<int> getTokenList = changeStringListToIntList(token!);
|
||||
|
||||
IoSenderManage.senderAddICCardCommand(
|
||||
keyID:"1",
|
||||
userID:"DeleteAll!@#",
|
||||
cardNo:255,
|
||||
useCountLimit:0,
|
||||
startTime:0x11223344,
|
||||
endTime:0x11223344,
|
||||
needAuthor:1,
|
||||
publicKey:publicKeyDataList,
|
||||
privateKey:getPrivateKeyList,
|
||||
token: getTokenList,
|
||||
);
|
||||
break;
|
||||
case 0x07:
|
||||
//无权限
|
||||
print("${reply.commandType!.typeValue} 用户无权限");
|
||||
|
||||
break;
|
||||
case 0x09:
|
||||
// 权限校验错误
|
||||
print("${reply.commandType!.typeValue} 权限校验错误");
|
||||
|
||||
break;
|
||||
default:
|
||||
//失败
|
||||
print("${reply.commandType!.typeValue} 失败");
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// 删除卡片
|
||||
Future<void> senderAddICCard(String keyId, String userID, int cardNo) async {
|
||||
BlueManage().judgeReconnect(BlueManage().connectDeviceMacAddress, BlueManage().connectDeviceName, (DeviceConnectionState state) async {
|
||||
if (state == DeviceConnectionState.connected){
|
||||
var publicKey = await Storage.getStringList(saveBluePublicKey);
|
||||
List<int> publicKeyDataList = changeStringListToIntList(publicKey!);
|
||||
|
||||
var privateKey = await Storage.getStringList(saveBluePrivateKey);
|
||||
List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
|
||||
|
||||
var token = await Storage.getStringList(saveBlueToken);
|
||||
List<int> getTokenList = changeStringListToIntList(token!);
|
||||
print("openDoorTokenPubToken:$getTokenList");
|
||||
|
||||
IoSenderManage.senderAddICCardCommand(
|
||||
// keyID:"1",
|
||||
// userID:"DeleteAll!@#",
|
||||
// cardNo:255,
|
||||
keyID:keyId,
|
||||
userID:userID,
|
||||
cardNo:cardNo,
|
||||
useCountLimit:0,
|
||||
startTime:0x11223344,
|
||||
endTime:0x11223344,
|
||||
needAuthor:1,
|
||||
publicKey:publicKeyDataList,
|
||||
privateKey:getPrivateKeyList,
|
||||
token: getTokenList,
|
||||
);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// 编辑iC卡
|
||||
void editICCardData() async{
|
||||
var entity = await ApiRepository.to.editICCardData(
|
||||
cardId: state.keyId.value.toString(),
|
||||
lockId: state.fingerprintItemData.value.lockId.toString(),
|
||||
weekDay: state.weekDay.value,
|
||||
startDate: state.effectiveDateTime.value.toString(),
|
||||
endDate: state.failureDateTime.value.toString(),
|
||||
isCoerced: state.isStressFingerprint.value ? "2" : "1",
|
||||
cardName: state.changeNameController.text,
|
||||
);
|
||||
if(entity.errorCode!.codeIsSuccessful){
|
||||
Toast.show(msg: "修改成功");
|
||||
Get.back(result: "addScuess");
|
||||
}
|
||||
}
|
||||
|
||||
// 删除IC卡
|
||||
void deletICCardData() async{
|
||||
var entity = await ApiRepository.to.deletIcCardData(
|
||||
cardId: state.fingerprintItemData.value.cardId.toString(),
|
||||
lockId: state.fingerprintItemData.value.lockId.toString(),
|
||||
type: "0",
|
||||
deleteType:"1"
|
||||
);
|
||||
if(entity.errorCode!.codeIsSuccessful){
|
||||
Toast.show(msg: "删除成功");
|
||||
Get.back(result: "addScuess");
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
void onReady() {
|
||||
// TODO: implement onReady
|
||||
super.onReady();
|
||||
|
||||
_initReplySubscription();
|
||||
}
|
||||
|
||||
@override
|
||||
void onInit() {
|
||||
// TODO: implement onInit
|
||||
super.onInit();
|
||||
|
||||
}
|
||||
|
||||
@override
|
||||
void onClose() {
|
||||
// TODO: implement onClose
|
||||
super.onClose();
|
||||
|
||||
_replySubscription.cancel();
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,362 @@
|
||||
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
||||
import 'package:get/get.dart';
|
||||
|
||||
import '../../../../appRouters.dart';
|
||||
import '../../../../app_settings/app_colors.dart';
|
||||
import '../../../../tools/commonItem.dart';
|
||||
import '../../../../tools/dateTool.dart';
|
||||
import '../../../../tools/showIosTipView.dart';
|
||||
import '../../../../tools/showTFView.dart';
|
||||
import '../../../../tools/storage.dart';
|
||||
import '../../../../tools/submitBtn.dart';
|
||||
import '../../../../tools/titleAppBar.dart';
|
||||
import '../../../../tools/toast.dart';
|
||||
import '../../../../translations/trans_lib.dart';
|
||||
import 'cardDetail_logic.dart';
|
||||
|
||||
class CardDetailPage extends StatefulWidget {
|
||||
const CardDetailPage({Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
State<CardDetailPage> createState() => _CardDetailPageState();
|
||||
}
|
||||
|
||||
class _CardDetailPageState extends State<CardDetailPage> {
|
||||
final logic = Get.put(CardDetailLogic());
|
||||
final state = Get.find<CardDetailLogic>().state;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
backgroundColor: AppColors.mainBackgroundColor,
|
||||
appBar: TitleAppBar(
|
||||
barTitle: "${TranslationLoader.lanKeys!.card!.tr}${TranslationLoader.lanKeys!.number!.tr}",
|
||||
haveBack: true,
|
||||
backgroundColor: AppColors.mainColor,
|
||||
// actionsList: [
|
||||
// TextButton(
|
||||
// child: Text(TranslationLoader.lanKeys!.share!.tr, style: TextStyle(color: Colors.white, fontSize: 24.sp),),
|
||||
// onPressed: () {
|
||||
//
|
||||
// },
|
||||
// ),
|
||||
// ],
|
||||
),
|
||||
body: Column(
|
||||
children: [
|
||||
Obx(() => CommonItem(
|
||||
leftTitel: "${TranslationLoader.lanKeys!.card!.tr}${TranslationLoader.lanKeys!.number!.tr}",
|
||||
rightTitle: state.typeNumber.value,
|
||||
isHaveDirection: false,
|
||||
isHaveLine: true)),
|
||||
Obx(() => CommonItem(
|
||||
leftTitel: TranslationLoader.lanKeys!.name!.tr,
|
||||
rightTitle: state.typeName.value,
|
||||
isHaveDirection: true,
|
||||
isHaveLine: true,
|
||||
action: () {
|
||||
showCupertinoAlertDialog(context);
|
||||
})),
|
||||
Obx(() => Visibility(
|
||||
visible: (state.keyType.value == 4 || state.keyType.value == 2) ? true : false,
|
||||
child: CommonItem(
|
||||
leftTitel: TranslationLoader.lanKeys!.periodValidity!.tr,
|
||||
allHeight: 70.h,
|
||||
// rightTitle:"2023.09.19 11:27\n2023.09.25 11:27",
|
||||
rightTitle: state.keyType.value == 1 ? "永久" : "${DateTool().dateToYMDHNString(state.effectiveDateTime.value.toString())}\n${DateTool().dateToYMDHNString(state.failureDateTime.value.toString())}",
|
||||
isHaveDirection: true,
|
||||
isHaveLine: true,
|
||||
action: () async {
|
||||
// switch(state.type.value){
|
||||
// case 0:
|
||||
// // 卡
|
||||
//
|
||||
// break;
|
||||
// case 1:
|
||||
// 当是指纹的时候
|
||||
if(state.keyType.value == 2){
|
||||
// 限时
|
||||
var data = await Get.toNamed(Routers.otherTypeKeyChangeDatePage, arguments: {
|
||||
"pushType": state.type.value,
|
||||
"fingerprintItemData": state.fingerprintItemData.value,
|
||||
});
|
||||
if(data != null) {
|
||||
setState(() {
|
||||
state.effectiveDateTime.value = data["beginTimeTimestamp"];
|
||||
state.failureDateTime.value = data["endTimeTimestamp"];
|
||||
});
|
||||
}
|
||||
}else if(state.keyType.value == 4){
|
||||
// 循环
|
||||
var data = await Get.toNamed(Routers.otherTypeKeyChangeValidityDatePage, arguments: {
|
||||
"pushType": state.type.value,
|
||||
"fingerprintItemData": state.fingerprintItemData.value,
|
||||
});
|
||||
if(data != null) {
|
||||
setState(() {
|
||||
state.effectiveDateTime.value = data["beginTimeTimestamp"];
|
||||
state.failureDateTime.value = data["endTimeTimestamp"];
|
||||
state.weekDay.value = data["weekDay"];
|
||||
});
|
||||
}
|
||||
}
|
||||
// break;
|
||||
// case 2:
|
||||
// // 遥控
|
||||
//
|
||||
// break;
|
||||
// }
|
||||
}))),
|
||||
Obx(() => Visibility(
|
||||
visible: state.keyType.value == 4 ? true : false,
|
||||
child: Obx(() => CommonItem(
|
||||
leftTitel: TranslationLoader.lanKeys!.effectiveDay!.tr,
|
||||
rightTitle: state.weekDay.value.join(','),
|
||||
isHaveDirection: true,
|
||||
action: () async {
|
||||
// switch(state.type.value){
|
||||
// case 0:
|
||||
// // 卡
|
||||
//
|
||||
// break;
|
||||
// case 1:
|
||||
// 当是指纹的时候
|
||||
var data = await Get.toNamed(Routers.otherTypeKeyChangeValidityDatePage, arguments: {
|
||||
"pushType": state.type.value,
|
||||
"fingerprintItemData": state.fingerprintItemData.value,
|
||||
});
|
||||
if(data != null) {
|
||||
setState(() {
|
||||
state.effectiveDateTime.value = data["beginTimeTimestamp"];
|
||||
state.failureDateTime.value = data["endTimeTimestamp"];
|
||||
state.weekDay.value = data["weekDay"];
|
||||
});
|
||||
}
|
||||
// break;
|
||||
// case 2:
|
||||
// // 遥控
|
||||
//
|
||||
// break;
|
||||
// }
|
||||
})))
|
||||
),
|
||||
Container(height: 10.h),
|
||||
Obx(() => CommonItem(
|
||||
leftTitel: TranslationLoader.lanKeys!.additive!.tr,
|
||||
rightTitle: state.adder.value,
|
||||
action: () {
|
||||
|
||||
})),
|
||||
Obx(() => CommonItem(
|
||||
leftTitel: TranslationLoader.lanKeys!.addTime!.tr,
|
||||
rightTitle: DateTool().dateToYMDHNString(state.addTime.value.toString()),
|
||||
action: () {
|
||||
|
||||
})),
|
||||
SizedBox(height: 10.h),
|
||||
Obx(() => CommonItem(
|
||||
leftTitel: TranslationLoader.lanKeys!.stressCard!.tr,
|
||||
rightTitle: "",
|
||||
isTipsImg: false,
|
||||
isHaveRightWidget: true,
|
||||
rightWidget: SizedBox(
|
||||
width: 60.w, height: 50.h, child: _isStressFingerprint()))),
|
||||
Container(height: 10.h),
|
||||
CommonItem(
|
||||
leftTitel: TranslationLoader.lanKeys!.operatingRecord!.tr,
|
||||
rightTitle: "",
|
||||
isHaveDirection: true,
|
||||
action: () {
|
||||
switch (state.type.value) {
|
||||
case 0:
|
||||
// 卡
|
||||
Get.toNamed(Routers.keyOperationRecordPage, arguments: {
|
||||
'lockId': state.fingerprintItemData.value.lockId.toString(),
|
||||
'cardId': state.fingerprintItemData.value.cardId.toString()
|
||||
});
|
||||
break;
|
||||
case 1:
|
||||
// 指纹
|
||||
Get.toNamed(Routers.keyOperationRecordPage, arguments: {
|
||||
'lockId': state.fingerprintItemData.value.lockId.toString(),
|
||||
'fingerprintId': state.fingerprintItemData.value.fingerprintId.toString()
|
||||
});
|
||||
break;
|
||||
case 2:
|
||||
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
}),
|
||||
// SizedBox(height: 40.h),
|
||||
// addControlsBtn(type),
|
||||
SizedBox(height: 30.h),
|
||||
SubmitBtn(
|
||||
btnName: TranslationLoader.lanKeys!.delete!.tr,
|
||||
isDelete: true,
|
||||
borderRadius: 20.w,
|
||||
margin: EdgeInsets.only(left: 30.w, right: 30.w, top: 30.w, bottom: 30.w),
|
||||
padding: EdgeInsets.only(top: 25.w, bottom: 25.w),
|
||||
onClick: () {
|
||||
showIosTipViewDialog(context);
|
||||
}),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
//isStressFingerprint false:不是胁迫指纹 ture:胁迫指纹
|
||||
CupertinoSwitch _isStressFingerprint() {
|
||||
return CupertinoSwitch(
|
||||
activeColor: CupertinoColors.activeBlue,
|
||||
trackColor: CupertinoColors.systemGrey5,
|
||||
thumbColor: CupertinoColors.white,
|
||||
value: state.isStressFingerprint.value,
|
||||
onChanged: (value) {
|
||||
setState(() {
|
||||
state.isStressFingerprint.value = value;
|
||||
logic.editICCardData();
|
||||
});
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
// Widget addControlsBtn(int type) {
|
||||
// List<Widget> widgetList = [];
|
||||
// List<Map<String, dynamic>> routerList = [];
|
||||
// //卡详情
|
||||
// if (type == 0) {
|
||||
// routerList.add({
|
||||
// 'btnTitle': '设置密码',
|
||||
// 'routerName': Routers.passwordKeyDetailPage,
|
||||
// 'type': 9
|
||||
// });
|
||||
// routerList.add({
|
||||
// 'btnTitle': '设置指纹',
|
||||
// 'routerName': Routers.otherTypeKeyManagePage,
|
||||
// 'type': 1
|
||||
// });
|
||||
// routerList.add({
|
||||
// 'btnTitle': '设置遥控',
|
||||
// 'routerName': Routers.otherTypeKeyManagePage,
|
||||
// 'type': 2
|
||||
// });
|
||||
// } else if (type == 1) {
|
||||
// //指纹详情
|
||||
// routerList.add({
|
||||
// 'btnTitle': '设置密码',
|
||||
// 'routerName': Routers.passwordKeyDetailPage,
|
||||
// 'type': 9
|
||||
// });
|
||||
// routerList.add({
|
||||
// 'btnTitle': '设置卡',
|
||||
// 'routerName': Routers.otherTypeKeyManagePage,
|
||||
// 'type': 0
|
||||
// });
|
||||
// routerList.add({
|
||||
// 'btnTitle': '设置遥控',
|
||||
// 'routerName': Routers.otherTypeKeyManagePage,
|
||||
// 'type': 2
|
||||
// });
|
||||
// } else if (type == 2) {
|
||||
// //遥控详情
|
||||
// routerList.add({
|
||||
// 'btnTitle': '设置密码',
|
||||
// 'routerName': Routers.passwordKeyDetailPage,
|
||||
// 'type': 9
|
||||
// });
|
||||
// routerList.add({
|
||||
// 'btnTitle': '设置卡',
|
||||
// 'routerName': Routers.otherTypeKeyManagePage,
|
||||
// 'type': 0
|
||||
// });
|
||||
// routerList.add({
|
||||
// 'btnTitle': '设置指纹',
|
||||
// 'routerName': Routers.otherTypeKeyManagePage,
|
||||
// 'type': 1
|
||||
// });
|
||||
// }
|
||||
//
|
||||
// for (int i = 0; i < routerList.length; i++) {
|
||||
// widgetList.add(SizedBox(
|
||||
// width: ScreenUtil().screenWidth - 40.w,
|
||||
// height: 60.h,
|
||||
// child: OutlinedButton(
|
||||
// style: OutlinedButton.styleFrom(
|
||||
// // backgroundColor: Colors.white,
|
||||
// side: BorderSide(width: 1, color: AppColors.mainColor)),
|
||||
// onPressed: () {
|
||||
// if (routerList[i]['type'] == 9) {
|
||||
// Navigator.pushNamed(context, Routers.passwordKeyManagePage);
|
||||
// } else {
|
||||
// Navigator.pushNamed(context, Routers.otherTypeKeyManagePage,
|
||||
// arguments: routerList[i]['type']);
|
||||
// }
|
||||
// },
|
||||
// child: Text(
|
||||
// routerList[i]['btnTitle'],
|
||||
// style: TextStyle(color: AppColors.mainColor, fontSize: 24.sp),
|
||||
// )),
|
||||
// ));
|
||||
//
|
||||
// widgetList.add(
|
||||
// SizedBox(
|
||||
// height: 10.h,
|
||||
// ),
|
||||
// );
|
||||
// }
|
||||
//
|
||||
// return Column(
|
||||
// children: widgetList,
|
||||
// );
|
||||
// }
|
||||
|
||||
|
||||
void showCupertinoAlertDialog(BuildContext context) {
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (BuildContext context) {
|
||||
return ShowTFView(
|
||||
title: "${TranslationLoader.lanKeys!.amend!.tr}${TranslationLoader.lanKeys!.name!.tr}",
|
||||
tipTitle: "",
|
||||
controller: state.changeNameController,
|
||||
sureClick: () {
|
||||
if(state.changeNameController.text.isEmpty){
|
||||
Toast.show(msg: "请输入姓名");
|
||||
return;
|
||||
}
|
||||
Get.back();
|
||||
logic.editICCardData();
|
||||
},
|
||||
cancelClick: () {
|
||||
Get.back();
|
||||
},);
|
||||
});
|
||||
}
|
||||
|
||||
void showIosTipViewDialog(BuildContext context) {
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (BuildContext context) {
|
||||
return ShowIosTipView(
|
||||
title: "提示",
|
||||
tipTitle: "确定要删除吗?",
|
||||
sureClick: () async {
|
||||
Get.back();
|
||||
String? idStr = await Storage.getUid();
|
||||
logic.senderAddICCard(state.fingerprintItemData.value.cardId.toString(), idStr ?? "", 0);
|
||||
},
|
||||
cancelClick: () {
|
||||
Get.back();
|
||||
},
|
||||
);
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,40 @@
|
||||
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
|
||||
import '../../fingerprint/fingerprintList/fingerprintListData_entity.dart';
|
||||
|
||||
class CardDetailState{
|
||||
final fingerprintItemData = FingerprintItemData().obs;
|
||||
final type = 0.obs;// 0卡 1指纹 2遥控
|
||||
|
||||
final TextEditingController changeNameController = TextEditingController();
|
||||
|
||||
final typeNumber = "".obs;// 指纹号
|
||||
final typeName = "".obs;// 指纹名字
|
||||
var effectiveDateTime = 0.obs;// 生效时间
|
||||
var failureDateTime = 0.obs;// 失效时间
|
||||
final keyType = 0.obs;// 永久:1;限时2,单次3,循环:4
|
||||
var weekDay = [].obs;// 有效日
|
||||
var adder = "".obs;// 添加者
|
||||
var addTime = 0.obs;// 添加时间
|
||||
var keyId = 0.obs;// 添加时间
|
||||
|
||||
final isStressFingerprint = false.obs;
|
||||
CardDetailState() {
|
||||
Map map = Get.arguments;
|
||||
fingerprintItemData.value = map["fingerprintItemData"];
|
||||
keyId.value = fingerprintItemData.value.cardId!;
|
||||
typeNumber.value = fingerprintItemData.value.cardNumber!;
|
||||
typeName.value = fingerprintItemData.value.cardName!;
|
||||
changeNameController.text = typeName.value;
|
||||
effectiveDateTime.value = fingerprintItemData.value.startDate!;
|
||||
failureDateTime.value = fingerprintItemData.value.endDate!;
|
||||
keyType.value = fingerprintItemData.value.cardType!;
|
||||
adder.value = fingerprintItemData.value.senderUsername!;
|
||||
addTime.value = fingerprintItemData.value.createDate!;
|
||||
isStressFingerprint.value = fingerprintItemData.value.isCoerced! == 2 ? true : false;
|
||||
weekDay.value = fingerprintItemData.value.weekDay!;
|
||||
}
|
||||
}
|
||||
372
star_lock/lib/main/lockDetail/card/cardList/cardList_logic.dart
Normal file
372
star_lock/lib/main/lockDetail/card/cardList/cardList_logic.dart
Normal file
@ -0,0 +1,372 @@
|
||||
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:flutter_reactive_ble/flutter_reactive_ble.dart';
|
||||
import 'package:star_lock/blue/io_type.dart';
|
||||
import 'package:star_lock/tools/baseGetXController.dart';
|
||||
import '../../../../blue/blue_manage.dart';
|
||||
import '../../../../blue/io_protocol/io_addICCard.dart';
|
||||
import '../../../../blue/io_protocol/io_checkingCardStatus.dart';
|
||||
import '../../../../blue/io_protocol/io_checkingUserInfoCount.dart';
|
||||
import '../../../../blue/io_reply.dart';
|
||||
import '../../../../blue/io_tool/io_tool.dart';
|
||||
import '../../../../blue/io_tool/manager_event_bus.dart';
|
||||
import '../../../../blue/sender_manage.dart';
|
||||
import '../../../../network/api_repository.dart';
|
||||
import '../../../../tools/eventBusEventManage.dart';
|
||||
import '../../../../tools/storage.dart';
|
||||
import '../../../../tools/toast.dart';
|
||||
import 'cardList_state.dart';
|
||||
|
||||
class CardListLogic extends BaseGetXController {
|
||||
CardListState state = CardListState();
|
||||
|
||||
// 获取解析后的数据
|
||||
late StreamSubscription<Reply> _replySubscription;
|
||||
void _initReplySubscription() {
|
||||
_replySubscription = EventBusManager().eventBus!.on<Reply>().listen((reply) {
|
||||
|
||||
// 添加卡片开始(重置锁里面所有卡)
|
||||
if((reply is SenderAddICCardReply) && (state.isDeletICCardData == true)) {
|
||||
_replyAddICCardBegin(reply);
|
||||
}
|
||||
|
||||
if(reply is SenderCheckingCardStatusReply) {
|
||||
_replyReferEventRecordNumber(reply);
|
||||
}
|
||||
|
||||
if(reply is SenderCheckingUserInfoCountReply){
|
||||
_replyCheckingUserInfoCount(reply);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// 添加卡片开始(此处用作删除卡片)
|
||||
Future<void> _replyAddICCardBegin(Reply reply) async {
|
||||
int status = reply.data[2];
|
||||
print("_replyAddFingerprintStatus:$status");
|
||||
|
||||
switch(status){
|
||||
case 0x00:
|
||||
//成功
|
||||
print("${reply.commandType!.typeValue} 数据解析成功");
|
||||
state.isDeletICCardData = false;
|
||||
deletICCardData();
|
||||
break;
|
||||
case 0x06:
|
||||
//无权限
|
||||
print("${reply.commandType!.typeValue} 需要鉴权");
|
||||
var privateKey = await Storage.getStringList(saveBluePrivateKey);
|
||||
List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
|
||||
|
||||
var publicKey = await Storage.getStringList(saveBluePublicKey);
|
||||
List<int> publicKeyDataList = changeStringListToIntList(publicKey!);
|
||||
|
||||
var token = await Storage.getStringList(saveBlueToken);
|
||||
List<int> getTokenList = changeStringListToIntList(token!);
|
||||
|
||||
IoSenderManage.senderAddICCardCommand(
|
||||
keyID:"1",
|
||||
userID:"DeleteAll!@#",
|
||||
cardNo:255,
|
||||
useCountLimit:0,
|
||||
startTime:0x11223344,
|
||||
endTime:0x11223344,
|
||||
needAuthor:1,
|
||||
publicKey:publicKeyDataList,
|
||||
privateKey:getPrivateKeyList,
|
||||
token: getTokenList,
|
||||
);
|
||||
break;
|
||||
case 0x07:
|
||||
//无权限
|
||||
print("${reply.commandType!.typeValue} 用户无权限");
|
||||
|
||||
break;
|
||||
case 0x09:
|
||||
// 权限校验错误
|
||||
print("${reply.commandType!.typeValue} 权限校验错误");
|
||||
|
||||
break;
|
||||
default:
|
||||
//失败
|
||||
print("${reply.commandType!.typeValue} 失败");
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// 获取卡片状态
|
||||
Future<void> _replyReferEventRecordNumber(Reply reply) async {
|
||||
int status = reply.data[2];
|
||||
switch(status){
|
||||
case 0x00:
|
||||
//成功
|
||||
print("${reply.commandType}数据解析成功");
|
||||
// _getLockStatus();
|
||||
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> _replyCheckingUserInfoCount(Reply reply) async {
|
||||
int status = reply.data[2];
|
||||
|
||||
// 用户数量
|
||||
int userNum = reply.data[5];
|
||||
// print("userNum:$userNum");
|
||||
|
||||
// 指纹数量
|
||||
int fingerNum = reply.data[6];
|
||||
// print("fingerNum:$fingerNum");
|
||||
|
||||
// 密码数量
|
||||
int pwdNum = reply.data[7];
|
||||
|
||||
// 卡片数量
|
||||
int cardNum = reply.data[8];
|
||||
|
||||
// 记录数量
|
||||
int logsNum = reply.data[9];
|
||||
|
||||
// 版本
|
||||
int verNo = reply.data[10];
|
||||
|
||||
// 最大管理员指纹数量
|
||||
int maxAdminFingerNum = reply.data[11];
|
||||
|
||||
// 最大用户指纹数量
|
||||
int maxUserFingerNum = reply.data[12];
|
||||
|
||||
// 最大管理员密码数量
|
||||
int maxAdminPassNum = reply.data[13];
|
||||
|
||||
// 最大用户密码数量
|
||||
int maxUserPassNum = reply.data[14];
|
||||
|
||||
// 最大管理员卡片数量
|
||||
int maxAdminCardNum = reply.data[15];
|
||||
|
||||
// 最大用户卡片数量
|
||||
int maxUserCardNum = reply.data[16];
|
||||
|
||||
// 序列号
|
||||
var serialNo = reply.data.sublist(17, 21);
|
||||
print("serialNo:$serialNo");
|
||||
|
||||
switch(status){
|
||||
case 0x00:
|
||||
//成功
|
||||
print("${reply.commandType}数据解析成功");
|
||||
// _getLockStatus();
|
||||
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> senderCheckingCardStatus() async {
|
||||
BlueManage().judgeReconnect(BlueManage().connectDeviceMacAddress, BlueManage().connectDeviceName, (DeviceConnectionState state) async {
|
||||
if (state == DeviceConnectionState.connected) {
|
||||
var privateKey = await Storage.getStringList(saveBluePrivateKey);
|
||||
List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
|
||||
|
||||
var token = await Storage.getStringList(saveBlueToken);
|
||||
List<int> getTokenList = changeStringListToIntList(token!);
|
||||
|
||||
var publicKey = await Storage.getStringList(saveBluePublicKey);
|
||||
List<int> getPublicKeyList = changeStringListToIntList(publicKey!);
|
||||
|
||||
IoSenderManage.senderCheckingCardStatusCommand(
|
||||
keyID:BlueManage().connectDeviceName,
|
||||
userID:await Storage.getUid(),
|
||||
role:0xff,
|
||||
cardCount:20,
|
||||
cardNo:1,
|
||||
token:getTokenList,
|
||||
needAuthor:1,
|
||||
publicKey:getPublicKeyList,
|
||||
privateKey:getPrivateKeyList,
|
||||
);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// 查询用户、指纹、密码、卡片数量(用于判断是否同步)
|
||||
Future<void> senderCheckingUserInfoCount() async {
|
||||
BlueManage().judgeReconnect(BlueManage().connectDeviceMacAddress, BlueManage().connectDeviceName, (DeviceConnectionState state) async {
|
||||
if (state == DeviceConnectionState.connected) {
|
||||
var privateKey = await Storage.getStringList(saveBluePrivateKey);
|
||||
List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
|
||||
|
||||
var token = await Storage.getStringList(saveBlueToken);
|
||||
List<int> getTokenList = changeStringListToIntList(token!);
|
||||
|
||||
var publicKey = await Storage.getStringList(saveBluePublicKey);
|
||||
List<int> getPublicKeyList = changeStringListToIntList(publicKey!);
|
||||
|
||||
IoSenderManage.senderCheckingUserInfoCountCommand(
|
||||
keyID:BlueManage().connectDeviceName,
|
||||
userID:await Storage.getUid(),
|
||||
role:0xff,
|
||||
nowTime:DateTime.now().millisecondsSinceEpoch~/1000,
|
||||
token:getTokenList,
|
||||
needAuthor:1,
|
||||
publicKey:getPublicKeyList,
|
||||
privateKey:getPrivateKeyList,
|
||||
);
|
||||
}
|
||||
}, isShowLoading: false);
|
||||
}
|
||||
|
||||
// 删除卡片
|
||||
Future<void> senderAddICCard(String keyId, String userID, int cardNo) async {
|
||||
BlueManage().judgeReconnect(BlueManage().connectDeviceMacAddress, BlueManage().connectDeviceName, (DeviceConnectionState state) async {
|
||||
if (state == DeviceConnectionState.connected){
|
||||
var publicKey = await Storage.getStringList(saveBluePublicKey);
|
||||
List<int> publicKeyDataList = changeStringListToIntList(publicKey!);
|
||||
|
||||
var privateKey = await Storage.getStringList(saveBluePrivateKey);
|
||||
List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
|
||||
|
||||
var token = await Storage.getStringList(saveBlueToken);
|
||||
List<int> getTokenList = changeStringListToIntList(token!);
|
||||
print("openDoorTokenPubToken:$getTokenList");
|
||||
|
||||
IoSenderManage.senderAddICCardCommand(
|
||||
// keyID:"1",
|
||||
// userID:"DeleteAll!@#",
|
||||
// cardNo:255,
|
||||
keyID:keyId,
|
||||
userID:userID,
|
||||
cardNo:cardNo,
|
||||
useCountLimit:0,
|
||||
startTime:0x11223344,
|
||||
endTime:0x11223344,
|
||||
needAuthor:1,
|
||||
publicKey:publicKeyDataList,
|
||||
privateKey:getPrivateKeyList,
|
||||
token: getTokenList,
|
||||
);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// 获取IC卡列表
|
||||
void getICCardListData() async{
|
||||
var entity = await ApiRepository.to.getICCardListData(
|
||||
lockId: state.lockId.value.toString(),
|
||||
pageNo: '1',
|
||||
pageSize: '20',
|
||||
searchStr: state.searchController.text,
|
||||
);
|
||||
if(entity.errorCode!.codeIsSuccessful){
|
||||
state.fingerprintItemListData.value = entity.data!.list!;
|
||||
}
|
||||
}
|
||||
|
||||
// 删除所有IC卡
|
||||
void deletICCardData() async{
|
||||
var entity = await ApiRepository.to.deletIcCardData(
|
||||
cardId: "",
|
||||
lockId: state.lockId.value.toString(),
|
||||
type: "1",
|
||||
deleteType:"1"
|
||||
);
|
||||
if(entity.errorCode!.codeIsSuccessful){
|
||||
Toast.show(msg: "重置成功");
|
||||
getICCardListData();
|
||||
}
|
||||
}
|
||||
|
||||
// 监听修改完详情之后刷新列表
|
||||
late StreamSubscription _teamEvent;
|
||||
void _initRefreshAction() {
|
||||
_teamEvent = eventBus.on<OtherTypeRefreshListEvent>().listen((event) {
|
||||
getICCardListData();
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> onReady() async {
|
||||
// TODO: implement onReady
|
||||
super.onReady();
|
||||
print("onReady()");
|
||||
|
||||
// 获取是否是演示模式 演示模式不获取接口
|
||||
var isDemoMode = await Storage.getBool(ifIsDemoModeOrNot);
|
||||
// print("aaaaaaa:$isDemoMode");
|
||||
if(isDemoMode == false){
|
||||
_initReplySubscription();
|
||||
|
||||
_initRefreshAction();
|
||||
|
||||
// 卡
|
||||
getICCardListData();
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> onInit() async {
|
||||
// TODO: implement onInit
|
||||
super.onInit();
|
||||
print("onInit()");
|
||||
var isDemoMode = await Storage.getBool(ifIsDemoModeOrNot);
|
||||
if(isDemoMode == false) {
|
||||
// senderQueryingFingerprintStatus();
|
||||
// senderCheckingCardStatus();
|
||||
senderCheckingUserInfoCount();
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> onClose() async {
|
||||
// TODO: implement onClose
|
||||
super.onClose();
|
||||
|
||||
var isDemoMode = await Storage.getBool(ifIsDemoModeOrNot);
|
||||
if(isDemoMode == false) {
|
||||
_replySubscription.cancel();
|
||||
_teamEvent.cancel();
|
||||
}
|
||||
}
|
||||
}
|
||||
318
star_lock/lib/main/lockDetail/card/cardList/cardList_page.dart
Normal file
318
star_lock/lib/main/lockDetail/card/cardList/cardList_page.dart
Normal file
@ -0,0 +1,318 @@
|
||||
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
||||
import 'package:get/get.dart';
|
||||
|
||||
import '../../../../appRouters.dart';
|
||||
import '../../../../app_settings/app_colors.dart';
|
||||
import '../../../../tools/dateTool.dart';
|
||||
import '../../../../tools/left_slide_actions.dart';
|
||||
import '../../../../tools/noData.dart';
|
||||
import '../../../../tools/showIosTipView.dart';
|
||||
import '../../../../tools/storage.dart';
|
||||
import '../../../../tools/submitBtn.dart';
|
||||
import '../../../../tools/titleAppBar.dart';
|
||||
import '../../../../tools/toast.dart';
|
||||
import '../../../../translations/trans_lib.dart';
|
||||
import '../../fingerprint/fingerprintList/fingerprintListData_entity.dart';
|
||||
import 'cardList_logic.dart';
|
||||
|
||||
class CardListPage extends StatefulWidget {
|
||||
const CardListPage({Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
State<CardListPage> createState() => _CardListPageState();
|
||||
}
|
||||
|
||||
class _CardListPageState extends State<CardListPage> {
|
||||
final logic = Get.put(CardListLogic());
|
||||
final state = Get.find<CardListLogic>().state;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
backgroundColor: AppColors.mainBackgroundColor,
|
||||
appBar: TitleAppBar(
|
||||
barTitle: TranslationLoader.lanKeys!.card!.tr,
|
||||
haveBack: true,
|
||||
backgroundColor: AppColors.mainColor,
|
||||
actionsList: [
|
||||
TextButton(
|
||||
child: Text(
|
||||
TranslationLoader.lanKeys!.reset!.tr,
|
||||
style: TextStyle(color: Colors.white, fontSize: 24.sp),
|
||||
),
|
||||
onPressed: () async {
|
||||
var isDemoMode = await Storage.getBool(ifIsDemoModeOrNot);
|
||||
if (isDemoMode == false) {
|
||||
showDeletAlertDialog(context);
|
||||
} else {
|
||||
// Get.toNamed(Routers.seletLockTypePage);
|
||||
Toast.show(msg: "演示模式");
|
||||
}
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
body: Column(
|
||||
children: [
|
||||
_searchWidget(),
|
||||
SizedBox(height: 20.h),
|
||||
Expanded(child: _buildMainUI()),
|
||||
AddBottomWhiteBtn(
|
||||
btnName:
|
||||
'${TranslationLoader.lanKeys!.add!.tr}${TranslationLoader.lanKeys!.card!.tr}',
|
||||
onClick: () async {
|
||||
var data =
|
||||
await Get.toNamed(Routers.addCardTypeManagePage, arguments: {
|
||||
"lockId": state.lockId.value,
|
||||
"fromType": 1 // 1从添加钥匙列表进入 2从考勤添加员工入口进入
|
||||
});
|
||||
if (data != null) {
|
||||
logic.getICCardListData();
|
||||
}
|
||||
},
|
||||
),
|
||||
SizedBox(
|
||||
height: 64.h,
|
||||
)
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
String getAppBarTitle(int type) {
|
||||
String title = "";
|
||||
switch (type) {
|
||||
case 0:
|
||||
title = TranslationLoader.lanKeys!.card!.tr;
|
||||
break;
|
||||
case 1:
|
||||
title = TranslationLoader.lanKeys!.fingerprint!.tr;
|
||||
break;
|
||||
case 2:
|
||||
title = TranslationLoader.lanKeys!.remoteControl!.tr;
|
||||
break;
|
||||
case 3:
|
||||
title = TranslationLoader.lanKeys!.face!.tr;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return title;
|
||||
}
|
||||
|
||||
Widget _searchWidget() {
|
||||
return Container(
|
||||
height: 60.h,
|
||||
margin: EdgeInsets.only(top: 20.w, left: 20.w, right: 10.w),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white, borderRadius: BorderRadius.circular(5)),
|
||||
child: TextField(
|
||||
//输入框一行
|
||||
maxLines: 1,
|
||||
controller: state.searchController,
|
||||
autofocus: false,
|
||||
onChanged: (value) {
|
||||
print("onChanged:$value");
|
||||
},
|
||||
onEditingComplete: () {
|
||||
print("onEditingComplete:");
|
||||
},
|
||||
onSubmitted: (value) {
|
||||
logic.getICCardListData();
|
||||
},
|
||||
decoration: InputDecoration(
|
||||
//输入里面输入文字内边距设置
|
||||
contentPadding: const EdgeInsets.only(
|
||||
top: 12.0, left: -19.0, right: -15.0, bottom: 8.0),
|
||||
hintText: TranslationLoader.lanKeys!.pleaseEnter!.tr,
|
||||
hintStyle: TextStyle(fontSize: 22.sp, height: 3.0),
|
||||
//不需要输入框下划线
|
||||
border: InputBorder.none,
|
||||
//左边图标设置
|
||||
icon: Padding(
|
||||
padding: EdgeInsets.only(
|
||||
top: 20.h, bottom: 20.h, right: 20.w, left: 10.w),
|
||||
child: Image.asset(
|
||||
'images/main/icon_main_search.png',
|
||||
width: 40.w,
|
||||
height: 40.w,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildMainUI() {
|
||||
return Obx(() => state.fingerprintItemListData.value.isNotEmpty
|
||||
? ListView.separated(
|
||||
itemCount: state.fingerprintItemListData.value.length,
|
||||
itemBuilder: (c, index) {
|
||||
FingerprintItemData fingerprintItemData = state.fingerprintItemListData.value[index];
|
||||
if (index < state.fingerprintItemListData.value.length) {
|
||||
return LeftSlideActions(
|
||||
key: Key(fingerprintItemData.cardName!),
|
||||
actionsWidth: 60,
|
||||
actions: [
|
||||
_buildDeleteBtn(fingerprintItemData.cardId.toString()),
|
||||
],
|
||||
decoration: const BoxDecoration(
|
||||
borderRadius: BorderRadius.all(Radius.circular(1)),
|
||||
),
|
||||
child: _keyItem(
|
||||
'images/icon_card.png',
|
||||
fingerprintItemData.cardName!,
|
||||
fingerprintItemData.cardType! == 1
|
||||
? "永久"
|
||||
:
|
||||
"${DateTool().dateToYMDHNString(fingerprintItemData.startDate.toString())} - ${DateTool().dateToYMDHNString(fingerprintItemData.endDate.toString())}", () async {
|
||||
var data = await Get.toNamed(
|
||||
Routers.cardDetailPage, arguments: {
|
||||
"fingerprintItemData": fingerprintItemData,
|
||||
});
|
||||
if (data != null) {
|
||||
logic.getICCardListData();
|
||||
}
|
||||
}),
|
||||
);
|
||||
}
|
||||
return const SizedBox.shrink();
|
||||
},
|
||||
separatorBuilder: (BuildContext context, int index) {
|
||||
return const Divider(
|
||||
height: 1,
|
||||
color: AppColors.greyLineColor,
|
||||
);
|
||||
},
|
||||
) : const NoData());
|
||||
}
|
||||
|
||||
Widget _buildDeleteBtn(String idStr) {
|
||||
return GestureDetector(
|
||||
onTap: () {
|
||||
// 省略: 弹出是否删除的确认对话框。
|
||||
showIosTipViewDialog(context, idStr);
|
||||
},
|
||||
child: Container(
|
||||
width: 60,
|
||||
color: const Color(0xFFF20101),
|
||||
alignment: Alignment.center,
|
||||
child: const Text(
|
||||
'删除',
|
||||
style: TextStyle(
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.w500,
|
||||
color: Colors.white,
|
||||
height: 1,
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
void showIosTipViewDialog(BuildContext context, String keyId) {
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (BuildContext context) {
|
||||
return ShowIosTipView(
|
||||
title: "提示",
|
||||
tipTitle: "确定要删除吗?",
|
||||
sureClick: () async {
|
||||
Get.back();
|
||||
String? idStr = await Storage.getUid();
|
||||
state.isDeletICCardData = true;
|
||||
logic.senderAddICCard(keyId, idStr ?? "", 0);
|
||||
},
|
||||
cancelClick: () {
|
||||
Get.back();
|
||||
},
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
Widget _keyItem(String lockTypeIcon, String lockTypeTitle, String showTime,
|
||||
Function() action) {
|
||||
return GestureDetector(
|
||||
onTap: action,
|
||||
child: Container(
|
||||
height: 90.h,
|
||||
// margin: EdgeInsets.only(left: 20.w, right: 20.w, top: 20.w),
|
||||
color: Colors.white,
|
||||
// decoration: BoxDecoration(
|
||||
// color: Colors.white,
|
||||
// // borderRadius: BorderRadius.circular(10.w),
|
||||
// ),
|
||||
child: Row(
|
||||
children: [
|
||||
SizedBox(width: 30.w),
|
||||
Image.asset(lockTypeIcon, width: 60.w, height: 60.w),
|
||||
SizedBox(width: 20.w),
|
||||
Expanded(
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
children: [
|
||||
Text(lockTypeTitle,
|
||||
style: TextStyle(
|
||||
fontSize: 24.sp, color: AppColors.blackColor)),
|
||||
],
|
||||
),
|
||||
SizedBox(height: 5.h),
|
||||
Container(
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
children: [
|
||||
Text(showTime,
|
||||
style: TextStyle(
|
||||
fontSize: 18.sp,
|
||||
color: AppColors.placeholderTextColor)),
|
||||
],
|
||||
),
|
||||
),
|
||||
SizedBox(width: 20.h),
|
||||
],
|
||||
),
|
||||
),
|
||||
SizedBox(width: 20.h),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
void showDeletAlertDialog(
|
||||
BuildContext context,
|
||||
) {
|
||||
showCupertinoDialog(
|
||||
context: context,
|
||||
builder: (context) {
|
||||
return CupertinoAlertDialog(
|
||||
title: const Text("提示"),
|
||||
content: const Text('重置后信息都会清除哦,确认要重置吗?'),
|
||||
actions: [
|
||||
CupertinoDialogAction(
|
||||
child: Text(TranslationLoader.lanKeys!.cancel!.tr),
|
||||
onPressed: () {
|
||||
Navigator.pop(context);
|
||||
},
|
||||
),
|
||||
CupertinoDialogAction(
|
||||
child: Text(TranslationLoader.lanKeys!.sure!.tr),
|
||||
onPressed: () {
|
||||
Navigator.pop(context);
|
||||
state.isDeletICCardData = true;
|
||||
logic.senderAddICCard("1", "DeleteAll!@#", 255);
|
||||
},
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,19 @@
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
import '../../fingerprint/fingerprintList/fingerprintListData_entity.dart';
|
||||
|
||||
class CardListState {
|
||||
final lockId = 0.obs;
|
||||
|
||||
var isDeletFingerprintData = false;
|
||||
var isDeletICCardData = false;
|
||||
|
||||
final fingerprintItemListData = <FingerprintItemData>[].obs;
|
||||
final TextEditingController searchController = TextEditingController();
|
||||
|
||||
CardListState() {
|
||||
Map map = Get.arguments;
|
||||
lockId.value = map["lockId"];
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,52 @@
|
||||
|
||||
import 'package:get/get.dart';
|
||||
import 'package:star_lock/tools/baseGetXController.dart';
|
||||
import '../../../../network/api_repository.dart';
|
||||
import '../../../../tools/eventBusEventManage.dart';
|
||||
import '../../../../tools/toast.dart';
|
||||
import 'otherTypeKeyChangeDate_state.dart';
|
||||
|
||||
class OtherTypeKeyChangeDateLogic extends BaseGetXController{
|
||||
OtherTypeKeyChangeDateState state = OtherTypeKeyChangeDateState();
|
||||
|
||||
// 修改指纹信息
|
||||
void editFingerprintsData() async{
|
||||
var entity = await ApiRepository.to.editFingerprintsData(
|
||||
fingerprintId: state.fingerprintItemData.value.fingerprintId.toString(),
|
||||
lockId: state.fingerprintItemData.value.lockId.toString(),
|
||||
weekDay: state.fingerprintItemData.value.weekDay!,
|
||||
startDate: state.beginTimeTimestamp.value.toString(),
|
||||
endDate: state.endTimeTimestamp.value.toString(),
|
||||
isCoerced: state.fingerprintItemData.value.isCoerced == 1 ? "2" : "1",
|
||||
fingerprintName: state.fingerprintItemData.value.fingerprintName!,
|
||||
);
|
||||
if(entity.errorCode!.codeIsSuccessful){
|
||||
Toast.show(msg: "修改成功");
|
||||
Get.back(result: {
|
||||
"beginTimeTimestamp":state.beginTimeTimestamp.value,
|
||||
"endTimeTimestamp":state.endTimeTimestamp.value,
|
||||
});
|
||||
eventBus.fire(OtherTypeRefreshListEvent());
|
||||
}
|
||||
}
|
||||
|
||||
// 编辑iC卡
|
||||
void editICCardData() async{
|
||||
var entity = await ApiRepository.to.editICCardData(
|
||||
cardId: state.fingerprintItemData.value.cardId.toString(),
|
||||
lockId: state.fingerprintItemData.value.lockId.toString(),
|
||||
weekDay: state.fingerprintItemData.value.weekDay!,
|
||||
startDate: state.beginTimeTimestamp.value.toString(),
|
||||
endDate: state.endTimeTimestamp.value.toString(),
|
||||
isCoerced: state.fingerprintItemData.value.isCoerced == 1 ? "2" : "1",
|
||||
cardName: state.fingerprintItemData.value.cardName!,
|
||||
);
|
||||
if(entity.errorCode!.codeIsSuccessful){
|
||||
Toast.show(msg: "修改成功");
|
||||
Get.back(result: {
|
||||
"beginTimeTimestamp":state.beginTimeTimestamp.value,
|
||||
"endTimeTimestamp":state.endTimeTimestamp.value,
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,99 @@
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_pickers/pickers.dart';
|
||||
import 'package:flutter_pickers/time_picker/model/date_mode.dart';
|
||||
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
||||
import 'package:get/get.dart';
|
||||
|
||||
import '../../../../app_settings/app_colors.dart';
|
||||
import '../../../../tools/commonItem.dart';
|
||||
import '../../../../tools/titleAppBar.dart';
|
||||
import '../../../../translations/trans_lib.dart';
|
||||
import 'otherTypeKeyChangeDate_logic.dart';
|
||||
|
||||
class OtherTypeKeyChangeDatePage extends StatefulWidget {
|
||||
const OtherTypeKeyChangeDatePage({Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
State<OtherTypeKeyChangeDatePage> createState() => _OtherTypeKeyChangeDatePageState();
|
||||
}
|
||||
|
||||
class _OtherTypeKeyChangeDatePageState extends State<OtherTypeKeyChangeDatePage> {
|
||||
final logic = Get.put(OtherTypeKeyChangeDateLogic());
|
||||
final state = Get.find<OtherTypeKeyChangeDateLogic>().state;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
backgroundColor: AppColors.mainBackgroundColor,
|
||||
appBar: TitleAppBar(
|
||||
barTitle: "${TranslationLoader.lanKeys!.amend!.tr}${TranslationLoader.lanKeys!.periodValidity!.tr}",
|
||||
haveBack: true,
|
||||
backgroundColor: AppColors.mainColor,
|
||||
actionsList: [
|
||||
TextButton(
|
||||
child: Text(
|
||||
TranslationLoader.lanKeys!.sure!.tr,
|
||||
style: TextStyle(color: Colors.white, fontSize: 24.sp),
|
||||
),
|
||||
onPressed: () {
|
||||
// print("state.pushType.value:${state.pushType.value}");
|
||||
switch (state.pushType.value) {
|
||||
case 0:
|
||||
// 卡
|
||||
logic.editICCardData();
|
||||
break;
|
||||
case 1:
|
||||
// 指纹
|
||||
logic.editFingerprintsData();
|
||||
break;
|
||||
case 2:
|
||||
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
body: buildMainUI(),
|
||||
);
|
||||
}
|
||||
|
||||
Widget buildMainUI() {
|
||||
return Column(
|
||||
children: [
|
||||
Obx(() => CommonItem(
|
||||
leftTitel: TranslationLoader.lanKeys!.effectiveTime!.tr,
|
||||
rightTitle: state.beginTime.value,
|
||||
isHaveLine: true,
|
||||
isHaveDirection: true,
|
||||
action: () {
|
||||
Pickers.showDatePicker(context, mode: DateMode.YMDHM,
|
||||
onConfirm: (p) {
|
||||
setState(() {
|
||||
state.beginTimeTimestamp.value = DateTime.parse(
|
||||
'${p.year}-${p.month.toString().padLeft(2,'0')}-${p.day.toString().padLeft(2,'0')} ${p.hour!.toString().padLeft(2,'0')}:${p.minute!.toString().padLeft(2,'0')}').millisecondsSinceEpoch;
|
||||
state.beginTime.value = "${p.year}.${p.month.toString().padLeft(2,'0')}.${p.day.toString().padLeft(2,'0')} ${p.hour.toString().padLeft(2,'0')}:${p.minute!.toString().padLeft(2,'0')}";
|
||||
});
|
||||
});
|
||||
})),
|
||||
Obx(() => CommonItem(
|
||||
leftTitel: TranslationLoader.lanKeys!.failureTime!.tr,
|
||||
rightTitle: state.endTime.value,
|
||||
isHaveDirection: true,
|
||||
action: () {
|
||||
Pickers.showDatePicker(context, mode: DateMode.YMDHM,
|
||||
onConfirm: (p) {
|
||||
setState(() {
|
||||
state.endTimeTimestamp.value = DateTime.parse(
|
||||
'${p.year}-${p.month.toString().padLeft(2,'0')}-${p.day.toString().padLeft(2,'0')} ${p.hour!.toString().padLeft(2,'0')}:${p.minute!.toString().padLeft(2,'0')}').millisecondsSinceEpoch;
|
||||
state.endTime.value = "${p.year}.${p.month.toString().padLeft(2,'0')}.${p.day.toString().padLeft(2,'0')} ${p.hour.toString().padLeft(2,'0')}:${p.minute!.toString().padLeft(2,'0')}";
|
||||
});
|
||||
});
|
||||
})),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,26 @@
|
||||
|
||||
import 'package:get/get.dart';
|
||||
import '../../../../tools/dateTool.dart';
|
||||
import '../../fingerprint/fingerprintList/fingerprintListData_entity.dart';
|
||||
|
||||
class OtherTypeKeyChangeDateState{
|
||||
final fingerprintItemData = FingerprintItemData().obs;
|
||||
|
||||
var beginTime = "".obs;// 开始时间
|
||||
var endTime = "".obs;// 结束时间
|
||||
var beginTimeTimestamp = 0.obs;// 开始时间时间戳
|
||||
var endTimeTimestamp = 0.obs;// 结束时间时间戳
|
||||
|
||||
var pushType = 0.obs;// 0卡 1指纹 2遥控
|
||||
|
||||
OtherTypeKeyChangeDateState() {
|
||||
Map map = Get.arguments;
|
||||
pushType.value = map["pushType"];
|
||||
fingerprintItemData.value = map["fingerprintItemData"];
|
||||
|
||||
beginTime.value = DateTool().dateToYMDHNString(fingerprintItemData.value.startDate.toString());
|
||||
endTime.value = DateTool().dateToYMDHNString(fingerprintItemData.value.endDate.toString());
|
||||
beginTimeTimestamp.value = fingerprintItemData.value.startDate!;
|
||||
endTimeTimestamp.value = fingerprintItemData.value.endDate!;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,56 @@
|
||||
|
||||
import 'package:get/get.dart';
|
||||
import 'package:star_lock/tools/baseGetXController.dart';
|
||||
|
||||
import '../../../../network/api_repository.dart';
|
||||
import '../../../../tools/eventBusEventManage.dart';
|
||||
import '../../../../tools/toast.dart';
|
||||
import 'otherTypeKeyChangeValidityDate_state.dart';
|
||||
|
||||
class OtherTypeKeyChangeValidityDateLogic extends BaseGetXController{
|
||||
OtherTypeKeyChangeValidityDateState state = OtherTypeKeyChangeValidityDateState();
|
||||
|
||||
// 修改指纹信息
|
||||
void editFingerprintsData() async{
|
||||
var entity = await ApiRepository.to.editFingerprintsData(
|
||||
fingerprintId: state.fingerprintItemData.value.fingerprintId.toString(),
|
||||
lockId: state.fingerprintItemData.value.lockId.toString(),
|
||||
weekDay: state.weekDay.value,
|
||||
startDate: state.beginTimeTimestamp.value.toString(),
|
||||
endDate: state.endTimeTimestamp.value.toString(),
|
||||
isCoerced: state.fingerprintItemData.value.isCoerced == 1 ? "2" : "1",
|
||||
fingerprintName: state.fingerprintItemData.value.fingerprintName!,
|
||||
);
|
||||
if(entity.errorCode!.codeIsSuccessful){
|
||||
Toast.show(msg: "修改成功");
|
||||
Get.back(result: {
|
||||
"beginTimeTimestamp":state.beginTimeTimestamp.value,
|
||||
"endTimeTimestamp":state.endTimeTimestamp.value,
|
||||
"weekDay":state.weekDay.value,
|
||||
});
|
||||
eventBus.fire(OtherTypeRefreshListEvent());
|
||||
}
|
||||
}
|
||||
|
||||
// 编辑iC卡
|
||||
void editICCardData() async{
|
||||
var entity = await ApiRepository.to.editICCardData(
|
||||
cardId: state.fingerprintItemData.value.cardId.toString(),
|
||||
lockId: state.fingerprintItemData.value.lockId.toString(),
|
||||
weekDay: state.weekDay.value,
|
||||
startDate: state.beginTimeTimestamp.value.toString(),
|
||||
endDate: state.endTimeTimestamp.value.toString(),
|
||||
isCoerced: state.fingerprintItemData.value.isCoerced == 1 ? "2" : "1",
|
||||
cardName: state.fingerprintItemData.value.cardName!,
|
||||
);
|
||||
if(entity.errorCode!.codeIsSuccessful){
|
||||
Toast.show(msg: "修改成功");
|
||||
Get.back(result: {
|
||||
"beginTimeTimestamp":state.beginTimeTimestamp.value,
|
||||
"endTimeTimestamp":state.endTimeTimestamp.value,
|
||||
"weekDay":state.weekDay.value,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@ -1,5 +1,4 @@
|
||||
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_pickers/pickers.dart';
|
||||
import 'package:flutter_pickers/time_picker/model/date_mode.dart';
|
||||
@ -0,0 +1,29 @@
|
||||
|
||||
import 'package:get/get.dart';
|
||||
|
||||
import '../../../../tools/dateTool.dart';
|
||||
import '../../fingerprint/fingerprintList/fingerprintListData_entity.dart';
|
||||
|
||||
class OtherTypeKeyChangeValidityDateState{
|
||||
final fingerprintItemData = FingerprintItemData().obs;
|
||||
|
||||
var beginTime = "".obs;// 开始时间
|
||||
var endTime = "".obs;// 结束时间
|
||||
var beginTimeTimestamp = 0.obs;// 开始时间时间戳
|
||||
var endTimeTimestamp = 0.obs;// 结束时间时间戳
|
||||
|
||||
var pushType = 0.obs;// 0卡 1指纹 2遥控
|
||||
var weekDay = [].obs;
|
||||
|
||||
OtherTypeKeyChangeValidityDateState() {
|
||||
Map map = Get.arguments;
|
||||
pushType.value = map["pushType"];
|
||||
fingerprintItemData.value = map["fingerprintItemData"];
|
||||
|
||||
beginTime.value = DateTool().dateToYMDHNString(fingerprintItemData.value.startDate.toString());
|
||||
endTime.value = DateTool().dateToYMDHNString(fingerprintItemData.value.endDate.toString());
|
||||
beginTimeTimestamp.value = fingerprintItemData.value.startDate!;
|
||||
endTimeTimestamp.value = fingerprintItemData.value.endDate!;
|
||||
weekDay.value = fingerprintItemData.value.weekDay!;
|
||||
}
|
||||
}
|
||||
@ -166,7 +166,7 @@ class _CheckingInAddStaffPageState extends State<CheckingInAddStaffPage> {
|
||||
}
|
||||
|
||||
var data = await Get.toNamed(
|
||||
Routers.otherTypeKeyManagePage,
|
||||
Routers.addCardTypeManagePage,
|
||||
arguments: {
|
||||
"lockId": state
|
||||
.getKeyInfosData.value.lockId,
|
||||
@ -187,7 +187,7 @@ class _CheckingInAddStaffPageState extends State<CheckingInAddStaffPage> {
|
||||
}
|
||||
|
||||
var data = await Get.toNamed(
|
||||
Routers.otherTypeKeyManagePage,
|
||||
Routers.addFingerprintTypeManagePage,
|
||||
arguments: {
|
||||
"lockId": state
|
||||
.getKeyInfosData.value.lockId,
|
||||
|
||||
78
star_lock/lib/main/lockDetail/face/addFace/addFace_page.dart
Normal file
78
star_lock/lib/main/lockDetail/face/addFace/addFace_page.dart
Normal file
@ -0,0 +1,78 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
||||
import 'package:get/get.dart';
|
||||
|
||||
import '../../../../../appRouters.dart';
|
||||
import '../../../../../app_settings/app_colors.dart';
|
||||
import '../../../../../tools/submitBtn.dart';
|
||||
import '../../../../../tools/titleAppBar.dart';
|
||||
import '../../../../../translations/trans_lib.dart';
|
||||
import '../../../../tools/toast.dart';
|
||||
|
||||
class AddFaceTipPage extends StatefulWidget {
|
||||
const AddFaceTipPage({Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
State<AddFaceTipPage> createState() => _AddFaceTipPageState();
|
||||
}
|
||||
|
||||
class _AddFaceTipPageState extends State<AddFaceTipPage> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
backgroundColor: Colors.white,
|
||||
appBar: TitleAppBar(
|
||||
barTitle: "${TranslationLoader.lanKeys!.addTip!.tr}${TranslationLoader.lanKeys!.face!.tr}",
|
||||
haveBack: true,
|
||||
backgroundColor: AppColors.mainColor),
|
||||
body: ListView(
|
||||
// mainAxisAlignment: MainAxisAlignment.center,
|
||||
// crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: [
|
||||
SizedBox(
|
||||
height: 50.h,
|
||||
),
|
||||
Image.asset(
|
||||
'images/main/icon_main_addFace.png',
|
||||
width: 100.w,
|
||||
height: 457.h,
|
||||
fit: BoxFit.fitHeight,
|
||||
),
|
||||
SizedBox(
|
||||
height: 60.h,
|
||||
),
|
||||
Container(
|
||||
padding: EdgeInsets.only(left: 20.w, right: 20.w),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
children: [
|
||||
Expanded(
|
||||
child: Text(
|
||||
"请单人正对门锁,距离一个成年人手臂长度(约0.6米).\n保持脸部无遮挡,露出五官",
|
||||
// TranslationLoader.lanKeys!.lightTouchScreenTip!.tr,
|
||||
textAlign: TextAlign.center,
|
||||
maxLines: null,
|
||||
style:
|
||||
TextStyle(fontSize: 24.sp, fontWeight: FontWeight.w600),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
SizedBox(
|
||||
height: 120.h,
|
||||
),
|
||||
Container(
|
||||
padding: EdgeInsets.only(left: 20.w, right: 20.w),
|
||||
child: SubmitBtn(
|
||||
btnName: "开始添加", //TranslationLoader.lanKeys!.next!.tr,
|
||||
borderRadius: 20.w,
|
||||
onClick: () {
|
||||
Toast.show(msg: "请确保在设备附近,设备未被连接,设备已打开");
|
||||
}),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,38 @@
|
||||
|
||||
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 'addFaceTypeManage_tabbar.dart';
|
||||
|
||||
class AddFaceTypeManagePage extends StatefulWidget {
|
||||
const AddFaceTypeManagePage({Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
State<AddFaceTypeManagePage> createState() => _AddFaceTypeManagePageState();
|
||||
}
|
||||
|
||||
class _AddFaceTypeManagePageState extends State<AddFaceTypeManagePage> {
|
||||
var index = 0;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
|
||||
return Scaffold(
|
||||
backgroundColor: AppColors.mainBackgroundColor,
|
||||
appBar: TitleAppBar(
|
||||
barTitle:
|
||||
"${TranslationLoader.lanKeys!.addTip!.tr}${TranslationLoader.lanKeys!.face!.tr}",
|
||||
haveBack: true,
|
||||
backgroundColor: AppColors.mainColor),
|
||||
body: Column(
|
||||
children: [
|
||||
AddFaceTypeManageTabbar(initialIndex: index),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,98 @@
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
||||
import 'package:get/get.dart';
|
||||
|
||||
import '../../../../../app_settings/app_colors.dart';
|
||||
import '../../../../../tools/CustomUnderlineTabIndicator.dart';
|
||||
import '../../../../../translations/trans_lib.dart';
|
||||
import '../addFaceType_page.dart';
|
||||
|
||||
class AddFaceTypeManageTabbar extends StatefulWidget {
|
||||
var initialIndex = 1;
|
||||
|
||||
AddFaceTypeManageTabbar({Key? key, required this.initialIndex}) : super(key: key);
|
||||
|
||||
@override
|
||||
State<AddFaceTypeManageTabbar> createState() => _AddFaceTypeManageTabbarState();
|
||||
}
|
||||
|
||||
class _AddFaceTypeManageTabbarState extends State<AddFaceTypeManageTabbar> with SingleTickerProviderStateMixin {
|
||||
late TabController _tabController;
|
||||
|
||||
final List<ItemView> _itemTabs = <ItemView>[
|
||||
ItemView(title: TranslationLoader.lanKeys!.permanent!.tr, seletType: "0"),
|
||||
ItemView(title: TranslationLoader.lanKeys!.timeLimit!.tr, seletType: "1"),
|
||||
ItemView(title: TranslationLoader.lanKeys!.circulation!.tr, seletType: "2"),
|
||||
];
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
// TODO: implement initState
|
||||
super.initState();
|
||||
_tabController = TabController(
|
||||
vsync: this,
|
||||
length: _itemTabs.length,
|
||||
initialIndex: widget.initialIndex);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Expanded(
|
||||
child: Column(
|
||||
children: [
|
||||
_tabBar(),
|
||||
_pageWidget(),
|
||||
],
|
||||
));
|
||||
}
|
||||
|
||||
TabBar _tabBar() {
|
||||
return TabBar(
|
||||
controller: _tabController,
|
||||
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(
|
||||
child: SizedBox(
|
||||
width: 1.sw / 5,
|
||||
child: Text(item.title, textAlign: TextAlign.center)));
|
||||
}
|
||||
|
||||
Widget _pageWidget() {
|
||||
return Expanded(
|
||||
child: TabBarView(
|
||||
controller: _tabController,
|
||||
children: _itemTabs
|
||||
.map((ItemView item) => AddFaceTypePage(seletType: item.seletType,))
|
||||
.toList(),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class ItemView {
|
||||
const ItemView({required this.title, required this.seletType});
|
||||
|
||||
final String title;
|
||||
final String seletType;
|
||||
}
|
||||
@ -0,0 +1,8 @@
|
||||
|
||||
import 'package:star_lock/tools/baseGetXController.dart';
|
||||
import 'addFaceType_state.dart';
|
||||
|
||||
class AddFaceTypeLogic extends BaseGetXController{
|
||||
AddFaceTypeState state = AddFaceTypeState();
|
||||
|
||||
}
|
||||
@ -0,0 +1,298 @@
|
||||
|
||||
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_pickers/pickers.dart';
|
||||
import 'package:flutter_pickers/time_picker/model/date_mode.dart';
|
||||
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
||||
import 'package:get/get.dart';
|
||||
|
||||
import '../../../../appRouters.dart';
|
||||
import '../../../../app_settings/app_colors.dart';
|
||||
import '../../../../tools/commonItem.dart';
|
||||
import '../../../../tools/storage.dart';
|
||||
import '../../../../tools/submitBtn.dart';
|
||||
import '../../../../tools/toast.dart';
|
||||
import '../../../../translations/trans_lib.dart';
|
||||
import 'addFaceType_logic.dart';
|
||||
|
||||
class AddFaceTypePage extends StatefulWidget {
|
||||
final String seletType;
|
||||
|
||||
const AddFaceTypePage({Key? key, required this.seletType}) : super(key: key);
|
||||
|
||||
@override
|
||||
State<AddFaceTypePage> createState() => _AddFaceTypePageState();
|
||||
}
|
||||
|
||||
class _AddFaceTypePageState extends State<AddFaceTypePage> {
|
||||
final logic = Get.put(AddFaceTypeLogic());
|
||||
final state = Get.find<AddFaceTypeLogic>().state;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
|
||||
return indexChangeWidget();
|
||||
}
|
||||
|
||||
Widget indexChangeWidget() {
|
||||
switch (int.parse(widget.seletType)) {
|
||||
case 0:
|
||||
{
|
||||
// 永久
|
||||
// return sendElectronicKeySucceed();
|
||||
return Column(
|
||||
children: [
|
||||
perpetualKeyWidget(TranslationLoader.lanKeys!.name!.tr,
|
||||
TranslationLoader.lanKeys!.pleaseEnter!.tr, state.nameController),
|
||||
keyBottomWidget()
|
||||
],
|
||||
);
|
||||
}
|
||||
case 1:
|
||||
{
|
||||
// 限时
|
||||
return Column(
|
||||
children: [
|
||||
perpetualKeyWidget(TranslationLoader.lanKeys!.name!.tr,
|
||||
TranslationLoader.lanKeys!.pleaseEnter!.tr, state.nameController),
|
||||
keyTimeLimitWidget(),
|
||||
SizedBox(height: 10.h),
|
||||
keyBottomWidget()
|
||||
],
|
||||
);
|
||||
}
|
||||
case 2:
|
||||
{
|
||||
// 循环
|
||||
return Column(
|
||||
children: [
|
||||
perpetualKeyWidget(TranslationLoader.lanKeys!.name!.tr,
|
||||
TranslationLoader.lanKeys!.pleaseEnter!.tr, state.nameController),
|
||||
CommonItem(
|
||||
leftTitel: TranslationLoader.lanKeys!.periodValidity!.tr,
|
||||
rightTitle: "",
|
||||
isHaveDirection: true,
|
||||
action: () async {
|
||||
Map result = await Get.toNamed(Routers.electronicKeyPeriodValidityPage);
|
||||
state.weekdaysList.value = result['validityValue'];
|
||||
state.effectiveDateTime.value = result['starDate'].millisecondsSinceEpoch;
|
||||
state.failureDateTime.value = result['endDate'].millisecondsSinceEpoch;
|
||||
print('得到的有效期数据:${state.weekdaysList.value} == ${state.effectiveDateTime.value} == ${state.failureDateTime.value}');
|
||||
}),
|
||||
SizedBox(height: 10.h),
|
||||
keyBottomWidget()
|
||||
],
|
||||
);
|
||||
}
|
||||
default:
|
||||
return Container();
|
||||
}
|
||||
}
|
||||
|
||||
// 密码命名输入框
|
||||
Widget perpetualKeyWidget(
|
||||
String titleStr, String rightTitle, TextEditingController controller) {
|
||||
return Column(
|
||||
children: [
|
||||
Container(height: 10.h),
|
||||
CommonItem(
|
||||
leftTitel: titleStr,
|
||||
rightTitle: "",
|
||||
isHaveRightWidget: true,
|
||||
rightWidget: getTFWidget(rightTitle)),
|
||||
Container(height: 10.h),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
// 限时顶部选择日期
|
||||
Widget keyTimeLimitWidget() {
|
||||
return Column(
|
||||
children: [
|
||||
Obx(() => CommonItem(
|
||||
leftTitel: TranslationLoader.lanKeys!.effectiveTime!.tr,
|
||||
rightTitle: state.beginTime.value,
|
||||
isHaveLine: true,
|
||||
isHaveDirection: true,
|
||||
action: () async {
|
||||
Pickers.showDatePicker(context, mode: DateMode.YMDHM,
|
||||
onConfirm: (p) {
|
||||
setState(() {
|
||||
setState(() {
|
||||
state.beginTime.value = '${p.year}-${p.month!.toString().padLeft(2,'0')}-${p.day!.toString().padLeft(2,'0')} ${p.hour!.toString().padLeft(2,'0')}:${p.minute!.toString().padLeft(2,'0')}';
|
||||
state.beginTimeTimestamp.value = DateTime.parse(state.beginTime.value).millisecondsSinceEpoch.toString();
|
||||
});
|
||||
});
|
||||
});
|
||||
})),
|
||||
Obx(() => CommonItem(
|
||||
leftTitel: TranslationLoader.lanKeys!.failureTime!.tr,
|
||||
rightTitle: state.endTime.value,
|
||||
isHaveDirection: true,
|
||||
action: () {
|
||||
Pickers.showDatePicker(context, mode: DateMode.YMDHM,
|
||||
onConfirm: (p) {
|
||||
setState(() {
|
||||
setState(() {
|
||||
state.endTime.value = '${p.year}-${p.month!.toString().padLeft(2,'0')}-${p.day!.toString().padLeft(2,'0')} ${p.hour!.toString().padLeft(2,'0')}:${p.minute!.toString().padLeft(2,'0')}';
|
||||
state.endTimeTimestamp.value = DateTime.parse(state.endTime.value).millisecondsSinceEpoch.toString();
|
||||
});
|
||||
});
|
||||
});
|
||||
})),
|
||||
Container(height: 10.h),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
Widget keyBottomWidget() {
|
||||
return Column(
|
||||
children: [
|
||||
// CommonItem(
|
||||
// leftTitel: TranslationLoader.lanKeys!.face!.tr,
|
||||
// rightTitle: "",
|
||||
// isTipsImg: false,
|
||||
// isHaveRightWidget: true,
|
||||
// rightWidget: SizedBox(
|
||||
// width: 60.w, height: 50.h, child: _isStressFingerprint())),
|
||||
SizedBox(height: 30.h),
|
||||
SubmitBtn(btnName: TranslationLoader.lanKeys!.next!.tr, onClick: () async {
|
||||
|
||||
var isDemoMode = await Storage.getBool(ifIsDemoModeOrNot);
|
||||
if(isDemoMode == false){
|
||||
// print("state.seletType:${state.seletType.value}");
|
||||
if(state.nameController.text.isEmpty){
|
||||
Toast.show(msg: "请输入姓名");
|
||||
return;
|
||||
}
|
||||
|
||||
Get.toNamed(Routers.addFaceTipPage);
|
||||
}else{
|
||||
// Get.toNamed(Routers.seletLockTypePage);
|
||||
Toast.show(msg: "演示模式");
|
||||
}
|
||||
|
||||
}),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
// 发送电子钥匙成功
|
||||
Widget sendElectronicKeySucceed() {
|
||||
return Column(
|
||||
children: [
|
||||
Container(
|
||||
height: 300.h,
|
||||
width: 1.sw,
|
||||
color: Colors.white,
|
||||
child: Column(
|
||||
children: [
|
||||
SizedBox(
|
||||
height: 30.h,
|
||||
),
|
||||
Image.asset(
|
||||
'images/main/icon_main_addLock.png',
|
||||
width: 150.w,
|
||||
height: 150.w,
|
||||
color: AppColors.mainColor,
|
||||
),
|
||||
SizedBox(
|
||||
height: 20.h,
|
||||
),
|
||||
Text(
|
||||
"操作成功,密码为",
|
||||
style: TextStyle(
|
||||
fontSize: 32.sp,
|
||||
color: Colors.black,
|
||||
fontWeight: FontWeight.w500),
|
||||
),
|
||||
SizedBox(
|
||||
height: 10.h,
|
||||
),
|
||||
Text(
|
||||
"62689876",
|
||||
style: TextStyle(
|
||||
fontSize: 60.sp,
|
||||
color: Colors.black,
|
||||
fontWeight: FontWeight.w500),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
SizedBox(
|
||||
height: 20.h,
|
||||
),
|
||||
SubmitBtn(
|
||||
btnName: '完成',
|
||||
fontSize: 28.sp,
|
||||
borderRadius: 20.w,
|
||||
margin: EdgeInsets.only(left: 30.w, right: 30.w, top: 30.w),
|
||||
padding: EdgeInsets.only(top: 25.w, bottom: 25.w),
|
||||
onClick: () {}),
|
||||
SubmitBtn(
|
||||
btnName: '分享',
|
||||
fontSize: 28.sp,
|
||||
borderRadius: 20.w,
|
||||
margin: EdgeInsets.only(left: 30.w, right: 30.w, top: 30.w),
|
||||
padding: EdgeInsets.only(top: 25.w, bottom: 25.w),
|
||||
onClick: () {}),
|
||||
SubmitBtn(
|
||||
btnName: '标记为:已入住',
|
||||
fontSize: 28.sp,
|
||||
borderRadius: 20.w,
|
||||
margin: EdgeInsets.only(left: 30.w, right: 30.w, top: 30.w),
|
||||
padding: EdgeInsets.only(top: 25.w, bottom: 25.w),
|
||||
onClick: () {}),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
// 接受者信息输入框
|
||||
Widget getTFWidget(String tfStr) {
|
||||
return Container(
|
||||
height: 50.h,
|
||||
width: 300.w,
|
||||
child: Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: TextField(
|
||||
//输入框一行
|
||||
maxLines: 1,
|
||||
controller: state.nameController,
|
||||
autofocus: false,
|
||||
textAlign: TextAlign.end,
|
||||
decoration: InputDecoration(
|
||||
//输入里面输入文字内边距设置
|
||||
contentPadding: const EdgeInsets.only(top: 12.0, bottom: 8.0),
|
||||
hintText: tfStr,
|
||||
hintStyle: TextStyle(fontSize: 24.sp),
|
||||
//不需要输入框下划线
|
||||
border: InputBorder.none,
|
||||
),
|
||||
),
|
||||
),
|
||||
SizedBox(
|
||||
width: 10.w,
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
//isStressFingerprint false:不是胁迫指纹 ture:胁迫指纹
|
||||
CupertinoSwitch _isStressFingerprint() {
|
||||
return CupertinoSwitch(
|
||||
activeColor: CupertinoColors.activeBlue,
|
||||
trackColor: CupertinoColors.systemGrey5,
|
||||
thumbColor: CupertinoColors.white,
|
||||
value: true,
|
||||
onChanged: (value) {
|
||||
setState(() {
|
||||
// state.isStressFingerprint.value = value;
|
||||
});
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,16 @@
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
|
||||
class AddFaceTypeState{
|
||||
var beginTime = "".obs;// 开始时间
|
||||
var endTime = "".obs;// 结束时间
|
||||
var beginTimeTimestamp = "".obs;// 开始时间时间戳
|
||||
var endTimeTimestamp = "".obs;// 结束时间时间戳
|
||||
|
||||
var effectiveDateTime = 0.obs;// 生效时间
|
||||
var failureDateTime = 0.obs;// 失效时间
|
||||
var weekdaysList = [].obs;
|
||||
|
||||
final TextEditingController nameController = TextEditingController();
|
||||
}
|
||||
@ -0,0 +1,8 @@
|
||||
|
||||
import 'package:star_lock/tools/baseGetXController.dart';
|
||||
import 'faceList_state.dart';
|
||||
|
||||
class FaceListLogic extends BaseGetXController{
|
||||
FaceListState state = FaceListState();
|
||||
|
||||
}
|
||||
252
star_lock/lib/main/lockDetail/face/faceList/faceList_page.dart
Normal file
252
star_lock/lib/main/lockDetail/face/faceList/faceList_page.dart
Normal file
@ -0,0 +1,252 @@
|
||||
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
||||
import 'package:get/get.dart';
|
||||
|
||||
import '../../../../appRouters.dart';
|
||||
import '../../../../app_settings/app_colors.dart';
|
||||
import '../../../../tools/noData.dart';
|
||||
import '../../../../tools/showIosTipView.dart';
|
||||
import '../../../../tools/storage.dart';
|
||||
import '../../../../tools/submitBtn.dart';
|
||||
import '../../../../tools/titleAppBar.dart';
|
||||
import '../../../../tools/toast.dart';
|
||||
import '../../../../translations/trans_lib.dart';
|
||||
import 'faceList_logic.dart';
|
||||
|
||||
class FaceList extends StatefulWidget {
|
||||
const FaceList({Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
State<FaceList> createState() => _FaceListState();
|
||||
}
|
||||
|
||||
class _FaceListState extends State<FaceList> {
|
||||
final logic = Get.put(FaceListLogic());
|
||||
final state = Get.find<FaceListLogic>().state;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
backgroundColor: AppColors.mainBackgroundColor,
|
||||
appBar: TitleAppBar(
|
||||
barTitle: TranslationLoader.lanKeys!.face!.tr,
|
||||
haveBack: true,
|
||||
backgroundColor: AppColors.mainColor,
|
||||
actionsList: [
|
||||
TextButton(
|
||||
child: Text(
|
||||
TranslationLoader.lanKeys!.reset!.tr,
|
||||
style: TextStyle(color: Colors.white, fontSize: 24.sp),
|
||||
),
|
||||
onPressed: () async {
|
||||
var isDemoMode = await Storage.getBool(ifIsDemoModeOrNot);
|
||||
if (isDemoMode == false) {
|
||||
showDeletAlertDialog(context);
|
||||
} else {
|
||||
// Get.toNamed(Routers.seletLockTypePage);
|
||||
Toast.show(msg: "演示模式");
|
||||
}
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
body: Column(
|
||||
children: [
|
||||
_searchWidget(),
|
||||
SizedBox(
|
||||
height: 20.h,
|
||||
),
|
||||
Expanded(child: _buildMainUI()),
|
||||
AddBottomWhiteBtn(
|
||||
btnName:
|
||||
'${TranslationLoader.lanKeys!.add!.tr}${TranslationLoader.lanKeys!.face!.tr}',
|
||||
onClick: () async {
|
||||
var data =
|
||||
await Get.toNamed(Routers.addFaceTypeManagePage);
|
||||
if (data != null) {
|
||||
// 遥控添加
|
||||
|
||||
}
|
||||
},
|
||||
),
|
||||
SizedBox(
|
||||
height: 64.h,
|
||||
)
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _searchWidget() {
|
||||
return Container(
|
||||
height: 60.h,
|
||||
margin: EdgeInsets.only(top: 20.w, left: 20.w, right: 10.w),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white, borderRadius: BorderRadius.circular(5)),
|
||||
child: TextField(
|
||||
//输入框一行
|
||||
maxLines: 1,
|
||||
controller: state.searchController,
|
||||
autofocus: false,
|
||||
onChanged: (value) {
|
||||
print("onChanged:$value");
|
||||
},
|
||||
onEditingComplete: () {
|
||||
print("onEditingComplete:");
|
||||
},
|
||||
onSubmitted: (value) {
|
||||
// 调用遥控列表
|
||||
|
||||
},
|
||||
decoration: InputDecoration(
|
||||
//输入里面输入文字内边距设置
|
||||
contentPadding: const EdgeInsets.only(
|
||||
top: 12.0, left: -19.0, right: -15.0, bottom: 8.0),
|
||||
hintText: TranslationLoader.lanKeys!.pleaseEnter!.tr,
|
||||
hintStyle: TextStyle(fontSize: 22.sp, height: 3.0),
|
||||
//不需要输入框下划线
|
||||
border: InputBorder.none,
|
||||
//左边图标设置
|
||||
icon: Padding(
|
||||
padding: EdgeInsets.only(
|
||||
top: 20.h, bottom: 20.h, right: 20.w, left: 10.w),
|
||||
child: Image.asset(
|
||||
'images/main/icon_main_search.png',
|
||||
width: 40.w,
|
||||
height: 40.w,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildMainUI() {
|
||||
String typeImgName = 'images/icon_card.png';
|
||||
|
||||
return const NoData();
|
||||
}
|
||||
|
||||
Widget _buildDeleteBtn(String idStr) {
|
||||
return GestureDetector(
|
||||
onTap: () {
|
||||
// 省略: 弹出是否删除的确认对话框。
|
||||
showIosTipViewDialog(context, idStr);
|
||||
},
|
||||
child: Container(
|
||||
width: 60,
|
||||
color: const Color(0xFFF20101),
|
||||
alignment: Alignment.center,
|
||||
child: const Text(
|
||||
'删除',
|
||||
style: TextStyle(
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.w500,
|
||||
color: Colors.white,
|
||||
height: 1,
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
void showIosTipViewDialog(BuildContext context, String keyId) {
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (BuildContext context) {
|
||||
return ShowIosTipView(
|
||||
title: "提示",
|
||||
tipTitle: "确定要删除吗?",
|
||||
sureClick: () async {
|
||||
// 遥控删除
|
||||
|
||||
},
|
||||
cancelClick: () {
|
||||
Get.back();
|
||||
},
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
Widget _keyItem(String lockTypeIcon, String lockTypeTitle, String showTime,
|
||||
Function() action) {
|
||||
return GestureDetector(
|
||||
onTap: action,
|
||||
child: Container(
|
||||
height: 90.h,
|
||||
// margin: EdgeInsets.only(left: 20.w, right: 20.w, top: 20.w),
|
||||
color: Colors.white,
|
||||
// decoration: BoxDecoration(
|
||||
// color: Colors.white,
|
||||
// // borderRadius: BorderRadius.circular(10.w),
|
||||
// ),
|
||||
child: Row(
|
||||
children: [
|
||||
SizedBox(width: 30.w),
|
||||
Image.asset(lockTypeIcon, width: 60.w, height: 60.w),
|
||||
SizedBox(width: 20.w),
|
||||
Expanded(
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
children: [
|
||||
Text(lockTypeTitle,
|
||||
style: TextStyle(
|
||||
fontSize: 24.sp, color: AppColors.blackColor)),
|
||||
],
|
||||
),
|
||||
SizedBox(height: 5.h),
|
||||
Container(
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
children: [
|
||||
Text(showTime,
|
||||
style: TextStyle(
|
||||
fontSize: 18.sp,
|
||||
color: AppColors.placeholderTextColor)),
|
||||
],
|
||||
),
|
||||
),
|
||||
SizedBox(width: 20.h),
|
||||
],
|
||||
),
|
||||
),
|
||||
SizedBox(width: 20.h),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
void showDeletAlertDialog(BuildContext context,) {
|
||||
showCupertinoDialog(
|
||||
context: context,
|
||||
builder: (context) {
|
||||
return CupertinoAlertDialog(
|
||||
title: const Text("提示"),
|
||||
content: const Text('重置后信息都会清除哦,确认要重置吗?'),
|
||||
actions: [
|
||||
CupertinoDialogAction(
|
||||
child: Text(TranslationLoader.lanKeys!.cancel!.tr),
|
||||
onPressed: () {
|
||||
Navigator.pop(context);
|
||||
},
|
||||
),
|
||||
CupertinoDialogAction(
|
||||
child: Text(TranslationLoader.lanKeys!.sure!.tr),
|
||||
onPressed: () {
|
||||
// 遥控重置
|
||||
|
||||
},
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,6 @@
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class FaceListState{
|
||||
final TextEditingController searchController = TextEditingController();
|
||||
}
|
||||
@ -0,0 +1,43 @@
|
||||
class AddFingerprintEntity {
|
||||
int? errorCode;
|
||||
String? description;
|
||||
String? errorMsg;
|
||||
Data? data;
|
||||
|
||||
AddFingerprintEntity(
|
||||
{this.errorCode, this.description, this.errorMsg, this.data});
|
||||
|
||||
AddFingerprintEntity.fromJson(Map<String, dynamic> json) {
|
||||
errorCode = json['errorCode'];
|
||||
description = json['description'];
|
||||
errorMsg = json['errorMsg'];
|
||||
data = json['data'] != null ? Data.fromJson(json['data']) : null;
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final Map<String, dynamic> data = <String, dynamic>{};
|
||||
data['errorCode'] = errorCode;
|
||||
data['description'] = description;
|
||||
data['errorMsg'] = errorMsg;
|
||||
if (this.data != null) {
|
||||
data['data'] = this.data!.toJson();
|
||||
}
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
||||
class Data {
|
||||
int? fingerprintId;
|
||||
|
||||
Data({this.fingerprintId});
|
||||
|
||||
Data.fromJson(Map<String, dynamic> json) {
|
||||
fingerprintId = json['fingerprintId'];
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final Map<String, dynamic> data = <String, dynamic>{};
|
||||
data['fingerprintId'] = fingerprintId;
|
||||
return data;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,365 @@
|
||||
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:flutter_reactive_ble/flutter_reactive_ble.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:get_storage/get_storage.dart';
|
||||
import 'package:star_lock/blue/io_type.dart';
|
||||
|
||||
import '../../../../../blue/blue_manage.dart';
|
||||
import '../../../../../blue/io_protocol/io_addFingerprint.dart';
|
||||
import '../../../../../blue/io_protocol/io_addStressFingerprint.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/eventBusEventManage.dart';
|
||||
import '../../../../../tools/storage.dart';
|
||||
import '../../../../../tools/toast.dart';
|
||||
import 'addFingerprint_state.dart';
|
||||
|
||||
class AddFingerprintLogic extends BaseGetXController {
|
||||
final AddFingerprintState state = AddFingerprintState();
|
||||
|
||||
// 监听设备返回的数据
|
||||
late StreamSubscription<Reply> _replySubscription;
|
||||
void _initReplySubscription() {
|
||||
_replySubscription = EventBusManager().eventBus!.on<Reply>().listen((reply) async {
|
||||
// 添加指纹开始
|
||||
if(reply is SenderAddFingerprintReply) {
|
||||
_replyAddFingerprintBegin(reply);
|
||||
}
|
||||
|
||||
// 添加指纹过程
|
||||
if(reply is SenderAddFingerprintProcessReply) {
|
||||
_replyAddFingerprintProcess(reply);
|
||||
}
|
||||
|
||||
// 添加指纹确认
|
||||
if(reply is SenderAddFingerprintConfirmationReply) {
|
||||
_replyAddFingerprintConfirmation(reply);
|
||||
}
|
||||
|
||||
// 添加胁迫指纹
|
||||
if(reply is SenderAddStressFingerprintReply) {
|
||||
_replyAddStressFingerprint(reply);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
Future<void> _replyAddFingerprintBegin(Reply reply) async {
|
||||
// var token = reply.data.sublist(2, 6);
|
||||
// var saveStrList = changeIntListToStringList(token);
|
||||
// print("_replyAddFingerprintReplyToken:$token");
|
||||
// Storage.setStringList(saveBlueToken, saveStrList);
|
||||
|
||||
int status = reply.data[2];
|
||||
print("status:$status");
|
||||
|
||||
switch(status){
|
||||
case 0x00:
|
||||
//成功
|
||||
print("${reply.commandType!.typeValue} 数据解析成功");
|
||||
state.ifConnectScuess.value = true;
|
||||
state.fingerprintNumber.value = reply.data.last.toString();
|
||||
break;
|
||||
case 0x06:
|
||||
//无权限
|
||||
print("${reply.commandType!.typeValue} 需要鉴权");
|
||||
var privateKey = await Storage.getStringList(saveBluePrivateKey);
|
||||
List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
|
||||
|
||||
var publicKey = await Storage.getStringList(saveBluePublicKey);
|
||||
List<int> publicKeyDataList = changeStringListToIntList(publicKey!);
|
||||
|
||||
var token = await Storage.getStringList(saveBlueToken);
|
||||
List<int> getTokenList = changeStringListToIntList(token!);
|
||||
|
||||
IoSenderManage.senderAddFingerprintCommand(
|
||||
keyID:"1",
|
||||
userID:await Storage.getUid(),
|
||||
fingerNo:1,
|
||||
useCountLimit:0xff,
|
||||
startTime:0x11223344,
|
||||
endTime:0x11223344,
|
||||
needAuthor:1,
|
||||
publicKey:publicKeyDataList,
|
||||
privateKey:getPrivateKeyList,
|
||||
token: getTokenList,
|
||||
);
|
||||
break;
|
||||
case 0x07:
|
||||
//无权限
|
||||
print("${reply.commandType!.typeValue} 用户无权限");
|
||||
|
||||
break;
|
||||
case 0x09:
|
||||
// 权限校验错误
|
||||
print("${reply.commandType!.typeValue} 权限校验错误");
|
||||
|
||||
break;
|
||||
default:
|
||||
//失败
|
||||
print("${reply.commandType!.typeValue} 失败");
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> _replyAddFingerprintProcess(Reply reply) async {
|
||||
var token = reply.data.sublist(2, 6);
|
||||
var saveStrList = changeIntListToStringList(token);
|
||||
print("_replyAddFingerprintReplyToken:$token");
|
||||
Storage.setStringList(saveBlueToken, saveStrList);
|
||||
|
||||
int status = reply.data[2];
|
||||
print("33 status:$status");
|
||||
|
||||
switch(status){
|
||||
case 0x00:
|
||||
//成功
|
||||
print("${reply.commandType!.typeValue} 数据解析成功");
|
||||
if(reply.data[5] == 255){
|
||||
// 注册指纹失败
|
||||
print("${reply.commandType!.typeValue} 注册指纹失败");
|
||||
Toast.show(msg: "添加失败");
|
||||
Get.close(2);
|
||||
}else{
|
||||
state.addFingerprintProcessNumber.value++;
|
||||
print("state.addFingerprintProcessNumber.value:${state.addFingerprintProcessNumber.value}");
|
||||
}
|
||||
break;
|
||||
case 0x06:
|
||||
//需要权限
|
||||
|
||||
break;
|
||||
case 0x07:
|
||||
//无权限
|
||||
print("${reply.commandType!.typeValue} 用户无权限");
|
||||
|
||||
break;
|
||||
case 0x09:
|
||||
// 权限校验错误
|
||||
print("${reply.commandType!.typeValue} 权限校验错误");
|
||||
|
||||
break;
|
||||
default:
|
||||
//失败
|
||||
print("${reply.commandType!.typeValue} 失败");
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> _replyAddFingerprintConfirmation(Reply reply) async {
|
||||
// var token = reply.data.sublist(2, 6);
|
||||
// var saveStrList = changeIntListToStringList(token);
|
||||
// print("_replyAddFingerprintReplyToken:$token");
|
||||
// Storage.setStringList(saveBlueToken, saveStrList);
|
||||
|
||||
int status = reply.data[2];
|
||||
print("status:$status");
|
||||
|
||||
switch(status){
|
||||
case 0x00:
|
||||
//成功
|
||||
print("${reply.commandType!.typeValue} 数据解析成功");
|
||||
// print("添加指纹确认成功,调用添加指纹接口");
|
||||
if(state.isCoerced.value == "2"){
|
||||
// 非胁迫指纹
|
||||
addFingerprintsData(reply.data[6].toString());
|
||||
}else{
|
||||
// 如果是胁迫指纹在 添加完之后以后再调用添加胁迫指纹的
|
||||
senderAddStressFingerprint();
|
||||
}
|
||||
break;
|
||||
case 0x06:
|
||||
//需要权限
|
||||
|
||||
break;
|
||||
case 0x07:
|
||||
//无权限
|
||||
print("${reply.commandType!.typeValue} 用户无权限");
|
||||
|
||||
break;
|
||||
case 0x09:
|
||||
// 权限校验错误
|
||||
print("${reply.commandType!.typeValue} 权限校验错误");
|
||||
|
||||
break;
|
||||
default:
|
||||
//失败
|
||||
print("${reply.commandType!.typeValue} 失败");
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> _replyAddStressFingerprint(Reply reply) async {
|
||||
// var token = reply.data.sublist(2, 6);
|
||||
// var saveStrList = changeIntListToStringList(token);
|
||||
// print("_replyAddFingerprintReplyToken:$token");
|
||||
// Storage.setStringList(saveBlueToken, saveStrList);
|
||||
|
||||
int status = reply.data[2];
|
||||
print("status:$status");
|
||||
|
||||
switch(status){
|
||||
case 0x00:
|
||||
//成功
|
||||
print("${reply.commandType!.typeValue} 数据解析成功");
|
||||
// print("添加指纹确认成功,调用添加指纹接口");
|
||||
addFingerprintsData(reply.data[6].toString());
|
||||
break;
|
||||
case 0x06:
|
||||
//需要权限
|
||||
|
||||
break;
|
||||
case 0x07:
|
||||
//无权限
|
||||
print("${reply.commandType!.typeValue} 用户无权限");
|
||||
|
||||
break;
|
||||
case 0x09:
|
||||
// 权限校验错误
|
||||
print("${reply.commandType!.typeValue} 权限校验错误");
|
||||
|
||||
break;
|
||||
default:
|
||||
//失败
|
||||
print("${reply.commandType!.typeValue} 失败");
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// 添加指纹开始
|
||||
Future<void> senderAddFingerprint() async {
|
||||
BlueManage().judgeReconnect(BlueManage().connectDeviceMacAddress, BlueManage().connectDeviceName, (DeviceConnectionState deviceConnectionState) async {
|
||||
if (deviceConnectionState == DeviceConnectionState.connected){
|
||||
var publicKey = await Storage.getStringList(saveBluePublicKey);
|
||||
List<int> publicKeyDataList = changeStringListToIntList(publicKey!);
|
||||
|
||||
var privateKey = await Storage.getStringList(saveBluePrivateKey);
|
||||
List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
|
||||
|
||||
var token = await Storage.getStringList(saveBlueToken);
|
||||
List<int> getTokenList = changeStringListToIntList(token!);
|
||||
print("openDoorTokenPubToken:$getTokenList state.startDate.value:${state.startDate.value}");
|
||||
|
||||
IoSenderManage.senderAddFingerprintCommand(
|
||||
keyID:"1",
|
||||
userID:await Storage.getUid(),
|
||||
fingerNo:1,
|
||||
useCountLimit:0xff,
|
||||
startTime:0x11223344,
|
||||
endTime:0x11223344,
|
||||
// startTime:int.parse(state.startDate.value)~/1000,
|
||||
// endTime:int.parse(state.endDate.value)~/1000,
|
||||
needAuthor:1,
|
||||
publicKey:publicKeyDataList,
|
||||
privateKey:getPrivateKeyList,
|
||||
token: getTokenList,
|
||||
);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// 添加胁迫指纹
|
||||
Future<void> senderAddStressFingerprint() async {
|
||||
BlueManage().judgeReconnect(BlueManage().connectDeviceMacAddress, BlueManage().connectDeviceName, (DeviceConnectionState deviceConnectionState) async {
|
||||
if (deviceConnectionState == DeviceConnectionState.connected){
|
||||
var publicKey = await Storage.getStringList(saveBluePublicKey);
|
||||
List<int> publicKeyDataList = changeStringListToIntList(publicKey!);
|
||||
|
||||
var privateKey = await Storage.getStringList(saveBluePrivateKey);
|
||||
List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
|
||||
|
||||
var token = await Storage.getStringList(saveBlueToken);
|
||||
List<int> getTokenList = changeStringListToIntList(token!);
|
||||
print("openDoorTokenPubToken:$getTokenList");
|
||||
|
||||
IoSenderManage.senderAddStressFingerprintCommand(
|
||||
keyID:"1",
|
||||
userID:await Storage.getUid(),
|
||||
fingerNo:1,
|
||||
useCountLimit:1,
|
||||
startTime:0x11223344,
|
||||
endTime:0x11223344,
|
||||
// startTime:int.parse(state.startDate.value)~/1000,
|
||||
// endTime:int.parse(state.endDate.value)~/1000,
|
||||
needAuthor:1,
|
||||
publicKey:publicKeyDataList,
|
||||
privateKey:getPrivateKeyList,
|
||||
token: getTokenList,
|
||||
);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// 添加指纹
|
||||
void addFingerprintsData(String fingerprintUserNo) async{
|
||||
var entity = await ApiRepository.to.addFingerprintsData(
|
||||
lockId: state.lockId.value.toString(),
|
||||
endDate: state.endDate.value,
|
||||
addType:state.addType.value,
|
||||
fingerprintName: state.fingerprintName.value,
|
||||
fingerprintNumber: "123456",
|
||||
fingerprintType: state.fingerprintType.value,
|
||||
isCoerced: state.isCoerced.value,
|
||||
startDate: state.startDate.value,
|
||||
weekDay: state.weekDay.value,
|
||||
);
|
||||
if(entity.errorCode!.codeIsSuccessful){
|
||||
Toast.show(msg: "添加成功");
|
||||
updateFingerprintUserNoLoadData(entity.data!.fingerprintId.toString(), fingerprintUserNo);
|
||||
}
|
||||
}
|
||||
|
||||
// 更新指纹用户账号
|
||||
void updateFingerprintUserNoLoadData(String fingerprintId, String fingerprintUserNo) async{
|
||||
var entity = await ApiRepository.to.updateFingerprintUserNoLoadData(
|
||||
fingerprintId: fingerprintId,
|
||||
lockId: state.lockId.value.toString(),
|
||||
fingerprintUserNo: fingerprintUserNo,
|
||||
);
|
||||
if(entity.errorCode!.codeIsSuccessful){
|
||||
Toast.show(msg: "添加成功");
|
||||
if(state.fromType.value == 2){
|
||||
// 回调指纹号
|
||||
eventBus.fire(ChickInAddStaffCardAndFingerprintBlockNumberEvent(fingerprintId));
|
||||
}else if(state.fromType.value == 1){
|
||||
eventBus.fire(OtherTypeRefreshListEvent());
|
||||
}
|
||||
Get.close(2);
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
void onReady() {
|
||||
// TODO: implement onReady
|
||||
super.onReady();
|
||||
|
||||
_initReplySubscription();
|
||||
}
|
||||
|
||||
@override
|
||||
void onInit() {
|
||||
// TODO: implement onInit
|
||||
super.onInit();
|
||||
|
||||
senderAddFingerprint();
|
||||
}
|
||||
|
||||
@override
|
||||
void onClose() {
|
||||
// TODO: implement onClose
|
||||
super.onClose();
|
||||
|
||||
_replySubscription.cancel();
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,141 @@
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
||||
import 'package:get/get.dart';
|
||||
|
||||
import '../../../../../appRouters.dart';
|
||||
import '../../../../../app_settings/app_colors.dart';
|
||||
import '../../../../../tools/submitBtn.dart';
|
||||
import '../../../../../tools/titleAppBar.dart';
|
||||
import '../../../../../translations/trans_lib.dart';
|
||||
import 'addFingerprint_logic.dart';
|
||||
|
||||
class AddFingerprintPage extends StatefulWidget {
|
||||
const AddFingerprintPage({Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
State<AddFingerprintPage> createState() => _AddFingerprintPageState();
|
||||
}
|
||||
|
||||
class _AddFingerprintPageState extends State<AddFingerprintPage> {
|
||||
final logic = Get.put(AddFingerprintLogic());
|
||||
final state = Get.find<AddFingerprintLogic>().state;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
backgroundColor: Colors.white,
|
||||
appBar: TitleAppBar(
|
||||
barTitle: TranslationLoader.lanKeys!.addLock!.tr,
|
||||
haveBack: true,
|
||||
backgroundColor: AppColors.mainColor),
|
||||
body: ListView(
|
||||
// mainAxisAlignment: MainAxisAlignment.center,
|
||||
// crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: [
|
||||
SizedBox(
|
||||
height: 50.h,
|
||||
),
|
||||
Obx(() => Visibility(
|
||||
visible:logic.state.ifConnectScuess.value,
|
||||
child: Container(
|
||||
padding: EdgeInsets.only(left: 20.w, right: 20.w),
|
||||
child: Column(
|
||||
children: [
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Expanded(
|
||||
child: Text(
|
||||
"请将您的手指按下",
|
||||
// TranslationLoader.lanKeys!.lightTouchScreenTip!.tr,
|
||||
textAlign: TextAlign.center,
|
||||
maxLines:null,
|
||||
style: TextStyle(fontSize: 24.sp, fontWeight: FontWeight.w600),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
SizedBox(height: 10.h),
|
||||
Text(
|
||||
"(${state.addFingerprintProcessNumber.value}/4)",
|
||||
// TranslationLoader.lanKeys!.lightTouchScreenTip!.tr,
|
||||
textAlign: TextAlign.center,
|
||||
maxLines:null,
|
||||
style: TextStyle(fontSize: 24.sp),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
)),
|
||||
Obx(() => Visibility(
|
||||
visible:!logic.state.ifConnectScuess.value,
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Expanded(
|
||||
child: Text(
|
||||
"尝试连接设备......",
|
||||
// TranslationLoader.lanKeys!.lightTouchScreenTip!.tr,
|
||||
textAlign: TextAlign.center,
|
||||
maxLines:null,
|
||||
style: TextStyle(fontSize: 24.sp, fontWeight: FontWeight.w600),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
)),
|
||||
SizedBox(
|
||||
height: 100.h,
|
||||
),
|
||||
Obx(() => Image.asset(
|
||||
getIconNumber(state.addFingerprintProcessNumber.value),
|
||||
width: 185.w,
|
||||
height: 295.h,
|
||||
),),
|
||||
SizedBox(
|
||||
height: 120.h,
|
||||
),
|
||||
Container(
|
||||
margin: EdgeInsets.all(10.w),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Expanded(
|
||||
child: Text(
|
||||
"根据提示,抬起手指后再进行下一次指纹采集",
|
||||
// TranslationLoader.lanKeys!.lightTouchScreenTip!.tr,
|
||||
textAlign: TextAlign.center,
|
||||
maxLines:null,
|
||||
style: TextStyle(fontSize: 24.sp),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
String getIconNumber(int number){
|
||||
switch(number){
|
||||
case 1:
|
||||
return 'images/main/icon_addFingerprint_fingerprint_two.png';
|
||||
break;
|
||||
case 2:
|
||||
return 'images/main/icon_addFingerprint_fingerprint_three.png';
|
||||
break;
|
||||
case 3:
|
||||
return 'images/main/icon_addFingerprint_fingerprint_four.png';
|
||||
break;
|
||||
case 4:
|
||||
return 'images/main/icon_addFingerprint_fingerprint_five.png';
|
||||
break;
|
||||
default:
|
||||
return 'images/main/icon_addFingerprint_fingerprint_one.png';
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,32 @@
|
||||
|
||||
import 'package:get/get.dart';
|
||||
|
||||
class AddFingerprintState{
|
||||
var ifConnectScuess = false.obs;
|
||||
var addFingerprintProcessNumber = 0.obs;
|
||||
final lockId = 0.obs;
|
||||
final endDate = "".obs;
|
||||
final addType = "".obs;
|
||||
final fingerprintName = "".obs;
|
||||
final fingerprintNumber = "".obs;
|
||||
final fingerprintType = "".obs;
|
||||
final isCoerced = "".obs;
|
||||
final startDate = "".obs;
|
||||
final weekDay = [].obs;
|
||||
final fromType = 1.obs;
|
||||
|
||||
AddFingerprintState() {
|
||||
Map map = Get.arguments;
|
||||
lockId.value = map["lockId"];
|
||||
endDate.value = map["endDate"];
|
||||
addType.value = map["addType"];
|
||||
fingerprintName.value = map["fingerprintName"];
|
||||
fingerprintNumber.value = map["fingerprintNumber"];
|
||||
fingerprintType.value = map["fingerprintType"];
|
||||
isCoerced.value = map["isCoerced"];
|
||||
startDate.value = map["startDate"];
|
||||
lockId.value = map["lockId"];
|
||||
weekDay.value = map["weekDay"];
|
||||
fromType.value = map["fromType"];
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,45 @@
|
||||
|
||||
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 'addFingerprintTypeManage_tabbar.dart';
|
||||
|
||||
class AddFingerprintTypeManagePage extends StatefulWidget {
|
||||
const AddFingerprintTypeManagePage({Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
State<AddFingerprintTypeManagePage> createState() => _AddFingerprintTypeManagePageState();
|
||||
}
|
||||
|
||||
class _AddFingerprintTypeManagePageState extends State<AddFingerprintTypeManagePage> {
|
||||
var index = 0;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
Map map = Get.arguments;
|
||||
var lockId = map["lockId"];
|
||||
var fromType = map["fromType"]; // 1从添加钥匙列表进入 2从考勤添加员工入口进入
|
||||
var fromTypeTwoStaffName = "";
|
||||
if(fromType == 2){
|
||||
fromTypeTwoStaffName = map["fromTypeTwoStaffName"]; // 从添加员工进入 传入员工名字
|
||||
}
|
||||
|
||||
return Scaffold(
|
||||
backgroundColor: AppColors.mainBackgroundColor,
|
||||
appBar: TitleAppBar(
|
||||
barTitle:
|
||||
"${TranslationLoader.lanKeys!.addTip!.tr}${TranslationLoader.lanKeys!.card!.tr}",
|
||||
haveBack: true,
|
||||
backgroundColor: AppColors.mainColor),
|
||||
body: Column(
|
||||
children: [
|
||||
AddFingerprintTypeManageTabbar(initialIndex: index, lockId: lockId, fromType: fromType, fromTypeTwoStaffName:fromTypeTwoStaffName),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@ -0,0 +1,108 @@
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
||||
import 'package:get/get.dart';
|
||||
|
||||
import '../../../../../app_settings/app_colors.dart';
|
||||
import '../../../../../tools/CustomUnderlineTabIndicator.dart';
|
||||
import '../../../../../translations/trans_lib.dart';
|
||||
import '../addFingerprintType_page.dart';
|
||||
|
||||
class AddFingerprintTypeManageTabbar extends StatefulWidget {
|
||||
var initialIndex = 1;
|
||||
var lockId = 0;
|
||||
var fromType = 0; // 1从添加钥匙列表进入 2从考勤添加员工入口进入
|
||||
var fromTypeTwoStaffName = "";// 从添加员工进入 传入员工名字
|
||||
|
||||
AddFingerprintTypeManageTabbar(
|
||||
{Key? key, required this.initialIndex, required this.lockId, required this.fromType, required this.fromTypeTwoStaffName}) : super(key: key);
|
||||
|
||||
@override
|
||||
State<AddFingerprintTypeManageTabbar> createState() => _AddFingerprintTypeManageTabbarState();
|
||||
}
|
||||
|
||||
class _AddFingerprintTypeManageTabbarState extends State<AddFingerprintTypeManageTabbar> with SingleTickerProviderStateMixin {
|
||||
late TabController _tabController;
|
||||
|
||||
final List<ItemView> _itemTabs = <ItemView>[
|
||||
ItemView(title: TranslationLoader.lanKeys!.permanent!.tr, seletType: "0"),
|
||||
ItemView(title: TranslationLoader.lanKeys!.timeLimit!.tr, seletType: "1"),
|
||||
ItemView(title: TranslationLoader.lanKeys!.circulation!.tr, seletType: "2"),
|
||||
];
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
// TODO: implement initState
|
||||
super.initState();
|
||||
|
||||
_tabController = TabController(
|
||||
vsync: this,
|
||||
length: _itemTabs.length,
|
||||
initialIndex: widget.initialIndex);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Expanded(
|
||||
child: Column(
|
||||
children: [
|
||||
_tabBar(),
|
||||
_pageWidget(),
|
||||
],
|
||||
));
|
||||
}
|
||||
|
||||
TabBar _tabBar() {
|
||||
return TabBar(
|
||||
controller: _tabController,
|
||||
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(
|
||||
child: SizedBox(
|
||||
width: 1.sw / 5,
|
||||
child: Text(item.title, textAlign: TextAlign.center)));
|
||||
}
|
||||
|
||||
Widget _pageWidget() {
|
||||
return Expanded(
|
||||
child: TabBarView(
|
||||
controller: _tabController,
|
||||
children: _itemTabs
|
||||
.map((ItemView item) => AddFingerprintTypePage(
|
||||
seletType: item.seletType,
|
||||
lockId: widget.lockId,
|
||||
fromType: widget.fromType,
|
||||
fromTypeTwoStaffName:widget.fromTypeTwoStaffName
|
||||
))
|
||||
.toList(),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class ItemView {
|
||||
const ItemView({required this.title, required this.seletType});
|
||||
|
||||
final String title;
|
||||
final String seletType;
|
||||
}
|
||||
@ -0,0 +1,87 @@
|
||||
|
||||
import 'package:get/get.dart';
|
||||
import 'package:star_lock/tools/baseGetXController.dart';
|
||||
import '../../../../appRouters.dart';
|
||||
import '../../../../tools/toast.dart';
|
||||
import 'addFingerprintType_state.dart';
|
||||
|
||||
class AddFingerprintTypeLogic extends BaseGetXController{
|
||||
AddFingerprintState state = AddFingerprintState();
|
||||
|
||||
// 添加指纹
|
||||
void addFingerprintsData() async {
|
||||
var fingerprintType = 0; // 永久:1;限时2,单次3,循环:4
|
||||
var startDate = "";
|
||||
var endDate = "";
|
||||
if (state.seletType.value == "0") {
|
||||
fingerprintType = 1;
|
||||
} else if (state.seletType.value == "1") {
|
||||
fingerprintType = 2;
|
||||
if (state.beginTimeTimestamp.value.isEmpty) {
|
||||
Toast.show(msg: "请选择开始时间");
|
||||
return;
|
||||
}
|
||||
if (state.endTimeTimestamp.value.isEmpty) {
|
||||
Toast.show(msg: "请选择开始时间");
|
||||
return;
|
||||
}
|
||||
|
||||
// if(DateTime.now().millisecondsSinceEpoch > int.parse(state.beginTimeTimestamp.value)){
|
||||
// Toast.show(msg: "生效时间要大于当前时间");
|
||||
// return;
|
||||
// }
|
||||
|
||||
if (int.parse(state.beginTimeTimestamp.value) >=
|
||||
int.parse(state.endTimeTimestamp.value)) {
|
||||
Toast.show(msg: "失效时间要大于生效时间");
|
||||
return;
|
||||
}
|
||||
|
||||
startDate = state.beginTimeTimestamp.value;
|
||||
endDate = state.endTimeTimestamp.value;
|
||||
} else if (state.seletType.value == "2") {
|
||||
if (state.effectiveDateTime.value <= 0) {
|
||||
Toast.show(msg: "请选择生效时间");
|
||||
return;
|
||||
}
|
||||
if (state.failureDateTime.value <= 0) {
|
||||
Toast.show(msg: "请选择失效时间");
|
||||
return;
|
||||
}
|
||||
|
||||
if (state.weekdaysList.value.isEmpty) {
|
||||
Toast.show(msg: "请选择有效日");
|
||||
return;
|
||||
}
|
||||
|
||||
// if(DateTime.now().millisecondsSinceEpoch >= state.effectiveDateTime.value){
|
||||
// Toast.show(msg: "生效时间要大于当前时间");
|
||||
// return;
|
||||
// }
|
||||
|
||||
if (state.effectiveDateTime.value >= state.failureDateTime.value) {
|
||||
Toast.show(msg: "失效时间要大于生效时间");
|
||||
return;
|
||||
}
|
||||
startDate = state.effectiveDateTime.value.toString();
|
||||
endDate = state.failureDateTime.value.toString();
|
||||
fingerprintType = 4;
|
||||
}
|
||||
|
||||
print("addOtherType startDate:$startDate endDate:$endDate");
|
||||
// 指纹
|
||||
Get.toNamed(Routers.addFingerprintPage, arguments: {
|
||||
"lockId": state.lockId.value,
|
||||
"endDate": endDate,
|
||||
"addType": "1",
|
||||
"fingerprintName": state.nameController.text,
|
||||
"fingerprintNumber": "123456",
|
||||
"fingerprintType": fingerprintType.toString(),
|
||||
"isCoerced": state.isStressFingerprint.value ? "1" : "2",
|
||||
"startDate": startDate,
|
||||
"weekDay": state.weekdaysList.value,
|
||||
"fromType": state.fromType.value,
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,304 @@
|
||||
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_pickers/pickers.dart';
|
||||
import 'package:flutter_pickers/time_picker/model/date_mode.dart';
|
||||
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
||||
import 'package:get/get.dart';
|
||||
|
||||
import '../../../../appRouters.dart';
|
||||
import '../../../../app_settings/app_colors.dart';
|
||||
import '../../../../tools/commonItem.dart';
|
||||
import '../../../../tools/storage.dart';
|
||||
import '../../../../tools/submitBtn.dart';
|
||||
import '../../../../tools/toast.dart';
|
||||
import '../../../../translations/trans_lib.dart';
|
||||
import 'addFingerprintType_logic.dart';
|
||||
|
||||
class AddFingerprintTypePage extends StatefulWidget {
|
||||
final String seletType;// 永久限时循环下标
|
||||
final int lockId;
|
||||
final int fromType;// // 1从添加钥匙列表进入 2从考勤添加员工入口进入
|
||||
final String fromTypeTwoStaffName;// 从添加员工进入 传入员工名字
|
||||
|
||||
const AddFingerprintTypePage({Key? key, required this.seletType, required this.lockId, required this.fromType, required this.fromTypeTwoStaffName}) : super(key: key);
|
||||
|
||||
@override
|
||||
State<AddFingerprintTypePage> createState() => _AddFingerprintTypePageState();
|
||||
}
|
||||
|
||||
class _AddFingerprintTypePageState extends State<AddFingerprintTypePage> {
|
||||
final logic = Get.put(AddFingerprintTypeLogic());
|
||||
final state = Get.find<AddFingerprintTypeLogic>().state;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
state.seletType.value = widget.seletType;
|
||||
state.lockId.value = widget.lockId;
|
||||
// state.nameController.text = widget.fromTypeTwoStaffName;
|
||||
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
// Your code here
|
||||
});
|
||||
return indexChangeWidget();
|
||||
}
|
||||
|
||||
Widget indexChangeWidget() {
|
||||
switch (int.parse(widget.seletType)) {
|
||||
case 0:
|
||||
{
|
||||
// 永久
|
||||
// return sendElectronicKeySucceed();
|
||||
return Column(
|
||||
children: [
|
||||
perpetualKeyWidget(TranslationLoader.lanKeys!.name!.tr, TranslationLoader.lanKeys!.pleaseEnter!.tr, state.nameController),
|
||||
keyBottomWidget()
|
||||
],
|
||||
);
|
||||
}
|
||||
case 1:
|
||||
{
|
||||
// 限时
|
||||
return Column(
|
||||
children: [
|
||||
perpetualKeyWidget(TranslationLoader.lanKeys!.name!.tr, TranslationLoader.lanKeys!.pleaseEnter!.tr, state.nameController),
|
||||
keyTimeLimitWidget(),
|
||||
SizedBox(height: 10.h),
|
||||
keyBottomWidget()
|
||||
],
|
||||
);
|
||||
}
|
||||
case 2:
|
||||
{
|
||||
// 循环
|
||||
return Column(
|
||||
children: [
|
||||
perpetualKeyWidget(TranslationLoader.lanKeys!.name!.tr,
|
||||
TranslationLoader.lanKeys!.pleaseEnter!.tr, state.nameController),
|
||||
CommonItem(
|
||||
leftTitel: TranslationLoader.lanKeys!.periodValidity!.tr,
|
||||
rightTitle: "",
|
||||
isHaveDirection: true,
|
||||
action: () async {
|
||||
Map result = await Get.toNamed(Routers.electronicKeyPeriodValidityPage);
|
||||
state.weekdaysList.value = result['validityValue'];
|
||||
state.effectiveDateTime.value = result['starDate'].millisecondsSinceEpoch;
|
||||
state.failureDateTime.value = result['endDate'].millisecondsSinceEpoch;
|
||||
print('得到的有效期数据:${state.weekdaysList.value} == ${state.effectiveDateTime.value} == ${state.failureDateTime.value}');
|
||||
}),
|
||||
SizedBox(height: 10.h),
|
||||
keyBottomWidget()
|
||||
],
|
||||
);
|
||||
}
|
||||
default:
|
||||
return Container();
|
||||
}
|
||||
}
|
||||
|
||||
// 密码命名输入框
|
||||
Widget perpetualKeyWidget(
|
||||
String titleStr, String rightTitle, TextEditingController controller) {
|
||||
return Column(
|
||||
children: [
|
||||
Container(height: 10.h),
|
||||
CommonItem(
|
||||
leftTitel: titleStr,
|
||||
rightTitle: "",
|
||||
isHaveRightWidget: true,
|
||||
rightWidget: getTFWidget(rightTitle)),
|
||||
Container(height: 10.h),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
// 限时顶部选择日期
|
||||
Widget keyTimeLimitWidget() {
|
||||
return Column(
|
||||
children: [
|
||||
Obx(() => CommonItem(
|
||||
leftTitel: TranslationLoader.lanKeys!.effectiveTime!.tr,
|
||||
rightTitle: state.beginTime.value,
|
||||
isHaveLine: true,
|
||||
isHaveDirection: true,
|
||||
action: () async {
|
||||
Pickers.showDatePicker(context, mode: DateMode.YMDHM,
|
||||
onConfirm: (p) {
|
||||
setState(() {
|
||||
setState(() {
|
||||
state.beginTime.value = '${p.year}-${p.month!.toString().padLeft(2,'0')}-${p.day!.toString().padLeft(2,'0')} ${p.hour!.toString().padLeft(2,'0')}:${p.minute!.toString().padLeft(2,'0')}';
|
||||
state.beginTimeTimestamp.value = DateTime.parse(state.beginTime.value).millisecondsSinceEpoch.toString();
|
||||
});
|
||||
});
|
||||
});
|
||||
})),
|
||||
Obx(() => CommonItem(
|
||||
leftTitel: TranslationLoader.lanKeys!.failureTime!.tr,
|
||||
rightTitle: state.endTime.value,
|
||||
isHaveDirection: true,
|
||||
action: () {
|
||||
Pickers.showDatePicker(context, mode: DateMode.YMDHM,
|
||||
onConfirm: (p) {
|
||||
setState(() {
|
||||
setState(() {
|
||||
state.endTime.value = '${p.year}-${p.month!.toString().padLeft(2,'0')}-${p.day!.toString().padLeft(2,'0')} ${p.hour!.toString().padLeft(2,'0')}:${p.minute!.toString().padLeft(2,'0')}';
|
||||
state.endTimeTimestamp.value = DateTime.parse(state.endTime.value).millisecondsSinceEpoch.toString();
|
||||
});
|
||||
});
|
||||
});
|
||||
})),
|
||||
Container(height: 10.h),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
Widget keyBottomWidget() {
|
||||
return Column(
|
||||
children: [
|
||||
CommonItem(
|
||||
leftTitel: TranslationLoader.lanKeys!.stressFingerprint!.tr,
|
||||
rightTitle: "",
|
||||
isTipsImg: false,
|
||||
isHaveRightWidget: true,
|
||||
rightWidget: SizedBox(
|
||||
width: 60.w, height: 50.h, child: _isStressFingerprint())),
|
||||
SizedBox(height: 30.h),
|
||||
SubmitBtn(btnName: TranslationLoader.lanKeys!.next!.tr, onClick: () async {
|
||||
|
||||
var isDemoMode = await Storage.getBool(ifIsDemoModeOrNot);
|
||||
if(isDemoMode == false){
|
||||
// print("state.seletType:${state.seletType.value}");
|
||||
if(state.nameController.text.isEmpty){
|
||||
Toast.show(msg: "请输入姓名");
|
||||
return;
|
||||
}
|
||||
|
||||
logic.addFingerprintsData();
|
||||
}else{
|
||||
// Get.toNamed(Routers.seletLockTypePage);
|
||||
Toast.show(msg: "演示模式");
|
||||
}
|
||||
|
||||
}),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
// 发送电子钥匙成功
|
||||
Widget sendElectronicKeySucceed() {
|
||||
return Column(
|
||||
children: [
|
||||
Container(
|
||||
height: 300.h,
|
||||
width: 1.sw,
|
||||
color: Colors.white,
|
||||
child: Column(
|
||||
children: [
|
||||
SizedBox(
|
||||
height: 30.h,
|
||||
),
|
||||
Image.asset(
|
||||
'images/main/icon_main_addLock.png',
|
||||
width: 150.w,
|
||||
height: 150.w,
|
||||
color: AppColors.mainColor,
|
||||
),
|
||||
SizedBox(
|
||||
height: 20.h,
|
||||
),
|
||||
Text(
|
||||
"操作成功,密码为",
|
||||
style: TextStyle(
|
||||
fontSize: 32.sp,
|
||||
color: Colors.black,
|
||||
fontWeight: FontWeight.w500),
|
||||
),
|
||||
SizedBox(
|
||||
height: 10.h,
|
||||
),
|
||||
Text(
|
||||
"62689876",
|
||||
style: TextStyle(
|
||||
fontSize: 60.sp,
|
||||
color: Colors.black,
|
||||
fontWeight: FontWeight.w500),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
SizedBox(
|
||||
height: 20.h,
|
||||
),
|
||||
SubmitBtn(
|
||||
btnName: '完成',
|
||||
fontSize: 28.sp,
|
||||
borderRadius: 20.w,
|
||||
margin: EdgeInsets.only(left: 30.w, right: 30.w, top: 30.w),
|
||||
padding: EdgeInsets.only(top: 25.w, bottom: 25.w),
|
||||
onClick: () {}),
|
||||
SubmitBtn(
|
||||
btnName: '分享',
|
||||
fontSize: 28.sp,
|
||||
borderRadius: 20.w,
|
||||
margin: EdgeInsets.only(left: 30.w, right: 30.w, top: 30.w),
|
||||
padding: EdgeInsets.only(top: 25.w, bottom: 25.w),
|
||||
onClick: () {}),
|
||||
SubmitBtn(
|
||||
btnName: '标记为:已入住',
|
||||
fontSize: 28.sp,
|
||||
borderRadius: 20.w,
|
||||
margin: EdgeInsets.only(left: 30.w, right: 30.w, top: 30.w),
|
||||
padding: EdgeInsets.only(top: 25.w, bottom: 25.w),
|
||||
onClick: () {}),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
// 接受者信息输入框
|
||||
Widget getTFWidget(String tfStr) {
|
||||
return Container(
|
||||
height: 50.h,
|
||||
width: 300.w,
|
||||
child: Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: TextField(
|
||||
//输入框一行
|
||||
maxLines: 1,
|
||||
controller: state.nameController,
|
||||
autofocus: false,
|
||||
textAlign: TextAlign.end,
|
||||
decoration: InputDecoration(
|
||||
//输入里面输入文字内边距设置
|
||||
contentPadding: const EdgeInsets.only(top: 12.0, bottom: 8.0),
|
||||
hintText: tfStr,
|
||||
hintStyle: TextStyle(fontSize: 24.sp),
|
||||
//不需要输入框下划线
|
||||
border: InputBorder.none,
|
||||
),
|
||||
),
|
||||
),
|
||||
SizedBox(
|
||||
width: 10.w,
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
//isStressFingerprint false:不是胁迫指纹 ture:胁迫指纹
|
||||
CupertinoSwitch _isStressFingerprint() {
|
||||
return CupertinoSwitch(
|
||||
activeColor: CupertinoColors.activeBlue,
|
||||
trackColor: CupertinoColors.systemGrey5,
|
||||
thumbColor: CupertinoColors.white,
|
||||
value: state.isStressFingerprint.value,
|
||||
onChanged: (value) {
|
||||
setState(() {
|
||||
state.isStressFingerprint.value = value;
|
||||
});
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,26 @@
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
|
||||
class AddFingerprintState{
|
||||
final lockId = 0.obs;
|
||||
final seletType = "0".obs;// 0永久 1显示 2循环
|
||||
final fromType = 1.obs; // // 1从添加钥匙列表进入 2从考勤添加员工入口进入
|
||||
final isStressFingerprint = false.obs;
|
||||
|
||||
var beginTime = "".obs;// 开始时间
|
||||
var endTime = "".obs;// 结束时间
|
||||
var beginTimeTimestamp = "".obs;// 开始时间时间戳
|
||||
var endTimeTimestamp = "".obs;// 结束时间时间戳
|
||||
|
||||
var effectiveDateTime = 0.obs;// 生效时间
|
||||
var failureDateTime = 0.obs;// 失效时间
|
||||
var weekdaysList = [].obs;
|
||||
|
||||
final TextEditingController nameController = TextEditingController();
|
||||
AddFingerprintState() {
|
||||
// Map map = Get.arguments;
|
||||
// lockId.value = map["lockId"];
|
||||
// fromType.value = map["fromType"];
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,9 @@
|
||||
|
||||
|
||||
import 'package:star_lock/tools/baseGetXController.dart';
|
||||
|
||||
import 'addFingerprintTip_state.dart';
|
||||
|
||||
class AddFingerprintTipLogic extends BaseGetXController{
|
||||
AddFingerprintTipState state = AddFingerprintTipState();
|
||||
}
|
||||
@ -0,0 +1,91 @@
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
||||
import 'package:get/get.dart';
|
||||
|
||||
import '../../../../../appRouters.dart';
|
||||
import '../../../../../app_settings/app_colors.dart';
|
||||
import '../../../../../tools/submitBtn.dart';
|
||||
import '../../../../../tools/titleAppBar.dart';
|
||||
import '../../../../../translations/trans_lib.dart';
|
||||
import 'addFingerprintTip_logic.dart';
|
||||
|
||||
class AddFingerprintTipPage extends StatefulWidget {
|
||||
const AddFingerprintTipPage({Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
State<AddFingerprintTipPage> createState() => _AddFingerprintTipPageState();
|
||||
}
|
||||
|
||||
class _AddFingerprintTipPageState extends State<AddFingerprintTipPage> {
|
||||
final logic = Get.put(AddFingerprintTipLogic());
|
||||
final state = Get.find<AddFingerprintTipLogic>().state;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
backgroundColor: Colors.white,
|
||||
appBar: TitleAppBar(
|
||||
barTitle: TranslationLoader.lanKeys!.addLock!.tr,
|
||||
haveBack: true,
|
||||
backgroundColor: AppColors.mainColor),
|
||||
body: ListView(
|
||||
// mainAxisAlignment: MainAxisAlignment.center,
|
||||
// crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: [
|
||||
SizedBox(
|
||||
height: 50.h,
|
||||
),
|
||||
Container(
|
||||
padding: EdgeInsets.only(left: 20.w, right: 20.w),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Expanded(
|
||||
child: Text(
|
||||
"添加过程中,请根据提示,在指纹采集器上进行多次的抬起按压",
|
||||
// TranslationLoader.lanKeys!.lightTouchScreenTip!.tr,
|
||||
textAlign: TextAlign.center,
|
||||
maxLines:null,
|
||||
style: TextStyle(fontSize: 24.sp, fontWeight: FontWeight.w600),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
SizedBox(
|
||||
height: 60.h,
|
||||
),
|
||||
Image.asset(
|
||||
'images/main/icon_addFingerprintTip.png',
|
||||
width: 270.w,
|
||||
height: 457.h,
|
||||
),
|
||||
SizedBox(
|
||||
height: 120.h,
|
||||
),
|
||||
Container(
|
||||
padding: EdgeInsets.only(left: 20.w, right: 20.w),
|
||||
child: SubmitBtn(
|
||||
btnName: "开始添加",//TranslationLoader.lanKeys!.next!.tr,
|
||||
borderRadius: 20.w,
|
||||
onClick: () {
|
||||
Get.toNamed(Routers.addFingerprintPage, arguments: {
|
||||
"lockId": state.lockId.value,
|
||||
"endDate": state.endDate.value,
|
||||
"addType": state.addType.value,
|
||||
"fingerprintName": state.fingerprintName.value,
|
||||
"fingerprintNumber": state.fingerprintNumber.value,
|
||||
"fingerprintType": state.fingerprintType.value,
|
||||
"isCoerced": state.isCoerced.value,
|
||||
"startDate": state.startDate.value,
|
||||
"weekDay": state.weekDay.value,
|
||||
"fromType": state.fromType.value,
|
||||
});
|
||||
}),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,30 @@
|
||||
|
||||
import 'package:get/get.dart';
|
||||
|
||||
class AddFingerprintTipState{
|
||||
final lockId = 0.obs;
|
||||
final endDate = "".obs;
|
||||
final addType = "".obs;
|
||||
final fingerprintName = "".obs;
|
||||
final fingerprintNumber = "".obs;
|
||||
final fingerprintType = "".obs;
|
||||
final isCoerced = "".obs;
|
||||
final startDate = "".obs;
|
||||
final weekDay = [].obs;
|
||||
final fromType = 1.obs;
|
||||
|
||||
AddFingerprintTipState() {
|
||||
Map map = Get.arguments;
|
||||
lockId.value = map["lockId"];
|
||||
endDate.value = map["endDate"];
|
||||
addType.value = map["addType"];
|
||||
fingerprintName.value = map["fingerprintName"];
|
||||
fingerprintNumber.value = map["fingerprintNumber"];
|
||||
fingerprintType.value = map["fingerprintType"];
|
||||
isCoerced.value = map["isCoerced"];
|
||||
startDate.value = map["startDate"];
|
||||
lockId.value = map["lockId"];
|
||||
weekDay.value = map["weekDay"];
|
||||
fromType.value = map["fromType"];
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,172 @@
|
||||
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:flutter_reactive_ble/flutter_reactive_ble.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:star_lock/blue/io_type.dart';
|
||||
import 'package:star_lock/tools/baseGetXController.dart';
|
||||
import '../../../../blue/blue_manage.dart';
|
||||
import '../../../../blue/io_protocol/io_addFingerprint.dart';
|
||||
import '../../../../blue/io_reply.dart';
|
||||
import '../../../../blue/io_tool/io_tool.dart';
|
||||
import '../../../../blue/io_tool/manager_event_bus.dart';
|
||||
import '../../../../blue/sender_manage.dart';
|
||||
import '../../../../network/api_repository.dart';
|
||||
import '../../../../tools/eventBusEventManage.dart';
|
||||
import '../../../../tools/storage.dart';
|
||||
import '../../../../tools/toast.dart';
|
||||
import 'fingerprintDetail_state.dart';
|
||||
|
||||
class FingerprintDetailLogic extends BaseGetXController{
|
||||
FingerprintDetailState state = FingerprintDetailState();
|
||||
|
||||
// 获取解析后的数据
|
||||
late StreamSubscription<Reply> _replySubscription;
|
||||
void _initReplySubscription() {
|
||||
_replySubscription = EventBusManager().eventBus!.on<Reply>().listen((reply) {
|
||||
// 添加指纹开始(此处用作删除指纹)
|
||||
if((reply is SenderAddFingerprintReply)) {
|
||||
_replyAddFingerprintBegin(reply);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// 添加指纹开始
|
||||
Future<void> _replyAddFingerprintBegin(Reply reply) async {
|
||||
|
||||
int status = reply.data[2];
|
||||
print("status:$status");
|
||||
|
||||
switch(status){
|
||||
case 0x00:
|
||||
//成功
|
||||
print("${reply.commandType!.typeValue} 数据解析成功");
|
||||
deletFingerprintsData();
|
||||
break;
|
||||
case 0x06:
|
||||
//无权限
|
||||
print("${reply.commandType!.typeValue} 需要鉴权");
|
||||
var privateKey = await Storage.getStringList(saveBluePrivateKey);
|
||||
List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
|
||||
|
||||
var publicKey = await Storage.getStringList(saveBluePublicKey);
|
||||
List<int> publicKeyDataList = changeStringListToIntList(publicKey!);
|
||||
|
||||
var token = await Storage.getStringList(saveBlueToken);
|
||||
List<int> getTokenList = changeStringListToIntList(token!);
|
||||
|
||||
IoSenderManage.senderAddFingerprintCommand(
|
||||
keyID:"1",
|
||||
userID:"DeleteAll!@#",
|
||||
fingerNo:255,
|
||||
useCountLimit:0,
|
||||
startTime:0x11223344,
|
||||
endTime:0x11223344,
|
||||
needAuthor:1,
|
||||
publicKey:publicKeyDataList,
|
||||
privateKey:getPrivateKeyList,
|
||||
token: getTokenList,
|
||||
);
|
||||
break;
|
||||
case 0x07:
|
||||
//无权限
|
||||
print("${reply.commandType!.typeValue} 用户无权限");
|
||||
|
||||
break;
|
||||
case 0x09:
|
||||
// 权限校验错误
|
||||
print("${reply.commandType!.typeValue} 权限校验错误");
|
||||
|
||||
break;
|
||||
default:
|
||||
//失败
|
||||
print("${reply.commandType!.typeValue} 失败");
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// 删除指纹
|
||||
Future<void> senderAddFingerprint(String keyId, String userID, int cardNo) async {
|
||||
BlueManage().judgeReconnect(BlueManage().connectDeviceMacAddress, BlueManage().connectDeviceName, (DeviceConnectionState deviceConnectionState) async {
|
||||
if (deviceConnectionState == DeviceConnectionState.connected){
|
||||
var publicKey = await Storage.getStringList(saveBluePublicKey);
|
||||
List<int> publicKeyDataList = changeStringListToIntList(publicKey!);
|
||||
|
||||
var privateKey = await Storage.getStringList(saveBluePrivateKey);
|
||||
List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
|
||||
|
||||
var token = await Storage.getStringList(saveBlueToken);
|
||||
List<int> getTokenList = changeStringListToIntList(token!);
|
||||
|
||||
IoSenderManage.senderAddFingerprintCommand(
|
||||
keyID:keyId,
|
||||
userID:userID,
|
||||
fingerNo:cardNo,
|
||||
useCountLimit:0,
|
||||
startTime:0x11223344,
|
||||
endTime:0x11223344,
|
||||
needAuthor:1,
|
||||
publicKey:publicKeyDataList,
|
||||
privateKey:getPrivateKeyList,
|
||||
token: getTokenList,
|
||||
);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
// 编辑指纹
|
||||
void editFingerprintsData() async{
|
||||
var entity = await ApiRepository.to.editFingerprintsData(
|
||||
fingerprintId: state.keyId.value.toString(),
|
||||
lockId: state.fingerprintItemData.value.lockId.toString(),
|
||||
weekDay: state.weekDay.value,
|
||||
startDate: state.effectiveDateTime.value.toString(),
|
||||
endDate: state.failureDateTime.value.toString(),
|
||||
isCoerced: state.isStressFingerprint.value ? "2" : "1",
|
||||
fingerprintName: state.changeNameController.text,
|
||||
);
|
||||
if(entity.errorCode!.codeIsSuccessful){
|
||||
Toast.show(msg: "修改成功");
|
||||
Get.back(result: "addScuess");
|
||||
}
|
||||
}
|
||||
|
||||
// 删除指纹
|
||||
void deletFingerprintsData() async{
|
||||
var entity = await ApiRepository.to.deletFingerprintsData(
|
||||
fingerprintId: state.fingerprintItemData.value.fingerprintId.toString(),
|
||||
lockId: state.fingerprintItemData.value.lockId.toString(),
|
||||
type: "0",
|
||||
deleteType:"1"
|
||||
);
|
||||
if(entity.errorCode!.codeIsSuccessful){
|
||||
Toast.show(msg: "删除成功");
|
||||
Get.back(result: "addScuess");
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
void onReady() {
|
||||
// TODO: implement onReady
|
||||
super.onReady();
|
||||
|
||||
_initReplySubscription();
|
||||
}
|
||||
|
||||
@override
|
||||
void onInit() {
|
||||
// TODO: implement onInit
|
||||
super.onInit();
|
||||
|
||||
}
|
||||
|
||||
@override
|
||||
void onClose() {
|
||||
// TODO: implement onClose
|
||||
super.onClose();
|
||||
|
||||
_replySubscription.cancel();
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,324 @@
|
||||
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
||||
import 'package:get/get.dart';
|
||||
|
||||
import '../../../../appRouters.dart';
|
||||
import '../../../../app_settings/app_colors.dart';
|
||||
import '../../../../tools/commonItem.dart';
|
||||
import '../../../../tools/dateTool.dart';
|
||||
import '../../../../tools/showIosTipView.dart';
|
||||
import '../../../../tools/showTFView.dart';
|
||||
import '../../../../tools/submitBtn.dart';
|
||||
import '../../../../tools/titleAppBar.dart';
|
||||
import '../../../../tools/toast.dart';
|
||||
import '../../../../translations/trans_lib.dart';
|
||||
import 'fingerprintDetail_logic.dart';
|
||||
|
||||
class FingerprintDetailPage extends StatefulWidget {
|
||||
const FingerprintDetailPage({Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
State<FingerprintDetailPage> createState() => _FingerprintDetailPageState();
|
||||
}
|
||||
|
||||
class _FingerprintDetailPageState extends State<FingerprintDetailPage> {
|
||||
final logic = Get.put(FingerprintDetailLogic());
|
||||
final state = Get.find<FingerprintDetailLogic>().state;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
backgroundColor: AppColors.mainBackgroundColor,
|
||||
appBar: TitleAppBar(
|
||||
barTitle: "${TranslationLoader.lanKeys!.fingerprint!.tr}${TranslationLoader.lanKeys!.number!.tr}",
|
||||
haveBack: true,
|
||||
backgroundColor: AppColors.mainColor,
|
||||
// actionsList: [
|
||||
// TextButton(
|
||||
// child: Text(TranslationLoader.lanKeys!.share!.tr, style: TextStyle(color: Colors.white, fontSize: 24.sp),),
|
||||
// onPressed: () {
|
||||
//
|
||||
// },
|
||||
// ),
|
||||
// ],
|
||||
),
|
||||
body: Column(
|
||||
children: [
|
||||
Obx(() => CommonItem(
|
||||
leftTitel: "${TranslationLoader.lanKeys!.fingerprint!.tr}${TranslationLoader.lanKeys!.number!.tr}",
|
||||
rightTitle: state.typeNumber.value,
|
||||
isHaveDirection: false,
|
||||
isHaveLine: true)),
|
||||
Obx(() => CommonItem(
|
||||
leftTitel: TranslationLoader.lanKeys!.name!.tr,
|
||||
rightTitle: state.typeName.value,
|
||||
isHaveDirection: true,
|
||||
isHaveLine: true,
|
||||
action: () {
|
||||
showCupertinoAlertDialog(context);
|
||||
})),
|
||||
Obx(() => Visibility(
|
||||
visible: (state.keyType.value == 4 || state.keyType.value == 2) ? true : false,
|
||||
child: CommonItem(
|
||||
leftTitel: TranslationLoader.lanKeys!.periodValidity!.tr,
|
||||
allHeight: 70.h,
|
||||
// rightTitle:"2023.09.19 11:27\n2023.09.25 11:27",
|
||||
rightTitle: state.keyType.value == 1 ? "永久" : "${DateTool().dateToYMDHNString(state.effectiveDateTime.value.toString())}\n${DateTool().dateToYMDHNString(state.failureDateTime.value.toString())}",
|
||||
isHaveDirection: true,
|
||||
isHaveLine: true,
|
||||
action: () async {
|
||||
// switch(state.type.value){
|
||||
// case 0:
|
||||
// // 卡
|
||||
//
|
||||
// break;
|
||||
// case 1:
|
||||
// 当是指纹的时候
|
||||
if(state.keyType.value == 2){
|
||||
// 限时
|
||||
var data = await Get.toNamed(Routers.otherTypeKeyChangeDatePage, arguments: {
|
||||
"fingerprintItemData": state.fingerprintItemData.value,
|
||||
});
|
||||
if(data != null) {
|
||||
setState(() {
|
||||
state.effectiveDateTime.value = data["beginTimeTimestamp"];
|
||||
state.failureDateTime.value = data["endTimeTimestamp"];
|
||||
});
|
||||
}
|
||||
}else if(state.keyType.value == 4){
|
||||
// 循环
|
||||
var data = await Get.toNamed(Routers.otherTypeKeyChangeValidityDatePage, arguments: {
|
||||
"fingerprintItemData": state.fingerprintItemData.value,
|
||||
});
|
||||
if(data != null) {
|
||||
setState(() {
|
||||
state.effectiveDateTime.value = data["beginTimeTimestamp"];
|
||||
state.failureDateTime.value = data["endTimeTimestamp"];
|
||||
state.weekDay.value = data["weekDay"];
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
}))),
|
||||
Obx(() => Visibility(
|
||||
visible: state.keyType.value == 4 ? true : false,
|
||||
child: Obx(() => CommonItem(
|
||||
leftTitel: TranslationLoader.lanKeys!.effectiveDay!.tr,
|
||||
rightTitle: state.weekDay.value.join(','),
|
||||
isHaveDirection: true,
|
||||
action: () async {
|
||||
// 当是指纹的时候
|
||||
var data = await Get.toNamed(Routers.otherTypeKeyChangeValidityDatePage, arguments: {
|
||||
"fingerprintItemData": state.fingerprintItemData.value,
|
||||
});
|
||||
if(data != null) {
|
||||
setState(() {
|
||||
state.effectiveDateTime.value = data["beginTimeTimestamp"];
|
||||
state.failureDateTime.value = data["endTimeTimestamp"];
|
||||
state.weekDay.value = data["weekDay"];
|
||||
});
|
||||
}
|
||||
})))
|
||||
),
|
||||
Container(height: 10.h),
|
||||
Obx(() => CommonItem(
|
||||
leftTitel: TranslationLoader.lanKeys!.additive!.tr,
|
||||
rightTitle: state.adder.value,
|
||||
action: () {
|
||||
|
||||
})),
|
||||
Obx(() => CommonItem(
|
||||
leftTitel: TranslationLoader.lanKeys!.addTime!.tr,
|
||||
rightTitle: DateTool().dateToYMDHNString(state.addTime.value.toString()),
|
||||
action: () {
|
||||
|
||||
})),
|
||||
SizedBox(height: 10.h),
|
||||
Obx(() => CommonItem(
|
||||
leftTitel: TranslationLoader.lanKeys!.stressFingerprint!.tr,
|
||||
rightTitle: "",
|
||||
isTipsImg: false,
|
||||
isHaveRightWidget: true,
|
||||
rightWidget: SizedBox(
|
||||
width: 60.w, height: 50.h, child: _isStressFingerprint()))),
|
||||
Container(height: 10.h),
|
||||
CommonItem(
|
||||
leftTitel: TranslationLoader.lanKeys!.operatingRecord!.tr,
|
||||
rightTitle: "",
|
||||
isHaveDirection: true,
|
||||
action: () {
|
||||
// 指纹
|
||||
Get.toNamed(Routers.keyOperationRecordPage, arguments: {
|
||||
'lockId': state.fingerprintItemData.value.lockId.toString(),
|
||||
'fingerprintId': state.fingerprintItemData.value.fingerprintId.toString()
|
||||
});
|
||||
}),
|
||||
// SizedBox(height: 40.h),
|
||||
// addControlsBtn(type),
|
||||
SizedBox(height: 30.h),
|
||||
SubmitBtn(
|
||||
btnName: TranslationLoader.lanKeys!.delete!.tr,
|
||||
isDelete: true,
|
||||
borderRadius: 20.w,
|
||||
margin: EdgeInsets.only(left: 30.w, right: 30.w, top: 30.w, bottom: 30.w),
|
||||
padding: EdgeInsets.only(top: 25.w, bottom: 25.w),
|
||||
onClick: () {
|
||||
showIosTipViewDialog(context);
|
||||
}),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
//isStressFingerprint false:不是胁迫指纹 ture:胁迫指纹
|
||||
CupertinoSwitch _isStressFingerprint() {
|
||||
return CupertinoSwitch(
|
||||
activeColor: CupertinoColors.activeBlue,
|
||||
trackColor: CupertinoColors.systemGrey5,
|
||||
thumbColor: CupertinoColors.white,
|
||||
value: state.isStressFingerprint.value,
|
||||
onChanged: (value) {
|
||||
setState(() {
|
||||
state.isStressFingerprint.value = value;
|
||||
logic.editFingerprintsData();
|
||||
});
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
// Widget addControlsBtn(int type) {
|
||||
// List<Widget> widgetList = [];
|
||||
// List<Map<String, dynamic>> routerList = [];
|
||||
// //卡详情
|
||||
// if (type == 0) {
|
||||
// routerList.add({
|
||||
// 'btnTitle': '设置密码',
|
||||
// 'routerName': Routers.passwordKeyDetailPage,
|
||||
// 'type': 9
|
||||
// });
|
||||
// routerList.add({
|
||||
// 'btnTitle': '设置指纹',
|
||||
// 'routerName': Routers.otherTypeKeyManagePage,
|
||||
// 'type': 1
|
||||
// });
|
||||
// routerList.add({
|
||||
// 'btnTitle': '设置遥控',
|
||||
// 'routerName': Routers.otherTypeKeyManagePage,
|
||||
// 'type': 2
|
||||
// });
|
||||
// } else if (type == 1) {
|
||||
// //指纹详情
|
||||
// routerList.add({
|
||||
// 'btnTitle': '设置密码',
|
||||
// 'routerName': Routers.passwordKeyDetailPage,
|
||||
// 'type': 9
|
||||
// });
|
||||
// routerList.add({
|
||||
// 'btnTitle': '设置卡',
|
||||
// 'routerName': Routers.otherTypeKeyManagePage,
|
||||
// 'type': 0
|
||||
// });
|
||||
// routerList.add({
|
||||
// 'btnTitle': '设置遥控',
|
||||
// 'routerName': Routers.otherTypeKeyManagePage,
|
||||
// 'type': 2
|
||||
// });
|
||||
// } else if (type == 2) {
|
||||
// //遥控详情
|
||||
// routerList.add({
|
||||
// 'btnTitle': '设置密码',
|
||||
// 'routerName': Routers.passwordKeyDetailPage,
|
||||
// 'type': 9
|
||||
// });
|
||||
// routerList.add({
|
||||
// 'btnTitle': '设置卡',
|
||||
// 'routerName': Routers.otherTypeKeyManagePage,
|
||||
// 'type': 0
|
||||
// });
|
||||
// routerList.add({
|
||||
// 'btnTitle': '设置指纹',
|
||||
// 'routerName': Routers.otherTypeKeyManagePage,
|
||||
// 'type': 1
|
||||
// });
|
||||
// }
|
||||
//
|
||||
// for (int i = 0; i < routerList.length; i++) {
|
||||
// widgetList.add(SizedBox(
|
||||
// width: ScreenUtil().screenWidth - 40.w,
|
||||
// height: 60.h,
|
||||
// child: OutlinedButton(
|
||||
// style: OutlinedButton.styleFrom(
|
||||
// // backgroundColor: Colors.white,
|
||||
// side: BorderSide(width: 1, color: AppColors.mainColor)),
|
||||
// onPressed: () {
|
||||
// if (routerList[i]['type'] == 9) {
|
||||
// Navigator.pushNamed(context, Routers.passwordKeyManagePage);
|
||||
// } else {
|
||||
// Navigator.pushNamed(context, Routers.otherTypeKeyManagePage,
|
||||
// arguments: routerList[i]['type']);
|
||||
// }
|
||||
// },
|
||||
// child: Text(
|
||||
// routerList[i]['btnTitle'],
|
||||
// style: TextStyle(color: AppColors.mainColor, fontSize: 24.sp),
|
||||
// )),
|
||||
// ));
|
||||
//
|
||||
// widgetList.add(
|
||||
// SizedBox(
|
||||
// height: 10.h,
|
||||
// ),
|
||||
// );
|
||||
// }
|
||||
//
|
||||
// return Column(
|
||||
// children: widgetList,
|
||||
// );
|
||||
// }
|
||||
|
||||
void showCupertinoAlertDialog(BuildContext context) {
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (BuildContext context) {
|
||||
return ShowTFView(
|
||||
title: "${TranslationLoader.lanKeys!.amend!.tr}${TranslationLoader.lanKeys!.name!.tr}",
|
||||
tipTitle: "",
|
||||
controller: state.changeNameController,
|
||||
sureClick: () {
|
||||
if(state.changeNameController.text.isEmpty){
|
||||
Toast.show(msg: "请输入姓名");
|
||||
return;
|
||||
}
|
||||
Get.back();
|
||||
// 指纹
|
||||
logic.editFingerprintsData();
|
||||
},
|
||||
cancelClick: () {
|
||||
Get.back();
|
||||
},);
|
||||
});
|
||||
}
|
||||
|
||||
void showIosTipViewDialog(BuildContext context) {
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (BuildContext context) {
|
||||
return ShowIosTipView(
|
||||
title: "提示",
|
||||
tipTitle: "确定要删除吗?",
|
||||
sureClick: () {
|
||||
Get.back();
|
||||
// 指纹
|
||||
logic.deletFingerprintsData();
|
||||
},
|
||||
cancelClick: () {
|
||||
Get.back();
|
||||
},
|
||||
);
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,39 @@
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
|
||||
import '../fingerprintList/fingerprintListData_entity.dart';
|
||||
|
||||
class FingerprintDetailState{
|
||||
final fingerprintItemData = FingerprintItemData().obs;
|
||||
|
||||
final TextEditingController changeNameController = TextEditingController();
|
||||
|
||||
final typeNumber = "".obs;// 指纹号
|
||||
final typeName = "".obs;// 指纹名字
|
||||
var effectiveDateTime = 0.obs;// 生效时间
|
||||
var failureDateTime = 0.obs;// 失效时间
|
||||
final keyType = 0.obs;// 永久:1;限时2,单次3,循环:4
|
||||
var weekDay = [].obs;// 有效日
|
||||
var adder = "".obs;// 添加者
|
||||
var addTime = 0.obs;// 添加时间
|
||||
var keyId = 0.obs;// 添加时间
|
||||
|
||||
final isStressFingerprint = false.obs;
|
||||
FingerprintDetailState() {
|
||||
Map map = Get.arguments;
|
||||
fingerprintItemData.value = map["fingerprintItemData"];
|
||||
keyId.value = fingerprintItemData.value.fingerprintId!;
|
||||
typeNumber.value = fingerprintItemData.value.fingerprintNumber!;
|
||||
typeName.value = fingerprintItemData.value.fingerprintName!;
|
||||
changeNameController.text = typeName.value;
|
||||
effectiveDateTime.value = fingerprintItemData.value.startDate!;
|
||||
failureDateTime.value = fingerprintItemData.value.endDate!;
|
||||
keyType.value = fingerprintItemData.value.fingerprintType!;
|
||||
adder.value = fingerprintItemData.value.senderUsername!;
|
||||
addTime.value = fingerprintItemData.value.createDate!;
|
||||
isStressFingerprint.value = fingerprintItemData.value.isCoerced! == 2 ? true : false;
|
||||
weekDay.value = fingerprintItemData.value.weekDay!;
|
||||
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,147 @@
|
||||
class FingerprintListDataEntity {
|
||||
int? errorCode;
|
||||
String? description;
|
||||
String? errorMsg;
|
||||
Data? data;
|
||||
|
||||
FingerprintListDataEntity(
|
||||
{this.errorCode, this.description, this.errorMsg, this.data});
|
||||
|
||||
FingerprintListDataEntity.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 = Map<String, dynamic>();
|
||||
data['errorCode'] = errorCode;
|
||||
data['description'] = description;
|
||||
data['errorMsg'] = errorMsg;
|
||||
if (this.data != null) {
|
||||
data['data'] = this.data!.toJson();
|
||||
}
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
||||
class Data {
|
||||
List<FingerprintItemData>? list;
|
||||
int? pageNo;
|
||||
int? pageSize;
|
||||
int? pages;
|
||||
int? total;
|
||||
|
||||
Data({this.list, this.pageNo, this.pageSize, this.pages, this.total});
|
||||
|
||||
Data.fromJson(Map<String, dynamic> json) {
|
||||
if (json['list'] != null) {
|
||||
list = <FingerprintItemData>[];
|
||||
json['list'].forEach((v) {
|
||||
list!.add(FingerprintItemData.fromJson(v));
|
||||
});
|
||||
}
|
||||
pageNo = json['pageNo'];
|
||||
pageSize = json['pageSize'];
|
||||
pages = json['pages'];
|
||||
total = json['total'];
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final Map<String, dynamic> data = <String, dynamic>{};
|
||||
if (list != null) {
|
||||
data['list'] = list!.map((v) => v.toJson()).toList();
|
||||
}
|
||||
data['pageNo'] = pageNo;
|
||||
data['pageSize'] = pageSize;
|
||||
data['pages'] = pages;
|
||||
data['total'] = total;
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
||||
class FingerprintItemData {
|
||||
int? fingerprintStatus;
|
||||
int? lockId;
|
||||
int? createDate;
|
||||
String? fingerprintName;
|
||||
int? endDate;
|
||||
int? apiUserId;
|
||||
String? nickName;
|
||||
int? isCoerced;
|
||||
int? startDate;
|
||||
String? fingerprintNumber;
|
||||
int? fingerprintType;
|
||||
int? fingerprintId;
|
||||
String? senderUsername;
|
||||
List? weekDay;
|
||||
|
||||
String? cardName;
|
||||
String? cardNumber;
|
||||
int? cardType;
|
||||
int? cardId;
|
||||
FingerprintItemData(
|
||||
{ this.fingerprintStatus,
|
||||
this.lockId,
|
||||
this.createDate,
|
||||
this.fingerprintName,
|
||||
this.endDate,
|
||||
this.apiUserId,
|
||||
this.nickName,
|
||||
this.isCoerced,
|
||||
this.startDate,
|
||||
this.fingerprintNumber,
|
||||
this.fingerprintType,
|
||||
this.fingerprintId,
|
||||
this.senderUsername,
|
||||
this.weekDay,
|
||||
this.cardName,
|
||||
this.cardNumber,
|
||||
this.cardType,
|
||||
this.cardId});
|
||||
|
||||
FingerprintItemData.fromJson(Map<String, dynamic> json) {
|
||||
fingerprintStatus = json['fingerprintStatus'];
|
||||
lockId = json['lockId'];
|
||||
createDate = json['createDate'];
|
||||
fingerprintName = json['fingerprintName'];
|
||||
endDate = json['endDate'];
|
||||
apiUserId = json['apiUserId'];
|
||||
nickName = json['nickName'];
|
||||
isCoerced = json['isCoerced'];
|
||||
startDate = json['startDate'];
|
||||
fingerprintNumber = json['fingerprintNumber'];
|
||||
fingerprintType = json['fingerprintType'];
|
||||
fingerprintId = json['fingerprintId'];
|
||||
senderUsername = json['senderUsername'];
|
||||
weekDay = json['weekDay'];
|
||||
cardName = json['cardName'];
|
||||
cardNumber = json['cardNumber'];
|
||||
cardType = json['cardType'];
|
||||
cardId = json['cardId'];
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final Map<String, dynamic> data = <String, dynamic>{};
|
||||
data['fingerprintStatus'] = fingerprintStatus;
|
||||
data['lockId'] = lockId;
|
||||
data['createDate'] = createDate;
|
||||
data['fingerprintName'] = fingerprintName;
|
||||
data['endDate'] = endDate;
|
||||
data['apiUserId'] = apiUserId;
|
||||
data['nickName'] = nickName;
|
||||
data['isCoerced'] = isCoerced;
|
||||
data['startDate'] = startDate;
|
||||
data['fingerprintNumber'] = fingerprintNumber;
|
||||
data['fingerprintType'] = fingerprintType;
|
||||
data['fingerprintId'] = fingerprintId;
|
||||
data['senderUsername'] = senderUsername;
|
||||
data['weekDay'] = weekDay;
|
||||
data['cardName'] = cardName;
|
||||
data['cardNumber'] = cardNumber;
|
||||
data['cardType'] = cardType;
|
||||
data['cardId'] = cardId;
|
||||
return data;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,404 @@
|
||||
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:flutter_reactive_ble/flutter_reactive_ble.dart';
|
||||
import 'package:star_lock/blue/io_type.dart';
|
||||
import 'package:star_lock/tools/baseGetXController.dart';
|
||||
import '../../../../blue/blue_manage.dart';
|
||||
import '../../../../blue/io_protocol/io_addFingerprint.dart';
|
||||
import '../../../../blue/io_protocol/io_checkingUserInfoCount.dart';
|
||||
import '../../../../blue/io_protocol/io_queryingFingerprintStatus.dart';
|
||||
import '../../../../blue/io_reply.dart';
|
||||
import '../../../../blue/io_tool/io_tool.dart';
|
||||
import '../../../../blue/io_tool/manager_event_bus.dart';
|
||||
import '../../../../blue/sender_manage.dart';
|
||||
import '../../../../network/api_repository.dart';
|
||||
import '../../../../tools/eventBusEventManage.dart';
|
||||
import '../../../../tools/storage.dart';
|
||||
import '../../../../tools/toast.dart';
|
||||
import 'fingerprintList_state.dart';
|
||||
|
||||
class FingerprintListLogic extends BaseGetXController{
|
||||
FingerprintListState state = FingerprintListState();
|
||||
|
||||
// 获取解析后的数据
|
||||
late StreamSubscription<Reply> _replySubscription;
|
||||
void _initReplySubscription() {
|
||||
_replySubscription = EventBusManager().eventBus!.on<Reply>().listen((reply) {
|
||||
// 添加指纹开始(此处用作删除指纹)
|
||||
if((reply is SenderAddFingerprintReply) && (state.isDeletFingerprintData == true)) {
|
||||
_replyAddFingerprintBegin(reply);
|
||||
}
|
||||
|
||||
if(reply is SenderQueryingFingerprintStatusReply) {
|
||||
// 获取指纹状态
|
||||
_replyQueryingFingerprintStatus(reply);
|
||||
}
|
||||
|
||||
if(reply is SenderCheckingUserInfoCountReply){
|
||||
_replyCheckingUserInfoCount(reply);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// 添加指纹开始
|
||||
Future<void> _replyAddFingerprintBegin(Reply reply) async {
|
||||
|
||||
int status = reply.data[2];
|
||||
print("status:$status");
|
||||
|
||||
switch(status){
|
||||
case 0x00:
|
||||
//成功
|
||||
print("${reply.commandType!.typeValue} 数据解析成功");
|
||||
state.isDeletFingerprintData = false;
|
||||
deletAllFingerprintsData();
|
||||
break;
|
||||
case 0x06:
|
||||
//无权限
|
||||
print("${reply.commandType!.typeValue} 需要鉴权");
|
||||
var privateKey = await Storage.getStringList(saveBluePrivateKey);
|
||||
List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
|
||||
|
||||
var publicKey = await Storage.getStringList(saveBluePublicKey);
|
||||
List<int> publicKeyDataList = changeStringListToIntList(publicKey!);
|
||||
|
||||
var token = await Storage.getStringList(saveBlueToken);
|
||||
List<int> getTokenList = changeStringListToIntList(token!);
|
||||
|
||||
IoSenderManage.senderAddFingerprintCommand(
|
||||
keyID:"1",
|
||||
userID:"DeleteAll!@#",
|
||||
fingerNo:255,
|
||||
useCountLimit:0,
|
||||
startTime:0x11223344,
|
||||
endTime:0x11223344,
|
||||
needAuthor:1,
|
||||
publicKey:publicKeyDataList,
|
||||
privateKey:getPrivateKeyList,
|
||||
token: getTokenList,
|
||||
);
|
||||
break;
|
||||
case 0x07:
|
||||
//无权限
|
||||
print("${reply.commandType!.typeValue} 用户无权限");
|
||||
|
||||
break;
|
||||
case 0x09:
|
||||
// 权限校验错误
|
||||
print("${reply.commandType!.typeValue} 权限校验错误");
|
||||
|
||||
break;
|
||||
default:
|
||||
//失败
|
||||
print("${reply.commandType!.typeValue} 失败");
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// 获取指纹状态
|
||||
Future<void> _replyQueryingFingerprintStatus(Reply reply) async {
|
||||
int status = reply.data[2];
|
||||
|
||||
switch(status){
|
||||
case 0x00:
|
||||
//成功
|
||||
print("${reply.commandType}数据解析成功");
|
||||
// _getLockStatus();
|
||||
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> _replyReferEventRecordNumber(Reply reply) async {
|
||||
int status = reply.data[2];
|
||||
switch(status){
|
||||
case 0x00:
|
||||
//成功
|
||||
print("${reply.commandType}数据解析成功");
|
||||
// _getLockStatus();
|
||||
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> _replyCheckingUserInfoCount(Reply reply) async {
|
||||
int status = reply.data[2];
|
||||
|
||||
// 用户数量
|
||||
int userNum = reply.data[5];
|
||||
// print("userNum:$userNum");
|
||||
|
||||
// 指纹数量
|
||||
int fingerNum = reply.data[6];
|
||||
// print("fingerNum:$fingerNum");
|
||||
|
||||
// 密码数量
|
||||
int pwdNum = reply.data[7];
|
||||
|
||||
// 卡片数量
|
||||
int cardNum = reply.data[8];
|
||||
|
||||
// 记录数量
|
||||
int logsNum = reply.data[9];
|
||||
|
||||
// 版本
|
||||
int verNo = reply.data[10];
|
||||
|
||||
// 最大管理员指纹数量
|
||||
int maxAdminFingerNum = reply.data[11];
|
||||
|
||||
// 最大用户指纹数量
|
||||
int maxUserFingerNum = reply.data[12];
|
||||
|
||||
// 最大管理员密码数量
|
||||
int maxAdminPassNum = reply.data[13];
|
||||
|
||||
// 最大用户密码数量
|
||||
int maxUserPassNum = reply.data[14];
|
||||
|
||||
// 最大管理员卡片数量
|
||||
int maxAdminCardNum = reply.data[15];
|
||||
|
||||
// 最大用户卡片数量
|
||||
int maxUserCardNum = reply.data[16];
|
||||
|
||||
// 序列号
|
||||
var serialNo = reply.data.sublist(17, 21);
|
||||
print("serialNo:$serialNo");
|
||||
|
||||
switch(status){
|
||||
case 0x00:
|
||||
//成功
|
||||
print("${reply.commandType}数据解析成功");
|
||||
// _getLockStatus();
|
||||
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> senderQueryingFingerprintStatus() async {
|
||||
BlueManage().judgeReconnect(BlueManage().connectDeviceMacAddress, BlueManage().connectDeviceName,(DeviceConnectionState state) async {
|
||||
if (state == DeviceConnectionState.connected) {
|
||||
var privateKey = await Storage.getStringList(saveBluePrivateKey);
|
||||
List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
|
||||
|
||||
var token = await Storage.getStringList(saveBlueToken);
|
||||
List<int> getTokenList = changeStringListToIntList(token!);
|
||||
|
||||
var publicKey = await Storage.getStringList(saveBluePublicKey);
|
||||
List<int> getPublicKeyList = changeStringListToIntList(publicKey!);
|
||||
|
||||
IoSenderManage.senderQueryingFingerprintStatusCommand(
|
||||
keyID:BlueManage().connectDeviceName,
|
||||
userID:await Storage.getUid(),
|
||||
role:0xff,
|
||||
fingerCount:20,
|
||||
fingerNo:1,
|
||||
token:getTokenList,
|
||||
needAuthor:1,
|
||||
publicKey:getPublicKeyList,
|
||||
privateKey:getPrivateKeyList,
|
||||
);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// 查询用户、指纹、密码、卡片数量(用于判断是否同步)
|
||||
Future<void> senderCheckingUserInfoCount() async {
|
||||
BlueManage().judgeReconnect(BlueManage().connectDeviceMacAddress, BlueManage().connectDeviceName, (DeviceConnectionState state) async {
|
||||
if (state == DeviceConnectionState.connected) {
|
||||
var privateKey = await Storage.getStringList(saveBluePrivateKey);
|
||||
List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
|
||||
|
||||
var token = await Storage.getStringList(saveBlueToken);
|
||||
List<int> getTokenList = changeStringListToIntList(token!);
|
||||
|
||||
var publicKey = await Storage.getStringList(saveBluePublicKey);
|
||||
List<int> getPublicKeyList = changeStringListToIntList(publicKey!);
|
||||
|
||||
IoSenderManage.senderCheckingUserInfoCountCommand(
|
||||
keyID:BlueManage().connectDeviceName,
|
||||
userID:await Storage.getUid(),
|
||||
role:0xff,
|
||||
nowTime:DateTime.now().millisecondsSinceEpoch~/1000,
|
||||
token:getTokenList,
|
||||
needAuthor:1,
|
||||
publicKey:getPublicKeyList,
|
||||
privateKey:getPrivateKeyList,
|
||||
);
|
||||
}
|
||||
}, isShowLoading: false);
|
||||
}
|
||||
|
||||
// 删除指纹
|
||||
Future<void> senderAddFingerprint(String keyId, String userID, int cardNo) async {
|
||||
BlueManage().judgeReconnect(BlueManage().connectDeviceMacAddress, BlueManage().connectDeviceName, (DeviceConnectionState deviceConnectionState) async {
|
||||
if (deviceConnectionState == DeviceConnectionState.connected){
|
||||
var publicKey = await Storage.getStringList(saveBluePublicKey);
|
||||
List<int> publicKeyDataList = changeStringListToIntList(publicKey!);
|
||||
|
||||
var privateKey = await Storage.getStringList(saveBluePrivateKey);
|
||||
List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
|
||||
|
||||
var token = await Storage.getStringList(saveBlueToken);
|
||||
List<int> getTokenList = changeStringListToIntList(token!);
|
||||
|
||||
IoSenderManage.senderAddFingerprintCommand(
|
||||
// keyID:"1",
|
||||
// userID:"DeleteAll!@#",
|
||||
// fingerNo:255,
|
||||
keyID:keyId,
|
||||
userID:userID,
|
||||
fingerNo:cardNo,
|
||||
useCountLimit:0,
|
||||
startTime:0x11223344,
|
||||
endTime:0x11223344,
|
||||
needAuthor:1,
|
||||
publicKey:publicKeyDataList,
|
||||
privateKey:getPrivateKeyList,
|
||||
token: getTokenList,
|
||||
);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// 获取指纹列表
|
||||
void getFingerprintsListData() async{
|
||||
var entity = await ApiRepository.to.getFingerprintsListData(
|
||||
lockId: state.lockId.value.toString(),
|
||||
pageNo: '1',
|
||||
pageSize: '20',
|
||||
searchStr: state.searchController.text,
|
||||
);
|
||||
if(entity.errorCode!.codeIsSuccessful){
|
||||
state.fingerprintItemListData.value = entity.data!.list!;
|
||||
}
|
||||
}
|
||||
|
||||
// 重置所有的指纹
|
||||
void deletAllFingerprintsData() async{
|
||||
var entity = await ApiRepository.to.deletFingerprintsData(
|
||||
fingerprintId: "",
|
||||
lockId: state.lockId.value.toString(),
|
||||
type: "1",
|
||||
deleteType:"1"
|
||||
);
|
||||
if(entity.errorCode!.codeIsSuccessful){
|
||||
Toast.show(msg: "重置成功");
|
||||
state.isDeletFingerprintData = false;
|
||||
getFingerprintsListData();
|
||||
}
|
||||
}
|
||||
|
||||
// 监听修改完详情之后刷新列表
|
||||
late StreamSubscription _teamEvent;
|
||||
void _initRefreshAction() {
|
||||
_teamEvent = eventBus.on<OtherTypeRefreshListEvent>().listen((event) {
|
||||
getFingerprintsListData();
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> onReady() async {
|
||||
// TODO: implement onReady
|
||||
super.onReady();
|
||||
print("onReady()");
|
||||
|
||||
// 获取是否是演示模式 演示模式不获取接口
|
||||
var isDemoMode = await Storage.getBool(ifIsDemoModeOrNot);
|
||||
// print("aaaaaaa:$isDemoMode");
|
||||
if(isDemoMode == false){
|
||||
_initReplySubscription();
|
||||
|
||||
_initRefreshAction();
|
||||
|
||||
getFingerprintsListData();
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> onInit() async {
|
||||
// TODO: implement onInit
|
||||
super.onInit();
|
||||
print("onInit()");
|
||||
var isDemoMode = await Storage.getBool(ifIsDemoModeOrNot);
|
||||
if(isDemoMode == false) {
|
||||
// senderQueryingFingerprintStatus();
|
||||
// senderCheckingCardStatus();
|
||||
senderCheckingUserInfoCount();
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> onClose() async {
|
||||
// TODO: implement onClose
|
||||
super.onClose();
|
||||
|
||||
var isDemoMode = await Storage.getBool(ifIsDemoModeOrNot);
|
||||
if(isDemoMode == false) {
|
||||
_replySubscription.cancel();
|
||||
_teamEvent.cancel();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,299 @@
|
||||
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
||||
import 'package:get/get.dart';
|
||||
|
||||
import '../../../../appRouters.dart';
|
||||
import '../../../../app_settings/app_colors.dart';
|
||||
import '../../../../tools/dateTool.dart';
|
||||
import '../../../../tools/left_slide_actions.dart';
|
||||
import '../../../../tools/noData.dart';
|
||||
import '../../../../tools/showIosTipView.dart';
|
||||
import '../../../../tools/storage.dart';
|
||||
import '../../../../tools/submitBtn.dart';
|
||||
import '../../../../tools/titleAppBar.dart';
|
||||
import '../../../../tools/toast.dart';
|
||||
import '../../../../translations/trans_lib.dart';
|
||||
import 'fingerprintListData_entity.dart';
|
||||
import 'fingerprintList_logic.dart';
|
||||
|
||||
class FingerprintListPage extends StatefulWidget {
|
||||
const FingerprintListPage({Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
State<FingerprintListPage> createState() => _FingerprintListPageState();
|
||||
}
|
||||
|
||||
class _FingerprintListPageState extends State<FingerprintListPage> {
|
||||
final logic = Get.put(FingerprintListLogic());
|
||||
final state = Get.find<FingerprintListLogic>().state;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
backgroundColor: AppColors.mainBackgroundColor,
|
||||
appBar: TitleAppBar(
|
||||
barTitle: TranslationLoader.lanKeys!.fingerprint!.tr,
|
||||
haveBack: true,
|
||||
backgroundColor: AppColors.mainColor,
|
||||
actionsList: [
|
||||
TextButton(
|
||||
child: Text(
|
||||
TranslationLoader.lanKeys!.reset!.tr,
|
||||
style: TextStyle(color: Colors.white, fontSize: 24.sp),
|
||||
),
|
||||
onPressed: () async {
|
||||
var isDemoMode = await Storage.getBool(ifIsDemoModeOrNot);
|
||||
if (isDemoMode == false) {
|
||||
showDeletAlertDialog(context);
|
||||
} else {
|
||||
// Get.toNamed(Routers.seletLockTypePage);
|
||||
Toast.show(msg: "演示模式");
|
||||
}
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
body: Column(
|
||||
children: [
|
||||
_searchWidget(),
|
||||
SizedBox(
|
||||
height: 20.h,
|
||||
),
|
||||
Expanded(child: _buildMainUI()),
|
||||
AddBottomWhiteBtn(
|
||||
btnName: '${TranslationLoader.lanKeys!.add!.tr}${TranslationLoader.lanKeys!.fingerprint!.tr}',
|
||||
onClick: () async {
|
||||
var data =
|
||||
await Get.toNamed(Routers.addFingerprintTypeManagePage, arguments: {
|
||||
"lockId": state.lockId.value,
|
||||
"fromType": 1 // 1从添加钥匙列表进入 2从考勤添加员工入口进入
|
||||
});
|
||||
if (data != null) {
|
||||
logic.getFingerprintsListData();
|
||||
}
|
||||
},
|
||||
),
|
||||
SizedBox(height: 64.h)
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _searchWidget() {
|
||||
return Container(
|
||||
height: 60.h,
|
||||
margin: EdgeInsets.only(top: 20.w, left: 20.w, right: 10.w),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white, borderRadius: BorderRadius.circular(5)),
|
||||
child: TextField(
|
||||
//输入框一行
|
||||
maxLines: 1,
|
||||
controller: state.searchController,
|
||||
autofocus: false,
|
||||
onChanged: (value) {
|
||||
print("onChanged:$value");
|
||||
},
|
||||
onEditingComplete: () {
|
||||
print("onEditingComplete:");
|
||||
},
|
||||
onSubmitted: (value) {
|
||||
logic.getFingerprintsListData();
|
||||
},
|
||||
decoration: InputDecoration(
|
||||
//输入里面输入文字内边距设置
|
||||
contentPadding: const EdgeInsets.only(
|
||||
top: 12.0, left: -19.0, right: -15.0, bottom: 8.0),
|
||||
hintText: TranslationLoader.lanKeys!.pleaseEnter!.tr,
|
||||
hintStyle: TextStyle(fontSize: 22.sp, height: 3.0),
|
||||
//不需要输入框下划线
|
||||
border: InputBorder.none,
|
||||
//左边图标设置
|
||||
icon: Padding(
|
||||
padding: EdgeInsets.only(
|
||||
top: 20.h, bottom: 20.h, right: 20.w, left: 10.w),
|
||||
child: Image.asset(
|
||||
'images/main/icon_main_search.png',
|
||||
width: 40.w,
|
||||
height: 40.w,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildMainUI() {
|
||||
|
||||
return Obx(() => state.fingerprintItemListData.value.isNotEmpty
|
||||
? ListView.separated(
|
||||
itemCount: state.fingerprintItemListData.value.length,
|
||||
itemBuilder: (c, index) {
|
||||
FingerprintItemData fingerprintItemData = state.fingerprintItemListData.value[index];
|
||||
// 指纹
|
||||
if (index < state.fingerprintItemListData.value.length) {
|
||||
return LeftSlideActions(
|
||||
key: Key(fingerprintItemData.fingerprintName!),
|
||||
actionsWidth: 60,
|
||||
actions: [
|
||||
_buildDeleteBtn(
|
||||
fingerprintItemData.fingerprintId.toString()),
|
||||
],
|
||||
decoration: const BoxDecoration(
|
||||
borderRadius: BorderRadius.all(Radius.circular(1)),
|
||||
),
|
||||
child: _keyItem(
|
||||
'images/icon_fingerprint.png',
|
||||
fingerprintItemData.fingerprintName!,
|
||||
fingerprintItemData.fingerprintType! == 1
|
||||
? "永久"
|
||||
: "${DateTool().dateToYMDHNString(fingerprintItemData.startDate.toString())} - ${DateTool().dateToYMDHNString(fingerprintItemData.endDate.toString())}",
|
||||
() async {
|
||||
var data = await Get.toNamed(
|
||||
Routers.fingerprintDetailPage,
|
||||
arguments: {
|
||||
"fingerprintItemData": fingerprintItemData,
|
||||
});
|
||||
if (data != null) {
|
||||
logic.getFingerprintsListData();
|
||||
}
|
||||
}),
|
||||
);
|
||||
}
|
||||
return const SizedBox.shrink();
|
||||
},
|
||||
separatorBuilder: (BuildContext context, int index) {
|
||||
return const Divider(
|
||||
height: 1,
|
||||
color: AppColors.greyLineColor,
|
||||
);
|
||||
},
|
||||
)
|
||||
: const NoData());
|
||||
}
|
||||
|
||||
Widget _buildDeleteBtn(String idStr) {
|
||||
return GestureDetector(
|
||||
onTap: () {
|
||||
// 省略: 弹出是否删除的确认对话框。
|
||||
showIosTipViewDialog(context, idStr);
|
||||
},
|
||||
child: Container(
|
||||
width: 60,
|
||||
color: const Color(0xFFF20101),
|
||||
alignment: Alignment.center,
|
||||
child: const Text(
|
||||
'删除',
|
||||
style: TextStyle(
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.w500,
|
||||
color: Colors.white,
|
||||
height: 1,
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
void showIosTipViewDialog(BuildContext context, String keyId) {
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (BuildContext context) {
|
||||
return ShowIosTipView(
|
||||
title: "提示",
|
||||
tipTitle: "确定要删除吗?",
|
||||
sureClick: () async {
|
||||
Get.back();
|
||||
String? idStr = await Storage.getUid();
|
||||
state.isDeletFingerprintData = true;
|
||||
logic.senderAddFingerprint(keyId, idStr ?? "", 0);
|
||||
},
|
||||
cancelClick: () {
|
||||
Get.back();
|
||||
},
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
Widget _keyItem(String lockTypeIcon, String lockTypeTitle, String showTime,
|
||||
Function() action) {
|
||||
return GestureDetector(
|
||||
onTap: action,
|
||||
child: Container(
|
||||
height: 90.h,
|
||||
// margin: EdgeInsets.only(left: 20.w, right: 20.w, top: 20.w),
|
||||
color: Colors.white,
|
||||
// decoration: BoxDecoration(
|
||||
// color: Colors.white,
|
||||
// // borderRadius: BorderRadius.circular(10.w),
|
||||
// ),
|
||||
child: Row(
|
||||
children: [
|
||||
SizedBox(width: 30.w),
|
||||
Image.asset(lockTypeIcon, width: 60.w, height: 60.w),
|
||||
SizedBox(width: 20.w),
|
||||
Expanded(
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
children: [
|
||||
Text(lockTypeTitle,
|
||||
style: TextStyle(
|
||||
fontSize: 24.sp, color: AppColors.blackColor)),
|
||||
],
|
||||
),
|
||||
SizedBox(height: 5.h),
|
||||
Container(
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
children: [
|
||||
Text(showTime,
|
||||
style: TextStyle(
|
||||
fontSize: 18.sp,
|
||||
color: AppColors.placeholderTextColor)),
|
||||
],
|
||||
),
|
||||
),
|
||||
SizedBox(width: 20.h),
|
||||
],
|
||||
),
|
||||
),
|
||||
SizedBox(width: 20.h),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
void showDeletAlertDialog(BuildContext context) {
|
||||
showCupertinoDialog(
|
||||
context: context,
|
||||
builder: (context) {
|
||||
return CupertinoAlertDialog(
|
||||
title: const Text("提示"),
|
||||
content: const Text('重置后信息都会清除哦,确认要重置吗?'),
|
||||
actions: [
|
||||
CupertinoDialogAction(
|
||||
child: Text(TranslationLoader.lanKeys!.cancel!.tr),
|
||||
onPressed: () {
|
||||
Navigator.pop(context);
|
||||
},
|
||||
),
|
||||
CupertinoDialogAction(
|
||||
child: Text(TranslationLoader.lanKeys!.sure!.tr),
|
||||
onPressed: () {
|
||||
Navigator.pop(context);
|
||||
state.isDeletFingerprintData = true;
|
||||
logic.senderAddFingerprint("1", "DeleteAll!@#", 255);
|
||||
},
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,20 @@
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
|
||||
import 'fingerprintListData_entity.dart';
|
||||
|
||||
class FingerprintListState{
|
||||
final lockId = 0.obs;
|
||||
|
||||
var isDeletFingerprintData = false;
|
||||
var isDeletICCardData = false;
|
||||
|
||||
final fingerprintItemListData = <FingerprintItemData>[].obs;
|
||||
final TextEditingController searchController = TextEditingController();
|
||||
|
||||
FingerprintListState() {
|
||||
Map map = Get.arguments;
|
||||
lockId.value = map["lockId"];
|
||||
}
|
||||
}
|
||||
@ -416,7 +416,7 @@ class LockSetLogic extends BaseGetXController {
|
||||
password: state.passwordTF.text,
|
||||
);
|
||||
if (entity.errorCode!.codeIsSuccessful) {
|
||||
// deletLockInfoData();
|
||||
deletLockInfoData();
|
||||
|
||||
blockDeletNumberCheckPasswordCallback();
|
||||
// if(state.currentDeviceUUid.value.isEmpty){
|
||||
|
||||
@ -301,9 +301,8 @@ class _LockDetailPageState extends State<LockDetailPage>
|
||||
if (state.keyInfos.value.lockFeature!.icCard == 1) {
|
||||
showWidgetArr.add(bottomItem('images/main/icon_main_icCard.png',
|
||||
TranslationLoader.lanKeys!.card!.tr, () {
|
||||
Get.toNamed(Routers.otherTypeKeyListPage, arguments: {
|
||||
Get.toNamed(Routers.cardListPage, arguments: {
|
||||
"lockId": widget.lockListInfoItemEntity.lockId,
|
||||
"fromType": 0
|
||||
});
|
||||
}));
|
||||
}
|
||||
@ -312,9 +311,8 @@ class _LockDetailPageState extends State<LockDetailPage>
|
||||
if (state.keyInfos.value.lockFeature!.fingerprint == 1) {
|
||||
showWidgetArr.add(bottomItem('images/main/icon_main_fingerprint.png',
|
||||
TranslationLoader.lanKeys!.fingerprint!.tr, () {
|
||||
Get.toNamed(Routers.otherTypeKeyListPage, arguments: {
|
||||
Get.toNamed(Routers.fingerprintListPage, arguments: {
|
||||
"lockId": widget.lockListInfoItemEntity.lockId,
|
||||
"fromType": 1
|
||||
});
|
||||
}));
|
||||
}
|
||||
@ -323,10 +321,7 @@ class _LockDetailPageState extends State<LockDetailPage>
|
||||
if (state.keyInfos.value.lockFeature!.bluetoothRemoteControl == 1) {
|
||||
showWidgetArr.add(bottomItem('images/main/icon_main_remoteControl.png',
|
||||
TranslationLoader.lanKeys!.remoteControl!.tr, () {
|
||||
Get.toNamed(Routers.otherTypeKeyListPage, arguments: {
|
||||
"lockId": widget.lockListInfoItemEntity.lockId,
|
||||
"fromType": 2
|
||||
});
|
||||
Get.toNamed(Routers.remoteControlListPage);
|
||||
}));
|
||||
}
|
||||
|
||||
@ -334,9 +329,8 @@ class _LockDetailPageState extends State<LockDetailPage>
|
||||
if (state.keyInfos.value.lockFeature!.d3Face == 1) {
|
||||
showWidgetArr.add(
|
||||
bottomItem('images/main/icon_face.png', TranslationLoader.lanKeys!.humanFace!.tr, () {
|
||||
Get.toNamed(Routers.otherTypeKeyListPage, arguments: {
|
||||
Get.toNamed(Routers.faceList, arguments: {
|
||||
"lockId": widget.lockListInfoItemEntity.lockId,
|
||||
"fromType": 3
|
||||
}); // Toast.show(msg: "功能暂未开放");
|
||||
|
||||
// tokNative('videoTalk',
|
||||
|
||||
@ -129,9 +129,8 @@ class _PasswordKeyDetailPageState extends State<PasswordKeyDetailPage> {
|
||||
// backgroundColor: Colors.white,
|
||||
side: BorderSide(width: 1, color: AppColors.mainColor)),
|
||||
onPressed: () {
|
||||
Navigator.pushNamed(context, Routers.otherTypeKeyManagePage, arguments: {
|
||||
Navigator.pushNamed(context, Routers.cardListPage, arguments: {
|
||||
"lockId": itemData.lockId,
|
||||
"fromType": 0
|
||||
});
|
||||
},
|
||||
child: Text(
|
||||
@ -152,9 +151,8 @@ class _PasswordKeyDetailPageState extends State<PasswordKeyDetailPage> {
|
||||
side: BorderSide(width: 1, color: AppColors.mainColor)),
|
||||
onPressed: () {
|
||||
Navigator.pushNamed(
|
||||
context, Routers.otherTypeKeyManagePage,arguments: {
|
||||
context, Routers.fingerprintListPage,arguments: {
|
||||
"lockId": itemData.lockId,
|
||||
"fromType": 1
|
||||
});
|
||||
},
|
||||
child: Text('设置指纹', style: TextStyle(color: AppColors.mainColor, fontSize: 24.sp),
|
||||
@ -171,9 +169,8 @@ class _PasswordKeyDetailPageState extends State<PasswordKeyDetailPage> {
|
||||
// backgroundColor: Colors.white,
|
||||
side: BorderSide(width: 1, color: AppColors.mainColor)),
|
||||
onPressed: () {
|
||||
Navigator.pushNamed(context, Routers.otherTypeKeyManagePage, arguments: {
|
||||
Navigator.pushNamed(context, Routers.remoteControlListPage, arguments: {
|
||||
"lockId": itemData.lockId,
|
||||
"fromType": 2
|
||||
});
|
||||
},
|
||||
child: Text(
|
||||
|
||||
@ -0,0 +1,38 @@
|
||||
|
||||
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 'addRemoteControlManage_tabbar.dart';
|
||||
|
||||
class AddRemoteControlManagePage extends StatefulWidget {
|
||||
const AddRemoteControlManagePage({Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
State<AddRemoteControlManagePage> createState() => _AddRemoteControlManagePageState();
|
||||
}
|
||||
|
||||
class _AddRemoteControlManagePageState extends State<AddRemoteControlManagePage> {
|
||||
var index = 0;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
|
||||
return Scaffold(
|
||||
backgroundColor: AppColors.mainBackgroundColor,
|
||||
appBar: TitleAppBar(
|
||||
barTitle:
|
||||
"${TranslationLoader.lanKeys!.addTip!.tr}${TranslationLoader.lanKeys!.remoteControl!.tr}",
|
||||
haveBack: true,
|
||||
backgroundColor: AppColors.mainColor),
|
||||
body: Column(
|
||||
children: [
|
||||
AddRemoteControlManageTabbar(initialIndex: index),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,100 @@
|
||||
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
||||
import 'package:get/get.dart';
|
||||
|
||||
import '../../../../../app_settings/app_colors.dart';
|
||||
import '../../../../../tools/CustomUnderlineTabIndicator.dart';
|
||||
import '../../../../../translations/trans_lib.dart';
|
||||
import '../addRemoteControl_page.dart';
|
||||
|
||||
class AddRemoteControlManageTabbar extends StatefulWidget {
|
||||
var initialIndex = 1;
|
||||
|
||||
AddRemoteControlManageTabbar({Key? key, required this.initialIndex}) : super(key: key);
|
||||
|
||||
@override
|
||||
State<AddRemoteControlManageTabbar> createState() => _AddRemoteControlManageTabbarState();
|
||||
}
|
||||
|
||||
class _AddRemoteControlManageTabbarState extends State<AddRemoteControlManageTabbar> with SingleTickerProviderStateMixin {
|
||||
late TabController _tabController;
|
||||
|
||||
final List<ItemView> _itemTabs = <ItemView>[
|
||||
ItemView(title: TranslationLoader.lanKeys!.permanent!.tr, seletType: "0"),
|
||||
ItemView(title: TranslationLoader.lanKeys!.timeLimit!.tr, seletType: "1"),
|
||||
ItemView(title: TranslationLoader.lanKeys!.circulation!.tr, seletType: "2"),
|
||||
];
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
// TODO: implement initState
|
||||
super.initState();
|
||||
_tabController = TabController(
|
||||
vsync: this,
|
||||
length: _itemTabs.length,
|
||||
initialIndex: widget.initialIndex);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Expanded(
|
||||
child: Column(
|
||||
children: [
|
||||
_tabBar(),
|
||||
_pageWidget(),
|
||||
],
|
||||
));
|
||||
}
|
||||
|
||||
TabBar _tabBar() {
|
||||
return TabBar(
|
||||
controller: _tabController,
|
||||
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(
|
||||
child: SizedBox(
|
||||
width: 1.sw / 5,
|
||||
child: Text(item.title, textAlign: TextAlign.center)));
|
||||
}
|
||||
|
||||
Widget _pageWidget() {
|
||||
return Expanded(
|
||||
child: TabBarView(
|
||||
controller: _tabController,
|
||||
children: _itemTabs
|
||||
.map((ItemView item) => AddRemoteControlPage(seletType: item.seletType,))
|
||||
.toList(),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class ItemView {
|
||||
const ItemView({required this.title, required this.seletType});
|
||||
|
||||
final String title;
|
||||
final String seletType;
|
||||
}
|
||||
|
||||
@ -0,0 +1,14 @@
|
||||
|
||||
import 'package:star_lock/tools/baseGetXController.dart';
|
||||
|
||||
import 'addRemoteControl_state.dart';
|
||||
|
||||
class AddRemoteControlLoigc extends BaseGetXController{
|
||||
AddRemoteControlState state = AddRemoteControlState();
|
||||
|
||||
@override
|
||||
void onInit() {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,297 @@
|
||||
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_pickers/pickers.dart';
|
||||
import 'package:flutter_pickers/time_picker/model/date_mode.dart';
|
||||
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
||||
import 'package:get/get.dart';
|
||||
|
||||
import '../../../../appRouters.dart';
|
||||
import '../../../../app_settings/app_colors.dart';
|
||||
import '../../../../tools/commonItem.dart';
|
||||
import '../../../../tools/storage.dart';
|
||||
import '../../../../tools/submitBtn.dart';
|
||||
import '../../../../tools/toast.dart';
|
||||
import '../../../../translations/trans_lib.dart';
|
||||
import 'addRemoteControl_logic.dart';
|
||||
|
||||
class AddRemoteControlPage extends StatefulWidget {
|
||||
final String seletType;
|
||||
|
||||
const AddRemoteControlPage({Key? key, required this.seletType}) : super(key: key);
|
||||
|
||||
@override
|
||||
State<AddRemoteControlPage> createState() => _AddRemoteControlPageState();
|
||||
}
|
||||
|
||||
class _AddRemoteControlPageState extends State<AddRemoteControlPage> {
|
||||
final logic = Get.put(AddRemoteControlLoigc());
|
||||
final state = Get.find<AddRemoteControlLoigc>().state;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
|
||||
return indexChangeWidget();
|
||||
}
|
||||
|
||||
Widget indexChangeWidget() {
|
||||
switch (int.parse(widget.seletType)) {
|
||||
case 0:
|
||||
{
|
||||
// 永久
|
||||
// return sendElectronicKeySucceed();
|
||||
return Column(
|
||||
children: [
|
||||
perpetualKeyWidget(TranslationLoader.lanKeys!.name!.tr,
|
||||
TranslationLoader.lanKeys!.pleaseEnter!.tr, state.nameController),
|
||||
keyBottomWidget()
|
||||
],
|
||||
);
|
||||
}
|
||||
case 1:
|
||||
{
|
||||
// 限时
|
||||
return Column(
|
||||
children: [
|
||||
perpetualKeyWidget(TranslationLoader.lanKeys!.name!.tr,
|
||||
TranslationLoader.lanKeys!.pleaseEnter!.tr, state.nameController),
|
||||
keyTimeLimitWidget(),
|
||||
SizedBox(height: 10.h),
|
||||
keyBottomWidget()
|
||||
],
|
||||
);
|
||||
}
|
||||
case 2:
|
||||
{
|
||||
// 循环
|
||||
return Column(
|
||||
children: [
|
||||
perpetualKeyWidget(TranslationLoader.lanKeys!.name!.tr,
|
||||
TranslationLoader.lanKeys!.pleaseEnter!.tr, state.nameController),
|
||||
CommonItem(
|
||||
leftTitel: TranslationLoader.lanKeys!.periodValidity!.tr,
|
||||
rightTitle: "",
|
||||
isHaveDirection: true,
|
||||
action: () async {
|
||||
Map result = await Get.toNamed(Routers.electronicKeyPeriodValidityPage);
|
||||
state.weekdaysList.value = result['validityValue'];
|
||||
state.effectiveDateTime.value = result['starDate'].millisecondsSinceEpoch;
|
||||
state.failureDateTime.value = result['endDate'].millisecondsSinceEpoch;
|
||||
print('得到的有效期数据:${state.weekdaysList.value} == ${state.effectiveDateTime.value} == ${state.failureDateTime.value}');
|
||||
}),
|
||||
SizedBox(height: 10.h),
|
||||
keyBottomWidget()
|
||||
],
|
||||
);
|
||||
}
|
||||
default:
|
||||
return Container();
|
||||
}
|
||||
}
|
||||
|
||||
// 密码命名输入框
|
||||
Widget perpetualKeyWidget(
|
||||
String titleStr, String rightTitle, TextEditingController controller) {
|
||||
return Column(
|
||||
children: [
|
||||
Container(height: 10.h),
|
||||
CommonItem(
|
||||
leftTitel: titleStr,
|
||||
rightTitle: "",
|
||||
isHaveRightWidget: true,
|
||||
rightWidget: getTFWidget(rightTitle)),
|
||||
Container(height: 10.h),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
// 限时顶部选择日期
|
||||
Widget keyTimeLimitWidget() {
|
||||
return Column(
|
||||
children: [
|
||||
Obx(() => CommonItem(
|
||||
leftTitel: TranslationLoader.lanKeys!.effectiveTime!.tr,
|
||||
rightTitle: state.beginTime.value,
|
||||
isHaveLine: true,
|
||||
isHaveDirection: true,
|
||||
action: () async {
|
||||
Pickers.showDatePicker(context, mode: DateMode.YMDHM,
|
||||
onConfirm: (p) {
|
||||
setState(() {
|
||||
setState(() {
|
||||
state.beginTime.value = '${p.year}-${p.month!.toString().padLeft(2,'0')}-${p.day!.toString().padLeft(2,'0')} ${p.hour!.toString().padLeft(2,'0')}:${p.minute!.toString().padLeft(2,'0')}';
|
||||
state.beginTimeTimestamp.value = DateTime.parse(state.beginTime.value).millisecondsSinceEpoch.toString();
|
||||
});
|
||||
});
|
||||
});
|
||||
})),
|
||||
Obx(() => CommonItem(
|
||||
leftTitel: TranslationLoader.lanKeys!.failureTime!.tr,
|
||||
rightTitle: state.endTime.value,
|
||||
isHaveDirection: true,
|
||||
action: () {
|
||||
Pickers.showDatePicker(context, mode: DateMode.YMDHM,
|
||||
onConfirm: (p) {
|
||||
setState(() {
|
||||
setState(() {
|
||||
state.endTime.value = '${p.year}-${p.month!.toString().padLeft(2,'0')}-${p.day!.toString().padLeft(2,'0')} ${p.hour!.toString().padLeft(2,'0')}:${p.minute!.toString().padLeft(2,'0')}';
|
||||
state.endTimeTimestamp.value = DateTime.parse(state.endTime.value).millisecondsSinceEpoch.toString();
|
||||
});
|
||||
});
|
||||
});
|
||||
})),
|
||||
Container(height: 10.h),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
Widget keyBottomWidget() {
|
||||
return Column(
|
||||
children: [
|
||||
// CommonItem(
|
||||
// leftTitel: TranslationLoader.lanKeys!.remoteControl!.tr,
|
||||
// rightTitle: "",
|
||||
// isTipsImg: false,
|
||||
// isHaveRightWidget: true,
|
||||
// rightWidget: SizedBox(
|
||||
// width: 60.w, height: 50.h, child: _isStressFingerprint())),
|
||||
SizedBox(height: 30.h),
|
||||
SubmitBtn(btnName: TranslationLoader.lanKeys!.next!.tr, onClick: () async {
|
||||
|
||||
var isDemoMode = await Storage.getBool(ifIsDemoModeOrNot);
|
||||
if(isDemoMode == false){
|
||||
// print("state.seletType:${state.seletType.value}");
|
||||
if(state.nameController.text.isEmpty){
|
||||
Toast.show(msg: "请输入姓名");
|
||||
return;
|
||||
}
|
||||
Toast.show(msg: "请确保在设备附近");
|
||||
// logic.addFingerprintsData();
|
||||
}else{
|
||||
// Get.toNamed(Routers.seletLockTypePage);
|
||||
Toast.show(msg: "演示模式");
|
||||
}
|
||||
|
||||
}),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
// 发送电子钥匙成功
|
||||
Widget sendElectronicKeySucceed() {
|
||||
return Column(
|
||||
children: [
|
||||
Container(
|
||||
height: 300.h,
|
||||
width: 1.sw,
|
||||
color: Colors.white,
|
||||
child: Column(
|
||||
children: [
|
||||
SizedBox(
|
||||
height: 30.h,
|
||||
),
|
||||
Image.asset(
|
||||
'images/main/icon_main_addLock.png',
|
||||
width: 150.w,
|
||||
height: 150.w,
|
||||
color: AppColors.mainColor,
|
||||
),
|
||||
SizedBox(
|
||||
height: 20.h,
|
||||
),
|
||||
Text(
|
||||
"操作成功,密码为",
|
||||
style: TextStyle(
|
||||
fontSize: 32.sp,
|
||||
color: Colors.black,
|
||||
fontWeight: FontWeight.w500),
|
||||
),
|
||||
SizedBox(
|
||||
height: 10.h,
|
||||
),
|
||||
Text(
|
||||
"62689876",
|
||||
style: TextStyle(
|
||||
fontSize: 60.sp,
|
||||
color: Colors.black,
|
||||
fontWeight: FontWeight.w500),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
SizedBox(
|
||||
height: 20.h,
|
||||
),
|
||||
SubmitBtn(
|
||||
btnName: '完成',
|
||||
fontSize: 28.sp,
|
||||
borderRadius: 20.w,
|
||||
margin: EdgeInsets.only(left: 30.w, right: 30.w, top: 30.w),
|
||||
padding: EdgeInsets.only(top: 25.w, bottom: 25.w),
|
||||
onClick: () {}),
|
||||
SubmitBtn(
|
||||
btnName: '分享',
|
||||
fontSize: 28.sp,
|
||||
borderRadius: 20.w,
|
||||
margin: EdgeInsets.only(left: 30.w, right: 30.w, top: 30.w),
|
||||
padding: EdgeInsets.only(top: 25.w, bottom: 25.w),
|
||||
onClick: () {}),
|
||||
SubmitBtn(
|
||||
btnName: '标记为:已入住',
|
||||
fontSize: 28.sp,
|
||||
borderRadius: 20.w,
|
||||
margin: EdgeInsets.only(left: 30.w, right: 30.w, top: 30.w),
|
||||
padding: EdgeInsets.only(top: 25.w, bottom: 25.w),
|
||||
onClick: () {}),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
// 接受者信息输入框
|
||||
Widget getTFWidget(String tfStr) {
|
||||
return Container(
|
||||
height: 50.h,
|
||||
width: 300.w,
|
||||
child: Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: TextField(
|
||||
//输入框一行
|
||||
maxLines: 1,
|
||||
controller: state.nameController,
|
||||
autofocus: false,
|
||||
textAlign: TextAlign.end,
|
||||
decoration: InputDecoration(
|
||||
//输入里面输入文字内边距设置
|
||||
contentPadding: const EdgeInsets.only(top: 12.0, bottom: 8.0),
|
||||
hintText: tfStr,
|
||||
hintStyle: TextStyle(fontSize: 24.sp),
|
||||
//不需要输入框下划线
|
||||
border: InputBorder.none,
|
||||
),
|
||||
),
|
||||
),
|
||||
SizedBox(
|
||||
width: 10.w,
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
//isStressFingerprint false:不是胁迫指纹 ture:胁迫指纹
|
||||
CupertinoSwitch _isStressFingerprint() {
|
||||
return CupertinoSwitch(
|
||||
activeColor: CupertinoColors.activeBlue,
|
||||
trackColor: CupertinoColors.systemGrey5,
|
||||
thumbColor: CupertinoColors.white,
|
||||
value: true,
|
||||
onChanged: (value) {
|
||||
setState(() {
|
||||
// state.isStressFingerprint.value = value;
|
||||
});
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,17 @@
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
|
||||
class AddRemoteControlState{
|
||||
|
||||
var beginTime = "".obs;// 开始时间
|
||||
var endTime = "".obs;// 结束时间
|
||||
var beginTimeTimestamp = "".obs;// 开始时间时间戳
|
||||
var endTimeTimestamp = "".obs;// 结束时间时间戳
|
||||
|
||||
var effectiveDateTime = 0.obs;// 生效时间
|
||||
var failureDateTime = 0.obs;// 失效时间
|
||||
var weekdaysList = [].obs;
|
||||
|
||||
final TextEditingController nameController = TextEditingController();
|
||||
}
|
||||
@ -0,0 +1,20 @@
|
||||
|
||||
|
||||
import 'package:star_lock/tools/baseGetXController.dart';
|
||||
|
||||
import 'remoteControlList_state.dart';
|
||||
|
||||
class RemoteControlListLogic extends BaseGetXController{
|
||||
RemoteControlListState state = RemoteControlListState();
|
||||
|
||||
@override
|
||||
void onInit() {
|
||||
super.onInit();
|
||||
}
|
||||
|
||||
@override
|
||||
void onClose() {
|
||||
super.onClose();
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,275 @@
|
||||
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
||||
import 'package:get/get.dart';
|
||||
|
||||
import '../../../../appRouters.dart';
|
||||
import '../../../../app_settings/app_colors.dart';
|
||||
import '../../../../tools/noData.dart';
|
||||
import '../../../../tools/showIosTipView.dart';
|
||||
import '../../../../tools/storage.dart';
|
||||
import '../../../../tools/submitBtn.dart';
|
||||
import '../../../../tools/titleAppBar.dart';
|
||||
import '../../../../tools/toast.dart';
|
||||
import '../../../../translations/trans_lib.dart';
|
||||
import 'remoteControlList_logic.dart';
|
||||
|
||||
class RemoteControlListPage extends StatefulWidget {
|
||||
const RemoteControlListPage({Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
State<RemoteControlListPage> createState() => _RemoteControlListPageState();
|
||||
}
|
||||
|
||||
class _RemoteControlListPageState extends State<RemoteControlListPage> {
|
||||
final logic = Get.put(RemoteControlListLogic());
|
||||
final state = Get.find<RemoteControlListLogic>().state;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
backgroundColor: AppColors.mainBackgroundColor,
|
||||
appBar: TitleAppBar(
|
||||
barTitle: TranslationLoader.lanKeys!.remoteControl!.tr,
|
||||
haveBack: true,
|
||||
backgroundColor: AppColors.mainColor,
|
||||
actionsList: [
|
||||
TextButton(
|
||||
child: Text(
|
||||
TranslationLoader.lanKeys!.reset!.tr,
|
||||
style: TextStyle(color: Colors.white, fontSize: 24.sp),
|
||||
),
|
||||
onPressed: () async {
|
||||
var isDemoMode = await Storage.getBool(ifIsDemoModeOrNot);
|
||||
if (isDemoMode == false) {
|
||||
showDeletAlertDialog(context);
|
||||
} else {
|
||||
// Get.toNamed(Routers.seletLockTypePage);
|
||||
Toast.show(msg: "演示模式");
|
||||
}
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
body: Column(
|
||||
children: [
|
||||
_searchWidget(),
|
||||
SizedBox(
|
||||
height: 20.h,
|
||||
),
|
||||
Expanded(child: _buildMainUI()),
|
||||
AddBottomWhiteBtn(
|
||||
btnName:
|
||||
'${TranslationLoader.lanKeys!.add!.tr}${TranslationLoader.lanKeys!.remoteControl!.tr}',
|
||||
onClick: () async {
|
||||
var data =
|
||||
await Get.toNamed(Routers.addRemoteControlManagePage);
|
||||
if (data != null) {
|
||||
// 遥控添加
|
||||
|
||||
}
|
||||
},
|
||||
),
|
||||
SizedBox(
|
||||
height: 64.h,
|
||||
)
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
// String getAppBarTitle(int type) {
|
||||
// String title = "";
|
||||
// switch (type) {
|
||||
// case 0:
|
||||
// title = TranslationLoader.lanKeys!.card!.tr;
|
||||
// break;
|
||||
// case 1:
|
||||
// title = TranslationLoader.lanKeys!.fingerprint!.tr;
|
||||
// break;
|
||||
// case 2:
|
||||
// title = TranslationLoader.lanKeys!.remoteControl!.tr;
|
||||
// break;
|
||||
// case 3:
|
||||
// title = TranslationLoader.lanKeys!.face!.tr;
|
||||
// break;
|
||||
// default:
|
||||
// break;
|
||||
// }
|
||||
// return title;
|
||||
// }
|
||||
|
||||
Widget _searchWidget() {
|
||||
return Container(
|
||||
height: 60.h,
|
||||
margin: EdgeInsets.only(top: 20.w, left: 20.w, right: 10.w),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white, borderRadius: BorderRadius.circular(5)),
|
||||
child: TextField(
|
||||
//输入框一行
|
||||
maxLines: 1,
|
||||
controller: state.searchController,
|
||||
autofocus: false,
|
||||
onChanged: (value) {
|
||||
print("onChanged:$value");
|
||||
},
|
||||
onEditingComplete: () {
|
||||
print("onEditingComplete:");
|
||||
},
|
||||
onSubmitted: (value) {
|
||||
// 调用遥控列表
|
||||
|
||||
},
|
||||
decoration: InputDecoration(
|
||||
//输入里面输入文字内边距设置
|
||||
contentPadding: const EdgeInsets.only(
|
||||
top: 12.0, left: -19.0, right: -15.0, bottom: 8.0),
|
||||
hintText: TranslationLoader.lanKeys!.pleaseEnter!.tr,
|
||||
hintStyle: TextStyle(fontSize: 22.sp, height: 3.0),
|
||||
//不需要输入框下划线
|
||||
border: InputBorder.none,
|
||||
//左边图标设置
|
||||
icon: Padding(
|
||||
padding: EdgeInsets.only(
|
||||
top: 20.h, bottom: 20.h, right: 20.w, left: 10.w),
|
||||
child: Image.asset(
|
||||
'images/main/icon_main_search.png',
|
||||
width: 40.w,
|
||||
height: 40.w,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildMainUI() {
|
||||
String typeImgName = 'images/icon_card.png';
|
||||
|
||||
return const NoData();
|
||||
}
|
||||
|
||||
Widget _buildDeleteBtn(String idStr) {
|
||||
return GestureDetector(
|
||||
onTap: () {
|
||||
// 省略: 弹出是否删除的确认对话框。
|
||||
showIosTipViewDialog(context, idStr);
|
||||
},
|
||||
child: Container(
|
||||
width: 60,
|
||||
color: const Color(0xFFF20101),
|
||||
alignment: Alignment.center,
|
||||
child: const Text(
|
||||
'删除',
|
||||
style: TextStyle(
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.w500,
|
||||
color: Colors.white,
|
||||
height: 1,
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
void showIosTipViewDialog(BuildContext context, String keyId) {
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (BuildContext context) {
|
||||
return ShowIosTipView(
|
||||
title: "提示",
|
||||
tipTitle: "确定要删除吗?",
|
||||
sureClick: () async {
|
||||
// 遥控删除
|
||||
|
||||
},
|
||||
cancelClick: () {
|
||||
Get.back();
|
||||
},
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
Widget _keyItem(String lockTypeIcon, String lockTypeTitle, String showTime,
|
||||
Function() action) {
|
||||
return GestureDetector(
|
||||
onTap: action,
|
||||
child: Container(
|
||||
height: 90.h,
|
||||
// margin: EdgeInsets.only(left: 20.w, right: 20.w, top: 20.w),
|
||||
color: Colors.white,
|
||||
// decoration: BoxDecoration(
|
||||
// color: Colors.white,
|
||||
// // borderRadius: BorderRadius.circular(10.w),
|
||||
// ),
|
||||
child: Row(
|
||||
children: [
|
||||
SizedBox(width: 30.w),
|
||||
Image.asset(lockTypeIcon, width: 60.w, height: 60.w),
|
||||
SizedBox(width: 20.w),
|
||||
Expanded(
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
children: [
|
||||
Text(lockTypeTitle,
|
||||
style: TextStyle(
|
||||
fontSize: 24.sp, color: AppColors.blackColor)),
|
||||
],
|
||||
),
|
||||
SizedBox(height: 5.h),
|
||||
Container(
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
children: [
|
||||
Text(showTime,
|
||||
style: TextStyle(
|
||||
fontSize: 18.sp,
|
||||
color: AppColors.placeholderTextColor)),
|
||||
],
|
||||
),
|
||||
),
|
||||
SizedBox(width: 20.h),
|
||||
],
|
||||
),
|
||||
),
|
||||
SizedBox(width: 20.h),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
void showDeletAlertDialog(
|
||||
BuildContext context,
|
||||
) {
|
||||
showCupertinoDialog(
|
||||
context: context,
|
||||
builder: (context) {
|
||||
return CupertinoAlertDialog(
|
||||
title: const Text("提示"),
|
||||
content: const Text('重置后信息都会清除哦,确认要重置吗?'),
|
||||
actions: [
|
||||
CupertinoDialogAction(
|
||||
child: Text(TranslationLoader.lanKeys!.cancel!.tr),
|
||||
onPressed: () {
|
||||
Navigator.pop(context);
|
||||
},
|
||||
),
|
||||
CupertinoDialogAction(
|
||||
child: Text(TranslationLoader.lanKeys!.sure!.tr),
|
||||
onPressed: () {
|
||||
// 遥控重置
|
||||
|
||||
},
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,7 @@
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class RemoteControlListState{
|
||||
final TextEditingController searchController = TextEditingController();
|
||||
|
||||
}
|
||||
@ -262,8 +262,8 @@ class _DemoModeLockDetailPageState extends State<DemoModeLockDetailPage> {
|
||||
TranslationLoader.lanKeys!.card!.tr, () {
|
||||
// gotoLogin();
|
||||
|
||||
Get.toNamed(Routers.otherTypeKeyListPage,
|
||||
arguments: {"lockId": 0, "fromType": 0});
|
||||
Get.toNamed(Routers.cardListPage,
|
||||
arguments: {"lockId": 0});
|
||||
}),
|
||||
|
||||
// 指纹
|
||||
@ -271,7 +271,7 @@ class _DemoModeLockDetailPageState extends State<DemoModeLockDetailPage> {
|
||||
TranslationLoader.lanKeys!.fingerprint!.tr, () {
|
||||
// gotoLogin();
|
||||
|
||||
Get.toNamed(Routers.otherTypeKeyListPage,
|
||||
Get.toNamed(Routers.fingerprintDetailPage,
|
||||
arguments: {"lockId": 1, "fromType": 1});
|
||||
}),
|
||||
|
||||
|
||||
@ -127,6 +127,10 @@ class _AddLockSeletCountryPageState extends State<AddLockSeletCountryPage> {
|
||||
Get.toNamed(Routers.saveLockPage, arguments: {
|
||||
"addressInfo": {},
|
||||
"pwdTimestamp": state.pwdTimestamp.value,
|
||||
"lockInfo": state.lockInfo,
|
||||
"featureValue": state.featureValue,
|
||||
"featureSettingValue": state.featureSettingValue,
|
||||
"featureSettingParams": state.featureSettingParams,
|
||||
});
|
||||
},
|
||||
),
|
||||
@ -144,6 +148,10 @@ class _AddLockSeletCountryPageState extends State<AddLockSeletCountryPage> {
|
||||
Get.toNamed(Routers.saveLockPage, arguments: {
|
||||
"addressInfo": {"country":model.name},
|
||||
"pwdTimestamp": state.pwdTimestamp.value,
|
||||
"lockInfo": state.lockInfo,
|
||||
"featureValue": state.featureValue,
|
||||
"featureSettingValue": state.featureSettingValue,
|
||||
"featureSettingParams": state.featureSettingParams,
|
||||
});
|
||||
// Navigator.pushNamed(context, Routers.saveLockPage);
|
||||
},
|
||||
|
||||
@ -4,8 +4,16 @@ import 'package:get/get.dart';
|
||||
class AddLockSeletCountryState{
|
||||
|
||||
var pwdTimestamp= 0.obs;
|
||||
var lockInfo = {};
|
||||
var featureValue = '';
|
||||
var featureSettingValue = '';
|
||||
var featureSettingParams = [];
|
||||
AddLockSeletCountryState() {
|
||||
Map map = Get.arguments;
|
||||
pwdTimestamp.value = map["pwdTimestamp"];
|
||||
lockInfo = map["lockInfo"];
|
||||
featureValue = map["featureValue"];
|
||||
featureSettingValue = map["featureSettingValue"];
|
||||
featureSettingParams = map["featureSettingParams"];
|
||||
}
|
||||
}
|
||||
|
||||
@ -238,6 +238,10 @@ class _LockAddressGaoDePageState extends State<LockAddressGaoDePage>{
|
||||
Get.toNamed(Routers.addLockSeletCountryPage, arguments: {
|
||||
"addressInfo": {},
|
||||
"pwdTimestamp": state.pwdTimestamp.value,
|
||||
"lockInfo": state.lockInfo,
|
||||
"featureValue": state.featureValue,
|
||||
"featureSettingValue": state.featureSettingValue,
|
||||
"featureSettingParams": state.featureSettingParams,
|
||||
});
|
||||
},
|
||||
),
|
||||
@ -254,6 +258,10 @@ class _LockAddressGaoDePageState extends State<LockAddressGaoDePage>{
|
||||
Get.toNamed(Routers.saveLockPage, arguments: {
|
||||
"addressInfo": addressInfo,
|
||||
"pwdTimestamp": state.pwdTimestamp.value,
|
||||
"lockInfo": state.lockInfo,
|
||||
"featureValue": state.featureValue,
|
||||
"featureSettingValue": state.featureSettingValue,
|
||||
"featureSettingParams": state.featureSettingParams,
|
||||
});
|
||||
// Navigator.pushNamed(context, Routers.saveLockPage);
|
||||
},
|
||||
|
||||
@ -8,8 +8,17 @@ import 'package:permission_handler/permission_handler.dart';
|
||||
class LockAddressGaoDeState{
|
||||
|
||||
var pwdTimestamp= 0.obs;
|
||||
var lockInfo = {};
|
||||
var featureValue = '';
|
||||
var featureSettingValue = '';
|
||||
var featureSettingParams = [];
|
||||
|
||||
LockAddressGaoDeState() {
|
||||
Map map = Get.arguments;
|
||||
pwdTimestamp.value = map["pwdTimestamp"];
|
||||
lockInfo = map["lockInfo"];
|
||||
featureValue = map["featureValue"];
|
||||
featureSettingValue = map["featureSettingValue"];
|
||||
featureSettingParams = map["featureSettingParams"];
|
||||
}
|
||||
}
|
||||
@ -12,6 +12,7 @@ import 'package:star_lock/tools/baseGetXController.dart';
|
||||
import '../../../appRouters.dart';
|
||||
import '../../../blue/blue_manage.dart';
|
||||
import '../../../blue/io_protocol/io_addUser.dart';
|
||||
import '../../../blue/io_protocol/io_getStarLockStatusInfo.dart';
|
||||
import '../../../blue/io_reply.dart';
|
||||
import '../../../blue/io_tool/io_manager.dart';
|
||||
import '../../../blue/io_tool/io_model.dart';
|
||||
@ -48,6 +49,11 @@ class NearbyLockLogic extends BaseGetXController{
|
||||
if(reply is GetPrivateKeyReply) {
|
||||
_replyGetPrivateKeyKey(reply);
|
||||
}
|
||||
|
||||
// 获取锁状态信息
|
||||
if(reply is GetStarLockStatuInfoReply) {
|
||||
_replyGetStarLockStatusInfo(reply);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@ -107,17 +113,15 @@ class NearbyLockLogic extends BaseGetXController{
|
||||
|
||||
// 时间戳
|
||||
List<int> timestamp = reply.data.sublist(32, 36);
|
||||
int timestampValue = (
|
||||
state.timestampValue = (
|
||||
(0xff & timestamp[(0)]) << 24 |
|
||||
(0xff & timestamp[1]) << 16 |
|
||||
(0xff & timestamp[2]) << 8 |
|
||||
(0xFF & timestamp[3]));
|
||||
String timestampValueStr = DateTool().dateToYMDHNSString(timestampValue.toString());
|
||||
print("timestamp:$timestamp timestampValue:$timestampValue timestampValueStr:$timestampValueStr");
|
||||
// String timestampValueStr = DateTool().dateToYMDHNSString(timestampValue.toString());
|
||||
// print("timestamp:$timestamp timestampValue:$timestampValue timestampValueStr:$timestampValueStr");
|
||||
|
||||
Get.toNamed(Routers.lockAddressGaoDePage, arguments: {
|
||||
"pwdTimestamp": timestampValue*1000,
|
||||
});
|
||||
_getStarLockStatus();
|
||||
break;
|
||||
case 0x07:
|
||||
//无权限
|
||||
@ -135,6 +139,198 @@ class NearbyLockLogic extends BaseGetXController{
|
||||
}
|
||||
}
|
||||
|
||||
// 获取星锁状态
|
||||
Future<void> _replyGetStarLockStatusInfo(Reply reply) async {
|
||||
int status = reply.data[2];
|
||||
switch(status){
|
||||
case 0x00:
|
||||
//成功
|
||||
print("${reply.commandType}数据解析成功");
|
||||
|
||||
// 厂商名称
|
||||
var vendor = reply.data.sublist(3, 23);
|
||||
print("vendor:$vendor reply.data:${reply.data}");
|
||||
var vendorStr = utf8String(vendor);
|
||||
state.lockInfo["vendor"] = vendorStr;
|
||||
// print("vendor:$vendor vendorStr:$vendorStr vendorStr.length${vendorStr.length}");
|
||||
|
||||
// 锁设备类型
|
||||
var product = reply.data[23];
|
||||
state.lockInfo["product"] = product;
|
||||
// print("product:$product");
|
||||
|
||||
// 产品名称
|
||||
var model = reply.data.sublist(24, 44);
|
||||
var modelStr = utf8String(model);
|
||||
state.lockInfo["model"] = modelStr;
|
||||
// print("model:$model modelStr:$modelStr modelStr:${modelStr.length}");
|
||||
|
||||
// 软件版本
|
||||
var fwVersion = reply.data.sublist(44, 64);
|
||||
var fwVersionStr = utf8String(fwVersion);
|
||||
state.lockInfo["fwVersion"] = fwVersionStr;
|
||||
// print("fwVersion:$fwVersion fwVersionStr:$fwVersionStr fwVersionStr:${fwVersionStr.length}");
|
||||
|
||||
// 硬件版本
|
||||
var hwVersion = reply.data.sublist(64, 84);
|
||||
var hwVersionStr = utf8String(hwVersion);
|
||||
state.lockInfo["hwVersion"] = hwVersionStr;
|
||||
// print("hwVersion:$hwVersion hwVersionStr:${hwVersionStr.length}");
|
||||
|
||||
// 厂商序列号
|
||||
var serialNum0 = reply.data.sublist(84, 100);
|
||||
var serialNum0Str = utf8String(serialNum0);
|
||||
// state.lockInfo["serialNum0"] = serialNum0Str;
|
||||
state.lockInfo["serialNum0"] = "${DateTime.now().millisecondsSinceEpoch~/10}";
|
||||
// print("serialNum0Str:$serialNum0Str serialNum0Str:${serialNum0Str.length}");
|
||||
|
||||
// 成品商序列号
|
||||
var serialNum1 = reply.data.sublist(100, 116);
|
||||
var serialNum1Str = utf8String(serialNum1);
|
||||
state.lockInfo["serialNum1"] = serialNum1Str;
|
||||
// print("serialNum1Str:$serialNum1Str serialNum1Str:${serialNum1Str.length}");
|
||||
|
||||
// 蓝牙名称
|
||||
var btDeviceName = reply.data.sublist(116, 132);
|
||||
var btDeviceNameStr = utf8String(btDeviceName);
|
||||
state.lockInfo["btDeviceName"] = btDeviceNameStr;
|
||||
// print("btDeviceName:$btDeviceName btDeviceNameStr:$btDeviceNameStr btDeviceNameStr:${btDeviceNameStr.length}");
|
||||
|
||||
// 电池剩余电量
|
||||
var battRemCap = reply.data[132];
|
||||
state.lockInfo["electricQuantity"] = battRemCap;
|
||||
// print("battRemCap:$battRemCap");
|
||||
|
||||
// 重置次数
|
||||
var restoreCounter = reply.data.sublist(133, 135);
|
||||
state.lockInfo["restoreCount"] = restoreCounter[0] * 256 + restoreCounter[1];
|
||||
// print("restoreCounter:$restoreCounter");
|
||||
|
||||
// 重置时间
|
||||
var restoreDate = reply.data.sublist(135, 139);
|
||||
int restoreDateValue = ((0xff & restoreDate[(0)]) << 24 | (0xff & restoreDate[1]) << 16 | (0xff & restoreDate[2]) << 8 | (0xFF & restoreDate[3]));
|
||||
// String restoreDateStr = DateTool().dateToYMDHNSString(restoreDateValue.toString());
|
||||
state.lockInfo["restoreDate"] = restoreDateValue*1000;
|
||||
// print("restoreDate:$restoreDate restoreDateValue:$restoreDateValue");
|
||||
|
||||
// 主控芯片型号
|
||||
var icPartNo = reply.data.sublist(139, 149);
|
||||
var icPartNoStr = utf8String(icPartNo);
|
||||
state.lockInfo["icPartNo"] = icPartNoStr;
|
||||
// print("icPartNo:$icPartNo icPartNoStr:$icPartNoStr");
|
||||
|
||||
// 有效时间
|
||||
var indate = reply.data.sublist(149, 153);
|
||||
int indateValue = ((0xff & indate[(0)]) << 24 | (0xff & indate[1]) << 16 | (0xff & indate[2]) << 8 | (0xFF & indate[3]));
|
||||
// String indateStr = DateTool().dateToYMDHNSString("$indateValue");
|
||||
state.lockInfo["indate"] = indateValue*1000;
|
||||
// print("indate:$indate indateValue:$indateValue");
|
||||
|
||||
// mac地址
|
||||
var macAddress = reply.data.sublist(153, 173);
|
||||
var macAddressStr = utf8String(macAddress);
|
||||
state.lockInfo["mac"] = macAddressStr;
|
||||
print("macAddress:$macAddress macAddressStr:$macAddressStr");
|
||||
|
||||
var index = 173;
|
||||
// 锁特征值字符串长度
|
||||
var featureValueLength = reply.data[173];
|
||||
// 锁特征值说明(本机能支持的功能)
|
||||
// 获取到锁给的字符数组
|
||||
var featureValue = reply.data.sublist(index+1, index + featureValueLength+1);
|
||||
String featureValueStr = asciiString(featureValue);
|
||||
state.featureValue = featureValueStr;
|
||||
// List allFeatureValueTwoList = charListChangeIntList(featureValue);
|
||||
// print("featureValueLength:$featureValueLength featureValue:$featureValue \n featureValueStr:$featureValueStr");
|
||||
index = index + featureValueLength + 1;
|
||||
|
||||
// 使能特征值字符串长度
|
||||
var featureEnValLength = reply.data[index];
|
||||
// 使能锁特征值说明(本机启用的功能)
|
||||
var featureEnVal = reply.data.sublist(index+1, index + featureEnValLength+1);
|
||||
String featureEnValStr = asciiString(featureValue);
|
||||
state.featureSettingValue = featureEnValStr;
|
||||
// List allFeatureEnValTwoList = charListChangeIntList(featureEnVal);
|
||||
// print("featureEnValLength:$featureEnValLength featureEnVal:$featureEnVal \n featureEnValStr:$featureEnValStr");
|
||||
index = index + featureEnValLength + 1;
|
||||
|
||||
// 支持的带参数特征值的总条目数
|
||||
// var featureParaTotal = reply.data[index];
|
||||
|
||||
var featureParaTotalList = reply.data.sublist(index);
|
||||
state.featureSettingParams = featureParaTotalList;
|
||||
// print("featureParaTotalList:$featureParaTotalList");
|
||||
|
||||
Get.toNamed(Routers.lockAddressGaoDePage, arguments: {
|
||||
"pwdTimestamp": state.timestampValue*1000,
|
||||
"lockInfo": state.lockInfo,
|
||||
"featureValue": state.featureValue,
|
||||
"featureSettingValue": state.featureSettingValue,
|
||||
"featureSettingParams": state.featureSettingParams,
|
||||
});
|
||||
|
||||
break;
|
||||
case 0x06:
|
||||
//无权限
|
||||
print("${reply.commandType}需要鉴权");
|
||||
|
||||
break;
|
||||
case 0x07:
|
||||
//无权限
|
||||
print("${reply.commandType}用户无权限");
|
||||
|
||||
break;
|
||||
case 0x09:
|
||||
// 权限校验错误
|
||||
print("${reply.commandType}权限校验错误");
|
||||
|
||||
break;
|
||||
default:
|
||||
//失败
|
||||
print("${reply.commandType}失败");
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// List charListChangeIntList(List<int> featureValue){
|
||||
// // 字符数组转化为16进制字符串
|
||||
// String featureValueStr = asciiString(featureValue);
|
||||
// // 16进制字符串转化为2进制的字符串 获取的是逆序的需要倒序 前面有0会消失 需要自动补全 暂时定位57个功能 要补全60
|
||||
// String featureValueTwoStr = int.parse(featureValueStr,radix: 16).toRadixString(2);
|
||||
// List<int> featureValueTwoList = [];
|
||||
// for(int i = 0;i<featureValueTwoStr.length;i++){
|
||||
// featureValueTwoList.add(int.parse(featureValueTwoStr[i]));
|
||||
// }
|
||||
// // 逆序
|
||||
// featureValueTwoList = featureValueTwoList.reversed.toList();
|
||||
// List allFeatureValueTwoList = getFixedLengthList(featureValueTwoList, 60 - featureValueTwoList.length);
|
||||
// // print("featureValueStr:$featureValueStr featureValueTwoStr:$featureValueTwoStr featureValueTwoList:$featureValueTwoList allFeatureValueTwoList:$allFeatureValueTwoList");
|
||||
// return allFeatureValueTwoList;
|
||||
// }
|
||||
|
||||
// 获取锁状态
|
||||
Future<void> _getStarLockStatus() async {
|
||||
// print("connectDeviceMacAddress:${BlueManage().connectDeviceMacAddress} connectDeviceName:${BlueManage().connectDeviceName}");
|
||||
// 进来之后首先连接
|
||||
BlueManage().judgeReconnect(BlueManage().connectDeviceMacAddress, BlueManage().connectDeviceName, (DeviceConnectionState state) async {
|
||||
if (state == DeviceConnectionState.connected) {
|
||||
var privateKey = await Storage.getStringList(saveBluePrivateKey);
|
||||
List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
|
||||
// IoSenderManage.senderGetLockStatu(
|
||||
// lockID:BlueManage().connectDeviceName,
|
||||
// userID:await Storage.getUid(),
|
||||
// privateKey:getPrivateKeyList,
|
||||
// );
|
||||
IoSenderManage.senderGetStarLockStatuInfo(
|
||||
lockID:BlueManage().connectDeviceName,
|
||||
userID:await Storage.getUid(),
|
||||
privateKey:getPrivateKeyList,
|
||||
);
|
||||
}
|
||||
}, isShowLoading: false);
|
||||
}
|
||||
|
||||
@override
|
||||
void onReady() {
|
||||
// TODO: implement onReady
|
||||
|
||||
@ -8,4 +8,11 @@ class NearbyLockState {
|
||||
|
||||
RxList<DiscoveredDevice> devices = <DiscoveredDevice>[].obs;
|
||||
var seletLockName = "".obs;
|
||||
|
||||
var timestampValue = 0;
|
||||
var lockInfo = {};
|
||||
var featureValue = '';
|
||||
var featureSettingValue = '';
|
||||
var featureSettingParams = [];
|
||||
|
||||
}
|
||||
@ -28,11 +28,6 @@ class SaveLockLogic extends BaseGetXController {
|
||||
if(reply is AddUserReply) {
|
||||
_replyAddUserKey(reply);
|
||||
}
|
||||
|
||||
// 获取锁状态信息
|
||||
if(reply is GetStarLockStatuInfoReply) {
|
||||
_replyGetStarLockStatusInfo(reply);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@ -68,13 +63,13 @@ class SaveLockLogic 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(),
|
||||
openMode:1,
|
||||
keyType:1,
|
||||
startDate:0x11223344,
|
||||
startDate:DateTime.now().millisecondsSinceEpoch,
|
||||
expireDate:0x11223344,
|
||||
role:255,
|
||||
password:"123456",
|
||||
@ -102,168 +97,6 @@ class SaveLockLogic extends BaseGetXController {
|
||||
}
|
||||
}
|
||||
|
||||
// 获取星锁状态
|
||||
Future<void> _replyGetStarLockStatusInfo(Reply reply) async {
|
||||
int status = reply.data[2];
|
||||
switch(status){
|
||||
case 0x00:
|
||||
//成功
|
||||
print("${reply.commandType}数据解析成功");
|
||||
|
||||
// 厂商名称
|
||||
var vendor = reply.data.sublist(3, 23);
|
||||
print("vendor:$vendor reply.data:${reply.data}");
|
||||
var vendorStr = utf8String(vendor);
|
||||
state.lockInfo["vendor"] = vendorStr;
|
||||
// print("vendor:$vendor vendorStr:$vendorStr vendorStr.length${vendorStr.length}");
|
||||
|
||||
// 锁设备类型
|
||||
var product = reply.data[23];
|
||||
state.lockInfo["product"] = product;
|
||||
// print("product:$product");
|
||||
|
||||
// 产品名称
|
||||
var model = reply.data.sublist(24, 44);
|
||||
var modelStr = utf8String(model);
|
||||
state.lockInfo["model"] = modelStr;
|
||||
// print("model:$model modelStr:$modelStr modelStr:${modelStr.length}");
|
||||
|
||||
// 软件版本
|
||||
var fwVersion = reply.data.sublist(44, 64);
|
||||
var fwVersionStr = utf8String(fwVersion);
|
||||
state.lockInfo["fwVersion"] = fwVersionStr;
|
||||
// print("fwVersion:$fwVersion fwVersionStr:$fwVersionStr fwVersionStr:${fwVersionStr.length}");
|
||||
|
||||
// 硬件版本
|
||||
var hwVersion = reply.data.sublist(64, 84);
|
||||
var hwVersionStr = utf8String(hwVersion);
|
||||
state.lockInfo["hwVersion"] = hwVersionStr;
|
||||
// print("hwVersion:$hwVersion hwVersionStr:${hwVersionStr.length}");
|
||||
|
||||
// 厂商序列号
|
||||
var serialNum0 = reply.data.sublist(84, 100);
|
||||
var serialNum0Str = utf8String(serialNum0);
|
||||
// state.lockInfo["serialNum0"] = serialNum0Str;
|
||||
state.lockInfo["serialNum0"] = "${DateTime.now().millisecondsSinceEpoch~/10}";
|
||||
// print("serialNum0Str:$serialNum0Str serialNum0Str:${serialNum0Str.length}");
|
||||
|
||||
// 成品商序列号
|
||||
var serialNum1 = reply.data.sublist(100, 116);
|
||||
var serialNum1Str = utf8String(serialNum1);
|
||||
state.lockInfo["serialNum1"] = serialNum1Str;
|
||||
// print("serialNum1Str:$serialNum1Str serialNum1Str:${serialNum1Str.length}");
|
||||
|
||||
// 蓝牙名称
|
||||
var btDeviceName = reply.data.sublist(116, 132);
|
||||
var btDeviceNameStr = utf8String(btDeviceName);
|
||||
state.lockInfo["btDeviceName"] = btDeviceNameStr;
|
||||
// print("btDeviceName:$btDeviceName btDeviceNameStr:$btDeviceNameStr btDeviceNameStr:${btDeviceNameStr.length}");
|
||||
|
||||
// 电池剩余电量
|
||||
var battRemCap = reply.data[132];
|
||||
state.lockInfo["electricQuantity"] = battRemCap;
|
||||
// print("battRemCap:$battRemCap");
|
||||
|
||||
// 重置次数
|
||||
var restoreCounter = reply.data.sublist(133, 135);
|
||||
state.lockInfo["restoreCount"] = restoreCounter[0] * 256 + restoreCounter[1];
|
||||
// print("restoreCounter:$restoreCounter");
|
||||
|
||||
// 重置时间
|
||||
var restoreDate = reply.data.sublist(135, 139);
|
||||
int restoreDateValue = ((0xff & restoreDate[(0)]) << 24 | (0xff & restoreDate[1]) << 16 | (0xff & restoreDate[2]) << 8 | (0xFF & restoreDate[3]));
|
||||
// String restoreDateStr = DateTool().dateToYMDHNSString(restoreDateValue.toString());
|
||||
state.lockInfo["restoreDate"] = restoreDateValue*1000;
|
||||
// print("restoreDate:$restoreDate restoreDateValue:$restoreDateValue");
|
||||
|
||||
// 主控芯片型号
|
||||
var icPartNo = reply.data.sublist(139, 149);
|
||||
var icPartNoStr = utf8String(icPartNo);
|
||||
state.lockInfo["icPartNo"] = icPartNoStr;
|
||||
// print("icPartNo:$icPartNo icPartNoStr:$icPartNoStr");
|
||||
|
||||
// 有效时间
|
||||
var indate = reply.data.sublist(149, 153);
|
||||
int indateValue = ((0xff & indate[(0)]) << 24 | (0xff & indate[1]) << 16 | (0xff & indate[2]) << 8 | (0xFF & indate[3]));
|
||||
// String indateStr = DateTool().dateToYMDHNSString("$indateValue");
|
||||
state.lockInfo["indate"] = indateValue*1000;
|
||||
// print("indate:$indate indateValue:$indateValue");
|
||||
|
||||
// mac地址
|
||||
var macAddress = reply.data.sublist(153, 173);
|
||||
var macAddressStr = utf8String(macAddress);
|
||||
state.lockInfo["mac"] = macAddressStr;
|
||||
print("macAddress:$macAddress macAddressStr:$macAddressStr");
|
||||
|
||||
var index = 173;
|
||||
// 锁特征值字符串长度
|
||||
var featureValueLength = reply.data[173];
|
||||
// 锁特征值说明(本机能支持的功能)
|
||||
// 获取到锁给的字符数组
|
||||
var featureValue = reply.data.sublist(index+1, index + featureValueLength+1);
|
||||
String featureValueStr = asciiString(featureValue);
|
||||
state.featureValue = featureValueStr;
|
||||
// List allFeatureValueTwoList = charListChangeIntList(featureValue);
|
||||
// print("featureValueLength:$featureValueLength featureValue:$featureValue \n featureValueStr:$featureValueStr");
|
||||
index = index + featureValueLength + 1;
|
||||
|
||||
// 使能特征值字符串长度
|
||||
var featureEnValLength = reply.data[index];
|
||||
// 使能锁特征值说明(本机启用的功能)
|
||||
var featureEnVal = reply.data.sublist(index+1, index + featureEnValLength+1);
|
||||
String featureEnValStr = asciiString(featureValue);
|
||||
state.featureSettingValue = featureEnValStr;
|
||||
// List allFeatureEnValTwoList = charListChangeIntList(featureEnVal);
|
||||
// print("featureEnValLength:$featureEnValLength featureEnVal:$featureEnVal \n featureEnValStr:$featureEnValStr");
|
||||
index = index + featureEnValLength + 1;
|
||||
|
||||
// 支持的带参数特征值的总条目数
|
||||
// var featureParaTotal = reply.data[index];
|
||||
|
||||
var featureParaTotalList = reply.data.sublist(index);
|
||||
state.featureSettingParams = featureParaTotalList;
|
||||
// print("featureParaTotalList:$featureParaTotalList");
|
||||
|
||||
break;
|
||||
case 0x06:
|
||||
//无权限
|
||||
print("${reply.commandType}需要鉴权");
|
||||
|
||||
break;
|
||||
case 0x07:
|
||||
//无权限
|
||||
print("${reply.commandType}用户无权限");
|
||||
|
||||
break;
|
||||
case 0x09:
|
||||
// 权限校验错误
|
||||
print("${reply.commandType}权限校验错误");
|
||||
|
||||
break;
|
||||
default:
|
||||
//失败
|
||||
print("${reply.commandType}失败");
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
List charListChangeIntList(List<int> featureValue){
|
||||
// 字符数组转化为16进制字符串
|
||||
String featureValueStr = asciiString(featureValue);
|
||||
// 16进制字符串转化为2进制的字符串 获取的是逆序的需要倒序 前面有0会消失 需要自动补全 暂时定位57个功能 要补全60
|
||||
String featureValueTwoStr = int.parse(featureValueStr,radix: 16).toRadixString(2);
|
||||
List<int> featureValueTwoList = [];
|
||||
for(int i = 0;i<featureValueTwoStr.length;i++){
|
||||
featureValueTwoList.add(int.parse(featureValueTwoStr[i]));
|
||||
}
|
||||
// 逆序
|
||||
featureValueTwoList = featureValueTwoList.reversed.toList();
|
||||
List allFeatureValueTwoList = getFixedLengthList(featureValueTwoList, 60 - featureValueTwoList.length);
|
||||
// print("featureValueStr:$featureValueStr featureValueTwoStr:$featureValueTwoStr featureValueTwoList:$featureValueTwoList allFeatureValueTwoList:$allFeatureValueTwoList");
|
||||
return allFeatureValueTwoList;
|
||||
}
|
||||
|
||||
// 保存事件,先调用蓝牙,蓝牙调用成功后再调用后台接口
|
||||
saveLockAction(){
|
||||
addUserConnectBlue();
|
||||
@ -355,28 +188,6 @@ class SaveLockLogic extends BaseGetXController {
|
||||
}
|
||||
}
|
||||
|
||||
// 获取锁状态
|
||||
Future<void> _getStarLockStatus() async {
|
||||
// print("connectDeviceMacAddress:${BlueManage().connectDeviceMacAddress} connectDeviceName:${BlueManage().connectDeviceName}");
|
||||
// 进来之后首先连接
|
||||
BlueManage().judgeReconnect(BlueManage().connectDeviceMacAddress, BlueManage().connectDeviceName, (DeviceConnectionState state) async {
|
||||
if (state == DeviceConnectionState.connected) {
|
||||
var privateKey = await Storage.getStringList(saveBluePrivateKey);
|
||||
List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
|
||||
// IoSenderManage.senderGetLockStatu(
|
||||
// lockID:BlueManage().connectDeviceName,
|
||||
// userID:await Storage.getUid(),
|
||||
// privateKey:getPrivateKeyList,
|
||||
// );
|
||||
IoSenderManage.senderGetStarLockStatuInfo(
|
||||
lockID:BlueManage().connectDeviceName,
|
||||
userID:await Storage.getUid(),
|
||||
privateKey:getPrivateKeyList,
|
||||
);
|
||||
}
|
||||
}, isShowLoading: false);
|
||||
}
|
||||
|
||||
@override
|
||||
void onReady() {
|
||||
// TODO: implement onReady
|
||||
@ -384,8 +195,6 @@ class SaveLockLogic extends BaseGetXController {
|
||||
print("onReady()");
|
||||
|
||||
_initReplySubscription();
|
||||
|
||||
_getStarLockStatus();
|
||||
}
|
||||
|
||||
@override
|
||||
|
||||
@ -24,6 +24,10 @@ class SaveLockState {
|
||||
Map map = Get.arguments;
|
||||
pwdTimestamp.value = map["pwdTimestamp"];
|
||||
addressInfo.value = map["addressInfo"];
|
||||
lockInfo = map["lockInfo"];
|
||||
featureValue = map["featureValue"];
|
||||
featureSettingValue = map["featureSettingValue"];
|
||||
featureSettingParams = map["featureSettingParams"];
|
||||
}
|
||||
|
||||
void onClose() {
|
||||
|
||||
@ -22,6 +22,7 @@ import '../common/safetyVerification/entity/SafetyVerificationEntity.dart';
|
||||
import '../login/login/entity/LoginEntity.dart';
|
||||
import '../login/register/entity/SendValidationCodeEntity.dart';
|
||||
import '../main/lockDetail/authorizedAdmin/authorizedAdmin/authorizedAdmin_entity.dart';
|
||||
import '../main/lockDetail/card/addICCard/addICCard_entity.dart';
|
||||
import '../main/lockDetail/checkingIn/checkingInDetail/checkingInDetail_entity.dart';
|
||||
import '../main/lockDetail/checkingIn/checkingInHolidays/checkingInSetHolidays/checkingInSetHolidays_entity.dart';
|
||||
import '../main/lockDetail/checkingIn/checkingInList/checkingInListDay_entity.dart';
|
||||
@ -29,15 +30,14 @@ import '../main/lockDetail/checkingIn/checkingInList/checkingInListMonth_entity.
|
||||
import '../main/lockDetail/checkingIn/checkingInSet/checkingInSet_entity.dart';
|
||||
import '../main/lockDetail/checkingIn/checkingInStaff/checkingInSetAddStaff/checkingInAddStaffSeletKey_entity.dart';
|
||||
import '../main/lockDetail/checkingIn/checkingInStaff/checkingInSetStaffList/checkingInStaffList_entity.dart';
|
||||
import '../main/lockDetail/fingerprint/addFingerprint/addFingerprint_entity.dart';
|
||||
import '../main/lockDetail/fingerprint/fingerprintList/fingerprintListData_entity.dart';
|
||||
import '../main/lockDetail/lcokSet/configuringWifi/configuringWifiEntity.dart';
|
||||
import '../main/lockDetail/lcokSet/lockSet/checkingInInfoData_entity.dart';
|
||||
import '../main/lockDetail/lcokSet/lockSet/lockSetInfo_entity.dart';
|
||||
import '../main/lockDetail/lcokSet/lockTime/getServerDatetime_entity.dart';
|
||||
import '../main/lockDetail/lockDetail/lockNetToken_entity.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';
|
||||
import '../main/lockMian/entity/lockListInfo_entity.dart';
|
||||
import '../mine/addLock/saveLock/entity/SaveLockEntity.dart';
|
||||
import '../mine/minePersonInfo/minePersonInfoPage/minePersonGetUploadFileInfo_entity.dart';
|
||||
|
||||
@ -4,8 +4,7 @@ import 'package:get/get.dart';
|
||||
import 'package:get/get_connect/http/src/request/request.dart';
|
||||
|
||||
FutureOr<dynamic> responseLogInterceptor(Request request, Response response) {
|
||||
Get.log(
|
||||
'HTTP RESPONSE =>\n stataCode:${response.statusCode} ${response.body} ${response.headers}');
|
||||
Get.log('HTTP request:${request.url}\n RESPONSE => stataCode:${response.statusCode} ${response.body} ${response.headers}');
|
||||
EasyLoading.dismiss(animation: true);
|
||||
return response;
|
||||
}
|
||||
|
||||
@ -449,6 +449,8 @@ class LanKeyEntity {
|
||||
this.openRight,
|
||||
this.judgmentMethod,
|
||||
this.judgmentMethodContent,
|
||||
this.stressPassword,
|
||||
this.stressCard,
|
||||
});
|
||||
|
||||
LanKeyEntity.fromJson(dynamic json) {
|
||||
@ -935,6 +937,8 @@ class LanKeyEntity {
|
||||
openRight = json['openRight'];
|
||||
judgmentMethod = json['judgmentMethod'];
|
||||
judgmentMethodContent = json['judgmentMethodContent'];
|
||||
stressPassword = json['stressPassword'];
|
||||
stressCard = json['stressCard'];
|
||||
}
|
||||
String? starLock;
|
||||
String? clickUnlockAndHoldDownClose;
|
||||
@ -1407,6 +1411,8 @@ class LanKeyEntity {
|
||||
String? openRight;
|
||||
String? judgmentMethod;
|
||||
String? judgmentMethodContent;
|
||||
String? stressPassword;
|
||||
String? stressCard;
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final map = <String, dynamic>{};
|
||||
@ -1890,6 +1896,8 @@ class LanKeyEntity {
|
||||
map['openRight'] = openRight;
|
||||
map['judgmentMethod'] = judgmentMethod;
|
||||
map['judgmentMethodContent'] = judgmentMethodContent;
|
||||
map['stressPassword'] = stressPassword;
|
||||
map['stressCard'] = stressCard;
|
||||
|
||||
return map;
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user