1,新增发送钥匙逻辑判断
2,新增发送钥匙国家/地区选择
This commit is contained in:
parent
0de13dd926
commit
8b426ade6c
@ -140,7 +140,6 @@ class _StarLockRegisterPageState extends State<StarLockRegisterPage> {
|
||||
SizedBox(height: 60.h),
|
||||
GestureDetector(
|
||||
onTap: () async {
|
||||
// Navigator.pushNamed(context, Routers.seletCountryRegionPage);
|
||||
var result = await Navigator.pushNamed(
|
||||
context, Routers.seletCountryRegionPage);
|
||||
result as Map<String, dynamic>;
|
||||
|
||||
@ -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;
|
||||
|
||||
@ -27,9 +27,8 @@ class _SeletCountryRegionPageState extends State<SeletCountryRegionPage> {
|
||||
|
||||
SuspensionUtil.setShowSuspensionStatus(
|
||||
countriesList.cast<ISuspensionBean>());
|
||||
Future.delayed(const Duration(milliseconds: 500), () {
|
||||
Future.delayed(const Duration(milliseconds: 20), () {
|
||||
getCountriesListRequest();
|
||||
// loadData();
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@ -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<SendElectronicKeyPage> {
|
||||
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<SendElectronicKeyPage> {
|
||||
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<String, dynamic>;
|
||||
countryCode = result['code'];
|
||||
countryName = result['countryName'];
|
||||
setState(() {});
|
||||
},
|
||||
),
|
||||
CommonItem(
|
||||
leftTitel: TranslationLoader.lanKeys!.name!.tr,
|
||||
rightTitle: "",
|
||||
@ -160,8 +188,10 @@ class _SendElectronicKeyPageState extends State<SendElectronicKeyPage> {
|
||||
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<SendElectronicKeyPage> {
|
||||
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<SendElectronicKeyPage> {
|
||||
//发送钥匙请求
|
||||
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<SendElectronicKeyPage> {
|
||||
}
|
||||
var entity = await ApiRepository.to.sendElectronicKey(
|
||||
'0',
|
||||
'0',
|
||||
countryCode,
|
||||
'1',
|
||||
getFailureDateTime,
|
||||
_isAuthentication == true ? '1' : '2',
|
||||
@ -306,16 +345,6 @@ class _SendElectronicKeyPageState extends State<SendElectronicKeyPage> {
|
||||
}
|
||||
}
|
||||
|
||||
///日期转时间戳
|
||||
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(
|
||||
|
||||
@ -87,6 +87,7 @@ dependencies:
|
||||
#加密解密
|
||||
encrypt: ^5.0.1
|
||||
crypto: ^3.0.3
|
||||
date_format: ^2.0.7
|
||||
|
||||
dev_dependencies:
|
||||
flutter_test:
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user