1,修复发送电子钥匙及密码模块部分输入框格式问题
2,修复发送电子钥匙-循环类型页面报红问题 3,修复不能给邮箱发送电子钥匙问题
This commit is contained in:
parent
1a8d726e2f
commit
3cfceece5b
@ -85,10 +85,11 @@ class _ElectronicKeyListPageState extends State<ElectronicKeyListPage> {
|
|||||||
btnName: TranslationLoader.lanKeys!.sendKey!.tr,
|
btnName: TranslationLoader.lanKeys!.sendKey!.tr,
|
||||||
onClick: () {
|
onClick: () {
|
||||||
Navigator.pushNamed(
|
Navigator.pushNamed(
|
||||||
context, Routers.sendElectronicKeyManagePage, arguments: {
|
context, Routers.sendElectronicKeyManagePage,
|
||||||
// "lockMainEntity": state.lockMainEntity.value,
|
arguments: {
|
||||||
"keyInfo": state.keyInfo.value
|
// "lockMainEntity": state.lockMainEntity.value,
|
||||||
}).then((val) {
|
"keyInfo": state.keyInfo.value
|
||||||
|
}).then((val) {
|
||||||
if (val != null) {
|
if (val != null) {
|
||||||
logic.mockNetworkDataRequest();
|
logic.mockNetworkDataRequest();
|
||||||
setState(() {});
|
setState(() {});
|
||||||
@ -145,7 +146,7 @@ class _ElectronicKeyListPageState extends State<ElectronicKeyListPage> {
|
|||||||
decoration: InputDecoration(
|
decoration: InputDecoration(
|
||||||
//输入里面输入文字内边距设置
|
//输入里面输入文字内边距设置
|
||||||
contentPadding: const EdgeInsets.only(
|
contentPadding: const EdgeInsets.only(
|
||||||
top: 12.0, left: -19.0, right: -15.0, bottom: 8.0),
|
top: 18.0, left: -19.0, right: -15.0, bottom: 2),
|
||||||
hintText: TranslationLoader.lanKeys!.pleaseEnter!.tr,
|
hintText: TranslationLoader.lanKeys!.pleaseEnter!.tr,
|
||||||
hintStyle: TextStyle(fontSize: 22.sp, height: 3.0),
|
hintStyle: TextStyle(fontSize: 22.sp, height: 3.0),
|
||||||
//不需要输入框下划线
|
//不需要输入框下划线
|
||||||
@ -161,6 +162,8 @@ class _ElectronicKeyListPageState extends State<ElectronicKeyListPage> {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
style:
|
||||||
|
TextStyle(fontSize: 22.sp, textBaseline: TextBaseline.alphabetic),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -201,14 +204,14 @@ class _ElectronicKeyListPageState extends State<ElectronicKeyListPage> {
|
|||||||
),
|
),
|
||||||
child: _electronicKeyItem('images/controls_user.png',
|
child: _electronicKeyItem('images/controls_user.png',
|
||||||
indexEntity.keyName!, useDateStr, keyStatus, isAdminKey, () {
|
indexEntity.keyName!, useDateStr, keyStatus, isAdminKey, () {
|
||||||
Navigator.pushNamed(context, Routers.electronicKeyDetailPage,
|
Navigator.pushNamed(context, Routers.electronicKeyDetailPage,
|
||||||
arguments: {"itemData": indexEntity}).then((val) {
|
arguments: {"itemData": indexEntity}).then((val) {
|
||||||
if (val != null) {
|
if (val != null) {
|
||||||
logic.mockNetworkDataRequest();
|
logic.mockNetworkDataRequest();
|
||||||
setState(() {});
|
setState(() {});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
return const SizedBox.shrink();
|
return const SizedBox.shrink();
|
||||||
|
|||||||
@ -0,0 +1,7 @@
|
|||||||
|
import 'package:star_lock/main/lockDetail/electronicKey/electronicKeyPeriodValidity/electronicKeyPeriodValidity_state.dart';
|
||||||
|
import 'package:star_lock/tools/baseGetXController.dart';
|
||||||
|
|
||||||
|
class ElectronicKeyPeriodValidityLogic extends BaseGetXController {
|
||||||
|
final ElectronicKeyPeriodValidityState state =
|
||||||
|
ElectronicKeyPeriodValidityState();
|
||||||
|
}
|
||||||
@ -5,6 +5,8 @@ import 'package:flutter_pickers/time_picker/model/date_mode.dart';
|
|||||||
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
||||||
import 'package:get/get.dart';
|
import 'package:get/get.dart';
|
||||||
import 'package:star_lock/main/lockDetail/electronicKey/electronicKeyPeriodValidity/KeyPeriodValidityModel.dart';
|
import 'package:star_lock/main/lockDetail/electronicKey/electronicKeyPeriodValidity/KeyPeriodValidityModel.dart';
|
||||||
|
import 'package:star_lock/main/lockDetail/electronicKey/electronicKeyPeriodValidity/electronicKeyPeriodValidity_logic.dart';
|
||||||
|
import 'package:star_lock/tools/toast.dart';
|
||||||
|
|
||||||
import '../../../../app_settings/app_colors.dart';
|
import '../../../../app_settings/app_colors.dart';
|
||||||
import '../../../../tools/commonItem.dart';
|
import '../../../../tools/commonItem.dart';
|
||||||
@ -22,35 +24,38 @@ class ElectronicKeyPeriodValidityPage extends StatefulWidget {
|
|||||||
|
|
||||||
class _ElectronicKeyPeriodValidityPageState
|
class _ElectronicKeyPeriodValidityPageState
|
||||||
extends State<ElectronicKeyPeriodValidityPage> {
|
extends State<ElectronicKeyPeriodValidityPage> {
|
||||||
List validityTextList = [
|
final logic = Get.put(ElectronicKeyPeriodValidityLogic());
|
||||||
TranslationLoader.lanKeys!.sundayShort!.tr,
|
final state = Get.find<ElectronicKeyPeriodValidityLogic>().state;
|
||||||
TranslationLoader.lanKeys!.mondayShort!.tr,
|
|
||||||
TranslationLoader.lanKeys!.tuesdayShort!.tr,
|
// List validityTextList = [
|
||||||
TranslationLoader.lanKeys!.wednesdayShort!.tr,
|
// TranslationLoader.lanKeys!.sundayShort!.tr,
|
||||||
TranslationLoader.lanKeys!.thursdayShort!.tr,
|
// TranslationLoader.lanKeys!.mondayShort!.tr,
|
||||||
TranslationLoader.lanKeys!.fridayShort!.tr,
|
// TranslationLoader.lanKeys!.tuesdayShort!.tr,
|
||||||
TranslationLoader.lanKeys!.saturdayShort!.tr
|
// TranslationLoader.lanKeys!.wednesdayShort!.tr,
|
||||||
];
|
// TranslationLoader.lanKeys!.thursdayShort!.tr,
|
||||||
List validityDataList = []; //自定义数据块
|
// TranslationLoader.lanKeys!.fridayShort!.tr,
|
||||||
List selectIndexList = []; //选中的有效期数组
|
// TranslationLoader.lanKeys!.saturdayShort!.tr
|
||||||
String _selectEffectiveDate = ''; //生效时间
|
// ];
|
||||||
String _selectFailureDate = ''; //失效时间
|
// List validityDataList = []; //自定义数据块
|
||||||
late DateTime _effectiveDateTime;
|
// List selectIndexList = []; //选中的有效期数组
|
||||||
late DateTime _failureDateTime;
|
// String _selectEffectiveDate = ''; //生效时间
|
||||||
|
// String _selectFailureDate = ''; //失效时间
|
||||||
|
// late DateTime _effectiveDateTime;
|
||||||
|
// late DateTime _failureDateTime;
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
|
|
||||||
for (var i = 0; i < validityTextList.length; i++) {
|
for (var i = 0; i < state.validityTextList.value.length; i++) {
|
||||||
int validityValue = 0;
|
int validityValue = 0;
|
||||||
if (i == 0) {
|
if (i == 0) {
|
||||||
validityValue = 7;
|
validityValue = 7;
|
||||||
} else {
|
} else {
|
||||||
validityValue = i;
|
validityValue = i;
|
||||||
}
|
}
|
||||||
KeyPeriodValidityModel model =
|
KeyPeriodValidityModel model = KeyPeriodValidityModel(
|
||||||
KeyPeriodValidityModel(validityTextList[i], i, false, validityValue);
|
state.validityTextList.value[i], i, false, validityValue);
|
||||||
validityDataList.add(model);
|
state.validityDataList.value.add(model);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -101,7 +106,8 @@ class _ElectronicKeyPeriodValidityPageState
|
|||||||
itemCount: 7,
|
itemCount: 7,
|
||||||
physics: const NeverScrollableScrollPhysics(),
|
physics: const NeverScrollableScrollPhysics(),
|
||||||
itemBuilder: (context, index) {
|
itemBuilder: (context, index) {
|
||||||
KeyPeriodValidityModel model = validityDataList[index];
|
KeyPeriodValidityModel model =
|
||||||
|
state.validityDataList.value[index];
|
||||||
return btnItem(model);
|
return btnItem(model);
|
||||||
}))
|
}))
|
||||||
],
|
],
|
||||||
@ -110,38 +116,40 @@ class _ElectronicKeyPeriodValidityPageState
|
|||||||
}
|
}
|
||||||
|
|
||||||
Widget btnItem(KeyPeriodValidityModel model) {
|
Widget btnItem(KeyPeriodValidityModel model) {
|
||||||
return GestureDetector(
|
return Obx(() => GestureDetector(
|
||||||
onTap: () {
|
onTap: () {
|
||||||
model.isValidity = !model.isValidity;
|
model.isValidity = !model.isValidity;
|
||||||
if (model.isValidity) {
|
if (model.isValidity) {
|
||||||
selectIndexList.add(model.validityValue);
|
state.selectIndexList.value.add(model.validityValue);
|
||||||
} else {
|
} else {
|
||||||
selectIndexList.remove(model.validityValue);
|
state.selectIndexList.value.remove(model.validityValue);
|
||||||
}
|
}
|
||||||
setState(() {});
|
setState(() {});
|
||||||
},
|
},
|
||||||
child: Container(
|
child: Container(
|
||||||
width: 40.w,
|
width: 40.w,
|
||||||
height: 40.w,
|
height: 40.w,
|
||||||
margin: EdgeInsets.all(10.w),
|
margin: EdgeInsets.all(10.w),
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
color: selectIndexList.contains(model.validityValue)
|
color: state.selectIndexList.value.contains(model.validityValue)
|
||||||
? Colors.blue
|
? Colors.blue
|
||||||
: Colors.white,
|
: Colors.white,
|
||||||
border: Border.all(width: 1, color: AppColors.greyBackgroundColor),
|
border:
|
||||||
borderRadius: BorderRadius.circular(30.w),
|
Border.all(width: 1, color: AppColors.greyBackgroundColor),
|
||||||
),
|
borderRadius: BorderRadius.circular(30.w),
|
||||||
child: Center(
|
),
|
||||||
child: Text(
|
child: Center(
|
||||||
model.validityText,
|
child: Text(
|
||||||
style: TextStyle(
|
model.validityText,
|
||||||
fontSize: 20.sp,
|
style: TextStyle(
|
||||||
color: selectIndexList.contains(model.validityValue)
|
fontSize: 20.sp,
|
||||||
? Colors.white
|
color:
|
||||||
: AppColors.darkGrayTextColor),
|
state.selectIndexList.value.contains(model.validityValue)
|
||||||
)),
|
? Colors.white
|
||||||
),
|
: AppColors.darkGrayTextColor),
|
||||||
);
|
)),
|
||||||
|
),
|
||||||
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget bottomWidget() {
|
Widget bottomWidget() {
|
||||||
@ -173,49 +181,59 @@ class _ElectronicKeyPeriodValidityPageState
|
|||||||
// });
|
// });
|
||||||
// }),
|
// }),
|
||||||
// Container(height: 10.h),
|
// Container(height: 10.h),
|
||||||
CommonItem(
|
Obx(() => CommonItem(
|
||||||
leftTitel: TranslationLoader.lanKeys!.effectiveDate!.tr,
|
leftTitel: TranslationLoader.lanKeys!.effectiveDate!.tr,
|
||||||
rightTitle: _selectEffectiveDate,
|
rightTitle: state.selectEffectiveDate.value,
|
||||||
isHaveDirection: true,
|
isHaveDirection: true,
|
||||||
isHaveLine: true,
|
isHaveLine: true,
|
||||||
action: () {
|
action: () {
|
||||||
Pickers.showDatePicker(context, mode: DateMode.YMDHM,
|
Pickers.showDatePicker(context, mode: DateMode.YMDHM,
|
||||||
onConfirm: (p) {
|
onConfirm: (p) {
|
||||||
_effectiveDateTime = DateTime.parse(
|
state.isHaveEffectiveDate.value = true;
|
||||||
|
state.effectiveDateTime.value = DateTime.parse(
|
||||||
'${p.year}-${intToStr(p.month!)}-${intToStr(p.day!)} ${intToStr(p.hour!)}:${intToStr(p.minute!)}');
|
'${p.year}-${intToStr(p.month!)}-${intToStr(p.day!)} ${intToStr(p.hour!)}:${intToStr(p.minute!)}');
|
||||||
_selectEffectiveDate = formatDate(_effectiveDateTime,
|
state.selectEffectiveDate.value = formatDate(
|
||||||
|
state.effectiveDateTime.value,
|
||||||
[yyyy, '-', mm, '-', dd, ' ', HH, ':', nn]);
|
[yyyy, '-', mm, '-', dd, ' ', HH, ':', nn]);
|
||||||
|
|
||||||
setState(() {});
|
|
||||||
});
|
});
|
||||||
}),
|
})),
|
||||||
CommonItem(
|
Obx(() => CommonItem(
|
||||||
leftTitel: TranslationLoader.lanKeys!.failureDate!.tr,
|
leftTitel: TranslationLoader.lanKeys!.failureDate!.tr,
|
||||||
rightTitle: _selectFailureDate,
|
rightTitle: state.selectFailureDate.value,
|
||||||
isHaveDirection: true,
|
isHaveDirection: true,
|
||||||
action: () {
|
action: () {
|
||||||
Pickers.showDatePicker(context, mode: DateMode.YMDHM,
|
Pickers.showDatePicker(context, mode: DateMode.YMDHM,
|
||||||
onConfirm: (p) {
|
onConfirm: (p) {
|
||||||
_failureDateTime = DateTime.parse(
|
state.isHaveFailureDate.value = true;
|
||||||
|
state.failureDateTime.value = DateTime.parse(
|
||||||
'${p.year}-${intToStr(p.month!)}-${intToStr(p.day!)} ${intToStr(p.hour!)}:${intToStr(p.minute!)}');
|
'${p.year}-${intToStr(p.month!)}-${intToStr(p.day!)} ${intToStr(p.hour!)}:${intToStr(p.minute!)}');
|
||||||
_selectFailureDate = formatDate(_failureDateTime,
|
state.selectFailureDate.value = formatDate(
|
||||||
|
state.failureDateTime.value,
|
||||||
[yyyy, '-', mm, '-', dd, ' ', HH, ':', nn]);
|
[yyyy, '-', mm, '-', dd, ' ', HH, ':', nn]);
|
||||||
setState(() {});
|
|
||||||
});
|
});
|
||||||
}),
|
})),
|
||||||
Container(height: 40.h),
|
Container(height: 40.h),
|
||||||
SubmitBtn(
|
Obx(() => SubmitBtn(
|
||||||
btnName: TranslationLoader.lanKeys!.sure!.tr,
|
btnName: TranslationLoader.lanKeys!.sure!.tr,
|
||||||
borderRadius: 20.w,
|
borderRadius: 20.w,
|
||||||
margin: EdgeInsets.only(left: 30.w, right: 30.w, top: 30.w),
|
margin: EdgeInsets.only(left: 30.w, right: 30.w, top: 30.w),
|
||||||
padding: EdgeInsets.only(top: 25.w, bottom: 25.w),
|
padding: EdgeInsets.only(top: 25.w, bottom: 25.w),
|
||||||
|
isDisabled: (state.selectIndexList.value.isNotEmpty &&
|
||||||
|
state.isHaveEffectiveDate.value == true &&
|
||||||
|
state.isHaveFailureDate.value == true)
|
||||||
|
? true
|
||||||
|
: false,
|
||||||
onClick: () {
|
onClick: () {
|
||||||
Map<String, dynamic> resultMap = {};
|
if ((state.selectIndexList.value.isNotEmpty &&
|
||||||
resultMap['validityValue'] = selectIndexList;
|
state.isHaveEffectiveDate.value == true &&
|
||||||
resultMap['starDate'] = _effectiveDateTime;
|
state.isHaveFailureDate.value == true)) {
|
||||||
resultMap['endDate'] = _failureDateTime;
|
Map<String, dynamic> resultMap = {};
|
||||||
Navigator.pop(context, resultMap);
|
resultMap['validityValue'] = state.selectIndexList.value;
|
||||||
}),
|
resultMap['starDate'] = state.effectiveDateTime.value;
|
||||||
|
resultMap['endDate'] = state.failureDateTime.value;
|
||||||
|
Navigator.pop(context, resultMap);
|
||||||
|
}
|
||||||
|
})),
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -0,0 +1,34 @@
|
|||||||
|
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/translations/trans_lib.dart';
|
||||||
|
|
||||||
|
import '../../../lockMian/entity/lockListInfo_entity.dart';
|
||||||
|
|
||||||
|
class ElectronicKeyPeriodValidityState {
|
||||||
|
TextEditingController searchController = TextEditingController(); //邮箱/手机号输入框
|
||||||
|
final keyInfo = LockListInfoItemEntity().obs;
|
||||||
|
// final lockMainEntity = LockMainEntity().obs;
|
||||||
|
var pageNum = 1.obs; //请求页码
|
||||||
|
final pageSize = 20.obs; //请求每页数据条数
|
||||||
|
final itemDataList = <ElectronicKeyListItem>[].obs;
|
||||||
|
|
||||||
|
final validityTextList = [
|
||||||
|
TranslationLoader.lanKeys!.sundayShort!.tr,
|
||||||
|
TranslationLoader.lanKeys!.mondayShort!.tr,
|
||||||
|
TranslationLoader.lanKeys!.tuesdayShort!.tr,
|
||||||
|
TranslationLoader.lanKeys!.wednesdayShort!.tr,
|
||||||
|
TranslationLoader.lanKeys!.thursdayShort!.tr,
|
||||||
|
TranslationLoader.lanKeys!.fridayShort!.tr,
|
||||||
|
TranslationLoader.lanKeys!.saturdayShort!.tr
|
||||||
|
].obs;
|
||||||
|
final validityDataList = [].obs; //自定义数据块
|
||||||
|
final selectIndexList = [].obs; //选中的有效期数组
|
||||||
|
final selectEffectiveDate = ''.obs; //生效时间
|
||||||
|
final selectFailureDate = ''.obs; //失效时间
|
||||||
|
DateTime dateTime = DateTime.now();
|
||||||
|
final effectiveDateTime = DateTime.now().obs;
|
||||||
|
final failureDateTime = DateTime.now().obs;
|
||||||
|
var isHaveEffectiveDate = false.obs;
|
||||||
|
var isHaveFailureDate = false.obs;
|
||||||
|
}
|
||||||
@ -2,6 +2,8 @@ import 'package:flutter/cupertino.dart';
|
|||||||
import 'package:get/get.dart';
|
import 'package:get/get.dart';
|
||||||
import 'package:get/get_utils/get_utils.dart';
|
import 'package:get/get_utils/get_utils.dart';
|
||||||
import 'package:star_lock/appRouters.dart';
|
import 'package:star_lock/appRouters.dart';
|
||||||
|
import 'package:star_lock/app_settings/app_colors.dart';
|
||||||
|
import 'package:star_lock/common/XSConstantMacro/XSConstantMacro.dart';
|
||||||
import 'package:star_lock/main/lockDetail/electronicKey/sendElectronicKey/sendElectronicKey/sendElectronicKey_state.dart';
|
import 'package:star_lock/main/lockDetail/electronicKey/sendElectronicKey/sendElectronicKey/sendElectronicKey_state.dart';
|
||||||
import 'package:star_lock/network/api_repository.dart';
|
import 'package:star_lock/network/api_repository.dart';
|
||||||
import 'package:star_lock/tools/baseGetXController.dart';
|
import 'package:star_lock/tools/baseGetXController.dart';
|
||||||
@ -14,18 +16,38 @@ class SendElectronicKeyLogic extends BaseGetXController {
|
|||||||
//发送钥匙请求
|
//发送钥匙请求
|
||||||
Future<void> sendElectronicKeyRequest(BuildContext widgetContext) async {
|
Future<void> sendElectronicKeyRequest(BuildContext widgetContext) async {
|
||||||
String lockID = state.keyInfo.value.lockId.toString();
|
String lockID = state.keyInfo.value.lockId.toString();
|
||||||
String getKeyType = (int.parse(state.type.value) + 1).toString();
|
int typeValue = int.parse(state.type.value);
|
||||||
if (state.type.value == '0') {
|
switch (typeValue) {
|
||||||
state.failureTimestamp.value =
|
case 0:
|
||||||
state.failureDateTime.value.millisecondsSinceEpoch;
|
{
|
||||||
state.effectiveTimestamp.value =
|
typeValue = XSConstantMacro.keyTypeTime;
|
||||||
state.effectiveDateTime.value.millisecondsSinceEpoch;
|
state.failureTimestamp.value =
|
||||||
|
state.failureDateTime.value.millisecondsSinceEpoch;
|
||||||
|
state.effectiveTimestamp.value =
|
||||||
|
state.effectiveDateTime.value.millisecondsSinceEpoch;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
typeValue = XSConstantMacro.keyTypeLong;
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
typeValue = XSConstantMacro.keyTypeOnce;
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
typeValue = XSConstantMacro.keyTypeLoop;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
typeValue = XSConstantMacro.keyTypeTime;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
String getKeyType = typeValue.toString();
|
||||||
|
|
||||||
var entity = await ApiRepository.to.sendElectronicKey(
|
var entity = await ApiRepository.to.sendElectronicKey(
|
||||||
createUser: state.isCreateUser.value ? "1" : "0",
|
createUser: state.isCreateUser.value ? "1" : "0",
|
||||||
countryCode: state.countryCode.value,
|
countryCode: state.countryCode.value,
|
||||||
usernameType: '1',
|
usernameType: isPhoneNumber(state.emailOrPhoneController.text) == true
|
||||||
|
? '1'
|
||||||
|
: '2',
|
||||||
endDate: state.failureTimestamp.value.toString(),
|
endDate: state.failureTimestamp.value.toString(),
|
||||||
faceAuthentication: state.isAuthentication.value == true ? '1' : '2',
|
faceAuthentication: state.isAuthentication.value == true ? '1' : '2',
|
||||||
isCameraEnable: '2',
|
isCameraEnable: '2',
|
||||||
@ -38,20 +60,37 @@ class SendElectronicKeyLogic extends BaseGetXController {
|
|||||||
receiverUsername: state.emailOrPhoneController.text,
|
receiverUsername: state.emailOrPhoneController.text,
|
||||||
remarks: '',
|
remarks: '',
|
||||||
startDate: state.effectiveTimestamp.value.toString(),
|
startDate: state.effectiveTimestamp.value.toString(),
|
||||||
weekDays: state.weekdaysList);
|
weekDays: state.weekdaysList.value);
|
||||||
if (entity.errorCode!.codeIsSuccessful) {
|
if (entity.errorCode!.codeIsSuccessful) {
|
||||||
print('发送电子钥匙成功');
|
print('发送电子钥匙成功');
|
||||||
state.isSendSuccess.value = true;
|
state.isSendSuccess.value = true;
|
||||||
} else {
|
} else {
|
||||||
if (entity.errorCode == 425) {
|
if (entity.errorCode == 425) {
|
||||||
//用户未注册
|
//用户未注册
|
||||||
_showDialog(widgetContext, '${entity.errorMsg}');
|
if (isPhoneNumber(state.emailOrPhoneController.text) == true) {
|
||||||
|
_showPhoneDialog(widgetContext, '${entity.errorMsg}');
|
||||||
|
} else {
|
||||||
|
_showEmailDialog(widgetContext);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool isPhoneNumber(String input) {
|
||||||
|
// 手机号正则表达式,这里简化为11位数字
|
||||||
|
final RegExp phoneRegExp = RegExp(r'^\d{11}$');
|
||||||
|
return phoneRegExp.hasMatch(input);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool isEmail(String input) {
|
||||||
|
// 邮箱正则表达式,这里简化为常见格式
|
||||||
|
final RegExp emailRegExp =
|
||||||
|
RegExp(r'^[\w-]+(\.[\w-]+)*@([\w-]+\.)+[a-zA-Z]{2,7}$');
|
||||||
|
return emailRegExp.hasMatch(input);
|
||||||
|
}
|
||||||
|
|
||||||
//用户未注册确认弹窗
|
//用户未注册确认弹窗
|
||||||
void _showDialog(widgetContext, String errMsg) {
|
void _showPhoneDialog(widgetContext, String errMsg) {
|
||||||
showCupertinoDialog(
|
showCupertinoDialog(
|
||||||
context: widgetContext,
|
context: widgetContext,
|
||||||
builder: (context) {
|
builder: (context) {
|
||||||
@ -59,13 +98,19 @@ class SendElectronicKeyLogic extends BaseGetXController {
|
|||||||
title: const Text('接收者号码未注册,请选择号码所在的国家并重新发送'),
|
title: const Text('接收者号码未注册,请选择号码所在的国家并重新发送'),
|
||||||
actions: [
|
actions: [
|
||||||
CupertinoDialogAction(
|
CupertinoDialogAction(
|
||||||
child: Text(TranslationLoader.lanKeys!.cancel!.tr),
|
child: Text(
|
||||||
|
TranslationLoader.lanKeys!.cancel!.tr,
|
||||||
|
style: TextStyle(color: AppColors.mainColor),
|
||||||
|
),
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
Navigator.of(context).pop();
|
Navigator.of(context).pop();
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
CupertinoDialogAction(
|
CupertinoDialogAction(
|
||||||
child: Text(TranslationLoader.lanKeys!.selet!.tr),
|
child: Text(
|
||||||
|
TranslationLoader.lanKeys!.selet!.tr,
|
||||||
|
style: TextStyle(color: AppColors.mainColor),
|
||||||
|
),
|
||||||
onPressed: () async {
|
onPressed: () async {
|
||||||
//选择国家代码
|
//选择国家代码
|
||||||
state.isCreateUser.value = true;
|
state.isCreateUser.value = true;
|
||||||
@ -84,4 +129,39 @@ class SendElectronicKeyLogic extends BaseGetXController {
|
|||||||
},
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//用户未注册确认弹窗---邮箱
|
||||||
|
void _showEmailDialog(widgetContext) {
|
||||||
|
showCupertinoDialog(
|
||||||
|
context: widgetContext,
|
||||||
|
builder: (context) {
|
||||||
|
return CupertinoAlertDialog(
|
||||||
|
title: Text('是否发送电子钥匙给未注册账号\n${state.emailOrPhoneController.text}'),
|
||||||
|
actions: [
|
||||||
|
CupertinoDialogAction(
|
||||||
|
child: Text(
|
||||||
|
TranslationLoader.lanKeys!.cancel!.tr,
|
||||||
|
style: TextStyle(color: AppColors.mainColor),
|
||||||
|
),
|
||||||
|
onPressed: () {
|
||||||
|
Navigator.of(context).pop();
|
||||||
|
},
|
||||||
|
),
|
||||||
|
CupertinoDialogAction(
|
||||||
|
child: Text(
|
||||||
|
TranslationLoader.lanKeys!.sure!.tr,
|
||||||
|
style: TextStyle(color: AppColors.mainColor),
|
||||||
|
),
|
||||||
|
onPressed: () {
|
||||||
|
state.isCreateUser.value = true;
|
||||||
|
Navigator.of(context).pop();
|
||||||
|
|
||||||
|
sendElectronicKeyRequest(widgetContext);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -217,11 +217,9 @@ class _SendElectronicKeyPageState extends State<SendElectronicKeyPage> {
|
|||||||
children: [
|
children: [
|
||||||
Obx(() => CommonItem(
|
Obx(() => CommonItem(
|
||||||
leftTitel: TranslationLoader.lanKeys!.periodValidity!.tr,
|
leftTitel: TranslationLoader.lanKeys!.periodValidity!.tr,
|
||||||
rightTitle: state.weekdaysList.isEmpty
|
rightTitle: state.weekdaysList.value.isEmpty
|
||||||
? ''
|
? ''
|
||||||
: state.weekdaysList
|
: state.weekdaysList.value.join(','),
|
||||||
.reduce((value, element) => value + ',' + element)
|
|
||||||
.toString(),
|
|
||||||
isHaveDirection: true,
|
isHaveDirection: true,
|
||||||
action: () async {
|
action: () async {
|
||||||
var result = await Navigator.pushNamed(
|
var result = await Navigator.pushNamed(
|
||||||
@ -406,9 +404,9 @@ class _SendElectronicKeyPageState extends State<SendElectronicKeyPage> {
|
|||||||
|
|
||||||
var entity = await ApiRepository.to.setRoomStatusData(
|
var entity = await ApiRepository.to.setRoomStatusData(
|
||||||
lockId: state.keyInfo.value.lockId!,
|
lockId: state.keyInfo.value.lockId!,
|
||||||
roomStatus:1,
|
roomStatus: 1,
|
||||||
);
|
);
|
||||||
if(entity.errorCode!.codeIsSuccessful){
|
if (entity.errorCode!.codeIsSuccessful) {
|
||||||
print("标记为已入住成功啦啦啦啦啦");
|
print("标记为已入住成功啦啦啦啦啦");
|
||||||
Toast.show(msg: "标记成功");
|
Toast.show(msg: "标记成功");
|
||||||
setState(() {});
|
setState(() {});
|
||||||
@ -440,6 +438,8 @@ class _SendElectronicKeyPageState extends State<SendElectronicKeyPage> {
|
|||||||
//不需要输入框下划线
|
//不需要输入框下划线
|
||||||
border: InputBorder.none,
|
border: InputBorder.none,
|
||||||
),
|
),
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: 22.sp, textBaseline: TextBaseline.alphabetic),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
SizedBox(
|
SizedBox(
|
||||||
|
|||||||
@ -86,9 +86,7 @@ class _PasswordKeyListPageState extends State<PasswordKeyListPage> {
|
|||||||
btnName: TranslationLoader.lanKeys!.getPassword!.tr,
|
btnName: TranslationLoader.lanKeys!.getPassword!.tr,
|
||||||
onClick: () {
|
onClick: () {
|
||||||
Navigator.pushNamed(context, Routers.passwordKeyManagePage,
|
Navigator.pushNamed(context, Routers.passwordKeyManagePage,
|
||||||
arguments: {
|
arguments: {"keyInfo": state.keyInfo.value}).then((val) {
|
||||||
"keyInfo": state.keyInfo.value
|
|
||||||
}).then((val) {
|
|
||||||
if (val != null) {
|
if (val != null) {
|
||||||
logic.mockNetworkDataRequest();
|
logic.mockNetworkDataRequest();
|
||||||
}
|
}
|
||||||
@ -143,7 +141,7 @@ class _PasswordKeyListPageState extends State<PasswordKeyListPage> {
|
|||||||
decoration: InputDecoration(
|
decoration: InputDecoration(
|
||||||
//输入里面输入文字内边距设置
|
//输入里面输入文字内边距设置
|
||||||
contentPadding: const EdgeInsets.only(
|
contentPadding: const EdgeInsets.only(
|
||||||
top: 12.0, left: -19.0, right: -15.0, bottom: 8.0),
|
top: 18.0, left: -19.0, right: -15.0, bottom: 2),
|
||||||
hintText: TranslationLoader.lanKeys!.pleaseEnter!.tr,
|
hintText: TranslationLoader.lanKeys!.pleaseEnter!.tr,
|
||||||
hintStyle: TextStyle(fontSize: 22.sp, height: 3.0),
|
hintStyle: TextStyle(fontSize: 22.sp, height: 3.0),
|
||||||
//不需要输入框下划线
|
//不需要输入框下划线
|
||||||
@ -186,13 +184,13 @@ class _PasswordKeyListPageState extends State<PasswordKeyListPage> {
|
|||||||
),
|
),
|
||||||
child: _electronicKeyItem('images/icon_password.png',
|
child: _electronicKeyItem('images/icon_password.png',
|
||||||
passwordKeyListItem.keyboardPwdName!, useDateStr, () {
|
passwordKeyListItem.keyboardPwdName!, useDateStr, () {
|
||||||
Navigator.pushNamed(context, Routers.passwordKeyDetailPage,
|
Navigator.pushNamed(context, Routers.passwordKeyDetailPage,
|
||||||
arguments: {"itemData": passwordKeyListItem}).then((val) {
|
arguments: {"itemData": passwordKeyListItem}).then((val) {
|
||||||
if (val != null) {
|
if (val != null) {
|
||||||
logic.mockNetworkDataRequest();
|
logic.mockNetworkDataRequest();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
return const SizedBox.shrink();
|
return const SizedBox.shrink();
|
||||||
@ -229,7 +227,8 @@ class _PasswordKeyListPageState extends State<PasswordKeyListPage> {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
void showIosTipViewDialog(BuildContext context, PasswordKeyListItem passwordKeyListItem) {
|
void showIosTipViewDialog(
|
||||||
|
BuildContext context, PasswordKeyListItem passwordKeyListItem) {
|
||||||
showDialog(
|
showDialog(
|
||||||
context: context,
|
context: context,
|
||||||
builder: (BuildContext context) {
|
builder: (BuildContext context) {
|
||||||
@ -238,14 +237,14 @@ class _PasswordKeyListPageState extends State<PasswordKeyListPage> {
|
|||||||
tipTitle: "确定要删除吗?",
|
tipTitle: "确定要删除吗?",
|
||||||
sureClick: () {
|
sureClick: () {
|
||||||
Get.back();
|
Get.back();
|
||||||
logic.deletePwdRequest(passwordKeyListItem.lockId.toString(), passwordKeyListItem.keyboardPwdId.toString(), 1);
|
logic.deletePwdRequest(passwordKeyListItem.lockId.toString(),
|
||||||
|
passwordKeyListItem.keyboardPwdId.toString(), 1);
|
||||||
},
|
},
|
||||||
cancelClick: () {
|
cancelClick: () {
|
||||||
Get.back();
|
Get.back();
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
}
|
});
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//使用期限
|
//使用期限
|
||||||
|
|||||||
@ -2,6 +2,9 @@ import 'dart:async';
|
|||||||
|
|
||||||
import 'package:flutter_reactive_ble/flutter_reactive_ble.dart';
|
import 'package:flutter_reactive_ble/flutter_reactive_ble.dart';
|
||||||
import 'package:star_lock/blue/io_type.dart';
|
import 'package:star_lock/blue/io_type.dart';
|
||||||
|
import 'package:star_lock/main/lockDetail/passwordKey/passwordKey_perpetual/passwordKey_perpetual_state.dart';
|
||||||
|
import 'package:star_lock/network/api_repository.dart';
|
||||||
|
import 'package:star_lock/tools/toast.dart';
|
||||||
|
|
||||||
import '../../../../blue/blue_manage.dart';
|
import '../../../../blue/blue_manage.dart';
|
||||||
import '../../../../blue/io_reply.dart';
|
import '../../../../blue/io_reply.dart';
|
||||||
@ -13,6 +16,135 @@ import '../../../../tools/baseGetXController.dart';
|
|||||||
import '../../../../tools/storage.dart';
|
import '../../../../tools/storage.dart';
|
||||||
|
|
||||||
class PasswordKeyPerpetualLogic extends BaseGetXController {
|
class PasswordKeyPerpetualLogic extends BaseGetXController {
|
||||||
|
final PasswordKeyPerpetualState state = PasswordKeyPerpetualState();
|
||||||
|
|
||||||
|
/**
|
||||||
|
单次 1 只能在开始时间后6小时内使用一次
|
||||||
|
永久 2 从开始时间开始永久有效,必需在开始时间24小时内使用一次,否则将失效
|
||||||
|
限期 3 在开始和结束时间内有效,必需在开始时间24小时内使用一次,否则将失效
|
||||||
|
删除 4 在锁上使用后会删除之前在锁上使用过的密码
|
||||||
|
周未循环 5 在周未开始和结束时间指定时间段内有效
|
||||||
|
每日循环 6 每天开始和结束时间指定时间段内有效
|
||||||
|
工作日循环 7 工作日开始和结束时间指定的时间段内有效
|
||||||
|
周一循环 8 每周一开始和结束时间指定时间段内有效
|
||||||
|
周二循环 9 每周二开始和结束时间指定时间段内有效
|
||||||
|
周三循环 10 每周三开始和结束时间指定时间段内有效
|
||||||
|
周四循环 11 每周四开始和结束时间指定时间段内有效
|
||||||
|
周五循环 12 每周五开始和结束时间指定时间段内有效
|
||||||
|
周六循环 13 每周六开始和结束时间指定时间段内有效
|
||||||
|
周天循环 14 每周日开始和结束时间指定时间段内有效
|
||||||
|
*/
|
||||||
|
//获取密码请求
|
||||||
|
Future<void> getKeyboardPwdRequest() async {
|
||||||
|
String getFailureDateTime = '0';
|
||||||
|
String getEffectiveDateTime = '0';
|
||||||
|
String lockId = state.keyInfo.value.lockId.toString();
|
||||||
|
int passwordType = int.parse(state.widgetType.value);
|
||||||
|
String getKeyType = passwordType.toString();
|
||||||
|
if (passwordType == 0) {
|
||||||
|
//永久
|
||||||
|
getKeyType = '2';
|
||||||
|
} else if (passwordType == 1) {
|
||||||
|
//限时
|
||||||
|
getKeyType = '3';
|
||||||
|
} else if (passwordType == 2) {
|
||||||
|
//单次
|
||||||
|
getKeyType = '1';
|
||||||
|
} else if (passwordType == 3) {
|
||||||
|
//自定义
|
||||||
|
} else if (passwordType == 4) {
|
||||||
|
//循环
|
||||||
|
if (state.cyclicModeStr.value == '每日') {
|
||||||
|
getKeyType = '6';
|
||||||
|
} else if (state.cyclicModeStr.value == '工作日') {
|
||||||
|
getKeyType = '7';
|
||||||
|
} else if (state.cyclicModeStr.value == '星期一') {
|
||||||
|
getKeyType = '8';
|
||||||
|
} else if (state.cyclicModeStr.value == '星期二') {
|
||||||
|
getKeyType = '9';
|
||||||
|
} else if (state.cyclicModeStr.value == '星期三') {
|
||||||
|
getKeyType = '10';
|
||||||
|
} else if (state.cyclicModeStr.value == '星期四') {
|
||||||
|
getKeyType = '11';
|
||||||
|
} else if (state.cyclicModeStr.value == '星期五') {
|
||||||
|
getKeyType = '12';
|
||||||
|
} else if (state.cyclicModeStr.value == '星期六') {
|
||||||
|
getKeyType = '13';
|
||||||
|
} else if (state.cyclicModeStr.value == '星期日') {
|
||||||
|
getKeyType = '14';
|
||||||
|
}
|
||||||
|
} else if (passwordType == 5) {
|
||||||
|
//清空码
|
||||||
|
getKeyType = '4';
|
||||||
|
}
|
||||||
|
if (state.widgetType.value != '0' &&
|
||||||
|
state.widgetType.value != '2' &&
|
||||||
|
state.widgetType.value != '5') {
|
||||||
|
getFailureDateTime =
|
||||||
|
state.failureDateTime.value.millisecondsSinceEpoch.toString();
|
||||||
|
getEffectiveDateTime =
|
||||||
|
state.effectiveDateTime.value.millisecondsSinceEpoch.toString();
|
||||||
|
}
|
||||||
|
var entity = await ApiRepository.to.getPasswordKey(
|
||||||
|
getFailureDateTime,
|
||||||
|
'0',
|
||||||
|
state.nameController.text,
|
||||||
|
getKeyType,
|
||||||
|
'0',
|
||||||
|
lockId,
|
||||||
|
'0',
|
||||||
|
getEffectiveDateTime,
|
||||||
|
'0',
|
||||||
|
state.startHours.value,
|
||||||
|
state.endHours.value,
|
||||||
|
1);
|
||||||
|
if (entity.errorCode!.codeIsSuccessful) {
|
||||||
|
print('获取密码成功');
|
||||||
|
state.isSendSuccess.value = true;
|
||||||
|
if (entity.data != null) {
|
||||||
|
state.getPwdStr.value = entity.data!.keyboardPwd!;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
Toast.show(msg: '${entity.errorMsg}');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//自定义密码请求
|
||||||
|
Future<void> addKeyboardPwdRequest() async {
|
||||||
|
String getFailureDateTime = '0';
|
||||||
|
String getEffectiveDateTime = '0';
|
||||||
|
String lockId = state.keyInfo.value.lockId.toString();
|
||||||
|
String getKeyType = '3';
|
||||||
|
//是否为永久
|
||||||
|
if (state.isPermanent.value == false) {
|
||||||
|
getKeyType = '3';
|
||||||
|
getFailureDateTime = DateTime.parse(state.selectFailureDate.value)
|
||||||
|
.millisecondsSinceEpoch
|
||||||
|
.toString();
|
||||||
|
getEffectiveDateTime = DateTime.parse(state.selectEffectiveDate.value)
|
||||||
|
.millisecondsSinceEpoch
|
||||||
|
.toString();
|
||||||
|
} else {
|
||||||
|
getKeyType = '2';
|
||||||
|
}
|
||||||
|
var entity = await ApiRepository.to.addPasswordKey(
|
||||||
|
lockId,
|
||||||
|
state.nameController.text,
|
||||||
|
state.pwdController.text,
|
||||||
|
getKeyType,
|
||||||
|
getEffectiveDateTime,
|
||||||
|
getFailureDateTime,
|
||||||
|
'0');
|
||||||
|
if (entity.errorCode!.codeIsSuccessful) {
|
||||||
|
print('获取密码成功');
|
||||||
|
state.isSendSuccess.value = true;
|
||||||
|
if (entity.data != null) {
|
||||||
|
state.getPwdStr.value = entity.data!.keyboardPwd!;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
Toast.show(msg: '${entity.errorMsg}');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
late DateTime getStartDateTime;
|
late DateTime getStartDateTime;
|
||||||
// 监听设备返回的数据
|
// 监听设备返回的数据
|
||||||
|
|||||||
@ -35,23 +35,23 @@ class PasswordKeyPerpetualPage extends StatefulWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class _PasswordKeyPerpetualPageState extends State<PasswordKeyPerpetualPage> {
|
class _PasswordKeyPerpetualPageState extends State<PasswordKeyPerpetualPage> {
|
||||||
final TextEditingController _nameController = TextEditingController();
|
|
||||||
final TextEditingController _pwdController = TextEditingController();
|
|
||||||
final logic = Get.put(PasswordKeyPerpetualLogic());
|
final logic = Get.put(PasswordKeyPerpetualLogic());
|
||||||
|
final state = Get.find<PasswordKeyPerpetualLogic>().state;
|
||||||
|
|
||||||
static const methodChannel = MethodChannel('talkPlugin');
|
static const methodChannel = MethodChannel('talkPlugin');
|
||||||
|
|
||||||
late bool _isSendSuccess; //是否发送成功
|
// late bool _isSendSuccess; //是否发送成功
|
||||||
late bool _isPermanent; //是否永久
|
// late bool _isPermanent; //是否永久
|
||||||
late String _getPwdStr;
|
// late String _getPwdStr;
|
||||||
String _selectEffectiveDate = ''; //生效时间
|
// String _selectEffectiveDate = ''; //生效时间
|
||||||
String _selectFailureDate = ''; //失效时间
|
// String _selectFailureDate = ''; //失效时间
|
||||||
late DateTime _effectiveDateTime;
|
// late DateTime _effectiveDateTime;
|
||||||
late DateTime _failureDateTime;
|
// late DateTime _failureDateTime;
|
||||||
late String cyclicModeStr; //循环模式
|
// late String cyclicModeStr; //循环模式
|
||||||
late String effectiveHourStr;
|
// late String effectiveHourStr;
|
||||||
late String failureHourStr;
|
// late String failureHourStr;
|
||||||
int startHours = 0;
|
// int startHours = 0;
|
||||||
int endHours = 0;
|
// int endHours = 0;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
@ -64,37 +64,56 @@ class _PasswordKeyPerpetualPageState extends State<PasswordKeyPerpetualPage> {
|
|||||||
void initState() {
|
void initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
|
|
||||||
_isSendSuccess = false;
|
state.keyInfo.value = widget.getKeyInfo;
|
||||||
_isPermanent = false;
|
state.widgetType.value = widget.type;
|
||||||
DateTime dateTime = DateTime.now();
|
|
||||||
_effectiveDateTime = dateTime;
|
|
||||||
_failureDateTime = dateTime;
|
|
||||||
if (int.parse(widget.type) == 4) {
|
|
||||||
cyclicModeStr = '周末';
|
|
||||||
|
|
||||||
_selectEffectiveDate = "${formatDate(dateTime, [HH])}:00"; //默认为当前时间
|
// _isSendSuccess = false;
|
||||||
_selectFailureDate = "${formatDate(dateTime, [HH])}:00"; //默认为当前时间
|
// _isPermanent = false;
|
||||||
startHours = _effectiveDateTime.hour;
|
DateTime dateTime = DateTime.now();
|
||||||
endHours = _failureDateTime.hour;
|
// _effectiveDateTime = dateTime;
|
||||||
} else if (int.parse(widget.type) == 3) {
|
// _failureDateTime = dateTime;
|
||||||
|
if (int.parse(state.widgetType.value) == 4) {
|
||||||
|
state.cyclicModeStr.value = '周末';
|
||||||
|
|
||||||
|
state.selectEffectiveDate.value =
|
||||||
|
"${formatDate(dateTime, [HH])}:00"; //默认为当前时间
|
||||||
|
state.selectFailureDate.value =
|
||||||
|
"${formatDate(dateTime, [HH])}:00"; //默认为当前时间
|
||||||
|
state.startHours.value = state.effectiveDateTime.value.hour;
|
||||||
|
state.endHours.value = state.failureDateTime.value.hour;
|
||||||
|
} else if (int.parse(state.widgetType.value) == 3) {
|
||||||
// 自定义
|
// 自定义
|
||||||
_selectEffectiveDate = formatDate(
|
state.selectEffectiveDate.value = formatDate(
|
||||||
dateTime, [yyyy, '-', mm, '-', dd, ' ', HH, ':', nn]); //默认为当前时间
|
dateTime, [yyyy, '-', mm, '-', dd, ' ', HH, ':', nn]); //默认为当前时间
|
||||||
_selectFailureDate = formatDate(
|
state.selectFailureDate.value = formatDate(
|
||||||
dateTime, [yyyy, '-', mm, '-', dd, ' ', HH, ':', nn]); //默认为当前时间
|
dateTime, [yyyy, '-', mm, '-', dd, ' ', HH, ':', nn]); //默认为当前时间
|
||||||
} else {
|
} else {
|
||||||
_selectEffectiveDate = "${formatDate(
|
state.selectEffectiveDate.value = "${formatDate(dateTime, [
|
||||||
dateTime, [yyyy, '-', mm, '-', dd, ' ', HH])}:00"; //默认为当前时间
|
yyyy,
|
||||||
_selectFailureDate = "${formatDate(
|
'-',
|
||||||
dateTime, [yyyy, '-', mm, '-', dd, ' ', HH])}:00"; //默认为当前时间
|
mm,
|
||||||
|
'-',
|
||||||
|
dd,
|
||||||
|
' ',
|
||||||
|
HH
|
||||||
|
])}:00"; //默认为当前时间
|
||||||
|
state.selectFailureDate.value = "${formatDate(dateTime, [
|
||||||
|
yyyy,
|
||||||
|
'-',
|
||||||
|
mm,
|
||||||
|
'-',
|
||||||
|
dd,
|
||||||
|
' ',
|
||||||
|
HH
|
||||||
|
])}:00"; //默认为当前时间
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget indexChangeWidget() {
|
Widget indexChangeWidget() {
|
||||||
if (_isSendSuccess) {
|
if (state.isSendSuccess.value) {
|
||||||
return sendElectronicKeySucceed();
|
return sendElectronicKeySucceed();
|
||||||
} else {
|
} else {
|
||||||
switch (int.parse(widget.type)) {
|
switch (int.parse(state.widgetType.value)) {
|
||||||
case 0:
|
case 0:
|
||||||
{
|
{
|
||||||
// 永久
|
// 永久
|
||||||
@ -103,7 +122,7 @@ class _PasswordKeyPerpetualPageState extends State<PasswordKeyPerpetualPage> {
|
|||||||
perpetualKeyWidget(
|
perpetualKeyWidget(
|
||||||
TranslationLoader.lanKeys!.name!.tr,
|
TranslationLoader.lanKeys!.name!.tr,
|
||||||
TranslationLoader.lanKeys!.pleaseNameYourPassword!.tr,
|
TranslationLoader.lanKeys!.pleaseNameYourPassword!.tr,
|
||||||
_nameController),
|
state.nameController),
|
||||||
keyBottomWidget(TranslationLoader.lanKeys!.getPasswordTip1!.tr)
|
keyBottomWidget(TranslationLoader.lanKeys!.getPasswordTip1!.tr)
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
@ -117,7 +136,7 @@ class _PasswordKeyPerpetualPageState extends State<PasswordKeyPerpetualPage> {
|
|||||||
perpetualKeyWidget(
|
perpetualKeyWidget(
|
||||||
TranslationLoader.lanKeys!.name!.tr,
|
TranslationLoader.lanKeys!.name!.tr,
|
||||||
TranslationLoader.lanKeys!.pleaseNameYourPassword!.tr,
|
TranslationLoader.lanKeys!.pleaseNameYourPassword!.tr,
|
||||||
_nameController),
|
state.nameController),
|
||||||
keyBottomWidget(TranslationLoader.lanKeys!.getPasswordTip2!.tr)
|
keyBottomWidget(TranslationLoader.lanKeys!.getPasswordTip2!.tr)
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
@ -130,7 +149,7 @@ class _PasswordKeyPerpetualPageState extends State<PasswordKeyPerpetualPage> {
|
|||||||
perpetualKeyWidget(
|
perpetualKeyWidget(
|
||||||
TranslationLoader.lanKeys!.name!.tr,
|
TranslationLoader.lanKeys!.name!.tr,
|
||||||
TranslationLoader.lanKeys!.pleaseNameYourPassword!.tr,
|
TranslationLoader.lanKeys!.pleaseNameYourPassword!.tr,
|
||||||
_nameController),
|
state.nameController),
|
||||||
keyBottomWidget(TranslationLoader.lanKeys!.getPasswordTip3!.tr)
|
keyBottomWidget(TranslationLoader.lanKeys!.getPasswordTip3!.tr)
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
@ -141,13 +160,15 @@ class _PasswordKeyPerpetualPageState extends State<PasswordKeyPerpetualPage> {
|
|||||||
return Column(
|
return Column(
|
||||||
children: [
|
children: [
|
||||||
keyIfPerpetualWidget(),
|
keyIfPerpetualWidget(),
|
||||||
_isPermanent == false ? keyTimeLimitWidget() : Container(),
|
state.isPermanent.value == false
|
||||||
|
? keyTimeLimitWidget()
|
||||||
|
: Container(),
|
||||||
perpetualKeyWidget(
|
perpetualKeyWidget(
|
||||||
TranslationLoader.lanKeys!.name!.tr,
|
TranslationLoader.lanKeys!.name!.tr,
|
||||||
TranslationLoader.lanKeys!.pleaseNameYourPassword!.tr,
|
TranslationLoader.lanKeys!.pleaseNameYourPassword!.tr,
|
||||||
_nameController),
|
state.nameController),
|
||||||
perpetualKeyWidget(TranslationLoader.lanKeys!.password!.tr,
|
perpetualKeyWidget(TranslationLoader.lanKeys!.password!.tr,
|
||||||
"请输入6-9位数字", _pwdController),
|
"请输入6-9位数字", state.pwdController),
|
||||||
keyBottomWidget(TranslationLoader.lanKeys!.getPasswordTip4!.tr)
|
keyBottomWidget(TranslationLoader.lanKeys!.getPasswordTip4!.tr)
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
@ -161,7 +182,7 @@ class _PasswordKeyPerpetualPageState extends State<PasswordKeyPerpetualPage> {
|
|||||||
perpetualKeyWidget(
|
perpetualKeyWidget(
|
||||||
TranslationLoader.lanKeys!.name!.tr,
|
TranslationLoader.lanKeys!.name!.tr,
|
||||||
TranslationLoader.lanKeys!.pleaseNameYourPassword!.tr,
|
TranslationLoader.lanKeys!.pleaseNameYourPassword!.tr,
|
||||||
_nameController),
|
state.nameController),
|
||||||
keyBottomWidget(TranslationLoader.lanKeys!.getPasswordTip5!.tr)
|
keyBottomWidget(TranslationLoader.lanKeys!.getPasswordTip5!.tr)
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
@ -174,7 +195,7 @@ class _PasswordKeyPerpetualPageState extends State<PasswordKeyPerpetualPage> {
|
|||||||
perpetualKeyWidget(
|
perpetualKeyWidget(
|
||||||
TranslationLoader.lanKeys!.name!.tr,
|
TranslationLoader.lanKeys!.name!.tr,
|
||||||
TranslationLoader.lanKeys!.pleaseNameYourPassword!.tr,
|
TranslationLoader.lanKeys!.pleaseNameYourPassword!.tr,
|
||||||
_nameController),
|
state.nameController),
|
||||||
keyBottomWidget(TranslationLoader.lanKeys!.getPasswordTip6!.tr)
|
keyBottomWidget(TranslationLoader.lanKeys!.getPasswordTip6!.tr)
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
@ -206,60 +227,61 @@ class _PasswordKeyPerpetualPageState extends State<PasswordKeyPerpetualPage> {
|
|||||||
|
|
||||||
// 限时顶部选择日期
|
// 限时顶部选择日期
|
||||||
Widget keyTimeLimitWidget() {
|
Widget keyTimeLimitWidget() {
|
||||||
return Container(
|
return Column(
|
||||||
// margin: EdgeInsets.only(left: 20.w, right: 20.w),
|
children: [
|
||||||
child: Column(
|
CommonItem(
|
||||||
children: [
|
leftTitel: TranslationLoader.lanKeys!.effectiveTime!.tr,
|
||||||
CommonItem(
|
rightTitle: state.selectEffectiveDate.value,
|
||||||
leftTitel: TranslationLoader.lanKeys!.effectiveTime!.tr,
|
isHaveLine: true,
|
||||||
rightTitle: _selectEffectiveDate,
|
isHaveDirection: true,
|
||||||
isHaveLine: true,
|
action: () {
|
||||||
isHaveDirection: true,
|
Pickers.showDatePicker(context, mode: DateMode.YMDHM,
|
||||||
action: () {
|
onConfirm: (p) {
|
||||||
Pickers.showDatePicker(context, mode: DateMode.YMDHM,
|
setState(() {
|
||||||
onConfirm: (p) {
|
if (int.parse(state.widgetType.value) == 3) {
|
||||||
setState(() {
|
// 自定义
|
||||||
if (int.parse(widget.type) == 3) {
|
state.effectiveDateTime.value = DateTime.parse(
|
||||||
// 自定义
|
'${p.year}-${intToStr(p.month!)}-${intToStr(p.day!)} ${intToStr(p.hour!)}:${intToStr(p.minute!)}');
|
||||||
_effectiveDateTime = DateTime.parse(
|
state.selectEffectiveDate.value = formatDate(
|
||||||
'${p.year}-${intToStr(p.month!)}-${intToStr(p.day!)} ${intToStr(p.hour!)}:${intToStr(p.minute!)}');
|
state.effectiveDateTime.value,
|
||||||
_selectEffectiveDate = formatDate(_effectiveDateTime,
|
[yyyy, '-', mm, '-', dd, ' ', HH, ':', nn]); //默认为当前时间
|
||||||
[yyyy, '-', mm, '-', dd, ' ', HH, ':', nn]); //默认为当前时间
|
} else {
|
||||||
} else {
|
state.effectiveDateTime.value = DateTime.parse(
|
||||||
_effectiveDateTime = DateTime.parse(
|
'${p.year}-${intToStr(p.month!)}-${intToStr(p.day!)} ${intToStr(p.hour!)}');
|
||||||
'${p.year}-${intToStr(p.month!)}-${intToStr(p.day!)} ${intToStr(p.hour!)}');
|
state.selectEffectiveDate.value = formatDate(
|
||||||
_selectEffectiveDate = "${formatDate(_effectiveDateTime,
|
state.effectiveDateTime.value,
|
||||||
[yyyy, '-', mm, '-', dd, ' ', HH, ':', nn])}00"; //默认为当前时间
|
[yyyy, '-', mm, '-', dd, ' ', HH, ':', nn]); //默认为当前时间
|
||||||
}
|
}
|
||||||
});
|
|
||||||
});
|
});
|
||||||
}),
|
});
|
||||||
CommonItem(
|
}),
|
||||||
leftTitel: TranslationLoader.lanKeys!.failureTime!.tr,
|
CommonItem(
|
||||||
rightTitle: _selectFailureDate,
|
leftTitel: TranslationLoader.lanKeys!.failureTime!.tr,
|
||||||
isHaveDirection: true,
|
rightTitle: state.selectFailureDate.value,
|
||||||
action: () {
|
isHaveDirection: true,
|
||||||
Pickers.showDatePicker(context, mode: DateMode.YMDHM,
|
action: () {
|
||||||
onConfirm: (p) {
|
Pickers.showDatePicker(context, mode: DateMode.YMDHM,
|
||||||
setState(() {
|
onConfirm: (p) {
|
||||||
if (int.parse(widget.type) == 3) {
|
setState(() {
|
||||||
// 自定义
|
if (int.parse(state.widgetType.value) == 3) {
|
||||||
_failureDateTime = DateTime.parse(
|
// 自定义
|
||||||
'${p.year}-${intToStr(p.month!)}-${intToStr(p.day!)} ${intToStr(p.hour!)}:${intToStr(p.minute!)}');
|
state.failureDateTime.value = DateTime.parse(
|
||||||
_selectFailureDate = formatDate(_failureDateTime,
|
'${p.year}-${intToStr(p.month!)}-${intToStr(p.day!)} ${intToStr(p.hour!)}:${intToStr(p.minute!)}');
|
||||||
[yyyy, '-', mm, '-', dd, ' ', HH, ':', nn]); //默认为当前时间
|
state.selectFailureDate.value = formatDate(
|
||||||
} else {
|
state.failureDateTime.value,
|
||||||
_failureDateTime = DateTime.parse(
|
[yyyy, '-', mm, '-', dd, ' ', HH, ':', nn]); //默认为当前时间
|
||||||
'${p.year}-${intToStr(p.month!)}-${intToStr(p.day!)} ${intToStr(p.hour!)}');
|
} else {
|
||||||
_selectFailureDate = "${formatDate(_failureDateTime,
|
state.failureDateTime.value = DateTime.parse(
|
||||||
[yyyy, '-', mm, '-', dd, ' ', HH])}:00";
|
'${p.year}-${intToStr(p.month!)}-${intToStr(p.day!)} ${intToStr(p.hour!)}');
|
||||||
}
|
state.selectFailureDate.value = formatDate(
|
||||||
});
|
state.failureDateTime.value,
|
||||||
|
[yyyy, '-', mm, '-', dd, ' ', HH]);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}),
|
});
|
||||||
Container(height: 10.h),
|
}),
|
||||||
],
|
Container(height: 10.h),
|
||||||
),
|
],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -276,7 +298,7 @@ class _PasswordKeyPerpetualPageState extends State<PasswordKeyPerpetualPage> {
|
|||||||
rightWidget:
|
rightWidget:
|
||||||
SizedBox(width: 60.w, height: 50.h, child: _switch()),
|
SizedBox(width: 60.w, height: 50.h, child: _switch()),
|
||||||
action: () {}),
|
action: () {}),
|
||||||
_isPermanent == true
|
state.isPermanent.value == true
|
||||||
? Container(height: 10.h)
|
? Container(height: 10.h)
|
||||||
: Container(height: 1.h),
|
: Container(height: 1.h),
|
||||||
],
|
],
|
||||||
@ -286,72 +308,70 @@ class _PasswordKeyPerpetualPageState extends State<PasswordKeyPerpetualPage> {
|
|||||||
|
|
||||||
// 循环
|
// 循环
|
||||||
Widget keyCirculationWidget() {
|
Widget keyCirculationWidget() {
|
||||||
return Container(
|
return Column(
|
||||||
// margin: EdgeInsets.only(left: 20.w, right: 20.w),
|
children: [
|
||||||
child: Column(
|
CommonItem(
|
||||||
children: [
|
leftTitel: TranslationLoader.lanKeys!.recursiveDevice!.tr,
|
||||||
CommonItem(
|
rightTitle: state.cyclicModeStr.value,
|
||||||
leftTitel: TranslationLoader.lanKeys!.recursiveDevice!.tr,
|
isHaveLine: true,
|
||||||
rightTitle: cyclicModeStr,
|
isHaveDirection: true,
|
||||||
isHaveLine: true,
|
action: () {
|
||||||
isHaveDirection: true,
|
List<String> pickerDataList = [
|
||||||
action: () {
|
'周末',
|
||||||
List<String> pickerDataList = [
|
'每日',
|
||||||
'周末',
|
'工作日',
|
||||||
'每日',
|
'星期一',
|
||||||
'工作日',
|
'星期二',
|
||||||
'星期一',
|
'星期三',
|
||||||
'星期二',
|
'星期四',
|
||||||
'星期三',
|
'星期五',
|
||||||
'星期四',
|
'星期六',
|
||||||
'星期五',
|
'星期日'
|
||||||
'星期六',
|
];
|
||||||
'星期日'
|
showPickerView(context, pickerDataList);
|
||||||
];
|
}),
|
||||||
showPickerView(context, pickerDataList);
|
CommonItem(
|
||||||
}),
|
leftTitel: TranslationLoader.lanKeys!.effectiveTime!.tr,
|
||||||
CommonItem(
|
rightTitle: state.selectEffectiveDate.value,
|
||||||
leftTitel: TranslationLoader.lanKeys!.effectiveTime!.tr,
|
isHaveLine: true,
|
||||||
rightTitle: _selectEffectiveDate,
|
isHaveDirection: true,
|
||||||
isHaveLine: true,
|
action: () {
|
||||||
isHaveDirection: true,
|
Pickers.showDatePicker(context, mode: DateMode.H, onConfirm: (p) {
|
||||||
action: () {
|
setState(() {
|
||||||
Pickers.showDatePicker(context, mode: DateMode.H,
|
state.effectiveDateTime.value = DateTime.parse(
|
||||||
onConfirm: (p) {
|
'${state.effectiveDateTime.value.year}-${intToStr(state.effectiveDateTime.value.month)}-${intToStr(state.effectiveDateTime.value.day)} ${intToStr(p.hour!)}:${intToStr(p.minute!)}');
|
||||||
setState(() {
|
state.selectEffectiveDate.value =
|
||||||
_effectiveDateTime = DateTime.parse(
|
formatDate(state.effectiveDateTime.value, [HH, ':', nn]);
|
||||||
'${_effectiveDateTime.year}-${intToStr(_effectiveDateTime.month)}-${intToStr(_effectiveDateTime.day)} ${intToStr(p.hour!)}:${intToStr(p.minute!)}');
|
state.startHours.value = p.hour!;
|
||||||
_selectEffectiveDate =
|
|
||||||
formatDate(_effectiveDateTime, [HH, ':', nn]);
|
|
||||||
startHours = p.hour!;
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
}),
|
});
|
||||||
CommonItem(
|
}),
|
||||||
leftTitel: TranslationLoader.lanKeys!.failureTime!.tr,
|
CommonItem(
|
||||||
rightTitle: _selectFailureDate,
|
leftTitel: TranslationLoader.lanKeys!.failureTime!.tr,
|
||||||
isHaveDirection: true,
|
rightTitle: state.selectFailureDate.value,
|
||||||
action: () {
|
isHaveDirection: true,
|
||||||
Pickers.showDatePicker(context, mode: DateMode.H, onConfirm: (p) {
|
action: () {
|
||||||
setState(() {
|
Pickers.showDatePicker(context, mode: DateMode.H, onConfirm: (p) {
|
||||||
_failureDateTime = DateTime.parse(
|
setState(() {
|
||||||
'${_failureDateTime.year}-${intToStr(_failureDateTime.month)}-${intToStr(_failureDateTime.day)} ${intToStr(p.hour!)}:${intToStr(p.minute!)}');
|
state.failureDateTime.value = DateTime.parse(
|
||||||
_selectFailureDate =
|
'${state.failureDateTime.value.year}-${intToStr(state.failureDateTime.value.month)}-${intToStr(state.failureDateTime.value.day)} ${intToStr(p.hour!)}:${intToStr(p.minute!)}');
|
||||||
formatDate(_failureDateTime, [HH, ':', nn]);
|
state.selectFailureDate.value =
|
||||||
endHours = p.hour!;
|
formatDate(state.failureDateTime.value, [HH, ':', nn]);
|
||||||
});
|
state.endHours.value = p.hour!;
|
||||||
});
|
});
|
||||||
}),
|
});
|
||||||
],
|
}),
|
||||||
),
|
],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
//底部选择pickerView
|
//底部选择pickerView
|
||||||
showPickerView(BuildContext context, List dataList) {
|
showPickerView(BuildContext context, List dataList) {
|
||||||
Pickers.showSinglePicker(context, data: dataList, pickerStyle: DefaultPickerStyle(), onConfirm: (p, position) {
|
Pickers.showSinglePicker(context,
|
||||||
|
data: dataList,
|
||||||
|
pickerStyle: DefaultPickerStyle(), onConfirm: (p, position) {
|
||||||
setState(() {
|
setState(() {
|
||||||
cyclicModeStr = p;
|
state.cyclicModeStr.value = p;
|
||||||
});
|
});
|
||||||
}, onChanged: (p, position) {
|
}, onChanged: (p, position) {
|
||||||
setState(() {});
|
setState(() {});
|
||||||
@ -405,18 +425,18 @@ class _PasswordKeyPerpetualPageState extends State<PasswordKeyPerpetualPage> {
|
|||||||
*/
|
*/
|
||||||
var isDemoMode = await Storage.getBool(ifIsDemoModeOrNot);
|
var isDemoMode = await Storage.getBool(ifIsDemoModeOrNot);
|
||||||
if (isDemoMode == false) {
|
if (isDemoMode == false) {
|
||||||
if (_nameController.text.isNotEmpty) {
|
if (state.nameController.text.isNotEmpty) {
|
||||||
logic.getStartDate(_effectiveDateTime);
|
logic.getStartDate(state.effectiveDateTime.value);
|
||||||
int passwordType = int.parse(widget.type);
|
int passwordType = int.parse(state.widgetType.value);
|
||||||
if (passwordType == 3) {
|
if (passwordType == 3) {
|
||||||
if (_pwdController.text.isNotEmpty) {
|
if (state.pwdController.text.isNotEmpty) {
|
||||||
//自定义密码
|
//自定义密码
|
||||||
addKeyboardPwdRequest();
|
logic.addKeyboardPwdRequest();
|
||||||
} else {
|
} else {
|
||||||
Toast.show(msg: '请输入密码');
|
Toast.show(msg: '请输入密码');
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
getKeyboardPwdRequest();
|
logic.getKeyboardPwdRequest();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Toast.show(msg: '请给密码命名');
|
Toast.show(msg: '请给密码命名');
|
||||||
@ -429,132 +449,6 @@ class _PasswordKeyPerpetualPageState extends State<PasswordKeyPerpetualPage> {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
单次 1 只能在开始时间后6小时内使用一次
|
|
||||||
永久 2 从开始时间开始永久有效,必需在开始时间24小时内使用一次,否则将失效
|
|
||||||
限期 3 在开始和结束时间内有效,必需在开始时间24小时内使用一次,否则将失效
|
|
||||||
删除 4 在锁上使用后会删除之前在锁上使用过的密码
|
|
||||||
周未循环 5 在周未开始和结束时间指定时间段内有效
|
|
||||||
每日循环 6 每天开始和结束时间指定时间段内有效
|
|
||||||
工作日循环 7 工作日开始和结束时间指定的时间段内有效
|
|
||||||
周一循环 8 每周一开始和结束时间指定时间段内有效
|
|
||||||
周二循环 9 每周二开始和结束时间指定时间段内有效
|
|
||||||
周三循环 10 每周三开始和结束时间指定时间段内有效
|
|
||||||
周四循环 11 每周四开始和结束时间指定时间段内有效
|
|
||||||
周五循环 12 每周五开始和结束时间指定时间段内有效
|
|
||||||
周六循环 13 每周六开始和结束时间指定时间段内有效
|
|
||||||
周天循环 14 每周日开始和结束时间指定时间段内有效
|
|
||||||
*/
|
|
||||||
//获取密码请求
|
|
||||||
Future<void> getKeyboardPwdRequest() async {
|
|
||||||
String getFailureDateTime = '0';
|
|
||||||
String getEffectiveDateTime = '0';
|
|
||||||
String lockId = widget.getKeyInfo.lockId.toString();
|
|
||||||
int passwordType = int.parse(widget.type);
|
|
||||||
String getKeyType = passwordType.toString();
|
|
||||||
if (passwordType == 0) {
|
|
||||||
//永久
|
|
||||||
getKeyType = '2';
|
|
||||||
} else if (passwordType == 1) {
|
|
||||||
//限时
|
|
||||||
getKeyType = '3';
|
|
||||||
} else if (passwordType == 2) {
|
|
||||||
//单次
|
|
||||||
getKeyType = '1';
|
|
||||||
} else if (passwordType == 3) {
|
|
||||||
//自定义
|
|
||||||
} else if (passwordType == 4) {
|
|
||||||
//循环
|
|
||||||
if (cyclicModeStr == '每日') {
|
|
||||||
getKeyType = '6';
|
|
||||||
} else if (cyclicModeStr == '工作日') {
|
|
||||||
getKeyType = '7';
|
|
||||||
} else if (cyclicModeStr == '星期一') {
|
|
||||||
getKeyType = '8';
|
|
||||||
} else if (cyclicModeStr == '星期二') {
|
|
||||||
getKeyType = '9';
|
|
||||||
} else if (cyclicModeStr == '星期三') {
|
|
||||||
getKeyType = '10';
|
|
||||||
} else if (cyclicModeStr == '星期四') {
|
|
||||||
getKeyType = '11';
|
|
||||||
} else if (cyclicModeStr == '星期五') {
|
|
||||||
getKeyType = '12';
|
|
||||||
} else if (cyclicModeStr == '星期六') {
|
|
||||||
getKeyType = '13';
|
|
||||||
} else if (cyclicModeStr == '星期日') {
|
|
||||||
getKeyType = '14';
|
|
||||||
}
|
|
||||||
} else if (passwordType == 5) {
|
|
||||||
//清空码
|
|
||||||
getKeyType = '4';
|
|
||||||
}
|
|
||||||
if (widget.type != '0' && widget.type != '2' && widget.type != '5') {
|
|
||||||
getFailureDateTime = _failureDateTime.millisecondsSinceEpoch.toString();
|
|
||||||
getEffectiveDateTime =
|
|
||||||
_effectiveDateTime.millisecondsSinceEpoch.toString();
|
|
||||||
}
|
|
||||||
var entity = await ApiRepository.to.getPasswordKey(
|
|
||||||
getFailureDateTime,
|
|
||||||
'0',
|
|
||||||
_nameController.text,
|
|
||||||
getKeyType,
|
|
||||||
'0',
|
|
||||||
lockId,
|
|
||||||
'0',
|
|
||||||
getEffectiveDateTime,
|
|
||||||
'0',
|
|
||||||
startHours,
|
|
||||||
endHours,
|
|
||||||
1);
|
|
||||||
if (entity.errorCode!.codeIsSuccessful) {
|
|
||||||
print('获取密码成功');
|
|
||||||
_isSendSuccess = true;
|
|
||||||
if (entity.data != null) {
|
|
||||||
_getPwdStr = entity.data!.keyboardPwd!;
|
|
||||||
setState(() {});
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
Toast.show(msg: '${entity.errorMsg}');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//自定义密码请求
|
|
||||||
Future<void> addKeyboardPwdRequest() async {
|
|
||||||
String getFailureDateTime = '0';
|
|
||||||
String getEffectiveDateTime = '0';
|
|
||||||
String lockId = widget.getKeyInfo.lockId.toString();
|
|
||||||
String getKeyType = '3';
|
|
||||||
//是否为永久
|
|
||||||
if (_isPermanent == false) {
|
|
||||||
getKeyType = '3';
|
|
||||||
getFailureDateTime =
|
|
||||||
DateTime.parse(_selectFailureDate).millisecondsSinceEpoch.toString();
|
|
||||||
getEffectiveDateTime = DateTime.parse(_selectEffectiveDate)
|
|
||||||
.millisecondsSinceEpoch
|
|
||||||
.toString();
|
|
||||||
} else {
|
|
||||||
getKeyType = '2';
|
|
||||||
}
|
|
||||||
var entity = await ApiRepository.to.addPasswordKey(
|
|
||||||
lockId,
|
|
||||||
_nameController.text,
|
|
||||||
_pwdController.text,
|
|
||||||
getKeyType,
|
|
||||||
getEffectiveDateTime,
|
|
||||||
getFailureDateTime,
|
|
||||||
'0');
|
|
||||||
if (entity.errorCode!.codeIsSuccessful) {
|
|
||||||
print('获取密码成功');
|
|
||||||
_isSendSuccess = true;
|
|
||||||
if (entity.data != null) {
|
|
||||||
_getPwdStr = entity.data!.keyboardPwd!;
|
|
||||||
setState(() {});
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
Toast.show(msg: '${entity.errorMsg}');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// 发送电子钥匙成功
|
// 发送电子钥匙成功
|
||||||
Widget sendElectronicKeySucceed() {
|
Widget sendElectronicKeySucceed() {
|
||||||
return Column(
|
return Column(
|
||||||
@ -584,7 +478,7 @@ class _PasswordKeyPerpetualPageState extends State<PasswordKeyPerpetualPage> {
|
|||||||
height: 10.h,
|
height: 10.h,
|
||||||
),
|
),
|
||||||
Text(
|
Text(
|
||||||
_getPwdStr,
|
state.getPwdStr.value,
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
fontSize: 40.sp,
|
fontSize: 40.sp,
|
||||||
color: Colors.black,
|
color: Colors.black,
|
||||||
@ -599,7 +493,7 @@ class _PasswordKeyPerpetualPageState extends State<PasswordKeyPerpetualPage> {
|
|||||||
SubmitBtn(
|
SubmitBtn(
|
||||||
btnName: '完成',
|
btnName: '完成',
|
||||||
onClick: () {
|
onClick: () {
|
||||||
_isSendSuccess = false;
|
state.isSendSuccess.value = false;
|
||||||
Navigator.pop(context, true);
|
Navigator.pop(context, true);
|
||||||
}),
|
}),
|
||||||
SizedBox(
|
SizedBox(
|
||||||
@ -659,10 +553,10 @@ class _PasswordKeyPerpetualPageState extends State<PasswordKeyPerpetualPage> {
|
|||||||
activeColor: CupertinoColors.activeBlue,
|
activeColor: CupertinoColors.activeBlue,
|
||||||
trackColor: CupertinoColors.systemGrey5,
|
trackColor: CupertinoColors.systemGrey5,
|
||||||
thumbColor: CupertinoColors.white,
|
thumbColor: CupertinoColors.white,
|
||||||
value: _isPermanent,
|
value: state.isPermanent.value,
|
||||||
onChanged: (value) {
|
onChanged: (value) {
|
||||||
setState(() {
|
setState(() {
|
||||||
_isPermanent = value;
|
state.isPermanent.value = value;
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
@ -758,7 +652,7 @@ class _PasswordKeyPerpetualPageState extends State<PasswordKeyPerpetualPage> {
|
|||||||
case 0:
|
case 0:
|
||||||
//微信好友
|
//微信好友
|
||||||
{
|
{
|
||||||
String pwdShareStr = '您好,您的密码是:$_getPwdStr';
|
String pwdShareStr = '您好,您的密码是:${state.getPwdStr.value}';
|
||||||
tokNative('flutter_sharePassword_to_ios',
|
tokNative('flutter_sharePassword_to_ios',
|
||||||
arguments: {'pwdShareStr': pwdShareStr}).then((result) {
|
arguments: {'pwdShareStr': pwdShareStr}).then((result) {
|
||||||
print('$result');
|
print('$result');
|
||||||
|
|||||||
@ -0,0 +1,24 @@
|
|||||||
|
import 'package:flutter/widgets.dart';
|
||||||
|
import 'package:get/get.dart';
|
||||||
|
import 'package:star_lock/main/lockMian/entity/lockListInfo_entity.dart';
|
||||||
|
|
||||||
|
class PasswordKeyPerpetualState {
|
||||||
|
final TextEditingController nameController = TextEditingController();
|
||||||
|
final TextEditingController pwdController = TextEditingController();
|
||||||
|
|
||||||
|
final isSendSuccess = false.obs; //是否发送成功
|
||||||
|
final isPermanent = false.obs; //是否永久
|
||||||
|
var getPwdStr = ''.obs;
|
||||||
|
var selectEffectiveDate = ''.obs; //生效时间
|
||||||
|
var selectFailureDate = ''.obs; //失效时间
|
||||||
|
DateTime dateTime = DateTime.now();
|
||||||
|
final effectiveDateTime = DateTime.now().obs;
|
||||||
|
final failureDateTime = DateTime.now().obs;
|
||||||
|
var cyclicModeStr = ''.obs; //循环模式
|
||||||
|
var effectiveHourStr = ''.obs;
|
||||||
|
var failureHourStr = ''.obs;
|
||||||
|
var startHours = 0.obs;
|
||||||
|
var endHours = 0.obs;
|
||||||
|
final widgetType = ''.obs;
|
||||||
|
final keyInfo = LockListInfoItemEntity().obs;
|
||||||
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user