diff --git a/star_lock/lib/main/lockDetail/lockSet/lockSet/lockSet_page.dart b/star_lock/lib/main/lockDetail/lockSet/lockSet/lockSet_page.dart index 646abc06..b350c55f 100644 --- a/star_lock/lib/main/lockDetail/lockSet/lockSet/lockSet_page.dart +++ b/star_lock/lib/main/lockDetail/lockSet/lockSet/lockSet_page.dart @@ -372,9 +372,8 @@ class _LockSetPageState extends State with RouteAware { isHaveLine: true, isHaveDirection: true, action: () { - Get.toNamed(Routers.msgNotificationPage, arguments: { - 'lockSetInfoData': state.lockSetInfoData.value - }); + Get.toNamed(Routers.msgNotificationPage, + arguments: {'lockId': state.lockSetInfoData.value.lockId}); })), //猫眼设置 Obx(() => Visibility( diff --git a/star_lock/lib/main/lockDetail/messageWarn/msgNotification/msgNotification/msgNotification_entity.dart b/star_lock/lib/main/lockDetail/messageWarn/msgNotification/msgNotification/msgNotification_entity.dart new file mode 100644 index 00000000..f6f4622f --- /dev/null +++ b/star_lock/lib/main/lockDetail/messageWarn/msgNotification/msgNotification/msgNotification_entity.dart @@ -0,0 +1,116 @@ +class MsgNotificationEntity { + int? errorCode; + String? description; + String? errorMsg; + Data? data; + + MsgNotificationEntity( + {this.errorCode, this.description, this.errorMsg, this.data}); + + MsgNotificationEntity.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? openDoorNoticeList; + int? dayNotOpenDoorState; + int? dayNotOpenDoorValue; + List? dayNotOpenDoorNoticeWayList; + int? doorNotCloseState; + int? tamperAlarmState; + int? lowElecNoticeState; + List? lowElecNoticeWayList; + List? coercionOpenDoorNoticeList; + int? doorbellNoticeState; + int? someoneAtDoorNoticeState; + + Data( + {this.openDoorNoticeList, + this.dayNotOpenDoorState, + this.dayNotOpenDoorValue, + this.dayNotOpenDoorNoticeWayList, + this.doorNotCloseState, + this.tamperAlarmState, + this.lowElecNoticeState, + this.lowElecNoticeWayList, + this.coercionOpenDoorNoticeList, + this.doorbellNoticeState, + this.someoneAtDoorNoticeState}); + + Data.fromJson(Map json) { + if (json['openDoorNoticeList'] != null) { + openDoorNoticeList = []; + json['openDoorNoticeList'].forEach((v) { + openDoorNoticeList!.add(v); + }); + } + dayNotOpenDoorState = json['dayNotOpenDoorState']; + dayNotOpenDoorValue = json['dayNotOpenDoorValue']; + if (json['dayNotOpenDoorNoticeWayList'] != null) { + dayNotOpenDoorNoticeWayList = []; + json['dayNotOpenDoorNoticeWayList'].forEach((v) { + dayNotOpenDoorNoticeWayList!.add(v); + }); + } + doorNotCloseState = json['doorNotCloseState']; + tamperAlarmState = json['tamperAlarmState']; + lowElecNoticeState = json['lowElecNoticeState']; + if (json['lowElecNoticeWayList'] != null) { + lowElecNoticeWayList = []; + json['lowElecNoticeWayList'].forEach((v) { + lowElecNoticeWayList!.add(v); + }); + } + if (json['coercionOpenDoorNoticeList'] != null) { + coercionOpenDoorNoticeList = []; + json['coercionOpenDoorNoticeList'].forEach((v) { + coercionOpenDoorNoticeList!.add(v); + }); + } + doorbellNoticeState = json['doorbellNoticeState']; + someoneAtDoorNoticeState = json['someoneAtDoorNoticeState']; + } + + Map toJson() { + final Map data = {}; + if (openDoorNoticeList != null) { + data['openDoorNoticeList'] = + openDoorNoticeList!.map((v) => v.toJson()).toList(); + } + data['dayNotOpenDoorState'] = dayNotOpenDoorState; + data['dayNotOpenDoorValue'] = dayNotOpenDoorValue; + if (dayNotOpenDoorNoticeWayList != null) { + data['dayNotOpenDoorNoticeWayList'] = + dayNotOpenDoorNoticeWayList!.map((v) => v.toJson()).toList(); + } + data['doorNotCloseState'] = doorNotCloseState; + data['tamperAlarmState'] = tamperAlarmState; + data['lowElecNoticeState'] = lowElecNoticeState; + if (lowElecNoticeWayList != null) { + data['lowElecNoticeWayList'] = + lowElecNoticeWayList!.map((v) => v).toList(); + } + if (coercionOpenDoorNoticeList != null) { + data['coercionOpenDoorNoticeList'] = + coercionOpenDoorNoticeList!.map((v) => v).toList(); + } + data['doorbellNoticeState'] = doorbellNoticeState; + data['someoneAtDoorNoticeState'] = someoneAtDoorNoticeState; + return data; + } +} diff --git a/star_lock/lib/main/lockDetail/messageWarn/msgNotification/msgNotification/msgNotification_logic.dart b/star_lock/lib/main/lockDetail/messageWarn/msgNotification/msgNotification/msgNotification_logic.dart index 0c09a6ee..88f154a0 100644 --- a/star_lock/lib/main/lockDetail/messageWarn/msgNotification/msgNotification/msgNotification_logic.dart +++ b/star_lock/lib/main/lockDetail/messageWarn/msgNotification/msgNotification/msgNotification_logic.dart @@ -1,7 +1,41 @@ - +import 'package:star_lock/main/lockDetail/messageWarn/msgNotification/msgNotification/msgNotification_entity.dart'; +import 'package:star_lock/network/api_repository.dart'; import 'package:star_lock/tools/baseGetXController.dart'; import 'msgNotification_state.dart'; class MsgNotificationLogic extends BaseGetXController { final MsgNotificationState state = MsgNotificationState(); + + // 获取锁消息设置 + void getLockNoticeSetting() async { + MsgNotificationEntity entity = await ApiRepository.to.getLockNoticeSetting( + lockId: state.getLockId.value, + ); + if (entity.errorCode!.codeIsSuccessful) { + state.nDaysNotOpenDoor.value = + entity.data!.dayNotOpenDoorState! == 0 ? '未启用' : '已启用'; + state.isDoorNotShut.value = + entity.data!.doorNotCloseState! == 0 ? false : true; + state.isTamperAlarm.value = + entity.data!.tamperAlarmState! == 0 ? '未启用' : '已启用'; + state.isLowBattery.value = + entity.data!.lowElecNoticeState! == 0 ? '未启用' : '已启用'; + state.isSomeoneRing.value = + entity.data!.doorbellNoticeState! == 0 ? false : true; //有人按门铃 + state.isSomeoneAppeared.value = + entity.data!.someoneAtDoorNoticeState! == 0 ? false : true; //有人出现在门口 + } + } + + //设置门未关好 + void updateDoorNotCloseSetting() async { + MsgNotificationEntity entity = + await ApiRepository.to.updateDoorNotCloseSetting( + lockId: state.getLockId.value, + doorNotCloseState: state.isDoorNotShut.value ? 1 : 0, + ); + if (entity.errorCode!.codeIsSuccessful) { + showToast('设置成功'); + } + } } diff --git a/star_lock/lib/main/lockDetail/messageWarn/msgNotification/msgNotification/msgNotification_page.dart b/star_lock/lib/main/lockDetail/messageWarn/msgNotification/msgNotification/msgNotification_page.dart index 36ef5a65..e9426bad 100644 --- a/star_lock/lib/main/lockDetail/messageWarn/msgNotification/msgNotification/msgNotification_page.dart +++ b/star_lock/lib/main/lockDetail/messageWarn/msgNotification/msgNotification/msgNotification_page.dart @@ -35,6 +35,12 @@ class _MsgNotificationPageState extends State { style: subTipsStyle), ]); + @override + initState() { + super.initState(); + logic.getLockNoticeSetting(); + } + @override Widget build(BuildContext context) { return Scaffold( @@ -71,20 +77,18 @@ class _MsgNotificationPageState extends State { isHaveLine: true, isHaveDirection: true, action: () { - Get.toNamed(Routers.openDoorNotifyPage, arguments: { - 'lockSetInfoData': state.lockSetInfoData.value, - }); - }, - ), - CommonItem( - leftTitel: 'N天未开门', - rightTitle: "已启用", - isHaveLine: true, - isHaveDirection: true, - action: () { - Get.toNamed(Routers.nDaysUnopenedPage); + Get.toNamed(Routers.openDoorNotifyPage); }, ), + Obx(() => CommonItem( + leftTitel: 'N天未开门', + rightTitle: state.nDaysNotOpenDoor.value, + isHaveLine: true, + isHaveDirection: true, + action: () { + Get.toNamed(Routers.nDaysUnopenedPage); + }, + )), // SizedBox( // height: 20.h, // ), @@ -102,21 +106,21 @@ class _MsgNotificationPageState extends State { isHaveRightWidget: true, rightWidget: SizedBox(width: 60.w, height: 50.h, child: _switch(2)))), - CommonItem( - leftTitel: '防拆报警', - rightTitle: "已启用", - isHaveLine: true, - isHaveDirection: true, - ), - CommonItem( - leftTitel: '低电量提醒', - rightTitle: "已启用", - isHaveLine: true, - isHaveDirection: true, - action: () { - Get.toNamed(Routers.lowBatteryReminderPage); - }, - ), + Obx(() => CommonItem( + leftTitel: '防拆报警', + rightTitle: state.isTamperAlarm.value, + isHaveLine: true, + isHaveDirection: true, + )), + Obx(() => CommonItem( + leftTitel: '低电量提醒', + rightTitle: state.isLowBattery.value, + isHaveLine: true, + isHaveDirection: true, + action: () { + Get.toNamed(Routers.lowBatteryReminderPage); + }, + )), CommonItem( leftTitel: '胁迫开门', rightTitle: "", @@ -204,7 +208,10 @@ class _MsgNotificationPageState extends State { break; //门未关好 case 2: - state.isDoorNotShut.value = value; + { + state.isDoorNotShut.value = value; + logic.updateDoorNotCloseSetting(); + } break; //有人按门铃 case 3: diff --git a/star_lock/lib/main/lockDetail/messageWarn/msgNotification/msgNotification/msgNotification_state.dart b/star_lock/lib/main/lockDetail/messageWarn/msgNotification/msgNotification/msgNotification_state.dart index 8319dc69..eba68dcb 100644 --- a/star_lock/lib/main/lockDetail/messageWarn/msgNotification/msgNotification/msgNotification_state.dart +++ b/star_lock/lib/main/lockDetail/messageWarn/msgNotification/msgNotification/msgNotification_state.dart @@ -1,9 +1,12 @@ import 'package:get/get.dart'; -import 'package:star_lock/main/lockDetail/lockSet/lockSet/lockSetInfo_entity.dart'; class MsgNotificationState { - var lockSetInfoData = LockSetInfoData().obs; + // var lockSetInfoData = LockSetInfoData().obs; + var getLockId = 0.obs; var isCheck = false.obs; + var nDaysNotOpenDoor = '已启用'.obs; //N天未开门 + var isTamperAlarm = '已启用'.obs; //防拆报警 + var isLowBattery = '已启用'.obs; //低电量提醒 var isLeaveHomeOpenDoor = false.obs; //离家开门 var isDoorNotShut = false.obs; //门未关好 var isSomeoneRing = false.obs; //有人按门铃 @@ -11,8 +14,8 @@ class MsgNotificationState { MsgNotificationState() { Map map = Get.arguments; - if (map['lockSetInfoData'] != null) { - lockSetInfoData.value = map['lockSetInfoData']; + if (map['lockId'] != null) { + getLockId.value = map['lockId']; } } } 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 8cc3e58b..1e669078 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,16 +1,6 @@ -import 'package:star_lock/network/api_repository.dart'; import 'package:star_lock/tools/baseGetXController.dart'; -import 'package:star_lock/versionUndate/versionUndate_entity.dart'; import 'openDoorNotify_state.dart'; class OpenDoorNotifyLogic extends BaseGetXController { final OpenDoorNotifyState state = OpenDoorNotifyState(); - - // 获取锁消息设置 - void getLockNoticeSetting() async { - VersionUndateEntity entity = await ApiRepository.to.getLockNoticeSetting( - lockId: state.lockSetInfoData.value.lockId!, - ); - if (entity.errorCode!.codeIsSuccessful) {} - } } 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 4d2c39e0..c24a07e3 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,8 +22,6 @@ class _OpenDoorNotifyPageState extends State { @override void initState() { super.initState(); - - logic.getLockNoticeSetting(); } @override diff --git a/star_lock/lib/network/api.dart b/star_lock/lib/network/api.dart index 556a8018..2d8f0c23 100644 --- a/star_lock/lib/network/api.dart +++ b/star_lock/lib/network/api.dart @@ -196,6 +196,9 @@ abstract class Api { final String getLockNoticeSettingURL = '/lockSetting/getLockNoticeSetting'; //获取锁消息设置 + final String updateLockNoticeSettingURL = + '/lockSetting/updateLockNoticeSetting'; //设置开门通知 + final String setWechatPushSwitchURL = '/user/setMpWechatPushSwitch'; //设置微信公众号推送 final String getMpWechatQrCodeURL = '/user/getMpWechatQrCode'; //获取微信公众号二维码 diff --git a/star_lock/lib/network/api_provider.dart b/star_lock/lib/network/api_provider.dart index f7bee884..b9933145 100644 --- a/star_lock/lib/network/api_provider.dart +++ b/star_lock/lib/network/api_provider.dart @@ -1683,9 +1683,8 @@ class ApiProvider extends BaseProvider { })); // 删除所有消息 - Future deletAllMessageLoadData() => post( - deletAllMessageURL.toUrl, - jsonEncode({})); + Future deletAllMessageLoadData() => + post(deletAllMessageURL.toUrl, jsonEncode({})); // 获取最新版本号 Future getVersionData(String brandName, String currentVersion) => @@ -1787,6 +1786,33 @@ class ApiProvider extends BaseProvider { 'lockId': lockId, })); + // 设置N天未开门 + Future updateNdaysNotCloseDoorNoticeSetting( + int lockId, + int dayNotOpenDoorState, + int dayNotOpenDoorValue, + List dayNotOpenDoorNoticeWayList) => + post( + updateLockNoticeSettingURL.toUrl, + jsonEncode({ + 'lockId': lockId, + 'dayNotOpenDoorState': dayNotOpenDoorState, + 'dayNotOpenDoorValue': dayNotOpenDoorValue, + 'dayNotOpenDoorNoticeWayList': dayNotOpenDoorNoticeWayList + })); + + // 设置门未关好 + Future updateDoorNotCloseSetting( + int lockId, + int doorNotCloseState, + ) => + post( + updateLockNoticeSettingURL.toUrl, + jsonEncode({ + 'lockId': lockId, + 'doorNotCloseState': doorNotCloseState, + })); + // 设置微信公众号推送 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 1f8e8b64..abc584c1 100644 --- a/star_lock/lib/network/api_repository.dart +++ b/star_lock/lib/network/api_repository.dart @@ -7,6 +7,7 @@ import 'package:star_lock/main/lockDetail/electronicKey/massSendElectronicKey/ma import 'package:star_lock/main/lockDetail/electronicKey/massSendElectronicKey/massSendLockGroupList/massSendLockGroupListEntity.dart'; import 'package:star_lock/main/lockDetail/face/addFace/addFace_entity.dart'; import 'package:star_lock/main/lockDetail/lockSet/basicInformation/basicInformation/KeyDetailEntity.dart'; +import 'package:star_lock/main/lockDetail/messageWarn/msgNotification/msgNotification/msgNotification_entity.dart'; 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/mall/lockMall_entity.dart'; @@ -1811,10 +1812,31 @@ class ApiRepository { } // 获取锁消息设置 - Future getLockNoticeSetting( + Future getLockNoticeSetting( {required int lockId}) async { final res = await apiProvider.getLockNoticeSetting(lockId); - return VersionUndateEntity.fromJson(res.body); + return MsgNotificationEntity.fromJson(res.body); + } + + // 设置N天未开门 + Future updateNdaysNotCloseDoorNoticeSetting( + {required int lockId, + required int dayNotOpenDoorState, + required int dayNotOpenDoorValue, + required List dayNotOpenDoorNoticeWayList}) async { + final res = await apiProvider.updateNdaysNotCloseDoorNoticeSetting(lockId, + dayNotOpenDoorState, dayNotOpenDoorValue, dayNotOpenDoorNoticeWayList); + return MsgNotificationEntity.fromJson(res.body); + } + + // 设置门未关好 + Future updateDoorNotCloseSetting({ + required int lockId, + required int doorNotCloseState, + }) async { + final res = + await apiProvider.updateDoorNotCloseSetting(lockId, doorNotCloseState); + return MsgNotificationEntity.fromJson(res.body); } // 设置微信公众号推送