更新短信第二次登录报错的问题
This commit is contained in:
@@ -117,9 +117,9 @@ class _MHTBindDeviceSuccessState extends State<MHTBindDeviceSuccess> {
|
||||
});
|
||||
}
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
if (homeController.sleepDays.value.isNotEmpty) {
|
||||
if (homeController.homeSleepDays.value.isNotEmpty) {
|
||||
homeController.selectedDayIndex.value =
|
||||
homeController.sleepDays.value.length - 1;
|
||||
homeController.homeSleepDays.value.length - 1;
|
||||
}
|
||||
});
|
||||
Get.until((route) =>
|
||||
@@ -347,9 +347,9 @@ class _MHTBindDeviceSuccessState extends State<MHTBindDeviceSuccess> {
|
||||
});
|
||||
}
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
if (homeController.sleepDays.value.isNotEmpty) {
|
||||
if (homeController.homeSleepDays.value.isNotEmpty) {
|
||||
homeController.selectedDayIndex.value =
|
||||
homeController.sleepDays.value.length - 1;
|
||||
homeController.homeSleepDays.value.length - 1;
|
||||
}
|
||||
});
|
||||
Get.until((route) =>
|
||||
|
||||
@@ -47,6 +47,8 @@ class MHTHomeController extends GetControllerEx<MHTHomeModel> {
|
||||
|
||||
String wifiMac = "";
|
||||
var sleepDays = [].obs;
|
||||
var homeSleepDays = [].obs;
|
||||
|
||||
|
||||
var selectedDayIndex = (6).obs;
|
||||
|
||||
@@ -426,4 +428,71 @@ class MHTHomeController extends GetControllerEx<MHTHomeModel> {
|
||||
},
|
||||
);
|
||||
}
|
||||
Future<void> getHomeSleeps(String? mac) async {
|
||||
String serviceAddress = ServiceConstant.service_address;
|
||||
String serviceName = ServiceConstant.server_service;
|
||||
String serviceApi = ServiceConstant.sleep_report;
|
||||
String queryUrl = "$serviceAddress$serviceName$serviceApi";
|
||||
|
||||
// 当前时间的毫秒时间戳
|
||||
int timestamp = DateTime.now().millisecondsSinceEpoch;
|
||||
|
||||
// 拼接参数
|
||||
List<String> queryParams = [];
|
||||
|
||||
if (mac != null && mac.isNotEmpty) {
|
||||
queryParams.add("mac=$mac");
|
||||
}
|
||||
queryParams.add("time=$timestamp");
|
||||
|
||||
if (queryParams.isNotEmpty) {
|
||||
queryUrl += "?${queryParams.join("&")}";
|
||||
}
|
||||
|
||||
await requestWithLog(
|
||||
logTitle: "请求睡眠信息列表",
|
||||
method: MyHttpMethod.get,
|
||||
queryUrl: queryUrl,
|
||||
onSuccess: (res) {
|
||||
if (res.data != null && res.data is List) {
|
||||
List<dynamic> rawList = res.data;
|
||||
List<Map<String, dynamic>> processedList =
|
||||
rawList.map<Map<String, dynamic>>((item) {
|
||||
Map<String, dynamic> map = Map<String, dynamic>.from(item);
|
||||
|
||||
// 取出 time
|
||||
String? timeStr = map['time'];
|
||||
int? timeMillis = timeStr != null ? int.tryParse(timeStr) : null;
|
||||
|
||||
if (timeMillis != null) {
|
||||
DateTime dateTime =
|
||||
DateTime.fromMillisecondsSinceEpoch(timeMillis);
|
||||
|
||||
// 格式化 week 和 date
|
||||
String week = MyUtils.formatDateTimeWeek(dateTime);
|
||||
String date = MyUtils.formatDateTimeDay(dateTime);
|
||||
|
||||
// 添加到 map 中
|
||||
map['week'] = week;
|
||||
map['date'] = date;
|
||||
}
|
||||
|
||||
return map;
|
||||
}).toList();
|
||||
|
||||
// 赋值给 sleepDays
|
||||
homeSleepDays.value = processedList;
|
||||
} else {
|
||||
// 为空时直接赋空数组
|
||||
homeSleepDays.value = [];
|
||||
}
|
||||
|
||||
// 更新UI
|
||||
updateAll();
|
||||
},
|
||||
onFailure: (res) {
|
||||
EasyDartModule.logger.warning("请求睡眠信息列表失败: ${res.msg}");
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,7 +9,6 @@ import 'package:vbvs_app/common/util/MyUtils.dart';
|
||||
import 'package:vbvs_app/component/NullDataComponentWidget.dart';
|
||||
import 'package:vbvs_app/component/tool/ClickableContainer.dart';
|
||||
import 'package:vbvs_app/component/tool/TopSlideNotification.dart';
|
||||
import 'package:vbvs_app/controller/home/home_controller.dart';
|
||||
import 'package:vbvs_app/controller/main_bottom/global_controller.dart';
|
||||
import 'package:vbvs_app/controller/user_info_controller.dart';
|
||||
import 'package:vbvs_app/controller/weather/weather_controller.dart';
|
||||
@@ -67,9 +66,9 @@ class _NewHomePageState extends State<NewHomePage> {
|
||||
});
|
||||
}
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
if (homeController.sleepDays.value.isNotEmpty) {
|
||||
if (homeController.homeSleepDays.value.isNotEmpty) {
|
||||
homeController.selectedDayIndex.value =
|
||||
homeController.sleepDays.value.length - 1;
|
||||
homeController.homeSleepDays.value.length - 1;
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -315,7 +314,7 @@ class _NewHomePageState extends State<NewHomePage> {
|
||||
homeController.selectDevcie.value =
|
||||
list[0]["mac"];
|
||||
deviceController
|
||||
.getSleeps(formFieldController.value);
|
||||
.getHomeSleeps(formFieldController.value);
|
||||
homeController.updateAll();
|
||||
});
|
||||
}
|
||||
@@ -429,7 +428,7 @@ class _NewHomePageState extends State<NewHomePage> {
|
||||
print("$val");
|
||||
if (val == null) {
|
||||
homeController
|
||||
.sleepDays
|
||||
.homeSleepDays
|
||||
.value = [];
|
||||
} else {
|
||||
homeController
|
||||
@@ -438,7 +437,7 @@ class _NewHomePageState extends State<NewHomePage> {
|
||||
formFieldController
|
||||
.value!;
|
||||
deviceController
|
||||
.getSleeps(
|
||||
.getHomeSleeps(
|
||||
formFieldController
|
||||
.value);
|
||||
homeController
|
||||
@@ -532,11 +531,11 @@ class _NewHomePageState extends State<NewHomePage> {
|
||||
),
|
||||
),
|
||||
if (homeController
|
||||
.sleepDays.value.length ==
|
||||
.homeSleepDays.value.length ==
|
||||
0)
|
||||
Expanded(child: NullDataWidget()),
|
||||
if (homeController
|
||||
.sleepDays.value.length !=
|
||||
.homeSleepDays.value.length !=
|
||||
0)
|
||||
Container(
|
||||
padding: EdgeInsets.only(
|
||||
@@ -556,11 +555,11 @@ class _NewHomePageState extends State<NewHomePage> {
|
||||
children: [
|
||||
...List.generate(
|
||||
homeController
|
||||
.sleepDays
|
||||
.homeSleepDays
|
||||
.value
|
||||
.length, (index) {
|
||||
var day = homeController
|
||||
.sleepDays[index];
|
||||
.homeSleepDays[index];
|
||||
bool isSelected =
|
||||
homeController
|
||||
.selectedDayIndex
|
||||
|
||||
@@ -21,16 +21,16 @@ class LoginModel {
|
||||
//版本id
|
||||
int? loginStyle = 1; //1.密码登录 2.短信登录(登录类型: 1:手机号/邮箱+验证码 2:微信一键登录 3:手机号+密码)
|
||||
|
||||
String? account = '17649984946'; //账户
|
||||
// String? account = '17649984946'; //账户
|
||||
// String? account = '13953240733'; //账户
|
||||
String? password = '123wyf..'; //密码
|
||||
// String? password = '123wyf..'; //密码
|
||||
// String? account = '15255134931'; //账户
|
||||
// String? password = 'mht123,.'; //密码
|
||||
|
||||
// String? account = '18607922869'; //账户
|
||||
// String? password = '373068'; //密码
|
||||
// String? account = ''; //账户
|
||||
// String? password = ''; //密码
|
||||
String? account = ''; //账户
|
||||
String? password = ''; //密码
|
||||
|
||||
String? phone; //手机号
|
||||
String? code; //验证码
|
||||
@@ -136,7 +136,7 @@ class MHTLoginController extends GetControllerEx<LoginModel> {
|
||||
}
|
||||
var data = {
|
||||
"type": type,
|
||||
"userName": model.account,
|
||||
"userName": account,
|
||||
"password": password,
|
||||
};
|
||||
String serviceAddress = ServiceConstant.service_address;
|
||||
@@ -173,13 +173,13 @@ class MHTLoginController extends GetControllerEx<LoginModel> {
|
||||
|
||||
Future<String> getCode(BuildContext context) async {
|
||||
String message = "";
|
||||
if (registerController.model.register_agree == null ||
|
||||
registerController.model.register_agree != true) {
|
||||
message = "需要同意协议".tr;
|
||||
TopSlideNotification.show(context,
|
||||
text: message, textColor: themeController.currentColor.sc9);
|
||||
return message;
|
||||
}
|
||||
// if (registerController.model.register_agree == null ||
|
||||
// registerController.model.register_agree != true) {
|
||||
// message = "需要同意协议".tr;
|
||||
// TopSlideNotification.show(context,
|
||||
// text: message, textColor: themeController.currentColor.sc9);
|
||||
// return message;
|
||||
// }
|
||||
if (model.phone == null || model.phone!.isEmpty) {
|
||||
message = "请输入手机号".tr;
|
||||
TopSlideNotification.show(context,
|
||||
|
||||
Reference in New Issue
Block a user