1、添加锁管理模块中,密码、卡、指纹即将到期功能。2、修改TAPD bug

This commit is contained in:
魏少阳 2024-03-29 18:32:33 +08:00
parent a6602f1d27
commit 665c1922b8
56 changed files with 2888 additions and 283 deletions

View File

@ -17,6 +17,8 @@ import 'baseWidget.dart';
import 'tools/appRouteObserver.dart';
import 'dart:io';
import 'tools/store_service.dart';
class MyApp extends StatefulWidget {
const MyApp({GlobalKey? key}) : super(key: key);
@ -47,8 +49,7 @@ class _MyAppState extends State<MyApp> with WidgetsBindingObserver, BaseWidget {
],
localeResolutionCallback: (locale, supportedLocales) {
if (!supportedLocales.contains(locale)) {
int idx = appSupportedLocales.indexWhere(
(element) => element.languageCode == locale!.languageCode);
int idx = appSupportedLocales.indexWhere((element) => element.languageCode == locale!.languageCode);
if (idx != -1) {
locale = appSupportedLocales[idx];
} else {
@ -56,12 +57,11 @@ class _MyAppState extends State<MyApp> with WidgetsBindingObserver, BaseWidget {
}
}
// print("localelocalelocalelocalelocale locale:${locale} locale.languageCode:${locale.languageCode} locale.countryCode:${locale.countryCode} supportedLocales:${supportedLocales}");
AppManager()
.setLanCode(code: '${locale!.languageCode}_${locale.countryCode}');
AppManager().setLanCode(code: '${locale!.languageCode}_${locale.countryCode}');
return locale;
},
// locale: StoreService.to.getLanguageCode().isNotEmpty ? appDept.deptSupportedLocales.where((element) => element.languageCode == StoreService.to.getLanguageCode()).first : Get.deviceLocale,
locale: Get.deviceLocale,
locale: StoreService.to.getLanguageCode()!.isNotEmpty ? appDept.deptSupportedLocales.where((element) => element.languageCode == StoreService.to.getLanguageCode()).first : Get.deviceLocale,
// locale: Get.deviceLocale,
fallbackLocale: const Locale('zh', 'CN'),
theme: ThemeData(
scaffoldBackgroundColor: const Color(0xFFF6F6F6),

View File

@ -30,7 +30,7 @@ import 'package:star_lock/mine/minePersonInfo/minePersonInfoViewSafetyProblem/mi
import 'package:star_lock/mine/mineSet/authorizedAdministrator/administratorDetails/adminDetailChangeDate_page.dart';
import 'package:star_lock/mine/mineSet/authorizedAdministrator/administratorDetails/administratorDetails_page.dart';
import 'package:star_lock/mine/mineSet/lockGroup/lockGroupList/lockGroupList_page.dart';
import 'package:star_lock/mine/mineSet/lockUserManage/expireLockList/expireLockList_page.dart';
import 'package:star_lock/mine/mineSet/lockUserManage/expireLockList/expireLockManage_page.dart';
import 'package:star_lock/mine/mineSet/mineSet/mineSet_page.dart';
import 'package:star_lock/mine/mineSet/transferGateway/selectGetewayList_page.dart';
import 'package:star_lock/mine/mineSet/transferSmartLock/recipientInformation/recipientInformation_page.dart';
@ -368,12 +368,10 @@ abstract class Routers {
static const massSendReceiverPage = '/massSendReceiverPage'; //
static const lockUserListPage = '/lockUserListPage'; //
static const administratorDetailsPage = '/administratorDetailsPage'; //
static const expireLockListPage = '/expireLockListPage'; //
static const expireLockManagePage = '/expireLockManagePage'; //
static const adminDetailChangeDatePage =
'/adminDetailChangeDatePage'; //
static const adminLockListPage = '/adminLockListPage'; //
static const expireLockChangeDatePage =
'/expireLockChangeDatePage'; //
static const safeVerifyPage = '/safeVerifyPage'; //
static const webviewShowPage = '/webviewShowPage'; //
static const demoModeLockDetailPage = '/DemoModeLockDetailPage'; //
@ -906,8 +904,8 @@ abstract class AppRouters {
name: Routers.administratorDetailsPage,
page: () => const AdministratorDetailsPage()),
GetPage(
name: Routers.expireLockListPage,
page: () => const ExpireLockListPage()),
name: Routers.expireLockManagePage,
page: () => const ExpireLockManagePage()),
GetPage(
name: Routers.otherTypeKeyChangeDatePage,
page: () => const OtherTypeKeyChangeDatePage()),

View File

@ -99,6 +99,13 @@ class SenderGetWifiCommand extends SenderProtocol {
}
}
class SenderGetWifiReply extends Reply {
SenderGetWifiReply.parseData(CommandType commandType, List<int> dataDetail)
: super.parseData(commandType, dataDetail) {
data = dataDetail;
}
}
class SenderGetWifiListReply extends Reply {
SenderGetWifiListReply.parseData(CommandType commandType, List<int> dataDetail)
: super.parseData(commandType, dataDetail) {

View File

@ -111,7 +111,7 @@ class CommandReciverManager {
break;
}
parseData(oriDataList).then((value) async {
// Get.log("parseData222 data:$value");
Get.log("parseData222 data:$value");
EasyLoading.dismiss();
await EventBusManager().eventBusFir(value);
}).catchError((error) {
@ -293,6 +293,13 @@ class CommandReciverManager {
SenderConfiguringWifiReply.parseData(commandType, data);
}
break;
case 53:
{
// wifilist
reply =
SenderGetWifiReply.parseData(commandType, data);
}
break;
case 54:
{
// 2.4G WIFI SSID

View File

@ -17,6 +17,10 @@ class OtherTypeKeyChangeDateState{
pushType.value = map["pushType"];
}
if(map["fingerprintItemData"] != null){
fingerprintItemData.value = map["fingerprintItemData"];
}
if(fingerprintItemData.value.startDate == 0 && fingerprintItemData.value.endDate == 0){
// getStartDate = "${formatDate(DateTime.now(), [yyyy,'-',mm,'-', dd, ' ', HH,])}:00"; //
// // state.selectEffectiveDate.value = getStartDate;

View File

@ -56,11 +56,11 @@ class ElectronicKeyDetailLogic extends BaseGetXController {
}
}
// setAdministrator
//
Future<void> deleteKeyRequest(int includeUnderlings) async {
ElectronicKeyListEntity entity = await ApiRepository.to.deleteElectronicKey(
keyId:state.itemData.value.keyId.toString(),
includeUnderlings: 0
includeUnderlings: includeUnderlings
);
if (entity.errorCode!.codeIsSuccessful) {
print("删除电子钥匙成功");

View File

@ -1,7 +1,7 @@
import 'package:get/get.dart';
import 'package:star_lock/main/lockDetail/electronicKey/electronicKeyList/entity/ElectronicKeyListEntity.dart';
import 'package:star_lock/mine/mineSet/lockUserManage/expireLockList/expireLockList_entity.dart';
import 'package:star_lock/mine/mineSet/lockUserManage/expireLockList/expireElectronicKey/expireLockList_entity.dart';
import '../../../../../tools/dateTool.dart';

View File

@ -1,7 +1,7 @@
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:star_lock/main/lockDetail/electronicKey/electronicKeyList/entity/ElectronicKeyListEntity.dart';
import 'package:star_lock/mine/mineSet/lockUserManage/expireLockList/expireLockList_entity.dart';
import 'package:star_lock/mine/mineSet/lockUserManage/expireLockList/expireElectronicKey/expireLockList_entity.dart';
import '../../../../../tools/dateTool.dart';

View File

@ -455,6 +455,8 @@ class LockDetailLogic extends BaseGetXController {
// signKey: signKeyDataList,
// privateKey: getPrivateKeyList,
// );
Get.log("openMode:$openMode");
BlueManage()
.bludSendData(state.keyInfos.value.bluetooth!.bluetoothDeviceName!,
(BluetoothConnectionState deviceConnectionState) async {

View File

@ -22,12 +22,52 @@ class WifiListLogic extends BaseGetXController {
late StreamSubscription<Reply> _replySubscription;
void _initReplySubscription() {
_replySubscription = EventBusManager().eventBus!.on<Reply>().listen((reply) {
if(reply is SenderGetWifiReply) {
_replySendGetWifiParameters(reply);
}
if(reply is SenderGetWifiListReply) {
_replyGetWifiListParameters(reply);
}
});
}
// wifi列表数据解析
Future<void> _replySendGetWifiParameters(Reply reply) async {
int status = reply.data[2];
switch(status){
case 0x00:
//
print("${reply.commandType}数据解析成功");
showEasyLoading();
cancelBlueConnetctToastTimer();
Future.delayed(5.seconds, (){
dismissEasyLoading();
});
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> _replyGetWifiListParameters(Reply reply) async {
int status = reply.data[2];
@ -36,11 +76,8 @@ class WifiListLogic extends BaseGetXController {
//
print("${reply.commandType}数据解析成功");
// showEasyLoading();
Future.delayed(4.seconds, (){
dismissEasyLoading();
});
dismissEasyLoading();
state.sureBtnState.value = 0;
cancelBlueConnetctToastTimer();
if (reply.data[6] > 0) {
reply.data.removeRange(0, 7);

View File

@ -9,6 +9,7 @@ import 'package:star_lock/tools/pickers/time_picker/model/date_mode.dart';
import '../../../../appRouters.dart';
import '../../../../app_settings/app_colors.dart';
import '../../../../tools/commonItem.dart';
import '../../../../tools/dateTool.dart';
import '../../../../tools/storage.dart';
import '../../../../tools/submitBtn.dart';
import '../../../../translations/trans_lib.dart';
@ -78,15 +79,22 @@ class _AddRemoteControlPageState extends State<AddRemoteControlPage> {
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}');
var result = await Get.toNamed(Routers.seletKeyCyclicDatePage,
arguments: {
'validityValue': state.weekdaysList.value,
'starDate': state.beginTime.value,
'endDate': state.endTime.value,
'starTime': state.effectiveDateTime.value,
'endTime': state.failureDateTime.value
});
if(result != null && result.isNotEmpty){
state.weekdaysList.value = result['validityValue'];
state.beginTime.value = result['starDate'];
state.endTime.value = result['endDate'];
state.effectiveDateTime.value = result['starTime'];
state.failureDateTime.value = result['endTime'];
Get.log('得到的有效期数据:${state.weekdaysList.value} == ${state.beginTime.value} == ${state.endTime.value}== ${state.effectiveDateTime.value} == ${state.failureDateTime.value}');
}
}),
SizedBox(height: 10.h),
keyBottomWidget()
@ -103,7 +111,6 @@ class _AddRemoteControlPageState extends State<AddRemoteControlPage> {
String titleStr, String rightTitle, TextEditingController controller) {
return Column(
children: [
Container(height: 10.h),
CommonItem(
leftTitel: titleStr,
rightTitle: "",
@ -126,16 +133,7 @@ class _AddRemoteControlPageState extends State<AddRemoteControlPage> {
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();
});
});
state.beginTime.value = DateTool().getYMDHNDateString(p, 1);
});
})),
Obx(() => CommonItem(
@ -143,18 +141,8 @@ class _AddRemoteControlPageState extends State<AddRemoteControlPage> {
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();
});
});
Pickers.showDatePicker(context, mode: DateMode.YMDHM, onConfirm: (p) {
state.endTime.value = DateTool().getYMDHNDateString(p, 1);
});
})),
Container(height: 10.h),

View File

@ -6,11 +6,8 @@ class AddRemoteControlState{
var beginTime = "".obs;//
var endTime = "".obs;//
var beginTimeTimestamp = "".obs;//
var endTimeTimestamp = "".obs;//
var effectiveDateTime = 0.obs;//
var failureDateTime = 0.obs;//
var effectiveDateTime = "".obs;//
var failureDateTime = "".obs;//
var weekdaysList = [].obs;
final TextEditingController nameController = TextEditingController();

View File

@ -39,18 +39,18 @@ class _MineMultiLanguagePageState extends State<MineMultiLanguagePage> {
List<Widget> _children() {
List<Widget> l = [];
l.add(
CommonItem(
leftTitel: '跟随系统',
rightTitle: "",
isHaveLine: true,
isHaveDirection: false,
isHaveRightWidget: true,
rightWidget: Container(),
action: () {
// logic.changeLanguage(e);
}),
);
// l.add(
// CommonItem(
// leftTitel: '跟随系统',
// rightTitle: "",
// isHaveLine: true,
// isHaveDirection: false,
// isHaveRightWidget: true,
// rightWidget: Container(),
// action: () {
// // logic.changeLanguage(e);
// }),
// );
for (int i = 0; i < state.languages.length; i++) {
var e = state.languages[i];
var lanType = ExtensionLanguageType.fromLanguageCode(e.languageCode);

View File

@ -20,6 +20,6 @@ class MineMultiLanguageState {
void resetLan() {
currentLanguageType.value = ExtensionLanguageType.fromLanguageCode(Get.locale!.languageCode);
print("currentLanguageType.value:${currentLanguageType.value}");
// StoreService.to.saveLanguageCode(Get.locale!.languageCode);
StoreService.to.saveLanguageCode(Get.locale!.languageCode);
}
}

View File

@ -5,6 +5,7 @@ import 'package:star_lock/mine/mineSet/appUnlockNeedMobileNetworkingLock/selectL
import '../../../app_settings/app_colors.dart';
import '../../../tools/commonItem.dart';
import '../../../tools/noData.dart';
import '../../../tools/submitBtn.dart';
import '../../../tools/titleAppBar.dart';
import '../../../translations/trans_lib.dart';
@ -46,7 +47,7 @@ class _APPUnlockNeedMobileNetworkingLockPageState extends State<APPUnlockNeedMob
// ))
// ],
backgroundColor: AppColors.mainColor),
body: Column(
body: Obx(() => state.lockItemList.value.isEmpty ? NoData() :Column(
children: [
Container(
padding: EdgeInsets.all(30.w),
@ -73,10 +74,10 @@ class _APPUnlockNeedMobileNetworkingLockPageState extends State<APPUnlockNeedMob
state.isCheckAll.value = !state.isCheckAll.value;
for(LockItemData lockItemData in state.lockItemList.value){
if(state.isCheckAll.value == true){
lockItemData.isCheck = true;
lockItemData.appUnlockOnline = 1;
state.selectLockIdList.add(lockItemData.lockId);
}else{
lockItemData.isCheck = false;
lockItemData.appUnlockOnline = 0;
state.selectLockIdList = [];
}
}
@ -94,7 +95,7 @@ class _APPUnlockNeedMobileNetworkingLockPageState extends State<APPUnlockNeedMob
)),
SizedBox(height: 15.h),
Expanded(
child: Obx(() => ListView.builder(
child: ListView.builder(
itemCount: state.lockItemList.value.length,
itemBuilder: (c, index) {
LockItemData itemData = state.lockItemList.value[index];
@ -104,7 +105,7 @@ class _APPUnlockNeedMobileNetworkingLockPageState extends State<APPUnlockNeedMob
// itemData.isCheck = false;
// }
return _gatewatListItem(itemData);
})),
}),
),
SubmitBtn(
btnName: TranslationLoader.lanKeys!.sure!.tr,
@ -119,17 +120,18 @@ class _APPUnlockNeedMobileNetworkingLockPageState extends State<APPUnlockNeedMob
height: 40.h,
)
],
));
)));
}
Widget _gatewatListItem(LockItemData itemData) {
return GestureDetector(
onTap: () {
setState(() {
itemData.isCheck = !itemData.isCheck;
if (itemData.isCheck == true) {
if (itemData.appUnlockOnline == 0) {
itemData.appUnlockOnline = 1;
state.selectLockIdList.add(itemData.lockId);
} else {
itemData.appUnlockOnline = 0;
state.selectLockIdList.remove(itemData.lockId);
}
@ -155,7 +157,7 @@ class _APPUnlockNeedMobileNetworkingLockPageState extends State<APPUnlockNeedMob
width: 15.w,
),
Image.asset(
itemData.isCheck == true
itemData.appUnlockOnline == 1
? 'images/icon_round_select.png'
: 'images/icon_round_unSelect.png',
width: 30.w,

View File

@ -52,19 +52,25 @@ class Data {
class LockItemData {
int? lockId;
String? lockAlias;
bool isCheck = false;
int? appUnlockOnline;
LockItemData({this.lockId, this.lockAlias, required this.isCheck});
LockItemData({
this.lockId,
this.lockAlias,
this.appUnlockOnline,
});
LockItemData.fromJson(Map<String, dynamic> json) {
lockId = json['lockId'];
lockAlias = json['lockAlias'];
appUnlockOnline = json['appUnlockOnline'];
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = <String, dynamic>{};
data['lockId'] = lockId;
data['lockAlias'] = lockAlias;
data['appUnlockOnline'] = appUnlockOnline;
return data;
}
}

View File

@ -2,7 +2,7 @@ import 'package:flutter/material.dart';
import 'package:flutter_easyloading/flutter_easyloading.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';
import 'package:star_lock/mine/mineSet/lockUserManage/expireLockList/expireLockList_entity.dart';
import 'package:star_lock/mine/mineSet/lockUserManage/expireLockList/expireElectronicKey/expireLockList_entity.dart';
import 'package:star_lock/network/api_repository.dart';
import 'package:star_lock/tools/baseGetXController.dart';

View File

@ -2,7 +2,7 @@ import 'package:flutter/material.dart';
import 'package:flutter_easyloading/flutter_easyloading.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';
import 'package:star_lock/mine/mineSet/lockUserManage/expireLockList/expireLockList_entity.dart';
import 'package:star_lock/mine/mineSet/lockUserManage/expireLockList/expireElectronicKey/expireLockList_entity.dart';
import 'package:star_lock/network/api_repository.dart';
import 'package:star_lock/tools/baseGetXController.dart';

View File

@ -0,0 +1,217 @@
class ExpireCardEntity {
int? errorCode;
String? description;
String? errorMsg;
ExpireCardListEntity? data;
ExpireCardEntity(
{this.errorCode, this.description, this.errorMsg, this.data});
ExpireCardEntity.fromJson(Map<String, dynamic> json) {
errorCode = json['errorCode'];
description = json['description'];
errorMsg = json['errorMsg'];
data = json['data'] != null ? ExpireCardListEntity.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 ExpireCardListEntity {
List<ExpireCardItemEntity>? list;
int? pageNo;
int? pageSize;
int? pages;
int? total;
ExpireCardListEntity({this.list, this.pageNo, this.pageSize, this.pages, this.total});
ExpireCardListEntity.fromJson(Map<String, dynamic> json) {
if (json['list'] != null) {
list = <ExpireCardItemEntity>[];
json['list'].forEach((v) {
list!.add(ExpireCardItemEntity.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 ExpireCardItemEntity {
String? clientId;
int? lockOwnerId;
int? lockId;
String? cardNumber;
int? startDate;
int? endDate;
int? cardStatus;
int? cardType;
int? cardRight;
List? weekDay;
int? addType;
int? isCoerced;
int? cardUserNo;
int? businessId;
String? createdAt;
String? updatedAt;
ApiUser? apiUser;
LockInfo? lockInfo;
int? cardId;
int? uid;
String? nickname;
String? lockAlias;
int? expireDate;
ExpireCardItemEntity(
{this.clientId,
this.lockOwnerId,
this.lockId,
this.cardNumber,
this.startDate,
this.endDate,
this.cardStatus,
this.cardType,
this.cardRight,
this.weekDay,
this.addType,
this.isCoerced,
this.cardUserNo,
this.businessId,
this.createdAt,
this.updatedAt,
this.apiUser,
this.lockInfo,
this.cardId,
this.uid,
this.nickname,
this.lockAlias,
this.expireDate});
ExpireCardItemEntity.fromJson(Map<String, dynamic> json) {
clientId = json['clientId'];
lockOwnerId = json['lockOwnerId'];
lockId = json['lockId'];
cardNumber = json['cardNumber'];
startDate = json['startDate'];
endDate = json['endDate'];
cardStatus = json['cardStatus'];
cardType = json['cardType'];
cardRight = json['cardRight'];
if (json['weekDays'] != null) {
weekDay = [];
json['weekDays'].forEach((v) {
weekDay!.add(v);
});
}
addType = json['addType'];
isCoerced = json['isCoerced'];
cardUserNo = json['cardUserNo'];
businessId = json['businessId'];
createdAt = json['created_at'];
updatedAt = json['updated_at'];
apiUser = json['api_user'] != null
? ApiUser.fromJson(json['api_user'])
: null;
lockInfo = json['lock_info'] != null
? new LockInfo.fromJson(json['lock_info'])
: null;
cardId = json['cardId'];
uid = json['uid'];
nickname = json['nickname'];
lockAlias = json['lockAlias'];
expireDate = json['expireDate'];
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = <String, dynamic>{};
data['clientId'] = clientId;
data['lockOwnerId'] = lockOwnerId;
data['lockId'] = lockId;
data['cardNumber'] = cardNumber;
data['startDate'] = startDate;
data['endDate'] = endDate;
data['cardStatus'] = cardStatus;
data['cardType'] = cardType;
data['cardRight'] = cardRight;
if (weekDay != null) {
data['weekDay'] = weekDay!.map((v) => v.toJson()).toList();
}
data['addType'] = addType;
data['isCoerced'] = isCoerced;
data['cardUserNo'] = cardUserNo;
data['businessId'] = businessId;
data['created_at'] = createdAt;
data['updated_at'] = updatedAt;
if (apiUser != null) {
data['api_user'] = apiUser!.toJson();
}
if (this.lockInfo != null) {
data['lock_info'] = this.lockInfo!.toJson();
}
data['cardId'] = cardId;
data['uid'] = uid;
data['nickname'] = nickname;
data['lockAlias'] = lockAlias;
data['expireDate'] = expireDate;
return data;
}
}
class ApiUser {
int? id;
String? accountName;
ApiUser({this.id, this.accountName});
ApiUser.fromJson(Map<String, dynamic> json) {
id = json['id'];
accountName = json['account_name'];
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = <String, dynamic>{};
data['id'] = id;
data['account_name'] = accountName;
return data;
}
}
class LockInfo {
String? btDeviceName;
LockInfo({this.btDeviceName});
LockInfo.fromJson(Map<String, dynamic> json) {
btDeviceName = json['btDeviceName'];
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = Map<String, dynamic>();
data['btDeviceName'] = btDeviceName;
return data;
}
}

View File

@ -0,0 +1,209 @@
import 'dart:async';
import 'package:flutter_blue_plus/flutter_blue_plus.dart';
import 'package:get/get.dart';
import 'package:star_lock/blue/blue_manage.dart';
import 'package:star_lock/blue/io_reply.dart';
import 'package:star_lock/blue/io_tool/io_tool.dart';
import 'package:star_lock/blue/io_tool/manager_event_bus.dart';
import 'package:star_lock/blue/io_type.dart';
import 'package:star_lock/tools/baseGetXController.dart';
import 'package:star_lock/tools/dateTool.dart';
import '../../../../../blue/io_protocol/io_addICCard.dart';
import '../../../../../blue/sender_manage.dart';
import '../../../../../network/api_repository.dart';
import '../../../../../tools/eventBusEventManage.dart';
import '../../../../../tools/storage.dart';
import 'expireCard_entity.dart';
import 'expireCard_state.dart';
class ExpireCardLogic extends BaseGetXController {
ExpireCardState state = ExpireCardState();
//
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} 数据解析成功");
cancelBlueConnetctToastTimer();
dismissEasyLoading();
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!);
String? userID = await Storage.getUid();
IoSenderManage.senderAddICCardCommand(
keyID:state.deletExpireCardItemEntity.cardId.toString(),
userID:userID,
cardNo:state.deletExpireCardItemEntity.cardUserNo!,
useCountLimit:0,
startTime:state.deletExpireCardItemEntity.startDate!~/1000,
endTime:state.deletExpireCardItemEntity.endDate!~/1000,
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() async {
if(state.sureBtnState.value == 1){
return;
}
state.sureBtnState.value = 1;
showEasyLoading();
showBlueConnetctToastTimer(action: (){
dismissEasyLoading();
state.sureBtnState.value = 0;
});
BlueManage().bludSendData(state.deletExpireCardItemEntity.lockInfo!.btDeviceName!, (BluetoothConnectionState deviceConnectionState) async {
if (deviceConnectionState == BluetoothConnectionState.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");
String? userID = await Storage.getUid();
IoSenderManage.senderAddICCardCommand(
keyID:state.deletExpireCardItemEntity.cardId.toString(),
userID:userID,
cardNo:state.deletExpireCardItemEntity.cardUserNo!,
useCountLimit:0,
startTime:state.deletExpireCardItemEntity.startDate!~/1000,
endTime:state.deletExpireCardItemEntity.endDate!~/1000,
needAuthor:1,
publicKey:publicKeyDataList,
privateKey:getPrivateKeyList,
token: getTokenList,
);
} else if (deviceConnectionState == BluetoothConnectionState.disconnected) {
dismissEasyLoading();
cancelBlueConnetctToastTimer();
state.sureBtnState.value = 0;
if(state.ifCurrentScreen.value == true){
showBlueConnetctToast();
}
}
});
}
//
Future<ExpireCardEntity> expirCardListRequest() async {
ExpireCardEntity entity = await ApiRepository.to.expireCardList(pageNo.toString(), pageSize.toString());
if(entity.errorCode!.codeIsSuccessful){
if (pageNo == 1) {
state.dataList.value = entity.data!.list!;
pageNo++;
} else {
if (entity.data!.list!.isNotEmpty) {
state.dataList.value.addAll(entity.data!.list!);
pageNo++;
}
}
}
return entity;
}
// IC卡
void deletICCardData() async{
var entity = await ApiRepository.to.deletIcCardData(
cardId: state.deletExpireCardItemEntity.cardId.toString(),
lockId: state.deletExpireCardItemEntity.lockId.toString(),
type: "0",
deleteType:"1"
);
if(entity.errorCode!.codeIsSuccessful){
showToast("删除成功", something: (){
BlueManage().disconnect();
pageNo = 1;
expirCardListRequest();
eventBus.fire(LockUserManageListRefreshUI());
});
}
}
//使
String getExpireDateStr(ExpireCardItemEntity itemData) {
String useDateStr = '';
if(itemData.cardType == 4){
useDateStr = '循环';
}else{
useDateStr = '${DateTool().dateToYMDString(itemData.startDate.toString())}-${DateTool().dateToYMDString(itemData.endDate.toString())}';
}
return useDateStr;
}
@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();
}
}

View File

@ -0,0 +1,242 @@
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:flutter_slidable/flutter_slidable.dart';
import 'package:get/get.dart';
import 'package:star_lock/app_settings/app_colors.dart';
import 'package:star_lock/tools/EasyRefreshTool.dart';
import 'package:star_lock/tools/noData.dart';
import '../../../../../appRouters.dart';
import '../../../../../tools/showTipView.dart';
import 'expireCard_entity.dart';
import 'expireCard_logic.dart';
class ExpireCardPage extends StatefulWidget {
const ExpireCardPage({Key? key}) : super(key: key);
@override
State<ExpireCardPage> createState() => _ExpireCardPageState();
}
class _ExpireCardPageState extends State<ExpireCardPage> {
final logic = Get.put(ExpireCardLogic());
final state = Get.find<ExpireCardLogic>().state;
Future<void> getHttpData() async {
logic.expirCardListRequest().then((ExpireCardEntity value){
if(mounted) setState(() {});
});
}
@override
void initState() {
super.initState();
getHttpData();
}
@override
Widget build(BuildContext context) {
return EasyRefreshTool(
onRefresh: (){
logic.pageNo = 1;
getHttpData();
},
onLoad: (){
getHttpData();
},
child: Obx(() => _buildMainUI())
);
}
Widget _buildMainUI() {
return state.dataList.isEmpty
? NoData(noDataHeight: 1.sh - ScreenUtil().statusBarHeight - ScreenUtil().bottomBarHeight - 190.h - 64.h)
: SlidableAutoCloseBehavior(
child: ListView.separated(
itemCount: state.dataList.length,
itemBuilder: (c, index) {
ExpireCardItemEntity indexEntity = state.dataList[index];
return Slidable(
key:ValueKey(indexEntity.uid),
endActionPane: ActionPane(
extentRatio: 0.2,
motion: const ScrollMotion(),
children: [
SlidableAction(
onPressed: (BuildContext context){
ShowTipView().showIosTipWithContentDialog("确定删除卡吗?", (){
state.deletExpireCardItemEntity = indexEntity;
logic.senderAddICCard();
});
},
backgroundColor: Colors.red,
foregroundColor: Colors.white,
label: '删除',
padding: EdgeInsets.only(left: 5.w, right: 5.w),
),
],
),
child: _electronicKeyItem(indexEntity),
);
},
separatorBuilder: (BuildContext context, int index) {
return const Divider(
height: 1,
color: AppColors.greyLineColor,
);
},
),
);
}
Widget _electronicKeyItem(ExpireCardItemEntity itemData) {
return GestureDetector(
onTap: () async {
// if(itemData.cardType! == 4){
// //
// var data = await Get.toNamed(Routers.electronicKeyPeriodValidityPage, arguments: {
// "pushType": 0,
// "expireLockItem": itemData,
// });
// if(data != null) {
// // setState(() {
// // state.starDate.value = data["starDate"];
// // state.endDate.value = data["endDate"];
// // state.starTime.value = data["starTime"];
// // state.endTime.value = data["endTime"];
// // state.weekDay.value = data["validityValue"];
// // });
// logic.pageNo = 1;
// getHttpData();
// }
// }else{
// var data = await Get.toNamed(Routers.electronicKeyDetailChangeDate, arguments: {
// "pushType": 0,
// "expireLockItem": itemData,
// });
// if(data != null) {
// setState(() {
// // state.starDate.value = data["beginTimeTimestamp"].toString();
// // state.endDate.value = data["endTimeTimestamp"].toString();
// // state.keyType.value = 2;
// logic.pageNo = 1;
// getHttpData();
// });
// }
// }
},
child: Container(
height: 90.h,
color: Colors.white,
child: Row(
children: [
SizedBox(
width: 30.w,
),
Image.asset(
'images/controls_user.png',
width: 60.w,
height: 60.w,
),
SizedBox(
width: 20.w,
),
Expanded(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Row(
mainAxisAlignment: MainAxisAlignment.start,
children: [
Text(
itemData.nickname ?? '',
style: TextStyle(
fontSize: 20.sp, color: AppColors.blackColor),
),
Expanded(
child: SizedBox(
width: 10.w,
)),
Text(
itemData.lockAlias ?? '',
style: TextStyle(
fontSize: 20.sp, color: AppColors.blackColor),
),
],
),
SizedBox(height: 10.h),
Row(
mainAxisAlignment: MainAxisAlignment.start,
children: [
Text(
logic.getExpireDateStr(itemData),
style: TextStyle(
fontSize: 18.sp,
color: AppColors.placeholderTextColor),
),
SizedBox(
width: 5.w,
),
getStatus(itemData),
],
),
SizedBox(width: 20.h),
],
),
),
SizedBox(width: 20.w),
],
),
),
);
}
Widget getStatus(ExpireCardItemEntity itemData) {
// if (itemData.keyboardPwdStatus! == 1) {
// return Container(
// padding: EdgeInsets.only(left: 5.w, right: 5.w),
// decoration: BoxDecoration(
// color: Colors.red,
// borderRadius: BorderRadius.circular(2.0),
// ),
// child: Text(
// '未生效',
// style: TextStyle(
// color: Colors.white, fontSize: 13.sp),
// ),
// );
// } else {
if (itemData.expireDate! > 0) {
return Container(
padding: EdgeInsets.only(left: 5.w, right: 5.w),
decoration: BoxDecoration(
color: AppColors.expireTextBgColor,
borderRadius: BorderRadius.circular(2.0),
),
child: Text(
'${itemData.expireDate.toString()}',
style: TextStyle(
color: Colors.white, fontSize: 13.sp),
),
);
} else {
return Container(
padding: EdgeInsets.only(left: 5.w, right: 5.w),
decoration: BoxDecoration(
color: Colors.red,
borderRadius: BorderRadius.circular(2.0),
),
child: Text(
'已过期',
style: TextStyle(
color: Colors.white, fontSize: 13.sp),
),
);
}
// }
}
}

View File

@ -0,0 +1,12 @@
import 'package:get/get.dart';
import 'expireCard_entity.dart';
class ExpireCardState{
final dataList = <ExpireCardItemEntity>[].obs;
var ifCurrentScreen = true.obs; // ,
var sureBtnState = 0.obs;// 0() 1()
ExpireCardItemEntity deletExpireCardItemEntity = ExpireCardItemEntity();
}

View File

@ -0,0 +1,75 @@
import 'package:star_lock/tools/baseGetXController.dart';
import 'package:star_lock/tools/dateTool.dart';
import 'package:star_lock/tools/eventBusEventManage.dart';
import 'package:star_lock/tools/showTipView.dart';
import '../../../../../main/lockDetail/electronicKey/electronicKeyList/entity/ElectronicKeyListEntity.dart';
import '../../../../../network/api_repository.dart';
import 'expireLockList_entity.dart';
import 'expireLockList_state.dart';
class ExpireLockListLogic extends BaseGetXController{
ExpireLockListState state = ExpireLockListState();
//
Future<ExpireLockListEntity> expireLockListRequest() async {
ExpireLockListEntity entity = await ApiRepository.to.expireLockList(pageNo.toString(), pageSize.toString());
if(entity.errorCode!.codeIsSuccessful){
if (pageNo == 1) {
state.dataList.value = entity.data!.itemList!;
pageNo++;
} else {
if (entity.data!.itemList!.isNotEmpty) {
state.dataList.value.addAll(entity.data!.itemList!);
pageNo++;
}
}
}
return entity;
}
//
Future<void> deleteKeyRequest(int includeUnderlings, ExpireLockItem expireLockItem) async {
ElectronicKeyListEntity entity = await ApiRepository.to.deleteElectronicKey(
keyId:expireLockItem.keyId.toString(),
includeUnderlings: includeUnderlings
);
if (entity.errorCode!.codeIsSuccessful) {
print("删除电子钥匙成功");
showToast("删除成功", something: () {
pageNo = 1;
expireLockListRequest();
eventBus.fire(LockUserManageListRefreshUI());
});
}
}
//使
String getExpireDateStr(ExpireLockItem itemData) {
String useDateStr = '';
if(itemData.keyType == 4){
useDateStr = '循环';
}else{
useDateStr = '${DateTool().dateToYMDString(itemData.startDate.toString())}-${DateTool().dateToYMDString(itemData.endDate.toString())}';
}
return useDateStr;
}
deletKeyLogic(ExpireLockItem expireLockItem){
if(expireLockItem.keyRight == 1){
//
ShowTipView().showDeleteAdministratorIsHaveAllDataDialog((isAllData) {
deleteKeyRequest(isAllData ? 1 : 0, expireLockItem);
});
}else{
//
ShowTipView().showDeleteKeyDataDialogDialog((){
deleteKeyRequest(0, expireLockItem);
});
}
}
}

View File

@ -1,14 +1,15 @@
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:flutter_slidable/flutter_slidable.dart';
import 'package:get/get.dart';
import 'package:star_lock/mine/mineSet/lockUserManage/expireLockList/expireLockList_entity.dart';
import 'package:star_lock/common/XSConstantMacro/XSConstantMacro.dart';
import 'package:star_lock/mine/mineSet/lockUserManage/expireLockList/expireElectronicKey/expireLockList_entity.dart';
import '../../../../appRouters.dart';
import '../../../../app_settings/app_colors.dart';
import '../../../../tools/EasyRefreshTool.dart';
import '../../../../tools/noData.dart';
import '../../../../tools/titleAppBar.dart';
import '../../../../translations/trans_lib.dart';
import '../../../../../appRouters.dart';
import '../../../../../app_settings/app_colors.dart';
import '../../../../../tools/EasyRefreshTool.dart';
import '../../../../../tools/noData.dart';
import 'expireLockList_logic.dart';
class ExpireLockListPage extends StatefulWidget {
@ -37,48 +38,61 @@ class _ExpireLockListPageState extends State<ExpireLockListPage> {
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: AppColors.mainBackgroundColor,
appBar: TitleAppBar(
barTitle: TranslationLoader.lanKeys!.aboutToExpire!.tr,
haveBack: true,
backgroundColor: AppColors.mainColor,
),
body: EasyRefreshTool(
onRefresh: (){
logic.pageNo = 1;
getHttpData();
},
onLoad: (){
getHttpData();
},
child: Obx(() => _buildMainUI())
),
return EasyRefreshTool(
onRefresh: (){
logic.pageNo = 1;
getHttpData();
},
onLoad: (){
getHttpData();
},
child: Obx(() => _buildMainUI())
);
}
Widget _buildMainUI() {
return state.dataList.isEmpty
? NoData(noDataHeight: 1.sh - ScreenUtil().statusBarHeight - ScreenUtil().bottomBarHeight - 190.h - 64.h)
: ListView.separated(
itemCount: state.dataList.length,
itemBuilder: (c, index) {
ExpireLockItem indexEntity = state.dataList[index];
return _electronicKeyItem(indexEntity);
},
separatorBuilder: (BuildContext context, int index) {
return const Divider(
height: 1,
color: AppColors.greyLineColor,
: SlidableAutoCloseBehavior(
child: ListView.separated(
itemCount: state.dataList.length,
itemBuilder: (c, index) {
ExpireLockItem indexEntity = state.dataList[index];
return Slidable(
key:ValueKey(indexEntity.uid),
endActionPane: ActionPane(
extentRatio: 0.2,
motion: const ScrollMotion(),
children: [
SlidableAction(
onPressed: (BuildContext context){
logic.deletKeyLogic(indexEntity);
},
backgroundColor: Colors.red,
foregroundColor: Colors.white,
label: '删除',
padding: EdgeInsets.only(left: 5.w, right: 5.w),
),
],
),
child: _electronicKeyItem(indexEntity),
);
},
separatorBuilder: (BuildContext context, int index) {
return const Divider(
height: 1,
color: AppColors.greyLineColor,
);
},
),
);
},
);
}
Widget _electronicKeyItem(ExpireLockItem itemData) {
return GestureDetector(
onTap: () async {
if(itemData.keyType! == 4){
//
var data = await Get.toNamed(Routers.electronicKeyPeriodValidityPage, arguments: {
"pushType": 0,
"expireLockItem": itemData,
@ -163,31 +177,7 @@ class _ExpireLockListPageState extends State<ExpireLockListPage> {
SizedBox(
width: 5.w,
),
itemData.expireDate! > 0
? Container(
padding: EdgeInsets.only(left: 5.w, right: 5.w),
decoration: BoxDecoration(
color: AppColors.expireTextBgColor,
borderRadius: BorderRadius.circular(2.0),
),
child: Text(
'${itemData.expireDate.toString()}',
style: TextStyle(
color: Colors.white, fontSize: 13.sp),
),
)
: Container(
padding: EdgeInsets.only(left: 5.w, right: 5.w),
decoration: BoxDecoration(
color: Colors.red,
borderRadius: BorderRadius.circular(2.0),
),
child: Text(
'已过期',
style: TextStyle(
color: Colors.white, fontSize: 13.sp),
),
)
getStatus(itemData),
],
),
SizedBox(width: 20.h),
@ -200,4 +190,50 @@ class _ExpireLockListPageState extends State<ExpireLockListPage> {
),
);
}
Widget getStatus(ExpireLockItem itemData) {
if (itemData.keyStatus! == XSConstantMacro.keyStatusWaitIneffective) {
return Container(
padding: EdgeInsets.only(left: 5.w, right: 5.w),
decoration: BoxDecoration(
color: Colors.red,
borderRadius: BorderRadius.circular(2.0),
),
child: Text(
'未生效',
style: TextStyle(
color: Colors.white, fontSize: 13.sp),
),
);
} else {
if (itemData.expireDate! > 0) {
return Container(
padding: EdgeInsets.only(left: 5.w, right: 5.w),
decoration: BoxDecoration(
color: AppColors.expireTextBgColor,
borderRadius: BorderRadius.circular(2.0),
),
child: Text(
'${itemData.expireDate.toString()}',
style: TextStyle(
color: Colors.white, fontSize: 13.sp),
),
);
} else {
return Container(
padding: EdgeInsets.only(left: 5.w, right: 5.w),
decoration: BoxDecoration(
color: Colors.red,
borderRadius: BorderRadius.circular(2.0),
),
child: Text(
'已过期',
style: TextStyle(
color: Colors.white, fontSize: 13.sp),
),
);
}
}
}
}

View File

@ -0,0 +1,39 @@
import 'package:star_lock/tools/baseGetXController.dart';
import 'package:star_lock/tools/dateTool.dart';
import '../../../../../network/api_repository.dart';
import '../expireFingerprint/expireFingerprint_entity.dart';
import 'expireFace_state.dart';
class ExpireFaceLogic extends BaseGetXController {
ExpireFaceState state = ExpireFaceState();
//
Future<ExpireFingerprintEntity> expirFaceListRequest() async {
ExpireFingerprintEntity entity = await ApiRepository.to.expireFingerprintList(pageNo.toString(), pageSize.toString());
if(entity.errorCode!.codeIsSuccessful){
if (pageNo == 1) {
state.dataList.value = entity.data!.list!;
pageNo++;
} else {
if (entity.data!.list!.isNotEmpty) {
state.dataList.value.addAll(entity.data!.list!);
pageNo++;
}
}
}
return entity;
}
//使
String getExpireDateStr(ExpireFingerprintItemEntity itemData) {
String useDateStr = '';
if(itemData.fingerprintType == 4){
useDateStr = '循环';
}else{
useDateStr = '${DateTool().dateToYMDString(itemData.startDate.toString())}-${DateTool().dateToYMDString(itemData.endDate.toString())}';
}
return useDateStr;
}
}

View File

@ -0,0 +1,240 @@
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:flutter_slidable/flutter_slidable.dart';
import 'package:get/get.dart';
import 'package:star_lock/tools/EasyRefreshTool.dart';
import '../../../../../app_settings/app_colors.dart';
import '../../../../../tools/noData.dart';
import '../../../../../tools/showTipView.dart';
import '../expireFingerprint/expireFingerprint_entity.dart';
import 'expireFace_logic.dart';
class ExpireFacePage extends StatefulWidget {
const ExpireFacePage({Key? key}) : super(key: key);
@override
State<ExpireFacePage> createState() => _ExpireFacePageState();
}
class _ExpireFacePageState extends State<ExpireFacePage> {
final logic = Get.put(ExpireFaceLogic());
final state = Get.find<ExpireFaceLogic>().state;
Future<void> getHttpData() async {
logic.expirFaceListRequest().then((ExpireFingerprintEntity value){
if(mounted) setState(() {});
});
}
@override
void initState() {
super.initState();
getHttpData();
}
@override
Widget build(BuildContext context) {
return EasyRefreshTool(
onRefresh: (){
logic.pageNo = 1;
getHttpData();
},
onLoad: (){
getHttpData();
},
child: Obx(() => _buildMainUI())
);
}
Widget _buildMainUI() {
return state.dataList.isEmpty
? NoData(noDataHeight: 1.sh - ScreenUtil().statusBarHeight - ScreenUtil().bottomBarHeight - 190.h - 64.h)
: SlidableAutoCloseBehavior(
child: ListView.separated(
itemCount: state.dataList.length,
itemBuilder: (c, index) {
ExpireFingerprintItemEntity indexEntity = state.dataList[index];
return Slidable(
key:ValueKey(indexEntity.uid),
endActionPane: ActionPane(
extentRatio: 0.2,
motion: const ScrollMotion(),
children: [
SlidableAction(
onPressed: (BuildContext context){
ShowTipView().showIosTipWithContentDialog("确定删除卡吗?", (){
// state.deletExpireFingerprintItemEntity = indexEntity;
// logic.senderAddFingerprint();
});
},
backgroundColor: Colors.red,
foregroundColor: Colors.white,
label: '删除',
padding: EdgeInsets.only(left: 5.w, right: 5.w),
),
],
),
child: _electronicKeyItem(indexEntity),
);
},
separatorBuilder: (BuildContext context, int index) {
return const Divider(
height: 1,
color: AppColors.greyLineColor,
);
},
),
);
}
Widget _electronicKeyItem(ExpireFingerprintItemEntity itemData) {
return GestureDetector(
onTap: () async {
// if(itemData.cardType! == 4){
// //
// var data = await Get.toNamed(Routers.electronicKeyPeriodValidityPage, arguments: {
// "pushType": 0,
// "expireLockItem": itemData,
// });
// if(data != null) {
// // setState(() {
// // state.starDate.value = data["starDate"];
// // state.endDate.value = data["endDate"];
// // state.starTime.value = data["starTime"];
// // state.endTime.value = data["endTime"];
// // state.weekDay.value = data["validityValue"];
// // });
// logic.pageNo = 1;
// getHttpData();
// }
// }else{
// var data = await Get.toNamed(Routers.electronicKeyDetailChangeDate, arguments: {
// "pushType": 0,
// "expireLockItem": itemData,
// });
// if(data != null) {
// setState(() {
// // state.starDate.value = data["beginTimeTimestamp"].toString();
// // state.endDate.value = data["endTimeTimestamp"].toString();
// // state.keyType.value = 2;
// logic.pageNo = 1;
// getHttpData();
// });
// }
// }
},
child: Container(
height: 90.h,
color: Colors.white,
child: Row(
children: [
SizedBox(
width: 30.w,
),
Image.asset(
'images/controls_user.png',
width: 60.w,
height: 60.w,
),
SizedBox(
width: 20.w,
),
Expanded(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Row(
mainAxisAlignment: MainAxisAlignment.start,
children: [
Text(
itemData.nickname ?? '',
style: TextStyle(
fontSize: 20.sp, color: AppColors.blackColor),
),
Expanded(
child: SizedBox(
width: 10.w,
)),
Text(
itemData.lockAlias ?? '',
style: TextStyle(
fontSize: 20.sp, color: AppColors.blackColor),
),
],
),
SizedBox(height: 10.h),
Row(
mainAxisAlignment: MainAxisAlignment.start,
children: [
Text(
logic.getExpireDateStr(itemData),
style: TextStyle(
fontSize: 18.sp,
color: AppColors.placeholderTextColor),
),
SizedBox(
width: 5.w,
),
getStatus(itemData),
],
),
SizedBox(width: 20.h),
],
),
),
SizedBox(width: 20.w),
],
),
),
);
}
Widget getStatus(ExpireFingerprintItemEntity itemData) {
// if (itemData.keyboardPwdStatus! == 1) {
// return Container(
// padding: EdgeInsets.only(left: 5.w, right: 5.w),
// decoration: BoxDecoration(
// color: Colors.red,
// borderRadius: BorderRadius.circular(2.0),
// ),
// child: Text(
// '未生效',
// style: TextStyle(
// color: Colors.white, fontSize: 13.sp),
// ),
// );
// } else {
if (itemData.expireDate! > 0) {
return Container(
padding: EdgeInsets.only(left: 5.w, right: 5.w),
decoration: BoxDecoration(
color: AppColors.expireTextBgColor,
borderRadius: BorderRadius.circular(2.0),
),
child: Text(
'${itemData.expireDate.toString()}',
style: TextStyle(
color: Colors.white, fontSize: 13.sp),
),
);
} else {
return Container(
padding: EdgeInsets.only(left: 5.w, right: 5.w),
decoration: BoxDecoration(
color: Colors.red,
borderRadius: BorderRadius.circular(2.0),
),
child: Text(
'已过期',
style: TextStyle(
color: Colors.white, fontSize: 13.sp),
),
);
}
// }
}
}

View File

@ -0,0 +1,13 @@
import 'package:get/get.dart';
import '../expireFingerprint/expireFingerprint_entity.dart';
class ExpireFaceState{
final dataList = <ExpireFingerprintItemEntity>[].obs;
var ifCurrentScreen = true.obs; // ,
var sureBtnState = 0.obs;// 0() 1()
ExpireFingerprintItemEntity deletExpireFingerprintItemEntity = ExpireFingerprintItemEntity();
}

View File

@ -0,0 +1,218 @@
class ExpireFingerprintEntity {
int? errorCode;
String? description;
String? errorMsg;
ExpireFingerprintListEntity? data;
ExpireFingerprintEntity(
{this.errorCode, this.description, this.errorMsg, this.data});
ExpireFingerprintEntity.fromJson(Map<String, dynamic> json) {
errorCode = json['errorCode'];
description = json['description'];
errorMsg = json['errorMsg'];
data = json['data'] != null ? ExpireFingerprintListEntity.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 ExpireFingerprintListEntity {
List<ExpireFingerprintItemEntity>? list;
int? pageNo;
int? pageSize;
int? pages;
int? total;
ExpireFingerprintListEntity({this.list, this.pageNo, this.pageSize, this.pages, this.total});
ExpireFingerprintListEntity.fromJson(Map<String, dynamic> json) {
if (json['list'] != null) {
list = <ExpireFingerprintItemEntity>[];
json['list'].forEach((v) {
list!.add(ExpireFingerprintItemEntity.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 ExpireFingerprintItemEntity {
String? clientId;
int? lockOwnerId;
int? lockId;
int? fingerprintStatus;
String? fingerprintNumber;
int? fingerprintType;
int? startDate;
int? endDate;
List? weekDay;
int? addType;
int? fingerRight;
int? isCoerced;
int? fingerprintUserNo;
int? businessId;
String? createdAt;
String? updatedAt;
ApiUser? apiUser;
LockInfo? lockInfo;
int? fingerprintId;
int? uid;
String? nickname;
String? lockAlias;
int? expireDate;
ExpireFingerprintItemEntity(
{this.clientId,
this.lockOwnerId,
this.lockId,
this.fingerprintStatus,
this.fingerprintNumber,
this.fingerprintType,
this.startDate,
this.endDate,
this.weekDay,
this.addType,
this.fingerRight,
this.isCoerced,
this.fingerprintUserNo,
this.businessId,
this.createdAt,
this.updatedAt,
this.apiUser,
this.lockInfo,
this.fingerprintId,
this.uid,
this.nickname,
this.lockAlias,
this.expireDate});
ExpireFingerprintItemEntity.fromJson(Map<String, dynamic> json) {
clientId = json['clientId'];
lockOwnerId = json['lockOwnerId'];
lockId = json['lockId'];
fingerprintStatus = json['fingerprintStatus'];
fingerprintNumber = json['fingerprintNumber'];
fingerprintType = json['fingerprintType'];
startDate = json['startDate'];
endDate = json['endDate'];
if (json['weekDays'] != null) {
weekDay = [];
json['weekDays'].forEach((v) {
weekDay!.add(v);
});
}
addType = json['addType'];
fingerRight = json['fingerRight'];
isCoerced = json['isCoerced'];
fingerprintUserNo = json['fingerprintUserNo'];
businessId = json['businessId'];
createdAt = json['created_at'];
updatedAt = json['updated_at'];
apiUser = json['api_user'] != null
? ApiUser.fromJson(json['api_user'])
: null;
lockInfo = json['lock_info'] != null
? LockInfo.fromJson(json['lock_info'])
: null;
fingerprintId = json['fingerprintId'];
uid = json['uid'];
nickname = json['nickname'];
lockAlias = json['lockAlias'];
expireDate = json['expireDate'];
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = <String, dynamic>{};
data['clientId'] = clientId;
data['lockOwnerId'] = lockOwnerId;
data['lockId'] = lockId;
data['fingerprintStatus'] = fingerprintStatus;
data['fingerprintNumber'] = fingerprintNumber;
data['fingerprintType'] = fingerprintType;
data['startDate'] = startDate;
data['endDate'] = endDate;
if (weekDay != null) {
data['weekDay'] = weekDay!.map((v) => v.toJson()).toList();
}
data['addType'] = addType;
data['fingerRight'] = fingerRight;
data['isCoerced'] = isCoerced;
data['fingerprintUserNo'] = fingerprintUserNo;
data['businessId'] = businessId;
data['created_at'] = createdAt;
data['updated_at'] = updatedAt;
if (apiUser != null) {
data['api_user'] = apiUser!.toJson();
}
if (lockInfo != null) {
data['lock_info'] = lockInfo!.toJson();
}
data['fingerprintId'] = fingerprintId;
data['uid'] = uid;
data['nickname'] = nickname;
data['lockAlias'] = lockAlias;
data['expireDate'] = expireDate;
return data;
}
}
class ApiUser {
int? id;
String? accountName;
ApiUser({this.id, this.accountName});
ApiUser.fromJson(Map<String, dynamic> json) {
id = json['id'];
accountName = json['account_name'];
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = <String, dynamic>{};
data['id'] = id;
data['account_name'] = accountName;
return data;
}
}
class LockInfo {
String? btDeviceName;
LockInfo({this.btDeviceName});
LockInfo.fromJson(Map<String, dynamic> json) {
btDeviceName = json['btDeviceName'];
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = <String, dynamic>{};
data['btDeviceName'] = btDeviceName;
return data;
}
}

View File

@ -0,0 +1,211 @@
import 'dart:async';
import 'package:flutter_blue_plus/flutter_blue_plus.dart';
import 'package:star_lock/blue/io_protocol/io_addFingerprint.dart';
import 'package:star_lock/blue/io_tool/io_tool.dart';
import 'package:star_lock/blue/io_type.dart';
import 'package:star_lock/tools/baseGetXController.dart';
import 'package:star_lock/tools/dateTool.dart';
import '../../../../../blue/blue_manage.dart';
import '../../../../../blue/io_reply.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 'expireFingerprint_entity.dart';
import 'expireFingerprint_state.dart';
class ExpireFingerprintLogic extends BaseGetXController {
ExpireFingerprintState state = ExpireFingerprintState();
//
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} 数据解析成功");
state.sureBtnState.value = 0;
cancelBlueConnetctToastTimer();
dismissEasyLoading();
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!);
String? userID = await Storage.getUid();
IoSenderManage.senderAddFingerprintCommand(
keyID:state.deletExpireFingerprintItemEntity.fingerprintId.toString(),
userID:userID,
fingerNo:int.parse(state.deletExpireFingerprintItemEntity.fingerprintNumber!),
useCountLimit:0,
startTime:state.deletExpireFingerprintItemEntity.startDate!~/1000,
endTime:state.deletExpireFingerprintItemEntity.endDate!~/1000,
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() async {
if(state.sureBtnState.value == 1){
return;
}
state.sureBtnState.value = 1;
showEasyLoading();
showBlueConnetctToastTimer(action: (){
dismissEasyLoading();
state.sureBtnState.value = 0;
});
BlueManage().bludSendData(state.deletExpireFingerprintItemEntity.lockInfo!.btDeviceName!, (BluetoothConnectionState deviceConnectionState) async {
if (deviceConnectionState == BluetoothConnectionState.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!);
String? userID = await Storage.getUid();
IoSenderManage.senderAddFingerprintCommand(
keyID:state.deletExpireFingerprintItemEntity.fingerprintId.toString(),
userID:userID,
fingerNo:int.parse(state.deletExpireFingerprintItemEntity.fingerprintNumber!),
useCountLimit:0,
startTime:state.deletExpireFingerprintItemEntity.startDate!~/1000,
endTime:state.deletExpireFingerprintItemEntity.endDate!~/1000,
needAuthor:1,
publicKey:publicKeyDataList,
privateKey:getPrivateKeyList,
token: getTokenList,
);
} else if (deviceConnectionState == BluetoothConnectionState.disconnected) {
dismissEasyLoading();
cancelBlueConnetctToastTimer();
state.sureBtnState.value = 0;
if(state.ifCurrentScreen.value == true){
showBlueConnetctToast();
}
}
});
}
//
void deletFingerprintsData() async{
var entity = await ApiRepository.to.deletFingerprintsData(
fingerprintId: state.deletExpireFingerprintItemEntity.fingerprintId.toString(),
lockId: state.deletExpireFingerprintItemEntity.lockId.toString(),
type: "0",
deleteType:"1"
);
if(entity.errorCode!.codeIsSuccessful){
showToast("删除成功",something: (){
BlueManage().disconnect();
pageNo = 1;
expirFingerprintListRequest();
eventBus.fire(LockUserManageListRefreshUI());
});
}
}
//
Future<ExpireFingerprintEntity> expirFingerprintListRequest() async {
ExpireFingerprintEntity entity = await ApiRepository.to.expireFingerprintList(pageNo.toString(), pageSize.toString());
if(entity.errorCode!.codeIsSuccessful){
if (pageNo == 1) {
state.dataList.value = entity.data!.list!;
pageNo++;
} else {
if (entity.data!.list!.isNotEmpty) {
state.dataList.value.addAll(entity.data!.list!);
pageNo++;
}
}
}
return entity;
}
//使
String getExpireDateStr(ExpireFingerprintItemEntity itemData) {
String useDateStr = '';
if(itemData.fingerprintType == 4){
useDateStr = '循环';
}else{
useDateStr = '${DateTool().dateToYMDString(itemData.startDate.toString())}-${DateTool().dateToYMDString(itemData.endDate.toString())}';
}
return useDateStr;
}
@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();
}
}

View File

@ -0,0 +1,240 @@
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:flutter_slidable/flutter_slidable.dart';
import 'package:get/get.dart';
import 'package:star_lock/tools/noData.dart';
import 'package:star_lock/tools/showTipView.dart';
import '../../../../../app_settings/app_colors.dart';
import '../../../../../tools/EasyRefreshTool.dart';
import 'expireFingerprint_entity.dart';
import 'expireFingerprint_logic.dart';
class ExpireFingerprintPage extends StatefulWidget {
const ExpireFingerprintPage({Key? key}) : super(key: key);
@override
State<ExpireFingerprintPage> createState() => _ExpireFingerprintPageState();
}
class _ExpireFingerprintPageState extends State<ExpireFingerprintPage> {
final logic = Get.put(ExpireFingerprintLogic());
final state = Get.find<ExpireFingerprintLogic>().state;
Future<void> getHttpData() async {
logic.expirFingerprintListRequest().then((ExpireFingerprintEntity value){
if(mounted) setState(() {});
});
}
@override
void initState() {
super.initState();
getHttpData();
}
@override
Widget build(BuildContext context) {
return EasyRefreshTool(
onRefresh: (){
logic.pageNo = 1;
getHttpData();
},
onLoad: (){
getHttpData();
},
child: Obx(() => _buildMainUI())
);
}
Widget _buildMainUI() {
return state.dataList.isEmpty
? NoData(noDataHeight: 1.sh - ScreenUtil().statusBarHeight - ScreenUtil().bottomBarHeight - 190.h - 64.h)
: SlidableAutoCloseBehavior(
child: ListView.separated(
itemCount: state.dataList.length,
itemBuilder: (c, index) {
ExpireFingerprintItemEntity indexEntity = state.dataList[index];
return Slidable(
key:ValueKey(indexEntity.uid),
endActionPane: ActionPane(
extentRatio: 0.2,
motion: const ScrollMotion(),
children: [
SlidableAction(
onPressed: (BuildContext context){
ShowTipView().showIosTipWithContentDialog("确定删除卡吗?", (){
state.deletExpireFingerprintItemEntity = indexEntity;
logic.senderAddFingerprint();
});
},
backgroundColor: Colors.red,
foregroundColor: Colors.white,
label: '删除',
padding: EdgeInsets.only(left: 5.w, right: 5.w),
),
],
),
child: _electronicKeyItem(indexEntity),
);
},
separatorBuilder: (BuildContext context, int index) {
return const Divider(
height: 1,
color: AppColors.greyLineColor,
);
},
),
);
}
Widget _electronicKeyItem(ExpireFingerprintItemEntity itemData) {
return GestureDetector(
onTap: () async {
// if(itemData.cardType! == 4){
// //
// var data = await Get.toNamed(Routers.electronicKeyPeriodValidityPage, arguments: {
// "pushType": 0,
// "expireLockItem": itemData,
// });
// if(data != null) {
// // setState(() {
// // state.starDate.value = data["starDate"];
// // state.endDate.value = data["endDate"];
// // state.starTime.value = data["starTime"];
// // state.endTime.value = data["endTime"];
// // state.weekDay.value = data["validityValue"];
// // });
// logic.pageNo = 1;
// getHttpData();
// }
// }else{
// var data = await Get.toNamed(Routers.electronicKeyDetailChangeDate, arguments: {
// "pushType": 0,
// "expireLockItem": itemData,
// });
// if(data != null) {
// setState(() {
// // state.starDate.value = data["beginTimeTimestamp"].toString();
// // state.endDate.value = data["endTimeTimestamp"].toString();
// // state.keyType.value = 2;
// logic.pageNo = 1;
// getHttpData();
// });
// }
// }
},
child: Container(
height: 90.h,
color: Colors.white,
child: Row(
children: [
SizedBox(
width: 30.w,
),
Image.asset(
'images/controls_user.png',
width: 60.w,
height: 60.w,
),
SizedBox(
width: 20.w,
),
Expanded(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Row(
mainAxisAlignment: MainAxisAlignment.start,
children: [
Text(
itemData.nickname ?? '',
style: TextStyle(
fontSize: 20.sp, color: AppColors.blackColor),
),
Expanded(
child: SizedBox(
width: 10.w,
)),
Text(
itemData.lockAlias ?? '',
style: TextStyle(
fontSize: 20.sp, color: AppColors.blackColor),
),
],
),
SizedBox(height: 10.h),
Row(
mainAxisAlignment: MainAxisAlignment.start,
children: [
Text(
logic.getExpireDateStr(itemData),
style: TextStyle(
fontSize: 18.sp,
color: AppColors.placeholderTextColor),
),
SizedBox(
width: 5.w,
),
getStatus(itemData),
],
),
SizedBox(width: 20.h),
],
),
),
SizedBox(width: 20.w),
],
),
),
);
}
Widget getStatus(ExpireFingerprintItemEntity itemData) {
// if (itemData.keyboardPwdStatus! == 1) {
// return Container(
// padding: EdgeInsets.only(left: 5.w, right: 5.w),
// decoration: BoxDecoration(
// color: Colors.red,
// borderRadius: BorderRadius.circular(2.0),
// ),
// child: Text(
// '未生效',
// style: TextStyle(
// color: Colors.white, fontSize: 13.sp),
// ),
// );
// } else {
if (itemData.expireDate! > 0) {
return Container(
padding: EdgeInsets.only(left: 5.w, right: 5.w),
decoration: BoxDecoration(
color: AppColors.expireTextBgColor,
borderRadius: BorderRadius.circular(2.0),
),
child: Text(
'${itemData.expireDate.toString()}',
style: TextStyle(
color: Colors.white, fontSize: 13.sp),
),
);
} else {
return Container(
padding: EdgeInsets.only(left: 5.w, right: 5.w),
decoration: BoxDecoration(
color: Colors.red,
borderRadius: BorderRadius.circular(2.0),
),
child: Text(
'已过期',
style: TextStyle(
color: Colors.white, fontSize: 13.sp),
),
);
}
// }
}
}

View File

@ -0,0 +1,12 @@
import 'package:get/get.dart';
import 'expireFingerprint_entity.dart';
class ExpireFingerprintState{
final dataList = <ExpireFingerprintItemEntity>[].obs;
var ifCurrentScreen = true.obs; // ,
var sureBtnState = 0.obs;// 0() 1()
ExpireFingerprintItemEntity deletExpireFingerprintItemEntity = ExpireFingerprintItemEntity();
}

View File

@ -1,41 +0,0 @@
import 'package:star_lock/tools/baseGetXController.dart';
import 'package:star_lock/tools/dateTool.dart';
import '../../../../network/api_repository.dart';
import 'expireLockList_entity.dart';
import 'expireLockList_state.dart';
class ExpireLockListLogic extends BaseGetXController{
ExpireLockListState state = ExpireLockListState();
//
Future<ExpireLockListEntity> expireLockListRequest() async {
ExpireLockListEntity entity = await ApiRepository.to.expireLockList(pageNo.toString(), pageSize.toString());
if(entity.errorCode!.codeIsSuccessful){
if (pageNo == 1) {
state.dataList.value = entity.data!.itemList!;
pageNo++;
} else {
if (entity.data!.itemList!.isNotEmpty) {
state.dataList.value.addAll(entity.data!.itemList!);
pageNo++;
}
}
}
return entity;
}
//使
String getExpireDateStr(ExpireLockItem itemData) {
String useDateStr = '';
if(itemData.keyType == 4){
useDateStr = '循环';
}else{
useDateStr = '${DateTool().dateToYMDString(itemData.startDate.toString())}-${DateTool().dateToYMDString(itemData.endDate.toString())}';
}
return useDateStr;
}
}

View File

@ -0,0 +1,33 @@
import 'package:flutter/material.dart';
import 'package:star_lock/tools/titleAppBar.dart';
import '../../../../app_settings/app_colors.dart';
import 'expireLockManage_tabbar.dart';
class ExpireLockManagePage extends StatefulWidget {
const ExpireLockManagePage({Key? key}) : super(key: key);
@override
State<ExpireLockManagePage> createState() => _ExpireLockManagePageState();
}
class _ExpireLockManagePageState extends State<ExpireLockManagePage> {
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: AppColors.mainBackgroundColor,
appBar: TitleAppBar(
barTitle: "即将到期",
haveBack: true,
backgroundColor: AppColors.mainColor),
body: const Column(
children: [
ExpireLockManageTabbar(),
],
),
);
}
}

View File

@ -0,0 +1,117 @@
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';
import 'package:star_lock/app_settings/app_colors.dart';
import 'package:star_lock/tools/CustomUnderlineTabIndicator.dart';
import 'package:star_lock/translations/trans_lib.dart';
import 'expireCard/expireCard_page.dart';
import 'expireElectronicKey/expireLockList_page.dart';
import 'expireFace/expireFace_page.dart';
import 'expireFingerprint/expireFingerprint_page.dart';
import 'expirePassword/expirePassword_page.dart';
class ExpireLockManageTabbar extends StatefulWidget {
const ExpireLockManageTabbar({Key? key}) : super(key: key);
@override
State<ExpireLockManageTabbar> createState() => _ExpireLockManageTabbarState();
}
class _ExpireLockManageTabbarState extends State<ExpireLockManageTabbar> with SingleTickerProviderStateMixin {
late TabController _tabController;
final List<ItemView> _itemTabs = <ItemView>[
ItemView(title: TranslationLoader.lanKeys!.electronicKey!.tr, selectType: "0"),
ItemView(title: TranslationLoader.lanKeys!.password!.tr, selectType: "1"),
ItemView(title: TranslationLoader.lanKeys!.card!.tr, selectType: "2"),
ItemView(title: TranslationLoader.lanKeys!.fingerprint!.tr, selectType: "3"),
ItemView(title: TranslationLoader.lanKeys!.face!.tr, selectType: "4"),
];
@override
void initState() {
// TODO: implement initState
super.initState();
_tabController = TabController(
vsync: this,
length: _itemTabs.length,
initialIndex: 1);
_tabController.addListener(() {
if (_tabController.animation!.value == _tabController.index) {
FocusScope.of(context).requestFocus(FocusNode());
}
});
}
@override
Widget build(BuildContext context) {
return Expanded(
child: Column(
children: [
_tabBar(),
_pageWidget(),
],
));
}
TabBar _tabBar() {
return TabBar(
controller: _tabController,
onTap: (index) {
FocusScope.of(context).requestFocus(FocusNode());
},
tabs: _itemTabs.map((ItemView item) => _tab(item)).toList(),
isScrollable: true,
indicatorColor: Colors.red,
unselectedLabelColor: Colors.black,
unselectedLabelStyle: TextStyle(
color: AppColors.mainColor,
fontSize: 24.sp,
),
automaticIndicatorColorAdjustment: true,
labelColor: AppColors.mainColor,
labelStyle: TextStyle(
color: AppColors.mainColor,
fontSize: 24.sp,
fontWeight: FontWeight.w600),
indicator: CustomUnderlineTabIndicator(
borderSide: BorderSide(color: AppColors.mainColor, width: 4.w),
strokeCap: StrokeCap.round,
width: 30.w),
);
}
Tab _tab(ItemView item) {
return Tab(
child: SizedBox(
// width: 1.sw / 5,
child: Text(item.title, textAlign: TextAlign.center)));
}
Widget _pageWidget() {
return Expanded(
child: TabBarView(
controller: _tabController,
children:const [
ExpireLockListPage(),
ExpirePasswordPage(),
ExpireCardPage(),
ExpireFingerprintPage(),
ExpireFacePage(),
]
),
);
}
}
class ItemView {
const ItemView({required this.title, required this.selectType});
final String title;
final String selectType;
}

View File

@ -0,0 +1,198 @@
class ExpirePasswordEntity {
int? errorCode;
String? description;
String? errorMsg;
ExpirePasswordListData? data;
ExpirePasswordEntity(
{this.errorCode, this.description, this.errorMsg, this.data});
ExpirePasswordEntity.fromJson(Map<String, dynamic> json) {
errorCode = json['errorCode'];
description = json['description'];
errorMsg = json['errorMsg'];
data = json['data'] != null ? ExpirePasswordListData.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 ExpirePasswordListData {
List<ExpirePasswordItemData>? list;
int? pageNo;
int? pageSize;
int? pages;
int? total;
ExpirePasswordListData({this.list, this.pageNo, this.pageSize, this.pages, this.total});
ExpirePasswordListData.fromJson(Map<String, dynamic> json) {
if (json['list'] != null) {
list = <ExpirePasswordItemData>[];
json['list'].forEach((v) {
list!.add(ExpirePasswordItemData.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 ExpirePasswordItemData {
String? clientId;
int? lockOwnerId;
int? lockId;
int? keyboardPwdType;
int? keyboardPwdStatus;
int? startDate;
int? endDate;
String? keyboardPwd;
String? keyboardPwdHash;
int? addType;
int? pwdRight;
int? isCustom;
int? isCoerced;
int? hoursStart;
int? hoursEnd;
int? pwdUserNo;
int? businessId;
String? createdAt;
String? updatedAt;
ApiUser? apiUser;
int? pwdId;
int? uid;
String? nickname;
String? lockAlias;
int? expireDate;
ExpirePasswordItemData(
{this.clientId,
this.lockOwnerId,
this.lockId,
this.keyboardPwdType,
this.keyboardPwdStatus,
this.startDate,
this.endDate,
this.keyboardPwd,
this.keyboardPwdHash,
this.addType,
this.pwdRight,
this.isCustom,
this.isCoerced,
this.hoursStart,
this.hoursEnd,
this.pwdUserNo,
this.businessId,
this.createdAt,
this.updatedAt,
this.apiUser,
this.pwdId,
this.uid,
this.nickname,
this.lockAlias,
this.expireDate});
ExpirePasswordItemData.fromJson(Map<String, dynamic> json) {
clientId = json['clientId'];
lockOwnerId = json['lockOwnerId'];
lockId = json['lockId'];
keyboardPwdType = json['keyboardPwdType'];
keyboardPwdStatus = json['keyboardPwdStatus'];
startDate = json['startDate'];
endDate = json['endDate'];
keyboardPwd = json['keyboardPwd'];
keyboardPwdHash = json['keyboardPwdHash'];
addType = json['addType'];
pwdRight = json['pwdRight'];
isCustom = json['isCustom'];
isCoerced = json['isCoerced'];
hoursStart = json['hoursStart'];
hoursEnd = json['hoursEnd'];
pwdUserNo = json['pwdUserNo'];
businessId = json['businessId'];
createdAt = json['created_at'];
updatedAt = json['updated_at'];
apiUser = json['api_user'] != null
? ApiUser.fromJson(json['api_user'])
: null;
pwdId = json['pwdId'];
uid = json['uid'];
nickname = json['nickname'];
lockAlias = json['lockAlias'];
expireDate = json['expireDate'];
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = <String, dynamic>{};
data['clientId'] = clientId;
data['lockOwnerId'] = lockOwnerId;
data['lockId'] = lockId;
data['keyboardPwdType'] = keyboardPwdType;
data['keyboardPwdStatus'] = keyboardPwdStatus;
data['startDate'] = startDate;
data['endDate'] = endDate;
data['keyboardPwd'] = keyboardPwd;
data['keyboardPwdHash'] = keyboardPwdHash;
data['addType'] = addType;
data['pwdRight'] = pwdRight;
data['isCustom'] = isCustom;
data['isCoerced'] = isCoerced;
data['hoursStart'] = hoursStart;
data['hoursEnd'] = hoursEnd;
data['pwdUserNo'] = pwdUserNo;
data['businessId'] = businessId;
data['created_at'] = createdAt;
data['updated_at'] = updatedAt;
if (apiUser != null) {
data['api_user'] = apiUser!.toJson();
}
data['pwdId'] = pwdId;
data['uid'] = uid;
data['nickname'] = nickname;
data['lockAlias'] = lockAlias;
data['expireDate'] = expireDate;
return data;
}
}
class ApiUser {
int? id;
String? accountName;
ApiUser({this.id, this.accountName});
ApiUser.fromJson(Map<String, dynamic> json) {
id = json['id'];
accountName = json['account_name'];
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = <String, dynamic>{};
data['id'] = id;
data['account_name'] = accountName;
return data;
}
}

View File

@ -0,0 +1,57 @@
import 'package:star_lock/tools/baseGetXController.dart';
import 'package:star_lock/tools/dateTool.dart';
import '../../../../../main/lockDetail/passwordKey/passwordKey_perpetual/passwordKeyEntity.dart';
import '../../../../../network/api_repository.dart';
import '../../../../../tools/eventBusEventManage.dart';
import 'expirePassword_entity.dart';
import 'expirePassword_state.dart';
class ExpirePasswordLogic extends BaseGetXController {
ExpirePasswordState state = ExpirePasswordState();
//
Future<ExpirePasswordEntity> expirePasswordListRequest() async {
ExpirePasswordEntity entity = await ApiRepository.to.expirePasswordList(pageNo.toString(), pageSize.toString());
if(entity.errorCode!.codeIsSuccessful){
if (pageNo == 1) {
state.dataList.value = entity.data!.list!;
pageNo++;
} else {
if (entity.data!.list!.isNotEmpty) {
state.dataList.value.addAll(entity.data!.list!);
pageNo++;
}
}
}
return entity;
}
// deleteType:1- 2-
Future<void> deletePwdRequest(ExpirePasswordItemData expirePasswordItemData) async {
PasswordKeyEntity entity = await ApiRepository.to.deleteKeyboardPwd(
expirePasswordItemData.lockId.toString(),
expirePasswordItemData.pwdId.toString(),
1);
if (entity.errorCode!.codeIsSuccessful) {
showToast("删除成功", something: () {
pageNo = 1;
expirePasswordListRequest();
eventBus.fire(LockUserManageListRefreshUI());
});
}
}
//使
String getExpireDateStr(ExpirePasswordItemData itemData) {
String useDateStr = '';
if(itemData.keyboardPwdType == 4){
useDateStr = '循环';
}else{
useDateStr = '${DateTool().dateToYMDString(itemData.startDate.toString())}-${DateTool().dateToYMDString(itemData.endDate.toString())}';
}
return useDateStr;
}
}

View File

@ -0,0 +1,240 @@
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:flutter_slidable/flutter_slidable.dart';
import 'package:get/get.dart';
import 'package:star_lock/appRouters.dart';
import 'package:star_lock/app_settings/app_colors.dart';
import 'package:star_lock/tools/EasyRefreshTool.dart';
import 'package:star_lock/tools/noData.dart';
import '../../../../../tools/showTipView.dart';
import 'expirePassword_entity.dart';
import 'expirePassword_logic.dart';
class ExpirePasswordPage extends StatefulWidget {
const ExpirePasswordPage({Key? key}) : super(key: key);
@override
State<ExpirePasswordPage> createState() => _ExpirePasswordPageState();
}
class _ExpirePasswordPageState extends State<ExpirePasswordPage> {
final logic = Get.put(ExpirePasswordLogic());
final state = Get.find<ExpirePasswordLogic>().state;
Future<void> getHttpData() async {
logic.expirePasswordListRequest().then((ExpirePasswordEntity value){
if(mounted) setState(() {});
});
}
@override
void initState() {
super.initState();
getHttpData();
}
@override
Widget build(BuildContext context) {
return EasyRefreshTool(
onRefresh: (){
logic.pageNo = 1;
getHttpData();
},
onLoad: (){
getHttpData();
},
child: Obx(() => _buildMainUI())
);
}
Widget _buildMainUI() {
return state.dataList.isEmpty
? NoData(noDataHeight: 1.sh - ScreenUtil().statusBarHeight - ScreenUtil().bottomBarHeight - 190.h - 64.h)
: SlidableAutoCloseBehavior(
child: ListView.separated(
itemCount: state.dataList.length,
itemBuilder: (c, index) {
ExpirePasswordItemData indexEntity = state.dataList[index];
return Slidable(
key:ValueKey(indexEntity.uid),
endActionPane: ActionPane(
extentRatio: 0.2,
motion: const ScrollMotion(),
children: [
SlidableAction(
onPressed: (BuildContext context){
ShowTipView().showIosTipWithContentDialog("确定删除该密码吗?", (){
logic.deletePwdRequest(indexEntity);
});
},
backgroundColor: Colors.red,
foregroundColor: Colors.white,
label: '删除',
padding: EdgeInsets.only(left: 5.w, right: 5.w),
),
],
),
child: _electronicKeyItem(indexEntity),
);
},
separatorBuilder: (BuildContext context, int index) {
return const Divider(
height: 1,
color: AppColors.greyLineColor,
);
},
),
);
}
Widget _electronicKeyItem(ExpirePasswordItemData itemData) {
return GestureDetector(
onTap: () async {
// if(itemData.keyboardPwdType! == 4){
// //
// var data = await Get.toNamed(Routers.electronicKeyPeriodValidityPage, arguments: {
// "pushType": 0,
// "expireLockItem": itemData,
// });
// if(data != null) {
// // setState(() {
// // state.starDate.value = data["starDate"];
// // state.endDate.value = data["endDate"];
// // state.starTime.value = data["starTime"];
// // state.endTime.value = data["endTime"];
// // state.weekDay.value = data["validityValue"];
// // });
// logic.pageNo = 1;
// getHttpData();
// }
// }else{
// var data = await Get.toNamed(Routers.electronicKeyDetailChangeDate, arguments: {
// "pushType": 0,
// "expireLockItem": itemData,
// });
// if(data != null) {
// setState(() {
// // state.starDate.value = data["beginTimeTimestamp"].toString();
// // state.endDate.value = data["endTimeTimestamp"].toString();
// // state.keyType.value = 2;
// logic.pageNo = 1;
// getHttpData();
// });
// }
// }
},
child: Container(
height: 90.h,
color: Colors.white,
child: Row(
children: [
SizedBox(
width: 30.w,
),
Image.asset(
'images/controls_user.png',
width: 60.w,
height: 60.w,
),
SizedBox(
width: 20.w,
),
Expanded(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Row(
mainAxisAlignment: MainAxisAlignment.start,
children: [
Text(
itemData.nickname ?? '',
style: TextStyle(
fontSize: 20.sp, color: AppColors.blackColor),
),
Expanded(
child: SizedBox(
width: 10.w,
)),
Text(
itemData.lockAlias ?? '',
style: TextStyle(
fontSize: 20.sp, color: AppColors.blackColor),
),
],
),
SizedBox(height: 10.h),
Row(
mainAxisAlignment: MainAxisAlignment.start,
children: [
Text(
logic.getExpireDateStr(itemData),
style: TextStyle(
fontSize: 18.sp,
color: AppColors.placeholderTextColor),
),
SizedBox(
width: 5.w,
),
getStatus(itemData),
],
),
SizedBox(width: 20.h),
],
),
),
SizedBox(width: 20.w),
],
),
),
);
}
Widget getStatus(ExpirePasswordItemData itemData) {
// if (itemData.keyboardPwdStatus! == 1) {
// return Container(
// padding: EdgeInsets.only(left: 5.w, right: 5.w),
// decoration: BoxDecoration(
// color: Colors.red,
// borderRadius: BorderRadius.circular(2.0),
// ),
// child: Text(
// '未生效',
// style: TextStyle(
// color: Colors.white, fontSize: 13.sp),
// ),
// );
// } else {
if (itemData.expireDate! > 0) {
return Container(
padding: EdgeInsets.only(left: 5.w, right: 5.w),
decoration: BoxDecoration(
color: AppColors.expireTextBgColor,
borderRadius: BorderRadius.circular(2.0),
),
child: Text(
'${itemData.expireDate.toString()}',
style: TextStyle(
color: Colors.white, fontSize: 13.sp),
),
);
} else {
return Container(
padding: EdgeInsets.only(left: 5.w, right: 5.w),
decoration: BoxDecoration(
color: Colors.red,
borderRadius: BorderRadius.circular(2.0),
),
child: Text(
'已过期',
style: TextStyle(
color: Colors.white, fontSize: 13.sp),
),
);
}
// }
}
}

View File

@ -0,0 +1,7 @@
import 'package:get/get.dart';
import 'expirePassword_entity.dart';
class ExpirePasswordState {
final dataList = <ExpirePasswordItemData>[].obs;
}

View File

@ -1,10 +1,13 @@
import 'dart:async';
import 'package:flutter_easyloading/flutter_easyloading.dart';
import 'package:get/get.dart';
import '../../../../main/lockDetail/electronicKey/massSendElectronicKey/massSendLockGroupList/lockUserList/lockUserListEntity.dart';
import '../../../../network/api_repository.dart';
import '../../../../tools/baseGetXController.dart';
import '../../../../tools/eventBusEventManage.dart';
import 'lockUserManageList_state.dart';
class LockUserManageListLogic extends BaseGetXController {
@ -13,7 +16,7 @@ class LockUserManageListLogic extends BaseGetXController {
//
Future<LockUserListEntity> lockUserListRequest() async {
LockUserListEntity entity =
await ApiRepository.to.lockUserList(pageNo.toString(), '20', state.searchController.text);
await ApiRepository.to.lockUserList(pageNo.toString(), pageSize, state.searchController.text);
if(entity.errorCode!.codeIsSuccessful){
if (pageNo == 1) {
state.dataList.value = entity.data!;
@ -41,12 +44,22 @@ class LockUserManageListLogic extends BaseGetXController {
}
}
///
StreamSubscription? _getElectronicKeyListRefreshUIEvent;
void _getElectronicKeyListRefreshUIAction() {
// eventBus
_getElectronicKeyListRefreshUIEvent = eventBus.on<LockUserManageListRefreshUI>().listen((event) {
pageNo = 1;
lockUserListRequest();
});
}
@override
void onReady() {
// TODO: implement onReady
super.onReady();
// lockUserListRequest();
_getElectronicKeyListRefreshUIAction();
}
@override
@ -58,5 +71,8 @@ class LockUserManageListLogic extends BaseGetXController {
@override
void onClose() {
// TODO: implement onClose
super.onClose();
_getElectronicKeyListRefreshUIEvent?.cancel();
}
}

View File

@ -11,7 +11,6 @@ import '../../../../../tools/titleAppBar.dart';
import '../../../../../translations/trans_lib.dart';
import '../../../../tools/EasyRefreshTool.dart';
import '../../../../tools/keySearchWidget.dart';
import '../../../../tools/left_slide_actions.dart';
import '../../../../tools/showIosTipView.dart';
import 'lockUserManageList_logic.dart';
@ -54,7 +53,7 @@ class _LockUserManageListPageState extends State<LockUserManageListPage> {
style: TextStyle(color: Colors.white, fontSize: 24.sp),
),
onPressed: () {
Navigator.pushNamed(context, Routers.expireLockListPage);
Navigator.pushNamed(context, Routers.expireLockManagePage);
},
),
],
@ -139,18 +138,6 @@ class _LockUserManageListPageState extends State<LockUserManageListPage> {
),
child: _electronicKeyItem(indexEntity),
);
// return LeftSlideActions(
// key: Key(indexEntity.userid!),
// actionsWidth: 60,
// actions: [
// _buildDeleteBtn(indexEntity),
// ],
// decoration: const BoxDecoration(
// borderRadius: BorderRadius.all(Radius.circular(1)),
// ),
// child: _electronicKeyItem(indexEntity),
// );
}
return const SizedBox.shrink();
// return _electronicKeyItem(indexEntity);
@ -233,36 +220,13 @@ class _LockUserManageListPageState extends State<LockUserManageListPage> {
);
}
// Widget _buildDeleteBtn(LockUserData passwordKeyListItem) {
// return GestureDetector(
// onTap: () {
// // :
// showIosTipViewDialog(context, passwordKeyListItem);
// },
// 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, LockUserData lockUserData) {
showDialog(
context: context,
builder: (BuildContext context) {
return ShowIosTipView(
title: "提示",
tipTitle: "确定要删除吗?",
tipTitle: "删除用户时,会将用户拥有的钥匙一起删除。",
sureClick: () {
Get.back();
logic.deletelockUserRequest(lockUserData.uid!);

View File

@ -1,6 +1,9 @@
import 'package:get/get.dart';
import 'package:star_lock/common/XSConstantMacro/XSConstantMacro.dart';
import 'package:star_lock/tools/baseGetXController.dart';
import 'package:star_lock/tools/eventBusEventManage.dart';
import '../../../../main/lockDetail/electronicKey/electronicKeyList/entity/ElectronicKeyListEntity.dart';
import '../../../../network/api_repository.dart';
import '../lockUserManageList/keyListByUserEntity.dart';
import 'ownedKeyList_state.dart';
@ -9,19 +12,63 @@ class OwnedKeyListLogic extends BaseGetXController {
OwnedKeyListState state = OwnedKeyListState();
//
Future<List<KeyListItem>> mockNetworkDataRequest() async {
KeyListByUserEntity entity = await ApiRepository.to.keyListByUser('1', '20', state.getUidStr);
Future<KeyListByUserEntity> mockNetworkDataRequest() async {
KeyListByUserEntity entity = await ApiRepository.to.keyListByUser(pageNo.toString(), pageSize, state.getUidStr.toString());
// if (entity.errorCode!.codeIsSuccessful) {
// print("请求用户拥有的锁:${entity.data!.keyList}");
// }
// if (entity.data != null) {
// return entity.data!.keyList!;
// } else {
// List<KeyListItem> dataList = [];
// return dataList;
// }
if(entity.errorCode!.codeIsSuccessful){
if (pageNo == 1) {
state.dataList.value = entity.data!.keyList!;
pageNo++;
} else {
if (entity.data!.keyList!.isNotEmpty) {
state.dataList.value.addAll(entity.data!.keyList!);
print("state.itemDataList.value.length:${state.dataList.value.length}");
pageNo++;
}
}
}
return entity;
}
// setAdministrator
Future<void> deleteKeyRequest(int keyId) async {
ElectronicKeyListEntity entity = await ApiRepository.to.deleteElectronicKey(
keyId:keyId.toString(),
includeUnderlings: 0
);
if (entity.errorCode!.codeIsSuccessful) {
print("请求用户拥有的锁:${entity.data!.keyList}");
}
if (entity.data != null) {
return entity.data!.keyList!;
} else {
List<KeyListItem> dataList = [];
return dataList;
print("删除电子钥匙成功");
showToast("删除成功", something: () {
pageNo = 1;
mockNetworkDataRequest();
eventBus.fire(LockUserManageListRefreshUI());
});
}
}
//
Future<void> setAdministrator() async {
// ElectronicKeyListEntity entity = await ApiRepository.to.setAdministrator(
// keyId:state.itemData.value.keyId.toString(),
// );
// if (entity.errorCode!.codeIsSuccessful) {
// showToast("设置成功", something: () {
// // eventBus.fire(ElectronicKeyListRefreshUI());
// // eventBus.fire(AuthorizedAdminPageRefreshUI());
// Get.back();
// });
// }
}
//使
String getUseDateStr(KeyListItem indexEntity) {
String useDateStr = '';

View File

@ -1,15 +1,19 @@
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:flutter_slidable/flutter_slidable.dart';
import 'package:get/get.dart';
import 'package:get/get_utils/get_utils.dart';
import 'package:star_lock/common/XSConstantMacro/XSConstantMacro.dart';
import 'package:star_lock/mine/mineSet/lockUserManage/lockUserManageList/keyListByUserEntity.dart';
import 'package:star_lock/network/api_repository.dart';
import 'package:star_lock/tools/baseGetXController.dart';
import 'package:star_lock/tools/noData.dart';
import 'package:star_lock/tools/showIosTipView.dart';
import 'package:star_lock/translations/trans_lib.dart';
import '../../../../../app_settings/app_colors.dart';
import '../../../../../tools/titleAppBar.dart';
import '../../../../tools/EasyRefreshTool.dart';
import 'ownedKeyList_logic.dart';
class OwnedKeyListPage extends StatefulWidget {
@ -23,9 +27,18 @@ class _OwnedKeyListPageState extends State<OwnedKeyListPage> {
final logic = Get.put(OwnedKeyListLogic());
final state = Get.find<OwnedKeyListLogic>().state;
Future<void> getHttpData() async {
logic.mockNetworkDataRequest().then((KeyListByUserEntity value){
if(mounted) setState(() {});
});
}
@override
void initState() {
super.initState();
getHttpData();
}
@override
@ -37,31 +50,20 @@ class _OwnedKeyListPageState extends State<OwnedKeyListPage> {
haveBack: true,
backgroundColor: AppColors.mainColor,
),
body: FutureBuilder<List<KeyListItem>>(
future: logic.mockNetworkDataRequest(),
builder: (BuildContext context,
AsyncSnapshot<List<KeyListItem>> snapshot) {
//
if (snapshot.connectionState == ConnectionState.done) {
if (snapshot.hasError) {
//
return const Text('请求失败');
} else {
//
final List<KeyListItem> itemList = snapshot.data!;
return Column(
children: [
_topOwnedKeyText(),
Expanded(child: _buildMainUI(itemList)),
],
);
}
} else {
// loading
return Container();
}
}));
body: EasyRefreshTool(
onRefresh: () {
logic.pageNo = 1;
getHttpData();
},
onLoad: () {
getHttpData();
},
child: Column(
children: [
_topOwnedKeyText(),
Obx(() => Expanded(child: _buildMainUI())),
],
)));
}
Widget _topOwnedKeyText() {
@ -80,16 +82,43 @@ class _OwnedKeyListPageState extends State<OwnedKeyListPage> {
);
}
Widget _buildMainUI(List itemList) {
return ListView.builder(
itemCount: itemList.length,
itemBuilder: (c, index) {
KeyListItem itemData = itemList[index];
return _electronicKeyItem(itemData);
});
Widget _buildMainUI() {
return state.dataList.isEmpty
? NoData(noDataHeight: 1.sh - ScreenUtil().statusBarHeight - ScreenUtil().bottomBarHeight - 190.h - 64.h)
: SlidableAutoCloseBehavior(
child: ListView.builder(
itemCount: state.dataList.length,
itemBuilder: (c, index) {
KeyListItem itemData = state.dataList[index];
return Slidable(
key:ValueKey(itemData.keyId),
endActionPane: ActionPane(
extentRatio: 0.2,
motion: const ScrollMotion(),
children: [
SlidableAction(
onPressed: (BuildContext context){
showIosTipViewDialog(itemData);
},
backgroundColor: Colors.red,
foregroundColor: Colors.white,
label: '删除',
padding: EdgeInsets.only(left: 5.w, right: 5.w),
),
],
),
child: _electronicKeyItem(itemData),
);
}),
);
}
Widget _electronicKeyItem(KeyListItem itemData) {
var isHaveExpired = false;
if(itemData.keyStatus == XSConstantMacro.keyStatusExpired){
isHaveExpired = true;
}
return GestureDetector(
onTap: () {},
child: Container(
@ -111,7 +140,28 @@ class _OwnedKeyListPageState extends State<OwnedKeyListPage> {
Row(
mainAxisAlignment: MainAxisAlignment.start,
children: [
Text(itemData.lockAlias ?? '', style: TextStyle(fontSize: 24.sp, color: AppColors.blackColor)),
// Text(itemData.lockAlias ?? '', style: TextStyle(fontSize: 24.sp, color: AppColors.blackColor)),
SizedBox(
width: 1.sw - 110.w - 100.w,
child: Row(
children: [
Flexible(
child: Text(
itemData.lockAlias ?? '',
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: TextStyle(fontSize: 24.sp, color: isHaveExpired ? Colors.grey:AppColors.blackColor)
),
),
],
),
),
Visibility(
visible: isHaveExpired,
child: Text("已过期",
style: TextStyle(fontSize: 22.sp, color: Colors.grey)),
),
SizedBox(width: 10.w),
],
),
SizedBox(height: 5.h),
@ -120,7 +170,7 @@ class _OwnedKeyListPageState extends State<OwnedKeyListPage> {
children: [
Text(
logic.getUseDateStr(itemData),
style: TextStyle(fontSize: 18.sp, color: AppColors.placeholderTextColor),
style: TextStyle(fontSize: 18.sp, color: isHaveExpired ? Colors.grey:AppColors.placeholderTextColor),
),
],
),
@ -134,4 +184,24 @@ class _OwnedKeyListPageState extends State<OwnedKeyListPage> {
),
);
}
void showIosTipViewDialog(KeyListItem lockUserData) {
showDialog(
context: Get.context!,
builder: (BuildContext context) {
return ShowIosTipView(
title: "提示",
tipTitle: "删除钥匙会在用户APP连网后生效",
sureClick: () {
Get.back();
logic.deleteKeyRequest(lockUserData.keyId!);
},
cancelClick: () {
Get.back();
},
);
}
);
}
}

View File

@ -1,11 +1,11 @@
import 'package:get/get.dart';
import '../lockUserManageList/keyListByUserEntity.dart';
class OwnedKeyListState{
var getUidStr = '';
var dataList = [].obs;
var getUidStr = 0;
var dataList = <KeyListItem>[].obs;
OwnedKeyListState(){
Map map = Get.arguments;

View File

@ -2,7 +2,7 @@ import 'dart:async';
import 'package:get/get.dart';
import 'package:star_lock/appRouters.dart';
import 'package:star_lock/login/login/entity/LoginEntity.dart';
import 'package:star_lock/mine/mineSet/lockUserManage/expireLockList/expireLockList_entity.dart';
import 'package:star_lock/mine/mineSet/lockUserManage/expireLockList/expireElectronicKey/expireLockList_entity.dart';
import 'package:star_lock/mine/mineSet/mineSet/mineSet_state.dart';
import 'package:star_lock/tools/storage.dart';
import '../../../../network/api_repository.dart';

View File

@ -27,7 +27,7 @@ class RecipientInformationEntity {
}
class RecipientInformationData {
String? uid;
int? uid;
String? nickname;
String? headUrl;
String? userid;

View File

@ -292,7 +292,7 @@ class _RecipientInformationPageState extends State<RecipientInformationPage> {
return Center(
child: Container(
width: 400.w,
height: 370.h,
height: 400.h,
color: Colors.white,
child: Column(
children: [

View File

@ -66,7 +66,7 @@ class _TransferSmartLockPageState extends State<TransferSmartLockPage> {
onRefresh: (){
getHttpData();
},
child: Column(
child: Obx(() => state.transferSmartLockListData.value.isNotEmpty ? Column(
children: [
// KeySearchWidget(
// editingController: state.searchController,
@ -80,13 +80,13 @@ class _TransferSmartLockPageState extends State<TransferSmartLockPage> {
_buildNextBtn(),
SizedBox(height: 64.h)
],
),
): NoData()),
),
);
}
Widget _buildMainUI() {
return Obx(() => state.transferSmartLockListData.value.isNotEmpty ? ListView.separated(
return ListView.separated(
itemCount: state.transferSmartLockListData.value.length,
separatorBuilder: (context, index) {
return Divider(
@ -107,7 +107,7 @@ class _TransferSmartLockPageState extends State<TransferSmartLockPage> {
}
});
});
}): NoData());
});
}
Widget _electronicKeyItem(TransferSmartLockItemData transferSmartLockItemData, Function() action) {

View File

@ -147,6 +147,10 @@ abstract class Api {
final String updateAdministratorURL =
'/authorizedAdmin/update'; ////
final String expireLockListURL = '/keyUser/listExpireUser'; //
final String expirePasswordListURL = '/keyUser/listExpirePwd'; //
final String expireCardListURL = '/keyUser/listExpireCard'; //
final String expireFingerprintListURL = '/keyUser/listExpireFingerprint'; //
final String expireFaceListURL = '//keyUser/listExpireFace'; //
final String userSettingsInfoURL = '/user/userSettingsInfo'; //
final String setAlertModeURL = '/user/setAlertMode'; //
final String setTouchUnlockFlagURL = '/user/setTouchUnlockFlag'; //

View File

@ -586,6 +586,34 @@ class ApiProvider extends BaseProvider {
'pageSize': pageSize,
}));
Future<Response> expirePasswordList(String pageNo, String pageSize) => post(
expirePasswordListURL.toUrl,
jsonEncode({
'pageNo': pageNo,
'pageSize': pageSize,
}));
Future<Response> expireCardList(String pageNo, String pageSize) => post(
expireCardListURL.toUrl,
jsonEncode({
'pageNo': pageNo,
'pageSize': pageSize,
}));
Future<Response> expireFingerprintList(String pageNo, String pageSize) => post(
expireFingerprintListURL.toUrl,
jsonEncode({
'pageNo': pageNo,
'pageSize': pageSize,
}));
Future<Response> expireFaceList(String pageNo, String pageSize) => post(
expireFaceListURL.toUrl,
jsonEncode({
'pageNo': pageNo,
'pageSize': pageSize,
}));
Future<Response> deleteKeyboardPwd(
String lockId, String keyboardPwdId, int deleteType) =>
post(

View File

@ -17,7 +17,8 @@ import 'package:star_lock/mine/minePersonInfo/minePersonInfoViewSafetyProblem/mi
import 'package:star_lock/mine/mineSet/appUnlockNeedMobileNetworkingLock/selectLockListEntity.dart';
import 'package:star_lock/mine/mineSet/authorizedAdministrator/administratorDetails/administratorDetailEntity.dart';
import 'package:star_lock/mine/mineSet/authorizedAdministrator/authorizedAdministrator/authorizedAdminListEntity.dart';
import 'package:star_lock/mine/mineSet/lockUserManage/expireLockList/expireLockList_entity.dart';
import 'package:star_lock/mine/mineSet/lockUserManage/expireLockList/expireElectronicKey/expireLockList_entity.dart';
import 'package:star_lock/mine/mineSet/lockUserManage/expireLockList/expireFingerprint/expireFingerprint_entity.dart';
import 'package:star_lock/mine/mineSet/lockUserManage/lockUserManageList/keyListByUserEntity.dart';
import 'package:star_lock/mine/mineSet/mineSet/userSettingInfoEntity.dart';
import '../common/safetyVerification/entity/CheckSafetyVerificationEntity.dart';
@ -45,6 +46,8 @@ import '../main/lockMian/entity/lockListInfo_entity.dart';
import '../mine/addLock/saveLock/entity/SaveLockEntity.dart';
import '../mine/message/messageList/messageList_entity.dart';
import '../mine/minePersonInfo/minePersonInfoPage/minePersonGetUploadFileInfo_entity.dart';
import '../mine/mineSet/lockUserManage/expireLockList/expireCard/expireCard_entity.dart';
import '../mine/mineSet/lockUserManage/expireLockList/expirePassword/expirePassword_entity.dart';
import '../mine/mineSet/transferGateway/selectGetewayList_entity.dart';
import '../mine/mineSet/transferSmartLock/recipientInformation/recipientInformation_entity.dart';
import '../mine/mineSet/transferSmartLock/transferSmartLockList/transferSmartLock_entity.dart';
@ -586,13 +589,32 @@ class ApiRepository {
return ElectronicKeyListEntity.fromJson(res.body);
}
//
//
Future<ExpireLockListEntity> expireLockList(
String pageNo, String pageSize) async {
final res = await apiProvider.expireLockList(pageNo, pageSize);
return ExpireLockListEntity.fromJson(res.body);
}
//
Future<ExpirePasswordEntity> expirePasswordList(
String pageNo, String pageSize) async {
final res = await apiProvider.expirePasswordList(pageNo, pageSize);
return ExpirePasswordEntity.fromJson(res.body);
}
//
Future<ExpireCardEntity> expireCardList(String pageNo, String pageSize) async {
final res = await apiProvider.expireCardList(pageNo, pageSize);
return ExpireCardEntity.fromJson(res.body);
}
//
Future<ExpireFingerprintEntity> expireFingerprintList(String pageNo, String pageSize) async {
final res = await apiProvider.expireFingerprintList(pageNo, pageSize);
return ExpireFingerprintEntity.fromJson(res.body);
}
//
Future<PasswordKeyEntity> deleteKeyboardPwd(
String lockId, String keyboardPwdId, int deleteType) async {

View File

@ -110,3 +110,8 @@ class DoorLockLogListRefreshUI {
DateTime getDoorLockLogTime;
DoorLockLogListRefreshUI(this.getDoorLockLogTime);
}
///
class LockUserManageListRefreshUI {
LockUserManageListRefreshUI();
}

View File

@ -93,4 +93,30 @@ class ShowTipView {
);
}
void showIosTipWithContentDialog(String contentStr, Function sureClick) {
showCupertinoDialog(
context: Get.context!,
builder: (context) {
return CupertinoAlertDialog(
content: Text(contentStr),
actions: [
CupertinoDialogAction(
child: Text(TranslationLoader.lanKeys!.cancel!.tr),
onPressed: () {
Get.back();
},
),
CupertinoDialogAction(
child: Text(TranslationLoader.lanKeys!.sure!.tr),
onPressed: () {
Get.back();
sureClick();
},
),
],
);
},
);
}
}

View File

@ -23,9 +23,9 @@ class StoreService<T> extends GetxService {
final String _deviceUUID = 'DEVICE_ID';
final String _languageCode = 'LANGUAGE_CODE';
Object? getDeviceId() => hasData(_deviceUUID) ? read(_deviceUUID): "";
String? getDeviceId() => hasData(_deviceUUID) ? read(_deviceUUID).toString(): "";
Future saveDeviceId(String uuid) => save(_deviceUUID, uuid);
Object? getLanguageCode() => hasData(_languageCode) ? read(_languageCode): "";
String? getLanguageCode() => hasData(_languageCode) ? read(_languageCode).toString(): "";
Future saveLanguageCode(String code) => save(_languageCode, code);
}