更新安卓通知栏提示
This commit is contained in:
@@ -110,8 +110,8 @@ class BlueteethBindController extends GetControllerEx<BlueteethBindModel> {
|
||||
updateAll();
|
||||
} else {
|
||||
safeShowNotification(res.msg ?? "获取设备状态异常");
|
||||
EasyDartModule.logger.info("获取设备状态异常: $res");
|
||||
DailyLogUtils.writeLog("获取设备状态异常: $res");
|
||||
// EasyDartModule.logger.info("获取设备状态异常: $res");
|
||||
// DailyLogUtils.writeLog("获取设备状态异常: $res");
|
||||
}
|
||||
});
|
||||
|
||||
@@ -122,8 +122,8 @@ class BlueteethBindController extends GetControllerEx<BlueteethBindModel> {
|
||||
updateAll();
|
||||
} else {
|
||||
safeShowNotification(res.msg ?? "获取设备状态异常");
|
||||
EasyDartModule.logger.info("获取设备状态异常: $res");
|
||||
DailyLogUtils.writeLog("获取设备状态异常: $res");
|
||||
// EasyDartModule.logger.info("获取设备状态异常: $res");
|
||||
// DailyLogUtils.writeLog("获取设备状态异常: $res");
|
||||
}
|
||||
}).catchError((e, stack) {
|
||||
print("updateDeviceStatus 执行异常: $e\n$stack");
|
||||
@@ -140,127 +140,6 @@ class BlueteethBindController extends GetControllerEx<BlueteethBindModel> {
|
||||
_statusTimer = null;
|
||||
}
|
||||
|
||||
// Future<ApiResponse> updateDeviceStatus() async {
|
||||
// try {
|
||||
// String serviceAddress = ServiceConstant.service_address;
|
||||
// String serviceName = ServiceConstant.server_service;
|
||||
// String serviceApi = ServiceConstant.get_bluetooth_device_status;
|
||||
// String queryUrl = "$serviceAddress$serviceName$serviceApi";
|
||||
|
||||
// if (model.devicelist != null && model.devicelist!.isNotEmpty) {
|
||||
// final macParams = model.devicelist!
|
||||
// .map((device) => "mac=${Uri.encodeQueryComponent(device.mac!)}")
|
||||
// .join("&");
|
||||
|
||||
// if (queryUrl.contains('?')) {
|
||||
// queryUrl += '&$macParams';
|
||||
// } else {
|
||||
// queryUrl += '?$macParams';
|
||||
// }
|
||||
// String? language = "";
|
||||
// if (languageController.selectLanguage != null) {
|
||||
// language = languageController.selectLanguage.value!.language_code;
|
||||
// }
|
||||
// if (language != null && language.isNotEmpty) {
|
||||
// if (queryUrl.contains("?")) {
|
||||
// queryUrl += "&lang=$language";
|
||||
// } else {
|
||||
// queryUrl += "?lang=$language";
|
||||
// }
|
||||
// }
|
||||
|
||||
// var response = await EasyDartModule.dio.get(queryUrl);
|
||||
// var responseData =
|
||||
// response.data is String ? jsonDecode(response.data) : response.data;
|
||||
// ApiResponse res =
|
||||
// ApiResponse.fromJson(responseData, (object) => object);
|
||||
// if (res.code != HttpStatusCodes.ok) return res;
|
||||
|
||||
// if (response.data['data'] != null && response.data['data'] is List) {
|
||||
// List<dynamic> responseList = response.data['data'];
|
||||
|
||||
// // 构建 mac -> 设备的映射
|
||||
// Map<String, BleDeviceData> deviceMap = {
|
||||
// for (var d in model.devicelist!)
|
||||
// if (d.mac != null) d.mac!.toLowerCase(): d,
|
||||
// };
|
||||
|
||||
// // 用于记录已经设置过主从关系的 mac,避免重复
|
||||
// Set<String> processedMacs = {};
|
||||
|
||||
// for (var item in responseList) {
|
||||
// String mac = item['mac'].toLowerCase();
|
||||
// String? bindMac = item['bindMac']?.toLowerCase();
|
||||
// bool? bind = item['bind'];
|
||||
|
||||
// if (!deviceMap.containsKey(mac)) continue;
|
||||
|
||||
// BleDeviceData currentDevice = deviceMap[mac]!;
|
||||
// currentDevice.bind = bind;
|
||||
|
||||
// if (bindMac != null && deviceMap.containsKey(bindMac)) {
|
||||
// final isMutualBind = responseList.any((e) =>
|
||||
// e['mac']?.toString().toLowerCase() == bindMac &&
|
||||
// e['bindMac']?.toString().toLowerCase() == mac);
|
||||
|
||||
// if (isMutualBind) {
|
||||
// if (processedMacs.contains(mac) ||
|
||||
// processedMacs.contains(bindMac)) {
|
||||
// continue;
|
||||
// }
|
||||
|
||||
// final masterMac = (mac.compareTo(bindMac) < 0) ? mac : bindMac;
|
||||
// final slaveMac = (mac.compareTo(bindMac) < 0) ? bindMac : mac;
|
||||
|
||||
// if (deviceMap.containsKey(masterMac) &&
|
||||
// deviceMap.containsKey(slaveMac)) {
|
||||
// deviceMap[masterMac]!.slave = deviceMap[slaveMac];
|
||||
// processedMacs.add(masterMac);
|
||||
// processedMacs.add(slaveMac);
|
||||
// }
|
||||
// } else {
|
||||
// if (!processedMacs.contains(mac)) {
|
||||
// BleDeviceData masterDevice = deviceMap[bindMac]!;
|
||||
// masterDevice.slave = currentDevice;
|
||||
// processedMacs.add(mac);
|
||||
// processedMacs.add(bindMac);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
// // 获取所有被作为 slave 的 mac,用于排除掉
|
||||
// final Set<String> allSlaveMacs = {
|
||||
// for (var d in deviceMap.values)
|
||||
// if (d.slave?.mac != null) d.slave!.mac!.toLowerCase()
|
||||
// };
|
||||
|
||||
// // 构造最终列表,只保留主设备和未被作为 slave 的独立设备
|
||||
// final List<BleDeviceData> finalList = deviceMap.values.where((d) {
|
||||
// final mac = d.mac?.toLowerCase();
|
||||
// if (mac == null) return false;
|
||||
// if (d.slave != null) return true; // 主设备
|
||||
// return !allSlaveMacs.contains(mac); // 不是别人 slave 的独立设备
|
||||
// }).toList();
|
||||
|
||||
// model.betDevicelist = finalList;
|
||||
// } else {
|
||||
// model.betDevicelist = [];
|
||||
// }
|
||||
|
||||
// updateAll();
|
||||
// return res;
|
||||
// }
|
||||
// } catch (e) {
|
||||
// print("获取设备状态异常: $e");
|
||||
// EasyDartModule.logger.info("获取设备状态异常: $e");
|
||||
// DailyLogUtils.writeLog("获取设备状态异常: $e");
|
||||
// return ApiResponse(code: -1, msg: "请求失败".tr);
|
||||
// }
|
||||
|
||||
// return ApiResponse(code: -1, msg: "未知错误".tr);
|
||||
// }
|
||||
|
||||
Future<ApiResponse> updateDeviceStatus() async {
|
||||
try {
|
||||
String serviceAddress = ServiceConstant.service_address;
|
||||
@@ -334,8 +213,8 @@ class BlueteethBindController extends GetControllerEx<BlueteethBindModel> {
|
||||
}
|
||||
} catch (e) {
|
||||
print("获取设备状态异常: $e");
|
||||
EasyDartModule.logger.info("获取设备状态异常: $e");
|
||||
DailyLogUtils.writeLog("获取设备状态异常: $e");
|
||||
// EasyDartModule.logger.info("获取设备状态异常: $e");
|
||||
// DailyLogUtils.writeLog("获取设备状态异常: $e");
|
||||
return ApiResponse(code: -1, msg: "请求失败".tr);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,17 +1,19 @@
|
||||
import 'package:ef/ef.dart';
|
||||
import 'package:json_annotation/json_annotation.dart';
|
||||
import 'package:vbvs_app/common/color/ServiceConstant.dart';
|
||||
import 'package:vbvs_app/common/util/requestWithLog.dart';
|
||||
|
||||
part 'common_message_setting_controller.g.dart'; // 由json_serializable自动生成的部分
|
||||
|
||||
@JsonSerializable()
|
||||
class CommonMessageSettingModel {
|
||||
int? setting = 0;//总设置 0 关闭 1 开启
|
||||
int? appSetting = 0;//app消息设置
|
||||
int? serviceSetting = 0;//服务号消息
|
||||
int? tipSetting = 0;//设备放置说明
|
||||
int? deviceUpgradeSetting = 0;//设备升级提示
|
||||
int? deviceIssueSetting = 0;//设备故障提示
|
||||
|
||||
int? setting = 0; //总设置 0 关闭 1 开启
|
||||
int? appSetting = 0; //app消息设置
|
||||
int? serviceSetting = 0; //服务号消息
|
||||
int? tipSetting = 0; //设备放置说明
|
||||
int? deviceUpgradeSetting = 0; //设备升级提示
|
||||
int? deviceIssueSetting = 0; //设备故障提示
|
||||
int? sleepReportSetting = 0; //睡眠报告通知
|
||||
|
||||
CommonMessageSettingModel();
|
||||
|
||||
@@ -30,9 +32,58 @@ class CommonMessageSettingModel {
|
||||
Map<String, dynamic> toJson() => _$CommonMessageSettingModelToJson(this);
|
||||
}
|
||||
|
||||
class CommonMessageSettingController extends GetControllerEx<CommonMessageSettingModel> {
|
||||
class CommonMessageSettingController
|
||||
extends GetControllerEx<CommonMessageSettingModel> {
|
||||
CommonMessageSettingController() {
|
||||
attr = GetModel(CommonMessageSettingModel()).obs;
|
||||
}
|
||||
|
||||
Future<void> getAppSleepNotify() async {
|
||||
String serviceAddress = ServiceConstant.service_address;
|
||||
String serviceName = ServiceConstant.server_service;
|
||||
String serviceApi = ServiceConstant.user_setting;
|
||||
String type = "sleep_report_notify";
|
||||
String queryUrl = "${serviceAddress}${serviceName}${serviceApi}?type=$type";
|
||||
await requestWithLog(
|
||||
logTitle: "查询用户睡眠通知消息配置",
|
||||
method: MyHttpMethod.get,
|
||||
queryUrl: queryUrl,
|
||||
onSuccess: (res) {
|
||||
if (res.data == null) {
|
||||
model.sleepReportSetting = 1;
|
||||
} else {
|
||||
model.sleepReportSetting = res.data["setting"];
|
||||
}
|
||||
updateAll();
|
||||
},
|
||||
onFailure: (res) {
|
||||
print(res);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
Future<void> updateSleepNotify(bool val) async {
|
||||
String serviceAddress = ServiceConstant.service_address;
|
||||
String serviceName = ServiceConstant.server_service;
|
||||
String serviceApi = ServiceConstant.user_setting;
|
||||
String type = "sleep_report_notify";
|
||||
String queryUrl = "${serviceAddress}${serviceName}${serviceApi}?type=$type";
|
||||
var data = {
|
||||
"type": type,
|
||||
"setting": val == true ? 1 : 0,
|
||||
"time": DateTime.now().millisecondsSinceEpoch,
|
||||
};
|
||||
await requestWithLog(
|
||||
logTitle: "查询用户睡眠通知消息配置",
|
||||
method: MyHttpMethod.put,
|
||||
queryUrl: queryUrl,
|
||||
data: data,
|
||||
onSuccess: (res) {
|
||||
updateAll();
|
||||
},
|
||||
onFailure: (res) {
|
||||
print(res);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,6 +19,7 @@ import 'package:vbvs_app/enum/APPPackageType.dart';
|
||||
import 'package:vbvs_app/model/api_response.dart';
|
||||
import 'package:vbvs_app/model/user_data.dart';
|
||||
import 'package:vbvs_app/pages/mh_page/homepage/controller/mht_home_controller.dart';
|
||||
import 'package:vbvs_app/pages/mh_page/user/controller/mht_login_controller.dart';
|
||||
|
||||
part 'user_info_controller.g.dart';
|
||||
|
||||
@@ -241,6 +242,7 @@ class UserInfoController extends GetControllerEx<UserInfoModel> {
|
||||
}
|
||||
|
||||
ApiResponse logOut() {
|
||||
updateAppSystemNotify(false);
|
||||
int code = AppConstants().ent_type;
|
||||
if (APPPackageType.MHT.code == code) {
|
||||
MHTHomeController mhtHomeController = Get.find();
|
||||
@@ -266,6 +268,7 @@ class UserInfoController extends GetControllerEx<UserInfoModel> {
|
||||
messageController.model.system_message_read = 0;
|
||||
CountdownController countdownController = Get.find();
|
||||
countdownController.countdown.value = 0;
|
||||
|
||||
return apiResponse;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user