diff --git a/star_lock/ios/Runner.xcodeproj/project.pbxproj b/star_lock/ios/Runner.xcodeproj/project.pbxproj index f1877154..004b97ec 100644 --- a/star_lock/ios/Runner.xcodeproj/project.pbxproj +++ b/star_lock/ios/Runner.xcodeproj/project.pbxproj @@ -373,14 +373,14 @@ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements; CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; - DEVELOPMENT_TEAM = 7NLFRKNVY3; + DEVELOPMENT_TEAM = ZJ29NYHTV5; ENABLE_BITCODE = NO; INFOPLIST_FILE = Runner/Info.plist; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", "@executable_path/Frameworks", ); - PRODUCT_BUNDLE_IDENTIFIER = com.example.starLock456; + PRODUCT_BUNDLE_IDENTIFIER = "cn.star-lock.lock"; PRODUCT_NAME = "$(TARGET_NAME)"; VERSIONING_SYSTEM = "apple-generic"; }; @@ -501,14 +501,14 @@ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements; CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; - DEVELOPMENT_TEAM = 7NLFRKNVY3; + DEVELOPMENT_TEAM = ZJ29NYHTV5; ENABLE_BITCODE = NO; INFOPLIST_FILE = Runner/Info.plist; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", "@executable_path/Frameworks", ); - PRODUCT_BUNDLE_IDENTIFIER = com.example.starLock456; + PRODUCT_BUNDLE_IDENTIFIER = "cn.star-lock.lock"; PRODUCT_NAME = "$(TARGET_NAME)"; VERSIONING_SYSTEM = "apple-generic"; }; @@ -522,14 +522,14 @@ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements; CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; - DEVELOPMENT_TEAM = 7NLFRKNVY3; + DEVELOPMENT_TEAM = ZJ29NYHTV5; ENABLE_BITCODE = NO; INFOPLIST_FILE = Runner/Info.plist; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", "@executable_path/Frameworks", ); - PRODUCT_BUNDLE_IDENTIFIER = com.example.starLock456; + PRODUCT_BUNDLE_IDENTIFIER = "cn.star-lock.lock"; PRODUCT_NAME = "$(TARGET_NAME)"; VERSIONING_SYSTEM = "apple-generic"; }; diff --git a/star_lock/lib/main/lockDetail/electronicKey/electronicKeyDetail/keyOperationRecord_page.dart b/star_lock/lib/main/lockDetail/electronicKey/electronicKeyDetail/keyOperationRecord_page.dart index 47684585..4874a62c 100644 --- a/star_lock/lib/main/lockDetail/electronicKey/electronicKeyDetail/keyOperationRecord_page.dart +++ b/star_lock/lib/main/lockDetail/electronicKey/electronicKeyDetail/keyOperationRecord_page.dart @@ -2,13 +2,10 @@ import 'package:flutter/material.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:get/get.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 '../../../../appRouters.dart'; import '../../../../app_settings/app_colors.dart'; -import '../../../../tools/submitBtn.dart'; import '../../../../tools/titleAppBar.dart'; import '../../../../translations/trans_lib.dart'; diff --git a/star_lock/lib/main/lockDetail/electronicKey/electronicKeyPeriodValidity/electronicKeyPeriodValidity_page.dart b/star_lock/lib/main/lockDetail/electronicKey/electronicKeyPeriodValidity/electronicKeyPeriodValidity_page.dart index 500ae6b5..80666b96 100644 --- a/star_lock/lib/main/lockDetail/electronicKey/electronicKeyPeriodValidity/electronicKeyPeriodValidity_page.dart +++ b/star_lock/lib/main/lockDetail/electronicKey/electronicKeyPeriodValidity/electronicKeyPeriodValidity_page.dart @@ -33,12 +33,10 @@ class _ElectronicKeyPeriodValidityPageState ]; List validityDataList = []; //自定义数据块 List selectIndexList = []; //选中的有效期数组 - String _effectiveTime = ''; - String _failureTime = ''; - - String _effectiveDate = ''; - String _failureDate = ''; - + String _selectEffectiveDate = ''; //生效时间 + String _selectFailureDate = ''; //失效时间 + late DateTime _effectiveDateTime; + late DateTime _failureDateTime; @override void initState() { super.initState(); @@ -149,58 +147,59 @@ class _ElectronicKeyPeriodValidityPageState Widget bottomWidget() { return Column( children: [ - CommonItem( - leftTitel: TranslationLoader.lanKeys!.effectiveTime!.tr, - rightTitle: _effectiveTime, - isHaveDirection: true, - isHaveLine: true, - action: () { - Pickers.showDatePicker(context, mode: DateMode.HM, - onConfirm: (p) { - _effectiveTime = '${intToStr(p.hour!)}:${intToStr(p.minute!)}'; + // CommonItem( + // leftTitel: TranslationLoader.lanKeys!.effectiveTime!.tr, + // rightTitle: _effectiveTime, + // isHaveDirection: true, + // isHaveLine: true, + // action: () { + // Pickers.showDatePicker(context, mode: DateMode.HM, + // onConfirm: (p) { + // _effectiveTime = '${intToStr(p.hour!)}:${intToStr(p.minute!)}'; - setState(() {}); - }); - }), - CommonItem( - leftTitel: TranslationLoader.lanKeys!.failureTime!.tr, - rightTitle: _failureTime, - isHaveDirection: true, - action: () { - Pickers.showDatePicker(context, mode: DateMode.HM, - onConfirm: (p) { - _failureTime = '${intToStr(p.hour!)}:${intToStr(p.minute!)}'; + // setState(() {}); + // }); + // }), + // CommonItem( + // leftTitel: TranslationLoader.lanKeys!.failureTime!.tr, + // rightTitle: _failureTime, + // isHaveDirection: true, + // action: () { + // Pickers.showDatePicker(context, mode: DateMode.HM, + // onConfirm: (p) { + // _failureTime = '${intToStr(p.hour!)}:${intToStr(p.minute!)}'; - setState(() {}); - }); - }), - Container(height: 10.h), + // setState(() {}); + // }); + // }), + // Container(height: 10.h), CommonItem( leftTitel: TranslationLoader.lanKeys!.effectiveDate!.tr, - rightTitle: _effectiveDate, + rightTitle: _selectEffectiveDate, isHaveDirection: true, isHaveLine: true, action: () { - Pickers.showDatePicker(context, mode: DateMode.YMD, + Pickers.showDatePicker(context, mode: DateMode.YMDHM, onConfirm: (p) { - DateTime getPTime = DateTime.parse( - '${intToStr(p.year!)}-${intToStr(p.month!)}-${intToStr(p.day!)}'); - _effectiveDate = formatDate(getPTime, [yyyy, '-', mm, '-', dd]); + _effectiveDateTime = DateTime.parse( + '${p.year}-${intToStr(p.month!)}-${intToStr(p.day!)} ${intToStr(p.hour!)}:${intToStr(p.minute!)}'); + _selectEffectiveDate = formatDate(_effectiveDateTime, + [yyyy, '-', mm, '-', dd, ' ', HH, ':', nn]); setState(() {}); }); }), CommonItem( leftTitel: TranslationLoader.lanKeys!.failureDate!.tr, - rightTitle: _failureDate, + rightTitle: _selectFailureDate, isHaveDirection: true, action: () { - Pickers.showDatePicker(context, mode: DateMode.YMD, + Pickers.showDatePicker(context, mode: DateMode.YMDHM, onConfirm: (p) { - DateTime getPTime = DateTime.parse( - '${intToStr(p.year!)}-${intToStr(p.month!)}-${intToStr(p.day!)}'); - _failureDate = formatDate(getPTime, [yyyy, '-', mm, '-', dd]); - + _failureDateTime = DateTime.parse( + '${p.year}-${intToStr(p.month!)}-${intToStr(p.day!)} ${intToStr(p.hour!)}:${intToStr(p.minute!)}'); + _selectFailureDate = formatDate(_failureDateTime, + [yyyy, '-', mm, '-', dd, ' ', HH, ':', nn]); setState(() {}); }); }), @@ -213,6 +212,8 @@ class _ElectronicKeyPeriodValidityPageState onClick: () { Map resultMap = {}; resultMap['validityValue'] = selectIndexList; + resultMap['starDate'] = _effectiveDateTime; + resultMap['endDate'] = _failureDateTime; Navigator.pop(context, resultMap); }), ], diff --git a/star_lock/lib/main/lockDetail/electronicKey/sendElectronicKey/sendElectronicKey/sendElectronicKey_page.dart b/star_lock/lib/main/lockDetail/electronicKey/sendElectronicKey/sendElectronicKey/sendElectronicKey_page.dart index e8efbb4d..8083416e 100644 --- a/star_lock/lib/main/lockDetail/electronicKey/sendElectronicKey/sendElectronicKey/sendElectronicKey_page.dart +++ b/star_lock/lib/main/lockDetail/electronicKey/sendElectronicKey/sendElectronicKey/sendElectronicKey_page.dart @@ -35,15 +35,17 @@ class _SendElectronicKeyPageState extends State { bool _isRemoteUnlock = false; //是否允许远程开锁 bool _isAuthentication = false; //是否可以实名认证 String _selectEffectiveDate = ''; //生效时间 + String _selectFailureDate = ''; //失效时间 late DateTime _effectiveDateTime; late DateTime _failureDateTime; - String _selectFailureDate = ''; //失效时间 TextEditingController emailOrPhoneController = TextEditingController(); //邮箱/手机号输入框 TextEditingController keyNameController = TextEditingController(); //钥匙名输入框 late bool _isSendSuccess; String countryName = '中国'; String countryCode = '86'; + List weekdaysList = []; + bool _isCreateUser = false; //用户未注册时传1 已注册传0 @override void initState() { @@ -239,9 +241,15 @@ class _SendElectronicKeyPageState extends State { leftTitel: TranslationLoader.lanKeys!.periodValidity!.tr, rightTitle: "", isHaveDirection: true, - action: () { - Navigator.pushNamed( + action: () async { + var result = await Navigator.pushNamed( context, Routers.electronicKeyPeriodValidityPage); + result as Map; + weekdaysList = result['validityValue']; + _effectiveDateTime = result['starDate']; + _failureDateTime = result['endDate']; + print( + '得到的有效期数据:$weekdaysList $_effectiveDateTime $_failureDateTime'); }), SizedBox( height: 10.h, @@ -274,11 +282,15 @@ class _SendElectronicKeyPageState extends State { //发送钥匙请求 if (emailOrPhoneController.text.isNotEmpty && keyNameController.text.isNotEmpty) { - //失效时间大于生效时间 - if (_failureDateTime.compareTo(_effectiveDateTime) == 1) { - sendElectronicKeyRequest(); + if (int.parse(widget.type) == 0) { + //失效时间大于生效时间 + if (_failureDateTime.compareTo(_effectiveDateTime) == 1) { + sendElectronicKeyRequest(); + } else { + Toast.show(msg: '失效时间需大于生效时间'); + } } else { - Toast.show(msg: '失效时间需大于生效时间'); + sendElectronicKeyRequest(); } } else { Toast.show(msg: '请完善信息'); @@ -321,7 +333,7 @@ class _SendElectronicKeyPageState extends State { .toString(); } var entity = await ApiRepository.to.sendElectronicKey( - '0', + _isCreateUser ? "1" : "0", countryCode, '1', getFailureDateTime, @@ -335,13 +347,18 @@ class _SendElectronicKeyPageState extends State { '小吴副号', emailOrPhoneController.text, '0', - getEffectiveDateTime, []); + getEffectiveDateTime, + weekdaysList); if (entity.errorCode!.codeIsSuccessful) { print('发送电子钥匙成功'); _isSendSuccess = true; setState(() {}); } else { Toast.show(msg: '${entity.errorMsg}'); + if (entity.errorCode == 425) { + //用户未注册 + _isCreateUser = true; + } } } diff --git a/star_lock/lib/main/lockDetail/passwordKey/passwordKeyList/passwordKeyList_page.dart b/star_lock/lib/main/lockDetail/passwordKey/passwordKeyList/passwordKeyList_page.dart index cb132494..b74fb76f 100644 --- a/star_lock/lib/main/lockDetail/passwordKey/passwordKeyList/passwordKeyList_page.dart +++ b/star_lock/lib/main/lockDetail/passwordKey/passwordKeyList/passwordKeyList_page.dart @@ -210,8 +210,15 @@ class _PasswordKeyListPageState extends State { 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 { //循环 - useDateStr = '循环'; + DateTime dateStr = + DateTime.fromMillisecondsSinceEpoch(indexEntity.sendDate!); + useDateStr = '${dateStr.toLocal().toString().substring(0, 16)} 循环'; } return useDateStr; diff --git a/star_lock/lib/main/lockDetail/passwordKey/passwordKey_perpetual/passwordKeyEntity.dart b/star_lock/lib/main/lockDetail/passwordKey/passwordKey_perpetual/passwordKeyEntity.dart new file mode 100644 index 00000000..6bdebb48 --- /dev/null +++ b/star_lock/lib/main/lockDetail/passwordKey/passwordKey_perpetual/passwordKeyEntity.dart @@ -0,0 +1,46 @@ +class PasswordKeyEntity { + int? errorCode; + String? description; + String? errorMsg; + PasswordKeyData? data; + + PasswordKeyEntity( + {this.errorCode, this.description, this.errorMsg, this.data}); + + PasswordKeyEntity.fromJson(Map json) { + errorCode = json['errorCode']; + description = json['description']; + errorMsg = json['errorMsg']; + data = json['data'] != null ? PasswordKeyData.fromJson(json['data']) : null; + } + + Map toJson() { + final Map data = {}; + data['errorCode'] = errorCode; + data['description'] = description; + data['errorMsg'] = errorMsg; + if (this.data != null) { + data['data'] = this.data!.toJson(); + } + return data; + } +} + +class PasswordKeyData { + String? keyboardPwd; + int? keyboardPwdId; + + PasswordKeyData({this.keyboardPwd, this.keyboardPwdId}); + + PasswordKeyData.fromJson(Map json) { + keyboardPwd = json['keyboardPwd']; + keyboardPwdId = json['keyboardPwdId']; + } + + Map toJson() { + final Map data = {}; + data['keyboardPwd'] = keyboardPwd; + data['keyboardPwdId'] = keyboardPwdId; + return data; + } +} diff --git a/star_lock/lib/main/lockDetail/passwordKey/passwordKey_perpetual/passwordKey_perpetual_page.dart b/star_lock/lib/main/lockDetail/passwordKey/passwordKey_perpetual/passwordKey_perpetual_page.dart index d701cb4b..39b817be 100644 --- a/star_lock/lib/main/lockDetail/passwordKey/passwordKey_perpetual/passwordKey_perpetual_page.dart +++ b/star_lock/lib/main/lockDetail/passwordKey/passwordKey_perpetual/passwordKey_perpetual_page.dart @@ -1,10 +1,15 @@ +import 'package:date_format/date_format.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; +import 'package:flutter_pickers/pickers.dart'; +import 'package:flutter_pickers/time_picker/model/date_mode.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:get/get.dart'; +import 'package:star_lock/network/api_repository.dart'; +import 'package:star_lock/tools/baseGetXController.dart'; +import 'package:star_lock/tools/toast.dart'; import '../../../../appRouters.dart'; -import '../../../../app_settings/app_colors.dart'; import '../../../../tools/commonItem.dart'; import '../../../../tools/submitBtn.dart'; import '../../../../translations/trans_lib.dart'; @@ -21,6 +26,12 @@ class PasswordKeyPerpetualPage extends StatefulWidget { class _PasswordKeyPerpetualPageState extends State { final TextEditingController _controller = TextEditingController(); + late bool _isSendSuccess; + late String _getPwdStr; + String _selectEffectiveDate = ''; //生效时间 + String _selectFailureDate = ''; //失效时间 + late DateTime _effectiveDateTime; + late DateTime _failureDateTime; @override Widget build(BuildContext context) { @@ -29,98 +40,109 @@ class _PasswordKeyPerpetualPageState extends State { @override void initState() { - // TODO: implement initState super.initState(); + + _isSendSuccess = false; + DateTime dateTime = DateTime.now(); + _effectiveDateTime = dateTime; + _failureDateTime = dateTime; + _selectEffectiveDate = formatDate( + dateTime, [yyyy, '-', mm, '-', dd, ' ', HH, ':', nn]); //默认为当前时间 + _selectFailureDate = formatDate( + dateTime, [yyyy, '-', mm, '-', dd, ' ', HH, ':', nn]); //默认为当前时间 } Widget indexChangeWidget() { - switch (int.parse(widget.type)) { - case 0: - { - // 永久 - // return sendElectronicKeySucceed(); - return Column( - children: [ - perpetualKeyWidget( - TranslationLoader.lanKeys!.name!.tr, - TranslationLoader.lanKeys!.pleaseNameYourPassword!.tr, - _controller), - keyBottomWidget(TranslationLoader.lanKeys!.getPasswordTip1!.tr) - ], - ); - } - case 1: - { - // 限时 - return Column( - children: [ - keyTimeLimitWidget(), - perpetualKeyWidget( - TranslationLoader.lanKeys!.name!.tr, - TranslationLoader.lanKeys!.pleaseNameYourPassword!.tr, - _controller), - keyBottomWidget(TranslationLoader.lanKeys!.getPasswordTip2!.tr) - ], - ); - } - case 2: - { - // 单次 - return Column( - children: [ - perpetualKeyWidget( - TranslationLoader.lanKeys!.name!.tr, - TranslationLoader.lanKeys!.pleaseNameYourPassword!.tr, - _controller), - keyBottomWidget(TranslationLoader.lanKeys!.getPasswordTip3!.tr) - ], - ); - } - case 3: - { - // 自定义 - return Column( - children: [ - keyIfPerpetualWidget(), - perpetualKeyWidget( - TranslationLoader.lanKeys!.name!.tr, - TranslationLoader.lanKeys!.pleaseNameYourPassword!.tr, - _controller), - perpetualKeyWidget(TranslationLoader.lanKeys!.password!.tr, - "请输入6-9位数字", _controller), - keyBottomWidget(TranslationLoader.lanKeys!.getPasswordTip4!.tr) - ], - ); - } - case 4: - { - // 循环 - return Column( - children: [ - keyCirculationWidget(), - perpetualKeyWidget( - TranslationLoader.lanKeys!.name!.tr, - TranslationLoader.lanKeys!.pleaseNameYourPassword!.tr, - _controller), - keyBottomWidget(TranslationLoader.lanKeys!.getPasswordTip5!.tr) - ], - ); - } - case 5: - { - // 清空 - return Column( - children: [ - perpetualKeyWidget( - TranslationLoader.lanKeys!.name!.tr, - TranslationLoader.lanKeys!.pleaseNameYourPassword!.tr, - _controller), - keyBottomWidget(TranslationLoader.lanKeys!.getPasswordTip6!.tr) - ], - ); - } - default: - return Container(); + if (_isSendSuccess) { + return sendElectronicKeySucceed(); + } else { + switch (int.parse(widget.type)) { + case 0: + { + // 永久 + return Column( + children: [ + perpetualKeyWidget( + TranslationLoader.lanKeys!.name!.tr, + TranslationLoader.lanKeys!.pleaseNameYourPassword!.tr, + _controller), + keyBottomWidget(TranslationLoader.lanKeys!.getPasswordTip1!.tr) + ], + ); + } + case 1: + { + // 限时 + return Column( + children: [ + keyTimeLimitWidget(), + perpetualKeyWidget( + TranslationLoader.lanKeys!.name!.tr, + TranslationLoader.lanKeys!.pleaseNameYourPassword!.tr, + _controller), + keyBottomWidget(TranslationLoader.lanKeys!.getPasswordTip2!.tr) + ], + ); + } + case 2: + { + // 单次 + return Column( + children: [ + perpetualKeyWidget( + TranslationLoader.lanKeys!.name!.tr, + TranslationLoader.lanKeys!.pleaseNameYourPassword!.tr, + _controller), + keyBottomWidget(TranslationLoader.lanKeys!.getPasswordTip3!.tr) + ], + ); + } + case 3: + { + // 自定义 + return Column( + children: [ + keyIfPerpetualWidget(), + perpetualKeyWidget( + TranslationLoader.lanKeys!.name!.tr, + TranslationLoader.lanKeys!.pleaseNameYourPassword!.tr, + _controller), + perpetualKeyWidget(TranslationLoader.lanKeys!.password!.tr, + "请输入6-9位数字", _controller), + keyBottomWidget(TranslationLoader.lanKeys!.getPasswordTip4!.tr) + ], + ); + } + case 4: + { + // 循环 + return Column( + children: [ + keyCirculationWidget(), + perpetualKeyWidget( + TranslationLoader.lanKeys!.name!.tr, + TranslationLoader.lanKeys!.pleaseNameYourPassword!.tr, + _controller), + keyBottomWidget(TranslationLoader.lanKeys!.getPasswordTip5!.tr) + ], + ); + } + case 5: + { + // 清空 + return Column( + children: [ + perpetualKeyWidget( + TranslationLoader.lanKeys!.name!.tr, + TranslationLoader.lanKeys!.pleaseNameYourPassword!.tr, + _controller), + keyBottomWidget(TranslationLoader.lanKeys!.getPasswordTip6!.tr) + ], + ); + } + default: + return Container(); + } } } @@ -151,18 +173,34 @@ class _PasswordKeyPerpetualPageState extends State { children: [ CommonItem( leftTitel: TranslationLoader.lanKeys!.effectiveTime!.tr, - rightTitle: "2020.06.20 11:49", + rightTitle: _selectEffectiveDate, isHaveLine: true, isHaveDirection: true, action: () { - // _showDatePicker(); + Pickers.showDatePicker(context, mode: DateMode.YMDHM, + onConfirm: (p) { + setState(() { + _effectiveDateTime = DateTime.parse( + '${p.year}-${intToStr(p.month!)}-${intToStr(p.day!)} ${intToStr(p.hour!)}:${intToStr(p.minute!)}'); + _selectEffectiveDate = formatDate(_effectiveDateTime, + [yyyy, '-', mm, '-', dd, ' ', HH, ':', nn]); + }); + }); }), CommonItem( leftTitel: TranslationLoader.lanKeys!.failureTime!.tr, - rightTitle: "2020.06.20 11:49", + rightTitle: _selectFailureDate, isHaveDirection: true, action: () { - // _showDatePicker(); + Pickers.showDatePicker(context, mode: DateMode.YMDHM, + onConfirm: (p) { + setState(() { + _failureDateTime = DateTime.parse( + '${p.year}-${intToStr(p.month!)}-${intToStr(p.day!)} ${intToStr(p.hour!)}:${intToStr(p.minute!)}'); + _selectFailureDate = formatDate(_failureDateTime, + [yyyy, '-', mm, '-', dd, ' ', HH, ':', nn]); + }); + }); }), Container(height: 10.h), ], @@ -239,17 +277,89 @@ class _PasswordKeyPerpetualPageState extends State { ), SubmitBtn( btnName: TranslationLoader.lanKeys!.getPassword!.tr, - onClick: () {}), + onClick: () { + getKeyboardPwdRequest(); + }), ], ); } + /** +单次 1 只能在开始时间后6小时内使用一次 +永久 2 从开始时间开始永久有效,必需在开始时间24小时内使用一次,否则将失效 +限期 3 在开始和结束时间内有效,必需在开始时间24小时内使用一次,否则将失效 +删除 4 在锁上使用后会删除之前在锁上使用过的密码 +周未循环 5 在周未开始和结束时间指定时间段内有效 +每日循环 6 每天开始和结束时间指定时间段内有效 +工作日循环 7 工作日开始和结束时间指定的时间段内有效 +周一循环 8 每周一开始和结束时间指定时间段内有效 +周二循环 9 每周二开始和结束时间指定时间段内有效 +周三循环 10 每周三开始和结束时间指定时间段内有效 +周四循环 11 每周四开始和结束时间指定时间段内有效 +周五循环 12 每周五开始和结束时间指定时间段内有效 +周六循环 13 每周六开始和结束时间指定时间段内有效 +周天循环 14 每周日开始和结束时间指定时间段内有效 + */ + //获取密码请求 + Future getKeyboardPwdRequest() async { + String getFailureDateTime = '0'; + String getEffectiveDateTime = '0'; + String lockId = '28'; + 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) { + //循环 + getKeyType = '6'; + } else if (passwordType == 5) { + //清空码 + getKeyType = '4'; + } + if (widget.type == '0') { + getFailureDateTime = + DateTime.parse(_selectFailureDate).millisecondsSinceEpoch.toString(); + getEffectiveDateTime = DateTime.parse(_selectEffectiveDate) + .millisecondsSinceEpoch + .toString(); + } + var entity = await ApiRepository.to.getPasswordKey( + getFailureDateTime, + '0', + _controller.text, + getKeyType, + '0', + lockId, + '0', + getEffectiveDateTime, + '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() { return Column( children: [ Container( - height: 300.h, + height: 270.h, width: 1.sw, color: Colors.white, child: Column( @@ -258,30 +368,26 @@ class _PasswordKeyPerpetualPageState extends State { height: 30.h, ), Image.asset( - 'images/main/icon_main_addLock.png', - width: 150.w, - height: 150.w, - color: AppColors.mainColor, + 'images/icon_send_success.png', + width: 100.w, + height: 100.w, ), SizedBox( height: 20.h, ), Text( "操作成功,密码为", - style: TextStyle( - fontSize: 32.sp, - color: Colors.black, - fontWeight: FontWeight.w500), + style: TextStyle(fontSize: 22.sp, color: Colors.black), ), SizedBox( height: 10.h, ), Text( - "62689876", + _getPwdStr, style: TextStyle( - fontSize: 60.sp, + fontSize: 40.sp, color: Colors.black, - fontWeight: FontWeight.w500), + fontWeight: FontWeight.w600), ), ], ), @@ -291,34 +397,32 @@ class _PasswordKeyPerpetualPageState extends State { ), SubmitBtn( btnName: '完成', - fontSize: 28.sp, - borderRadius: 20.w, - margin: EdgeInsets.only(left: 30.w, right: 30.w, top: 30.w), - padding: EdgeInsets.only(top: 25.w, bottom: 25.w), - onClick: () {}), - SubmitBtn( - btnName: '分享', - fontSize: 28.sp, - borderRadius: 20.w, - margin: EdgeInsets.only(left: 30.w, right: 30.w, top: 30.w), - padding: EdgeInsets.only(top: 25.w, bottom: 25.w), onClick: () { - Navigator.pushNamed(context, Routers.sendEmailNotificationPage); + Navigator.pop(context); }), - SubmitBtn( - btnName: '标记为:已入住', - fontSize: 28.sp, - borderRadius: 20.w, - margin: EdgeInsets.only(left: 30.w, right: 30.w, top: 30.w), - padding: EdgeInsets.only(top: 25.w, bottom: 25.w), - onClick: () {}), + SizedBox( + height: 10.h, + ), + OutLineBtn( + btnName: '分享', + onClick: () { + Navigator.pushNamed(context, Routers.sendEmailNotificationPage); + }, + ), + SizedBox( + height: 10.h, + ), + OutLineBtn( + btnName: '标记为:已入住', + onClick: () {}, + ), ], ); } // 接受者信息输入框 Widget getTFWidget(String tfStr) { - return Container( + return SizedBox( height: 50.h, width: 300.w, child: Row( @@ -327,7 +431,7 @@ class _PasswordKeyPerpetualPageState extends State { child: TextField( //输入框一行 maxLines: 1, - // controller: _controller, + controller: _controller, autofocus: false, textAlign: TextAlign.end, decoration: InputDecoration( @@ -362,4 +466,8 @@ class _PasswordKeyPerpetualPageState extends State { }, ); } + + String intToStr(int v) { + return (v < 10) ? "0$v" : "$v"; + } } diff --git a/star_lock/lib/network/api.dart b/star_lock/lib/network/api.dart index 08224b1f..93087a47 100644 --- a/star_lock/lib/network/api.dart +++ b/star_lock/lib/network/api.dart @@ -28,4 +28,5 @@ abstract class Api { final String getLockInfoURL = '/lock/syncDataPage'; // 获取锁信息 + final String passwordKeyGetURL = '/keyboardPwd/get'; //获取密码 } diff --git a/star_lock/lib/network/api_provider.dart b/star_lock/lib/network/api_provider.dart index c40f4cb9..fa91300f 100644 --- a/star_lock/lib/network/api_provider.dart +++ b/star_lock/lib/network/api_provider.dart @@ -276,8 +276,33 @@ class ApiProvider extends BaseProvider { })); Future resetPasswordKey(String lockId, String operatorUid) => post( - resetElectronicKeyURL.toUrl, + resetPasswordURL.toUrl, jsonEncode({'lockId': lockId, 'operatorUid': operatorUid})); + + Future getKeyboardPwd( + String endDate, + String isExclusive, + String keyboardPwdName, + String keyboardPwdType, + String keyboardPwdVersion, + String lockId, + String operatorUid, + String startDate, + String timezoneRawOffSet, + ) => + post( + passwordKeyGetURL.toUrl, + jsonEncode({ + 'endDate': endDate, + 'isExclusive': isExclusive, + 'keyboardPwdName': keyboardPwdName, + 'keyboardPwdType': keyboardPwdType, + 'keyboardPwdVersion': keyboardPwdVersion, + 'lockId': lockId, + 'operatorUid': operatorUid, + 'startDate': startDate, + 'timezoneRawOffSet': timezoneRawOffSet + })); } extension ExtensionString on String { diff --git a/star_lock/lib/network/api_repository.dart b/star_lock/lib/network/api_repository.dart index 38bb7f5a..df4bb462 100644 --- a/star_lock/lib/network/api_repository.dart +++ b/star_lock/lib/network/api_repository.dart @@ -3,6 +3,7 @@ import 'package:star_lock/login/seletCountryRegion/common/countryRegionEntity.da 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/main/lockDetail/passwordKey/passwordKeyList/passwordKeyListEntity.dart'; +import 'package:star_lock/main/lockDetail/passwordKey/passwordKey_perpetual/passwordKeyEntity.dart'; import '../common/safetyVerification/entity/CheckSafetyVerificationEntity.dart'; import '../common/safetyVerification/entity/SafetyVerificationEntity.dart'; import '../login/login/entity/LoginEntity.dart'; @@ -255,4 +256,28 @@ class ApiRepository { return LockMainEntity.fromJson(res.body); } + //获取密码 + Future getPasswordKey( + String endDate, + String isExclusive, + String keyboardPwdName, + String keyboardPwdType, + String keyboardPwdVersion, + String lockId, + String operatorUid, + String startDate, + String timezoneRawOffSet, + ) async { + final res = await apiProvider.getKeyboardPwd( + endDate, + isExclusive, + keyboardPwdName, + keyboardPwdType, + keyboardPwdVersion, + lockId, + operatorUid, + startDate, + timezoneRawOffSet); + return PasswordKeyEntity.fromJson(res.body); + } }