1.修复睡眠日报中睡眠规律性数据显示错误
2.更新时区设置
This commit is contained in:
@@ -2,6 +2,7 @@ import 'dart:convert';
|
||||
|
||||
import 'package:EasyDartModule/EasyDartModule.dart';
|
||||
import 'package:ef/ef.dart';
|
||||
import 'package:flutterflow_ui/flutterflow_ui.dart';
|
||||
import 'package:json_annotation/json_annotation.dart';
|
||||
import 'package:vbvs_app/common/color/ServiceConstant.dart';
|
||||
import 'package:vbvs_app/common/color/appConstants.dart';
|
||||
@@ -9,6 +10,7 @@ import 'package:vbvs_app/common/color/app_uri_status.dart';
|
||||
import 'package:vbvs_app/common/pojo/city.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/enum/APPPackageType.dart';
|
||||
import 'package:vbvs_app/model/api_response.dart';
|
||||
|
||||
@@ -50,6 +52,7 @@ class PersonController extends GetControllerEx<PersonModel> {
|
||||
RxString height = "".obs;
|
||||
DateTime? dateTime = DateTime.now(); //选择时间
|
||||
CityModel? cityModel;
|
||||
RxString timeZone = "".obs; //选择时区
|
||||
|
||||
RxList diseaseList = [].obs;
|
||||
RxString update_person_mac = "".obs;
|
||||
@@ -79,10 +82,10 @@ class PersonController extends GetControllerEx<PersonModel> {
|
||||
queryUrl += "?lang=$language";
|
||||
}
|
||||
}
|
||||
if (name.value.isEmpty) {
|
||||
apiResponse.msg = "请输入姓名".tr;
|
||||
return apiResponse;
|
||||
}
|
||||
// if (name.value.isEmpty) {
|
||||
// apiResponse.msg = "请输入姓名".tr;
|
||||
// return apiResponse;
|
||||
// }
|
||||
if (birthday.value.isEmpty) {
|
||||
apiResponse.msg = "请选择生日".tr;
|
||||
return apiResponse;
|
||||
@@ -95,10 +98,14 @@ class PersonController extends GetControllerEx<PersonModel> {
|
||||
apiResponse.msg = "请输入身高".tr;
|
||||
return apiResponse;
|
||||
}
|
||||
if (cityModel == null || cityModel!.id == null) {
|
||||
apiResponse.msg = "请选择城市".tr;
|
||||
if (timeZone == null || timeZone.value.isEmpty) {
|
||||
apiResponse.msg = "请选择时区".tr;
|
||||
return apiResponse;
|
||||
}
|
||||
// if (cityModel == null || cityModel!.id == null) {
|
||||
// apiResponse.msg = "请选择城市".tr;
|
||||
// return apiResponse;
|
||||
// }
|
||||
|
||||
var data = {
|
||||
"id": currentPersonId.value,
|
||||
@@ -110,8 +117,8 @@ class PersonController extends GetControllerEx<PersonModel> {
|
||||
"weight": weight!.value,
|
||||
"height": height.value,
|
||||
"disease": selectedDiseaseIds.value,
|
||||
"city_id": cityModel!.id,
|
||||
"UTC": cityModel!.UTC,
|
||||
"city_id": cityModel?.id,
|
||||
"UTC": timeZone.value,
|
||||
};
|
||||
var response =
|
||||
await EasyDartModule.dio.put(queryUrl, data: jsonEncode(data));
|
||||
@@ -240,4 +247,35 @@ class PersonController extends GetControllerEx<PersonModel> {
|
||||
}
|
||||
return ApiResponse(code: -1, msg: "未知错误".tr); // Default return statement
|
||||
}
|
||||
|
||||
getTimeZoneByLocalTime() async {
|
||||
String serviceAddress = ServiceConstant.service_address;
|
||||
String serviceName = ServiceConstant.server_service;
|
||||
String serviceApi = ServiceConstant.localTimeZone;
|
||||
|
||||
// 获取当前本地时间并格式化为字符串
|
||||
DateTime now = DateTime.now();
|
||||
String time = DateFormat("yyyy-MM-dd HH:mm:ss").format(now);
|
||||
|
||||
// 构建查询URL,对时间参数进行URL编码
|
||||
String queryUrl =
|
||||
"${serviceAddress}${serviceName}${serviceApi}?time=${Uri.encodeComponent(time)}";
|
||||
|
||||
String serverTimeUtc = "";
|
||||
// 发起请求
|
||||
await requestWithLog(
|
||||
logTitle: "查询本地时区",
|
||||
method: MyHttpMethod.get,
|
||||
queryUrl: queryUrl,
|
||||
onSuccess: (res) {
|
||||
print("本地时间: $time");
|
||||
print("接口返回: $res");
|
||||
serverTimeUtc = res.data;
|
||||
},
|
||||
onFailure: (res) {
|
||||
print("查询时区失败");
|
||||
},
|
||||
);
|
||||
return serverTimeUtc;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user