diff --git a/lib/main/lockDetail/authorizedAdmin/authorizedAdmin/authorizedAdmin_logic.dart b/lib/main/lockDetail/authorizedAdmin/authorizedAdmin/authorizedAdmin_logic.dart index 434c7e57..3869b32f 100755 --- a/lib/main/lockDetail/authorizedAdmin/authorizedAdmin/authorizedAdmin_logic.dart +++ b/lib/main/lockDetail/authorizedAdmin/authorizedAdmin/authorizedAdmin_logic.dart @@ -10,8 +10,8 @@ import 'package:star_lock/tools/dateTool.dart'; import 'package:star_lock/tools/showCupertinoAlertView.dart'; import '../../../../blue/blue_manage.dart'; -import '../../../../blue/io_reply.dart'; import '../../../../blue/io_protocol/io_transferPermissions.dart'; +import '../../../../blue/io_reply.dart'; import '../../../../blue/io_tool/io_tool.dart'; import '../../../../blue/io_tool/manager_event_bus.dart'; import '../../../../blue/sender_manage.dart'; diff --git a/lib/main/lockDetail/authorizedAdmin/authorizedAdmin/authorizedAdmin_page.dart b/lib/main/lockDetail/authorizedAdmin/authorizedAdmin/authorizedAdmin_page.dart index 8eb565c0..6f3d0d2f 100755 --- a/lib/main/lockDetail/authorizedAdmin/authorizedAdmin/authorizedAdmin_page.dart +++ b/lib/main/lockDetail/authorizedAdmin/authorizedAdmin/authorizedAdmin_page.dart @@ -4,6 +4,7 @@ import 'package:flutter/services.dart'; import 'package:flutter_native_contact_picker/flutter_native_contact_picker.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:get/get.dart'; +import 'package:star_lock/main/lockDetail/authorizedAdmin/authorizedAdmin/authorizedAdmin_state.dart'; import 'package:star_lock/tools/dateTool.dart'; import 'package:star_lock/tools/pickers/pickers.dart'; @@ -31,8 +32,8 @@ class AuthorizedAdminPage extends StatefulWidget { class _AuthorizedAdminPageState extends State with SingleTickerProviderStateMixin { - final logic = Get.put(AuthorizedAdminLogic()); - final state = Get.find().state; + final AuthorizedAdminLogic logic = Get.put(AuthorizedAdminLogic()); + final AuthorizedAdminState state = Get.find().state; @override void initState() { @@ -60,7 +61,7 @@ class _AuthorizedAdminPageState extends State haveBack: true, backgroundColor: AppColors.mainColor), body: Column( - children: [ + children: [ _tabBar(), _pageWidget(), ], @@ -78,7 +79,7 @@ class _AuthorizedAdminPageState extends State // 限时 return SingleChildScrollView( child: Column( - children: [ + children: [ keyInfoWidget(), keyTimeWidget(), keyOnlyManageWidget(), @@ -92,7 +93,7 @@ class _AuthorizedAdminPageState extends State // 永久 return SingleChildScrollView( child: Column( - children: [ + children: [ keyInfoWidget(), keyOnlyManageWidget(), keyBottomWidget( @@ -107,17 +108,17 @@ class _AuthorizedAdminPageState extends State // 顶部钥匙信息widget Widget keyInfoWidget() { return Column( - children: [ + children: [ CommonItem( leftTitel: TranslationLoader.lanKeys!.receiver!.tr, - rightTitle: "", + rightTitle: '', isHaveLine: true, isHaveRightWidget: true, rightWidget: getTFWidget(true, TranslationLoader.lanKeys!.pleaseEnterNumberOrEmail!.tr, 1)), CommonItem( leftTitel: TranslationLoader.lanKeys!.countryAndRegion!.tr, - rightTitle: "", + rightTitle: '', isHaveLine: true, isHaveRightWidget: true, isHaveDirection: true, @@ -128,7 +129,7 @@ class _AuthorizedAdminPageState extends State 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; @@ -140,7 +141,7 @@ class _AuthorizedAdminPageState extends State ), CommonItem( leftTitel: TranslationLoader.lanKeys!.name!.tr, - rightTitle: "", + rightTitle: '', isHaveRightWidget: true, rightWidget: getTFWidget( false, TranslationLoader.lanKeys!.enterYourName!.tr, 2)), @@ -152,17 +153,18 @@ class _AuthorizedAdminPageState extends State // 生效失效时间 Widget keyTimeWidget() { return Column( - children: [ + children: [ CommonItem( leftTitel: TranslationLoader.lanKeys!.effectiveTime!.tr, rightTitle: state.beginDate.value, 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) { + selectDate: selectDate, + mode: DateMode.YMDHM, onConfirm: (PDuration p) { setState(() { state.beginDate.value = DateTool().getYMDHNDateString(p, 1); }); @@ -173,10 +175,11 @@ class _AuthorizedAdminPageState extends State 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) { + selectDate: selectDate, + mode: DateMode.YMDHM, onConfirm: (PDuration p) { setState(() { state.endDate.value = DateTool().getYMDHNDateString(p, 1); }); @@ -190,14 +193,14 @@ class _AuthorizedAdminPageState extends State // 实名认证 Widget keyOnlyManageWidget() { return Column( - children: [ + children: [ CommonItem( - leftTitel: "仅管理自己创建的用户", - rightTitle: "", + leftTitel: '仅管理自己创建的用户', + rightTitle: '', isHaveRightWidget: true, isTipsImg: true, tipsImgAction: () { - ShowTipView().showSureAlertDialog("授权管理员只能查看和管理自己下发的钥匙、密码等权限"); + ShowTipView().showSureAlertDialog('授权管理员只能查看和管理自己下发的钥匙、密码等权限'); }, rightWidget: SizedBox( width: 60.w, @@ -212,11 +215,11 @@ class _AuthorizedAdminPageState extends State Widget keyBottomWidget(String tipStr) { return Column( - children: [ + children: [ Container( padding: EdgeInsets.all(20.w), child: Row( - children: [ + children: [ Expanded( child: Text( tipStr, @@ -233,26 +236,27 @@ class _AuthorizedAdminPageState extends State SubmitBtn( btnName: TranslationLoader.lanKeys!.send!.tr, onClick: () async { - var isDemoMode = await Storage.getBool(ifIsDemoModeOrNot); + final bool? isDemoMode = await Storage.getBool(ifIsDemoModeOrNot); if (isDemoMode == false) { //发送钥匙请求 logic.sendElectronicKeyRequest(); } else { - logic.showToast("演示模式"); + logic.showToast('演示模式'); } }), Container( padding: EdgeInsets.only(right: 30.w), child: Row( mainAxisAlignment: MainAxisAlignment.end, - children: [ + children: [ TextButton( onPressed: () async { - var isDemoMode = await Storage.getBool(ifIsDemoModeOrNot); + final bool? isDemoMode = + await Storage.getBool(ifIsDemoModeOrNot); if (isDemoMode == false) { Get.toNamed(Routers.volumeAuthorizationLockManagePage); } else { - logic.showToast("演示模式"); + logic.showToast('演示模式'); } }, child: Text( @@ -270,16 +274,15 @@ class _AuthorizedAdminPageState extends State // 实名认证 Widget keyRealNameWidget() { return Column( - children: [ + children: [ Obx(() => CommonItem( leftTitel: TranslationLoader.lanKeys!.realNameAuthentication!.tr, - rightTitle: "", + rightTitle: '', isTipsImg: true, - isHaveLine: - logic.state.isRequireAuth.value == true ? true : false, + isHaveLine: logic.state.isRequireAuth.value == true, tipsImgAction: () { ShowTipView().showSureAlertDialog( - "人脸实名认证指的是用户在使用手机APP开锁时,需要先进行本人人脸验证,验证通过才能开锁。".tr); + '人脸实名认证指的是用户在使用手机APP开锁时,需要先进行本人人脸验证,验证通过才能开锁。'.tr); }, isHaveRightWidget: true, rightWidget: SizedBox( @@ -289,7 +292,7 @@ class _AuthorizedAdminPageState extends State visible: logic.state.isRequireAuth.value, child: CommonItem( leftTitel: '真实姓名'.tr, - rightTitle: "", + rightTitle: '', isHaveRightWidget: true, isHaveLine: true, rightWidget: getTFWidget(false, '请输入真实姓名'.tr, 3)))), @@ -297,7 +300,7 @@ class _AuthorizedAdminPageState extends State visible: logic.state.isRequireAuth.value, child: CommonItem( leftTitel: '身份证号'.tr, - rightTitle: "", + rightTitle: '', isHaveRightWidget: true, rightWidget: getTFWidget(false, '请输入身份证号'.tr, 4)))), ], @@ -307,13 +310,13 @@ class _AuthorizedAdminPageState extends State // 发送电子钥匙成功 Widget sendElectronicKeySucceed() { return Column( - children: [ + children: [ Container( height: 250.h, width: 1.sw, color: Colors.white, child: Column( - children: [ + children: [ SizedBox( height: 30.h, ), @@ -327,9 +330,9 @@ class _AuthorizedAdminPageState extends State ), Row( mainAxisAlignment: MainAxisAlignment.center, - children: [ + children: [ Text( - "发送成功", + '发送成功', style: TextStyle( fontSize: 26.sp, color: Colors.black, @@ -354,9 +357,9 @@ class _AuthorizedAdminPageState extends State ), 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 { NativeInteractionTool() @@ -387,7 +390,7 @@ class _AuthorizedAdminPageState extends State height: 65.h, width: 300.w, child: Row( - children: [ + children: [ Expanded( child: TextField( //输入框一行 @@ -425,38 +428,37 @@ class _AuthorizedAdminPageState extends State 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(() { - state.contact = currentContact!; - 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!; - } - }); - }, - ), - ) - : 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(() { + state.contact = currentContact!; + 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() ], ), ); @@ -469,7 +471,7 @@ class _AuthorizedAdminPageState extends State trackColor: CupertinoColors.systemGrey5, thumbColor: CupertinoColors.white, value: state.isAuthentication.value, - onChanged: (value) { + onChanged: (bool value) { setState(() { if (logic.state.isAuthentication.value == false) { logic.keyCheckFace(); @@ -489,7 +491,7 @@ class _AuthorizedAdminPageState extends State trackColor: CupertinoColors.systemGrey5, thumbColor: CupertinoColors.white, value: state.onlyManageYouCreatesUser.value, - onChanged: (value) { + onChanged: (bool value) { setState(() { state.onlyManageYouCreatesUser.value = !state.onlyManageYouCreatesUser.value; @@ -498,7 +500,7 @@ class _AuthorizedAdminPageState extends State ); } - Future _openModalBottomSheet() async { + void _openModalBottomSheet() { showModalBottomSheet( context: context, shape: RoundedRectangleBorder( @@ -506,7 +508,7 @@ class _AuthorizedAdminPageState extends State constraints: BoxConstraints(maxHeight: 270.h), builder: (BuildContext context) { return Column( - children: [ + children: [ SizedBox( width: ScreenUtil().screenWidth, height: 180.h, @@ -537,7 +539,7 @@ class _AuthorizedAdminPageState extends State } List initBottomSheetList() { - List widgetList = []; + final List widgetList = []; widgetList.add(buildCenter3('images/icon_wechat.png', '微信好友', 0)); widgetList.add(buildCenter3('images/icon_message.png', '短信', 1)); @@ -557,7 +559,7 @@ class _AuthorizedAdminPageState extends State EdgeInsets.only(top: 20.w, bottom: 20.w, left: 10.w, right: 10.w), child: Column( mainAxisAlignment: MainAxisAlignment.center, - children: [ + children: [ Image.asset( imageName, width: 50.w, @@ -579,7 +581,7 @@ class _AuthorizedAdminPageState extends State } //\n生效时间:${itemData.startDate}\n类型:永久\n锁名:${itemData.keyboardPwdName} - _jumpSmartDeviceRoute(int itemIndex) { + dynamic _jumpSmartDeviceRoute(int itemIndex) { Get.back(); switch (itemIndex) { case 0: @@ -613,8 +615,8 @@ class _AuthorizedAdminPageState extends State TabBar _tabBar() { return TabBar( controller: state.tabController, - tabs: _itemTabs.map((ItemView item) => _tab(item)).toList(), - onTap: (index) { + tabs: _itemTabs.map(_tab).toList(), + onTap: (int index) { FocusScope.of(context).requestFocus(FocusNode()); }, isScrollable: true, @@ -655,14 +657,14 @@ class _AuthorizedAdminPageState extends State child: TabBarView( controller: state.tabController, children: _itemTabs - .map((ItemView item) => Obx(() => indexChangeWidget())) + .map((ItemView item) => Obx(indexChangeWidget)) .toList()), ); } final List _itemTabs = [ - ItemView(title: TranslationLoader.lanKeys!.timeLimit!.tr, type: "0"), - ItemView(title: TranslationLoader.lanKeys!.permanent!.tr, type: "1"), + ItemView(title: TranslationLoader.lanKeys!.timeLimit!.tr, type: '0'), + ItemView(title: TranslationLoader.lanKeys!.permanent!.tr, type: '1'), ]; } diff --git a/lib/main/lockDetail/authorizedAdmin/authorizedAdminList/authorizedAdminList_page.dart b/lib/main/lockDetail/authorizedAdmin/authorizedAdminList/authorizedAdminList_page.dart index 752a1115..1fa9edf5 100755 --- a/lib/main/lockDetail/authorizedAdmin/authorizedAdminList/authorizedAdminList_page.dart +++ b/lib/main/lockDetail/authorizedAdmin/authorizedAdminList/authorizedAdminList_page.dart @@ -4,6 +4,7 @@ import 'package:flutter_slidable/flutter_slidable.dart'; import 'package:get/get.dart'; import 'package:star_lock/common/XSConstantMacro/XSConstantMacro.dart'; import 'package:star_lock/main/lockDetail/authorizedAdmin/authorizedAdminList/authorizedAdminList_logic.dart'; +import 'package:star_lock/main/lockDetail/authorizedAdmin/authorizedAdminList/authorizedAdminList_state.dart'; import 'package:star_lock/main/lockDetail/electronicKey/electronicKeyList/entity/ElectronicKeyListEntity.dart'; import 'package:star_lock/tools/noData.dart'; import 'package:star_lock/tools/storage.dart'; @@ -25,8 +26,8 @@ class AuthorizedAdminListPage extends StatefulWidget { } class _AuthorizedAdminListPageState extends State { - final logic = Get.put(AuthorizedAdminListLogic()); - final state = Get.find().state; + final AuthorizedAdminListLogic logic = Get.put(AuthorizedAdminListLogic()); + final AuthorizedAdminListState state = Get.find().state; @override void initState() { @@ -37,7 +38,7 @@ class _AuthorizedAdminListPageState extends State { Future mockRequest() async { // 获取是否是演示模式 演示模式不获取接口 - var isDemoMode = await Storage.getBool(ifIsDemoModeOrNot); + final bool? isDemoMode = await Storage.getBool(ifIsDemoModeOrNot); if (isDemoMode == false) { logic.mockNetworkDataRequest().then((ElectronicKeyListEntity value) { setState(() {}); @@ -63,7 +64,7 @@ class _AuthorizedAdminListPageState extends State { mockRequest(); }, child: Column( - children: [ + children: [ Expanded(child: _buildMainUI()), SizedBox( height: 20.h, @@ -72,7 +73,7 @@ class _AuthorizedAdminListPageState extends State { btnName: TranslationLoader.lanKeys!.addAuthorizedAdmin!.tr, onClick: () { Navigator.pushNamed(context, Routers.authorizedAdminPage) - .then((val) { + .then((Object? val) { if (val != null) { logic.pageNo = 1; mockRequest(); @@ -89,14 +90,14 @@ class _AuthorizedAdminListPageState extends State { } Widget _buildMainUI() { - return Obx(() => state.itemDataList.value.isEmpty + return Obx(() => state.itemDataList.isEmpty ? NoData(noDataHeight: 1.sh - ScreenUtil().statusBarHeight - 90) : SlidableAutoCloseBehavior( child: ListView.separated( - itemCount: state.itemDataList.value.length, - itemBuilder: (c, index) { - ElectronicKeyListItem indexEntity = - state.itemDataList.value[index]; + itemCount: state.itemDataList.length, + itemBuilder: (BuildContext c, int index) { + final ElectronicKeyListItem indexEntity = + state.itemDataList[index]; String useDateStr = ''; //使用期限 String keyStatus = ''; //钥匙状态 @@ -116,16 +117,16 @@ class _AuthorizedAdminListPageState extends State { } return Slidable( - key: ValueKey(indexEntity.keyId), + key: ValueKey(indexEntity.keyId), endActionPane: ActionPane( extentRatio: 0.2, motion: const ScrollMotion(), - children: [ + children: [ SlidableAction( onPressed: (BuildContext context) { ShowTipView() .showDeleteAdministratorIsHaveAllDataDialog( - '同时删除其发送的所有钥匙,钥匙删除后不能恢复', (isAllData) { + '同时删除其发送的所有钥匙,钥匙删除后不能恢复', (bool isAllData) { logic.deleteKeyRequest(indexEntity.keyId.toString(), isAllData ? 1 : 0); }); @@ -145,9 +146,9 @@ class _AuthorizedAdminListPageState extends State { isAdminKey, () { Navigator.pushNamed( context, Routers.electronicKeyDetailPage, - arguments: { - "itemData": indexEntity, - }).then((val) { + arguments: { + 'itemData': indexEntity, + }).then((Object? val) { if (val != null) { logic.mockNetworkDataRequest(); setState(() {}); @@ -172,14 +173,14 @@ class _AuthorizedAdminListPageState extends State { if (indexEntity.keyType == XSConstantMacro.keyTypeTime) { //限期 - DateTime startDateStr = + final DateTime startDateStr = DateTime.fromMillisecondsSinceEpoch(indexEntity.startDate!); - DateTime endDateStr = + final DateTime endDateStr = DateTime.fromMillisecondsSinceEpoch(indexEntity.endDate!); useDateStr = '${startDateStr.toLocal().toString().substring(0, 16)}-${endDateStr.toLocal().toString().substring(0, 16)}'; } else if (indexEntity.keyType == XSConstantMacro.keyTypeLong) { - useDateStr = "永久"; + useDateStr = '永久'; } return useDateStr; } @@ -192,7 +193,7 @@ class _AuthorizedAdminListPageState extends State { color: Colors.white, height: 100.h, child: Row( - children: [ + children: [ SizedBox(width: 30.w), Image.asset( avatarURL, @@ -203,13 +204,13 @@ class _AuthorizedAdminListPageState extends State { Expanded( child: Column( mainAxisAlignment: MainAxisAlignment.center, - children: [ + children: [ Row( - children: [ + children: [ SizedBox( width: 1.sw - 110.w - 100.w, child: Row( - children: [ + children: [ Flexible( child: Text(receiveUser, maxLines: 1, @@ -231,7 +232,7 @@ class _AuthorizedAdminListPageState extends State { SizedBox(height: 10.h), Row( mainAxisAlignment: MainAxisAlignment.start, - children: [ + children: [ Text( useDate, style: TextStyle( diff --git a/lib/main/lockDetail/authorizedAdmin/volumeAuthorizationLock/notice_template_entity.dart b/lib/main/lockDetail/authorizedAdmin/volumeAuthorizationLock/notice_template_entity.dart new file mode 100644 index 00000000..e876778b --- /dev/null +++ b/lib/main/lockDetail/authorizedAdmin/volumeAuthorizationLock/notice_template_entity.dart @@ -0,0 +1,71 @@ +class NoticeTemplateEntity { + NoticeTemplateEntity( + {this.errorCode, this.description, this.errorMsg, this.data}); + + NoticeTemplateEntity.fromJson(Map json) { + errorCode = json['errorCode']; + description = json['description']; + errorMsg = json['errorMsg']; + if (json['data'] is Map) { + data = Data.fromJson(json['data']); + } + } + + int? errorCode; + String? description; + String? errorMsg; + Data? data; + + Map toJson() { + final Map data = {}; + data['errorCode'] = errorCode; + data['description'] = description; + data['errorMsg'] = errorMsg; + data['data'] = this.data; + return data; + } +} + +class Data { + Data.fromJson(Map json) { + if (json['list'] is List) { + json['list'].forEach((dynamic element) { + list?.add(Item.fromJson(element)); + }); + } + } + + List? list = []; + + Map toJson() { + final Map data = {}; + data['list'] = list; + return data; + } +} + +class Item { + Item.fromJson(Map json) { + type = json['type']; + name = json['name']; + template = json['template']; + isUse = json['isUse']; + fee = json['fee']; + } + + String? type; + String? name; + String? template; + int? isUse; + int? fee; + + Map toJson() { + final Map data = {}; + data['type'] = type; + data['name'] = name; + data['template'] = template; + data['isUse'] = isUse; + data['fee'] = fee; + return data; + } +} diff --git a/lib/main/lockDetail/authorizedAdmin/volumeAuthorizationLock/volumeAuthorizationLock_logic.dart b/lib/main/lockDetail/authorizedAdmin/volumeAuthorizationLock/volumeAuthorizationLock_logic.dart index 99472fb2..d75cd07c 100755 --- a/lib/main/lockDetail/authorizedAdmin/volumeAuthorizationLock/volumeAuthorizationLock_logic.dart +++ b/lib/main/lockDetail/authorizedAdmin/volumeAuthorizationLock/volumeAuthorizationLock_logic.dart @@ -2,19 +2,22 @@ import 'dart:ffi'; import 'package:flutter_easyloading/flutter_easyloading.dart'; import 'package:get/get.dart'; +import 'package:star_lock/main/lockDetail/authorizedAdmin/volumeAuthorizationLock/notice_template_entity.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/tools/commonDataManage.dart'; import 'volumeAuthorizationLock_state.dart'; class VolumeAuthorizationLockLogic extends BaseGetXController { - final state = VolumeAuthorizationLockState(); + final VolumeAuthorizationLockState state = VolumeAuthorizationLockState(); //发送批量授权管理员 Future addAuthorizedAdminRequest() async { String getFailureDateTime = '0'; String getEffectiveDateTime = '0'; - if (state.selectWidgetType == '1') { + if (state.selectWidgetType.value == '1') { getFailureDateTime = state.failureDateTime.value.millisecondsSinceEpoch.toString(); getEffectiveDateTime = @@ -25,11 +28,11 @@ class VolumeAuthorizationLockLogic extends BaseGetXController { showToast('请选择锁'.tr); return; } - var entity = await ApiRepository.to.addAuthorizedAdmin( + final KeyDetailEntity entity = await ApiRepository.to.addAuthorizedAdmin( createUser: state.isCreateUser.value ? '1' : '0', endDate: getFailureDateTime, isRemoteUnlock: '0', - keyGroupIdList: [], + keyGroupIdList: [], lockIdList: state.lockIdList.value, name: state.keyNameController.text, startDate: getEffectiveDateTime, @@ -49,4 +52,5 @@ class VolumeAuthorizationLockLogic extends BaseGetXController { } } } + } diff --git a/lib/main/lockDetail/authorizedAdmin/volumeAuthorizationLock/volumeAuthorizationLock_page.dart b/lib/main/lockDetail/authorizedAdmin/volumeAuthorizationLock/volumeAuthorizationLock_page.dart index 2aa60e45..cf0c27ed 100755 --- a/lib/main/lockDetail/authorizedAdmin/volumeAuthorizationLock/volumeAuthorizationLock_page.dart +++ b/lib/main/lockDetail/authorizedAdmin/volumeAuthorizationLock/volumeAuthorizationLock_page.dart @@ -181,7 +181,7 @@ class _VolumeAuthorizationLockPageState children: [ CommonItem( leftTitel: TranslationLoader.lanKeys!.lock!.tr, - rightTitle: state.lockIdList.value.isEmpty + rightTitle: state.lockIdList.isEmpty ? TranslationLoader.lanKeys!.pleaseSelect!.tr : state.lockIdList.length.toString(), isHaveDirection: true, @@ -190,11 +190,13 @@ class _VolumeAuthorizationLockPageState arguments: {'keyLimits': '1'}) .then((Object? value) { //得到选中的锁ID列表 - if (value != null) { - value as Map; - state.lockIdList.value = value['selectLockIdList']; - - // setState(() {}); + if (value is Map && + value['selectLockIdList'] is List) { + state.lockIdList.clear(); + value['selectLockIdList'].forEach((element) { + state.lockIdList.add(element); + }); + setState(() {}); } }); }), @@ -211,13 +213,6 @@ class _VolumeAuthorizationLockPageState 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), ], ); @@ -359,47 +354,10 @@ class _VolumeAuthorizationLockPageState state.isSendSuccess.value = 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() { - // 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( @@ -407,7 +365,7 @@ class _VolumeAuthorizationLockPageState trackColor: CupertinoColors.systemGrey5, thumbColor: CupertinoColors.white, value: state.onlyManageYouCreatesUser.value, - onChanged: (value) { + onChanged: (bool value) { setState(() { state.onlyManageYouCreatesUser.value = !state.onlyManageYouCreatesUser.value; diff --git a/lib/network/api.dart b/lib/network/api.dart index 81e7c5c7..17bcdc88 100755 --- a/lib/network/api.dart +++ b/lib/network/api.dart @@ -236,4 +236,6 @@ abstract class Api { final String deleteLockCloudStorageURL = '/lockCloudStorage/delete'; //删除云存 final String getUserNoList = '/key/getUserNoList'; //获取指定锁下所有userNo + + final String getNoticeTemplateURL = '/key/getNoticeTemplate'; //获取短信或者邮箱模板 } diff --git a/lib/network/api_provider.dart b/lib/network/api_provider.dart index 2f15be18..5fd77904 100755 --- a/lib/network/api_provider.dart +++ b/lib/network/api_provider.dart @@ -2085,6 +2085,17 @@ class ApiProvider extends BaseProvider { // 获取指定锁下所有userNo Future getLockUserNoList(int lockId) => post(getUserNoList.toUrl, jsonEncode({'lockId': lockId})); + + // 获取短信或者邮箱模板 + Future> getNoticeTemplate( + int lockId, int keyId, int channelType) => + post( + getNoticeTemplateURL.toUrl, + jsonEncode({ + 'lockId': lockId, + 'keyId': keyId, + 'channelType': channelType, + })); } extension ExtensionString on String { diff --git a/lib/network/api_repository.dart b/lib/network/api_repository.dart index 72bf24f1..db2c6619 100755 --- a/lib/network/api_repository.dart +++ b/lib/network/api_repository.dart @@ -1,6 +1,7 @@ import 'package:get/get.dart'; import 'package:star_lock/blue/entity/lock_user_no_list_entity.dart'; import 'package:star_lock/login/selectCountryRegion/common/countryRegionEntity.dart'; +import 'package:star_lock/main/lockDetail/authorizedAdmin/volumeAuthorizationLock/notice_template_entity.dart'; import 'package:star_lock/main/lockDetail/doorLockLog/doorLockLog_entity.dart'; import 'package:star_lock/main/lockDetail/electronicKey/electronicKeyList/entity/ElectronicKeyListEntity.dart'; import 'package:star_lock/main/lockDetail/electronicKey/massSendElectronicKey/massSendLockGroupList/lockUserList/lockUserList_entity.dart'; @@ -2119,4 +2120,15 @@ class ApiRepository { final res = await apiProvider.getLockUserNoList(lockId); return LockUserNoListEntity.fromJson(res.body); } + + // 电子钥匙获取短信模板 + Future getNoticeTemplate({ + required int lockId, + required int keyId, + required int channelType, + }) async { + final Response res = + await apiProvider.getNoticeTemplate(lockId, keyId, channelType); + return NoticeTemplateEntity.fromJson(res.body); + } } diff --git a/lib/network/response_interceptor_log.dart b/lib/network/response_interceptor_log.dart index f24553c4..85890536 100755 --- a/lib/network/response_interceptor_log.dart +++ b/lib/network/response_interceptor_log.dart @@ -5,7 +5,7 @@ import 'package:get/get_connect/http/src/request/request.dart'; import 'package:star_lock/app_settings/app_settings.dart'; FutureOr responseLogInterceptor(Request request, Response response) { - // AppLog.log('HTTP request:${request.url}\n RESPONSE => stataCode:${response.statusCode} ${response.bodyString}'); // \n ${response.headers} + AppLog.log('HTTP request:${request.url}\n RESPONSE => stataCode:${response.statusCode} ${response.bodyString}'); // \n ${response.headers} EasyLoading.dismiss(animation: true); return response; } diff --git a/pubspec.yaml b/pubspec.yaml index efb41595..dfc6975b 100755 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -55,8 +55,9 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev # 1.0.45+2024052003:打包给公司测试 # 1.0.46+2024052004:打包给公司测试 # 1.0.47+2024052101:打包给欧阳回归测试 +# 1.0.48+2024052201:打包给欧阳回归测试 -version: 1.0.47+2024052101 +version: 1.0.48+2024052201 environment: sdk: '>=2.12.0 <3.0.0'