diff --git a/lib/http/api.dart b/lib/http/api.dart index 1821c0cd..bbafefe7 100644 --- a/lib/http/api.dart +++ b/lib/http/api.dart @@ -616,5 +616,7 @@ class Api { static const String removeMsg = '/session_svr/v1/session_svr/remove_session'; + static const String removeSysMsg = '/x/sys-msg/del_notify_list'; + static const String setTop = '/session_svr/v1/session_svr/set_top'; } diff --git a/lib/http/msg.dart b/lib/http/msg.dart index bd9c6c58..9599c81c 100644 --- a/lib/http/msg.dart +++ b/lib/http/msg.dart @@ -167,6 +167,34 @@ class MsgHttp { } } + static Future removeSysMsg( + dynamic id, + ) async { + String csrf = await Request.getCsrf(); + var res = await Request().post( + HttpString.messageBaseUrl + Api.removeSysMsg, + queryParameters: { + 'mobi_app': 'android', + 'csrf': csrf, + }, + data: { + 'csrf': csrf, + 'ids': [id], + 'station_ids': [], + 'type': 4, + 'mobi_app': 'android', + }, + ); + if (res.data['code'] == 0) { + return {'status': true}; + } else { + return { + 'status': false, + 'msg': res.data['message'], + }; + } + } + static Future setTop( dynamic talkerId, int opType, diff --git a/lib/pages/msg_feed_top/sys_msg/controller.dart b/lib/pages/msg_feed_top/sys_msg/controller.dart index c2acafa4..0652998d 100644 --- a/lib/pages/msg_feed_top/sys_msg/controller.dart +++ b/lib/pages/msg_feed_top/sys_msg/controller.dart @@ -50,6 +50,7 @@ class SysMsgController extends GetxController { return false; } } + Future onLoad() async { if (isEnd) return; queryMsgFeedSysMsg(); @@ -60,4 +61,14 @@ class SysMsgController extends GetxController { cursorTime = -1; queryMsgFeedSysMsg(); } + + Future onRemove(int index) async { + var res = await MsgHttp.removeSysMsg(msgFeedSysMsgList[index].id); + if (res['status']) { + msgFeedSysMsgList.removeAt(index); + SmartDialog.showToast('删除成功'); + } else { + SmartDialog.showToast(res['msg']); + } + } } diff --git a/lib/pages/msg_feed_top/sys_msg/view.dart b/lib/pages/msg_feed_top/sys_msg/view.dart index efe418a9..1c3621e3 100644 --- a/lib/pages/msg_feed_top/sys_msg/view.dart +++ b/lib/pages/msg_feed_top/sys_msg/view.dart @@ -83,6 +83,33 @@ class _SysMsgPageState extends State { } return ListTile( onTap: () {}, + onLongPress: () { + showDialog( + context: context, + builder: (_) => AlertDialog( + title: const Text('确定删除该消息?'), + actions: [ + TextButton( + onPressed: Get.back, + child: Text( + '取消', + style: TextStyle( + color: Theme.of(context) + .colorScheme + .outline, + ), + ), + ), + TextButton( + onPressed: () { + Get.back(); + _sysMsgController.onRemove(i); + }, + child: const Text('确定'), + ), + ], + )); + }, title: Text( "${_sysMsgController.msgFeedSysMsgList[i].title}", style: Theme.of(context).textTheme.titleMedium,