diff --git a/star_lock/images/lan/lan_en.json b/star_lock/images/lan/lan_en.json index 24497a72..6b0d0e08 100644 --- a/star_lock/images/lan/lan_en.json +++ b/star_lock/images/lan/lan_en.json @@ -766,7 +766,8 @@ "亮屏持续时间":"Screen on time", "逗留警告":"Stay warning", "异常警告":"Abnormal warning", - + "短信提醒":"SMS reminder", + "邮件提醒":"Email reminder", "关锁":"关锁", "功能":"功能", "配件":"配件" diff --git a/star_lock/images/lan/lan_keys.json b/star_lock/images/lan/lan_keys.json index 9cde7ffe..6e2cb604 100644 --- a/star_lock/images/lan/lan_keys.json +++ b/star_lock/images/lan/lan_keys.json @@ -765,6 +765,8 @@ "亮屏持续时间":"亮屏持续时间", "逗留警告":"逗留警告", "异常警告":"异常警告", + "短信提醒":"短信提醒", + "邮件提醒":"邮件提醒", "关锁":"Close Lock", "功能":"Function", "配件":"Parts" diff --git a/star_lock/images/lan/lan_zh.json b/star_lock/images/lan/lan_zh.json index bc29a5f5..f2c861e7 100644 --- a/star_lock/images/lan/lan_zh.json +++ b/star_lock/images/lan/lan_zh.json @@ -768,6 +768,8 @@ "亮屏持续时间":"亮屏持续时间", "逗留警告":"逗留警告", "异常警告":"异常警告", + "短信提醒":"短信提醒", + "邮件提醒":"邮件提醒", "关锁":"关锁", "功能":"功能", "配件":"配件" diff --git a/star_lock/lib/main/lockDetail/messageWarn/addFamily/addFamily_logic.dart b/star_lock/lib/main/lockDetail/messageWarn/addFamily/addFamily_logic.dart index 897a42e0..bab8a869 100644 --- a/star_lock/lib/main/lockDetail/messageWarn/addFamily/addFamily_logic.dart +++ b/star_lock/lib/main/lockDetail/messageWarn/addFamily/addFamily_logic.dart @@ -1,6 +1,91 @@ +import 'package:get/get.dart'; import 'package:star_lock/main/lockDetail/messageWarn/addFamily/addFamily_state.dart'; +import 'package:star_lock/main/lockDetail/messageWarn/notificationMode/notificationMode_data.dart'; +import 'package:star_lock/network/api_repository.dart'; import 'package:star_lock/tools/baseGetXController.dart'; class AddFamilyLogic extends BaseGetXController { final AddFamilyState state = AddFamilyState(); + + void addLockNoticeSetting() async { + var entity = await ApiRepository.to.addLockNoticeSetting( + lockId: state.getLockId.value, + noticeType: 10, + settingValue: { + 'openDoorId': state.lockUserKeys.value.currentOpenDoorID, + 'openDoorType': state.lockUserKeys.value.currentKeyType, + 'remark': state.lockUserKeys.value.currentKeyName ?? '', + 'noticeWay': [ + {'type': 'mail', 'accounts': getEmailAndSMSAccountList(true)}, + {'type': 'sms', 'accounts': getEmailAndSMSAccountList(false)} + ] + }, + ); + if (entity.errorCode!.codeIsSuccessful) { + showToast('添加成功'.tr); + Get.back(result: true); + } + } + + List getEmailAndSMSAccountList(bool isEmail) { + List list = []; + List accountList = []; + isEmail + ? accountList = state.emailReceiverList.value + : accountList = state.phoneReceiverList.value; + for (int i = 0; i < accountList.length; i++) { + MsgNoticeModeData item = accountList[i]; + Map map = {}; + map['countryCode'] = isEmail ? 0 : item.countryCode; + map['account'] = isEmail ? item.receiveEmail : item.receivePhone; + list.add(map); + } + return list; + } + + String getEmailListStr(Map val) { + String emailListStr = ''; + if (val['emailReceiverList'] != null) { + state.emailReceiverList.value = val['emailReceiverList']; + List emailReceiverList = state.emailReceiverList.value; + for (int i = 0; i < emailReceiverList.length; i++) { + MsgNoticeModeData item = emailReceiverList[i]; + emailListStr += item.receiveEmail; + // 检查是否为最后一个元素 + if (i < emailReceiverList.length - 1) { + emailListStr += ','; + } + } + } + return emailListStr; + } + + String getPhoneListStr(Map val) { + String phoneListStr = ''; + + if (val['phoneReceiverList'] != null) { + state.phoneReceiverList.value = val['phoneReceiverList']; + List phoneReceiverList = state.phoneReceiverList.value; + for (int i = 0; i < phoneReceiverList.length; i++) { + MsgNoticeModeData item = phoneReceiverList[i]; + phoneListStr += item.receivePhone; + // 检查是否为最后一个元素 + if (i < phoneReceiverList.length - 1) { + phoneListStr += ','; + } + } + } + return phoneListStr; + } + + bool checkBtnDisable() { + if ((state.emailListStr.value.isEmpty || + state.phontListStr.value.isEmpty) || + state.lockUserKeys.value.currentKeyTypeStr!.isEmpty || + state.lockUserKeys.value.currentKeyName!.isEmpty) { + return false; + } else { + return true; + } + } } diff --git a/star_lock/lib/main/lockDetail/messageWarn/addFamily/addFamily_page.dart b/star_lock/lib/main/lockDetail/messageWarn/addFamily/addFamily_page.dart index 87421f30..e10c50d6 100644 --- a/star_lock/lib/main/lockDetail/messageWarn/addFamily/addFamily_page.dart +++ b/star_lock/lib/main/lockDetail/messageWarn/addFamily/addFamily_page.dart @@ -74,22 +74,23 @@ class _AddFamilyPageState extends State { isHaveRightWidget: false, isHaveDirection: true, action: () { - Get.toNamed(Routers.notificationModePage); + Get.toNamed(Routers.notificationModePage)?.then((val) { + if (val != null) { + state.emailListStr.value = logic.getEmailListStr(val); + state.phontListStr.value = logic.getPhoneListStr(val); + print( + 'emailListStr:${state.emailListStr.value},phontListStr:${state.phontListStr.value}'); + } + }); }, ), - Container( - padding: EdgeInsets.only( - left: 10.w, right: 10.w, top: 12.h, bottom: 12.h), - margin: EdgeInsets.only(bottom: 20.h, top: 10.h), - decoration: BoxDecoration( - color: AppColors.mainBackgroundColor, - borderRadius: BorderRadius.circular(6.0.w), - ), - child: Text( - '${'APP推送'.tr} ${'管理员'.tr}', - style: TextStyle(color: Colors.black, fontSize: 20.sp), - ), - ) + _buildNotifyContain('APP推送'.tr, '管理员'.tr), + Obx(() => state.emailListStr.value.isNotEmpty + ? _buildNotifyContain('邮件提醒'.tr, state.emailListStr.value) + : Container()), + Obx(() => state.phontListStr.value.isNotEmpty + ? _buildNotifyContain('短信提醒'.tr, state.phontListStr.value) + : Container()), ], ), ), @@ -97,11 +98,13 @@ class _AddFamilyPageState extends State { child: SizedBox( height: 40.h, )), - SubmitBtn( - btnName: '保存'.tr, - isDisabled: false, - onClick: () {}, - ), + Obx(() => SubmitBtn( + btnName: '保存'.tr, + isDisabled: logic.checkBtnDisable(), + onClick: () { + logic.addLockNoticeSetting(); + }, + )), SizedBox( height: 60.h, ) @@ -111,6 +114,34 @@ class _AddFamilyPageState extends State { ); } + Widget _buildNotifyContain(String notifyTitle, String notifyContent) { + return Container( + padding: + EdgeInsets.only(left: 10.w, right: 10.w, top: 12.h, bottom: 12.h), + margin: EdgeInsets.only(bottom: 20.h, top: 10.h, left: 20.w, right: 20.w), + decoration: BoxDecoration( + color: AppColors.mainBackgroundColor, + borderRadius: BorderRadius.circular(6.0.w), + ), + child: Row( + children: [ + Text( + notifyTitle, + style: TextStyle(color: Colors.black, fontSize: 20.sp), + ), + Expanded( + child: SizedBox( + width: 20.w, + )), + Text(notifyContent, + textAlign: TextAlign.end, + style: TextStyle( + color: AppColors.placeholderTextColor, fontSize: 20.sp)), + ], + ), + ); + } + // 接受者邮箱输入框 Widget getFamilyWidget(String tfStr) { TextEditingController emailController = TextEditingController(); diff --git a/star_lock/lib/main/lockDetail/messageWarn/addFamily/addFamily_state.dart b/star_lock/lib/main/lockDetail/messageWarn/addFamily/addFamily_state.dart index ca1643c7..355b2e0c 100644 --- a/star_lock/lib/main/lockDetail/messageWarn/addFamily/addFamily_state.dart +++ b/star_lock/lib/main/lockDetail/messageWarn/addFamily/addFamily_state.dart @@ -4,6 +4,13 @@ import 'package:star_lock/main/lockDetail/messageWarn/lockUser/lockUser_entity.d class AddFamilyState { var getLockId = 0.obs; var lockUserKeys = LockUserListKeys().obs; + var emailReceiverList = [].obs; + var phoneReceiverList = [].obs; + var emailListStr = ''.obs; + var phontListStr = ''.obs; + + var openDoorId = 0.obs; + var openDoorType = 0.obs; AddFamilyState() { Map map = Get.arguments; diff --git a/star_lock/lib/main/lockDetail/messageWarn/familyDetails/familyDetails_page.dart b/star_lock/lib/main/lockDetail/messageWarn/familyDetails/familyDetails_page.dart index 4f5801b3..7d237ae6 100644 --- a/star_lock/lib/main/lockDetail/messageWarn/familyDetails/familyDetails_page.dart +++ b/star_lock/lib/main/lockDetail/messageWarn/familyDetails/familyDetails_page.dart @@ -64,7 +64,7 @@ class _FamilyDetailsPageState extends State { child: Column( children: [ CommonItem( - leftTitel: '提醒方式', + leftTitel: '提醒方式'.tr, rightTitle: "", isHaveLine: false, isHaveRightWidget: false, diff --git a/star_lock/lib/main/lockDetail/messageWarn/lockUser/lockUser_entity.dart b/star_lock/lib/main/lockDetail/messageWarn/lockUser/lockUser_entity.dart index df4d38b0..39f29f61 100644 --- a/star_lock/lib/main/lockDetail/messageWarn/lockUser/lockUser_entity.dart +++ b/star_lock/lib/main/lockDetail/messageWarn/lockUser/lockUser_entity.dart @@ -60,7 +60,7 @@ class LockUserData { } class LockUserListKeys { - // int? id; + int? id; String? clientId; int? lockOwnerId; int? apiUserId; @@ -116,10 +116,10 @@ class LockUserListKeys { String? currentKeyName; //当前钥匙名称 bool? isCurrentSelect; //当前是否选中 int? currentDateType; //钥匙日期类型 1:永久 2:限期 3:单次 4:循环 + int? currentOpenDoorID; //当前开门ID LockUserListKeys( - { - // this.id, + {this.id, this.clientId, this.lockOwnerId, this.apiUserId, @@ -176,7 +176,9 @@ class LockUserListKeys { this.currentDateType}); LockUserListKeys.fromJson(Map json) { - // id = json['id']; + if (json['id'] != null) { + id = json['id']; + } clientId = json['clientId']; lockOwnerId = json['lockOwnerId']; apiUserId = json['apiUserId']; @@ -243,7 +245,9 @@ class LockUserListKeys { Map toJson() { final Map data = {}; - // data['id'] = id; + if (id != null) { + data['id'] = id; + } data['clientId'] = clientId; data['lockOwnerId'] = lockOwnerId; data['apiUserId'] = apiUserId; diff --git a/star_lock/lib/main/lockDetail/messageWarn/lockUser/lockUser_logic.dart b/star_lock/lib/main/lockDetail/messageWarn/lockUser/lockUser_logic.dart index 64039133..94590d17 100644 --- a/star_lock/lib/main/lockDetail/messageWarn/lockUser/lockUser_logic.dart +++ b/star_lock/lib/main/lockDetail/messageWarn/lockUser/lockUser_logic.dart @@ -24,6 +24,7 @@ class LockUserLogic extends BaseGetXController { element.currentKeyName = element.keyName; element.isCurrentSelect = false; element.currentDateType = element.keyType; + element.currentOpenDoorID = element.id; }); LockUserData data2 = entity.data![1]; data2.lockUserList?.forEach((element) { @@ -33,6 +34,7 @@ class LockUserLogic extends BaseGetXController { element.currentKeyName = element.keyboardPwdName; element.isCurrentSelect = false; element.currentDateType = element.keyboardPwdType; + element.currentOpenDoorID = element.keyboardPwdId; }); LockUserData data3 = entity.data![2]; data3.lockUserList?.forEach((element) { diff --git a/star_lock/lib/main/lockDetail/messageWarn/msgNotification/coerceOpenDoor/coerceFingerprint/coerceFingerprint_page.dart b/star_lock/lib/main/lockDetail/messageWarn/msgNotification/coerceOpenDoor/coerceFingerprint/coerceFingerprint_page.dart index a14e83b0..cbdb6227 100644 --- a/star_lock/lib/main/lockDetail/messageWarn/msgNotification/coerceOpenDoor/coerceFingerprint/coerceFingerprint_page.dart +++ b/star_lock/lib/main/lockDetail/messageWarn/msgNotification/coerceOpenDoor/coerceFingerprint/coerceFingerprint_page.dart @@ -46,7 +46,7 @@ class _CoerceFingerprintPageState extends State { child: Column( children: [ CommonItem( - leftTitel: '提醒方式', + leftTitel: '提醒方式'.tr, rightTitle: "", isHaveLine: false, isHaveRightWidget: false, diff --git a/star_lock/lib/main/lockDetail/messageWarn/msgNotification/nDaysUnopened/nDaysUnopened_page.dart b/star_lock/lib/main/lockDetail/messageWarn/msgNotification/nDaysUnopened/nDaysUnopened_page.dart index ea0b3aea..50504d6d 100644 --- a/star_lock/lib/main/lockDetail/messageWarn/msgNotification/nDaysUnopened/nDaysUnopened_page.dart +++ b/star_lock/lib/main/lockDetail/messageWarn/msgNotification/nDaysUnopened/nDaysUnopened_page.dart @@ -83,7 +83,7 @@ class _NDaysUnopenedPageState extends State { child: Column( children: [ CommonItem( - leftTitel: '提醒方式', + leftTitel: '提醒方式'.tr, rightTitle: "", isHaveLine: false, isHaveRightWidget: false, diff --git a/star_lock/lib/main/lockDetail/messageWarn/msgNotification/openDoorNotify/openDoorNotify_entity.dart b/star_lock/lib/main/lockDetail/messageWarn/msgNotification/openDoorNotify/openDoorNotify_entity.dart new file mode 100644 index 00000000..0db28a37 --- /dev/null +++ b/star_lock/lib/main/lockDetail/messageWarn/msgNotification/openDoorNotify/openDoorNotify_entity.dart @@ -0,0 +1,178 @@ +class OpenDoorNotifyEntity { + int? errorCode; + String? description; + String? errorMsg; + Data? data; + + OpenDoorNotifyEntity( + {this.errorCode, this.description, this.errorMsg, this.data}); + + OpenDoorNotifyEntity.fromJson(Map json) { + errorCode = json['errorCode']; + description = json['description']; + errorMsg = json['errorMsg']; + data = json['data'] != null ? Data.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 Data { + List? list; + int? total; + int? pageNo; + int? pageSize; + + Data({this.list, this.total, this.pageNo, this.pageSize}); + + Data.fromJson(Map json) { + if (json['list'] != null) { + list = []; + json['list'].forEach((v) { + list!.add(DataList.fromJson(v)); + }); + } + total = json['total']; + pageNo = json['pageNo']; + pageSize = json['pageSize']; + } + + Map toJson() { + final Map data = {}; + if (list != null) { + data['list'] = list!.map((v) => v.toJson()).toList(); + } + data['total'] = total; + data['pageNo'] = pageNo; + data['pageSize'] = pageSize; + return data; + } +} + +class DataList { + int? id; + int? lockId; + int? noticeType; + SettingValue? settingValue; + String? createdAt; + String? updatedAt; + + DataList( + {this.id, + this.lockId, + this.noticeType, + this.settingValue, + this.createdAt, + this.updatedAt}); + + DataList.fromJson(Map json) { + id = json['id']; + lockId = json['lockId']; + noticeType = json['noticeType']; + settingValue = json['settingValue'] != null + ? SettingValue.fromJson(json['settingValue']) + : null; + createdAt = json['created_at']; + updatedAt = json['updated_at']; + } + + Map toJson() { + final Map data = {}; + data['id'] = id; + data['lockId'] = lockId; + data['noticeType'] = noticeType; + if (settingValue != null) { + data['settingValue'] = settingValue!.toJson(); + } + data['created_at'] = createdAt; + data['updated_at'] = updatedAt; + return data; + } +} + +class SettingValue { + int? openDoorId; + int? openDoorType; + String? remark; + List? noticeWay; + + SettingValue( + {this.openDoorId, this.openDoorType, this.remark, this.noticeWay}); + + SettingValue.fromJson(Map json) { + openDoorId = json['openDoorId']; + openDoorType = json['openDoorType']; + remark = json['remark']; + if (json['noticeWay'] != null) { + noticeWay = []; + json['noticeWay'].forEach((v) { + noticeWay!.add(NoticeWay.fromJson(v)); + }); + } + } + + Map toJson() { + final Map data = {}; + data['openDoorId'] = openDoorId; + data['openDoorType'] = openDoorType; + data['remark'] = remark; + if (noticeWay != null) { + data['noticeWay'] = noticeWay!.map((v) => v.toJson()).toList(); + } + return data; + } +} + +class NoticeWay { + String? type; + List? accounts; + + NoticeWay({this.type, this.accounts}); + + NoticeWay.fromJson(Map json) { + type = json['type']; + if (json['accounts'] != null) { + accounts = []; + json['accounts'].forEach((v) { + accounts!.add(Accounts.fromJson(v)); + }); + } + } + + Map toJson() { + final Map data = {}; + data['type'] = type; + if (accounts != null) { + data['accounts'] = accounts!.map((v) => v.toJson()).toList(); + } + return data; + } +} + +class Accounts { + int? countryCode; + String? account; + + Accounts({this.countryCode, this.account}); + + Accounts.fromJson(Map json) { + countryCode = json['countryCode']; + account = json['account']; + } + + Map toJson() { + final Map data = {}; + data['countryCode'] = countryCode; + data['account'] = account; + return data; + } +} diff --git a/star_lock/lib/main/lockDetail/messageWarn/msgNotification/openDoorNotify/openDoorNotify_logic.dart b/star_lock/lib/main/lockDetail/messageWarn/msgNotification/openDoorNotify/openDoorNotify_logic.dart index 1e669078..8988a109 100644 --- a/star_lock/lib/main/lockDetail/messageWarn/msgNotification/openDoorNotify/openDoorNotify_logic.dart +++ b/star_lock/lib/main/lockDetail/messageWarn/msgNotification/openDoorNotify/openDoorNotify_logic.dart @@ -1,6 +1,19 @@ +import 'package:star_lock/main/lockDetail/messageWarn/msgNotification/openDoorNotify/openDoorNotify_entity.dart'; +import 'package:star_lock/network/api_repository.dart'; import 'package:star_lock/tools/baseGetXController.dart'; import 'openDoorNotify_state.dart'; class OpenDoorNotifyLogic extends BaseGetXController { final OpenDoorNotifyState state = OpenDoorNotifyState(); + + void lockNoticeSettingAccountList() async { + OpenDoorNotifyEntity entity = + await ApiRepository.to.lockNoticeSettingAccountList( + lockId: state.getLockId.value, + noticeType: 10, + ); + if (entity.errorCode!.codeIsSuccessful) { + state.openDoorNotifyList.value = entity.data!.list!; + } + } } diff --git a/star_lock/lib/main/lockDetail/messageWarn/msgNotification/openDoorNotify/openDoorNotify_page.dart b/star_lock/lib/main/lockDetail/messageWarn/msgNotification/openDoorNotify/openDoorNotify_page.dart index b59ffcca..b800ac59 100644 --- a/star_lock/lib/main/lockDetail/messageWarn/msgNotification/openDoorNotify/openDoorNotify_page.dart +++ b/star_lock/lib/main/lockDetail/messageWarn/msgNotification/openDoorNotify/openDoorNotify_page.dart @@ -22,6 +22,8 @@ class _OpenDoorNotifyPageState extends State { @override void initState() { super.initState(); + + logic.lockNoticeSettingAccountList(); } @override @@ -39,12 +41,17 @@ class _OpenDoorNotifyPageState extends State { SizedBox( height: 20.h, ), - Expanded(child: _buildMainUI()), + Expanded(child: Obx(() => _buildMainUI())), AddBottomWhiteBtn( btnName: '添加家人'.tr, onClick: () { Get.toNamed(Routers.addFamilyPage, - arguments: {'getLockId': state.getLockId.value}); + arguments: {'getLockId': state.getLockId.value}) + ?.then((value) { + if (value != null) { + logic.lockNoticeSettingAccountList(); + } + }); }, ), SizedBox( @@ -67,7 +74,7 @@ class _OpenDoorNotifyPageState extends State { Widget _buildMainUI() { return ListView.separated( shrinkWrap: true, - itemCount: state.msgNoticeInfo.value.openDoorNoticeList?.length ?? 0, + itemCount: state.openDoorNotifyList.length, itemBuilder: (c, index) { return _electronicKeyItem( 'images/controls_user.png', '18682150237', '电子钥匙', () { diff --git a/star_lock/lib/main/lockDetail/messageWarn/msgNotification/openDoorNotify/openDoorNotify_state.dart b/star_lock/lib/main/lockDetail/messageWarn/msgNotification/openDoorNotify/openDoorNotify_state.dart index fb749d19..f20aec5c 100644 --- a/star_lock/lib/main/lockDetail/messageWarn/msgNotification/openDoorNotify/openDoorNotify_state.dart +++ b/star_lock/lib/main/lockDetail/messageWarn/msgNotification/openDoorNotify/openDoorNotify_state.dart @@ -7,6 +7,7 @@ class OpenDoorNotifyState { final pageSize = 20.obs; //请求每页数据条数 var itemDataList = [].obs; var getLockId = 0.obs; + var openDoorNotifyList = [].obs; OpenDoorNotifyState() { Map map = Get.arguments; diff --git a/star_lock/lib/main/lockDetail/messageWarn/notificationMode/notificationMode_data.dart b/star_lock/lib/main/lockDetail/messageWarn/notificationMode/notificationMode_data.dart new file mode 100644 index 00000000..a6b945b2 --- /dev/null +++ b/star_lock/lib/main/lockDetail/messageWarn/notificationMode/notificationMode_data.dart @@ -0,0 +1,8 @@ +import 'package:flutter/material.dart'; + +class MsgNoticeModeData { + final TextEditingController receiverTF = TextEditingController(); + var receiveEmail = ''; + var receivePhone = ''; + var countryCode = 86; +} diff --git a/star_lock/lib/main/lockDetail/messageWarn/notificationMode/notificationMode_page.dart b/star_lock/lib/main/lockDetail/messageWarn/notificationMode/notificationMode_page.dart index bf76d011..d5653eb2 100644 --- a/star_lock/lib/main/lockDetail/messageWarn/notificationMode/notificationMode_page.dart +++ b/star_lock/lib/main/lockDetail/messageWarn/notificationMode/notificationMode_page.dart @@ -1,7 +1,10 @@ import 'package:flutter/material.dart'; +import 'package:flutter/services.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:get/get.dart'; import 'package:star_lock/appRouters.dart'; +import 'package:star_lock/main/lockDetail/messageWarn/msgNotification/msgNotification/msgNotification_entity.dart'; +import 'package:star_lock/main/lockDetail/messageWarn/notificationMode/notificationMode_data.dart'; import 'package:star_lock/main/lockDetail/messageWarn/notificationMode/notificationMode_logic.dart'; import 'package:star_lock/tools/commonItem.dart'; import 'package:star_lock/tools/submitBtn.dart'; @@ -31,11 +34,11 @@ class _NotificationModePageState extends State { return Scaffold( backgroundColor: AppColors.mainBackgroundColor, appBar: TitleAppBar( - barTitle: '提醒方式', + barTitle: '提醒方式'.tr, haveBack: true, backgroundColor: AppColors.mainColor), body: SingleChildScrollView( - child: _buildMainView(), + child: Obx(() => _buildMainView()), )); } @@ -43,297 +46,218 @@ class _NotificationModePageState extends State { return Column( children: [ CommonItem( - leftTitel: 'APP推送', - rightTitle: '管理员', + leftTitel: 'APP推送'.tr, + rightTitle: '管理员'.tr, isHaveLine: true, isHaveDirection: false, action: () {}), SizedBox( height: 10.h, ), - CommonItem( - leftTitel: '邮件提醒', - rightTitle: '', - isHaveLine: true, - isHaveDirection: false, - isHaveRightWidget: true, - rightWidget: state.emailReceiverList.value.length < 3 - ? Image.asset( - 'images/icon_btn_add.png', - width: 32.w, - height: 32.w, - ) - : Container(), - action: () { - if (state.emailReceiverList.value.length < 3) { - setState(() { - state.emailReceiverList.value.add(1); - }); - } - }), - Obx(() => SizedBox( - height: state.emailReceiverList.value.length * 62.h, - child: ListView.separated( - itemCount: state.emailReceiverList.value.length, - itemBuilder: (BuildContext context, int index) { - return _buildReceiverItem(index, true); - }, - separatorBuilder: (BuildContext context, int index) { - return Divider( - height: 1.h, - color: AppColors.greyBackgroundColor, - ); - }, - ), - )), + _buildNotifyWayItem('邮件提醒'.tr, isEmail: true), + _buildListView(isEmail: true), SizedBox( height: 10.h, ), - CommonItem( - leftTitel: '短信提醒', - rightTitle: '', - isHaveLine: true, - isHaveDirection: false, - isHaveRightWidget: true, - rightWidget: state.phoneReceiverList.value.length < 3 - ? Image.asset( - 'images/icon_btn_add.png', - width: 32.w, - height: 32.w, - ) - : Container(), - action: () { - if (state.phoneReceiverList.value.length < 3) { - setState(() { - state.phoneReceiverList.value.add(1); - }); - } - }), - SizedBox( - height: state.phoneReceiverList.value.length * 62.h, - child: ListView.separated( - itemCount: state.phoneReceiverList.value.length, - itemBuilder: (BuildContext context, int index) { - return _buildReceiverItem(index, false); - }, - separatorBuilder: (BuildContext context, int index) { - return Divider( - height: 1.h, - color: AppColors.greyBackgroundColor, - ); - }, - ), - ), + _buildNotifyWayItem('短信提醒'.tr, isEmail: false), + _buildListView(isEmail: false), SizedBox( height: 60.h, ), SubmitBtn( btnName: '确定'.tr, - onClick: () {}, + onClick: () { + Get.back(result: { + 'emailReceiverList': state.emailReceiverList.value, + 'phoneReceiverList': state.phoneReceiverList.value + }); + }, ) ], ); } - Widget _buildReceiverItem(int index, bool isEmail) { + Widget _buildNotifyWayItem(String title, {required bool isEmail}) { + return CommonItem( + leftTitel: title, + rightTitle: '', + isHaveLine: true, + isHaveDirection: false, + isHaveRightWidget: true, + rightWidget: (!isEmail + ? state.phoneReceiverList.value.length < 3 + : state.emailReceiverList.value.length < 3) + ? Image.asset( + 'images/icon_btn_add.png', + width: 32.w, + height: 32.w, + ) + : Container(), + action: () { + if (isEmail) { + if (state.emailReceiverList.value.length < 3) { + state.emailReceiverList.value.add(MsgNoticeModeData()); + } + state.emailReceiverList.refresh(); + } else { + if (state.phoneReceiverList.value.length < 3) { + state.phoneReceiverList.value.add(MsgNoticeModeData()); + } + state.phoneReceiverList.refresh(); + } + }); + } + + Widget _buildListView({required bool isEmail}) { + return SizedBox( + height: isEmail + ? state.emailReceiverList.value.length * 62.h + : state.phoneReceiverList.value.length * 62.h, + child: ListView.separated( + itemCount: isEmail + ? state.emailReceiverList.value.length + : state.phoneReceiverList.value.length, + itemBuilder: (BuildContext context, int index) { + return _buildReceiverItemWidget(index, isEmail: isEmail); + }, + separatorBuilder: (BuildContext context, int index) { + return Divider( + height: 1.h, + color: AppColors.greyBackgroundColor, + ); + }, + ), + ); + } + + Widget _buildReceiverItemWidget(int index, {required bool isEmail}) { return Container( + padding: EdgeInsets.only(left: 20.w, right: 20.w), + height: 62.h, color: Colors.white, child: Row( children: [ GestureDetector( - child: SizedBox( - // width: 40.w, - child: Row( - children: [ - SizedBox( - width: 20.w, - ), - Image.asset( - 'images/icon_massSend_delete.png', - width: 26.w, - height: 26.w, - ) - ], - ), - ), - onTap: () { - setState(() { - if (isEmail) { - state.emailReceiverList.value.removeAt(index); - } else { - state.phoneReceiverList.value.removeAt(index); - } - }); - }, - ), - Expanded( - child: Column( - children: [ - massSendReceiverCellWidget( - leftTitel: TranslationLoader.lanKeys!.receiver!.tr, - rightTitle: state.inputEmailStr.value, - isHaveLine: true, - isHaveRightWidget: true, - rightWidget: isEmail - ? getEmailTFWidget('请输入Email'.tr, 1) - : getPhoneWidget('请输入手机号'.tr, 1)), - Divider( - color: AppColors.greyLineColor, - indent: 20.w, - endIndent: 20.w, - height: 1, - ), - ], - )) - ], - ), - ); - } - - // TextEditingController _receiverController(String getStr) { - // TextEditingController controller = TextEditingController(text: getStr); - // controller.addListener(() { - // state.inputEmailStr.value = controller.text; - // print(controller.text); - // }); - - // return controller; - // } - - // 接受者邮箱输入框 - Widget getEmailTFWidget(String tfStr, int lineIndex) { - TextEditingController emailController = TextEditingController(); - return SizedBox( - height: 50.h, - width: 360.w, - child: Row( - children: [ - Expanded( - child: TextField( - controller: emailController, - //输入框一行 - maxLines: 1, - autofocus: false, - textAlign: TextAlign.end, - decoration: InputDecoration( - hintText: tfStr, - hintStyle: TextStyle(fontSize: 22.sp), - //不需要输入框下划线 - border: InputBorder.none, - ), - ), - ), - ], - ), - ); - } - - // 接受者手机号输入框 - Widget getPhoneWidget(String tfStr, int lineIndex) { - TextEditingController phoneController = TextEditingController(); - - return SizedBox( - height: 50.h, - width: 360.w, - child: Row( - children: [ - Expanded( - child: GestureDetector( - child: Container( - width: 90.w, - color: Colors.white, - child: Row( - mainAxisAlignment: MainAxisAlignment.end, - children: [ - Obx(() => Text( - '+${state.countryCode}', - style: TextStyle( - color: AppColors.darkGrayTextColor, - fontSize: 20.sp), - )), - Image.asset( - 'images/icon_grayPullDown.png', - width: 20.w, - height: 20.w, - ), - ], - ), - ), - onTap: () async { - var result = await Get.toNamed(Routers.selectCountryRegionPage); - if (result != null) { - result as Map; - state.countryCode.value = result['code']; - state.countryName.value = result['countryName']; + onTap: (() { + if (isEmail) { + state.emailReceiverList.value.removeAt(index); + state.emailReceiverList.refresh(); + } else { + state.phoneReceiverList.value.removeAt(index); + state.phoneReceiverList.refresh(); } - }, - )), - SizedBox( - width: 5.w, - ), - SizedBox( - width: 180.w, - child: TextField( - controller: phoneController, - //输入框一行 - maxLines: 1, - autofocus: false, - textAlign: TextAlign.end, - decoration: InputDecoration( - hintText: tfStr, - hintStyle: TextStyle(fontSize: 22.sp), - //不需要输入框下划线 - border: InputBorder.none, + }), + child: Container( + color: Colors.white, + child: Image.asset( + 'images/icon_massSend_delete.png', + width: 26.w, + height: 26.w, ), ), ), + SizedBox( + width: 20.w, + ), + Text( + TranslationLoader.lanKeys!.receiver!.tr, + style: TextStyle(fontSize: 22.sp), + ), + Expanded(child: SizedBox(width: 10.w)), + !isEmail + ? GestureDetector( + child: Container( + width: 90.w, + color: Colors.white, + child: Row( + mainAxisAlignment: MainAxisAlignment.end, + children: [ + Obx(() => Text( + '+${state.countryCode}', + style: TextStyle( + color: AppColors.darkGrayTextColor, + fontSize: 20.sp), + )), + Image.asset( + 'images/icon_grayPullDown.png', + width: 20.w, + height: 20.w, + ), + ], + ), + ), + onTap: () async { + var result = + await Get.toNamed(Routers.selectCountryRegionPage); + if (result != null) { + result as Map; + state.countryCode.value = result['code']; + state.countryName.value = result['countryName']; + } + }, + ) + : Container(), + getReceiverTFWidget(isEmail ? '请输入Email'.tr : '请输入手机号', index, + isEmail: isEmail) ], ), ); } - Widget massSendReceiverCellWidget({ - String? leftTitel, - String? rightTitle, - bool? isHaveDirection, - bool? isHaveLine, - bool? isHaveRightWidget, - Widget? rightWidget, - Function()? action, - double? allHeight, - }) { - return Column( - // mainAxisAlignment: MainAxisAlignment.center, - children: [ - Container( - height: 60.h, - color: Colors.white, - padding: EdgeInsets.only(right: 20.w), // , top: 20.w, bottom: 20.w - child: Row( - children: [ - SizedBox(width: 20.w), - Text(leftTitel!, style: TextStyle(fontSize: 22.sp)), - Expanded(child: SizedBox(width: 10.w)), - Row( - mainAxisAlignment: MainAxisAlignment.end, - children: [ - isHaveRightWidget! - ? rightWidget! - : Text( - rightTitle ?? "", - textAlign: TextAlign.end, - // overflow: TextOverflow.ellipsis, - // maxLines: 1, - style: TextStyle( - fontSize: 22.sp, - color: AppColors.darkGrayTextColor), - ) - ], - ) - ], + // 接受者信息输入框 + Widget getReceiverTFWidget(String tfStr, int lineIndex, + {required bool isEmail}) { + MsgNoticeModeData msgData = isEmail + ? state.emailReceiverList.value[lineIndex] + : state.phoneReceiverList.value[lineIndex]; + return SizedBox( + height: 65.h, + width: 200.w, + child: Row( + children: [ + Expanded( + child: TextField( + controller: msgData.receiverTF, + //输入框一行 + maxLines: 1, + inputFormatters: [ + FilteringTextInputFormatter.deny('\n'), + LengthLimitingTextInputFormatter(30), + ], + autofocus: false, + textAlign: TextAlign.end, + decoration: InputDecoration( + hintText: tfStr, + hintStyle: TextStyle(fontSize: 22.sp), + focusedBorder: const OutlineInputBorder( + borderSide: + BorderSide(width: 0, color: Colors.transparent)), + disabledBorder: const OutlineInputBorder( + borderSide: + BorderSide(width: 0, color: Colors.transparent)), + enabledBorder: const OutlineInputBorder( + borderSide: + BorderSide(width: 0, color: Colors.transparent)), + border: const OutlineInputBorder( + borderSide: + BorderSide(width: 0, color: Colors.transparent)), + contentPadding: const EdgeInsets.symmetric(vertical: 0), + ), + style: TextStyle( + fontSize: 22.sp, textBaseline: TextBaseline.alphabetic), + onChanged: (value) { + if (isEmail) { + msgData.receiveEmail = value; + state.emailReceiverList.value[lineIndex] = msgData; + } else { + msgData.receivePhone = value; + state.phoneReceiverList.value[lineIndex] = msgData; + } + }, + ), ), - ) - ], + ], + ), ); } } diff --git a/star_lock/lib/main/lockDetail/messageWarn/notificationMode/notificationMode_state.dart b/star_lock/lib/main/lockDetail/messageWarn/notificationMode/notificationMode_state.dart index fbaebd83..6b228506 100644 --- a/star_lock/lib/main/lockDetail/messageWarn/notificationMode/notificationMode_state.dart +++ b/star_lock/lib/main/lockDetail/messageWarn/notificationMode/notificationMode_state.dart @@ -1,9 +1,9 @@ import 'package:get/get.dart'; class NotificationModeState { - var inputEmailStr = ''.obs; // 输入的邮箱地址 var emailReceiverList = [].obs; var phoneReceiverList = [].obs; + var countryName = '中国'.obs; - var countryCode = '86'.obs; + var countryCode = 86.obs; } diff --git a/star_lock/lib/network/api.dart b/star_lock/lib/network/api.dart index 440f9e89..3f14e73a 100644 --- a/star_lock/lib/network/api.dart +++ b/star_lock/lib/network/api.dart @@ -45,7 +45,8 @@ abstract class Api { final String passwordKeyGetURL = '/keyboardPwd/get'; //获取密码 final String passwordKeyAddURL = '/keyboardPwd/add'; //自定义密码 - final String passwordKeyCheckKeyboardpwdNameURL = '/keyboardPwd/checkKeyboardpwdName'; //自定义密码校验密码跟名字是否重复 + final String passwordKeyCheckKeyboardpwdNameURL = + '/keyboardPwd/checkKeyboardpwdName'; //自定义密码校验密码跟名字是否重复 final String updatePasswordKeyURL = '/keyboardPwd/update'; //修改密码详情 final String updatePWDNumberURL = '/keyboardPwd/updatePwdUserNo'; //更新锁用户需要 final String clearOperationRecordURL = '/lockRecords/clear'; //清空操作记录 @@ -199,6 +200,10 @@ abstract class Api { final String updateLockNoticeSettingURL = '/lockSetting/updateLockNoticeSetting'; //设置开门通知 final String lockKeysListURL = '/lock/lockKeysList'; //锁钥匙列表 + final String addLockNoticeSettingURL = + '/lockNoticeSettingAccount/add'; //添加开门通知 + final String lockNoticeSettingListURL = + '/lockNoticeSettingAccount/list'; //开门通知列表 final String setWechatPushSwitchURL = '/user/setMpWechatPushSwitch'; //设置微信公众号推送 diff --git a/star_lock/lib/network/api_provider.dart b/star_lock/lib/network/api_provider.dart index 3158f738..071ce1ae 100644 --- a/star_lock/lib/network/api_provider.dart +++ b/star_lock/lib/network/api_provider.dart @@ -432,12 +432,15 @@ class ApiProvider extends BaseProvider { })); // 更新锁用户序号 - Future updatePWDNumber(String lockId, String keyboardPwdId, String pwdUserNo) => post( - updatePWDNumberURL.toUrl, - jsonEncode({ - 'lockId': lockId, - 'keyboardPwdId': keyboardPwdId, - 'pwdUserNo': pwdUserNo})); + Future updatePWDNumber( + String lockId, String keyboardPwdId, String pwdUserNo) => + post( + updatePWDNumberURL.toUrl, + jsonEncode({ + 'lockId': lockId, + 'keyboardPwdId': keyboardPwdId, + 'pwdUserNo': pwdUserNo + })); Future addKeyboardPwd( String lockId, @@ -1888,6 +1891,22 @@ class ApiProvider extends BaseProvider { Future getLockKeysList(int lockId) => post(lockKeysListURL.toUrl, jsonEncode({'lockId': lockId})); + // 添加开门通知 + Future addLockNoticeSetting( + int lockId, int noticeType, Map settingValue) => + post( + addLockNoticeSettingURL.toUrl, + jsonEncode({ + 'lockId': lockId, + 'noticeType': noticeType, + 'settingValue': settingValue + })); + + // 开门通知列表 + Future lockNoticeSettingAccountList(int lockId, int noticeType) => + post(lockNoticeSettingListURL.toUrl, + jsonEncode({'lockId': lockId, 'noticeType': noticeType})); + // 设置微信公众号推送 Future setMpWechatPushSwitch(int mpWechatPushSwitch) => post( setWechatPushSwitchURL.toUrl, diff --git a/star_lock/lib/network/api_repository.dart b/star_lock/lib/network/api_repository.dart index 60ca82fb..48193b9d 100644 --- a/star_lock/lib/network/api_repository.dart +++ b/star_lock/lib/network/api_repository.dart @@ -48,6 +48,7 @@ import '../main/lockDetail/lockSet/lockSet/lockSetInfo_entity.dart'; import '../main/lockDetail/lockSet/lockTime/getServerDatetime_entity.dart'; import '../main/lockDetail/lockDetail/lockNetToken_entity.dart'; import '../main/lockDetail/lockOperatingRecord/lockOperatingRecordGetLastRecordTime_entity.dart'; +import '../main/lockDetail/messageWarn/msgNotification/openDoorNotify/openDoorNotify_entity.dart'; import '../main/lockMian/entity/lockListInfo_entity.dart'; import '../mine/addLock/saveLock/entity/SaveLockEntity.dart'; import '../mine/message/messageList/messageList_entity.dart'; @@ -447,13 +448,10 @@ class ApiRepository { // 更新锁用户序号 Future updatePWDNumber( {required String lockId, - required String keyboardPwdId, - required String pwdUserNo}) async { - final res = await apiProvider.updatePWDNumber( - lockId, - keyboardPwdId, - pwdUserNo - ); + required String keyboardPwdId, + required String pwdUserNo}) async { + final res = + await apiProvider.updatePWDNumber(lockId, keyboardPwdId, pwdUserNo); return PasswordKeyEntity.fromJson(res.body); } @@ -668,11 +666,9 @@ class ApiRepository { //删除密码 Future deleteKeyboardPwd( - { - required String lockId, - required String keyboardPwdId, - required int deleteType - }) async { + {required String lockId, + required String keyboardPwdId, + required int deleteType}) async { final res = await apiProvider.deleteKeyboardPwd(lockId, keyboardPwdId, deleteType); return PasswordKeyEntity.fromJson(res.body); @@ -1361,17 +1357,8 @@ class ApiRepository { required String addType, required List weekDay, required int faceRight}) async { - final res = await apiProvider.addFaceData( - lockId, - faceName, - faceNumber, - faceType, - startDate, - endDate, - featureData, - addType, - weekDay, - faceRight); + final res = await apiProvider.addFaceData(lockId, faceName, faceNumber, + faceType, startDate, endDate, featureData, addType, weekDay, faceRight); return AddFaceEntity.fromJson(res.body); } @@ -1911,6 +1898,24 @@ class ApiRepository { return LockUserEntity.fromJson(res.body); } + // 添加开门通知 + Future addLockNoticeSetting( + {required int lockId, + required int noticeType, + required Map settingValue}) async { + final res = await apiProvider.addLockNoticeSetting( + lockId, noticeType, settingValue); + return MsgNotificationEntity.fromJson(res.body); + } + + // 开门通知列表 + Future lockNoticeSettingAccountList( + {required int lockId, required int noticeType}) async { + final res = + await apiProvider.lockNoticeSettingAccountList(lockId, noticeType); + return OpenDoorNotifyEntity.fromJson(res.body); + } + // 设置微信公众号推送 Future setMpWechatPushSwitch( {required int mpWechatPushSwitch}) async {