1,即将到期列表接口调试及逻辑处理

2,群发钥匙逻辑完善及处理
3,添加授权管理员逻辑处理及接口调试
This commit is contained in:
Daisy 2023-09-19 10:53:41 +08:00
parent 61621e7318
commit e9cf543e89
12 changed files with 810 additions and 250 deletions

View File

@ -121,4 +121,5 @@ class AppColors {
static const greyBackgroundColor = Color.fromRGBO(240, 240, 240, 1); //
static const btnDisableColor = Color.fromRGBO(178, 178, 178, 1); //
static const toBeReceiveBgColor = Color.fromRGBO(246, 203, 203, 1); //
static const expireTextBgColor = Color.fromRGBO(253, 166, 8, 1); //
}

View File

@ -439,6 +439,7 @@ class _AuthorizedAdminPageState extends State<AuthorizedAdminPage> {
if (entity.errorCode == 425) {
//
_isCreateUser = true;
sendElectronicKeyRequest();
}
}
}

View File

@ -326,6 +326,7 @@ class _VolumeAuthorizationLockPageState
if (entity.errorCode == 425) {
//
_isCreateUser = true;
addAuthorizedAdminRequest();
}
}
}

View File

@ -1,4 +1,5 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_pickers/pickers.dart';
import 'package:flutter_pickers/time_picker/model/date_mode.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
@ -63,47 +64,100 @@ class _MassSendElectronicKeyPageState extends State<MassSendElectronicKeyPage> {
}
Widget indexChangeWidget() {
switch (int.parse(widget.type)) {
case 0:
{
//
return Column(
children: [
keyInfoWidget(),
keyTimeWidget(),
remoteUnlockingWidget(),
keyBottomWidget()
],
);
}
case 1:
{
//
return Column(
children: [
keyInfoWidget(),
remoteUnlockingWidget(),
keyBottomWidget()
],
);
}
case 2:
{
//
return Column(
children: [
keyInfoWidget(),
periodValidityWidget(),
remoteUnlockingWidget(),
keyBottomWidget()
],
);
}
default:
return Container();
if (_isSendSuccess) {
return sendElectronicKeySucceed();
} else {
switch (int.parse(widget.type)) {
case 0:
{
//
return Column(
children: [
keyInfoWidget(),
keyTimeWidget(),
remoteUnlockingWidget(),
keyBottomWidget()
],
);
}
case 1:
{
//
return Column(
children: [
keyInfoWidget(),
remoteUnlockingWidget(),
keyBottomWidget()
],
);
}
case 2:
{
//
return Column(
children: [
keyInfoWidget(),
periodValidityWidget(),
remoteUnlockingWidget(),
keyBottomWidget()
],
);
}
default:
return Container();
}
}
}
//
Widget sendElectronicKeySucceed() {
return Column(
children: [
Container(
height: 250.h,
width: 1.sw,
color: Colors.white,
child: Column(
children: [
SizedBox(
height: 30.h,
),
Image.asset(
'images/icon_send_success.png',
width: 100.w,
height: 100.w,
),
SizedBox(
height: 20.h,
),
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text(
"发送成功",
style: TextStyle(
fontSize: 26.sp,
color: Colors.black,
fontWeight: FontWeight.w500),
),
],
),
],
),
),
SizedBox(
height: 20.h,
),
SubmitBtn(
btnName: '完成',
onClick: () {
_isSendSuccess = false;
Navigator.pop(context, true);
}),
],
);
}
//
Future<void> MassKeyChecksRequest() async {
String getFailureDateTime = '0';
@ -135,7 +189,7 @@ class _MassSendElectronicKeyPageState extends State<MassSendElectronicKeyPage> {
getFailureDateTime,
[],
_lockIdList,
'1',
_isCreateUser == true ? '1' : '0',
_isRemote ? '1' : '2',
receiverUserID,
receiverUserID,
@ -152,6 +206,7 @@ class _MassSendElectronicKeyPageState extends State<MassSendElectronicKeyPage> {
if (entity.errorCode == 425) {
//
_isCreateUser = true;
batchSendElectronicKeyRequest(receiverUserID);
}
}
}

View File

@ -19,9 +19,6 @@ class MassSendReceiverCell extends StatelessWidget {
@override
Widget build(BuildContext context) {
TextEditingController emailOrPhoneController = TextEditingController();
TextEditingController keyNameController = TextEditingController();
return Container(
color: Colors.white,
child: Row(
@ -80,6 +77,7 @@ class MassSendReceiverCell extends StatelessWidget {
TextEditingController _receiverController(String getStr) {
TextEditingController controller = TextEditingController(text: getStr);
controller.addListener(() {
userData.userid = controller.text;
print(controller.text);
});
@ -89,6 +87,7 @@ class MassSendReceiverCell extends StatelessWidget {
TextEditingController _nickNameController(String getStr) {
TextEditingController controller = TextEditingController(text: getStr);
controller.addListener(() {
userData.nickname = controller.text;
print(controller.text);
});

View File

@ -361,6 +361,7 @@ class _SendElectronicKeyPageState extends State<SendElectronicKeyPage> {
if (entity.errorCode == 425) {
//
_isCreateUser = true;
sendElectronicKeyRequest();
}
}
}

View File

@ -147,9 +147,8 @@ class _LockSeletGroupingPageState extends State<LockSeletGroupingPage> {
context: context,
builder: (BuildContext context) {
return ShowTFView(
title:
"${TranslationLoader.lanKeys!.amend!.tr}${TranslationLoader.lanKeys!.lockGroup!.tr}",
tipTitle: "请输入",
title: TranslationLoader.lanKeys!.createNewGroup!.tr,
tipTitle: TranslationLoader.lanKeys!.pleaseEnter!.tr,
controller: _changeNameController,
sureClick: () {
//

View File

@ -1,12 +1,17 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.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_utils/get_utils.dart';
import 'package:star_lock/appRouters.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/tools/commonItem.dart';
import 'package:star_lock/tools/submitBtn.dart';
import 'package:star_lock/tools/toast.dart';
import 'package:star_lock/translations/trans_lib.dart';
class AddAuthorizedAdministratorPage extends StatefulWidget {
@ -25,6 +30,20 @@ class _AddAuthorizedAdministratorPageState
final FlutterContactPicker _contactPicker = FlutterContactPicker();
late Contact _contact;
final _templateNameTf = TextEditingController();
late List _lockIdList;
late bool _isRemoteUnlock;
late bool _isCreateUser;
var _selectEffectiveDate = ''; //
var _selectFailureDate = ''; //
late DateTime _effectiveDateTime;
late DateTime _failureDateTime;
final TextEditingController _emailOrPhoneController =
TextEditingController(); ///
final TextEditingController _keyNameController =
TextEditingController(); //
String countryName = '中国';
String countryCode = '86';
late bool _isSendSuccess;
List tabs = [
TranslationLoader.lanKeys!.permanent!.tr,
@ -35,6 +54,10 @@ class _AddAuthorizedAdministratorPageState
void initState() {
super.initState();
_isCreateUser = false;
_lockIdList = [];
_isRemoteUnlock = false;
_isSendSuccess = false;
_tabController = TabController(length: 2, vsync: this);
}
@ -43,215 +66,282 @@ class _AddAuthorizedAdministratorPageState
return DefaultTabController(
length: 2,
child: Scaffold(
appBar: AppBar(
backgroundColor: AppColors.mainColor,
title: Text(
TranslationLoader.lanKeys!.addAuthorizedAdmin!.tr,
style: TextStyle(
color: Colors.white,
fontSize: 28.sp,
fontWeight: FontWeight.w600),
),
elevation: 0,
leading: IconButton(
icon: const Icon(Icons.arrow_back_ios, color: Colors.white),
onPressed: () => Navigator.of(context).pop(),
),
bottom: PreferredSize(
preferredSize: const Size.fromHeight(45),
child: Material(
color: Colors.white,
child: Theme(
data: ThemeData(
///,
highlightColor: Colors.transparent,
///
splashColor: Colors.transparent,
),
child: TabBar(
controller: _tabController,
indicatorSize: TabBarIndicatorSize.label,
indicatorColor: AppColors.mainColor,
unselectedLabelColor: AppColors.blackColor,
labelColor: AppColors.mainColor,
// isScrollable: true,
tabs: tabs.map((e) => Tab(text: e)).toList()),
)),
),
appBar: AppBar(
backgroundColor: AppColors.mainColor,
title: Text(
TranslationLoader.lanKeys!.addAuthorizedAdmin!.tr,
style: TextStyle(
color: Colors.white,
fontSize: 28.sp,
fontWeight: FontWeight.w600),
),
body: TabBarView(controller: _tabController, children: [
_permanentAdministrator(),
_timeLimitAdministrator()
])));
elevation: 0,
leading: IconButton(
icon: const Icon(Icons.arrow_back_ios, color: Colors.white),
onPressed: () => Navigator.of(context).pop(),
),
bottom: PreferredSize(
preferredSize: const Size.fromHeight(45),
child: Material(
color: Colors.white,
child: Theme(
data: ThemeData(
///,
highlightColor: Colors.transparent,
///
splashColor: Colors.transparent,
),
child: TabBar(
controller: _tabController,
indicatorSize: TabBarIndicatorSize.label,
indicatorColor: AppColors.mainColor,
unselectedLabelColor: AppColors.blackColor,
labelColor: AppColors.mainColor,
// isScrollable: true,
tabs: tabs.map((e) => Tab(text: e)).toList()),
)),
),
),
body: TabBarView(controller: _tabController, children: [
SingleChildScrollView(
child: _permanentAdministrator(),
),
SingleChildScrollView(
child: _timeLimitAdministrator(),
)
]),
));
}
//
Widget _permanentAdministrator() {
return Column(
children: [
SizedBox(
height: 10.h,
),
_buildAccoutRow(),
SizedBox(
height: 10.h,
),
CommonItem(
leftTitel: TranslationLoader.lanKeys!.lock!.tr,
rightTitle: TranslationLoader.lanKeys!.pleaseSelet!.tr,
isHaveDirection: true,
action: () {}),
SizedBox(
height: 10.h,
),
remoteUnlockingWidget(),
SizedBox(
height: 20.h,
),
_buildSureBtn()
],
);
if (_isSendSuccess) {
return sendElectronicKeySucceed();
} else {
return Column(
children: [
SizedBox(
height: 10.h,
),
keyInfoWidget(),
SizedBox(
height: 10.h,
),
CommonItem(
leftTitel: TranslationLoader.lanKeys!.lock!.tr,
rightTitle: _lockIdList.isEmpty
? TranslationLoader.lanKeys!.pleaseSelet!.tr
: _lockIdList.length.toString(),
isHaveDirection: true,
action: () {
Navigator.pushNamed(context, Routers.massSendLockGroupPage)
.then((value) {
//ID列表
if (value != null) {
value as Map<String, dynamic>;
_lockIdList = value['selectLockIdList'];
setState(() {});
}
});
}),
SizedBox(
height: 10.h,
),
remoteUnlockingWidget(),
SizedBox(
height: 20.h,
),
_buildSureBtn()
],
);
}
}
//
Widget _timeLimitAdministrator() {
if (_isSendSuccess) {
return sendElectronicKeySucceed();
} else {
return Column(
children: [
SizedBox(
height: 10.h,
),
keyInfoWidget(),
SizedBox(
height: 10.h,
),
keyTimeWidget(),
SizedBox(
height: 10.h,
),
CommonItem(
leftTitel: TranslationLoader.lanKeys!.lock!.tr,
rightTitle: _lockIdList.isEmpty
? TranslationLoader.lanKeys!.pleaseSelet!.tr
: _lockIdList.length.toString(),
isHaveDirection: true,
action: () {
Navigator.pushNamed(context, Routers.massSendLockGroupPage)
.then((value) {
//ID列表
if (value != null) {
value as Map<String, dynamic>;
_lockIdList = value['selectLockIdList'];
setState(() {});
}
});
}),
SizedBox(
height: 10.h,
),
remoteUnlockingWidget(),
SizedBox(
height: 20.h,
),
_buildSureBtn()
],
);
}
}
//
Future<void> addAuthorizedAdminRequest() async {
String getFailureDateTime = '0';
String getEffectiveDateTime = '0';
if (_tabController!.index == 1) {
getFailureDateTime = _failureDateTime.millisecondsSinceEpoch.toString();
getEffectiveDateTime =
_effectiveDateTime.millisecondsSinceEpoch.toString();
}
var entity = await ApiRepository.to.addAuthorizedAdmin(
_isCreateUser ? "1" : "0",
getFailureDateTime,
_isRemoteUnlock == true ? '1' : '2',
[],
_lockIdList,
_keyNameController.text,
getEffectiveDateTime,
_emailOrPhoneController.text,
countryCode,
'1',
);
if (entity.errorCode!.codeIsSuccessful) {
print('发送电子钥匙成功');
_isSendSuccess = true;
setState(() {});
} else {
Toast.show(msg: '${entity.errorMsg}');
if (entity.errorCode == 425) {
//
_isCreateUser = true;
addAuthorizedAdminRequest();
}
}
}
// widget
Widget keyInfoWidget() {
return Column(
children: [
SizedBox(
height: 10.h,
),
_buildAccoutRow(),
SizedBox(
height: 10.h,
),
keyTimeWidget(),
SizedBox(
height: 10.h,
Container(height: 10.h),
CommonItem(
leftTitel: TranslationLoader.lanKeys!.accountNumber!.tr,
rightTitle: "",
isHaveLine: true,
isHaveRightWidget: true,
rightWidget: getTFWidget(
true,
TranslationLoader.lanKeys!.pleaseEnterNumberOrEmail!.tr,
_emailOrPhoneController)),
CommonItem(
leftTitel: TranslationLoader.lanKeys!.countryAndRegion!.tr,
rightTitle: "",
isHaveLine: true,
isHaveRightWidget: true,
isHaveDirection: true,
rightWidget: Text(
'$countryName +$countryCode',
textAlign: TextAlign.end,
style:
TextStyle(fontSize: 22.sp, color: AppColors.darkGrayTextColor),
),
action: () async {
var result = await Navigator.pushNamed(
context, Routers.seletCountryRegionPage);
result as Map<String, dynamic>;
countryCode = result['code'];
countryName = result['countryName'];
setState(() {});
},
),
CommonItem(
leftTitel: TranslationLoader.lanKeys!.lock!.tr,
rightTitle: TranslationLoader.lanKeys!.pleaseSelet!.tr,
isHaveDirection: true,
action: () {}),
SizedBox(
height: 10.h,
),
remoteUnlockingWidget(),
SizedBox(
height: 20.h,
),
_buildSureBtn()
leftTitel: TranslationLoader.lanKeys!.name!.tr,
rightTitle: "",
isHaveRightWidget: true,
rightWidget: getTFWidget(
false,
TranslationLoader.lanKeys!.pleaseEnter!.tr,
_keyNameController)),
Container(height: 10.h),
],
);
}
Widget _buildAccoutRow() {
return Column(
children: [
Container(
color: Colors.white,
height: 60.h,
child: Row(
children: [
SizedBox(
width: 40.w,
),
Text(
TranslationLoader.lanKeys!.accountNumber!.tr,
style: TextStyle(
color: AppColors.darkGrayTextColor, fontSize: 24.sp),
),
Expanded(
child: TextField(
textAlign: TextAlign.right,
keyboardType: TextInputType.text,
onChanged: (value) {},
decoration: InputDecoration(
border: InputBorder.none,
hintText:
TranslationLoader.lanKeys!.pleaseEnterAccountNumber!.tr,
hintStyle: TextStyle(
color: AppColors.placeholderTextColor,
fontSize: ScreenUtil().setSp(24),
textBaseline: TextBaseline.alphabetic),
),
)),
SizedBox(
width: 20.w,
),
Image.asset(
'images/icon_addressBook.png',
width: 28.w,
height: 28.h,
),
SizedBox(
width: 40.w,
)
],
),
),
const SizedBox(
height: 1,
),
Container(
color: Colors.white,
child: Row(
children: [
SizedBox(
width: 40.w,
),
Text(
TranslationLoader.lanKeys!.name!.tr,
style: TextStyle(
color: AppColors.darkGrayTextColor, fontSize: 24.sp),
),
Expanded(
child: TextField(
textAlign: TextAlign.right,
keyboardType: TextInputType.text,
onChanged: (value) {},
decoration: InputDecoration(
border: InputBorder.none,
hintText: TranslationLoader.lanKeys!.pleaseEnter!.tr,
hintStyle: TextStyle(
color: AppColors.placeholderTextColor,
fontSize: ScreenUtil().setSp(24),
textBaseline: TextBaseline.alphabetic),
),
)),
SizedBox(
width: 40.w,
)
],
),
),
],
);
}
Widget getTFWidget(TextEditingController tfController, String tfStr) {
return Container(
//
Widget getTFWidget(
bool isHaveBtn, String tfStr, TextEditingController editController) {
return SizedBox(
height: 50.h,
width: 500.w,
width: 300.w,
child: Row(
children: [
Expanded(
child: TextField(
controller: editController,
//
maxLines: 1,
controller: tfController,
// controller: _controller,
autofocus: false,
textAlign: TextAlign.end,
decoration: InputDecoration(
//
contentPadding: const EdgeInsets.only(top: 12.0, bottom: 8.0),
hintText: tfStr,
hintStyle: TextStyle(fontSize: 22.sp),
//线
border: InputBorder.none,
),
),
),
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? contact = await _contactPicker.selectContact();
setState(() {
_contact = contact!;
// print("object111111111111 ${_contact.fullName} ${_contact.phoneNumbers}");
});
},
),
)
: Container()
],
),
);
@ -278,18 +368,32 @@ class _AddAuthorizedAdministratorPageState
children: [
CommonItem(
leftTitel: TranslationLoader.lanKeys!.effectiveTime!.tr,
rightTitle: "2020.06.20 11:49",
rightTitle: _selectEffectiveDate,
isHaveLine: true,
isHaveDirection: true,
action: () {
// _showDatePicker();
Pickers.showDatePicker(context, mode: DateMode.YMDHM,
onConfirm: (p) {
setState(() {
_selectEffectiveDate =
'${p.year}-${intToStr(p.month!)}-${intToStr(p.day!)} ${intToStr(p.hour!)}:${intToStr(p.minute!)}';
_effectiveDateTime = DateTime.parse(_selectEffectiveDate);
});
});
}),
CommonItem(
leftTitel: TranslationLoader.lanKeys!.failureTime!.tr,
rightTitle: "2020.06.20 11:49",
rightTitle: _selectFailureDate,
isHaveDirection: true,
action: () {
// _showDatePicker();
Pickers.showDatePicker(context, mode: DateMode.YMDHM,
onConfirm: (p) {
setState(() {
_selectFailureDate =
'${p.year}-${intToStr(p.month!)}-${intToStr(p.day!)} ${intToStr(p.hour!)}:${intToStr(p.minute!)}';
_failureDateTime = DateTime.parse(_selectFailureDate);
});
});
}),
Container(height: 10.h),
],
@ -342,16 +446,87 @@ class _AddAuthorizedAdministratorPageState
);
}
//
Widget sendElectronicKeySucceed() {
return Column(
children: [
Container(
height: 250.h,
width: 1.sw,
color: Colors.white,
child: Column(
children: [
SizedBox(
height: 30.h,
),
Image.asset(
'images/icon_send_success.png',
width: 100.w,
height: 100.w,
),
SizedBox(
height: 20.h,
),
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text(
"发送成功",
style: TextStyle(
fontSize: 26.sp,
color: Colors.black,
fontWeight: FontWeight.w500),
),
],
),
],
),
),
SizedBox(
height: 20.h,
),
SubmitBtn(
btnName: '完成',
onClick: () {
_isSendSuccess = false;
Navigator.pop(context, true);
}),
SizedBox(
height: 10.h,
),
OutLineBtn(
btnName: '邮件通知',
onClick: () {
Navigator.pushNamed(context, Routers.sendEmailNotificationPage);
},
),
SizedBox(
height: 10.h,
),
OutLineBtn(
btnName: '微信通知',
onClick: () {},
),
SizedBox(
height: 10.h,
),
OutLineBtn(
btnName: '标记为已入住',
onClick: () {},
),
],
);
}
CupertinoSwitch _switch() {
bool _isOn = false;
return CupertinoSwitch(
activeColor: CupertinoColors.activeBlue,
trackColor: CupertinoColors.systemGrey5,
thumbColor: CupertinoColors.white,
value: _isOn,
value: _isRemoteUnlock,
onChanged: (value) {
setState(() {
_isOn = value;
_isRemoteUnlock = !_isRemoteUnlock;
});
},
);
@ -360,7 +535,13 @@ class _AddAuthorizedAdministratorPageState
Widget _buildSureBtn() {
return SubmitBtn(
btnName: TranslationLoader.lanKeys!.sure!.tr,
onClick: () {},
onClick: () {
addAuthorizedAdminRequest();
},
);
}
String intToStr(int v) {
return (v < 10) ? "0$v" : "$v";
}
}

View File

@ -1,11 +1,15 @@
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';
import 'package:star_lock/main/lockDetail/electronicKey/massSendElectronicKey/massSendLockGroupList/massSendLockGroupListEntity.dart';
import 'package:star_lock/network/api_repository.dart';
import 'package:star_lock/tools/baseGetXController.dart';
import 'package:star_lock/tools/showTFView.dart';
import 'package:star_lock/tools/toast.dart';
import '../../../../../appRouters.dart';
import '../../../../../app_settings/app_colors.dart';
import '../../../../../tools/commonItem.dart';
import '../../../../../tools/submitBtn.dart';
import '../../../../../tools/titleAppBar.dart';
import '../../../../../translations/trans_lib.dart';
@ -17,6 +21,15 @@ class LockGroupListPage extends StatefulWidget {
}
class _LockGroupListPageState extends State<LockGroupListPage> {
TextEditingController _changeNameController = TextEditingController();
@override
void initState() {
super.initState();
mockNetworkDataRequest();
}
@override
Widget build(BuildContext context) {
return Scaffold(
@ -33,6 +46,7 @@ class _LockGroupListPageState extends State<LockGroupListPage> {
),
onPressed: () {
// -
showCupertinoAlertDialog(context);
},
),
],
@ -79,4 +93,56 @@ class _LockGroupListPageState extends State<LockGroupListPage> {
}
});
}
//
Future<List<GroupListItem>> mockNetworkDataRequest() async {
MassSendLockGroupListEntity entity =
await ApiRepository.to.lockGroupList('1');
if (entity.errorCode!.codeIsSuccessful) {
if (entity.data != null) {
return entity.data!.groupList!;
} else {
List<GroupListItem> dataList = [];
return dataList;
}
} else {
return [];
}
}
//
Future<void> addLockGroupRequest() async {
MassSendLockGroupListEntity entity =
await ApiRepository.to.addLockGroup(_changeNameController.text, '0');
if (entity.errorCode!.codeIsSuccessful) {
Toast.show(msg: "创建成功");
mockNetworkDataRequest();
setState(() {});
}
}
void showCupertinoAlertDialog(BuildContext context) {
showDialog(
context: context,
builder: (BuildContext context) {
return ShowTFView(
title: TranslationLoader.lanKeys!.createNewGroup!.tr,
tipTitle: TranslationLoader.lanKeys!.pleaseEnter!.tr,
controller: _changeNameController,
sureClick: () {
//
if (_changeNameController.text.isNotEmpty) {
addLockGroupRequest();
Navigator.pop(context);
} else {
Toast.show(msg: '请输入分组名称');
}
},
cancelClick: () {
Navigator.pop(context);
},
);
},
);
}
}

View File

@ -0,0 +1,222 @@
class ExpireLockListEntity {
int? errorCode;
String? description;
String? errorMsg;
ExpireLockListData? data;
ExpireLockListEntity(
{this.errorCode, this.description, this.errorMsg, this.data});
ExpireLockListEntity.fromJson(Map<String, dynamic> json) {
errorCode = json['errorCode'];
description = json['description'];
errorMsg = json['errorMsg'];
data =
json['data'] != null ? ExpireLockListData.fromJson(json['data']) : null;
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = <String, dynamic>{};
data['errorCode'] = errorCode;
data['description'] = description;
data['errorMsg'] = errorMsg;
if (this.data != null) {
data['data'] = this.data!.toJson();
}
return data;
}
}
class ExpireLockListData {
List<ExpireLockItem>? itemList;
int? pageNo;
int? pageSize;
int? pages;
int? total;
ExpireLockListData(
{this.itemList, this.pageNo, this.pageSize, this.pages, this.total});
ExpireLockListData.fromJson(Map<String, dynamic> json) {
if (json['list'] != null) {
itemList = <ExpireLockItem>[];
json['list'].forEach((v) {
itemList!.add(ExpireLockItem.fromJson(v));
});
}
pageNo = json['pageNo'];
pageSize = json['pageSize'];
pages = json['pages'];
total = json['total'];
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = <String, dynamic>{};
if (itemList != null) {
data['list'] = itemList!.map((v) => v.toJson()).toList();
}
data['pageNo'] = pageNo;
data['pageSize'] = pageSize;
data['pages'] = pages;
data['total'] = total;
return data;
}
}
class ExpireLockItem {
String? clientId;
int? lockOwnerId;
int? lockId;
int? senderUserId;
int? keyType;
int? startDate;
int? endDate;
List? weekDays;
String? remarks;
int? remoteEnable;
int? isCameraEnable;
int? faceAuthentication;
int? keyRight;
int? userType;
int? keyStatus;
int? groupId;
int? lockUserNo;
int? date;
String? createdAt;
String? updatedAt;
UserInfo? userInfo;
int? keyId;
int? uid;
String? nickname;
String? lockAlias;
int? expireDate;
String? nickname2;
String? headUrl;
String? userid;
ExpireLockItem(
{this.clientId,
this.lockOwnerId,
this.lockId,
this.senderUserId,
this.keyType,
this.startDate,
this.endDate,
this.weekDays,
this.remarks,
this.remoteEnable,
this.isCameraEnable,
this.faceAuthentication,
this.keyRight,
this.userType,
this.keyStatus,
this.groupId,
this.lockUserNo,
this.date,
this.createdAt,
this.updatedAt,
this.userInfo,
this.keyId,
this.uid,
this.nickname,
this.lockAlias,
this.expireDate,
this.nickname2,
this.headUrl,
this.userid});
ExpireLockItem.fromJson(Map<String, dynamic> json) {
clientId = json['clientId'];
lockOwnerId = json['lockOwnerId'];
lockId = json['lockId'];
senderUserId = json['senderUserId'];
keyType = json['keyType'];
startDate = json['startDate'];
endDate = json['endDate'];
if (json['weekDays'] != null) {
weekDays = [];
json['weekDays'].forEach((v) {
weekDays!.add(v);
});
}
remarks = json['remarks'];
remoteEnable = json['remoteEnable'];
isCameraEnable = json['isCameraEnable'];
faceAuthentication = json['faceAuthentication'];
keyRight = json['keyRight'];
userType = json['userType'];
keyStatus = json['keyStatus'];
groupId = json['groupId'];
lockUserNo = json['lockUserNo'];
date = json['date'];
createdAt = json['created_at'];
updatedAt = json['updated_at'];
userInfo =
json['user_info'] != null ? UserInfo.fromJson(json['user_info']) : null;
keyId = json['keyId'];
uid = json['uid'];
nickname = json['nickname'];
lockAlias = json['lockAlias'];
expireDate = json['expireDate'];
nickname2 = json['nickname2'];
headUrl = json['headUrl'];
userid = json['userid'];
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = <String, dynamic>{};
data['clientId'] = clientId;
data['lockOwnerId'] = lockOwnerId;
data['lockId'] = lockId;
data['senderUserId'] = senderUserId;
data['keyType'] = keyType;
data['startDate'] = startDate;
data['endDate'] = endDate;
if (weekDays != null) {
data['weekDays'] = weekDays!.map((v) => v.toJson()).toList();
}
data['remarks'] = remarks;
data['remoteEnable'] = remoteEnable;
data['isCameraEnable'] = isCameraEnable;
data['faceAuthentication'] = faceAuthentication;
data['keyRight'] = keyRight;
data['userType'] = userType;
data['keyStatus'] = keyStatus;
data['groupId'] = groupId;
data['lockUserNo'] = lockUserNo;
data['date'] = date;
data['created_at'] = createdAt;
data['updated_at'] = updatedAt;
if (userInfo != null) {
data['user_info'] = userInfo!.toJson();
}
data['keyId'] = keyId;
data['uid'] = uid;
data['nickname'] = nickname;
data['lockAlias'] = lockAlias;
data['expireDate'] = expireDate;
data['nickname2'] = nickname2;
data['headUrl'] = headUrl;
data['userid'] = userid;
return data;
}
}
class UserInfo {
int? id;
String? accountName;
UserInfo({this.id, this.accountName});
UserInfo.fromJson(Map<String, dynamic> json) {
id = json['id'];
accountName = json['account_name'];
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = <String, dynamic>{};
data['id'] = id;
data['account_name'] = accountName;
return data;
}
}

View File

@ -1,9 +1,9 @@
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';
import 'package:star_lock/main/lockDetail/electronicKey/electronicKeyList/entity/ElectronicKeyListEntity.dart';
import 'package:star_lock/main/lockDetail/electronicKey/massSendElectronicKey/massSendLockGroupList/lockUserList/lockUserListEntity.dart';
import 'package:star_lock/mine/mineSet/lockUserManage/expireLockList/expireLockListEntity.dart';
import 'package:star_lock/network/api_repository.dart';
import 'package:star_lock/tools/baseGetXController.dart';
import '../../../../appRouters.dart';
import '../../../../app_settings/app_colors.dart';
@ -18,7 +18,7 @@ class ExpireLockListPage extends StatefulWidget {
}
class _ExpireLockListPageState extends State<ExpireLockListPage> {
List<LockUserData> dataList = [];
List<ExpireLockItem> dataList = [];
@override
void initState() {
@ -44,7 +44,7 @@ class _ExpireLockListPageState extends State<ExpireLockListPage> {
return ListView.separated(
itemCount: dataList.length,
itemBuilder: (c, index) {
LockUserData indexEntity = dataList[index];
ExpireLockItem indexEntity = dataList[index];
return _electronicKeyItem(indexEntity);
},
separatorBuilder: (BuildContext context, int index) {
@ -57,19 +57,30 @@ class _ExpireLockListPageState extends State<ExpireLockListPage> {
}
//
Future<List<LockUserData>> expireLockListRequest() async {
ElectronicKeyListEntity entity =
Future<List<ExpireLockItem>> expireLockListRequest() async {
ExpireLockListEntity entity =
await ApiRepository.to.expireLockList('0', '1', '20');
// if (entity.errorCode!.codeIsSuccessful) {
// setState(() {
// dataList = entity.data! as List<LockUserData>;
// // dataList = entity.data!;
// });
// }
if (entity.errorCode!.codeIsSuccessful) {
setState(() {
dataList = entity.data!.itemList!;
// dataList = entity.data!;
});
}
return dataList;
}
Widget _electronicKeyItem(LockUserData itemData) {
//使
String getExpireDateStr(ExpireLockItem itemData) {
DateTime startDateStr =
DateTime.fromMillisecondsSinceEpoch(itemData.startDate!);
DateTime endDateStr =
DateTime.fromMillisecondsSinceEpoch(itemData.endDate!);
String useDateStr =
'${startDateStr.toLocal().toString().substring(0, 10)}-${endDateStr.toLocal().toString().substring(0, 10)}';
return useDateStr;
}
Widget _electronicKeyItem(ExpireLockItem itemData) {
return GestureDetector(
onTap: () {
Navigator.pushNamed(context, Routers.ownedKeyListPage,
@ -78,10 +89,6 @@ class _ExpireLockListPageState extends State<ExpireLockListPage> {
child: Container(
height: 90.h,
color: Colors.white,
// decoration: BoxDecoration(
// color: Colors.white,
// borderRadius: BorderRadius.circular(10.w),
// ),
child: Row(
children: [
SizedBox(
@ -105,20 +112,46 @@ class _ExpireLockListPageState extends State<ExpireLockListPage> {
Text(
itemData.nickname ?? '',
style: TextStyle(
fontSize: 24.sp, color: AppColors.blackColor),
fontSize: 20.sp, color: AppColors.blackColor),
),
Expanded(
child: SizedBox(
width: 10.w,
)),
Text(
itemData.lockAlias ?? '',
style: TextStyle(
fontSize: 20.sp, color: AppColors.blackColor),
),
],
),
SizedBox(height: 5.h),
SizedBox(height: 10.h),
Row(
mainAxisAlignment: MainAxisAlignment.start,
children: [
Text(
itemData.userid ?? '',
getExpireDateStr(itemData),
style: TextStyle(
fontSize: 18.sp,
color: AppColors.placeholderTextColor),
),
SizedBox(
width: 5.w,
),
itemData.expireDate! > 0
? Container(
padding: EdgeInsets.only(left: 2.w, right: 2.w),
decoration: BoxDecoration(
color: AppColors.expireTextBgColor,
borderRadius: BorderRadius.circular(2.0),
),
child: Text(
'${itemData.expireDate.toString()}',
style: TextStyle(
color: Colors.white, fontSize: 13.sp),
),
)
: Container()
],
),
SizedBox(width: 20.h),

View File

@ -9,6 +9,7 @@ import 'package:star_lock/main/lockDetail/lcokSet/basicInformation/lockSeletGrou
import 'package:star_lock/main/lockDetail/passwordKey/passwordKeyList/passwordKeyListEntity.dart';
import 'package:star_lock/main/lockDetail/passwordKey/passwordKey_perpetual/passwordKeyEntity.dart';
import 'package:star_lock/mine/mineSet/authorizedAdministrator/authorizedAdminListEntity.dart';
import 'package:star_lock/mine/mineSet/lockUserManage/expireLockList/expireLockListEntity.dart';
import 'package:star_lock/mine/mineSet/lockUserManage/keyListByUserEntity.dart';
import '../common/safetyVerification/entity/CheckSafetyVerificationEntity.dart';
import '../common/safetyVerification/entity/SafetyVerificationEntity.dart';
@ -407,10 +408,10 @@ class ApiRepository {
}
//
Future<ElectronicKeyListEntity> expireLockList(
Future<ExpireLockListEntity> expireLockList(
String operatorUid, String pageNo, String pageSize) async {
final res = await apiProvider.expireLockList(operatorUid, pageNo, pageSize);
return ElectronicKeyListEntity.fromJson(res.body);
return ExpireLockListEntity.fromJson(res.body);
}
//