1,新增发送钥匙逻辑判断
2,新增发送钥匙国家/地区选择
This commit is contained in:
parent
0de13dd926
commit
8b426ade6c
@ -140,7 +140,6 @@ class _StarLockRegisterPageState extends State<StarLockRegisterPage> {
|
|||||||
SizedBox(height: 60.h),
|
SizedBox(height: 60.h),
|
||||||
GestureDetector(
|
GestureDetector(
|
||||||
onTap: () async {
|
onTap: () async {
|
||||||
// Navigator.pushNamed(context, Routers.seletCountryRegionPage);
|
|
||||||
var result = await Navigator.pushNamed(
|
var result = await Navigator.pushNamed(
|
||||||
context, Routers.seletCountryRegionPage);
|
context, Routers.seletCountryRegionPage);
|
||||||
result as Map<String, dynamic>;
|
result as Map<String, dynamic>;
|
||||||
|
|||||||
@ -10,7 +10,7 @@ class StarLockRegisterState {
|
|||||||
final TextEditingController sureController = TextEditingController();
|
final TextEditingController sureController = TextEditingController();
|
||||||
final TextEditingController codeController = TextEditingController();
|
final TextEditingController codeController = TextEditingController();
|
||||||
|
|
||||||
var countryCode = '+86'.obs;
|
var countryCode = '86'.obs;
|
||||||
var countryId = '1'.obs;
|
var countryId = '1'.obs;
|
||||||
var countryName = '中国'.obs;
|
var countryName = '中国'.obs;
|
||||||
var phoneOrEmailStr = ''.obs;
|
var phoneOrEmailStr = ''.obs;
|
||||||
|
|||||||
@ -27,9 +27,8 @@ class _SeletCountryRegionPageState extends State<SeletCountryRegionPage> {
|
|||||||
|
|
||||||
SuspensionUtil.setShowSuspensionStatus(
|
SuspensionUtil.setShowSuspensionStatus(
|
||||||
countriesList.cast<ISuspensionBean>());
|
countriesList.cast<ISuspensionBean>());
|
||||||
Future.delayed(const Duration(milliseconds: 500), () {
|
Future.delayed(const Duration(milliseconds: 20), () {
|
||||||
getCountriesListRequest();
|
getCountriesListRequest();
|
||||||
// loadData();
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1,3 +1,4 @@
|
|||||||
|
import 'package:date_format/date_format.dart';
|
||||||
import 'package:flutter/cupertino.dart';
|
import 'package:flutter/cupertino.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_pickers/pickers.dart';
|
import 'package:flutter_pickers/pickers.dart';
|
||||||
@ -34,21 +35,27 @@ class _SendElectronicKeyPageState extends State<SendElectronicKeyPage> {
|
|||||||
bool _isRemoteUnlock = false; //是否允许远程开锁
|
bool _isRemoteUnlock = false; //是否允许远程开锁
|
||||||
bool _isAuthentication = false; //是否可以实名认证
|
bool _isAuthentication = false; //是否可以实名认证
|
||||||
String _selectEffectiveDate = ''; //生效时间
|
String _selectEffectiveDate = ''; //生效时间
|
||||||
|
late DateTime _effectiveDateTime;
|
||||||
|
late DateTime _failureDateTime;
|
||||||
String _selectFailureDate = ''; //失效时间
|
String _selectFailureDate = ''; //失效时间
|
||||||
TextEditingController emailOrPhoneController =
|
TextEditingController emailOrPhoneController =
|
||||||
TextEditingController(); //邮箱/手机号输入框
|
TextEditingController(); //邮箱/手机号输入框
|
||||||
TextEditingController keyNameController = TextEditingController(); //钥匙名输入框
|
TextEditingController keyNameController = TextEditingController(); //钥匙名输入框
|
||||||
late bool _isSendSuccess;
|
late bool _isSendSuccess;
|
||||||
|
String countryName = '中国';
|
||||||
|
String countryCode = '86';
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
|
|
||||||
DateTime dateTime = DateTime.now();
|
DateTime dateTime = DateTime.now();
|
||||||
_selectEffectiveDate =
|
_effectiveDateTime = dateTime;
|
||||||
'${dateTime.year}-${dateTime.month}-${dateTime.day} ${dateTime.hour}:${dateTime.minute}'; //默认为当前时间
|
_failureDateTime = dateTime;
|
||||||
_selectFailureDate =
|
_selectEffectiveDate = formatDate(
|
||||||
'${dateTime.year}-${dateTime.month}-${dateTime.day} ${dateTime.hour}:${dateTime.minute}'; //默认为当前时间
|
dateTime, [yyyy, '-', mm, '-', dd, ' ', HH, ':', nn]); //默认为当前时间
|
||||||
|
_selectFailureDate = formatDate(
|
||||||
|
dateTime, [yyyy, '-', mm, '-', dd, ' ', HH, ':', nn]); //默认为当前时间
|
||||||
_isSendSuccess = false;
|
_isSendSuccess = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -136,6 +143,27 @@ class _SendElectronicKeyPageState extends State<SendElectronicKeyPage> {
|
|||||||
isHaveRightWidget: true,
|
isHaveRightWidget: true,
|
||||||
rightWidget: getTFWidget(true,
|
rightWidget: getTFWidget(true,
|
||||||
TranslationLoader.lanKeys!.pleaseEnterNumberOrEmail!.tr, 1)),
|
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(
|
CommonItem(
|
||||||
leftTitel: TranslationLoader.lanKeys!.name!.tr,
|
leftTitel: TranslationLoader.lanKeys!.name!.tr,
|
||||||
rightTitle: "",
|
rightTitle: "",
|
||||||
@ -160,8 +188,10 @@ class _SendElectronicKeyPageState extends State<SendElectronicKeyPage> {
|
|||||||
Pickers.showDatePicker(context, mode: DateMode.YMDHM,
|
Pickers.showDatePicker(context, mode: DateMode.YMDHM,
|
||||||
onConfirm: (p) {
|
onConfirm: (p) {
|
||||||
setState(() {
|
setState(() {
|
||||||
_selectEffectiveDate =
|
_effectiveDateTime = DateTime.parse(
|
||||||
'${p.year}-${p.month}-${p.day} ${p.hour}:${p.minute}';
|
'${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,
|
Pickers.showDatePicker(context, mode: DateMode.YMDHM,
|
||||||
onConfirm: (p) {
|
onConfirm: (p) {
|
||||||
setState(() {
|
setState(() {
|
||||||
_selectFailureDate =
|
_failureDateTime = DateTime.parse(
|
||||||
'${p.year}-${p.month}-${p.day} ${p.hour}:${p.minute}';
|
'${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 &&
|
if (emailOrPhoneController.text.isNotEmpty &&
|
||||||
keyNameController.text.isNotEmpty) {
|
keyNameController.text.isNotEmpty) {
|
||||||
sendElectronicKeyRequest();
|
//失效时间大于生效时间
|
||||||
|
if (_failureDateTime.compareTo(_effectiveDateTime) == 1) {
|
||||||
|
sendElectronicKeyRequest();
|
||||||
|
} else {
|
||||||
|
Toast.show(msg: '失效时间需大于生效时间');
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
Toast.show(msg: '请完善信息');
|
||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
Container(
|
Container(
|
||||||
@ -283,7 +322,7 @@ class _SendElectronicKeyPageState extends State<SendElectronicKeyPage> {
|
|||||||
}
|
}
|
||||||
var entity = await ApiRepository.to.sendElectronicKey(
|
var entity = await ApiRepository.to.sendElectronicKey(
|
||||||
'0',
|
'0',
|
||||||
'0',
|
countryCode,
|
||||||
'1',
|
'1',
|
||||||
getFailureDateTime,
|
getFailureDateTime,
|
||||||
_isAuthentication == true ? '1' : '2',
|
_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() {
|
Widget sendElectronicKeySucceed() {
|
||||||
return Column(
|
return Column(
|
||||||
|
|||||||
@ -87,6 +87,7 @@ dependencies:
|
|||||||
#加密解密
|
#加密解密
|
||||||
encrypt: ^5.0.1
|
encrypt: ^5.0.1
|
||||||
crypto: ^3.0.3
|
crypto: ^3.0.3
|
||||||
|
date_format: ^2.0.7
|
||||||
|
|
||||||
dev_dependencies:
|
dev_dependencies:
|
||||||
flutter_test:
|
flutter_test:
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user