密码详情及电子钥匙详情问题及梳理修改
This commit is contained in:
parent
cacf3528e3
commit
f0a90edb6e
@ -0,0 +1,34 @@
|
||||
import 'package:get/get.dart';
|
||||
import 'package:star_lock/main/lockDetail/electronicKey/electronicKeyDetail/electronicKeyDetail/electronicKeyDetail_state.dart';
|
||||
import 'package:star_lock/main/lockDetail/electronicKey/electronicKeyDetail/keyOperationRecordEntity.dart';
|
||||
import 'package:star_lock/main/lockDetail/electronicKey/electronicKeyList/entity/ElectronicKeyListEntity.dart';
|
||||
import 'package:star_lock/network/api_repository.dart';
|
||||
import 'package:star_lock/tools/baseGetXController.dart';
|
||||
import 'package:star_lock/tools/toast.dart';
|
||||
|
||||
class ElectronicKeyDetailLogic extends BaseGetXController {
|
||||
final ElectronicKeyDetailState state = ElectronicKeyDetailState();
|
||||
|
||||
//修改钥匙名称请求
|
||||
Future<void> modifyKeyNameRequest() async {
|
||||
KeyOperationRecordEntity entity = await ApiRepository.to
|
||||
.modifyKeyNameForAdmin(state.itemData.value.keyId.toString(),
|
||||
state.changeNameController.text, '');
|
||||
if (entity.errorCode!.codeIsSuccessful) {
|
||||
print("修改要是名称成功啦啦啦啦啦");
|
||||
Toast.show(msg: "修改成功");
|
||||
Get.back();
|
||||
}
|
||||
}
|
||||
|
||||
//删除电子钥匙名称请求
|
||||
Future<void> deleteKeyRequest() async {
|
||||
ElectronicKeyListEntity entity = await ApiRepository.to
|
||||
.deleteElectronicKey(state.itemData.value.keyId.toString());
|
||||
if (entity.errorCode!.codeIsSuccessful) {
|
||||
print("删除电子钥匙成功");
|
||||
Toast.show(msg: "删除成功");
|
||||
Get.back();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -3,12 +3,9 @@ import 'package:flutter/material.dart';
|
||||
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:star_lock/common/XSConstantMacro/XSConstantMacro.dart';
|
||||
import 'package:star_lock/main/lockDetail/electronicKey/electronicKeyDetail/keyOperationRecordEntity.dart';
|
||||
import 'package:star_lock/main/lockDetail/electronicKey/electronicKeyDetail/electronicKeyDetail/electronicKeyDetail_logic.dart';
|
||||
import 'package:star_lock/main/lockDetail/electronicKey/electronicKeyList/entity/ElectronicKeyListEntity.dart';
|
||||
import 'package:star_lock/network/api_repository.dart';
|
||||
import 'package:star_lock/tools/baseGetXController.dart';
|
||||
import 'package:star_lock/tools/jh_pop_menus.dart';
|
||||
import 'package:star_lock/tools/toast.dart';
|
||||
|
||||
import '../../../../../appRouters.dart';
|
||||
import '../../../../../app_settings/app_colors.dart';
|
||||
@ -28,16 +25,11 @@ class ElectronicKeyDetailPage extends StatefulWidget {
|
||||
}
|
||||
|
||||
class _ElectronicKeyDetailPageState extends State<ElectronicKeyDetailPage> {
|
||||
final TextEditingController _changeNameController = TextEditingController();
|
||||
ElectronicKeyListItem itemData = ElectronicKeyListItem();
|
||||
final logic = Get.put(ElectronicKeyDetailLogic());
|
||||
final state = Get.find<ElectronicKeyDetailLogic>().state;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
dynamic obj = ModalRoute.of(context)?.settings.arguments;
|
||||
if (obj != null && (obj["itemData"] != null)) {
|
||||
itemData = obj["itemData"];
|
||||
}
|
||||
|
||||
return Scaffold(
|
||||
resizeToAvoidBottomInset: false,
|
||||
backgroundColor: AppColors.mainBackgroundColor,
|
||||
@ -68,38 +60,29 @@ class _ElectronicKeyDetailPageState extends State<ElectronicKeyDetailPage> {
|
||||
children: [
|
||||
CommonItem(
|
||||
leftTitel: TranslationLoader.lanKeys!.name!.tr,
|
||||
rightTitle: _changeNameController.text.isNotEmpty
|
||||
? _changeNameController.text
|
||||
: itemData.keyName,
|
||||
rightTitle: state.changeNameController.text.isNotEmpty
|
||||
? state.changeNameController.text
|
||||
: state.itemData.value.keyName,
|
||||
isHaveDirection: true,
|
||||
isHaveLine: true,
|
||||
action: () {
|
||||
showCupertinoAlertDialog(context);
|
||||
}),
|
||||
CommonItem(
|
||||
leftTitel: TranslationLoader.lanKeys!.effectiveTime!.tr,
|
||||
allHeight: 90.h,
|
||||
rightTitle: getUseDateStr(itemData),
|
||||
isHaveDirection: true,
|
||||
action: () {
|
||||
Navigator.pushNamed(
|
||||
context, Routers.electronicKeyDetailChangeDate,
|
||||
arguments: {"itemData": itemData});
|
||||
}),
|
||||
getPeriodValidityWidget(),
|
||||
Container(height: 10.h),
|
||||
CommonItem(
|
||||
leftTitel: TranslationLoader.lanKeys!.receiver!.tr,
|
||||
rightTitle: itemData.username,
|
||||
rightTitle: state.itemData.value.username,
|
||||
action: () {}),
|
||||
const SizedBox(height: 1),
|
||||
CommonItem(
|
||||
leftTitel: TranslationLoader.lanKeys!.sender!.tr,
|
||||
rightTitle: itemData.senderUsername,
|
||||
rightTitle: state.itemData.value.senderUsername,
|
||||
action: () {}),
|
||||
const SizedBox(height: 1),
|
||||
CommonItem(
|
||||
leftTitel: TranslationLoader.lanKeys!.senderTime!.tr,
|
||||
rightTitle: getSenderDate(itemData),
|
||||
rightTitle: getSenderDate(state.itemData.value),
|
||||
action: () {}),
|
||||
Container(height: 10.h),
|
||||
CommonItem(
|
||||
@ -108,8 +91,9 @@ class _ElectronicKeyDetailPageState extends State<ElectronicKeyDetailPage> {
|
||||
isHaveRightWidget: true,
|
||||
rightWidget: SizedBox(
|
||||
width: 60.w,
|
||||
child:
|
||||
_switch(itemData.faceAuthentication == 1 ? true : false)),
|
||||
child: _switch(state.itemData.value.faceAuthentication == 1
|
||||
? true
|
||||
: false)),
|
||||
action: () {}),
|
||||
Container(height: 10.h),
|
||||
CommonItem(
|
||||
@ -119,8 +103,8 @@ class _ElectronicKeyDetailPageState extends State<ElectronicKeyDetailPage> {
|
||||
action: () {
|
||||
Navigator.pushNamed(context, Routers.keyOperationRecordPage,
|
||||
arguments: {
|
||||
'lockId': itemData.lockId.toString(),
|
||||
'keyId': itemData.keyId.toString()
|
||||
'lockId': state.itemData.value.lockId.toString(),
|
||||
'keyId': state.itemData.value.keyId.toString()
|
||||
});
|
||||
}),
|
||||
Container(height: 40.h),
|
||||
@ -139,106 +123,136 @@ class _ElectronicKeyDetailPageState extends State<ElectronicKeyDetailPage> {
|
||||
);
|
||||
}
|
||||
|
||||
//使用期限
|
||||
String getUseDateStr(ElectronicKeyListItem indexEntity) {
|
||||
String useDateStr = '';
|
||||
if (indexEntity.keyType == XSConstantMacro.keyTypeTime) {
|
||||
//限期
|
||||
DateTime startDateStr =
|
||||
DateTime.fromMillisecondsSinceEpoch(indexEntity.startDate!);
|
||||
DateTime endDateStr =
|
||||
DateTime.fromMillisecondsSinceEpoch(indexEntity.endDate!);
|
||||
useDateStr =
|
||||
'${startDateStr.toLocal().toString().substring(0, 16)}\n${endDateStr.toLocal().toString().substring(0, 16)}';
|
||||
} else if (indexEntity.keyType == XSConstantMacro.keyTypeLong) {
|
||||
//永久
|
||||
// DateTime dateStr = DateTime.fromMillisecondsSinceEpoch(indexEntity.date!);
|
||||
// useDateStr = '${dateStr.toLocal().toString().substring(0, 16)}\n 永久';
|
||||
useDateStr = '永久';
|
||||
} else if (indexEntity.keyType == XSConstantMacro.keyTypeOnce) {
|
||||
//单次
|
||||
// DateTime dateStr = DateTime.fromMillisecondsSinceEpoch(indexEntity.date!);
|
||||
// useDateStr = '${dateStr.toLocal().toString().substring(0, 16)}\n 单次';
|
||||
useDateStr = '单次';
|
||||
} else if (indexEntity.keyType == XSConstantMacro.keyTypeLoop) {
|
||||
//循环
|
||||
useDateStr = '循环';
|
||||
//根据类型获取限时有效期样式
|
||||
Widget getPeriodValidityWidget() {
|
||||
int? dateType = state.itemData.value.keyType;
|
||||
if (dateType == XSConstantMacro.keyTypeLong) {
|
||||
return getLongTypeDateWidget();
|
||||
} else if (dateType == XSConstantMacro.keyTypeTime) {
|
||||
return getTimeLimitTypeDateWidget();
|
||||
} else if (dateType == XSConstantMacro.keyTypeOnce) {
|
||||
return getOnceTypeDateWidget();
|
||||
} else if (dateType == XSConstantMacro.keyTypeLoop) {
|
||||
return getLoopTypeDateWidget();
|
||||
}
|
||||
|
||||
return useDateStr;
|
||||
return Container();
|
||||
}
|
||||
|
||||
//永久钥匙
|
||||
Widget getLongTypeDateWidget() {
|
||||
return CommonItem(
|
||||
leftTitel: TranslationLoader.lanKeys!.periodValidity!.tr,
|
||||
rightTitle: '永久',
|
||||
isHaveDirection: true,
|
||||
action: () {
|
||||
Navigator.pushNamed(context, Routers.electronicKeyDetailChangeDate,
|
||||
arguments: {"itemData": state.itemData.value});
|
||||
});
|
||||
}
|
||||
|
||||
//限时钥匙
|
||||
Widget getTimeLimitTypeDateWidget() {
|
||||
DateTime startDateStr =
|
||||
DateTime.fromMillisecondsSinceEpoch(state.itemData.value.startDate!);
|
||||
DateTime endDateStr =
|
||||
DateTime.fromMillisecondsSinceEpoch(state.itemData.value.endDate!);
|
||||
String useDateStr =
|
||||
'${startDateStr.toLocal().toString().substring(0, 16)}\n${endDateStr.toLocal().toString().substring(0, 16)}';
|
||||
|
||||
return CommonItem(
|
||||
leftTitel: TranslationLoader.lanKeys!.periodValidity!.tr,
|
||||
allHeight: 90.h,
|
||||
rightTitle: useDateStr,
|
||||
isHaveDirection: true,
|
||||
action: () {
|
||||
Navigator.pushNamed(context, Routers.electronicKeyDetailChangeDate,
|
||||
arguments: {"itemData": state.itemData.value});
|
||||
});
|
||||
}
|
||||
|
||||
//单次钥匙
|
||||
Widget getOnceTypeDateWidget() {
|
||||
return CommonItem(
|
||||
leftTitel: TranslationLoader.lanKeys!.periodValidity!.tr,
|
||||
rightTitle: '单次',
|
||||
isHaveDirection: false,
|
||||
);
|
||||
}
|
||||
|
||||
//循环钥匙
|
||||
Widget getLoopTypeDateWidget() {
|
||||
DateTime startDateStr =
|
||||
DateTime.fromMillisecondsSinceEpoch(state.itemData.value.startDate!);
|
||||
DateTime endDateStr =
|
||||
DateTime.fromMillisecondsSinceEpoch(state.itemData.value.endDate!);
|
||||
String useDateStr =
|
||||
'${startDateStr.toLocal().toString().substring(0, 16)} \n ${endDateStr.toLocal().toString().substring(0, 16)}';
|
||||
|
||||
List getEffectiveDateList = [];
|
||||
List weekDaysList = state.itemData.value.weekDays!;
|
||||
if (weekDaysList.isNotEmpty) {
|
||||
String effectiveDateStr = '';
|
||||
for (int i = 0; i < weekDaysList.length; i++) {
|
||||
if (weekDaysList[i] == 1) {
|
||||
effectiveDateStr = '一';
|
||||
getEffectiveDateList.add(effectiveDateStr);
|
||||
} else if (weekDaysList[i] == 2) {
|
||||
effectiveDateStr = '二';
|
||||
getEffectiveDateList.add(effectiveDateStr);
|
||||
} else if (weekDaysList[i] == 3) {
|
||||
effectiveDateStr = '三';
|
||||
getEffectiveDateList.add(effectiveDateStr);
|
||||
} else if (weekDaysList[i] == 4) {
|
||||
effectiveDateStr = '四';
|
||||
getEffectiveDateList.add(effectiveDateStr);
|
||||
} else if (weekDaysList[i] == 5) {
|
||||
effectiveDateStr = '五';
|
||||
getEffectiveDateList.add(effectiveDateStr);
|
||||
} else if (weekDaysList[i] == 6) {
|
||||
effectiveDateStr = '六';
|
||||
getEffectiveDateList.add(effectiveDateStr);
|
||||
} else if (weekDaysList[i] == 7) {
|
||||
effectiveDateStr = '日';
|
||||
getEffectiveDateList.add(effectiveDateStr);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return Column(
|
||||
children: [
|
||||
CommonItem(
|
||||
leftTitel: TranslationLoader.lanKeys!.effectiveTime!.tr,
|
||||
allHeight: 90.h,
|
||||
rightTitle: useDateStr,
|
||||
isHaveDirection: true,
|
||||
isHaveLine: true,
|
||||
action: () {
|
||||
Navigator.pushNamed(
|
||||
context, Routers.electronicKeyPeriodValidityPage);
|
||||
}),
|
||||
CommonItem(
|
||||
leftTitel: '有效日',
|
||||
rightTitle: getEffectiveDateList.map((e) => e.toString()).join(','),
|
||||
isHaveDirection: true,
|
||||
isHaveLine: true,
|
||||
action: () {
|
||||
Navigator.pushNamed(
|
||||
context, Routers.electronicKeyPeriodValidityPage);
|
||||
}),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
//发送时间
|
||||
String getSenderDate(ElectronicKeyListItem indexEntity) {
|
||||
String senderDate = '';
|
||||
DateTime dateStr = DateTime.fromMillisecondsSinceEpoch(indexEntity.sendDate!);
|
||||
DateTime dateStr =
|
||||
DateTime.fromMillisecondsSinceEpoch(indexEntity.sendDate!);
|
||||
senderDate = dateStr.toLocal().toString().substring(0, 16);
|
||||
return senderDate;
|
||||
}
|
||||
|
||||
// Widget commonItem(String leftTitle, String rightTitle,
|
||||
// {bool isHaveDirection = false,
|
||||
// bool isHaveLine = false,
|
||||
// bool isHaveRightWidget = false,
|
||||
// Widget? rightWidget,
|
||||
// Function()? action}) {
|
||||
// return GestureDetector(
|
||||
// onTap: action,
|
||||
// child: Column(
|
||||
// // mainAxisAlignment: MainAxisAlignment.center,
|
||||
// children: [
|
||||
// Container(
|
||||
// // height: 80.h,
|
||||
// color: Colors.white,
|
||||
// padding: EdgeInsets.only(
|
||||
// left: 20.w, right: 10.w, top: 20.w, bottom: 20.w),
|
||||
// child: Row(
|
||||
// children: [
|
||||
// SizedBox(width: 20.w),
|
||||
// Text(
|
||||
// leftTitle,
|
||||
// style:
|
||||
// TextStyle(fontSize: 28.sp, fontWeight: FontWeight.w500),
|
||||
// ),
|
||||
// SizedBox(width: 20.w),
|
||||
// Expanded(
|
||||
// child: Row(
|
||||
// mainAxisAlignment: MainAxisAlignment.end,
|
||||
// children: [
|
||||
// isHaveRightWidget
|
||||
// ? rightWidget!
|
||||
// : Text(
|
||||
// rightTitle,
|
||||
// textAlign: TextAlign.end,
|
||||
// style: TextStyle(
|
||||
// fontSize: 28.sp, fontWeight: FontWeight.w500),
|
||||
// )
|
||||
// ],
|
||||
// ),
|
||||
// ),
|
||||
// SizedBox(width: 5.w),
|
||||
// isHaveDirection
|
||||
// ? Image.asset(
|
||||
// 'images/icon_right.png',
|
||||
// width: 50.w,
|
||||
// height: 50.w,
|
||||
// )
|
||||
// : SizedBox(width: 10.w),
|
||||
// // SizedBox(width:10.w),
|
||||
// ],
|
||||
// ),
|
||||
// ),
|
||||
// isHaveLine
|
||||
// ? Container(
|
||||
// height: 0.5.h,
|
||||
// color: Colors.grey,
|
||||
// )
|
||||
// : Container()
|
||||
// ],
|
||||
// ),
|
||||
// );
|
||||
// }
|
||||
|
||||
CupertinoSwitch _switch(isOn) {
|
||||
return CupertinoSwitch(
|
||||
activeColor: CupertinoColors.activeBlue,
|
||||
@ -253,33 +267,6 @@ class _ElectronicKeyDetailPageState extends State<ElectronicKeyDetailPage> {
|
||||
);
|
||||
}
|
||||
|
||||
//修改钥匙名称请求
|
||||
Future<void> modifyKeyNameRequest() async {
|
||||
KeyOperationRecordEntity entity = await ApiRepository.to
|
||||
.modifyKeyNameForAdmin(
|
||||
itemData.keyId.toString(), _changeNameController.text, '');
|
||||
if (entity.errorCode!.codeIsSuccessful) {
|
||||
print("修改要是名称成功啦啦啦啦啦");
|
||||
Toast.show(msg: "修改成功");
|
||||
setState(() {
|
||||
Navigator.pop(context);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
//删除电子钥匙名称请求
|
||||
Future<void> deleteKeyRequest() async {
|
||||
ElectronicKeyListEntity entity =
|
||||
await ApiRepository.to.deleteElectronicKey(itemData.keyId.toString());
|
||||
if (entity.errorCode!.codeIsSuccessful) {
|
||||
print("删除电子钥匙成功");
|
||||
Toast.show(msg: "删除成功");
|
||||
setState(() {
|
||||
Navigator.pop(context, true);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
void showCupertinoAlertDialog(BuildContext context) {
|
||||
showDialog(
|
||||
context: context,
|
||||
@ -288,11 +275,11 @@ class _ElectronicKeyDetailPageState extends State<ElectronicKeyDetailPage> {
|
||||
title:
|
||||
"${TranslationLoader.lanKeys!.amend!.tr} ${TranslationLoader.lanKeys!.name!.tr}",
|
||||
tipTitle: "请输入",
|
||||
controller: _changeNameController,
|
||||
controller: state.changeNameController,
|
||||
sureClick: () {
|
||||
//发送编辑钥匙名称请求
|
||||
if (_changeNameController.text.isNotEmpty) {
|
||||
modifyKeyNameRequest();
|
||||
if (state.changeNameController.text.isNotEmpty) {
|
||||
logic.modifyKeyNameRequest();
|
||||
}
|
||||
},
|
||||
cancelClick: () {
|
||||
@ -304,7 +291,7 @@ class _ElectronicKeyDetailPageState extends State<ElectronicKeyDetailPage> {
|
||||
}
|
||||
|
||||
void showIosTipViewDialog(BuildContext context) {
|
||||
showDialog(
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (BuildContext context) {
|
||||
return ShowIosTipView(
|
||||
@ -312,14 +299,12 @@ class _ElectronicKeyDetailPageState extends State<ElectronicKeyDetailPage> {
|
||||
tipTitle: "确定要删除吗?",
|
||||
sureClick: () {
|
||||
Get.back();
|
||||
deleteKeyRequest();
|
||||
logic.deleteKeyRequest();
|
||||
},
|
||||
cancelClick: () {
|
||||
Get.back();
|
||||
},
|
||||
);
|
||||
}
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -0,0 +1,13 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:star_lock/main/lockDetail/electronicKey/electronicKeyList/entity/ElectronicKeyListEntity.dart';
|
||||
|
||||
class ElectronicKeyDetailState {
|
||||
final itemData = ElectronicKeyListItem().obs;
|
||||
final TextEditingController changeNameController = TextEditingController();
|
||||
|
||||
ElectronicKeyDetailState() {
|
||||
Map map = Get.arguments;
|
||||
itemData.value = map["itemData"];
|
||||
}
|
||||
}
|
||||
@ -270,6 +270,8 @@ class _ElectronicKeyListPageState extends State<ElectronicKeyListPage> {
|
||||
//使用期限
|
||||
String getUseDateStr(ElectronicKeyListItem indexEntity) {
|
||||
String useDateStr = '';
|
||||
DateTime sendDateStr =
|
||||
DateTime.fromMillisecondsSinceEpoch(indexEntity.sendDate!);
|
||||
if (indexEntity.keyType == XSConstantMacro.keyTypeTime) {
|
||||
//限期
|
||||
DateTime startDateStr =
|
||||
@ -280,14 +282,11 @@ class _ElectronicKeyListPageState extends State<ElectronicKeyListPage> {
|
||||
'${startDateStr.toLocal().toString().substring(0, 16)}-${endDateStr.toLocal().toString().substring(0, 16)}';
|
||||
} else if (indexEntity.keyType == XSConstantMacro.keyTypeLong) {
|
||||
//永久
|
||||
// DateTime dateStr = DateTime.fromMillisecondsSinceEpoch(indexEntity.date!);
|
||||
// useDateStr = '${dateStr.toLocal().toString().substring(0, 16)} 永久';
|
||||
useDateStr = "永久";
|
||||
useDateStr = '${sendDateStr.toLocal().toString().substring(0, 16)} 永久';
|
||||
} else if (indexEntity.keyType == XSConstantMacro.keyTypeOnce) {
|
||||
//单次
|
||||
// DateTime dateStr = DateTime.fromMillisecondsSinceEpoch(indexEntity.date!);
|
||||
// useDateStr = '${dateStr.toLocal().toString().substring(0, 16)} 单次';
|
||||
useDateStr = "单次";
|
||||
useDateStr = '${sendDateStr.toLocal().toString().substring(0, 16)} 单次';
|
||||
} else if (indexEntity.keyType == XSConstantMacro.keyTypeLoop) {
|
||||
//循环
|
||||
useDateStr = '循环';
|
||||
|
||||
@ -0,0 +1,38 @@
|
||||
import 'package:get/get.dart';
|
||||
import 'package:star_lock/main/lockDetail/passwordKey/passwordKeyDetail/passwordKeyDetail_state.dart';
|
||||
import 'package:star_lock/main/lockDetail/passwordKey/passwordKey_perpetual/passwordKeyEntity.dart';
|
||||
import 'package:star_lock/network/api_repository.dart';
|
||||
import 'package:star_lock/tools/baseGetXController.dart';
|
||||
import 'package:star_lock/tools/toast.dart';
|
||||
|
||||
class PasswordKeyDetailLogic extends BaseGetXController {
|
||||
final PasswordKeyDetailState state = PasswordKeyDetailState();
|
||||
|
||||
//删除密码请求 deleteType:1-蓝牙 2-网关
|
||||
Future<void> deletePwdRequest() async {
|
||||
PasswordKeyEntity entity = await ApiRepository.to.deleteKeyboardPwd(
|
||||
state.itemData.value.lockId.toString(),
|
||||
state.itemData.value.keyboardPwdId.toString(),
|
||||
1);
|
||||
if (entity.errorCode!.codeIsSuccessful) {
|
||||
Toast.show(msg: "删除成功");
|
||||
Get.back();
|
||||
}
|
||||
}
|
||||
|
||||
//更新密码请求
|
||||
Future<void> updatePwdRequest() async {
|
||||
PasswordKeyEntity entity = await ApiRepository.to.updatePasswordKey(
|
||||
state.itemData.value.lockId.toString(),
|
||||
state.itemData.value.keyboardPwdId.toString(),
|
||||
state.inputNameController.text,
|
||||
state.inputPwdController.text,
|
||||
'',
|
||||
'',
|
||||
'');
|
||||
if (entity.errorCode!.codeIsSuccessful) {
|
||||
Toast.show(msg: "修改成功");
|
||||
Get.back();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -2,12 +2,9 @@ import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:star_lock/main/lockDetail/passwordKey/passwordKeyDetail/passwordKeyDetail_logic.dart';
|
||||
import 'package:star_lock/main/lockDetail/passwordKey/passwordKeyList/passwordKeyListEntity.dart';
|
||||
import 'package:star_lock/main/lockDetail/passwordKey/passwordKey_perpetual/passwordKeyEntity.dart';
|
||||
import 'package:star_lock/network/api_repository.dart';
|
||||
import 'package:star_lock/tools/baseGetXController.dart';
|
||||
import 'package:star_lock/tools/showTFView.dart';
|
||||
import 'package:star_lock/tools/toast.dart';
|
||||
|
||||
import '../../../../appRouters.dart';
|
||||
import '../../../../app_settings/app_colors.dart';
|
||||
@ -25,25 +22,12 @@ class PasswordKeyDetailPage extends StatefulWidget {
|
||||
}
|
||||
|
||||
class _PasswordKeyDetailPageState extends State<PasswordKeyDetailPage> {
|
||||
PasswordKeyListItem itemData = PasswordKeyListItem();
|
||||
late TextEditingController _inputPwdController;
|
||||
late TextEditingController _inputNameController;
|
||||
static const methodChannel = MethodChannel('talkPlugin');
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
|
||||
_inputPwdController = TextEditingController();
|
||||
_inputNameController = TextEditingController();
|
||||
}
|
||||
final logic = Get.put(PasswordKeyDetailLogic());
|
||||
final state = Get.find<PasswordKeyDetailLogic>().state;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
dynamic obj = ModalRoute.of(context)?.settings.arguments;
|
||||
if (obj != null && (obj["itemData"] != null)) {
|
||||
itemData = obj["itemData"];
|
||||
}
|
||||
return Scaffold(
|
||||
backgroundColor: AppColors.mainBackgroundColor,
|
||||
appBar: TitleAppBar(
|
||||
@ -68,45 +52,52 @@ class _PasswordKeyDetailPageState extends State<PasswordKeyDetailPage> {
|
||||
children: [
|
||||
CommonItem(
|
||||
leftTitel: TranslationLoader.lanKeys!.password!.tr,
|
||||
rightTitle: _inputPwdController.text.isNotEmpty
|
||||
? _inputPwdController.text
|
||||
: itemData.keyboardPwd,
|
||||
rightTitle: state.inputPwdController.text.isNotEmpty
|
||||
? state.inputPwdController.text
|
||||
: state.itemData.value.keyboardPwd,
|
||||
isHaveDirection: true,
|
||||
isHaveLine: true,
|
||||
action: () {
|
||||
showCupertinoAlertDialog(context, _inputPwdController);
|
||||
showCupertinoAlertDialog(context, state.inputPwdController);
|
||||
}),
|
||||
CommonItem(
|
||||
leftTitel: TranslationLoader.lanKeys!.name!.tr,
|
||||
rightTitle: _inputNameController.text.isNotEmpty
|
||||
? _inputNameController.text
|
||||
: itemData.keyboardPwdName,
|
||||
rightTitle: state.inputNameController.text.isNotEmpty
|
||||
? state.inputNameController.text
|
||||
: state.itemData.value.keyboardPwdName,
|
||||
isHaveDirection: true,
|
||||
isHaveLine: true,
|
||||
action: () {
|
||||
showCupertinoAlertDialog(context, _inputNameController);
|
||||
showCupertinoAlertDialog(
|
||||
context, state.inputNameController);
|
||||
}),
|
||||
CommonItem(
|
||||
leftTitel: TranslationLoader.lanKeys!.effectiveTime!.tr,
|
||||
rightTitle: "永久",
|
||||
rightTitle: getUseDateStr(),
|
||||
isHaveDirection: true,
|
||||
allHeight:
|
||||
state.itemData.value.keyboardPwdType == 3 ? 90.h : 65.h,
|
||||
action: () {
|
||||
if (state.itemData.value.keyboardPwdType! > 4 &&
|
||||
state.itemData.value.keyboardPwdType! < 15) {
|
||||
return;
|
||||
}
|
||||
Navigator.pushNamed(
|
||||
context, Routers.electronicKeyDetailChangeDate,
|
||||
arguments: {
|
||||
'lockId': itemData.lockId.toString(),
|
||||
'pwdId': itemData.keyboardPwdId.toString()
|
||||
'lockId': state.itemData.value.lockId.toString(),
|
||||
'pwdId': state.itemData.value.keyboardPwdId.toString()
|
||||
});
|
||||
}),
|
||||
Container(height: 10.h),
|
||||
CommonItem(
|
||||
leftTitel: TranslationLoader.lanKeys!.sender!.tr,
|
||||
rightTitle: itemData.senderUsername,
|
||||
rightTitle: state.itemData.value.senderUsername,
|
||||
isHaveLine: true,
|
||||
action: () {}),
|
||||
CommonItem(
|
||||
leftTitel: TranslationLoader.lanKeys!.senderTime!.tr,
|
||||
rightTitle: getSenderDate(itemData),
|
||||
rightTitle: getSenderDate(state.itemData.value),
|
||||
action: () {}),
|
||||
Container(height: 10.h),
|
||||
CommonItem(
|
||||
@ -116,8 +107,8 @@ class _PasswordKeyDetailPageState extends State<PasswordKeyDetailPage> {
|
||||
action: () {
|
||||
Navigator.pushNamed(context, Routers.keyOperationRecordPage,
|
||||
arguments: {
|
||||
'lockId': itemData.lockId.toString(),
|
||||
'keyId': itemData.keyboardPwdId.toString()
|
||||
'lockId': state.itemData.value.lockId.toString(),
|
||||
'keyId': state.itemData.value.keyboardPwdId.toString()
|
||||
});
|
||||
}),
|
||||
Container(height: 40.h),
|
||||
@ -129,9 +120,10 @@ class _PasswordKeyDetailPageState extends State<PasswordKeyDetailPage> {
|
||||
// backgroundColor: Colors.white,
|
||||
side: BorderSide(width: 1, color: AppColors.mainColor)),
|
||||
onPressed: () {
|
||||
Navigator.pushNamed(context, Routers.cardListPage, arguments: {
|
||||
"lockId": itemData.lockId,
|
||||
});
|
||||
Navigator.pushNamed(context, Routers.cardListPage,
|
||||
arguments: {
|
||||
"lockId": state.itemData.value.lockId,
|
||||
});
|
||||
},
|
||||
child: Text(
|
||||
'设置卡',
|
||||
@ -150,12 +142,15 @@ class _PasswordKeyDetailPageState extends State<PasswordKeyDetailPage> {
|
||||
// backgroundColor: Colors.white,
|
||||
side: BorderSide(width: 1, color: AppColors.mainColor)),
|
||||
onPressed: () {
|
||||
Navigator.pushNamed(
|
||||
context, Routers.fingerprintListPage,arguments: {
|
||||
"lockId": itemData.lockId,
|
||||
});
|
||||
Navigator.pushNamed(context, Routers.fingerprintListPage,
|
||||
arguments: {
|
||||
"lockId": state.itemData.value.lockId,
|
||||
});
|
||||
},
|
||||
child: Text('设置指纹', style: TextStyle(color: AppColors.mainColor, fontSize: 24.sp),
|
||||
child: Text(
|
||||
'设置指纹',
|
||||
style: TextStyle(
|
||||
color: AppColors.mainColor, fontSize: 24.sp),
|
||||
)),
|
||||
),
|
||||
SizedBox(
|
||||
@ -169,9 +164,11 @@ class _PasswordKeyDetailPageState extends State<PasswordKeyDetailPage> {
|
||||
// backgroundColor: Colors.white,
|
||||
side: BorderSide(width: 1, color: AppColors.mainColor)),
|
||||
onPressed: () {
|
||||
Navigator.pushNamed(context, Routers.remoteControlListPage, arguments: {
|
||||
"lockId": itemData.lockId,
|
||||
});
|
||||
Navigator.pushNamed(
|
||||
context, Routers.remoteControlListPage,
|
||||
arguments: {
|
||||
"lockId": state.itemData.value.lockId,
|
||||
});
|
||||
},
|
||||
child: Text(
|
||||
'设置遥控',
|
||||
@ -197,6 +194,83 @@ class _PasswordKeyDetailPageState extends State<PasswordKeyDetailPage> {
|
||||
));
|
||||
}
|
||||
|
||||
//使用期限
|
||||
String getUseDateStr() {
|
||||
int? getPwdType = state.itemData.value.keyboardPwdType;
|
||||
String useDateStr = '';
|
||||
DateTime startDateStr =
|
||||
DateTime.fromMillisecondsSinceEpoch(state.itemData.value.startDate!);
|
||||
DateTime endDateStr =
|
||||
DateTime.fromMillisecondsSinceEpoch(state.itemData.value.endDate!);
|
||||
int starHour = startDateStr.hour;
|
||||
int endHour = endDateStr.hour;
|
||||
|
||||
switch (getPwdType) {
|
||||
case 1:
|
||||
//单次 1 只能在开始时间后6小时内使用一次
|
||||
useDateStr =
|
||||
'${startDateStr.toLocal().toString().substring(0, 16)}\n${endDateStr.toLocal().toString().substring(0, 16)}';
|
||||
break;
|
||||
case 2:
|
||||
//永久 2 从开始时间开始永久有效,必需在开始时间24小时内使用一次,否则将失效
|
||||
useDateStr = '永久';
|
||||
break;
|
||||
case 3:
|
||||
//限期 3 在开始和结束时间内有效,必需在开始时间24小时内使用一次,否则将失效
|
||||
useDateStr =
|
||||
'${startDateStr.toLocal().toString().substring(0, 16)}\n${endDateStr.toLocal().toString().substring(0, 16)}';
|
||||
break;
|
||||
case 4:
|
||||
//删除 4 在锁上使用后会删除之前在锁上使用过的密码
|
||||
useDateStr =
|
||||
'${startDateStr.toLocal().toString().substring(0, 16)}\n${endDateStr.toLocal().toString().substring(0, 16)}';
|
||||
break;
|
||||
case 5:
|
||||
//周未循环 5 在周未开始和结束时间指定时间段内有效
|
||||
useDateStr = '周末 $starHour:00-$endHour:00';
|
||||
break;
|
||||
case 6:
|
||||
//每日循环 6 每天开始和结束时间指定时间段内有效
|
||||
useDateStr = '周日 $starHour:00-$endHour:00';
|
||||
break;
|
||||
case 7:
|
||||
//工作日循环 7 工作日开始和结束时间指定的时间段内有效
|
||||
useDateStr = '工作日 $starHour:00-$endHour:00';
|
||||
break;
|
||||
case 8:
|
||||
//周一循环 8 每周一开始和结束时间指定时间段内有效
|
||||
useDateStr = '周一 $starHour:00-$endHour:00';
|
||||
break;
|
||||
case 9:
|
||||
//周二循环 9 每周二开始和结束时间指定时间段内有效
|
||||
useDateStr = '周二 $starHour:00-$endHour:00';
|
||||
break;
|
||||
case 10:
|
||||
//周三循环 10 每周三开始和结束时间指定时间段内有效
|
||||
useDateStr = '周三 $starHour:00-$endHour:00';
|
||||
break;
|
||||
case 11:
|
||||
//周四循环 11 每周四开始和结束时间指定时间段内有效
|
||||
useDateStr = '周四 $starHour:00-$endHour:00';
|
||||
break;
|
||||
case 12:
|
||||
//周五循环 12 每周五开始和结束时间指定时间段内有效
|
||||
useDateStr = '周五 $starHour:00-$endHour:00';
|
||||
break;
|
||||
case 13:
|
||||
//周六循环 13 每周六开始和结束时间指定时间段内有效
|
||||
useDateStr = '周六 $starHour:00-$endHour:00';
|
||||
break;
|
||||
case 14:
|
||||
//周天循环 14 每周日开始和结束时间指定时间段内有效
|
||||
useDateStr = '周天 $starHour:00-$endHour:00';
|
||||
break;
|
||||
|
||||
default:
|
||||
}
|
||||
return useDateStr;
|
||||
}
|
||||
|
||||
//发送时间
|
||||
String getSenderDate(PasswordKeyListItem indexEntity) {
|
||||
String senderDate = '';
|
||||
@ -206,106 +280,13 @@ class _PasswordKeyDetailPageState extends State<PasswordKeyDetailPage> {
|
||||
return senderDate;
|
||||
}
|
||||
|
||||
Widget commonItem(String leftTitle, String rightTitle,
|
||||
{bool isHaveDirection = false,
|
||||
bool isHaveLine = false,
|
||||
bool isHaveRightWidget = false,
|
||||
Widget? rightWidget,
|
||||
Function()? action}) {
|
||||
return GestureDetector(
|
||||
onTap: action,
|
||||
child: Column(
|
||||
// mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Container(
|
||||
// height: 80.h,
|
||||
color: Colors.white,
|
||||
padding: EdgeInsets.only(
|
||||
left: 20.w, right: 10.w, top: 20.w, bottom: 20.w),
|
||||
child: Row(
|
||||
children: [
|
||||
SizedBox(width: 20.w),
|
||||
Text(
|
||||
leftTitle,
|
||||
style:
|
||||
TextStyle(fontSize: 28.sp, fontWeight: FontWeight.w500),
|
||||
),
|
||||
SizedBox(width: 20.w),
|
||||
Expanded(
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.end,
|
||||
children: [
|
||||
isHaveRightWidget
|
||||
? rightWidget!
|
||||
: Text(
|
||||
rightTitle,
|
||||
textAlign: TextAlign.end,
|
||||
style: TextStyle(
|
||||
fontSize: 28.sp, fontWeight: FontWeight.w500),
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
SizedBox(width: 5.w),
|
||||
isHaveDirection
|
||||
? Image.asset(
|
||||
'images/icon_right.png',
|
||||
width: 50.w,
|
||||
height: 50.w,
|
||||
)
|
||||
: SizedBox(width: 10.w),
|
||||
// SizedBox(width:10.w),
|
||||
],
|
||||
),
|
||||
),
|
||||
isHaveLine
|
||||
? Container(
|
||||
height: 0.5.h,
|
||||
color: Colors.grey,
|
||||
)
|
||||
: Container()
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
//删除密码请求 deleteType:1-蓝牙 2-网关
|
||||
Future<void> deletePwdRequest() async {
|
||||
PasswordKeyEntity entity = await ApiRepository.to.deleteKeyboardPwd(
|
||||
itemData.lockId.toString(), itemData.keyboardPwdId.toString(), 1);
|
||||
if (entity.errorCode!.codeIsSuccessful) {
|
||||
Toast.show(msg: "删除成功");
|
||||
setState(() {
|
||||
Navigator.pop(context, true);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
//更新密码请求
|
||||
Future<void> updatePwdRequest() async {
|
||||
PasswordKeyEntity entity = await ApiRepository.to.updatePasswordKey(
|
||||
itemData.lockId.toString(),
|
||||
itemData.keyboardPwdId.toString(),
|
||||
_inputNameController.text,
|
||||
_inputPwdController.text,
|
||||
'',
|
||||
'',
|
||||
'');
|
||||
if (entity.errorCode!.codeIsSuccessful) {
|
||||
Toast.show(msg: "修改成功");
|
||||
setState(() {
|
||||
Navigator.pop(context);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
void showCupertinoAlertDialog(
|
||||
BuildContext context, TextEditingController inputController) {
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (BuildContext context) {
|
||||
return ShowTFView(
|
||||
title: inputController == _inputNameController
|
||||
title: inputController == state.inputNameController
|
||||
? "${TranslationLoader.lanKeys!.amend!.tr}${TranslationLoader.lanKeys!.name!.tr}"
|
||||
: "${TranslationLoader.lanKeys!.amend!.tr}${TranslationLoader.lanKeys!.password!.tr}",
|
||||
tipTitle: "请输入",
|
||||
@ -313,7 +294,7 @@ class _PasswordKeyDetailPageState extends State<PasswordKeyDetailPage> {
|
||||
sureClick: () {
|
||||
//发送编辑钥匙名称请求
|
||||
if (inputController.text.isNotEmpty) {
|
||||
updatePwdRequest();
|
||||
logic.updatePwdRequest();
|
||||
}
|
||||
},
|
||||
cancelClick: () {
|
||||
@ -411,7 +392,7 @@ class _PasswordKeyDetailPageState extends State<PasswordKeyDetailPage> {
|
||||
{
|
||||
Navigator.pop(context);
|
||||
String pwdShareStr =
|
||||
'您好,您的密码是:${itemData.keyboardPwd}\n生效时间:${itemData.startDate}\n类型:永久\n锁名:${itemData.keyboardPwdName}';
|
||||
'您好,您的密码是:${state.itemData.value.keyboardPwd}\n生效时间:${state.itemData.value.startDate}\n类型:永久\n锁名:${state.itemData.value.keyboardPwdName}';
|
||||
tokNative('flutter_sharePassword_to_ios',
|
||||
arguments: {'pwdShareStr': pwdShareStr}).then((result) {
|
||||
print('$result');
|
||||
@ -456,13 +437,12 @@ class _PasswordKeyDetailPageState extends State<PasswordKeyDetailPage> {
|
||||
tipTitle: "确定要删除吗?",
|
||||
sureClick: () {
|
||||
Get.back();
|
||||
deletePwdRequest();
|
||||
logic.deletePwdRequest();
|
||||
},
|
||||
cancelClick: () {
|
||||
Get.back();
|
||||
},
|
||||
);
|
||||
}
|
||||
);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@ -0,0 +1,20 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:star_lock/main/lockDetail/passwordKey/passwordKeyList/passwordKeyListEntity.dart';
|
||||
|
||||
class PasswordKeyDetailState {
|
||||
final itemData = PasswordKeyListItem().obs;
|
||||
final TextEditingController inputPwdController = TextEditingController();
|
||||
final TextEditingController inputNameController = TextEditingController();
|
||||
|
||||
// final keyInfo = LockListInfoItemEntity().obs;
|
||||
// var pageNum = 1.obs; //请求页码
|
||||
// final pageSize = 20.obs; //请求每页数据条数
|
||||
// final itemDataList = <PasswordKeyListItem>[].obs;
|
||||
// final TextEditingController searchController = TextEditingController();
|
||||
|
||||
PasswordKeyDetailState() {
|
||||
Map map = Get.arguments;
|
||||
itemData.value = map["itemData"];
|
||||
}
|
||||
}
|
||||
@ -248,54 +248,89 @@ class _PasswordKeyListPageState extends State<PasswordKeyListPage> {
|
||||
}
|
||||
|
||||
//使用期限
|
||||
/**
|
||||
单次 1 只能在开始时间后6小时内使用一次
|
||||
永久 2 从开始时间开始永久有效,必需在开始时间24小时内使用一次,否则将失效
|
||||
限期 3 在开始和结束时间内有效,必需在开始时间24小时内使用一次,否则将失效
|
||||
删除 4 在锁上使用后会删除之前在锁上使用过的密码
|
||||
周未循环 5 在周未开始和结束时间指定时间段内有效
|
||||
每日循环 6 每天开始和结束时间指定时间段内有效
|
||||
工作日循环 7 工作日开始和结束时间指定的时间段内有效
|
||||
周一循环 8 每周一开始和结束时间指定时间段内有效
|
||||
周二循环 9 每周二开始和结束时间指定时间段内有效
|
||||
周三循环 10 每周三开始和结束时间指定时间段内有效
|
||||
周四循环 11 每周四开始和结束时间指定时间段内有效
|
||||
周五循环 12 每周五开始和结束时间指定时间段内有效
|
||||
周六循环 13 每周六开始和结束时间指定时间段内有效
|
||||
周天循环 14 每周日开始和结束时间指定时间段内有效
|
||||
*/
|
||||
String getUseDateStr(PasswordKeyListItem indexEntity) {
|
||||
int? getPwdType = indexEntity.keyboardPwdType;
|
||||
String useDateStr = '';
|
||||
if (indexEntity.keyboardPwdType == 3) {
|
||||
//限期
|
||||
DateTime startDateStr =
|
||||
DateTime.fromMillisecondsSinceEpoch(indexEntity.startDate!);
|
||||
DateTime endDateStr =
|
||||
DateTime.fromMillisecondsSinceEpoch(indexEntity.endDate!);
|
||||
useDateStr =
|
||||
'${startDateStr.toLocal().toString().substring(0, 16)}-${endDateStr.toLocal().toString().substring(0, 16)}';
|
||||
} else if (indexEntity.keyboardPwdType == 2) {
|
||||
//永久
|
||||
DateTime dateStr =
|
||||
DateTime.fromMillisecondsSinceEpoch(indexEntity.sendDate!);
|
||||
useDateStr = '${dateStr.toLocal().toString().substring(0, 16)} 永久';
|
||||
} else if (indexEntity.keyboardPwdType == 1) {
|
||||
//单次
|
||||
DateTime dateStr =
|
||||
DateTime.fromMillisecondsSinceEpoch(indexEntity.sendDate!);
|
||||
useDateStr = '${dateStr.toLocal().toString().substring(0, 16)} 单次';
|
||||
} else if (indexEntity.keyboardPwdType == 4) {
|
||||
//删除
|
||||
DateTime dateStr =
|
||||
DateTime.fromMillisecondsSinceEpoch(indexEntity.sendDate!);
|
||||
useDateStr = '${dateStr.toLocal().toString().substring(0, 16)} 清空码';
|
||||
} else {
|
||||
//循环
|
||||
DateTime dateStr =
|
||||
DateTime.fromMillisecondsSinceEpoch(indexEntity.sendDate!);
|
||||
useDateStr = '${dateStr.toLocal().toString().substring(0, 16)} 循环';
|
||||
}
|
||||
DateTime sendDateStr =
|
||||
DateTime.fromMillisecondsSinceEpoch(indexEntity.sendDate!);
|
||||
DateTime startDateStr =
|
||||
DateTime.fromMillisecondsSinceEpoch(indexEntity.startDate!);
|
||||
DateTime endDateStr =
|
||||
DateTime.fromMillisecondsSinceEpoch(indexEntity.endDate!);
|
||||
int starHour = startDateStr.hour;
|
||||
int endHour = endDateStr.hour;
|
||||
|
||||
switch (getPwdType) {
|
||||
case 1:
|
||||
//单次 1 只能在开始时间后6小时内使用一次
|
||||
useDateStr = '${sendDateStr.toLocal().toString().substring(0, 16)} 单次';
|
||||
break;
|
||||
case 2:
|
||||
//永久 2 从开始时间开始永久有效,必需在开始时间24小时内使用一次,否则将失效
|
||||
useDateStr = '${sendDateStr.toLocal().toString().substring(0, 16)} 永久';
|
||||
break;
|
||||
case 3:
|
||||
//限期 3 在开始和结束时间内有效,必需在开始时间24小时内使用一次,否则将失效
|
||||
useDateStr =
|
||||
'${startDateStr.toLocal().toString().substring(0, 16)} - ${endDateStr.toLocal().toString().substring(0, 16)} 限时';
|
||||
break;
|
||||
case 4:
|
||||
//删除 4 在锁上使用后会删除之前在锁上使用过的密码
|
||||
useDateStr = '${sendDateStr.toLocal().toString().substring(0, 16)} 清空码';
|
||||
break;
|
||||
case 5:
|
||||
//周未循环 5 在周未开始和结束时间指定时间段内有效
|
||||
useDateStr =
|
||||
'${sendDateStr.toLocal().toString().substring(0, 16)} 周末$starHour:00-$endHour:00 循环';
|
||||
break;
|
||||
case 6:
|
||||
//每日循环 6 每天开始和结束时间指定时间段内有效
|
||||
useDateStr =
|
||||
'${sendDateStr.toLocal().toString().substring(0, 16)} 周日$starHour:00-$endHour:00 循环';
|
||||
break;
|
||||
case 7:
|
||||
//工作日循环 7 工作日开始和结束时间指定的时间段内有效
|
||||
useDateStr =
|
||||
'${sendDateStr.toLocal().toString().substring(0, 16)} 工作日$starHour:00-$endHour:00 循环';
|
||||
break;
|
||||
case 8:
|
||||
//周一循环 8 每周一开始和结束时间指定时间段内有效
|
||||
useDateStr =
|
||||
'${sendDateStr.toLocal().toString().substring(0, 16)} 周一$starHour:00-$endHour:00 循环';
|
||||
break;
|
||||
case 9:
|
||||
//周二循环 9 每周二开始和结束时间指定时间段内有效
|
||||
useDateStr =
|
||||
'${sendDateStr.toLocal().toString().substring(0, 16)} 周二$starHour:00-$endHour:00 循环';
|
||||
break;
|
||||
case 10:
|
||||
//周三循环 10 每周三开始和结束时间指定时间段内有效
|
||||
useDateStr =
|
||||
'${sendDateStr.toLocal().toString().substring(0, 16)} 周三$starHour:00-$endHour:00 循环';
|
||||
break;
|
||||
case 11:
|
||||
//周四循环 11 每周四开始和结束时间指定时间段内有效
|
||||
useDateStr =
|
||||
'${sendDateStr.toLocal().toString().substring(0, 16)} 周四$starHour:00-$endHour:00 循环';
|
||||
break;
|
||||
case 12:
|
||||
//周五循环 12 每周五开始和结束时间指定时间段内有效
|
||||
useDateStr =
|
||||
'${sendDateStr.toLocal().toString().substring(0, 16)} 周五$starHour:00-$endHour:00 循环';
|
||||
break;
|
||||
case 13:
|
||||
//周六循环 13 每周六开始和结束时间指定时间段内有效
|
||||
useDateStr =
|
||||
'${sendDateStr.toLocal().toString().substring(0, 16)} 周六$starHour:00-$endHour:00 循环';
|
||||
break;
|
||||
case 14:
|
||||
//周天循环 14 每周日开始和结束时间指定时间段内有效
|
||||
useDateStr =
|
||||
'${sendDateStr.toLocal().toString().substring(0, 16)} 周天$starHour:00-$endHour:00 循环';
|
||||
break;
|
||||
|
||||
default:
|
||||
}
|
||||
return useDateStr;
|
||||
}
|
||||
|
||||
|
||||
@ -404,53 +404,62 @@ class _PasswordKeyPerpetualPageState extends State<PasswordKeyPerpetualPage> {
|
||||
var isDemoMode = await Storage.getBool(ifIsDemoModeOrNot);
|
||||
if (isDemoMode == false) {
|
||||
int getWidgetNumber = int.parse(widget.type);
|
||||
if (state.nameController.text.isEmpty) {
|
||||
Toast.show(msg: '请输入姓名');
|
||||
return;
|
||||
}
|
||||
|
||||
//限时
|
||||
if (getWidgetNumber == 1) {
|
||||
if (!state.effectiveDateTime.value
|
||||
.isBefore(state.failureDateTime.value)) {
|
||||
Toast.show(msg: '失效时间需大于生效时间');
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
//自定义密码
|
||||
if (getWidgetNumber == 3) {
|
||||
logic.getStartDate(state.effectiveDateTime.value);
|
||||
if (state.nameController.text.isEmpty) {
|
||||
Toast.show(msg: '请输入姓名');
|
||||
return;
|
||||
}
|
||||
if (state.pwdController.text.isEmpty) {
|
||||
Toast.show(msg: '请输入密码');
|
||||
return;
|
||||
}
|
||||
//非永久 须有时限
|
||||
if (state.isPermanent.value == false) {
|
||||
print('自定义密码输出********有时限');
|
||||
if (!state.effectiveDateTime.value
|
||||
.isBefore(state.failureDateTime.value)) {
|
||||
.isBefore(state.failureDateTime.value) ||
|
||||
state.effectiveDateTime.value
|
||||
.isAtSameMomentAs(state.failureDateTime.value)) {
|
||||
Toast.show(msg: '失效时间需大于生效时间');
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
logic.addKeyboardPwdRequest();
|
||||
}
|
||||
|
||||
//循环密码
|
||||
if (getWidgetNumber == 4) {
|
||||
if (!state.effectiveDateTime.value
|
||||
.isBefore(state.failureDateTime.value)) {
|
||||
Toast.show(msg: '结束时间需大于当前时间');
|
||||
} else {
|
||||
if (state.nameController.text.isEmpty) {
|
||||
Toast.show(msg: '请输入姓名');
|
||||
return;
|
||||
}
|
||||
if (state.loopEndHours.value <= state.loopStartHours.value) {
|
||||
Toast.show(msg: '失效时间需大于生效时间');
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
logic.getKeyboardPwdRequest();
|
||||
//限时
|
||||
if (getWidgetNumber == 1) {
|
||||
if (!state.effectiveDateTime.value
|
||||
.isBefore(state.failureDateTime.value) ||
|
||||
state.effectiveDateTime.value
|
||||
.isAtSameMomentAs(state.failureDateTime.value)) {
|
||||
Toast.show(msg: '失效时间需大于生效时间');
|
||||
return;
|
||||
}
|
||||
}
|
||||
//循环密码
|
||||
if (getWidgetNumber == 4) {
|
||||
if (!state.effectiveDateTime.value
|
||||
.isBefore(state.failureDateTime.value)) {
|
||||
Toast.show(msg: '结束时间需大于当前时间');
|
||||
return;
|
||||
}
|
||||
if (state.loopEndHours.value <=
|
||||
state.loopStartHours.value) {
|
||||
Toast.show(msg: '失效时间需大于生效时间');
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
logic.getKeyboardPwdRequest();
|
||||
}
|
||||
} else {
|
||||
Toast.show(msg: '演示模式');
|
||||
}
|
||||
|
||||
@ -9,7 +9,7 @@ class PasswordKeyPerpetualState {
|
||||
|
||||
final isInitialized = false.obs;
|
||||
final isSendSuccess = false.obs; //是否发送成功
|
||||
final isPermanent = false.obs; //是否永久
|
||||
final isPermanent = true.obs; //是否永久
|
||||
var getPwdStr = ''.obs;
|
||||
|
||||
final effectiveDateTime = DateTime.now().obs;
|
||||
|
||||
@ -59,18 +59,24 @@ class CommonItem extends StatelessWidget {
|
||||
children: [
|
||||
isHaveRightWidget!
|
||||
? rightWidget!
|
||||
: Text(rightTitle ?? "", textAlign: TextAlign.end,
|
||||
: Text(
|
||||
rightTitle ?? "",
|
||||
textAlign: TextAlign.right,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
maxLines: 1,
|
||||
maxLines: 2,
|
||||
style: TextStyle(
|
||||
fontSize: 22.sp,
|
||||
color: AppColors.darkGrayTextColor),
|
||||
)
|
||||
),
|
||||
],
|
||||
),
|
||||
isHaveDirection! ? SizedBox(width: 3.w) : Container(),
|
||||
isHaveDirection!
|
||||
? Image.asset('images/icon_right_grey.png', width: 12.w, height: 21.w,)
|
||||
? Image.asset(
|
||||
'images/icon_right_grey.png',
|
||||
width: 12.w,
|
||||
height: 21.w,
|
||||
)
|
||||
: SizedBox(width: 10.w),
|
||||
isHaveDirection! ? SizedBox(width: 5.w) : Container(),
|
||||
],
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user