1,新增公用正则判断文件
2,设置/更新授权管理员接口修改及对接 3,发送授权管理员/详情新增仅管理自己创建的用户及相关逻辑处理 4,批量授权管理员模块代码重构 5,部分模块代码风格优化
This commit is contained in:
parent
af04296143
commit
63e963b3e0
@ -753,7 +753,7 @@
|
||||
"当被胁迫要求强行开锁时,使用胁迫指纹会触发报警,报警消息会推送给管理员,该功能需要锁联网": "当被胁迫要求强行开锁时,使用胁迫指纹会触发报警,报警消息会推送给管理员,该功能需要锁联网",
|
||||
"胁迫指纹": "胁迫指纹",
|
||||
"指纹列表": "指纹列表",
|
||||
"经过以上设定的时间,锁没有被开启,系统会给指定对象发送提醒消息,该功能需要锁联网": "经过以上设定的时间,锁没有被开启,系统会给指定对象发送提醒消息,该功能需要锁联网",
|
||||
"经过以上设定的时间,锁没有被开启,系统会给指定对象发送提醒消息,该功能需要锁联网": "经过以上设定的时间,锁没有被开启,系统会给指定对象发送提醒消息,该功能需要锁联网。",
|
||||
"打开提醒后,当锁电量低于20%、10%和5%,系统会给指定对象发送提醒消息。电量读取方式:网关读取或APP读取。": "打开提醒后,当锁电量低于20%、10%和5%,系统会给指定对象发送提醒消息。电量读取方式:网关读取或APP读取。",
|
||||
"门未开时间": "门未开时间",
|
||||
"添加和使用面容开锁时:": "添加和使用面容开锁时:",
|
||||
|
||||
@ -1,5 +1,8 @@
|
||||
import 'dart:ffi';
|
||||
|
||||
|
||||
import 'package:flutter_easyloading/flutter_easyloading.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:star_lock/network/api_repository.dart';
|
||||
import 'package:star_lock/tools/baseGetXController.dart';
|
||||
|
||||
import 'volumeAuthorizationLock_state.dart';
|
||||
@ -7,4 +10,43 @@ import 'volumeAuthorizationLock_state.dart';
|
||||
class VolumeAuthorizationLockLogic extends BaseGetXController {
|
||||
final state = VolumeAuthorizationLockState();
|
||||
|
||||
}
|
||||
//发送批量授权管理员
|
||||
Future<void> addAuthorizedAdminRequest() async {
|
||||
String getFailureDateTime = '0';
|
||||
String getEffectiveDateTime = '0';
|
||||
if (state.selectWidgetType == '1') {
|
||||
getFailureDateTime =
|
||||
state.failureDateTime.value.millisecondsSinceEpoch.toString();
|
||||
getEffectiveDateTime =
|
||||
state.effectiveDateTime.value.millisecondsSinceEpoch.toString();
|
||||
}
|
||||
|
||||
if (state.lockIdList.isEmpty) {
|
||||
showToast('请选择锁'.tr);
|
||||
return;
|
||||
}
|
||||
var entity = await ApiRepository.to.addAuthorizedAdmin(
|
||||
createUser: state.isCreateUser.value ? '1' : '0',
|
||||
endDate: getFailureDateTime,
|
||||
isRemoteUnlock: '0',
|
||||
keyGroupIdList: [],
|
||||
lockIdList: state.lockIdList.value,
|
||||
name: state.keyNameController.text,
|
||||
startDate: getEffectiveDateTime,
|
||||
userid: state.emailOrPhoneController.text,
|
||||
countryCode: state.countryCode.value,
|
||||
usernameType: '1',
|
||||
isOnlyManageSelf: state.onlyManageYouCreatesUser.value == true ? 1 : 2,
|
||||
);
|
||||
if (entity.errorCode!.codeIsSuccessful) {
|
||||
state.isSendSuccess.value = true;
|
||||
} else {
|
||||
EasyLoading.showToast('${entity.errorMsg}', duration: 2000.milliseconds);
|
||||
if (entity.errorCode == 425) {
|
||||
//用户未注册
|
||||
state.isCreateUser.value = true;
|
||||
addAuthorizedAdminRequest();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,19 +1,16 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:flutter_easyloading/flutter_easyloading.dart';
|
||||
import 'package:flutter_native_contact_picker/flutter_native_contact_picker.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/app_settings/app_colors.dart';
|
||||
import 'package:star_lock/network/api_repository.dart';
|
||||
import 'package:star_lock/tools/baseGetXController.dart';
|
||||
import 'package:star_lock/main/lockDetail/authorizedAdmin/volumeAuthorizationLock/volumeAuthorizationLock_state.dart';
|
||||
import 'package:star_lock/tools/pickers/pickers.dart';
|
||||
import 'package:star_lock/tools/pickers/time_picker/model/date_mode.dart';
|
||||
import 'package:star_lock/tools/pickers/time_picker/model/pduration.dart';
|
||||
import 'package:star_lock/tools/showTipView.dart';
|
||||
|
||||
import '../../../../appRouters.dart';
|
||||
import '../../../../tools/commonItem.dart';
|
||||
@ -22,10 +19,9 @@ import '../../../../translations/trans_lib.dart';
|
||||
import 'volumeAuthorizationLock_logic.dart';
|
||||
|
||||
class VolumeAuthorizationLockPage extends StatefulWidget {
|
||||
final String type;
|
||||
|
||||
const VolumeAuthorizationLockPage({Key? key, required this.type})
|
||||
const VolumeAuthorizationLockPage({required this.type, Key? key})
|
||||
: super(key: key);
|
||||
final String type;
|
||||
|
||||
@override
|
||||
State<VolumeAuthorizationLockPage> createState() =>
|
||||
@ -33,53 +29,23 @@ class VolumeAuthorizationLockPage extends StatefulWidget {
|
||||
}
|
||||
|
||||
//批量授权锁页面
|
||||
class _VolumeAuthorizationLockPageState extends State<VolumeAuthorizationLockPage> {
|
||||
final logic = Get.put(VolumeAuthorizationLockLogic());
|
||||
final state = Get.find<VolumeAuthorizationLockLogic>().state;
|
||||
|
||||
final FlutterContactPicker _contactPicker = FlutterContactPicker();
|
||||
final TextEditingController _emailOrPhoneController =
|
||||
TextEditingController(); //邮箱/手机号输入框
|
||||
final TextEditingController _keyNameController =
|
||||
TextEditingController(); //钥匙名输入框
|
||||
late Contact _contact;
|
||||
late List _lockIdList;
|
||||
late bool _isSendSuccess;
|
||||
late bool _isCreateUser; //是否需要创建用户
|
||||
late bool _isRemoteUnlock; //是否远程开锁
|
||||
var _selectEffectiveDate = ''; //生效时间
|
||||
var _selectFailureDate = ''; //失效时间
|
||||
late DateTime _effectiveDateTime;
|
||||
late DateTime _failureDateTime;
|
||||
String countryName = '中国';
|
||||
String countryCode = '86';
|
||||
class _VolumeAuthorizationLockPageState
|
||||
extends State<VolumeAuthorizationLockPage> {
|
||||
final VolumeAuthorizationLockLogic logic =
|
||||
Get.put(VolumeAuthorizationLockLogic());
|
||||
final VolumeAuthorizationLockState state =
|
||||
Get.find<VolumeAuthorizationLockLogic>().state;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
state.selectWidgetType.value = widget.type;
|
||||
return SingleChildScrollView(
|
||||
child: indexChangeWidget(),
|
||||
child: Obx(indexChangeWidget),
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
|
||||
_lockIdList = [];
|
||||
_isRemoteUnlock = false;
|
||||
_isSendSuccess = false;
|
||||
_isCreateUser = false;
|
||||
DateTime dateTime = DateTime.now();
|
||||
_effectiveDateTime = dateTime;
|
||||
_failureDateTime = dateTime;
|
||||
_selectEffectiveDate =
|
||||
'${dateTime.year}-${dateTime.month}-${dateTime.day} ${dateTime.hour}:${dateTime.minute}'; //默认为当前时间
|
||||
_selectFailureDate =
|
||||
'${dateTime.year}-${dateTime.month}-${dateTime.day} ${dateTime.hour}:${dateTime.minute}'; //默认为当前时间
|
||||
}
|
||||
|
||||
Widget indexChangeWidget() {
|
||||
if (_isSendSuccess) {
|
||||
if (state.isSendSuccess.value) {
|
||||
return sendElectronicKeySucceed();
|
||||
} else {
|
||||
switch (int.parse(widget.type)) {
|
||||
@ -87,7 +53,7 @@ class _VolumeAuthorizationLockPageState extends State<VolumeAuthorizationLockPag
|
||||
{
|
||||
// 永久
|
||||
return Column(
|
||||
children: [
|
||||
children: <Widget>[
|
||||
keyInfoWidget(),
|
||||
remoteUnlockingWidget(),
|
||||
SizedBox(
|
||||
@ -100,7 +66,7 @@ class _VolumeAuthorizationLockPageState extends State<VolumeAuthorizationLockPag
|
||||
default:
|
||||
// 限时
|
||||
return Column(
|
||||
children: [
|
||||
children: <Widget>[
|
||||
keyInfoWidget(),
|
||||
keyTimeWidget(),
|
||||
remoteUnlockingWidget(),
|
||||
@ -117,47 +83,47 @@ class _VolumeAuthorizationLockPageState extends State<VolumeAuthorizationLockPag
|
||||
// 顶部钥匙信息widget
|
||||
Widget keyInfoWidget() {
|
||||
return Column(
|
||||
children: [
|
||||
children: <Widget>[
|
||||
CommonItem(
|
||||
leftTitel: TranslationLoader.lanKeys!.accountNumber!.tr,
|
||||
rightTitle: "",
|
||||
rightTitle: '',
|
||||
isHaveLine: true,
|
||||
isHaveRightWidget: true,
|
||||
rightWidget: getTFWidget(
|
||||
true,
|
||||
TranslationLoader.lanKeys!.pleaseEnterNumberOrEmail!.tr,
|
||||
_emailOrPhoneController)),
|
||||
state.emailOrPhoneController)),
|
||||
CommonItem(
|
||||
leftTitel: TranslationLoader.lanKeys!.countryAndRegion!.tr,
|
||||
rightTitle: "",
|
||||
rightTitle: '',
|
||||
isHaveLine: true,
|
||||
isHaveRightWidget: true,
|
||||
isHaveDirection: true,
|
||||
rightWidget: Text(
|
||||
'$countryName +$countryCode',
|
||||
'${state.countryName.value} +${state.countryCode.value}',
|
||||
textAlign: TextAlign.end,
|
||||
style:
|
||||
TextStyle(fontSize: 22.sp, color: AppColors.darkGrayTextColor),
|
||||
),
|
||||
action: () async {
|
||||
var result = await Navigator.pushNamed(
|
||||
final Object? result = await Navigator.pushNamed(
|
||||
context, Routers.selectCountryRegionPage);
|
||||
if (result != null) {
|
||||
result as Map<String, dynamic>;
|
||||
countryCode = result['code'];
|
||||
countryName = result['countryName'];
|
||||
setState(() {});
|
||||
state.countryCode.value = result['code'];
|
||||
state.countryName.value = result['countryName'];
|
||||
// setState(() {});
|
||||
}
|
||||
},
|
||||
),
|
||||
CommonItem(
|
||||
leftTitel: TranslationLoader.lanKeys!.name!.tr,
|
||||
rightTitle: "",
|
||||
rightTitle: '',
|
||||
isHaveRightWidget: true,
|
||||
rightWidget: getTFWidget(
|
||||
false,
|
||||
TranslationLoader.lanKeys!.pleaseEnter!.tr,
|
||||
_keyNameController)),
|
||||
state.keyNameController)),
|
||||
Container(height: 10.h),
|
||||
],
|
||||
);
|
||||
@ -166,36 +132,42 @@ class _VolumeAuthorizationLockPageState extends State<VolumeAuthorizationLockPag
|
||||
// 生效失效时间
|
||||
Widget keyTimeWidget() {
|
||||
return Column(
|
||||
children: [
|
||||
children: <Widget>[
|
||||
CommonItem(
|
||||
leftTitel: TranslationLoader.lanKeys!.effectiveTime!.tr,
|
||||
rightTitle: _selectEffectiveDate,
|
||||
rightTitle: state.selectEffectiveDate.value,
|
||||
isHaveLine: true,
|
||||
isHaveDirection: true,
|
||||
action: () {
|
||||
PDuration selectDate = PDuration.parse(_effectiveDateTime);
|
||||
final PDuration selectDate =
|
||||
PDuration.parse(state.effectiveDateTime.value);
|
||||
Pickers.showDatePicker(context,
|
||||
selectDate: selectDate, mode: DateMode.YMDHM, onConfirm: (p) {
|
||||
setState(() {
|
||||
_selectEffectiveDate =
|
||||
'${p.year}-${intToStr(p.month!)}-${intToStr(p.day!)} ${intToStr(p.hour!)}:${intToStr(p.minute!)}';
|
||||
_effectiveDateTime = DateTime.parse(_selectEffectiveDate);
|
||||
});
|
||||
selectDate: selectDate,
|
||||
mode: DateMode.YMDHM, onConfirm: (PDuration p) {
|
||||
// setState(() {
|
||||
state.selectEffectiveDate.value =
|
||||
'${p.year}-${intToStr(p.month!)}-${intToStr(p.day!)} ${intToStr(p.hour!)}:${intToStr(p.minute!)}';
|
||||
state.effectiveDateTime.value =
|
||||
DateTime.parse(state.selectEffectiveDate.value);
|
||||
// });
|
||||
});
|
||||
}),
|
||||
CommonItem(
|
||||
leftTitel: TranslationLoader.lanKeys!.failureTime!.tr,
|
||||
rightTitle: _selectFailureDate,
|
||||
rightTitle: state.selectFailureDate.value,
|
||||
isHaveDirection: true,
|
||||
action: () {
|
||||
PDuration selectDate = PDuration.parse(_failureDateTime);
|
||||
final PDuration selectDate =
|
||||
PDuration.parse(state.failureDateTime.value);
|
||||
Pickers.showDatePicker(context,
|
||||
selectDate: selectDate, mode: DateMode.YMDHM, onConfirm: (p) {
|
||||
setState(() {
|
||||
_selectFailureDate =
|
||||
'${p.year}-${intToStr(p.month!)}-${intToStr(p.day!)} ${intToStr(p.hour!)}:${intToStr(p.minute!)}';
|
||||
_failureDateTime = DateTime.parse(_selectFailureDate);
|
||||
});
|
||||
selectDate: selectDate,
|
||||
mode: DateMode.YMDHM, onConfirm: (PDuration p) {
|
||||
// setState(() {
|
||||
state.selectFailureDate.value =
|
||||
'${p.year}-${intToStr(p.month!)}-${intToStr(p.day!)} ${intToStr(p.hour!)}:${intToStr(p.minute!)}';
|
||||
state.failureDateTime.value =
|
||||
DateTime.parse(state.selectFailureDate.value);
|
||||
// });
|
||||
});
|
||||
}),
|
||||
Container(height: 10.h),
|
||||
@ -206,33 +178,46 @@ class _VolumeAuthorizationLockPageState extends State<VolumeAuthorizationLockPag
|
||||
// 远程开锁
|
||||
Widget remoteUnlockingWidget() {
|
||||
return Column(
|
||||
children: [
|
||||
children: <Widget>[
|
||||
CommonItem(
|
||||
leftTitel: TranslationLoader.lanKeys!.lock!.tr,
|
||||
rightTitle: _lockIdList.isEmpty
|
||||
rightTitle: state.lockIdList.value.isEmpty
|
||||
? TranslationLoader.lanKeys!.pleaseSelect!.tr
|
||||
: _lockIdList.length.toString(),
|
||||
: state.lockIdList.length.toString(),
|
||||
isHaveDirection: true,
|
||||
action: () {
|
||||
Navigator.pushNamed(context, Routers.massSendLockGroupListPage, arguments: {
|
||||
"keyLimits":"1"
|
||||
}).then((value) {
|
||||
Navigator.pushNamed(context, Routers.massSendLockGroupListPage,
|
||||
arguments: <String, String>{'keyLimits': '1'})
|
||||
.then((Object? value) {
|
||||
//得到选中的锁ID列表
|
||||
if (value != null) {
|
||||
value as Map<String, dynamic>;
|
||||
_lockIdList = value['selectLockIdList'];
|
||||
state.lockIdList.value = value['selectLockIdList'];
|
||||
|
||||
setState(() {});
|
||||
// setState(() {});
|
||||
}
|
||||
});
|
||||
}),
|
||||
Container(height: 10.h),
|
||||
CommonItem(
|
||||
leftTitel: TranslationLoader.lanKeys!.remoteUnlockingAllowed!.tr,
|
||||
rightTitle: "",
|
||||
leftTitel: '仅管理自己创建的用户',
|
||||
rightTitle: '',
|
||||
isHaveRightWidget: true,
|
||||
rightWidget: SizedBox(width: 60.w, height: 50.h, child: _switch()),
|
||||
action: () {}),
|
||||
isTipsImg: true,
|
||||
tipsImgAction: () {
|
||||
ShowTipView().showSureAlertDialog('授权管理员只能查看和管理自己下发的钥匙、密码等权限');
|
||||
},
|
||||
rightWidget: SizedBox(
|
||||
width: 60.w,
|
||||
height: 50.h,
|
||||
child: _onlyManageYouCreatesUserSwitch())),
|
||||
|
||||
// CommonItem(
|
||||
// leftTitel: TranslationLoader.lanKeys!.remoteUnlockingAllowed!.tr,
|
||||
// rightTitle: '',
|
||||
// isHaveRightWidget: true,
|
||||
// rightWidget: SizedBox(width: 60.w, height: 50.h, child: _switch()),
|
||||
// action: () {}),
|
||||
Container(height: 10.h),
|
||||
],
|
||||
);
|
||||
@ -240,14 +225,14 @@ class _VolumeAuthorizationLockPageState extends State<VolumeAuthorizationLockPag
|
||||
|
||||
Widget keyBottomWidget() {
|
||||
return Column(
|
||||
children: [
|
||||
children: <Widget>[
|
||||
SubmitBtn(
|
||||
btnName: TranslationLoader.lanKeys!.sure!.tr,
|
||||
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: () {
|
||||
addAuthorizedAdminRequest();
|
||||
logic.addAuthorizedAdminRequest();
|
||||
}),
|
||||
],
|
||||
);
|
||||
@ -260,7 +245,7 @@ class _VolumeAuthorizationLockPageState extends State<VolumeAuthorizationLockPag
|
||||
height: 50.h,
|
||||
width: 300.w,
|
||||
child: Row(
|
||||
children: [
|
||||
children: <Widget>[
|
||||
Expanded(
|
||||
child: TextField(
|
||||
controller: editController,
|
||||
@ -294,89 +279,51 @@ class _VolumeAuthorizationLockPageState extends State<VolumeAuthorizationLockPag
|
||||
SizedBox(
|
||||
width: 10.w,
|
||||
),
|
||||
isHaveBtn
|
||||
? Container(
|
||||
width: 30.w,
|
||||
height: 30.w,
|
||||
decoration: const BoxDecoration(
|
||||
color: Colors.white,
|
||||
image: DecorationImage(
|
||||
image: AssetImage('images/icon_addressBook.png'),
|
||||
fit: BoxFit.fill),
|
||||
),
|
||||
alignment: Alignment.center,
|
||||
child: InkWell(
|
||||
onTap: () async {
|
||||
Contact? currentContact =
|
||||
await _contactPicker.selectContact();
|
||||
setState(() {
|
||||
if (currentContact!.phoneNumbers!.isNotEmpty) {
|
||||
_emailOrPhoneController.text = currentContact
|
||||
.phoneNumbers![0]
|
||||
.replaceAll(RegExp(r"\s+\b|\b\s"), "");
|
||||
}
|
||||
if (currentContact.fullName!.isNotEmpty) {
|
||||
_keyNameController.text = currentContact.fullName!;
|
||||
}
|
||||
});
|
||||
},
|
||||
),
|
||||
)
|
||||
: Container()
|
||||
if (isHaveBtn)
|
||||
Container(
|
||||
width: 30.w,
|
||||
height: 30.w,
|
||||
decoration: const BoxDecoration(
|
||||
color: Colors.white,
|
||||
image: DecorationImage(
|
||||
image: AssetImage('images/icon_addressBook.png'),
|
||||
fit: BoxFit.fill),
|
||||
),
|
||||
alignment: Alignment.center,
|
||||
child: InkWell(
|
||||
onTap: () async {
|
||||
final Contact? currentContact =
|
||||
await state.contactPicker.selectContact();
|
||||
// setState(() {
|
||||
if (currentContact!.phoneNumbers!.isNotEmpty) {
|
||||
state.emailOrPhoneController.text = currentContact
|
||||
.phoneNumbers![0]
|
||||
.replaceAll(RegExp(r'\s+\b|\b\s'), '');
|
||||
}
|
||||
if (currentContact.fullName!.isNotEmpty) {
|
||||
state.keyNameController.text = currentContact.fullName!;
|
||||
}
|
||||
// });
|
||||
},
|
||||
),
|
||||
)
|
||||
else
|
||||
Container()
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
//发送批量授权管理员
|
||||
Future<void> addAuthorizedAdminRequest() async {
|
||||
String getFailureDateTime = '0';
|
||||
String getEffectiveDateTime = '0';
|
||||
if (widget.type == '1') {
|
||||
getFailureDateTime = _failureDateTime.millisecondsSinceEpoch.toString();
|
||||
getEffectiveDateTime =
|
||||
_effectiveDateTime.millisecondsSinceEpoch.toString();
|
||||
}
|
||||
|
||||
if (_lockIdList.isEmpty) {
|
||||
logic.showToast("请选择锁".tr);
|
||||
return;
|
||||
}
|
||||
var entity = await ApiRepository.to.addAuthorizedAdmin(
|
||||
createUser: _isCreateUser ? "1" : "0",
|
||||
endDate: getFailureDateTime,
|
||||
isRemoteUnlock: _isRemoteUnlock == true ? '1' : '2',
|
||||
keyGroupIdList: [],
|
||||
lockIdList: _lockIdList,
|
||||
name: _keyNameController.text,
|
||||
startDate: getEffectiveDateTime,
|
||||
userid: _emailOrPhoneController.text,
|
||||
countryCode: countryCode,
|
||||
usernameType: '1',
|
||||
);
|
||||
if (entity.errorCode!.codeIsSuccessful) {
|
||||
_isSendSuccess = true;
|
||||
setState(() {});
|
||||
} else {
|
||||
EasyLoading.showToast('${entity.errorMsg}', duration: 2000.milliseconds);
|
||||
if (entity.errorCode == 425) {
|
||||
//用户未注册
|
||||
_isCreateUser = true;
|
||||
addAuthorizedAdminRequest();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 发送电子钥匙成功
|
||||
Widget sendElectronicKeySucceed() {
|
||||
return Column(
|
||||
children: [
|
||||
children: <Widget>[
|
||||
Container(
|
||||
height: 250.h,
|
||||
width: 1.sw,
|
||||
color: Colors.white,
|
||||
child: Column(
|
||||
children: [
|
||||
children: <Widget>[
|
||||
SizedBox(
|
||||
height: 30.h,
|
||||
),
|
||||
@ -390,9 +337,9 @@ class _VolumeAuthorizationLockPageState extends State<VolumeAuthorizationLockPag
|
||||
),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
children: <Widget>[
|
||||
Text(
|
||||
"发送成功",
|
||||
'发送成功',
|
||||
style: TextStyle(
|
||||
fontSize: 26.sp,
|
||||
color: Colors.black,
|
||||
@ -409,7 +356,7 @@ class _VolumeAuthorizationLockPageState extends State<VolumeAuthorizationLockPag
|
||||
SubmitBtn(
|
||||
btnName: '完成'.tr,
|
||||
onClick: () {
|
||||
_isSendSuccess = false;
|
||||
state.isSendSuccess.value = false;
|
||||
Navigator.pop(context, true);
|
||||
}),
|
||||
SizedBox(
|
||||
@ -439,21 +386,37 @@ class _VolumeAuthorizationLockPageState extends State<VolumeAuthorizationLockPag
|
||||
);
|
||||
}
|
||||
|
||||
CupertinoSwitch _switch() {
|
||||
// CupertinoSwitch _switch() {
|
||||
// return CupertinoSwitch(
|
||||
// activeColor: CupertinoColors.activeBlue,
|
||||
// trackColor: CupertinoColors.systemGrey5,
|
||||
// thumbColor: CupertinoColors.white,
|
||||
// value: state.isRemoteUnlock.value,
|
||||
// onChanged: (bool value) {
|
||||
// setState(() {
|
||||
// _isRemoteUnlock = !_isRemoteUnlock;
|
||||
// });
|
||||
// },
|
||||
// );
|
||||
// }
|
||||
|
||||
//仅管理自己创建的用户
|
||||
CupertinoSwitch _onlyManageYouCreatesUserSwitch() {
|
||||
return CupertinoSwitch(
|
||||
activeColor: CupertinoColors.activeBlue,
|
||||
trackColor: CupertinoColors.systemGrey5,
|
||||
thumbColor: CupertinoColors.white,
|
||||
value: _isRemoteUnlock,
|
||||
value: state.onlyManageYouCreatesUser.value,
|
||||
onChanged: (value) {
|
||||
setState(() {
|
||||
_isRemoteUnlock = !_isRemoteUnlock;
|
||||
state.onlyManageYouCreatesUser.value =
|
||||
!state.onlyManageYouCreatesUser.value;
|
||||
});
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
String intToStr(int v) {
|
||||
return (v < 10) ? "0$v" : "$v";
|
||||
return (v < 10) ? '0$v' : '$v';
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,5 +1,26 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_native_contact_picker/flutter_native_contact_picker.dart';
|
||||
import 'package:get/get.dart';
|
||||
|
||||
|
||||
class VolumeAuthorizationLockState{
|
||||
|
||||
}
|
||||
class VolumeAuthorizationLockState {
|
||||
final FlutterContactPicker contactPicker = FlutterContactPicker();
|
||||
final TextEditingController emailOrPhoneController =
|
||||
TextEditingController(); //邮箱/手机号输入框
|
||||
final TextEditingController keyNameController =
|
||||
TextEditingController(); //钥匙名输入框
|
||||
late Contact contact;
|
||||
RxList<int> lockIdList = <int>[].obs;
|
||||
RxBool isSendSuccess = false.obs;
|
||||
RxBool isCreateUser = false.obs; //是否需要创建用户
|
||||
RxBool sRemoteUnlock = false.obs; //是否远程开锁
|
||||
RxBool onlyManageYouCreatesUser = false.obs; //只能管理您创建的用户
|
||||
RxString selectEffectiveDate =
|
||||
'${DateTime.now().year}-${DateTime.now().month}-${DateTime.now().day} ${DateTime.now().hour}:${DateTime.now().minute}'
|
||||
.obs; //生效时间
|
||||
RxString selectFailureDate = ''.obs; //失效时间
|
||||
Rx<DateTime> effectiveDateTime = DateTime.now().obs;
|
||||
Rx<DateTime> failureDateTime = DateTime.now().obs;
|
||||
RxString countryName = '中国'.obs;
|
||||
RxString countryCode = '86'.obs;
|
||||
RxString selectWidgetType = '0'.obs;
|
||||
}
|
||||
|
||||
@ -125,7 +125,7 @@ class _MassSendElectronicKeyPageState extends State<MassSendElectronicKeyPage> {
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Text(
|
||||
"发送成功".tr,
|
||||
'发送成功'.tr,
|
||||
style: TextStyle(
|
||||
fontSize: 26.sp,
|
||||
color: Colors.black,
|
||||
@ -201,9 +201,10 @@ class _MassSendElectronicKeyPageState extends State<MassSendElectronicKeyPage> {
|
||||
: state.lockIdList.length.toString(),
|
||||
isHaveDirection: true,
|
||||
action: () {
|
||||
Navigator.pushNamed(context, Routers.massSendLockGroupListPage, arguments:{
|
||||
"keyLimits":"2",
|
||||
}).then((value) {
|
||||
Navigator.pushNamed(context, Routers.massSendLockGroupListPage,
|
||||
arguments: {
|
||||
'keyLimits': '2',
|
||||
}).then((Object? value) {
|
||||
//得到选中的锁ID列表
|
||||
if (value != null) {
|
||||
value as Map<String, dynamic>;
|
||||
|
||||
@ -6,6 +6,7 @@ import 'package:star_lock/common/XSConstantMacro/XSConstantMacro.dart';
|
||||
import 'package:star_lock/main/lockDetail/electronicKey/sendElectronicKey/sendElectronicKey/view/sendElectronicKeyView_state.dart';
|
||||
import 'package:star_lock/mine/valueAddedServices/advancedFunctionRecord/advancedFunctionRecord_entity.dart';
|
||||
import 'package:star_lock/network/api_repository.dart';
|
||||
import 'package:star_lock/tools/regularExpression.dart';
|
||||
import 'package:star_lock/tools/showCupertinoAlertView.dart';
|
||||
import 'package:star_lock/tools/baseGetXController.dart';
|
||||
import 'package:star_lock/tools/commonDataManage.dart';
|
||||
@ -139,7 +140,9 @@ class SendElectronicKeyViewLogic extends BaseGetXController {
|
||||
var entity = await ApiRepository.to.sendElectronicKey(
|
||||
createUser: state.isCreateUser == true ? "1" : "0",
|
||||
countryCode: state.countryCode,
|
||||
usernameType: isPhoneNumber(state.emailOrPhoneController.text) == true
|
||||
usernameType: RegularExpression()
|
||||
.isPhoneNumber(state.emailOrPhoneController.text) ==
|
||||
true
|
||||
? '1'
|
||||
: '2',
|
||||
endDate: int.parse(endDate),
|
||||
@ -184,7 +187,8 @@ class SendElectronicKeyViewLogic extends BaseGetXController {
|
||||
|
||||
//检测实名认证是否支持开启
|
||||
Future<void> keyCheckFace() async {
|
||||
AdvancedFunctionRecordEntity entity = await ApiRepository.to.keyCheckFace(
|
||||
final AdvancedFunctionRecordEntity entity =
|
||||
await ApiRepository.to.keyCheckFace(
|
||||
lockId: CommonDataManage().currentKeyInfo.lockId ?? 0,
|
||||
);
|
||||
if (entity.errorCode!.codeIsSuccessful) {
|
||||
@ -205,19 +209,6 @@ class SendElectronicKeyViewLogic extends BaseGetXController {
|
||||
}
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
TextEditingController getCurrentController(int lineIndex) {
|
||||
TextEditingController currentController = TextEditingController();
|
||||
switch (lineIndex) {
|
||||
|
||||
@ -5,7 +5,9 @@ import 'package:get/get.dart';
|
||||
import 'package:star_lock/appRouters.dart';
|
||||
import 'package:star_lock/main/lockDetail/messageWarn/notificationMode/notificationMode_data.dart';
|
||||
import 'package:star_lock/main/lockDetail/messageWarn/notificationMode/notificationMode_logic.dart';
|
||||
import 'package:star_lock/main/lockDetail/messageWarn/notificationMode/notificationMode_state.dart';
|
||||
import 'package:star_lock/tools/commonItem.dart';
|
||||
import 'package:star_lock/tools/regularExpression.dart';
|
||||
import 'package:star_lock/tools/submitBtn.dart';
|
||||
import 'package:star_lock/translations/trans_lib.dart';
|
||||
|
||||
@ -20,8 +22,8 @@ class NotificationModePage extends StatefulWidget {
|
||||
}
|
||||
|
||||
class _NotificationModePageState extends State<NotificationModePage> {
|
||||
final logic = Get.put(NotificationModeLogic());
|
||||
final state = Get.find<NotificationModeLogic>().state;
|
||||
final NotificationModeLogic logic = Get.put(NotificationModeLogic());
|
||||
final NotificationModeState state = Get.find<NotificationModeLogic>().state;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
@ -43,7 +45,7 @@ class _NotificationModePageState extends State<NotificationModePage> {
|
||||
|
||||
Widget _buildMainView() {
|
||||
return Column(
|
||||
children: [
|
||||
children: <Widget>[
|
||||
CommonItem(
|
||||
leftTitel: 'APP推送'.tr,
|
||||
rightTitle: '管理员'.tr,
|
||||
@ -66,7 +68,7 @@ class _NotificationModePageState extends State<NotificationModePage> {
|
||||
SubmitBtn(
|
||||
btnName: '确定'.tr,
|
||||
onClick: () {
|
||||
Get.back(result: {
|
||||
Get.back(result: <String, List>{
|
||||
'emailReceiverList': state.emailReceiverList.value,
|
||||
'phoneReceiverList': state.phoneReceiverList.value
|
||||
});
|
||||
@ -135,9 +137,9 @@ class _NotificationModePageState extends State<NotificationModePage> {
|
||||
height: 62.h,
|
||||
color: Colors.white,
|
||||
child: Row(
|
||||
children: [
|
||||
children: <Widget>[
|
||||
GestureDetector(
|
||||
onTap: (() {
|
||||
onTap: () {
|
||||
if (isEmail) {
|
||||
state.emailReceiverList.value.removeAt(index);
|
||||
state.emailReceiverList.refresh();
|
||||
@ -145,7 +147,7 @@ class _NotificationModePageState extends State<NotificationModePage> {
|
||||
state.phoneReceiverList.value.removeAt(index);
|
||||
state.phoneReceiverList.refresh();
|
||||
}
|
||||
}),
|
||||
},
|
||||
child: Container(
|
||||
color: Colors.white,
|
||||
child: Image.asset(
|
||||
@ -163,39 +165,40 @@ class _NotificationModePageState extends State<NotificationModePage> {
|
||||
style: TextStyle(fontSize: 22.sp),
|
||||
),
|
||||
Expanded(child: SizedBox(width: 10.w)),
|
||||
!isEmail
|
||||
? GestureDetector(
|
||||
child: Container(
|
||||
width: 90.w,
|
||||
color: Colors.white,
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.end,
|
||||
children: [
|
||||
Obx(() => Text(
|
||||
'+${state.countryCode}',
|
||||
style: TextStyle(
|
||||
color: AppColors.darkGrayTextColor,
|
||||
fontSize: 20.sp),
|
||||
)),
|
||||
Image.asset(
|
||||
'images/icon_grayPullDown.png',
|
||||
width: 20.w,
|
||||
height: 20.w,
|
||||
),
|
||||
],
|
||||
if (!isEmail)
|
||||
GestureDetector(
|
||||
child: Container(
|
||||
width: 90.w,
|
||||
color: Colors.white,
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.end,
|
||||
children: <Widget>[
|
||||
Obx(() => Text(
|
||||
'+${state.countryCode}',
|
||||
style: TextStyle(
|
||||
color: AppColors.darkGrayTextColor,
|
||||
fontSize: 20.sp),
|
||||
)),
|
||||
Image.asset(
|
||||
'images/icon_grayPullDown.png',
|
||||
width: 20.w,
|
||||
height: 20.w,
|
||||
),
|
||||
),
|
||||
onTap: () async {
|
||||
var result =
|
||||
await Get.toNamed(Routers.selectCountryRegionPage);
|
||||
if (result != null) {
|
||||
result as Map<String, dynamic>;
|
||||
state.countryCode.value = result['code'];
|
||||
state.countryName.value = result['countryName'];
|
||||
}
|
||||
},
|
||||
)
|
||||
: Container(),
|
||||
],
|
||||
),
|
||||
),
|
||||
onTap: () async {
|
||||
final result =
|
||||
await Get.toNamed(Routers.selectCountryRegionPage);
|
||||
if (result != null) {
|
||||
result as Map<String, dynamic>;
|
||||
state.countryCode.value = result['code'];
|
||||
state.countryName.value = result['countryName'];
|
||||
}
|
||||
},
|
||||
)
|
||||
else
|
||||
Container(),
|
||||
getReceiverTFWidget(isEmail ? '请输入Email'.tr : '请输入手机号'.tr, index,
|
||||
isEmail: isEmail)
|
||||
],
|
||||
@ -206,7 +209,7 @@ class _NotificationModePageState extends State<NotificationModePage> {
|
||||
// 接受者信息输入框
|
||||
Widget getReceiverTFWidget(String tfStr, int lineIndex,
|
||||
{required bool isEmail}) {
|
||||
MsgNoticeModeData msgData = isEmail
|
||||
final MsgNoticeModeData msgData = isEmail
|
||||
? state.emailReceiverList.value[lineIndex]
|
||||
: state.phoneReceiverList.value[lineIndex];
|
||||
msgData.countryCode = state.countryCode.value;
|
||||
@ -216,7 +219,7 @@ class _NotificationModePageState extends State<NotificationModePage> {
|
||||
height: 65.h,
|
||||
width: 200.w,
|
||||
child: Row(
|
||||
children: [
|
||||
children: <Widget>[
|
||||
Expanded(
|
||||
child: TextField(
|
||||
controller: msgData.receiverTF,
|
||||
@ -247,7 +250,7 @@ class _NotificationModePageState extends State<NotificationModePage> {
|
||||
),
|
||||
style: TextStyle(
|
||||
fontSize: 22.sp, textBaseline: TextBaseline.alphabetic),
|
||||
onChanged: (value) {
|
||||
onChanged: (String value) {
|
||||
if (isEmail) {
|
||||
msgData.receiveEmail = value;
|
||||
state.emailReceiverList.value[lineIndex] = msgData;
|
||||
|
||||
@ -14,7 +14,7 @@ class StarLockMineLogic extends BaseGetXController {
|
||||
|
||||
//用户信息
|
||||
Future<void> getUserInfoRequest() async {
|
||||
MinePersonInfoEntity entity = await ApiRepository.to.getUserInfo();
|
||||
final MinePersonInfoEntity entity = await ApiRepository.to.getUserInfo();
|
||||
if (entity.errorCode!.codeIsSuccessful) {
|
||||
state.mineInfoData.value = entity.data!;
|
||||
state.isVip.value = state.mineInfoData.value.isVip! == 0 ? false : true;
|
||||
@ -24,7 +24,7 @@ class StarLockMineLogic extends BaseGetXController {
|
||||
|
||||
//删除账号请求
|
||||
Future<void> userLogoutRequest() async {
|
||||
LoginEntity entity = await ApiRepository.to.userLogout(deviceld: '');
|
||||
final LoginEntity entity = await ApiRepository.to.userLogout(deviceld: '');
|
||||
if (entity.errorCode!.codeIsSuccessful) {}
|
||||
}
|
||||
|
||||
@ -32,14 +32,15 @@ class StarLockMineLogic extends BaseGetXController {
|
||||
StreamSubscription? _mineInfoChangeRefreshUIEvent;
|
||||
void _mineInfoChangeRefreshUIAction() {
|
||||
// 蓝牙协议通知传输跟蓝牙之外的数据传输类不一样 eventBus
|
||||
_mineInfoChangeRefreshUIEvent =
|
||||
eventBus.on<MineInfoChangeRefreshUI>().listen((event) {
|
||||
_mineInfoChangeRefreshUIEvent = eventBus
|
||||
.on<MineInfoChangeRefreshUI>()
|
||||
.listen((MineInfoChangeRefreshUI event) {
|
||||
getMineInfoData();
|
||||
});
|
||||
}
|
||||
|
||||
getMineInfoData() async {
|
||||
final data = await Storage.getString(saveUserLoginData);
|
||||
final String? data = await Storage.getString(saveUserLoginData);
|
||||
if (data != null && data.isNotEmpty) {
|
||||
state.userNickName.value = (await Storage.getNickname())!;
|
||||
state.userMobile.value = (await Storage.getMobile())! ?? '';
|
||||
|
||||
@ -2,6 +2,7 @@ import 'package:flutter/material.dart';
|
||||
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:star_lock/flavors.dart';
|
||||
import 'package:star_lock/mine/mine/starLockMine_state.dart';
|
||||
import 'package:star_lock/tools/commonDataManage.dart';
|
||||
|
||||
import '../../appRouters.dart';
|
||||
@ -22,8 +23,8 @@ class StarLockMinePage extends StatefulWidget {
|
||||
GlobalKey<StarLockMinePageState> starLockMineKey = GlobalKey();
|
||||
|
||||
class StarLockMinePageState extends State<StarLockMinePage> with BaseWidget {
|
||||
final logic = Get.put(StarLockMineLogic());
|
||||
final state = Get.find<StarLockMineLogic>().state;
|
||||
final StarLockMineLogic logic = Get.put(StarLockMineLogic());
|
||||
final StarLockMineState state = Get.find<StarLockMineLogic>().state;
|
||||
|
||||
@override
|
||||
initState() {
|
||||
@ -36,7 +37,7 @@ class StarLockMinePageState extends State<StarLockMinePage> with BaseWidget {
|
||||
return Scaffold(
|
||||
backgroundColor: const Color(0xFFFFFFFF),
|
||||
body: Column(
|
||||
children: [
|
||||
children: <Widget>[
|
||||
topWidget(),
|
||||
bottomListWidget(),
|
||||
SizedBox(
|
||||
@ -54,7 +55,7 @@ class StarLockMinePageState extends State<StarLockMinePage> with BaseWidget {
|
||||
color: AppColors.mainColor,
|
||||
// color: Colors.red,
|
||||
child: Stack(
|
||||
children: [
|
||||
children: <Widget>[
|
||||
Image.asset(
|
||||
'images/mine/icon_mine_topBg.png',
|
||||
width: 400.w,
|
||||
@ -63,7 +64,7 @@ class StarLockMinePageState extends State<StarLockMinePage> with BaseWidget {
|
||||
),
|
||||
Center(
|
||||
child: Column(
|
||||
children: [
|
||||
children: <Widget>[
|
||||
SizedBox(
|
||||
height: 120.h,
|
||||
),
|
||||
@ -97,7 +98,7 @@ class StarLockMinePageState extends State<StarLockMinePage> with BaseWidget {
|
||||
logic.showToast('请先添加锁');
|
||||
} else {
|
||||
Get.toNamed(Routers.advancedFeaturesWebPage,
|
||||
arguments: {'isShop': true});
|
||||
arguments: <String, bool>{'isShop': true});
|
||||
}
|
||||
} else {
|
||||
Get.toNamed(
|
||||
@ -108,7 +109,7 @@ class StarLockMinePageState extends State<StarLockMinePage> with BaseWidget {
|
||||
color: Colors.transparent,
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
children: <Widget>[
|
||||
Text(
|
||||
state.userNickName.value.isNotEmpty
|
||||
? state.userNickName.value
|
||||
@ -122,17 +123,18 @@ class StarLockMinePageState extends State<StarLockMinePage> with BaseWidget {
|
||||
SizedBox(
|
||||
width: 5.w,
|
||||
),
|
||||
!state.isVip.value
|
||||
? Image.asset(
|
||||
'images/mine/icon_mine_noPlus.png',
|
||||
width: 20.w,
|
||||
height: 20.w,
|
||||
)
|
||||
: Image.asset(
|
||||
'images/mine/icon_mine_isPlus.png',
|
||||
width: 20.w,
|
||||
height: 20.w,
|
||||
),
|
||||
if (!state.isVip.value)
|
||||
Image.asset(
|
||||
'images/mine/icon_mine_noPlus.png',
|
||||
width: 20.w,
|
||||
height: 20.w,
|
||||
)
|
||||
else
|
||||
Image.asset(
|
||||
'images/mine/icon_mine_isPlus.png',
|
||||
width: 20.w,
|
||||
height: 20.w,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
@ -183,20 +185,22 @@ class StarLockMinePageState extends State<StarLockMinePage> with BaseWidget {
|
||||
Get.toNamed(Routers.mineSetPage);
|
||||
}),
|
||||
//上架审核
|
||||
F.isLite
|
||||
? Container()
|
||||
: mineItem('images/mine/icon_mine_main_vip.png',
|
||||
TranslationLoader.lanKeys!.valueAddedServices!.tr, () {
|
||||
Get.back();
|
||||
Get.toNamed(Routers.valueAddedServicesPage);
|
||||
}),
|
||||
F.isLite
|
||||
? Container()
|
||||
: mineItem(
|
||||
'images/mine/icon_mine_main_shoppingcart.png', "配件商城".tr, () {
|
||||
Get.back();
|
||||
Get.toNamed(Routers.lockMallPage);
|
||||
}),
|
||||
if (F.isLite)
|
||||
Container()
|
||||
else
|
||||
mineItem('images/mine/icon_mine_main_vip.png',
|
||||
TranslationLoader.lanKeys!.valueAddedServices!.tr, () {
|
||||
Get.back();
|
||||
Get.toNamed(Routers.valueAddedServicesPage);
|
||||
}),
|
||||
if (F.isLite)
|
||||
Container()
|
||||
else
|
||||
mineItem('images/mine/icon_mine_main_shoppingcart.png', '配件商城'.tr,
|
||||
() {
|
||||
Get.back();
|
||||
Get.toNamed(Routers.lockMallPage);
|
||||
}),
|
||||
mineItem('images/mine/icon_mine_main_about.png',
|
||||
TranslationLoader.lanKeys!.about!.tr, () {
|
||||
Get.back();
|
||||
@ -209,7 +213,7 @@ class StarLockMinePageState extends State<StarLockMinePage> with BaseWidget {
|
||||
|
||||
Widget keyBottomWidget() {
|
||||
return Column(
|
||||
children: [
|
||||
children: <Widget>[
|
||||
SubmitBtn(
|
||||
btnName: TranslationLoader.lanKeys!.logout!.tr,
|
||||
borderRadius: 20.w,
|
||||
@ -222,7 +226,7 @@ class StarLockMinePageState extends State<StarLockMinePage> with BaseWidget {
|
||||
// color: Colors.red,
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.end,
|
||||
children: [
|
||||
children: <Widget>[
|
||||
TextButton(
|
||||
child: Text(
|
||||
TranslationLoader.lanKeys!.deleteAccount!.tr,
|
||||
@ -246,7 +250,7 @@ class StarLockMinePageState extends State<StarLockMinePage> with BaseWidget {
|
||||
return GestureDetector(
|
||||
onTap: action,
|
||||
child: Row(
|
||||
children: [
|
||||
children: <Widget>[
|
||||
Center(
|
||||
child: Container(
|
||||
// height: 80.h,
|
||||
@ -254,7 +258,7 @@ class StarLockMinePageState extends State<StarLockMinePage> with BaseWidget {
|
||||
padding: EdgeInsets.all(20.h),
|
||||
color: Colors.white,
|
||||
child: Row(
|
||||
children: [
|
||||
children: <Widget>[
|
||||
Image.asset(
|
||||
lockTypeIcon,
|
||||
width: 28.w,
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:star_lock/main/lockDetail/lockSet/basicInformation/basicInformation/KeyDetailEntity.dart';
|
||||
import 'package:star_lock/network/api_repository.dart';
|
||||
import 'package:star_lock/tools/baseGetXController.dart';
|
||||
import 'package:star_lock/translations/trans_lib.dart';
|
||||
@ -16,44 +17,46 @@ class AddAuthorizedAdministratorLogic extends BaseGetXController {
|
||||
final RegExp phoneRegExp = RegExp(r'^\d{11}$');
|
||||
return phoneRegExp.hasMatch(input);
|
||||
}
|
||||
|
||||
//发送批量授权管理员
|
||||
Future<void> addAuthorizedAdminRequest() async {
|
||||
if (state.emailOrPhoneController.text.isEmpty) {
|
||||
showToast("请输入接收者账号");
|
||||
showToast('请输入接收者账号');
|
||||
return;
|
||||
}
|
||||
if (state.keyNameController.text.isEmpty) {
|
||||
showToast("请输入接收者姓名");
|
||||
showToast('请输入接收者姓名');
|
||||
return;
|
||||
}
|
||||
|
||||
if(state.lockIdList.isEmpty){
|
||||
showToast("请选择锁".tr);
|
||||
if (state.lockIdList.isEmpty) {
|
||||
showToast('请选择锁'.tr);
|
||||
return;
|
||||
}
|
||||
|
||||
var startDate = "0";
|
||||
var endDate = "0";
|
||||
String startDate = '0';
|
||||
String endDate = '0';
|
||||
if (state.type.value == '0') {
|
||||
startDate = DateTool().dateToTimestamp(state.beginDate.value, 1).toString();
|
||||
startDate =
|
||||
DateTool().dateToTimestamp(state.beginDate.value, 1).toString();
|
||||
endDate = DateTool().dateToTimestamp(state.endDate.value, 1).toString();
|
||||
|
||||
if (startDate.isEmpty) {
|
||||
showToast("请选择开始时间");
|
||||
showToast('请选择开始时间');
|
||||
return;
|
||||
}
|
||||
if (endDate.isEmpty) {
|
||||
showToast("请选择结束时间");
|
||||
showToast('请选择结束时间');
|
||||
return;
|
||||
}
|
||||
|
||||
if (int.parse(startDate) >= int.parse(endDate)) {
|
||||
showToast("失效时间要大于生效时间");
|
||||
showToast('失效时间要大于生效时间');
|
||||
return;
|
||||
}
|
||||
}
|
||||
var entity = await ApiRepository.to.addAuthorizedAdmin(
|
||||
createUser: state.isCreateUser.value ? "1" : "0",
|
||||
final KeyDetailEntity entity = await ApiRepository.to.addAuthorizedAdmin(
|
||||
createUser: state.isCreateUser.value ? '1' : '0',
|
||||
endDate: endDate,
|
||||
isRemoteUnlock: state.isRemoteUnlock.value == true ? '1' : '2',
|
||||
keyGroupIdList: [],
|
||||
@ -62,9 +65,9 @@ class AddAuthorizedAdministratorLogic extends BaseGetXController {
|
||||
startDate: startDate,
|
||||
userid: state.emailOrPhoneController.text,
|
||||
countryCode: state.countryCode.value,
|
||||
usernameType: isPhoneNumber(state.emailOrPhoneController.text) == true
|
||||
? '1'
|
||||
: '2',
|
||||
usernameType:
|
||||
isPhoneNumber(state.emailOrPhoneController.text) == true ? '1' : '2',
|
||||
isOnlyManageSelf: state.onlyManageYouCreatesUser.value == true ? 1 : 2,
|
||||
);
|
||||
if (entity.errorCode!.codeIsSuccessful) {
|
||||
state.isSendSuccess.value = true;
|
||||
@ -77,7 +80,7 @@ class AddAuthorizedAdministratorLogic extends BaseGetXController {
|
||||
if (entity.errorCode == 425) {
|
||||
//用户未注册
|
||||
state.isCreateUser.value = true;
|
||||
_showDialog("${entity.errorMsg}");
|
||||
_showDialog('${entity.errorMsg}');
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -86,15 +89,13 @@ class AddAuthorizedAdministratorLogic extends BaseGetXController {
|
||||
void _showDialog(String errMsg) {
|
||||
showCupertinoDialog(
|
||||
context: Get.context!,
|
||||
builder: (context) {
|
||||
builder: (BuildContext context) {
|
||||
return CupertinoAlertDialog(
|
||||
title: const Text('接收者号码未注册,请重新发送'),
|
||||
actions: [
|
||||
actions: <Widget>[
|
||||
CupertinoDialogAction(
|
||||
child: Text(TranslationLoader.lanKeys!.cancel!.tr),
|
||||
onPressed: () {
|
||||
Get.back();
|
||||
},
|
||||
onPressed: Get.back,
|
||||
),
|
||||
CupertinoDialogAction(
|
||||
child: Text(TranslationLoader.lanKeys!.sure!.tr),
|
||||
|
||||
@ -6,10 +6,12 @@ import 'package:flutter_screenutil/flutter_screenutil.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:star_lock/appRouters.dart';
|
||||
import 'package:star_lock/app_settings/app_colors.dart';
|
||||
import 'package:star_lock/mine/mineSet/authorizedAdministrator/addAuthorizedAdministrator/addAuthorizedAdministrator_state.dart';
|
||||
import 'package:star_lock/tools/commonItem.dart';
|
||||
import 'package:star_lock/tools/pickers/pickers.dart';
|
||||
import 'package:star_lock/tools/pickers/time_picker/model/date_mode.dart';
|
||||
import 'package:star_lock/tools/pickers/time_picker/model/pduration.dart';
|
||||
import 'package:star_lock/tools/showTipView.dart';
|
||||
import 'package:star_lock/tools/submitBtn.dart';
|
||||
import 'package:star_lock/translations/trans_lib.dart';
|
||||
|
||||
@ -18,10 +20,9 @@ import '../../../../tools/dateTool.dart';
|
||||
import 'addAuthorizedAdministrator_logic.dart';
|
||||
|
||||
class AddAuthorizedAdministratorPage extends StatefulWidget {
|
||||
String type;
|
||||
|
||||
AddAuthorizedAdministratorPage({Key? key, required this.type})
|
||||
AddAuthorizedAdministratorPage({required this.type, Key? key})
|
||||
: super(key: key);
|
||||
String type;
|
||||
|
||||
@override
|
||||
State<StatefulWidget> createState() {
|
||||
@ -32,8 +33,10 @@ class AddAuthorizedAdministratorPage extends StatefulWidget {
|
||||
class _AddAuthorizedAdministratorPageState
|
||||
extends State<AddAuthorizedAdministratorPage>
|
||||
with SingleTickerProviderStateMixin {
|
||||
final logic = Get.put(AddAuthorizedAdministratorLogic());
|
||||
final state = Get.find<AddAuthorizedAdministratorLogic>().state;
|
||||
final AddAuthorizedAdministratorLogic logic =
|
||||
Get.put(AddAuthorizedAdministratorLogic());
|
||||
final AddAuthorizedAdministratorState state =
|
||||
Get.find<AddAuthorizedAdministratorLogic>().state;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
@ -67,9 +70,9 @@ class _AddAuthorizedAdministratorPageState
|
||||
: state.lockIdList.value.length.toString(),
|
||||
isHaveDirection: true,
|
||||
action: () {
|
||||
Navigator.pushNamed(context, Routers.massSendLockGroupListPage, arguments: {
|
||||
"keyLimits":"1"
|
||||
}).then((value) {
|
||||
Navigator.pushNamed(context, Routers.massSendLockGroupListPage,
|
||||
arguments: <String, String>{'keyLimits': '1'})
|
||||
.then((Object? value) {
|
||||
//得到选中的锁ID列表
|
||||
if (value != null) {
|
||||
value as Map<String, dynamic>;
|
||||
@ -82,7 +85,19 @@ class _AddAuthorizedAdministratorPageState
|
||||
SizedBox(
|
||||
height: 10.h,
|
||||
),
|
||||
remoteUnlockingWidget(),
|
||||
CommonItem(
|
||||
leftTitel: '仅管理自己创建的用户',
|
||||
rightTitle: '',
|
||||
isHaveRightWidget: true,
|
||||
isTipsImg: true,
|
||||
tipsImgAction: () {
|
||||
ShowTipView().showSureAlertDialog('授权管理员只能查看和管理自己下发的钥匙、密码等权限');
|
||||
},
|
||||
rightWidget: SizedBox(
|
||||
width: 60.w,
|
||||
height: 50.h,
|
||||
child: _onlyManageYouCreatesUserSwitch())),
|
||||
// remoteUnlockingWidget(),
|
||||
SizedBox(
|
||||
height: 20.h,
|
||||
),
|
||||
@ -110,9 +125,10 @@ class _AddAuthorizedAdministratorPageState
|
||||
: state.lockIdList.value.length.toString(),
|
||||
isHaveDirection: true,
|
||||
action: () {
|
||||
Navigator.pushNamed(context, Routers.massSendLockGroupListPage,arguments:{
|
||||
"keyLimits":"1",
|
||||
}).then((value) {
|
||||
Navigator.pushNamed(context, Routers.massSendLockGroupListPage,
|
||||
arguments: {
|
||||
'keyLimits': '1',
|
||||
}).then((Object? value) {
|
||||
//得到选中的锁ID列表
|
||||
if (value != null) {
|
||||
value as Map<String, dynamic>;
|
||||
@ -125,7 +141,19 @@ class _AddAuthorizedAdministratorPageState
|
||||
SizedBox(
|
||||
height: 10.h,
|
||||
),
|
||||
remoteUnlockingWidget(),
|
||||
// remoteUnlockingWidget(),
|
||||
CommonItem(
|
||||
leftTitel: '仅管理自己创建的用户',
|
||||
rightTitle: '',
|
||||
isHaveRightWidget: true,
|
||||
isTipsImg: true,
|
||||
tipsImgAction: () {
|
||||
ShowTipView().showSureAlertDialog('授权管理员只能查看和管理自己下发的钥匙、密码等权限');
|
||||
},
|
||||
rightWidget: SizedBox(
|
||||
width: 60.w,
|
||||
height: 50.h,
|
||||
child: _onlyManageYouCreatesUserSwitch())),
|
||||
SizedBox(
|
||||
height: 20.h,
|
||||
),
|
||||
@ -141,7 +169,7 @@ class _AddAuthorizedAdministratorPageState
|
||||
children: [
|
||||
CommonItem(
|
||||
leftTitel: TranslationLoader.lanKeys!.accountNumber!.tr,
|
||||
rightTitle: "",
|
||||
rightTitle: '',
|
||||
isHaveLine: true,
|
||||
isHaveRightWidget: true,
|
||||
rightWidget: getTFWidget(
|
||||
@ -150,7 +178,7 @@ class _AddAuthorizedAdministratorPageState
|
||||
state.emailOrPhoneController)),
|
||||
CommonItem(
|
||||
leftTitel: TranslationLoader.lanKeys!.countryAndRegion!.tr,
|
||||
rightTitle: "",
|
||||
rightTitle: '',
|
||||
isHaveLine: true,
|
||||
isHaveRightWidget: true,
|
||||
isHaveDirection: true,
|
||||
@ -173,7 +201,7 @@ class _AddAuthorizedAdministratorPageState
|
||||
),
|
||||
CommonItem(
|
||||
leftTitel: TranslationLoader.lanKeys!.name!.tr,
|
||||
rightTitle: "",
|
||||
rightTitle: '',
|
||||
isHaveRightWidget: true,
|
||||
rightWidget: getTFWidget(
|
||||
false,
|
||||
@ -228,50 +256,67 @@ class _AddAuthorizedAdministratorPageState
|
||||
SizedBox(
|
||||
width: 10.w,
|
||||
),
|
||||
isHaveBtn
|
||||
? Container(
|
||||
width: 30.w,
|
||||
height: 30.w,
|
||||
decoration: const BoxDecoration(
|
||||
color: Colors.white,
|
||||
image: DecorationImage(
|
||||
image: AssetImage('images/icon_addressBook.png'),
|
||||
fit: BoxFit.fill),
|
||||
),
|
||||
alignment: Alignment.center,
|
||||
child: InkWell(
|
||||
onTap: () async {
|
||||
Contact? currentContact =
|
||||
await state.contactPicker.selectContact();
|
||||
setState(() {
|
||||
if (currentContact!.phoneNumbers!.isNotEmpty) {
|
||||
state.emailOrPhoneController.text = currentContact
|
||||
.phoneNumbers![0]
|
||||
.replaceAll(RegExp(r"\s+\b|\b\s"), "");
|
||||
}
|
||||
});
|
||||
},
|
||||
),
|
||||
)
|
||||
: Container()
|
||||
if (isHaveBtn)
|
||||
Container(
|
||||
width: 30.w,
|
||||
height: 30.w,
|
||||
decoration: const BoxDecoration(
|
||||
color: Colors.white,
|
||||
image: DecorationImage(
|
||||
image: AssetImage('images/icon_addressBook.png'),
|
||||
fit: BoxFit.fill),
|
||||
),
|
||||
alignment: Alignment.center,
|
||||
child: InkWell(
|
||||
onTap: () async {
|
||||
final Contact? currentContact =
|
||||
await state.contactPicker.selectContact();
|
||||
setState(() {
|
||||
if (currentContact!.phoneNumbers!.isNotEmpty) {
|
||||
state.emailOrPhoneController.text = currentContact
|
||||
.phoneNumbers![0]
|
||||
.replaceAll(RegExp(r'\s+\b|\b\s'), '');
|
||||
}
|
||||
});
|
||||
},
|
||||
),
|
||||
)
|
||||
else
|
||||
Container()
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
// 远程开锁
|
||||
Widget remoteUnlockingWidget() {
|
||||
return Column(
|
||||
children: [
|
||||
CommonItem(
|
||||
leftTitel: TranslationLoader.lanKeys!.remoteUnlockingAllowed!.tr,
|
||||
rightTitle: "",
|
||||
isHaveRightWidget: true,
|
||||
rightWidget: SizedBox(
|
||||
width: 60.w, height: 50.h, child: Obx(() => _switch())),
|
||||
action: () {}),
|
||||
Container(height: 40.h),
|
||||
],
|
||||
// Widget remoteUnlockingWidget() {
|
||||
// return Column(
|
||||
// children: [
|
||||
// CommonItem(
|
||||
// leftTitel: TranslationLoader.lanKeys!.remoteUnlockingAllowed!.tr,
|
||||
// rightTitle: '',
|
||||
// isHaveRightWidget: true,
|
||||
// rightWidget:
|
||||
// SizedBox(width: 60.w, height: 50.h, child: Obx(_switch)),
|
||||
// action: () {}),
|
||||
// Container(height: 40.h),
|
||||
// ],
|
||||
// );
|
||||
// }
|
||||
|
||||
//仅管理自己创建的用户
|
||||
CupertinoSwitch _onlyManageYouCreatesUserSwitch() {
|
||||
return CupertinoSwitch(
|
||||
activeColor: CupertinoColors.activeBlue,
|
||||
trackColor: CupertinoColors.systemGrey5,
|
||||
thumbColor: CupertinoColors.white,
|
||||
value: state.onlyManageYouCreatesUser.value,
|
||||
onChanged: (value) {
|
||||
setState(() {
|
||||
state.onlyManageYouCreatesUser.value =
|
||||
!state.onlyManageYouCreatesUser.value;
|
||||
});
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
@ -285,7 +330,7 @@ class _AddAuthorizedAdministratorPageState
|
||||
isHaveLine: true,
|
||||
isHaveDirection: true,
|
||||
action: () {
|
||||
PDuration selectDate =
|
||||
final PDuration selectDate =
|
||||
PDuration.parse(DateTime.tryParse(state.beginDate.value));
|
||||
Pickers.showDatePicker(context,
|
||||
selectDate: selectDate, mode: DateMode.YMDHM, onConfirm: (p) {
|
||||
@ -299,7 +344,7 @@ class _AddAuthorizedAdministratorPageState
|
||||
rightTitle: state.endDate.value,
|
||||
isHaveDirection: true,
|
||||
action: () {
|
||||
PDuration selectDate =
|
||||
final PDuration selectDate =
|
||||
PDuration.parse(DateTime.tryParse(state.endDate.value));
|
||||
Pickers.showDatePicker(context,
|
||||
selectDate: selectDate, mode: DateMode.YMDHM, onConfirm: (p) {
|
||||
@ -314,12 +359,12 @@ class _AddAuthorizedAdministratorPageState
|
||||
|
||||
Widget keyBottomWidget(String tipStr) {
|
||||
return Column(
|
||||
children: [
|
||||
children: <Widget>[
|
||||
Container(
|
||||
padding: EdgeInsets.all(20.w),
|
||||
child: Row(
|
||||
// crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
children: <Widget>[
|
||||
Expanded(
|
||||
child: Text(
|
||||
tipStr,
|
||||
@ -341,7 +386,7 @@ class _AddAuthorizedAdministratorPageState
|
||||
// color: Colors.red,
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.end,
|
||||
children: [
|
||||
children: <Widget>[
|
||||
TextButton(
|
||||
onPressed: () {
|
||||
Navigator.pushNamed(
|
||||
@ -366,7 +411,7 @@ class _AddAuthorizedAdministratorPageState
|
||||
trackColor: CupertinoColors.systemGrey5,
|
||||
thumbColor: CupertinoColors.white,
|
||||
value: state.isRemoteUnlock.value,
|
||||
onChanged: (value) {
|
||||
onChanged: (bool value) {
|
||||
state.isRemoteUnlock.value = !state.isRemoteUnlock.value;
|
||||
},
|
||||
);
|
||||
@ -390,7 +435,7 @@ class _AddAuthorizedAdministratorPageState
|
||||
width: 1.sw,
|
||||
color: Colors.white,
|
||||
child: Column(
|
||||
children: [
|
||||
children: <Widget>[
|
||||
SizedBox(
|
||||
height: 30.h,
|
||||
),
|
||||
@ -406,7 +451,7 @@ class _AddAuthorizedAdministratorPageState
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Text(
|
||||
"发送成功",
|
||||
'发送成功',
|
||||
style: TextStyle(
|
||||
fontSize: 26.sp,
|
||||
color: Colors.black,
|
||||
@ -431,9 +476,9 @@ class _AddAuthorizedAdministratorPageState
|
||||
),
|
||||
OutLineBtn(
|
||||
btnName:
|
||||
state.emailOrPhoneController.text.contains("@") ? '邮件通知' : "短信通知",
|
||||
state.emailOrPhoneController.text.contains('@') ? '邮件通知' : '短信通知',
|
||||
onClick: () {
|
||||
if (state.emailOrPhoneController.text.contains("@")) {
|
||||
if (state.emailOrPhoneController.text.contains('@')) {
|
||||
Get.toNamed(Routers.sendEmailNotificationPage);
|
||||
} else {
|
||||
// _openModalBottomSheet();
|
||||
@ -468,7 +513,7 @@ class _AddAuthorizedAdministratorPageState
|
||||
}
|
||||
|
||||
List<Widget> initBottomSheetList() {
|
||||
List<Widget> widgetList = [];
|
||||
final List<Widget> widgetList = <Widget>[];
|
||||
|
||||
widgetList.add(buildCenter3('images/icon_wechat.png', '微信好友', 0));
|
||||
widgetList.add(buildCenter3('images/icon_message.png', '短信', 1));
|
||||
@ -510,7 +555,7 @@ class _AddAuthorizedAdministratorPageState
|
||||
}
|
||||
|
||||
//\n生效时间:${itemData.startDate}\n类型:永久\n锁名:${itemData.keyboardPwdName}
|
||||
_jumpSmartDeviceRoute(int itemIndex) {
|
||||
void _jumpSmartDeviceRoute(int itemIndex) {
|
||||
Get.back();
|
||||
switch (itemIndex) {
|
||||
case 0:
|
||||
|
||||
@ -1,4 +1,3 @@
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_native_contact_picker/flutter_native_contact_picker.dart';
|
||||
import 'package:get/get.dart';
|
||||
@ -14,26 +13,25 @@ class AddAuthorizedAdministratorState {
|
||||
|
||||
final FlutterContactPicker contactPicker = FlutterContactPicker();
|
||||
late Contact contact;
|
||||
var type = ''.obs;
|
||||
RxString type = ''.obs;
|
||||
var lockIdList = [].obs;
|
||||
var weekdaysList = [].obs;
|
||||
var isCreateUser = false.obs; //用户未注册时传1 已注册传0
|
||||
RxBool isCreateUser = false.obs; //用户未注册时传1 已注册传0
|
||||
|
||||
var beginDate = DateTool().dateToYMDHNString(DateTime.now().millisecondsSinceEpoch.toString()).obs; //默认为当前时间 开始时间
|
||||
var endDate = DateTool().dateToYMDHNString(DateTime.now().millisecondsSinceEpoch.toString()).obs;//
|
||||
RxString beginDate = DateTool()
|
||||
.dateToYMDHNString(DateTime.now().millisecondsSinceEpoch.toString())
|
||||
.obs; //默认为当前时间 开始时间
|
||||
RxString endDate = DateTool()
|
||||
.dateToYMDHNString(DateTime.now().millisecondsSinceEpoch.toString())
|
||||
.obs; //
|
||||
|
||||
var countryName = '中国'.obs;
|
||||
var countryCode = '86'.obs;
|
||||
var isSendSuccess = false.obs;
|
||||
final isRemoteUnlock = false.obs; //是否允许远程开锁
|
||||
final isAuthentication = false.obs; //是否允许实名认证
|
||||
final keyInfo = LockListInfoItemEntity().obs;
|
||||
RxString countryName = '中国'.obs;
|
||||
RxString countryCode = '86'.obs;
|
||||
RxBool isSendSuccess = false.obs;
|
||||
final RxBool isRemoteUnlock = false.obs; //是否允许远程开锁
|
||||
final RxBool isAuthentication = false.obs; //是否允许实名认证
|
||||
final RxBool onlyManageYouCreatesUser = false.obs; //只能管理您创建的用户
|
||||
final Rx<LockListInfoItemEntity> keyInfo = LockListInfoItemEntity().obs;
|
||||
|
||||
String pwdShareStr = '您好,您的授权管理员生成成功';
|
||||
AddAuthorizedAdministratorState() {
|
||||
// Map map = Get.arguments;
|
||||
// if ((map["keyInfo"] != null)) {
|
||||
// keyInfo.value = map["keyInfo"];
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
||||
@ -34,8 +34,8 @@ class _AdminDetailChangeDatePage extends State<AdminDetailChangeDatePage> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
dynamic obj = ModalRoute.of(context)?.settings.arguments;
|
||||
if (obj != null && (obj["itemData"] != null)) {
|
||||
itemData = obj["itemData"];
|
||||
if (obj != null && (obj['itemData'] != null)) {
|
||||
itemData = obj['itemData'];
|
||||
}
|
||||
|
||||
return Scaffold(
|
||||
@ -101,14 +101,16 @@ class _AdminDetailChangeDatePage extends State<AdminDetailChangeDatePage> {
|
||||
|
||||
//更新管理员信息请求
|
||||
Future<void> updateAdministratorRequest() async {
|
||||
ElectronicKeyListEntity entity = await ApiRepository.to.updateAdministrator(
|
||||
itemData.uid.toString(),
|
||||
'',
|
||||
_failureDateTime.millisecondsSinceEpoch.toString(),
|
||||
_effectiveDateTime.millisecondsSinceEpoch.toString(),
|
||||
'');
|
||||
final ElectronicKeyListEntity entity = await ApiRepository.to
|
||||
.updateAdministrator(
|
||||
uid: itemData.uid.toString(),
|
||||
endDate: _failureDateTime.millisecondsSinceEpoch.toString(),
|
||||
startDate: _effectiveDateTime.millisecondsSinceEpoch.toString(),
|
||||
keyName: '',
|
||||
isOnlyManageSelf:
|
||||
itemData.onlyManageYouCreatesUser == true ? 1 : 2);
|
||||
if (entity.errorCode!.codeIsSuccessful) {
|
||||
EasyLoading.showToast("修改成功", duration: 2000.milliseconds);
|
||||
EasyLoading.showToast('修改成功', duration: 2000.milliseconds);
|
||||
setState(() {
|
||||
Navigator.pop(context);
|
||||
});
|
||||
@ -116,6 +118,6 @@ class _AdminDetailChangeDatePage extends State<AdminDetailChangeDatePage> {
|
||||
}
|
||||
|
||||
String intToStr(int v) {
|
||||
return (v < 10) ? "0$v" : "$v";
|
||||
return (v < 10) ? '0$v' : '$v';
|
||||
}
|
||||
}
|
||||
|
||||
@ -35,6 +35,7 @@ class Data {
|
||||
int? endDate;
|
||||
int? startDate;
|
||||
int? isRemoteUnlock;
|
||||
int? isOnlyManageSelf;
|
||||
String? name;
|
||||
String? userid;
|
||||
List<LockListItem>? lockList;
|
||||
@ -46,6 +47,7 @@ class Data {
|
||||
this.endDate,
|
||||
this.startDate,
|
||||
this.isRemoteUnlock,
|
||||
this.isOnlyManageSelf,
|
||||
this.name,
|
||||
this.userid,
|
||||
this.lockList});
|
||||
@ -57,6 +59,7 @@ class Data {
|
||||
endDate = json['endDate'];
|
||||
startDate = json['startDate'];
|
||||
isRemoteUnlock = json['isRemoteUnlock'];
|
||||
isOnlyManageSelf = json['isOnlyManageSelf'];
|
||||
name = json['name'];
|
||||
userid = json['userid'];
|
||||
if (json['lockList'] != null) {
|
||||
@ -75,6 +78,7 @@ class Data {
|
||||
data['endDate'] = endDate;
|
||||
data['startDate'] = startDate;
|
||||
data['isRemoteUnlock'] = isRemoteUnlock;
|
||||
data['isOnlyManageSelf'] = isOnlyManageSelf;
|
||||
data['name'] = name;
|
||||
data['userid'] = userid;
|
||||
if (lockList != null) {
|
||||
|
||||
@ -1,4 +1,3 @@
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:star_lock/common/XSConstantMacro/XSConstantMacro.dart';
|
||||
@ -7,48 +6,59 @@ import '../../../../main/lockDetail/electronicKey/electronicKeyList/entity/Elect
|
||||
import '../../../../network/api_repository.dart';
|
||||
import '../../../../tools/custom_bottom_sheet.dart';
|
||||
import '../../../../tools/eventBusEventManage.dart';
|
||||
import '../../../../tools/jh_pop_menus.dart';
|
||||
import '../../../../tools/showTipView.dart';
|
||||
import '../authorizedAdministrator/authorizedAdminListEntity.dart';
|
||||
import 'administratorDetailEntity.dart';
|
||||
import 'administratorDetails_state.dart';
|
||||
|
||||
class AdministratorDetailsLogic extends BaseGetXController{
|
||||
class AdministratorDetailsLogic extends BaseGetXController {
|
||||
AdministratorDetailsState state = AdministratorDetailsState();
|
||||
|
||||
|
||||
//管理员详情请求
|
||||
Future<void> administratorDetailRequest() async {
|
||||
AdministratorDetailEntity entity = await ApiRepository.to.authorizedAdminDetail(state.itemData.value.uid ?? 0);
|
||||
final AdministratorDetailEntity entity = await ApiRepository.to
|
||||
.authorizedAdminDetail(state.itemData.value.uid ?? 0);
|
||||
if (entity.errorCode!.codeIsSuccessful) {
|
||||
state.lockItemList.value = entity.data!.lockList!;
|
||||
state.onlyManageYouCreatesUser.value =
|
||||
entity.data!.isOnlyManageSelf == 1 ? true : false;
|
||||
}
|
||||
}
|
||||
|
||||
//更新管理员信息请求
|
||||
Future<void> updateAdministratorRequest(bool isRemote) async {
|
||||
String isRemoteUnlock = state.isOnRemote.value == true ? '1' : '2';
|
||||
ElectronicKeyListEntity entity = await ApiRepository.to.updateAdministrator(
|
||||
state.itemData.value.uid.toString(),
|
||||
state.changeNameController.text,
|
||||
'',
|
||||
'',
|
||||
isRemoteUnlock);
|
||||
Future<void> updateAdministratorRequest({required bool isChangeName}) async {
|
||||
int isManageCreateUser = 0;
|
||||
if (!isChangeName) {
|
||||
isManageCreateUser = state.onlyManageYouCreatesUser.value == true ? 2 : 1;
|
||||
}
|
||||
final ElectronicKeyListEntity entity = await ApiRepository.to
|
||||
.updateAdministrator(
|
||||
uid: state.itemData.value.uid.toString(),
|
||||
keyName: isChangeName
|
||||
? state.changeNameController.text
|
||||
: state.itemData.value.name ?? '',
|
||||
endDate: '',
|
||||
startDate: '',
|
||||
isOnlyManageSelf: isChangeName
|
||||
? state.itemData.value.onlyManageYouCreatesUser ?? 0
|
||||
: isManageCreateUser);
|
||||
if (entity.errorCode!.codeIsSuccessful) {
|
||||
showToast("修改成功".tr);
|
||||
}else{
|
||||
state.isOnRemote.value = !state.isOnRemote.value;
|
||||
if (!isChangeName) {
|
||||
state.onlyManageYouCreatesUser.value =
|
||||
!state.onlyManageYouCreatesUser.value;
|
||||
}
|
||||
showToast('修改成功'.tr);
|
||||
administratorDetailRequest();
|
||||
}
|
||||
}
|
||||
|
||||
//删除授权管理员请求 是否删除授权管理员发送的钥匙。 1是,0否
|
||||
Future<void> deleteAdministratorRequest(int includeUnderlings) async {
|
||||
AuthorizedAdminListEntity entity = await ApiRepository.to.deleteAuthorizedAdmin(
|
||||
state.itemData.value.uid.toString(),
|
||||
includeUnderlings.toString()
|
||||
);
|
||||
final AuthorizedAdminListEntity entity = await ApiRepository.to
|
||||
.deleteAuthorizedAdmin(
|
||||
state.itemData.value.uid.toString(), includeUnderlings.toString());
|
||||
if (entity.errorCode!.codeIsSuccessful) {
|
||||
showToast("删除成功".tr, something: (){
|
||||
showToast('删除成功'.tr, something: () {
|
||||
// eventBus.fire(AuthorizedAdministratorListPageRefreshUI());
|
||||
Get.back();
|
||||
});
|
||||
@ -57,12 +67,11 @@ class AdministratorDetailsLogic extends BaseGetXController{
|
||||
|
||||
//冻结
|
||||
Future<void> freezeKey(int includeUnderlings) async {
|
||||
ElectronicKeyListEntity entity = await ApiRepository.to.freezeKey(
|
||||
keyId:state.itemData.value.keyId.toString(),
|
||||
includeUnderlings: includeUnderlings
|
||||
);
|
||||
final ElectronicKeyListEntity entity = await ApiRepository.to.freezeKey(
|
||||
keyId: state.itemData.value.keyId.toString(),
|
||||
includeUnderlings: includeUnderlings);
|
||||
if (entity.errorCode!.codeIsSuccessful) {
|
||||
showToast("设置成功".tr, something: () {
|
||||
showToast('设置成功'.tr, something: () {
|
||||
eventBus.fire(ElectronicKeyListRefreshUI());
|
||||
eventBus.fire(AuthorizedAdminPageRefreshUI());
|
||||
});
|
||||
@ -71,12 +80,11 @@ class AdministratorDetailsLogic extends BaseGetXController{
|
||||
|
||||
//取消冻结
|
||||
Future<void> cancelFreeze(int includeUnderlings) async {
|
||||
ElectronicKeyListEntity entity = await ApiRepository.to.cancelFreeze(
|
||||
keyId:state.itemData.value.keyId.toString(),
|
||||
includeUnderlings: includeUnderlings
|
||||
);
|
||||
final ElectronicKeyListEntity entity = await ApiRepository.to.cancelFreeze(
|
||||
keyId: state.itemData.value.keyId.toString(),
|
||||
includeUnderlings: includeUnderlings);
|
||||
if (entity.errorCode!.codeIsSuccessful) {
|
||||
showToast("设置成功".tr, something: () {
|
||||
showToast('设置成功'.tr, something: () {
|
||||
eventBus.fire(ElectronicKeyListRefreshUI());
|
||||
eventBus.fire(AuthorizedAdminPageRefreshUI());
|
||||
});
|
||||
@ -85,11 +93,12 @@ class AdministratorDetailsLogic extends BaseGetXController{
|
||||
|
||||
//取消授权管理员
|
||||
Future<void> cancelAdministrator() async {
|
||||
ElectronicKeyListEntity entity = await ApiRepository.to.cancelAdministrator(
|
||||
keyId:state.itemData.value.keyId.toString(),
|
||||
final ElectronicKeyListEntity entity =
|
||||
await ApiRepository.to.cancelAdministrator(
|
||||
keyId: state.itemData.value.keyId.toString(),
|
||||
);
|
||||
if (entity.errorCode!.codeIsSuccessful) {
|
||||
showToast("设置成功".tr, something: () {
|
||||
showToast('设置成功'.tr, something: () {
|
||||
eventBus.fire(ElectronicKeyListRefreshUI());
|
||||
eventBus.fire(AuthorizedAdminPageRefreshUI());
|
||||
Get.back();
|
||||
@ -97,8 +106,11 @@ class AdministratorDetailsLogic extends BaseGetXController{
|
||||
}
|
||||
}
|
||||
|
||||
Future openModalBottomSheet() async {
|
||||
var textList = [state.itemData.value.keyStatus == 110405 ? '取消冻结'.tr : "冻结".tr, '取消授权'.tr];
|
||||
Future<void> openModalBottomSheet() async {
|
||||
final List<String> textList = <String>[
|
||||
if (state.itemData.value.keyStatus == 110405) '取消冻结'.tr else '冻结'.tr,
|
||||
'取消授权'.tr
|
||||
];
|
||||
|
||||
showModalBottomSheet(
|
||||
context: Get.context!,
|
||||
@ -109,24 +121,25 @@ class AdministratorDetailsLogic extends BaseGetXController{
|
||||
topTitle: '',
|
||||
items: textList,
|
||||
chooseCallback: (value) {
|
||||
int index = value;
|
||||
if(index == 0){
|
||||
if(state.itemData.value.keyStatus == 110405){
|
||||
final int index = value;
|
||||
if (index == 0) {
|
||||
if (state.itemData.value.keyStatus == 110405) {
|
||||
// 取消冻结
|
||||
ShowTipView().showDeleteAdministratorIsHaveAllDataDialog('同时解冻其发送的钥匙'.tr, (isAllData) {
|
||||
ShowTipView().showDeleteAdministratorIsHaveAllDataDialog(
|
||||
'同时解冻其发送的钥匙'.tr, (isAllData) {
|
||||
cancelFreeze(isAllData ? 1 : 0);
|
||||
});
|
||||
}else{
|
||||
ShowTipView().showDeleteAdministratorIsHaveAllDataDialog('同时冻结其发送的钥匙'.tr, (isAllData) {
|
||||
} else {
|
||||
ShowTipView().showDeleteAdministratorIsHaveAllDataDialog(
|
||||
'同时冻结其发送的钥匙'.tr, (isAllData) {
|
||||
freezeKey(isAllData ? 1 : 0);
|
||||
});
|
||||
}
|
||||
}else{
|
||||
} else {
|
||||
// 取消/授权管理员
|
||||
// 管理员
|
||||
ShowTipView().showIosTipWithContentDialog("取消授权会在用户APP连网后生效".tr, (){
|
||||
cancelAdministrator();
|
||||
});
|
||||
ShowTipView().showIosTipWithContentDialog(
|
||||
'取消授权会在用户APP连网后生效'.tr, cancelAdministrator);
|
||||
}
|
||||
},
|
||||
);
|
||||
@ -138,20 +151,24 @@ class AdministratorDetailsLogic extends BaseGetXController{
|
||||
String useDateStr = '';
|
||||
if (indexEntity.keyType == XSConstantMacro.keyTypeTime) {
|
||||
//限期
|
||||
DateTime startDateStr =
|
||||
DateTime.fromMillisecondsSinceEpoch(indexEntity.startDate!);
|
||||
DateTime endDateStr =
|
||||
DateTime.fromMillisecondsSinceEpoch(indexEntity.endDate!);
|
||||
final DateTime startDateStr =
|
||||
DateTime.fromMillisecondsSinceEpoch(indexEntity.startDate!);
|
||||
final DateTime endDateStr =
|
||||
DateTime.fromMillisecondsSinceEpoch(indexEntity.endDate!);
|
||||
useDateStr =
|
||||
'${startDateStr.toLocal().toString().substring(0, 16)}\n${endDateStr.toLocal().toString().substring(0, 16)}';
|
||||
'${startDateStr.toLocal().toString().substring(0, 16)}\n${endDateStr.toLocal().toString().substring(0, 16)}';
|
||||
} else if (indexEntity.keyType == XSConstantMacro.keyTypeLong) {
|
||||
//永久
|
||||
DateTime dateStr = DateTime.fromMillisecondsSinceEpoch(indexEntity.date!);
|
||||
useDateStr = '${dateStr.toLocal().toString().substring(0, 16)}\n${"永久".tr}';
|
||||
final DateTime dateStr =
|
||||
DateTime.fromMillisecondsSinceEpoch(indexEntity.date!);
|
||||
useDateStr =
|
||||
'${dateStr.toLocal().toString().substring(0, 16)}\n${"永久".tr}';
|
||||
} else if (indexEntity.keyType == XSConstantMacro.keyTypeOnce) {
|
||||
//单次
|
||||
DateTime dateStr = DateTime.fromMillisecondsSinceEpoch(indexEntity.date!);
|
||||
useDateStr = '${dateStr.toLocal().toString().substring(0, 16)} \n${"单次".tr}';
|
||||
final DateTime dateStr =
|
||||
DateTime.fromMillisecondsSinceEpoch(indexEntity.date!);
|
||||
useDateStr =
|
||||
'${dateStr.toLocal().toString().substring(0, 16)} \n${"单次".tr}';
|
||||
} else if (indexEntity.keyType == XSConstantMacro.keyTypeLoop) {
|
||||
//循环
|
||||
useDateStr = '循环'.tr;
|
||||
@ -177,7 +194,5 @@ class AdministratorDetailsLogic extends BaseGetXController{
|
||||
void onClose() {
|
||||
// TODO: implement onClose
|
||||
super.onClose();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -2,7 +2,8 @@ import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:star_lock/tools/jh_pop_menus.dart';
|
||||
import 'package:star_lock/mine/mineSet/authorizedAdministrator/administratorDetails/administratorDetails_state.dart';
|
||||
import 'package:star_lock/mine/mineSet/authorizedAdministrator/authorizedAdministrator/authorizedAdminListEntity.dart';
|
||||
|
||||
import '../../../../../appRouters.dart';
|
||||
import '../../../../../app_settings/app_colors.dart';
|
||||
@ -23,8 +24,9 @@ class AdministratorDetailsPage extends StatefulWidget {
|
||||
}
|
||||
|
||||
class _AdministratorDetailsPageState extends State<AdministratorDetailsPage> {
|
||||
final logic = Get.put(AdministratorDetailsLogic());
|
||||
final state = Get.find<AdministratorDetailsLogic>().state;
|
||||
final AdministratorDetailsLogic logic = Get.put(AdministratorDetailsLogic());
|
||||
final AdministratorDetailsState state =
|
||||
Get.find<AdministratorDetailsLogic>().state;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
@ -33,79 +35,100 @@ class _AdministratorDetailsPageState extends State<AdministratorDetailsPage> {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
|
||||
return Scaffold(
|
||||
resizeToAvoidBottomInset: false,
|
||||
backgroundColor: AppColors.mainBackgroundColor,
|
||||
appBar: TitleAppBar(
|
||||
barTitle: '管理员详情'.tr,
|
||||
haveBack: true,
|
||||
actionsList: [
|
||||
actionsList: <Widget>[
|
||||
IconButton(
|
||||
icon: Image.asset(
|
||||
'images/icon_bar_more.png',
|
||||
height: 30.h,
|
||||
width: 10.w,
|
||||
),
|
||||
onPressed: () {
|
||||
logic.openModalBottomSheet();
|
||||
},
|
||||
onPressed: logic.openModalBottomSheet,
|
||||
),
|
||||
],
|
||||
backgroundColor: AppColors.mainColor),
|
||||
body: Obx(()=>Column(
|
||||
children: [
|
||||
CommonItem(
|
||||
leftTitel: TranslationLoader.lanKeys!.name!.tr,
|
||||
rightTitle: state.changeNameController.text.isNotEmpty
|
||||
? state.changeNameController.text
|
||||
: state.itemData.value.name,
|
||||
isHaveDirection: true,
|
||||
isHaveLine: true,
|
||||
action: () {
|
||||
showCupertinoAlertDialog(context);
|
||||
}),
|
||||
CommonItem(
|
||||
leftTitel: TranslationLoader.lanKeys!.effectiveTime!.tr,
|
||||
allHeight: 90.h,
|
||||
rightTitle: logic.getUseDateStr(state.itemData.value),
|
||||
isHaveDirection: true,
|
||||
action: () {
|
||||
Navigator.pushNamed(context, Routers.adminDetailChangeDatePage,
|
||||
arguments: {"itemData": state.itemData.value});
|
||||
}),
|
||||
Container(height: 10.h),
|
||||
CommonItem(
|
||||
leftTitel: TranslationLoader.lanKeys!.lock!.tr,
|
||||
rightTitle: state.itemData.value.lockNum.toString(),
|
||||
isHaveDirection: false,
|
||||
action: () {
|
||||
// //锁列表页面
|
||||
// Navigator.pushNamed(context, Routers.lockItemListPage,
|
||||
// arguments: {'lockList': state.lockItemList});
|
||||
}),
|
||||
Container(height: 10.h),
|
||||
CommonItem(
|
||||
leftTitel: TranslationLoader.lanKeys!.remoteUnlocking!.tr,
|
||||
rightTitle: "",
|
||||
isHaveRightWidget: true,
|
||||
rightWidget: SizedBox(width: 60.w, child: _switch()),
|
||||
action: () {}),
|
||||
Container(height: 40.h),
|
||||
SubmitBtn(
|
||||
btnName: TranslationLoader.lanKeys!.delete!.tr,
|
||||
borderRadius: 20.w,
|
||||
isDelete: true,
|
||||
margin: EdgeInsets.only(
|
||||
left: 30.w, right: 30.w, top: 30.w, bottom: 30.w),
|
||||
padding: EdgeInsets.only(top: 25.w, bottom: 25.w),
|
||||
onClick: () {
|
||||
ShowTipView().showDeleteAdministratorIsHaveAllDataDialog('同时删除其发送的所有钥匙,钥匙删除后不能恢复'.tr, (isAllData) {
|
||||
logic.deleteAdministratorRequest(isAllData ? 1 : 0);
|
||||
});
|
||||
}),
|
||||
],
|
||||
)),
|
||||
body: Obx(() => Column(
|
||||
children: <Widget>[
|
||||
CommonItem(
|
||||
leftTitel: TranslationLoader.lanKeys!.name!.tr,
|
||||
rightTitle: state.changeNameController.text.isNotEmpty
|
||||
? state.changeNameController.text
|
||||
: state.itemData.value.name,
|
||||
isHaveDirection: true,
|
||||
isHaveLine: true,
|
||||
action: () {
|
||||
showCupertinoAlertDialog(context);
|
||||
}),
|
||||
CommonItem(
|
||||
leftTitel: TranslationLoader.lanKeys!.effectiveTime!.tr,
|
||||
allHeight: 90.h,
|
||||
rightTitle: logic.getUseDateStr(state.itemData.value),
|
||||
isHaveDirection: true,
|
||||
action: () {
|
||||
Navigator.pushNamed(
|
||||
context, Routers.adminDetailChangeDatePage,
|
||||
arguments: <String, AuthorizedAdminListItem>{
|
||||
'itemData': state.itemData.value
|
||||
});
|
||||
}),
|
||||
Container(height: 10.h),
|
||||
CommonItem(
|
||||
leftTitel: TranslationLoader.lanKeys!.lock!.tr,
|
||||
rightTitle: state.itemData.value.lockNum.toString(),
|
||||
isHaveDirection: false,
|
||||
action: () {
|
||||
// //锁列表页面
|
||||
// Navigator.pushNamed(context, Routers.lockItemListPage,
|
||||
// arguments: {'lockList': state.lockItemList});
|
||||
}),
|
||||
Container(height: 10.h),
|
||||
CommonItem(
|
||||
leftTitel: '仅管理自己创建的用户',
|
||||
rightTitle: '',
|
||||
isHaveRightWidget: true,
|
||||
isTipsImg: true,
|
||||
tipsImgAction: () {
|
||||
ShowTipView()
|
||||
.showSureAlertDialog('授权管理员只能查看和管理自己下发的钥匙、密码等权限');
|
||||
},
|
||||
rightWidget: SizedBox(
|
||||
width: 60.w,
|
||||
height: 50.h,
|
||||
child: _onlyManageYouCreatesUserSwitch())),
|
||||
Container(height: 40.h),
|
||||
SubmitBtn(
|
||||
btnName: TranslationLoader.lanKeys!.delete!.tr,
|
||||
borderRadius: 20.w,
|
||||
isDelete: true,
|
||||
margin: EdgeInsets.only(
|
||||
left: 30.w, right: 30.w, top: 30.w, bottom: 30.w),
|
||||
padding: EdgeInsets.only(top: 25.w, bottom: 25.w),
|
||||
onClick: () {
|
||||
ShowTipView().showDeleteAdministratorIsHaveAllDataDialog(
|
||||
'同时删除其发送的所有钥匙,钥匙删除后不能恢复'.tr, (bool isAllData) {
|
||||
logic.deleteAdministratorRequest(isAllData ? 1 : 0);
|
||||
});
|
||||
}),
|
||||
],
|
||||
)),
|
||||
);
|
||||
}
|
||||
|
||||
//仅管理自己创建的用户
|
||||
CupertinoSwitch _onlyManageYouCreatesUserSwitch() {
|
||||
return CupertinoSwitch(
|
||||
activeColor: CupertinoColors.activeBlue,
|
||||
trackColor: CupertinoColors.systemGrey5,
|
||||
thumbColor: CupertinoColors.white,
|
||||
value: state.onlyManageYouCreatesUser.value,
|
||||
onChanged: (value) {
|
||||
logic.updateAdministratorRequest(isChangeName: false);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
@ -119,14 +142,14 @@ class _AdministratorDetailsPageState extends State<AdministratorDetailsPage> {
|
||||
onTap: action,
|
||||
child: Column(
|
||||
// mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
children: <Widget>[
|
||||
Container(
|
||||
// height: 80.h,
|
||||
color: Colors.white,
|
||||
padding: EdgeInsets.only(
|
||||
left: 20.w, right: 10.w, top: 20.w, bottom: 20.w),
|
||||
child: Row(
|
||||
children: [
|
||||
children: <Widget>[
|
||||
SizedBox(width: 20.w),
|
||||
Text(
|
||||
leftTitle,
|
||||
@ -137,69 +160,57 @@ class _AdministratorDetailsPageState extends State<AdministratorDetailsPage> {
|
||||
Expanded(
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.end,
|
||||
children: [
|
||||
isHaveRightWidget
|
||||
? rightWidget!
|
||||
: Text(
|
||||
rightTitle,
|
||||
textAlign: TextAlign.end,
|
||||
style: TextStyle(
|
||||
fontSize: 28.sp, fontWeight: FontWeight.w500),
|
||||
)
|
||||
children: <Widget>[
|
||||
if (isHaveRightWidget)
|
||||
rightWidget!
|
||||
else
|
||||
Text(
|
||||
rightTitle,
|
||||
textAlign: TextAlign.end,
|
||||
style: TextStyle(
|
||||
fontSize: 28.sp, fontWeight: FontWeight.w500),
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
SizedBox(width: 5.w),
|
||||
isHaveDirection
|
||||
? Image.asset(
|
||||
'images/icon_right.png',
|
||||
width: 50.w,
|
||||
height: 50.w,
|
||||
)
|
||||
: SizedBox(width: 10.w),
|
||||
if (isHaveDirection)
|
||||
Image.asset(
|
||||
'images/icon_right.png',
|
||||
width: 50.w,
|
||||
height: 50.w,
|
||||
)
|
||||
else
|
||||
SizedBox(width: 10.w),
|
||||
// SizedBox(width:10.w),
|
||||
],
|
||||
),
|
||||
),
|
||||
isHaveLine
|
||||
? Container(
|
||||
height: 0.5.h,
|
||||
color: Colors.grey,
|
||||
)
|
||||
: Container()
|
||||
if (isHaveLine)
|
||||
Container(
|
||||
height: 0.5.h,
|
||||
color: Colors.grey,
|
||||
)
|
||||
else
|
||||
Container()
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
CupertinoSwitch _switch() {
|
||||
return CupertinoSwitch(
|
||||
activeColor: CupertinoColors.activeBlue,
|
||||
trackColor: CupertinoColors.systemGrey5,
|
||||
thumbColor: CupertinoColors.white,
|
||||
value: state.isOnRemote.value,
|
||||
onChanged: (value) {
|
||||
setState(() {
|
||||
state.isOnRemote.value = !state.isOnRemote.value;
|
||||
logic.updateAdministratorRequest(true);
|
||||
});
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
void showCupertinoAlertDialog(BuildContext context) {
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (BuildContext context) {
|
||||
return ShowTFView(
|
||||
title:
|
||||
"${TranslationLoader.lanKeys!.amend!.tr} ${TranslationLoader.lanKeys!.name!.tr}",
|
||||
tipTitle: "请输入".tr,
|
||||
'${TranslationLoader.lanKeys!.amend!.tr} ${TranslationLoader.lanKeys!.name!.tr}',
|
||||
tipTitle: '请输入'.tr,
|
||||
controller: state.changeNameController,
|
||||
sureClick: () {
|
||||
//发送编辑钥匙名称请求
|
||||
if (state.changeNameController.text.isNotEmpty) {
|
||||
logic.updateAdministratorRequest(false);
|
||||
logic.updateAdministratorRequest(isChangeName: true);
|
||||
}
|
||||
},
|
||||
cancelClick: () {
|
||||
|
||||
@ -1,22 +1,20 @@
|
||||
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
|
||||
import '../../../../main/lockDetail/electronicKey/massSendElectronicKey/massSendLockGroupList/massSendLockGroupListEntity.dart';
|
||||
import '../authorizedAdministrator/authorizedAdminListEntity.dart';
|
||||
|
||||
class AdministratorDetailsState{
|
||||
final TextEditingController changeNameController = TextEditingController();
|
||||
final itemData = AuthorizedAdminListItem().obs;
|
||||
var isOnRemote = false.obs;
|
||||
var lockItemList = <LockListItem>[].obs;
|
||||
|
||||
AdministratorDetailsState(){
|
||||
Map map = Get.arguments;
|
||||
if (map != null && (map["itemData"] != null)) {
|
||||
itemData.value = map["itemData"];
|
||||
isOnRemote.value = itemData.value.isRemoteUnlock == 1 ? true : false;
|
||||
class AdministratorDetailsState {
|
||||
AdministratorDetailsState() {
|
||||
final Map map = Get.arguments;
|
||||
if (map['itemData'] != null) {
|
||||
itemData.value = map['itemData'];
|
||||
onlyManageYouCreatesUser.value =
|
||||
itemData.value.onlyManageYouCreatesUser == 1 ? true : false;
|
||||
}
|
||||
}
|
||||
}
|
||||
final TextEditingController changeNameController = TextEditingController();
|
||||
final Rx<AuthorizedAdminListItem> itemData = AuthorizedAdminListItem().obs;
|
||||
RxBool onlyManageYouCreatesUser = false.obs;
|
||||
RxList<LockListItem> lockItemList = <LockListItem>[].obs;
|
||||
}
|
||||
|
||||
@ -1,12 +1,6 @@
|
||||
class AuthorizedAdminListEntity {
|
||||
int? errorCode;
|
||||
String? description;
|
||||
String? errorMsg;
|
||||
AuthorizedAdminListData? data;
|
||||
|
||||
AuthorizedAdminListEntity(
|
||||
{this.errorCode, this.description, this.errorMsg, this.data});
|
||||
|
||||
AuthorizedAdminListEntity.fromJson(Map<String, dynamic> json) {
|
||||
errorCode = json['errorCode'];
|
||||
description = json['description'];
|
||||
@ -15,6 +9,10 @@ class AuthorizedAdminListEntity {
|
||||
? AuthorizedAdminListData.fromJson(json['data'])
|
||||
: null;
|
||||
}
|
||||
int? errorCode;
|
||||
String? description;
|
||||
String? errorMsg;
|
||||
AuthorizedAdminListData? data;
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final Map<String, dynamic> data = <String, dynamic>{};
|
||||
@ -29,15 +27,8 @@ class AuthorizedAdminListEntity {
|
||||
}
|
||||
|
||||
class AuthorizedAdminListData {
|
||||
List<AuthorizedAdminListItem>? itemList;
|
||||
int? pageNo;
|
||||
int? pageSize;
|
||||
int? pages;
|
||||
int? total;
|
||||
|
||||
AuthorizedAdminListData(
|
||||
{this.itemList, this.pageNo, this.pageSize, this.pages, this.total});
|
||||
|
||||
AuthorizedAdminListData.fromJson(Map<String, dynamic> json) {
|
||||
if (json['list'] != null) {
|
||||
itemList = <AuthorizedAdminListItem>[];
|
||||
@ -50,6 +41,11 @@ class AuthorizedAdminListData {
|
||||
pages = json['pages'];
|
||||
total = json['total'];
|
||||
}
|
||||
List<AuthorizedAdminListItem>? itemList;
|
||||
int? pageNo;
|
||||
int? pageSize;
|
||||
int? pages;
|
||||
int? total;
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final Map<String, dynamic> data = <String, dynamic>{};
|
||||
@ -65,19 +61,6 @@ class AuthorizedAdminListData {
|
||||
}
|
||||
|
||||
class AuthorizedAdminListItem {
|
||||
int? uid;
|
||||
int? keyStatus;
|
||||
int? lockNum;
|
||||
int? endDate;
|
||||
int? startDate;
|
||||
String? name;
|
||||
String? headUrl;
|
||||
String? userid;
|
||||
int? keyType;
|
||||
int? date;
|
||||
int? isRemoteUnlock;
|
||||
int? keyId;
|
||||
|
||||
AuthorizedAdminListItem(
|
||||
{this.uid,
|
||||
this.keyStatus,
|
||||
@ -90,8 +73,8 @@ class AuthorizedAdminListItem {
|
||||
this.keyType,
|
||||
this.date,
|
||||
this.isRemoteUnlock,
|
||||
this.keyId});
|
||||
|
||||
this.keyId,
|
||||
this.onlyManageYouCreatesUser});
|
||||
AuthorizedAdminListItem.fromJson(Map<String, dynamic> json) {
|
||||
uid = json['uid'];
|
||||
keyStatus = json['keyStatus'];
|
||||
@ -105,7 +88,21 @@ class AuthorizedAdminListItem {
|
||||
date = json['date'];
|
||||
isRemoteUnlock = json['isRemoteUnlock'];
|
||||
keyId = json['keyId'];
|
||||
onlyManageYouCreatesUser = json['onlyManageYouCreatesUser'];
|
||||
}
|
||||
int? uid;
|
||||
int? keyStatus;
|
||||
int? lockNum;
|
||||
int? endDate;
|
||||
int? startDate;
|
||||
String? name;
|
||||
String? headUrl;
|
||||
String? userid;
|
||||
int? keyType;
|
||||
int? date;
|
||||
int? isRemoteUnlock;
|
||||
int? keyId;
|
||||
int? onlyManageYouCreatesUser;
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final Map<String, dynamic> data = <String, dynamic>{};
|
||||
@ -121,6 +118,7 @@ class AuthorizedAdminListItem {
|
||||
data['date'] = date;
|
||||
data['isRemoteUnlock'] = isRemoteUnlock;
|
||||
data['keyId'] = keyId;
|
||||
data['onlyManageYouCreatesUser'] = onlyManageYouCreatesUser;
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,4 +1,3 @@
|
||||
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:star_lock/tools/baseGetXController.dart';
|
||||
@ -9,15 +8,13 @@ import '../../../../tools/eventBusEventManage.dart';
|
||||
import 'authorizedAdminListEntity.dart';
|
||||
import 'authorizedAdministratorList_state.dart';
|
||||
|
||||
class AuthorizedAdministratorListLogic extends BaseGetXController{
|
||||
class AuthorizedAdministratorListLogic extends BaseGetXController {
|
||||
AuthorizedAdministratorListState state = AuthorizedAdministratorListState();
|
||||
|
||||
//请求授权管理员列表
|
||||
Future<AuthorizedAdminListEntity> mockNetworkDataRequest() async {
|
||||
AuthorizedAdminListEntity entity = await ApiRepository.to.authorizedAdminList(
|
||||
pageNo.toString(),
|
||||
pageSize.toString()
|
||||
);
|
||||
final AuthorizedAdminListEntity entity = await ApiRepository.to
|
||||
.authorizedAdminList(pageNo.toString(), pageSize.toString());
|
||||
if (entity.errorCode!.codeIsSuccessful) {
|
||||
if (pageNo == 1) {
|
||||
state.itemDataList.value = entity.data!.itemList!;
|
||||
@ -34,11 +31,12 @@ class AuthorizedAdministratorListLogic extends BaseGetXController{
|
||||
}
|
||||
|
||||
//删除授权管理员请求 是否删除授权管理员发送的钥匙。 1是,0否
|
||||
Future<void> deleteAdministratorRequest(String uid, int includeUnderlings) async {
|
||||
AuthorizedAdminListEntity entity = await ApiRepository.to
|
||||
Future<void> deleteAdministratorRequest(
|
||||
String uid, int includeUnderlings) async {
|
||||
final AuthorizedAdminListEntity entity = await ApiRepository.to
|
||||
.deleteAuthorizedAdmin(uid, includeUnderlings.toString());
|
||||
if (entity.errorCode!.codeIsSuccessful) {
|
||||
showToast("删除成功", something: (){
|
||||
showToast('删除成功', something: () {
|
||||
pageNo = 1;
|
||||
mockNetworkDataRequest();
|
||||
});
|
||||
@ -51,12 +49,12 @@ class AuthorizedAdministratorListLogic extends BaseGetXController{
|
||||
if (indexEntity.keyType == XSConstantMacro.keyTypeTime) {
|
||||
//限期
|
||||
if (indexEntity.startDate != null && indexEntity.endDate != null) {
|
||||
DateTime startDateStr =
|
||||
DateTime.fromMillisecondsSinceEpoch(indexEntity.startDate!);
|
||||
DateTime endDateStr =
|
||||
DateTime.fromMillisecondsSinceEpoch(indexEntity.endDate!);
|
||||
final DateTime startDateStr =
|
||||
DateTime.fromMillisecondsSinceEpoch(indexEntity.startDate!);
|
||||
final DateTime endDateStr =
|
||||
DateTime.fromMillisecondsSinceEpoch(indexEntity.endDate!);
|
||||
useDateStr =
|
||||
'${startDateStr.toLocal().toString().substring(0, 16)}-${endDateStr.toLocal().toString().substring(0, 16)}';
|
||||
'${startDateStr.toLocal().toString().substring(0, 16)}-${endDateStr.toLocal().toString().substring(0, 16)}';
|
||||
} else {
|
||||
useDateStr = '限期';
|
||||
}
|
||||
@ -77,7 +75,8 @@ class AuthorizedAdministratorListLogic extends BaseGetXController{
|
||||
StreamSubscription? _authorizedAdministratorListPageRefreshUIEvent;
|
||||
void _authorizedAdministratorListPageRefreshUIAction() {
|
||||
// 蓝牙协议通知传输跟蓝牙之外的数据传输类不一样 eventBus
|
||||
_authorizedAdministratorListPageRefreshUIEvent = eventBus.on<AuthorizedAdministratorListPageRefreshUI>().listen((event) {
|
||||
_authorizedAdministratorListPageRefreshUIEvent =
|
||||
eventBus.on<AuthorizedAdministratorListPageRefreshUI>().listen((event) {
|
||||
pageNo = 1;
|
||||
mockNetworkDataRequest();
|
||||
});
|
||||
@ -102,5 +101,4 @@ class AuthorizedAdministratorListLogic extends BaseGetXController{
|
||||
super.onClose();
|
||||
_authorizedAdministratorListPageRefreshUIEvent?.cancel();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -3,6 +3,7 @@ import 'package:flutter_screenutil/flutter_screenutil.dart';
|
||||
import 'package:flutter_slidable/flutter_slidable.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:star_lock/mine/mineSet/authorizedAdministrator/authorizedAdministrator/authorizedAdminListEntity.dart';
|
||||
import 'package:star_lock/mine/mineSet/authorizedAdministrator/authorizedAdministrator/authorizedAdministratorList_state.dart';
|
||||
import 'package:star_lock/tools/noData.dart';
|
||||
import 'package:star_lock/tools/showCupertinoAlertView.dart';
|
||||
import 'package:star_lock/tools/submitBtn.dart';
|
||||
@ -27,11 +28,13 @@ class AuthorizedAdministratorListPage extends StatefulWidget {
|
||||
|
||||
class _AuthorizedAdministratorListPageState
|
||||
extends State<AuthorizedAdministratorListPage> {
|
||||
final logic = Get.put(AuthorizedAdministratorListLogic());
|
||||
final state = Get.find<AuthorizedAdministratorListLogic>().state;
|
||||
final AuthorizedAdministratorListLogic logic =
|
||||
Get.put(AuthorizedAdministratorListLogic());
|
||||
final AuthorizedAdministratorListState state =
|
||||
Get.find<AuthorizedAdministratorListLogic>().state;
|
||||
|
||||
Future<void> getHttpData() async {
|
||||
var isDemoMode = await Storage.getBool(ifIsDemoModeOrNot);
|
||||
final bool? isDemoMode = await Storage.getBool(ifIsDemoModeOrNot);
|
||||
if (isDemoMode == false) {
|
||||
logic.mockNetworkDataRequest().then((AuthorizedAdminListEntity value) {
|
||||
setState(() {});
|
||||
@ -54,7 +57,7 @@ class _AuthorizedAdministratorListPageState
|
||||
barTitle: TranslationLoader.lanKeys!.authorizedAdmin!.tr,
|
||||
haveBack: true,
|
||||
backgroundColor: AppColors.mainColor,
|
||||
actionsList: [
|
||||
actionsList: <Widget>[
|
||||
IconButton(
|
||||
icon: Image.asset(
|
||||
'images/icon_add_white.png',
|
||||
@ -65,7 +68,7 @@ class _AuthorizedAdministratorListPageState
|
||||
// 处理操作按钮的点击事件
|
||||
Navigator.pushNamed(
|
||||
context, Routers.addAuthorizedAdministratorPage)
|
||||
.then((value) {
|
||||
.then((Object? value) {
|
||||
setState(() {
|
||||
logic.pageNo = 1;
|
||||
getHttpData();
|
||||
@ -84,7 +87,7 @@ class _AuthorizedAdministratorListPageState
|
||||
getHttpData();
|
||||
},
|
||||
child: Column(
|
||||
children: [
|
||||
children: <Widget>[
|
||||
// _searchWidget(),
|
||||
Expanded(child: _buildMainUI()),
|
||||
],
|
||||
@ -95,7 +98,7 @@ class _AuthorizedAdministratorListPageState
|
||||
Widget _buildMainUI() {
|
||||
return Obx(() => state.itemDataList.isEmpty
|
||||
? Stack(
|
||||
children: [
|
||||
children: <Widget>[
|
||||
NoData(
|
||||
noDataHeight: 1.sh -
|
||||
ScreenUtil().statusBarHeight -
|
||||
@ -111,7 +114,7 @@ class _AuthorizedAdministratorListPageState
|
||||
onClick: () {
|
||||
Navigator.pushNamed(
|
||||
context, Routers.addAuthorizedAdministratorPage)
|
||||
.then((value) {
|
||||
.then((Object? value) {
|
||||
setState(() {
|
||||
logic.pageNo = 1;
|
||||
getHttpData();
|
||||
@ -125,8 +128,8 @@ class _AuthorizedAdministratorListPageState
|
||||
: SlidableAutoCloseBehavior(
|
||||
child: ListView.separated(
|
||||
itemCount: state.itemDataList.value.length,
|
||||
itemBuilder: (c, index) {
|
||||
AuthorizedAdminListItem authorizedAdminListItem =
|
||||
itemBuilder: (BuildContext c, int index) {
|
||||
final AuthorizedAdminListItem authorizedAdminListItem =
|
||||
state.itemDataList.value[index];
|
||||
|
||||
return Slidable(
|
||||
@ -134,12 +137,12 @@ class _AuthorizedAdministratorListPageState
|
||||
endActionPane: ActionPane(
|
||||
extentRatio: 0.2,
|
||||
motion: const ScrollMotion(),
|
||||
children: [
|
||||
children: <Widget>[
|
||||
SlidableAction(
|
||||
onPressed: (BuildContext context) {
|
||||
ShowTipView()
|
||||
.showDeleteAdministratorIsHaveAllDataDialog(
|
||||
'同时删除其发送的所有钥匙,钥匙删除后不能恢复', (isAllData) {
|
||||
'同时删除其发送的所有钥匙,钥匙删除后不能恢复', (bool isAllData) {
|
||||
logic.deleteAdministratorRequest(
|
||||
authorizedAdminListItem.uid.toString(),
|
||||
isAllData ? 1 : 0);
|
||||
@ -169,10 +172,12 @@ class _AuthorizedAdministratorListPageState
|
||||
return GestureDetector(
|
||||
onTap: () async {
|
||||
//高级功能
|
||||
var isVip = await Storage.getBool(saveIsVip);
|
||||
final bool? isVip = await Storage.getBool(saveIsVip);
|
||||
if (isVip == true) {
|
||||
Get.toNamed(Routers.administratorDetailsPage,
|
||||
arguments: {'itemData': itemData})?.then((value) {
|
||||
arguments: <String, AuthorizedAdminListItem>{
|
||||
'itemData': itemData
|
||||
})?.then((value) {
|
||||
setState(() {
|
||||
logic.pageNo = 1;
|
||||
getHttpData();
|
||||
@ -186,7 +191,7 @@ class _AuthorizedAdministratorListPageState
|
||||
height: 100.h,
|
||||
color: Colors.white,
|
||||
child: Row(
|
||||
children: [
|
||||
children: <Widget>[
|
||||
SizedBox(
|
||||
width: 30.w,
|
||||
),
|
||||
@ -195,14 +200,14 @@ class _AuthorizedAdministratorListPageState
|
||||
Expanded(
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
children: <Widget>[
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
children: [
|
||||
children: <Widget>[
|
||||
SizedBox(
|
||||
width: 1.sw - 110.w - 100.w,
|
||||
child: Row(
|
||||
children: [
|
||||
children: <Widget>[
|
||||
Flexible(
|
||||
child: Text(itemData.name ?? '',
|
||||
maxLines: 1,
|
||||
@ -224,7 +229,7 @@ class _AuthorizedAdministratorListPageState
|
||||
SizedBox(height: 5.h),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
children: [
|
||||
children: <Widget>[
|
||||
Text(
|
||||
logic.getUseDateStr(itemData),
|
||||
style: TextStyle(
|
||||
|
||||
@ -591,7 +591,7 @@ class ApiProvider extends BaseProvider {
|
||||
jsonEncode({'uid': uid, 'includeUnderlings': includeUnderlings}));
|
||||
|
||||
Future<Response> updateAdministrator(String uid, String keyName,
|
||||
String endDate, String startDate, String remoteEnable) =>
|
||||
String endDate, String startDate, int isOnlyManageSelf) =>
|
||||
post(
|
||||
updateAdministratorURL.toUrl,
|
||||
jsonEncode({
|
||||
@ -599,7 +599,7 @@ class ApiProvider extends BaseProvider {
|
||||
'keyName': keyName,
|
||||
'endDate': endDate,
|
||||
'startDate': startDate,
|
||||
'remoteEnable': remoteEnable
|
||||
'isOnlyManageSelf': isOnlyManageSelf
|
||||
}));
|
||||
|
||||
// 设置授权管理员
|
||||
@ -1575,7 +1575,8 @@ class ApiProvider extends BaseProvider {
|
||||
String startDate,
|
||||
String userid,
|
||||
String countryCode,
|
||||
String usernameType) =>
|
||||
String usernameType,
|
||||
int isOnlyManageSelf) =>
|
||||
post(
|
||||
addAuthorizedAdminURL.toUrl,
|
||||
jsonEncode({
|
||||
@ -1588,7 +1589,8 @@ class ApiProvider extends BaseProvider {
|
||||
'startDate': startDate,
|
||||
'userid': userid,
|
||||
'countryCode': countryCode,
|
||||
'usernameType': usernameType
|
||||
'usernameType': usernameType,
|
||||
'isOnlyManageSelf': isOnlyManageSelf
|
||||
}));
|
||||
|
||||
//退出登录
|
||||
|
||||
@ -618,13 +618,13 @@ class ApiRepository {
|
||||
|
||||
//更新授权管理员
|
||||
Future<ElectronicKeyListEntity> updateAdministrator(
|
||||
String uid,
|
||||
String keyName,
|
||||
String endDate,
|
||||
String startDate,
|
||||
String remoteEnable) async {
|
||||
{required String uid,
|
||||
required String keyName,
|
||||
required String endDate,
|
||||
required String startDate,
|
||||
required int isOnlyManageSelf}) async {
|
||||
final res = await apiProvider.updateAdministrator(
|
||||
uid, keyName, endDate, startDate, remoteEnable);
|
||||
uid, keyName, endDate, startDate, isOnlyManageSelf);
|
||||
return ElectronicKeyListEntity.fromJson(res.body);
|
||||
}
|
||||
|
||||
@ -979,7 +979,8 @@ class ApiRepository {
|
||||
required String startDate,
|
||||
required String userid,
|
||||
required String countryCode,
|
||||
required String usernameType}) async {
|
||||
required String usernameType,
|
||||
required int isOnlyManageSelf}) async {
|
||||
final res = await apiProvider.addAuthorizedAdmin(
|
||||
createUser,
|
||||
endDate,
|
||||
@ -990,7 +991,8 @@ class ApiRepository {
|
||||
startDate,
|
||||
userid,
|
||||
countryCode,
|
||||
usernameType);
|
||||
usernameType,
|
||||
isOnlyManageSelf);
|
||||
return KeyDetailEntity.fromJson(res.body);
|
||||
}
|
||||
|
||||
|
||||
14
lib/tools/regularExpression.dart
Normal file
14
lib/tools/regularExpression.dart
Normal file
@ -0,0 +1,14 @@
|
||||
class RegularExpression {
|
||||
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);
|
||||
}
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user