From e9cf543e890fd6f92e5efec130c3a12b3aae5102 Mon Sep 17 00:00:00 2001 From: Daisy <> Date: Tue, 19 Sep 2023 10:53:41 +0800 Subject: [PATCH] =?UTF-8?q?1=EF=BC=8C=E5=8D=B3=E5=B0=86=E5=88=B0=E6=9C=9F?= =?UTF-8?q?=E5=88=97=E8=A1=A8=E6=8E=A5=E5=8F=A3=E8=B0=83=E8=AF=95=E5=8F=8A?= =?UTF-8?q?=E9=80=BB=E8=BE=91=E5=A4=84=E7=90=86=202=EF=BC=8C=E7=BE=A4?= =?UTF-8?q?=E5=8F=91=E9=92=A5=E5=8C=99=E9=80=BB=E8=BE=91=E5=AE=8C=E5=96=84?= =?UTF-8?q?=E5=8F=8A=E5=A4=84=E7=90=86=203=EF=BC=8C=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?=E6=8E=88=E6=9D=83=E7=AE=A1=E7=90=86=E5=91=98=E9=80=BB=E8=BE=91?= =?UTF-8?q?=E5=A4=84=E7=90=86=E5=8F=8A=E6=8E=A5=E5=8F=A3=E8=B0=83=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- star_lock/lib/app_settings/app_colors.dart | 1 + .../authorizedAdmin/authorizedAdmin_page.dart | 1 + .../volumeAuthorizationLock_page.dart | 1 + .../massSendElectronicKey_page.dart | 133 +++-- .../massSendReceiverCell.dart | 5 +- .../sendElectronicKey_page.dart | 1 + .../lockSeletGrouping_page.dart | 5 +- .../addAuthorizedAdministrator_page.dart | 545 ++++++++++++------ .../mineSet/lockGroup/lockGroupList_page.dart | 68 ++- .../expireLockList/expireLockListEntity.dart | 222 +++++++ .../expireLockList/expireLockList_page.dart | 73 ++- star_lock/lib/network/api_repository.dart | 5 +- 12 files changed, 810 insertions(+), 250 deletions(-) create mode 100644 star_lock/lib/mine/mineSet/lockUserManage/expireLockList/expireLockListEntity.dart diff --git a/star_lock/lib/app_settings/app_colors.dart b/star_lock/lib/app_settings/app_colors.dart index 434f88cb..ce8ce31e 100644 --- a/star_lock/lib/app_settings/app_colors.dart +++ b/star_lock/lib/app_settings/app_colors.dart @@ -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); //即将到期时间字体背景色 } diff --git a/star_lock/lib/main/lockDetail/authorizedAdmin/authorizedAdmin/authorizedAdmin_page.dart b/star_lock/lib/main/lockDetail/authorizedAdmin/authorizedAdmin/authorizedAdmin_page.dart index 7b7ba3f3..b364dfe4 100644 --- a/star_lock/lib/main/lockDetail/authorizedAdmin/authorizedAdmin/authorizedAdmin_page.dart +++ b/star_lock/lib/main/lockDetail/authorizedAdmin/authorizedAdmin/authorizedAdmin_page.dart @@ -439,6 +439,7 @@ class _AuthorizedAdminPageState extends State { if (entity.errorCode == 425) { //用户未注册 _isCreateUser = true; + sendElectronicKeyRequest(); } } } diff --git a/star_lock/lib/main/lockDetail/authorizedAdmin/volumeAuthorizationLock/volumeAuthorizationLock_page.dart b/star_lock/lib/main/lockDetail/authorizedAdmin/volumeAuthorizationLock/volumeAuthorizationLock_page.dart index e47470b1..fd60c3f8 100644 --- a/star_lock/lib/main/lockDetail/authorizedAdmin/volumeAuthorizationLock/volumeAuthorizationLock_page.dart +++ b/star_lock/lib/main/lockDetail/authorizedAdmin/volumeAuthorizationLock/volumeAuthorizationLock_page.dart @@ -326,6 +326,7 @@ class _VolumeAuthorizationLockPageState if (entity.errorCode == 425) { //用户未注册 _isCreateUser = true; + addAuthorizedAdminRequest(); } } } diff --git a/star_lock/lib/main/lockDetail/electronicKey/massSendElectronicKey/massSendElectronicKey_page.dart b/star_lock/lib/main/lockDetail/electronicKey/massSendElectronicKey/massSendElectronicKey_page.dart index 7a10a16d..8b7668a8 100644 --- a/star_lock/lib/main/lockDetail/electronicKey/massSendElectronicKey/massSendElectronicKey_page.dart +++ b/star_lock/lib/main/lockDetail/electronicKey/massSendElectronicKey/massSendElectronicKey_page.dart @@ -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 { } 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 MassKeyChecksRequest() async { String getFailureDateTime = '0'; @@ -135,7 +189,7 @@ class _MassSendElectronicKeyPageState extends State { getFailureDateTime, [], _lockIdList, - '1', + _isCreateUser == true ? '1' : '0', _isRemote ? '1' : '2', receiverUserID, receiverUserID, @@ -152,6 +206,7 @@ class _MassSendElectronicKeyPageState extends State { if (entity.errorCode == 425) { //用户未注册 _isCreateUser = true; + batchSendElectronicKeyRequest(receiverUserID); } } } diff --git a/star_lock/lib/main/lockDetail/electronicKey/massSendElectronicKey/massSendLockGroupList/massSendReceiver/massSendReceiverCell.dart b/star_lock/lib/main/lockDetail/electronicKey/massSendElectronicKey/massSendLockGroupList/massSendReceiver/massSendReceiverCell.dart index f82551e1..507674c6 100644 --- a/star_lock/lib/main/lockDetail/electronicKey/massSendElectronicKey/massSendLockGroupList/massSendReceiver/massSendReceiverCell.dart +++ b/star_lock/lib/main/lockDetail/electronicKey/massSendElectronicKey/massSendLockGroupList/massSendReceiver/massSendReceiverCell.dart @@ -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); }); diff --git a/star_lock/lib/main/lockDetail/electronicKey/sendElectronicKey/sendElectronicKey/sendElectronicKey_page.dart b/star_lock/lib/main/lockDetail/electronicKey/sendElectronicKey/sendElectronicKey/sendElectronicKey_page.dart index 73e397c0..592b41d2 100644 --- a/star_lock/lib/main/lockDetail/electronicKey/sendElectronicKey/sendElectronicKey/sendElectronicKey_page.dart +++ b/star_lock/lib/main/lockDetail/electronicKey/sendElectronicKey/sendElectronicKey/sendElectronicKey_page.dart @@ -361,6 +361,7 @@ class _SendElectronicKeyPageState extends State { if (entity.errorCode == 425) { //用户未注册 _isCreateUser = true; + sendElectronicKeyRequest(); } } } diff --git a/star_lock/lib/main/lockDetail/lcokSet/basicInformation/lockSeletGrouping/lockSeletGrouping_page.dart b/star_lock/lib/main/lockDetail/lcokSet/basicInformation/lockSeletGrouping/lockSeletGrouping_page.dart index 86111711..fba69716 100644 --- a/star_lock/lib/main/lockDetail/lcokSet/basicInformation/lockSeletGrouping/lockSeletGrouping_page.dart +++ b/star_lock/lib/main/lockDetail/lcokSet/basicInformation/lockSeletGrouping/lockSeletGrouping_page.dart @@ -147,9 +147,8 @@ class _LockSeletGroupingPageState extends State { 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: () { //发送编辑钥匙名称请求 diff --git a/star_lock/lib/mine/mineSet/authorizedAdministrator/addAuthorizedAdministrator_page.dart b/star_lock/lib/mine/mineSet/authorizedAdministrator/addAuthorizedAdministrator_page.dart index e978c301..91b23912 100644 --- a/star_lock/lib/mine/mineSet/authorizedAdministrator/addAuthorizedAdministrator_page.dart +++ b/star_lock/lib/mine/mineSet/authorizedAdministrator/addAuthorizedAdministrator_page.dart @@ -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; + _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; + _lockIdList = value['selectLockIdList']; + + setState(() {}); + } + }); + }), + SizedBox( + height: 10.h, + ), + remoteUnlockingWidget(), + SizedBox( + height: 20.h, + ), + _buildSureBtn() + ], + ); + } + } + + //发送批量授权管理员 + Future 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; + 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"; + } } diff --git a/star_lock/lib/mine/mineSet/lockGroup/lockGroupList_page.dart b/star_lock/lib/mine/mineSet/lockGroup/lockGroupList_page.dart index 85323824..c4d94fbe 100644 --- a/star_lock/lib/mine/mineSet/lockGroup/lockGroupList_page.dart +++ b/star_lock/lib/mine/mineSet/lockGroup/lockGroupList_page.dart @@ -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 { + TextEditingController _changeNameController = TextEditingController(); + + @override + void initState() { + super.initState(); + + mockNetworkDataRequest(); + } + @override Widget build(BuildContext context) { return Scaffold( @@ -33,6 +46,7 @@ class _LockGroupListPageState extends State { ), onPressed: () { // 处理操作按钮的点击事件-添加锁分组 + showCupertinoAlertDialog(context); }, ), ], @@ -79,4 +93,56 @@ class _LockGroupListPageState extends State { } }); } + + //分组列表请求 + Future> mockNetworkDataRequest() async { + MassSendLockGroupListEntity entity = + await ApiRepository.to.lockGroupList('1'); + if (entity.errorCode!.codeIsSuccessful) { + if (entity.data != null) { + return entity.data!.groupList!; + } else { + List dataList = []; + return dataList; + } + } else { + return []; + } + } + + //创建锁分组请求 + Future 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); + }, + ); + }, + ); + } } diff --git a/star_lock/lib/mine/mineSet/lockUserManage/expireLockList/expireLockListEntity.dart b/star_lock/lib/mine/mineSet/lockUserManage/expireLockList/expireLockListEntity.dart new file mode 100644 index 00000000..8262df98 --- /dev/null +++ b/star_lock/lib/mine/mineSet/lockUserManage/expireLockList/expireLockListEntity.dart @@ -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 json) { + errorCode = json['errorCode']; + description = json['description']; + errorMsg = json['errorMsg']; + data = + json['data'] != null ? ExpireLockListData.fromJson(json['data']) : null; + } + + Map toJson() { + final Map data = {}; + data['errorCode'] = errorCode; + data['description'] = description; + data['errorMsg'] = errorMsg; + if (this.data != null) { + data['data'] = this.data!.toJson(); + } + return data; + } +} + +class ExpireLockListData { + List? itemList; + int? pageNo; + int? pageSize; + int? pages; + int? total; + + ExpireLockListData( + {this.itemList, this.pageNo, this.pageSize, this.pages, this.total}); + + ExpireLockListData.fromJson(Map json) { + if (json['list'] != null) { + itemList = []; + json['list'].forEach((v) { + itemList!.add(ExpireLockItem.fromJson(v)); + }); + } + pageNo = json['pageNo']; + pageSize = json['pageSize']; + pages = json['pages']; + total = json['total']; + } + + Map toJson() { + final Map data = {}; + 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 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 toJson() { + final Map data = {}; + 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 json) { + id = json['id']; + accountName = json['account_name']; + } + + Map toJson() { + final Map data = {}; + data['id'] = id; + data['account_name'] = accountName; + return data; + } +} diff --git a/star_lock/lib/mine/mineSet/lockUserManage/expireLockList/expireLockList_page.dart b/star_lock/lib/mine/mineSet/lockUserManage/expireLockList/expireLockList_page.dart index f6cefa19..b8e37a62 100644 --- a/star_lock/lib/mine/mineSet/lockUserManage/expireLockList/expireLockList_page.dart +++ b/star_lock/lib/mine/mineSet/lockUserManage/expireLockList/expireLockList_page.dart @@ -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 { - List dataList = []; + List dataList = []; @override void initState() { @@ -44,7 +44,7 @@ class _ExpireLockListPageState extends State { 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 { } //请求即将到期列表 - Future> expireLockListRequest() async { - ElectronicKeyListEntity entity = + Future> expireLockListRequest() async { + ExpireLockListEntity entity = await ApiRepository.to.expireLockList('0', '1', '20'); - // if (entity.errorCode!.codeIsSuccessful) { - // setState(() { - // dataList = entity.data! as List; - // // 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 { 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 { 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), diff --git a/star_lock/lib/network/api_repository.dart b/star_lock/lib/network/api_repository.dart index 2f3f776c..c08a2182 100644 --- a/star_lock/lib/network/api_repository.dart +++ b/star_lock/lib/network/api_repository.dart @@ -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 expireLockList( + Future 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); } //删除密码