From 8b426ade6cacb607b1fb5af44a0a78b24d82c36a Mon Sep 17 00:00:00 2001 From: Daisy <> Date: Wed, 23 Aug 2023 17:08:49 +0800 Subject: [PATCH] =?UTF-8?q?1=EF=BC=8C=E6=96=B0=E5=A2=9E=E5=8F=91=E9=80=81?= =?UTF-8?q?=E9=92=A5=E5=8C=99=E9=80=BB=E8=BE=91=E5=88=A4=E6=96=AD=202?= =?UTF-8?q?=EF=BC=8C=E6=96=B0=E5=A2=9E=E5=8F=91=E9=80=81=E9=92=A5=E5=8C=99?= =?UTF-8?q?=E5=9B=BD=E5=AE=B6/=E5=9C=B0=E5=8C=BA=E9=80=89=E6=8B=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../register/starLock_register_page.dart | 1 - .../register/starLock_register_state.dart | 2 +- .../seletCountryRegion_page.dart | 3 +- .../sendElectronicKey_page.dart | 69 +++++++++++++------ star_lock/pubspec.yaml | 1 + 5 files changed, 52 insertions(+), 24 deletions(-) diff --git a/star_lock/lib/login/register/starLock_register_page.dart b/star_lock/lib/login/register/starLock_register_page.dart index 2f6de795..c365c554 100644 --- a/star_lock/lib/login/register/starLock_register_page.dart +++ b/star_lock/lib/login/register/starLock_register_page.dart @@ -140,7 +140,6 @@ class _StarLockRegisterPageState extends State { SizedBox(height: 60.h), GestureDetector( onTap: () async { - // Navigator.pushNamed(context, Routers.seletCountryRegionPage); var result = await Navigator.pushNamed( context, Routers.seletCountryRegionPage); result as Map; diff --git a/star_lock/lib/login/register/starLock_register_state.dart b/star_lock/lib/login/register/starLock_register_state.dart index 1f23e1e0..e2e545f0 100644 --- a/star_lock/lib/login/register/starLock_register_state.dart +++ b/star_lock/lib/login/register/starLock_register_state.dart @@ -10,7 +10,7 @@ class StarLockRegisterState { final TextEditingController sureController = TextEditingController(); final TextEditingController codeController = TextEditingController(); - var countryCode = '+86'.obs; + var countryCode = '86'.obs; var countryId = '1'.obs; var countryName = '中国'.obs; var phoneOrEmailStr = ''.obs; diff --git a/star_lock/lib/login/seletCountryRegion/seletCountryRegion_page.dart b/star_lock/lib/login/seletCountryRegion/seletCountryRegion_page.dart index 52847ec2..31f667a7 100644 --- a/star_lock/lib/login/seletCountryRegion/seletCountryRegion_page.dart +++ b/star_lock/lib/login/seletCountryRegion/seletCountryRegion_page.dart @@ -27,9 +27,8 @@ class _SeletCountryRegionPageState extends State { SuspensionUtil.setShowSuspensionStatus( countriesList.cast()); - Future.delayed(const Duration(milliseconds: 500), () { + Future.delayed(const Duration(milliseconds: 20), () { getCountriesListRequest(); - // loadData(); }); } 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 54059186..e8efbb4d 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 @@ -1,3 +1,4 @@ +import 'package:date_format/date_format.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:flutter_pickers/pickers.dart'; @@ -34,21 +35,27 @@ class _SendElectronicKeyPageState extends State { bool _isRemoteUnlock = false; //是否允许远程开锁 bool _isAuthentication = false; //是否可以实名认证 String _selectEffectiveDate = ''; //生效时间 + late DateTime _effectiveDateTime; + late DateTime _failureDateTime; String _selectFailureDate = ''; //失效时间 TextEditingController emailOrPhoneController = TextEditingController(); //邮箱/手机号输入框 TextEditingController keyNameController = TextEditingController(); //钥匙名输入框 late bool _isSendSuccess; + String countryName = '中国'; + String countryCode = '86'; @override void initState() { super.initState(); DateTime dateTime = DateTime.now(); - _selectEffectiveDate = - '${dateTime.year}-${dateTime.month}-${dateTime.day} ${dateTime.hour}:${dateTime.minute}'; //默认为当前时间 - _selectFailureDate = - '${dateTime.year}-${dateTime.month}-${dateTime.day} ${dateTime.hour}:${dateTime.minute}'; //默认为当前时间 + _effectiveDateTime = dateTime; + _failureDateTime = dateTime; + _selectEffectiveDate = formatDate( + dateTime, [yyyy, '-', mm, '-', dd, ' ', HH, ':', nn]); //默认为当前时间 + _selectFailureDate = formatDate( + dateTime, [yyyy, '-', mm, '-', dd, ' ', HH, ':', nn]); //默认为当前时间 _isSendSuccess = false; } @@ -136,6 +143,27 @@ class _SendElectronicKeyPageState extends State { isHaveRightWidget: true, rightWidget: getTFWidget(true, TranslationLoader.lanKeys!.pleaseEnterNumberOrEmail!.tr, 1)), + CommonItem( + leftTitel: TranslationLoader.lanKeys!.countryAndRegion!.tr, + rightTitle: "", + isHaveLine: true, + isHaveRightWidget: true, + isHaveDirection: true, + rightWidget: Text( + '$countryName +$countryCode', + textAlign: TextAlign.end, + style: + TextStyle(fontSize: 22.sp, color: AppColors.darkGrayTextColor), + ), + action: () async { + var result = await Navigator.pushNamed( + context, Routers.seletCountryRegionPage); + result as Map; + countryCode = result['code']; + countryName = result['countryName']; + setState(() {}); + }, + ), CommonItem( leftTitel: TranslationLoader.lanKeys!.name!.tr, rightTitle: "", @@ -160,8 +188,10 @@ class _SendElectronicKeyPageState extends State { Pickers.showDatePicker(context, mode: DateMode.YMDHM, onConfirm: (p) { setState(() { - _selectEffectiveDate = - '${p.year}-${p.month}-${p.day} ${p.hour}:${p.minute}'; + _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]); }); }); }), @@ -173,8 +203,10 @@ class _SendElectronicKeyPageState extends State { Pickers.showDatePicker(context, mode: DateMode.YMDHM, onConfirm: (p) { setState(() { - _selectFailureDate = - '${p.year}-${p.month}-${p.day} ${p.hour}:${p.minute}'; + _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]); }); }); }), @@ -242,7 +274,14 @@ class _SendElectronicKeyPageState extends State { //发送钥匙请求 if (emailOrPhoneController.text.isNotEmpty && keyNameController.text.isNotEmpty) { - sendElectronicKeyRequest(); + //失效时间大于生效时间 + if (_failureDateTime.compareTo(_effectiveDateTime) == 1) { + sendElectronicKeyRequest(); + } else { + Toast.show(msg: '失效时间需大于生效时间'); + } + } else { + Toast.show(msg: '请完善信息'); } }), Container( @@ -283,7 +322,7 @@ class _SendElectronicKeyPageState extends State { } var entity = await ApiRepository.to.sendElectronicKey( '0', - '0', + countryCode, '1', getFailureDateTime, _isAuthentication == true ? '1' : '2', @@ -306,16 +345,6 @@ class _SendElectronicKeyPageState extends State { } } - ///日期转时间戳 - static int dateToTimestamp(String date, {isMicroseconds = false}) { - DateTime dateTime = DateTime.parse(date); - int timestamp = dateTime.millisecondsSinceEpoch; - if (isMicroseconds) { - timestamp = dateTime.microsecondsSinceEpoch; - } - return timestamp; - } - // 发送电子钥匙成功 Widget sendElectronicKeySucceed() { return Column( diff --git a/star_lock/pubspec.yaml b/star_lock/pubspec.yaml index aeb63e8c..201041a7 100644 --- a/star_lock/pubspec.yaml +++ b/star_lock/pubspec.yaml @@ -87,6 +87,7 @@ dependencies: #加密解密 encrypt: ^5.0.1 crypto: ^3.0.3 + date_format: ^2.0.7 dev_dependencies: flutter_test: