更新消息设置

This commit is contained in:
wyf
2025-12-05 17:37:01 +08:00
parent 1cc26aa46d
commit db51c42664
44 changed files with 7510 additions and 1059 deletions

View File

@@ -135,12 +135,14 @@ class _EPageState extends State<EPage> with AutomaticKeepAliveClientMixin {
Widget _buildLoggedInContent() {
return Obx(() {
if (finalUri.isEmpty) {
return Center(child: CircularProgressIndicator(
strokeWidth: 2,
valueColor: AlwaysStoppedAnimation<Color>(
themeController.currentColor.sc1,
),
),);
return Center(
child: CircularProgressIndicator(
strokeWidth: 2,
valueColor: AlwaysStoppedAnimation<Color>(
themeController.currentColor.sc1,
),
),
);
}
// 如果设备列表为空
@@ -166,7 +168,9 @@ class _EPageState extends State<EPage> with AutomaticKeepAliveClientMixin {
return Stack(
children: [
InAppWebView(
initialUrlRequest: URLRequest(url: WebUri(finalUri.value+"?t=${DateTime.now().millisecondsSinceEpoch}")),
initialUrlRequest: URLRequest(
url: WebUri(finalUri.value +
"?t=${DateTime.now().millisecondsSinceEpoch}")),
onLoadStart: (controller, url) {
isPageLoading.value = true;
},
@@ -178,12 +182,14 @@ class _EPageState extends State<EPage> with AutomaticKeepAliveClientMixin {
valueListenable: isPageLoading,
builder: (context, isLoading, child) {
return isLoading
? Center(child:CircularProgressIndicator(
? Center(
child: CircularProgressIndicator(
strokeWidth: 2,
valueColor: AlwaysStoppedAnimation<Color>(
themeController.currentColor.sc1,
),
),)
),
)
: SizedBox.shrink();
},
),
@@ -212,55 +218,127 @@ class _EPageState extends State<EPage> with AutomaticKeepAliveClientMixin {
}
Future<void> getDeviceList() async {
BodyDeviceController bodyDeviceController = Get.find();
ApiResponse apiResponse = await bodyDeviceController.getDeviceList();
try {
BodyDeviceController bodyDeviceController = Get.find();
ApiResponse apiResponse =
await bodyDeviceController.getDeviceList(isAllDevice: true);
if (apiResponse.code == HttpStatusCodes.ok) {
List<dynamic> rawList = apiResponse.data;
if (apiResponse.code == HttpStatusCodes.ok) {
List<dynamic> rawList = apiResponse.data;
// 提取 mac 和 person.name
List<Map<String, dynamic>> newList = rawList.map((item) {
String mac = item['mac'] ?? '';
String name = (item['person'] != null &&
item['person']['name'] != null &&
item['person']['name'].toString().trim().isNotEmpty)
? item['person']['name'] + "_${mac}"
: '未命名'.tr + "_${mac}";
return {
'mac': mac,
'name': name,
};
}).toList();
// 提取 mac 和 person.name
List<Map<String, dynamic>> newList = rawList.map((item) {
String mac = item['mac'] ?? '';
String name = (item['person'] != null &&
item['person']['name'] != null &&
item['person']['name'].toString().trim().isNotEmpty)
? item['person']['name'] + "_${mac}"
: '未命名'.tr + "_${mac}";
return {
'mac': mac,
'name': name,
};
}).toList();
deviceList.value = newList;
deviceList.value = newList;
// 拼接参数 person
if (deviceList.isNotEmpty) {
// JSON 编码整个 deviceList 对象数组
String personParam = Uri.encodeComponent(jsonEncode(deviceList));
finalUri.value = "${widget.sleepUri}?person=$personParam";
// 拼接参数 person
if (deviceList.isNotEmpty) {
// JSON 编码整个 deviceList 对象数组
String personParam = Uri.encodeComponent(jsonEncode(deviceList));
finalUri.value = "${widget.sleepUri}?person=$personParam";
} else {
finalUri.value = widget.sleepUri;
}
}
String? language = "";
if (AppConstants().ent_type == APPPackageType.MHT.code) {
if (mhLanguageController.selectLanguage != null) {
language = mhLanguageController.selectLanguage.value!.language_code;
}
} else {
finalUri.value = widget.sleepUri;
if (languageController.selectLanguage != null) {
language = languageController.selectLanguage.value!.language_code;
}
}
}
String? language = "";
if (AppConstants().ent_type == APPPackageType.MHT.code) {
if (mhLanguageController.selectLanguage != null) {
language = mhLanguageController.selectLanguage.value!.language_code;
}
} else {
if (languageController.selectLanguage != null) {
language = languageController.selectLanguage.value!.language_code;
}
}
if (language != null && language.isNotEmpty) {
if (finalUri.value.contains("?")) {
finalUri.value += "&lang=$language";
} else {
finalUri.value += "?lang=$language";
if (language != null && language.isNotEmpty) {
if (finalUri.value.contains("?")) {
finalUri.value += "&lang=$language";
} else {
finalUri.value += "?lang=$language";
}
}
ef.log("msg");
} catch (e) {
ef.log(e.toString());
}
ef.log("msg");
}
// Future<void> getDeviceList() async {
// try {
// BodyDeviceController bodyDeviceController = Get.find();
// ApiResponse apiResponse =
// await bodyDeviceController.getDeviceList(isAllDevice: true);
// // 调试:打印返回的数据结构
// print('API响应数据: $apiResponse');
// print('API响应数据类型: ${apiResponse.data.runtimeType}');
// print('API响应数据内容: ${apiResponse.data}');
// if (apiResponse.code == HttpStatusCodes.ok) {
// List<dynamic> rawList = apiResponse.data;
// // 调试:检查 rawList 的类型和内容
// print('rawList 类型: ${rawList.runtimeType}');
// print('rawList 长度: ${rawList.length}');
// if (rawList.isNotEmpty) {
// print('rawList[0] 类型: ${rawList[0].runtimeType}');
// print('rawList[0] 内容: ${rawList[0]}');
// }
// // 安全处理:确保每个元素都是 Map
// List<Map<String, dynamic>> newList =
// rawList.whereType<Map>().map((item) {
// // 调试每个 item
// print('处理 item: $item');
// print('item 类型: ${item.runtimeType}');
// String mac = (item['mac'] ?? '').toString();
// String name = '未命名'.tr + "_${mac}";
// if (item['person'] != null && item['person'] is Map) {
// var person = item['person'] as Map;
// if (person['name'] != null &&
// person['name'].toString().trim().isNotEmpty) {
// name = '${person['name']}_${mac}';
// }
// }
// return {
// 'mac': mac,
// 'name': name,
// };
// }).toList();
// deviceList.value = newList;
// // 拼接参数 person
// if (deviceList.isNotEmpty) {
// // JSON 编码整个 deviceList 对象数组
// String personParam = Uri.encodeComponent(jsonEncode(deviceList));
// finalUri.value = "${widget.sleepUri}?person=$personParam";
// } else {
// finalUri.value = widget.sleepUri;
// }
// }
// // ... 后续语言处理代码不变
// } catch (e) {
// print('getDeviceList 错误详情: $e');
// print('错误堆栈: ${e}');
// ef.log(e.toString());
// }
// }
}

View File

@@ -1106,7 +1106,6 @@ class _HomePageState extends State<HomePage> {
if (currentIndex >= device_bind_process.length) return;
String code = device_bind_process[currentIndex]['mac'];
showUnBindTipDialog(
context,
Column(
@@ -1145,6 +1144,7 @@ class _HomePageState extends State<HomePage> {
),
],
),
textAlign: TextAlign.center, // 添加这一行
),
],
),
@@ -1208,6 +1208,12 @@ class _HomePageState extends State<HomePage> {
device_bind_process.removeAt(currentIndex);
showNextDialog();
},
onNoTipChanged: (value) {
updateDeviceTipStatus(
code, device_bind_process[currentIndex], value);
// device_bind_process.removeAt(currentIndex);
// showNextDialog();
},
);
}
@@ -1252,9 +1258,11 @@ class _HomePageState extends State<HomePage> {
bool celibration = res.data['celibration'];
bool person_info = res.data['person_info'];
bool wifi = res.data['wifi'];
if (!celibration || !person_info || !wifi) {
res.data['device_info'] = element;
userInfoController.device_bind_status.add(res.data);
if (res.data['noTip'] == null || res.data['noTip'] == false) {
if (!celibration || !person_info || !wifi) {
res.data['device_info'] = element;
userInfoController.device_bind_status.add(res.data);
}
}
}
} catch (e) {
@@ -1267,4 +1275,43 @@ class _HomePageState extends State<HomePage> {
print("查询设备绑定列表失败: $e");
}
}
void updateDeviceTipStatus(String mac, Map config, bool noTip) {
try {
String serviceAddress = ServiceConstant.service_address;
String serviceName = ServiceConstant.server_service;
String serviceApi = ServiceConstant.user_setting;
String type = "device_bind_status_$mac";
String queryUrl =
"${serviceAddress}${serviceName}${serviceApi}?type=${type}";
requestWithLog(
logTitle: "查询绑定流程",
method: MyHttpMethod.get,
queryUrl: queryUrl,
onSuccess: (res) {
print(res);
Map<String, dynamic> data = {
"type": type,
"mac": mac,
"wifi": res.data['wifi'],
"celibration": res.data['celibration'],
"person_info": res.data['person_info'],
"noTip": noTip,
"time": DateTime.now().millisecondsSinceEpoch,
};
requestWithLog(
logTitle: "更新绑定流程",
method: MyHttpMethod.put,
queryUrl: queryUrl,
data: data,
onSuccess: (res) {},
onFailure: (res) {},
);
},
onFailure: (res) {},
);
} catch (e) {
ef.log("$e");
}
}
}

View File

@@ -37,7 +37,7 @@ class _MessagePageState extends State<MessagePage> {
// 监听切换语言
subscription = EventBus().on<SwitchLanguageEvent>().listen((event) {
ef.log("切换语言事件通知:${event.language}");
ef.log("切换语言事件通知:${event.language}");
_fetchMessageData();
});
_fetchMessageData();
@@ -255,7 +255,7 @@ class _MessagePageState extends State<MessagePage> {
10.rpx, // 动态设置左侧位置
child: Container(
width: lineWidth,
height: 4.rpx,
height: 5.rpx,
decoration: BoxDecoration(
color: themeController.currentColor.sc2,
borderRadius:

View File

@@ -208,17 +208,17 @@ class _MinePageState extends State<MinePage> {
final user =
userInfoController
.model.user!;
if (user.email != null &&
user.email!
.isNotEmpty) {
return user.email!;
} else if (user.phone !=
null &&
if (user.phone != null &&
user.phone!
.isNotEmpty) {
return MyUtils
.hidePhoneNumber(
user.phone!);
} else if (user.email !=
null &&
user.email!
.isNotEmpty) {
return user.email!;
} else {
return "微信用户".tr;
}
@@ -690,7 +690,7 @@ class _MinePageState extends State<MinePage> {
mainAxisSize: MainAxisSize.max,
children: [
Text(
'V1.0.2511.21',
'V1.0.2512.03',
style: TextStyle(
fontFamily: 'Inter',
// color: Color(0xFFD9E3EB),