地址接口的视线
This commit is contained in:
@@ -39,8 +39,9 @@ class PeopleInfoController extends GetControllerEx<PeopleInfoModel> {
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> initData(String mac) async {
|
||||
await getPeoples(mac); // 控制器创建时立即执行
|
||||
Future<void> onInit() async {
|
||||
super.onInit();
|
||||
await getPeoples(Get.arguments['mac']); // 控制器创建时立即执行
|
||||
}
|
||||
|
||||
getPeoples(String mac) async {
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
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/color/appConstants.dart';
|
||||
import 'package:vbvs_app/common/util/requestWithLog.dart';
|
||||
import 'package:vbvs_app/model/api_response.dart';
|
||||
import 'apply_repair_controller.dart';
|
||||
part 'repair_list_controller.g.dart';
|
||||
|
||||
@@ -11,7 +14,7 @@ class RepairListModel {
|
||||
bool isLoading = false;
|
||||
bool hasMore = true;
|
||||
|
||||
List<ApplyRepairModel> repairList = [];
|
||||
List repairList = [];
|
||||
|
||||
RepairListModel();
|
||||
static RepairListModel fromJson(Map<String, dynamic> json) =>
|
||||
@@ -20,34 +23,32 @@ class RepairListModel {
|
||||
}
|
||||
|
||||
class RepairListController extends GetControllerEx<RepairListModel> {
|
||||
// RepairRepository repairRepository = RepairRepository();
|
||||
RepairListController() {
|
||||
attr = GetModel(RepairListModel()).obs;
|
||||
}
|
||||
|
||||
// //初始化列表数据
|
||||
// Future<void> initData() async {
|
||||
// if (model.isLoading) {
|
||||
// return;
|
||||
// }
|
||||
// model.isLoading = true;
|
||||
// final List<dynamic> fetchedRepairs = await repairRepository.fetchRepairs(
|
||||
// limit: model.limit, offset: model.offset);
|
||||
// if (fetchedRepairs != null) {
|
||||
// List<ApplyRepairModel> infos = [];
|
||||
// List<dynamic> tmp = fetchedRepairs as List<dynamic>;
|
||||
// try {
|
||||
// infos = tmp.map((repair) => ApplyRepairModel.fromJson(repair)).toList();
|
||||
// model.repairList.addAll(infos);
|
||||
// } catch (e) {
|
||||
// print('Error parsing JSON: $e');
|
||||
// }
|
||||
// }
|
||||
// model.offset += model.limit; // 更新 offset,下一次查询跳过当前已经加载的记录
|
||||
// model.hasMore = fetchedRepairs.length == model.limit; // 判断是否还有更多数据
|
||||
// model.isLoading = false;
|
||||
// updateAll();
|
||||
// }
|
||||
//初始化列表数据
|
||||
@override
|
||||
Future<void> onInit() async {
|
||||
super.onInit();
|
||||
await getRepairList();
|
||||
}
|
||||
|
||||
getRepairList() async {
|
||||
String serviceAddress = ServiceConstant.service_address;
|
||||
String serviceName = ServiceConstant.server_service;
|
||||
String serviceApi = ServiceConstant.submit_repair;
|
||||
String queryUrl = "${serviceAddress}${serviceName}${serviceApi}";
|
||||
requestWithLog(
|
||||
logTitle: "查询报修数据",
|
||||
method: MyHttpMethod.get,
|
||||
queryUrl: queryUrl,
|
||||
onSuccess: (res) {
|
||||
model.repairList = res.data;
|
||||
updateAll();
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
// Future<String> addScore(int id, int score) async {
|
||||
// return await repairRepository.addScore(id, score);
|
||||
|
||||
@@ -108,74 +108,4 @@ class RepairController extends GetControllerEx<RepairModel> {
|
||||
return ApiResponse(code: -1, msg: "服务器.失败".tr);
|
||||
}
|
||||
}
|
||||
|
||||
// Future<ApiResponse> uploadImg() async {
|
||||
// EasyDartModule.logger.info("请求上传媒体文件");
|
||||
// DailyLogUtils.writeLog("请求上传媒体文件");
|
||||
// final ImagePicker picker = ImagePicker();
|
||||
// final XFile? file = await picker.pickMedia(); // ✅ 支持图片或视频
|
||||
|
||||
// try {
|
||||
// ApiResponse apiResponse = ApiResponse(code: -1, msg: "我的.媒体上传失败".tr);
|
||||
// if (file == null) {
|
||||
// apiResponse.msg = "我的.未选择文件".tr;
|
||||
// return apiResponse;
|
||||
// }
|
||||
|
||||
// final String filePath = file.path;
|
||||
// final String fileName = filePath.split('/').last;
|
||||
// final int fileSize = await file.length();
|
||||
|
||||
// final isImage = filePath.endsWith(".jpg") ||
|
||||
// filePath.endsWith(".jpeg") ||
|
||||
// filePath.endsWith(".png") ||
|
||||
// filePath.endsWith(".gif");
|
||||
// final isVideo = filePath.endsWith(".mp4") ||
|
||||
// filePath.endsWith(".mov") ||
|
||||
// filePath.endsWith(".avi") ||
|
||||
// filePath.endsWith(".mkv");
|
||||
|
||||
// // 限制大小
|
||||
// if (isImage && fileSize > 1048576 * 5) {
|
||||
// apiResponse.msg = "上传限制(图片最大5MB)".tr;
|
||||
// return apiResponse;
|
||||
// } else if (isVideo && fileSize > 1048576 * 50) {
|
||||
// apiResponse.msg = "上传限制(视频最大50MB)".tr;
|
||||
// return apiResponse;
|
||||
// }
|
||||
|
||||
// // 构建上传地址
|
||||
// String queryUrl =
|
||||
// "${ServiceConstant.service_address}${ServiceConstant.server_service}${ServiceConstant.upload_file}";
|
||||
// String? language =
|
||||
// languageController.selectLanguage?.value?.language_code;
|
||||
// if (language != null && language.isNotEmpty) {
|
||||
// queryUrl +=
|
||||
// queryUrl.contains("?") ? "&lang=$language" : "?lang=$language";
|
||||
// }
|
||||
|
||||
// // 构建 formData
|
||||
// var formData = dio.FormData.fromMap({
|
||||
// "type": 2,
|
||||
// "file": await dio.MultipartFile.fromFile(filePath, filename: fileName),
|
||||
// });
|
||||
|
||||
// var response = await EasyDartModule.dio.post(queryUrl, data: formData);
|
||||
// if (response != null) {
|
||||
// var responseData =
|
||||
// response.data is String ? jsonDecode(response.data) : response.data;
|
||||
// ApiResponse res =
|
||||
// ApiResponse.fromJson(responseData, (object) => object);
|
||||
// MyUtils.formatResponse(res, "我的.上传成功".tr, "我的.媒体上传失败".tr);
|
||||
// updateAll();
|
||||
// return res;
|
||||
// } else {
|
||||
// return ApiResponse(code: -1, msg: "服务器.失败".tr);
|
||||
// }
|
||||
// } catch (e) {
|
||||
// EasyDartModule.logger.error("上传媒体失败->$e");
|
||||
// DailyLogUtils.writeError("上传媒体失败->$e");
|
||||
// return ApiResponse(code: -1, msg: "服务器.失败".tr);
|
||||
// }
|
||||
// }
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user