更改分享和解绑消息弹窗
This commit is contained in:
@@ -2,6 +2,7 @@ import 'dart:convert';
|
||||
|
||||
import 'package:EasyDartModule/EasyDartModule.dart';
|
||||
import 'package:ef/ef.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutterflow_ui/flutterflow_ui.dart';
|
||||
import 'package:json_annotation/json_annotation.dart';
|
||||
import 'package:vbvs_app/common/color/ServiceConstant.dart';
|
||||
@@ -9,6 +10,8 @@ import 'package:vbvs_app/common/color/appConstants.dart';
|
||||
import 'package:vbvs_app/common/color/app_uri_status.dart';
|
||||
import 'package:vbvs_app/common/util/DailyLogUtils.dart';
|
||||
import 'package:vbvs_app/common/util/MyUtils.dart';
|
||||
import 'package:vbvs_app/common/util/requestWithLog.dart';
|
||||
import 'package:vbvs_app/component/tool/TopSlideNotification.dart';
|
||||
import 'package:vbvs_app/enum/APPPackageType.dart';
|
||||
import 'package:vbvs_app/model/api_response.dart';
|
||||
|
||||
@@ -44,20 +47,36 @@ class MessageController extends GetControllerEx<MessageModel> {
|
||||
|
||||
RxList messageList = [].obs;
|
||||
|
||||
Future<ApiResponse> getMessageList({String? key}) async {
|
||||
int bodyPage = 1;
|
||||
int systemPage = 1;
|
||||
|
||||
Future<void> loadMore(String type) async {
|
||||
if (type == "app_vsm") {
|
||||
bodyPage++;
|
||||
await getMessageList(key: "app_vsm", page: bodyPage, append: true);
|
||||
} else {
|
||||
systemPage++;
|
||||
await getMessageList(key: "app_system", page: systemPage, append: true);
|
||||
}
|
||||
}
|
||||
|
||||
Future<ApiResponse> getMessageList(
|
||||
{String? key, int page = 1, int limit = 20, bool append = false}) async {
|
||||
try {
|
||||
ApiResponse apiResponse = ApiResponse(code: -1, msg: "请求失败".tr);
|
||||
String serviceAddress = ServiceConstant.service_address;
|
||||
String serviceName = ServiceConstant.server_service;
|
||||
String serviceApi = ServiceConstant.message_list;
|
||||
String messageType = "app_system";
|
||||
if (model.type == 1) {
|
||||
String messageType;
|
||||
if (key != null && key.isNotEmpty) {
|
||||
messageType = key;
|
||||
} else if (model.type == 1) {
|
||||
messageType = "app_vsm";
|
||||
} else {
|
||||
messageType = "app_system";
|
||||
}
|
||||
String queryUrl =
|
||||
"${serviceAddress}${serviceName}${serviceApi}?type=${messageType}";
|
||||
"${serviceAddress}${serviceName}${serviceApi}?type=${messageType}&page=$page&limit=$limit";
|
||||
String? language = "";
|
||||
if (AppConstants().ent_type == APPPackageType.MHT.code) {
|
||||
if (mhLanguageController.selectLanguage != null) {
|
||||
@@ -83,8 +102,12 @@ class MessageController extends GetControllerEx<MessageModel> {
|
||||
ApiResponse.fromJson(responseData, (object) => object);
|
||||
MyUtils.formatResponse(res, "请求成功".tr, "请求失败".tr);
|
||||
if (res.code == HttpStatusCodes.ok) {
|
||||
if (append) {
|
||||
messageList.addAll(res.data ?? []);
|
||||
} else {
|
||||
messageList.assignAll(res.data ?? []);
|
||||
}
|
||||
updateAll();
|
||||
messageList.value = res.data;
|
||||
return res;
|
||||
}
|
||||
} else {
|
||||
@@ -223,4 +246,45 @@ class MessageController extends GetControllerEx<MessageModel> {
|
||||
return ApiResponse(code: -1, msg: "失败".tr);
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> updateMessageReadStatus(BuildContext context, String messageType,
|
||||
{String? mid, bool all = false}) async {
|
||||
final serviceAddress = ServiceConstant.service_address;
|
||||
final serviceName = ServiceConstant.server_service;
|
||||
final serviceApi = ServiceConstant.message_read;
|
||||
|
||||
// 构建 query 参数
|
||||
String queryUrl =
|
||||
"$serviceAddress$serviceName$serviceApi?type=$messageType";
|
||||
if (all) {
|
||||
queryUrl += "&mid=ALL";
|
||||
} else if (mid != null && mid.isNotEmpty) {
|
||||
queryUrl += "&mid=$mid";
|
||||
}
|
||||
|
||||
await requestWithLog(
|
||||
logTitle: all ? '更新所有消息为已读' : '更新消息为已读',
|
||||
method: MyHttpMethod.post,
|
||||
queryUrl: queryUrl,
|
||||
onSuccess: (res) {
|
||||
if (res.code == HttpStatusCodes.ok) {
|
||||
getMessageList(key: messageType);
|
||||
getMessageStatus();
|
||||
|
||||
// ✅ 只有在 all 为 true 时才提示
|
||||
if (all) {
|
||||
TopSlideNotification.show(
|
||||
context,
|
||||
text: res.msg!,
|
||||
textColor: Color(0XFF00C1AA),
|
||||
);
|
||||
}
|
||||
}
|
||||
},
|
||||
onFailure: (res) {
|
||||
TopSlideNotification.show(context,
|
||||
text: res.msg!, textColor: Color(0xFFFF7159));
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user