棉花app新增页面
This commit is contained in:
31
lib/controller/main_bottom/main_page_b_controller.dart
Normal file
31
lib/controller/main_bottom/main_page_b_controller.dart
Normal file
@@ -0,0 +1,31 @@
|
||||
import 'package:ef/ef.dart';
|
||||
import 'package:json_annotation/json_annotation.dart';
|
||||
import 'package:vbvs_app/controller/main_bottom/main_page_controller.dart';
|
||||
part 'main_page_b_controller.g.dart';
|
||||
|
||||
@JsonSerializable()
|
||||
class MainPageBModel {
|
||||
int currentIndex = 0;
|
||||
MainPageBModel();
|
||||
factory MainPageBModel.fromJson(Map<String, dynamic> json) {
|
||||
try {
|
||||
return _$MainPageBModelFromJson(json);
|
||||
} catch (e) {
|
||||
// 在实际应用中,应该有更细致的异常处理策略和错误日志
|
||||
return MainPageBModel(); // 或者返回一个带有错误信息的特定DeviceInfoModel实例
|
||||
}
|
||||
}
|
||||
|
||||
// 序列化为JSON时的异常处理
|
||||
Map<String, dynamic> toJson() => _$MainPageBModelToJson(this);
|
||||
}
|
||||
|
||||
class MainPageBController extends GetControllerEx<MainPageBModel> {
|
||||
MainPageBController() {
|
||||
attr = GetModel(MainPageBModel()).obs;
|
||||
}
|
||||
|
||||
resetParm() {
|
||||
model.currentIndex = 0;
|
||||
}
|
||||
}
|
||||
15
lib/controller/main_bottom/main_page_b_controller.g.dart
Normal file
15
lib/controller/main_bottom/main_page_b_controller.g.dart
Normal file
@@ -0,0 +1,15 @@
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
|
||||
part of 'main_page_b_controller.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// JsonSerializableGenerator
|
||||
// **************************************************************************
|
||||
|
||||
MainPageBModel _$MainPageBModelFromJson(Map<String, dynamic> json) =>
|
||||
MainPageBModel()..currentIndex = (json['currentIndex'] as num).toInt();
|
||||
|
||||
Map<String, dynamic> _$MainPageBModelToJson(MainPageBModel instance) =>
|
||||
<String, dynamic>{
|
||||
'currentIndex': instance.currentIndex,
|
||||
};
|
||||
155
lib/controller/mh/address_controller.dart
Normal file
155
lib/controller/mh/address_controller.dart
Normal file
@@ -0,0 +1,155 @@
|
||||
import 'package:ef/ef.dart';
|
||||
import 'package:flutter_city_picker/model/address.dart';
|
||||
import 'package:flutterflow_ui/flutterflow_ui.dart';
|
||||
import 'package:json_annotation/json_annotation.dart';
|
||||
import 'package:vbvs_app/controller/mh/user_data.dart';
|
||||
import 'package:vbvs_app/controller/mh/muser_info_controller.dart';
|
||||
|
||||
part 'address_controller.g.dart';
|
||||
|
||||
@JsonSerializable()
|
||||
class AddressModel {
|
||||
//版本id
|
||||
String? province; //省份
|
||||
String? city; //市
|
||||
String? county; //区
|
||||
String? street; //街道
|
||||
String? detail; //详细信息
|
||||
String? name; //名字
|
||||
String? phone; //手机号
|
||||
bool? ischecked = false; //是否默认
|
||||
|
||||
int currentType = 0;
|
||||
String? all_address;
|
||||
@JsonKey(ignore: true)
|
||||
List<AddressNode>? addressList = [];
|
||||
|
||||
AddressModel();
|
||||
|
||||
static AddressModel fromJson(Map<String, dynamic> json) =>
|
||||
_$AddressModelFromJson(json);
|
||||
Map<String, dynamic> toJson() => _$AddressModelToJson(this);
|
||||
}
|
||||
|
||||
class AddressController extends GetControllerEx<AddressModel> {
|
||||
AddressController() {
|
||||
attr = GetModel(AddressModel()).obs;
|
||||
}
|
||||
|
||||
Future<String> updateAddress(
|
||||
Map<String, dynamic> address, AddressModel model) async {
|
||||
if (model.addressList != null && model.addressList!.isNotEmpty) {
|
||||
if (model.addressList!.length > 0) {
|
||||
address["province"] = model.addressList![0].name; // 第一个元素为省
|
||||
}
|
||||
if (model.addressList!.length > 1) {
|
||||
address["city"] = model.addressList![1].name; // 第二个元素为市
|
||||
}
|
||||
if (model.addressList!.length > 2) {
|
||||
address["county"] = model.addressList![2].name; // 第三个元素为区
|
||||
}
|
||||
if (model.addressList!.length > 3) {
|
||||
address["street"] = model.addressList![3].name; // 第四个元素为街道
|
||||
}
|
||||
}
|
||||
address['detail'] = model.detail;
|
||||
address['name'] = model.name;
|
||||
address['phone'] = model.phone;
|
||||
address['isChecked'] = model.ischecked;
|
||||
|
||||
try {
|
||||
final data = await ef.client.rpc("get_now_datetime");
|
||||
final response = await ef.client.from("app_user_address").update({
|
||||
'province': address["province"],
|
||||
'city': address["city"],
|
||||
'county': address["county"],
|
||||
'street': address["street"],
|
||||
'detail': address["detail"],
|
||||
'name': address["name"],
|
||||
'phone': address["phone"],
|
||||
'ischecked': address['isChecked'] ? 1 : 0,
|
||||
'update_time':
|
||||
DateFormat("yyyy-MM-dd HH:mm:ss").parse("$data").toString(),
|
||||
}).eq("id", address['id']);
|
||||
} catch (e) {
|
||||
print('Error fetching repairs: $e');
|
||||
return e.toString();
|
||||
}
|
||||
return '';
|
||||
}
|
||||
|
||||
addAddress(AddressModel model) async {
|
||||
try {
|
||||
final MUserInfoController userInfoController =
|
||||
Get.find<MUserInfoController>();
|
||||
UserModel user = userInfoController.model.user!;
|
||||
|
||||
// 设置省市区街道名称
|
||||
if (model.addressList != null && model.addressList!.isNotEmpty) {
|
||||
if (model.addressList!.length > 0)
|
||||
model.province = model.addressList![0].name; // 第一个元素为省
|
||||
if (model.addressList!.length > 1)
|
||||
model.city = model.addressList![1].name; // 第二个元素为市
|
||||
if (model.addressList!.length > 2)
|
||||
model.county = model.addressList![2].name; // 第三个元素为区
|
||||
if (model.addressList!.length > 3)
|
||||
model.street = model.addressList![3].name; // 第四个元素为街道
|
||||
}
|
||||
|
||||
// 查询数据库是否已有该用户的地址
|
||||
final existingAddresses = await ef.client
|
||||
.from('app_user_address')
|
||||
.select()
|
||||
.eq('user_id', user.uid!);
|
||||
|
||||
// 如果没有地址,将新增地址默认选中
|
||||
if (existingAddresses.isEmpty) {
|
||||
model.ischecked = true;
|
||||
} else if (model.ischecked == true) {
|
||||
// 如果新地址被选中,将其他地址的 `ischecked` 字段设为 `0`
|
||||
await ef.client
|
||||
.from('app_user_address')
|
||||
.update({'ischecked': 0}).eq('user_id', user.uid!);
|
||||
}
|
||||
|
||||
// 添加新地址
|
||||
final response = await ef.client.from('app_user_address').insert({
|
||||
'province': model.province,
|
||||
'city': model.city,
|
||||
'county': model.county,
|
||||
'street': model.street,
|
||||
'detail': model.detail,
|
||||
'name': model.name,
|
||||
'phone': model.phone,
|
||||
'ischecked': model.ischecked! ? 1 : 0,
|
||||
'user_id': user.uid,
|
||||
});
|
||||
} catch (e) {
|
||||
print(e);
|
||||
}
|
||||
}
|
||||
|
||||
Future<List<AddressNode>> getData({int? level, int? pid}) async {
|
||||
// 构建查询
|
||||
var query = ef.from("app_area_city").select();
|
||||
|
||||
// 如果 pid 不为 null,添加 pid 的条件
|
||||
if (pid != null) {
|
||||
query = query.eq("pid", pid);
|
||||
}
|
||||
if (level != null) {
|
||||
query = query.eq("deep", level);
|
||||
}
|
||||
List arr = await query;
|
||||
|
||||
List<AddressNode> addressNodes = arr.map((item) {
|
||||
return AddressNode.fromJson({
|
||||
"name": item["ext_name"], // ext_name 对应 name
|
||||
"code": item["id"], // id 对应 code
|
||||
"letter": item["pinyin_prefix_upper"], // pinyin_prefix_upper 对应 letter
|
||||
});
|
||||
}).toList();
|
||||
|
||||
return addressNodes;
|
||||
}
|
||||
}
|
||||
33
lib/controller/mh/address_controller.g.dart
Normal file
33
lib/controller/mh/address_controller.g.dart
Normal file
@@ -0,0 +1,33 @@
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
|
||||
part of 'address_controller.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// JsonSerializableGenerator
|
||||
// **************************************************************************
|
||||
|
||||
AddressModel _$AddressModelFromJson(Map<String, dynamic> json) => AddressModel()
|
||||
..province = json['province'] as String?
|
||||
..city = json['city'] as String?
|
||||
..county = json['county'] as String?
|
||||
..street = json['street'] as String?
|
||||
..detail = json['detail'] as String?
|
||||
..name = json['name'] as String?
|
||||
..phone = json['phone'] as String?
|
||||
..ischecked = json['ischecked'] as bool?
|
||||
..currentType = (json['currentType'] as num).toInt()
|
||||
..all_address = json['all_address'] as String?;
|
||||
|
||||
Map<String, dynamic> _$AddressModelToJson(AddressModel instance) =>
|
||||
<String, dynamic>{
|
||||
'province': instance.province,
|
||||
'city': instance.city,
|
||||
'county': instance.county,
|
||||
'street': instance.street,
|
||||
'detail': instance.detail,
|
||||
'name': instance.name,
|
||||
'phone': instance.phone,
|
||||
'ischecked': instance.ischecked,
|
||||
'currentType': instance.currentType,
|
||||
'all_address': instance.all_address,
|
||||
};
|
||||
64
lib/controller/mh/address_list_controller.dart
Normal file
64
lib/controller/mh/address_list_controller.dart
Normal file
@@ -0,0 +1,64 @@
|
||||
import 'package:ef/ef.dart';
|
||||
import 'package:json_annotation/json_annotation.dart';
|
||||
|
||||
|
||||
part 'address_list_controller.g.dart';
|
||||
|
||||
@JsonSerializable()
|
||||
class AddressListModel {
|
||||
List addressList = [];
|
||||
Map address = {}; //之前控制的设备
|
||||
|
||||
int? type = 1; //1添加,2编辑
|
||||
|
||||
AddressListModel();
|
||||
|
||||
static AddressListModel fromJson(Map<String, dynamic> json) =>
|
||||
_$AddressListModelFromJson(json);
|
||||
Map<String, dynamic> toJson() => _$AddressListModelToJson(this);
|
||||
}
|
||||
|
||||
class AddressListController extends GetControllerEx<AddressListModel> {
|
||||
AddressListController() {
|
||||
attr = GetModel(AddressListModel()).obs;
|
||||
}
|
||||
|
||||
// getAddressList() async {
|
||||
// await ApiService.request.get("/api/address/info/list").then((d) {
|
||||
// model.addressList = d.data["data"] ?? [];
|
||||
// updateAll();
|
||||
// }).catchError((e) {
|
||||
// print("$e");
|
||||
// });
|
||||
// }
|
||||
|
||||
// //更新默认
|
||||
// Future<void> updateDefault(address) async {
|
||||
// var id = address['id'];
|
||||
// var uid = address['userId'];
|
||||
// try {
|
||||
// await ef.client
|
||||
// .from("app_user_address")
|
||||
// .update({
|
||||
// 'ischecked': 0,
|
||||
// })
|
||||
// .eq("user_id", address['userId'])
|
||||
// .eq("ischecked", 1);
|
||||
// await ef.client.from("app_user_address").update({
|
||||
// 'ischecked': 1,
|
||||
// }).eq("id", address['id']);
|
||||
// } catch (e) {
|
||||
// print('Error fetching repairs: $e');
|
||||
// }
|
||||
// }
|
||||
|
||||
// // 删除地址
|
||||
// Future<void> deleteAddress(String id) async {
|
||||
// try {
|
||||
// await ef.client.from("app_user_address").delete().eq("id", id);
|
||||
// print("Address with ID $id has been successfully deleted.");
|
||||
// } catch (e) {
|
||||
// print("Error deleting address with ID $id: $e");
|
||||
// }
|
||||
// }
|
||||
}
|
||||
20
lib/controller/mh/address_list_controller.g.dart
Normal file
20
lib/controller/mh/address_list_controller.g.dart
Normal file
@@ -0,0 +1,20 @@
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
|
||||
part of 'address_list_controller.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// JsonSerializableGenerator
|
||||
// **************************************************************************
|
||||
|
||||
AddressListModel _$AddressListModelFromJson(Map<String, dynamic> json) =>
|
||||
AddressListModel()
|
||||
..addressList = json['addressList'] as List<dynamic>
|
||||
..address = json['address'] as Map<String, dynamic>
|
||||
..type = (json['type'] as num?)?.toInt();
|
||||
|
||||
Map<String, dynamic> _$AddressListModelToJson(AddressListModel instance) =>
|
||||
<String, dynamic>{
|
||||
'addressList': instance.addressList,
|
||||
'address': instance.address,
|
||||
'type': instance.type,
|
||||
};
|
||||
198
lib/controller/mh/apply_repair_controller.dart
Normal file
198
lib/controller/mh/apply_repair_controller.dart
Normal file
@@ -0,0 +1,198 @@
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:ef/ef.dart';
|
||||
import 'package:flutter/src/widgets/framework.dart';
|
||||
import 'package:flutterflow_ui/flutterflow_ui.dart';
|
||||
import 'package:img_picker/img_picker.dart';
|
||||
import 'package:json_annotation/json_annotation.dart';
|
||||
|
||||
import 'package:path/path.dart' as p;
|
||||
import 'package:uuid/uuid.dart';
|
||||
import 'package:vbvs_app/common/util/MyUtils.dart';
|
||||
|
||||
import 'muser_info_controller.dart';
|
||||
|
||||
part 'apply_repair_controller.g.dart';
|
||||
|
||||
@JsonSerializable()
|
||||
class ApplyRepairModel {
|
||||
int? id; //报修id
|
||||
String? apply_name; //申请人名称
|
||||
String? tel; //手机号
|
||||
String? address; //地址
|
||||
String? desc; //问题描述
|
||||
DateTime? create_time; //创建时间
|
||||
|
||||
String? device_type; //类型 床,床垫 不能为空
|
||||
String? device_category; //型号 不能为空
|
||||
String? device_id; //序列号 设备id 不能为空
|
||||
|
||||
String? device_name; //名称 可为空
|
||||
|
||||
List<String>? issue_img = []; //图片
|
||||
int? imagesLImit = 3; //图片限制上传数量
|
||||
String? img_bucket = 'mianhuatang_repair';
|
||||
|
||||
String? status; //维修状态
|
||||
|
||||
String? select_device;
|
||||
// String? select_type;
|
||||
// List<String>? device_list = ['床垫/BY-H/智能床垫', '床垫/BY-A/智能床垫', '床垫/BY-C/智能床垫'];
|
||||
List<dynamic>? device_list = [];
|
||||
int? score;
|
||||
DateTime? score_time; //创建时间
|
||||
|
||||
int? messageType = 1; //消息类型
|
||||
int? repairId; //消息类型
|
||||
|
||||
ApplyRepairModel();
|
||||
static ApplyRepairModel fromJson(Map<String, dynamic> json) =>
|
||||
_$ApplyRepairModelFromJson(json);
|
||||
Map<String, dynamic> toJson() => _$ApplyRepairModelToJson(this);
|
||||
}
|
||||
|
||||
class ApplyRepairController extends GetControllerEx<ApplyRepairModel> {
|
||||
// RepairRepository repairRepository = RepairRepository();
|
||||
ApplyRepairController() {
|
||||
attr = GetModel(ApplyRepairModel()).obs;
|
||||
}
|
||||
|
||||
// //上传图片
|
||||
// Future<void> uploadImg() async {
|
||||
// final ImagePicker picker = ImagePicker();
|
||||
// final XFile? image = await picker.pickImage(source: ImageSource.gallery);
|
||||
// final user = Supabase.instance.client.auth.currentUser;
|
||||
// try {
|
||||
// if (image != null) {
|
||||
// int fileSize = await image.length(); // 获取图片大小,单位为字节
|
||||
// if (fileSize > 1024 * 1024 * 5) {
|
||||
// // 1 MB = 1024 * 1024 bytes
|
||||
// showToast("上传图片不能超过5MB");
|
||||
// return;
|
||||
// }
|
||||
// final filePath = image.path; // 获取文件路径
|
||||
// final fileExtension = p.extension(filePath); // 获取文件扩展名,包括点(.)
|
||||
// // 获取当前日期并格式化为 yyyy-MM-dd
|
||||
// final String folderName =
|
||||
// DateFormat('yyyy-MM-dd').format(DateTime.now());
|
||||
// final file = File(image.path);
|
||||
// // 构造文件路径,文件会被上传到 record_img 文件夹下的当天日期文件夹
|
||||
// var response = await ef.client.storage
|
||||
// .from(model.img_bucket!)
|
||||
// .upload('$folderName/${Uuid().v4()}$fileExtension', file);
|
||||
// if (response != null) {
|
||||
// String publicUrl =
|
||||
// ef.client.storage.from(model.img_bucket!).getPublicUrl(response);
|
||||
|
||||
// print('文件上传成功: $response');
|
||||
// print('文件上传成功: $publicUrl');
|
||||
// String prefixToRemove = 'mianhuatang_repair/';
|
||||
// model.issue_img!.add(response.startsWith(prefixToRemove)
|
||||
// ? response.substring(prefixToRemove.length)
|
||||
// : response);
|
||||
// updateAll();
|
||||
// }
|
||||
// print('/$model.img_bucket');
|
||||
// } else {
|
||||
// print('未选择图片');
|
||||
// return;
|
||||
// }
|
||||
// } catch (e) {
|
||||
// print('上传失败: $e');
|
||||
// }
|
||||
// }
|
||||
|
||||
// //提交
|
||||
// Future<String> submitRepair(BuildContext context) async {
|
||||
// //tmp
|
||||
// // return '';
|
||||
// String message = '';
|
||||
// final MyDialogController myDialogController =
|
||||
// Get.find<MyDialogController>();
|
||||
// if (model.device_type == null || model.device_type!.isEmpty) {
|
||||
// message = '请选择设备类型!';
|
||||
// showToast(message);
|
||||
// return message;
|
||||
// }
|
||||
// if (model.device_category == null || model.device_category!.isEmpty) {
|
||||
// message = '请输入设备型号!';
|
||||
// showToast(message);
|
||||
// return message;
|
||||
// }
|
||||
// if (model.device_id == null || model.device_id!.isEmpty) {
|
||||
// message = '请输入设备序列号id!';
|
||||
// showToast(message);
|
||||
// return message;
|
||||
// }
|
||||
// if (model.apply_name == null || model.apply_name!.isEmpty) {
|
||||
// message = '请输入姓名!';
|
||||
// showToast(message);
|
||||
// return message;
|
||||
// }
|
||||
// RegExp nameRegExp = RegExp(r'^[\u4e00-\u9fa5]{2,4}$');
|
||||
|
||||
// if (!nameRegExp.hasMatch(model.apply_name!)) {
|
||||
// message = '姓名必须为2到4个汉字!';
|
||||
// showToast(message);
|
||||
// return message;
|
||||
// }
|
||||
// if (model.tel == null || model.tel!.isEmpty) {
|
||||
// message = '请输入手机号!';
|
||||
// showToast(message);
|
||||
// return message;
|
||||
// }
|
||||
// if (!MyUtils.isValidPhoneNumber(model.tel!)) {
|
||||
// message = '无效的手机号!';
|
||||
// showToast(message);
|
||||
// return message;
|
||||
// }
|
||||
// if (model.address == null || model.address!.isEmpty) {
|
||||
// message = '请输入地址!';
|
||||
// showToast(message);
|
||||
// return message;
|
||||
// }
|
||||
// if (model.desc == null || model.desc!.isEmpty) {
|
||||
// message = '请输入问题描述!';
|
||||
// showToast(message);
|
||||
// return message;
|
||||
// }
|
||||
// if (model.issue_img == null || model.issue_img!.isEmpty) {
|
||||
// message = '请至少上传一张问题图片!';
|
||||
// showToast(message);
|
||||
// return message;
|
||||
// }
|
||||
// model.status = RepairStatus.pending;
|
||||
// await repairRepository.saveRepair(model);
|
||||
// return message;
|
||||
// }
|
||||
|
||||
// Future<void> getDeviceList() async {
|
||||
// final UserInfoController userInfoController =
|
||||
// Get.find<UserInfoController>();
|
||||
// // UserModel loginUser = userInfoController.model.user!;
|
||||
// DeviceListController deviceListController = Get.find();
|
||||
// await deviceListController.getDeviceList();
|
||||
// var aa = deviceListController.model.deviceListWyf;
|
||||
// ApplyRepairController applyRepairController = Get.find();
|
||||
// applyRepairController.model.device_list = aa;
|
||||
// }
|
||||
|
||||
// String getPublicUrl(String path) {
|
||||
// try {
|
||||
// String bucketPath = '${model.img_bucket}/';
|
||||
// if (path.contains(bucketPath)) {
|
||||
// int firstIndex = path.indexOf(bucketPath);
|
||||
// // int secondIndex =
|
||||
// // response.indexOf(bucketPath, firstIndex + bucketPath.length);
|
||||
// if (firstIndex != -1) {
|
||||
// // 去掉第一个存储桶路径
|
||||
// path = path.replaceFirst(bucketPath, '', firstIndex);
|
||||
// }
|
||||
// }
|
||||
// String publicUrl =
|
||||
// ef.client.storage.from(model.img_bucket!).getPublicUrl(path);
|
||||
// return publicUrl;
|
||||
// } catch (e) {}
|
||||
// return '';
|
||||
// }
|
||||
}
|
||||
60
lib/controller/mh/apply_repair_controller.g.dart
Normal file
60
lib/controller/mh/apply_repair_controller.g.dart
Normal file
@@ -0,0 +1,60 @@
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
|
||||
part of 'apply_repair_controller.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// JsonSerializableGenerator
|
||||
// **************************************************************************
|
||||
|
||||
ApplyRepairModel _$ApplyRepairModelFromJson(Map<String, dynamic> json) =>
|
||||
ApplyRepairModel()
|
||||
..id = (json['id'] as num?)?.toInt()
|
||||
..apply_name = json['apply_name'] as String?
|
||||
..tel = json['tel'] as String?
|
||||
..address = json['address'] as String?
|
||||
..desc = json['desc'] as String?
|
||||
..create_time = json['create_time'] == null
|
||||
? null
|
||||
: DateTime.parse(json['create_time'] as String)
|
||||
..device_type = json['device_type'] as String?
|
||||
..device_category = json['device_category'] as String?
|
||||
..device_id = json['device_id'] as String?
|
||||
..device_name = json['device_name'] as String?
|
||||
..issue_img = (json['issue_img'] as List<dynamic>?)
|
||||
?.map((e) => e as String)
|
||||
.toList()
|
||||
..imagesLImit = (json['imagesLImit'] as num?)?.toInt()
|
||||
..img_bucket = json['img_bucket'] as String?
|
||||
..status = json['status'] as String?
|
||||
..select_device = json['select_device'] as String?
|
||||
..device_list = json['device_list'] as List<dynamic>?
|
||||
..score = (json['score'] as num?)?.toInt()
|
||||
..score_time = json['score_time'] == null
|
||||
? null
|
||||
: DateTime.parse(json['score_time'] as String)
|
||||
..messageType = (json['messageType'] as num?)?.toInt()
|
||||
..repairId = (json['repairId'] as num?)?.toInt();
|
||||
|
||||
Map<String, dynamic> _$ApplyRepairModelToJson(ApplyRepairModel instance) =>
|
||||
<String, dynamic>{
|
||||
'id': instance.id,
|
||||
'apply_name': instance.apply_name,
|
||||
'tel': instance.tel,
|
||||
'address': instance.address,
|
||||
'desc': instance.desc,
|
||||
'create_time': instance.create_time?.toIso8601String(),
|
||||
'device_type': instance.device_type,
|
||||
'device_category': instance.device_category,
|
||||
'device_id': instance.device_id,
|
||||
'device_name': instance.device_name,
|
||||
'issue_img': instance.issue_img,
|
||||
'imagesLImit': instance.imagesLImit,
|
||||
'img_bucket': instance.img_bucket,
|
||||
'status': instance.status,
|
||||
'select_device': instance.select_device,
|
||||
'device_list': instance.device_list,
|
||||
'score': instance.score,
|
||||
'score_time': instance.score_time?.toIso8601String(),
|
||||
'messageType': instance.messageType,
|
||||
'repairId': instance.repairId,
|
||||
};
|
||||
74
lib/controller/mh/book_info_controller.dart
Normal file
74
lib/controller/mh/book_info_controller.dart
Normal file
@@ -0,0 +1,74 @@
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:ef/ef.dart';
|
||||
|
||||
|
||||
class BookInfoModel {
|
||||
// DateTime? dateTime; //预约时间
|
||||
String? userName; //预约人
|
||||
String? userPhone; //预约电话
|
||||
List time_period = []; //预约时段
|
||||
// String? select_time; //选择时间
|
||||
int? select_time_index; //选择时间
|
||||
|
||||
List datetimes = [];
|
||||
int? datetimes_index;
|
||||
Map dataT = {};
|
||||
|
||||
BookInfoModel();
|
||||
}
|
||||
|
||||
class BookInfoController extends GetControllerEx<BookInfoModel> {
|
||||
BookInfoController() {
|
||||
attr = GetModel(BookInfoModel()).obs;
|
||||
}
|
||||
|
||||
// get userInfoController => Get.find<UserInfoController>();
|
||||
|
||||
// getData(id) {
|
||||
// model.datetimes = [];
|
||||
// model.datetimes_index = null;
|
||||
// model.dataT = {};
|
||||
// updateAll();
|
||||
// ApiService.reservation.get("/agent/userBook/config/detailConfigByStore?storeId=$id")
|
||||
// .then((d) {
|
||||
// model.datetimes = d.data["dateList"];
|
||||
// model.datetimes_index = 0;
|
||||
// model.dataT = d.data;
|
||||
// time_periodChange();
|
||||
// });
|
||||
// }
|
||||
|
||||
// time_periodChange() {
|
||||
// if(model.datetimes_index == null) {
|
||||
// return;
|
||||
// }
|
||||
// model.select_time_index = null;
|
||||
// model.time_period = model.dataT[model.datetimes?[model.datetimes_index!]["day"]];
|
||||
// updateAll();
|
||||
// }
|
||||
|
||||
// submitData(id) {
|
||||
// String tel = userInfoController.model?.user?.tel ?? "";
|
||||
// if(tel.isEmpty) {
|
||||
// showToast("用户未存在手机号");
|
||||
// return;
|
||||
// }
|
||||
// return ApiService.reservation.post("/agent/userBook/submitBook", data: {
|
||||
// "extUserId": tel,
|
||||
// "storeId": id,
|
||||
// "realName": model.userName,
|
||||
// "userPhone": model.userPhone,
|
||||
// "bookDateId": model.time_period[model.select_time_index!]["id"]
|
||||
// });
|
||||
// }
|
||||
|
||||
// messageAdd(Map data) {
|
||||
// return ApiService.request.post("/api/message/info", data: {
|
||||
// "type": 0,
|
||||
// "status": 1,
|
||||
// "read": 1,
|
||||
// "data": jsonEncode(data)
|
||||
// });
|
||||
// }
|
||||
}
|
||||
125
lib/controller/mh/experience_store_list_page.dart
Normal file
125
lib/controller/mh/experience_store_list_page.dart
Normal file
@@ -0,0 +1,125 @@
|
||||
import 'dart:ui';
|
||||
|
||||
import 'package:ef/ef.dart';
|
||||
|
||||
|
||||
import 'package:json_annotation/json_annotation.dart';
|
||||
|
||||
part 'experience_store_list_page.g.dart';
|
||||
|
||||
@JsonSerializable()
|
||||
class ExperienceStoreListModel {
|
||||
List experienceStoreModelList = []; //体验店列
|
||||
|
||||
@JsonKey(ignore: true)
|
||||
String? keyword = '';
|
||||
@JsonKey(ignore: true)
|
||||
Color? color = Color(0xFFFFFFFF);
|
||||
|
||||
ExperienceStoreListModel();
|
||||
// static ExperienceStoreListModel fromJson(Map<String, dynamic> json) =>
|
||||
// _$ExperienceStoreListModelFromJson(json);
|
||||
// Map<String, dynamic> toJson() => _$ExperienceStoreListModelToJson(this);
|
||||
}
|
||||
|
||||
class ExperienceStoreListController
|
||||
extends GetControllerEx<ExperienceStoreListModel> {
|
||||
ExperienceStoreListController() {
|
||||
attr = GetModel(ExperienceStoreListModel()).obs;
|
||||
}
|
||||
|
||||
// Position? position;
|
||||
// double latitude = 31.8512;
|
||||
// double longitude = 117.26061;
|
||||
|
||||
// int total = 0;
|
||||
// int page = 0;
|
||||
// bool lock = false;
|
||||
|
||||
|
||||
// resetParm() {
|
||||
// position = null;
|
||||
// total = 0;
|
||||
// page = 0;
|
||||
// lock = false;
|
||||
// model.experienceStoreModelList = [];
|
||||
// updateAll();
|
||||
// }
|
||||
|
||||
// getData({int count = 10}) async {
|
||||
// if (page != 0 && page * count > total) {
|
||||
// return;
|
||||
// }
|
||||
// if (lock) {
|
||||
// return;
|
||||
// }
|
||||
// if (page == 0) {
|
||||
// position = await locationCheck();
|
||||
// }
|
||||
// lock = true;
|
||||
// int page_ = page;
|
||||
// ApiService.reservation
|
||||
// .get(
|
||||
// "/agent/userBook/config/getBookStoreList?storeName=${"${model.keyword}".isNotEmpty ? model.keyword : ''}&latitude=${position == null ? latitude : position?.latitude}&longitude=${position == null ? longitude : position?.longitude}&page=$page&size=$count&sort=distance")
|
||||
// .then((d) {
|
||||
// lock = false;
|
||||
// if (page == 0) {
|
||||
// model.experienceStoreModelList = d.data["records"];
|
||||
// } else {
|
||||
// int index = 0;
|
||||
// d.data["records"]?.forEach((item) {
|
||||
// if (model.experienceStoreModelList
|
||||
// .indexWhere((item2) => item2["id"] == item["id"]) ==
|
||||
// -1) {
|
||||
// model.experienceStoreModelList.add(item);
|
||||
// } else {
|
||||
// model.experienceStoreModelList[index] = item;
|
||||
// }
|
||||
// index++;
|
||||
// });
|
||||
// }
|
||||
// page = page_ + 1;
|
||||
// total = d.data["total"];
|
||||
// updateAll();
|
||||
// }).catchError((d) {
|
||||
// lock = false;
|
||||
// });
|
||||
// }
|
||||
|
||||
determinePosition() async {
|
||||
// bool serviceEnabled;
|
||||
// LocationPermission permission;
|
||||
|
||||
// // Test if location services are enabled.
|
||||
// serviceEnabled = await Geolocator.isLocationServiceEnabled();
|
||||
// if (!serviceEnabled) {
|
||||
// // Location services are not enabled don't continue
|
||||
// // accessing the position and request users of the
|
||||
// // App to enable the location services.
|
||||
// return Future.error('Location services are disabled.');
|
||||
// }
|
||||
|
||||
// permission = await Geolocator.checkPermission();
|
||||
// if (permission == LocationPermission.denied) {
|
||||
// permission = await Geolocator.requestPermission();
|
||||
// if (permission == LocationPermission.denied) {
|
||||
// // Permissions are denied, next time you could try
|
||||
// // requesting permissions again (this is also where
|
||||
// // Android's shouldShowRequestPermissionRationale
|
||||
// // returned true. According to Android guidelines
|
||||
// // your App should show an explanatory UI now.
|
||||
// return Future.error('Location permissions are denied');
|
||||
// }
|
||||
// }
|
||||
|
||||
// if (permission == LocationPermission.deniedForever) {
|
||||
// // Permissions are denied forever, handle appropriately.
|
||||
// return Future.error(
|
||||
// 'Location permissions are permanently denied, we cannot request permissions.');
|
||||
// }
|
||||
|
||||
// // When we reach here, permissions are granted and we can
|
||||
// // continue accessing the position of the device.
|
||||
// position = await Geolocator.getCurrentPosition();
|
||||
}
|
||||
}
|
||||
19
lib/controller/mh/experience_store_list_page.g.dart
Normal file
19
lib/controller/mh/experience_store_list_page.g.dart
Normal file
@@ -0,0 +1,19 @@
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
|
||||
part of 'experience_store_list_page.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// JsonSerializableGenerator
|
||||
// **************************************************************************
|
||||
|
||||
ExperienceStoreListModel _$ExperienceStoreListModelFromJson(
|
||||
Map<String, dynamic> json) =>
|
||||
ExperienceStoreListModel()
|
||||
..experienceStoreModelList =
|
||||
json['experienceStoreModelList'] as List<dynamic>;
|
||||
|
||||
Map<String, dynamic> _$ExperienceStoreListModelToJson(
|
||||
ExperienceStoreListModel instance) =>
|
||||
<String, dynamic>{
|
||||
'experienceStoreModelList': instance.experienceStoreModelList,
|
||||
};
|
||||
55
lib/controller/mh/issue_controller.dart
Normal file
55
lib/controller/mh/issue_controller.dart
Normal file
@@ -0,0 +1,55 @@
|
||||
import 'package:ef/ef.dart';
|
||||
import 'package:json_annotation/json_annotation.dart';
|
||||
import 'package:vbvs_app/common/color/appConstants.dart';
|
||||
|
||||
part 'issue_controller.g.dart';
|
||||
|
||||
@JsonSerializable()
|
||||
class IssueListModel {
|
||||
List issueList = [];
|
||||
|
||||
int limit = AppConstants.limit;
|
||||
int offset = 0;
|
||||
bool isLoading = false;
|
||||
bool hasMore = true;
|
||||
|
||||
int? selectedIndex;
|
||||
|
||||
IssueListModel();
|
||||
static IssueListModel fromJson(Map<String, dynamic> json) =>
|
||||
_$IssueListModelFromJson(json);
|
||||
Map<String, dynamic> toJson() => _$IssueListModelToJson(this);
|
||||
}
|
||||
|
||||
class IssueListController extends GetControllerEx<IssueListModel> {
|
||||
// HelpRepository helpRepository = HelpRepository();
|
||||
IssueListController() {
|
||||
attr = GetModel(IssueListModel()).obs;
|
||||
}
|
||||
|
||||
|
||||
// //初始化列表数据
|
||||
// Future<void> initData() async {
|
||||
// if (model.isLoading) {
|
||||
// return;
|
||||
// }
|
||||
// model.isLoading = true;
|
||||
// final List<dynamic> fetchedRepairs = await helpRepository.findHelpInfos(
|
||||
// limit: model.limit, offset: model.offset);
|
||||
// if (fetchedRepairs != null) {
|
||||
// List<IssueModel> infos = [];
|
||||
// List<dynamic> tmp = fetchedRepairs as List<dynamic>;
|
||||
// try {
|
||||
// // infos = tmp.map((repair) => IssueModel.fromJson(repair)).toList();
|
||||
// // model.issueList!.addAll(infos);
|
||||
// model.issueList.addAll(tmp);
|
||||
// } catch (e) {
|
||||
// print('Error parsing JSON: $e');
|
||||
// }
|
||||
// }
|
||||
// model.offset += model.limit; // 更新 offset,下一次查询跳过当前已经加载的记录
|
||||
// model.hasMore = fetchedRepairs.length == model.limit; // 判断是否还有更多数据
|
||||
// model.isLoading = false;
|
||||
// updateAll();
|
||||
// }
|
||||
}
|
||||
26
lib/controller/mh/issue_controller.g.dart
Normal file
26
lib/controller/mh/issue_controller.g.dart
Normal file
@@ -0,0 +1,26 @@
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
|
||||
part of 'issue_controller.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// JsonSerializableGenerator
|
||||
// **************************************************************************
|
||||
|
||||
IssueListModel _$IssueListModelFromJson(Map<String, dynamic> json) =>
|
||||
IssueListModel()
|
||||
..issueList = json['issueList'] as List<dynamic>
|
||||
..limit = (json['limit'] as num).toInt()
|
||||
..offset = (json['offset'] as num).toInt()
|
||||
..isLoading = json['isLoading'] as bool
|
||||
..hasMore = json['hasMore'] as bool
|
||||
..selectedIndex = (json['selectedIndex'] as num?)?.toInt();
|
||||
|
||||
Map<String, dynamic> _$IssueListModelToJson(IssueListModel instance) =>
|
||||
<String, dynamic>{
|
||||
'issueList': instance.issueList,
|
||||
'limit': instance.limit,
|
||||
'offset': instance.offset,
|
||||
'isLoading': instance.isLoading,
|
||||
'hasMore': instance.hasMore,
|
||||
'selectedIndex': instance.selectedIndex,
|
||||
};
|
||||
20
lib/controller/mh/issue_preview_controller.dart
Normal file
20
lib/controller/mh/issue_preview_controller.dart
Normal file
@@ -0,0 +1,20 @@
|
||||
import 'package:ef/ef.dart';
|
||||
import 'package:json_annotation/json_annotation.dart';
|
||||
|
||||
part 'issue_preview_controller.g.dart';
|
||||
|
||||
@JsonSerializable()
|
||||
class IssuePreviewInfoModel {
|
||||
|
||||
IssuePreviewInfoModel();
|
||||
|
||||
static IssuePreviewInfoModel fromJson(Map<String, dynamic> json) =>
|
||||
_$IssuePreviewInfoModelFromJson(json);
|
||||
Map<String, dynamic> toJson() => _$IssuePreviewInfoModelToJson(this);
|
||||
}
|
||||
|
||||
class IssuePreviewInfoController extends GetControllerEx<IssuePreviewInfoModel> {
|
||||
IssuePreviewInfoController() {
|
||||
attr = GetModel(IssuePreviewInfoModel()).obs;
|
||||
}
|
||||
}
|
||||
15
lib/controller/mh/issue_preview_controller.g.dart
Normal file
15
lib/controller/mh/issue_preview_controller.g.dart
Normal file
@@ -0,0 +1,15 @@
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
|
||||
part of 'issue_preview_controller.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// JsonSerializableGenerator
|
||||
// **************************************************************************
|
||||
|
||||
IssuePreviewInfoModel _$IssuePreviewInfoModelFromJson(
|
||||
Map<String, dynamic> json) =>
|
||||
IssuePreviewInfoModel();
|
||||
|
||||
Map<String, dynamic> _$IssuePreviewInfoModelToJson(
|
||||
IssuePreviewInfoModel instance) =>
|
||||
<String, dynamic>{};
|
||||
198
lib/controller/mh/message_controller.dart
Normal file
198
lib/controller/mh/message_controller.dart
Normal file
@@ -0,0 +1,198 @@
|
||||
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/app_uri_status.dart';
|
||||
import 'package:vbvs_app/common/util/DailyLogUtils.dart';
|
||||
import 'package:vbvs_app/common/util/MyUtils.dart';
|
||||
import 'package:vbvs_app/model/api_response.dart';
|
||||
|
||||
part 'message_controller.g.dart'; // 由json_serializable自动生成的部分
|
||||
|
||||
@JsonSerializable()
|
||||
class MhMessageModel {
|
||||
int? type = 1; //设备类型 1:体征消息 2.系统消息
|
||||
int? body_message_read = 0; //体征消息 0:已读 1:未读
|
||||
int? system_message_read = 0; //系统消息 0:已读 1:未读
|
||||
|
||||
MhMessageModel();
|
||||
|
||||
// 从JSON反序列化时的异常处理
|
||||
|
||||
factory MhMessageModel.fromJson(Map<String, dynamic> json) {
|
||||
try {
|
||||
return _$MhMessageModelFromJson(json);
|
||||
} catch (e) {
|
||||
// 在实际应用中,应该有更细致的异常处理策略和错误日志
|
||||
return MhMessageModel(); // 或者返回一个带有错误信息的特定DeviceInfoModel实例
|
||||
}
|
||||
}
|
||||
|
||||
// 序列化为JSON时的异常处理
|
||||
Map<String, dynamic> toJson() => _$MhMessageModelToJson(this);
|
||||
}
|
||||
|
||||
class MhMessageController extends GetControllerEx<MhMessageModel> {
|
||||
MhMessageController() {
|
||||
attr = GetModel(MhMessageModel()).obs;
|
||||
}
|
||||
|
||||
RxList messageList = [].obs;
|
||||
|
||||
Future<ApiResponse> getMessageList({String? key}) async {
|
||||
try {
|
||||
ApiResponse apiResponse = ApiResponse(code: -1, msg: "请求失败".tr);
|
||||
String serviceAddress = ServiceConstant.service_address;
|
||||
String serviceName = ServiceConstant.server_service;
|
||||
String serviceApi = ServiceConstant.message_list;
|
||||
String messageType = "app_system";
|
||||
if (model.type == 1) {
|
||||
messageType = "app_body";
|
||||
} else {
|
||||
messageType = "app_system";
|
||||
}
|
||||
String queryUrl =
|
||||
"${serviceAddress}${serviceName}${serviceApi}?type=${messageType}";
|
||||
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);
|
||||
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);
|
||||
if (res.code == HttpStatusCodes.ok) {
|
||||
updateAll();
|
||||
messageList.value = res.data;
|
||||
return res;
|
||||
}
|
||||
} else {
|
||||
return ApiResponse(code: -1, msg: "服务器.失败".tr);
|
||||
}
|
||||
return apiResponse;
|
||||
} catch (e) {
|
||||
EasyDartModule.logger.info("设备请求列表: $e");
|
||||
DailyLogUtils.writeLog("设备请求列表: $e");
|
||||
}
|
||||
return ApiResponse(code: -1, msg: "未知错误".tr); // Default return statement
|
||||
}
|
||||
|
||||
//获取消息已读未读
|
||||
Future<ApiResponse> getMessageStatus() async {
|
||||
try {
|
||||
ApiResponse apiResponse = ApiResponse(code: -1, msg: "请求失败".tr);
|
||||
// return apiResponse;
|
||||
String serviceAddress = ServiceConstant.service_address;
|
||||
String serviceName = ServiceConstant.server_service;
|
||||
String serviceApi = ServiceConstant.message_read;
|
||||
|
||||
String queryUrl = "${serviceAddress}${serviceName}${serviceApi}";
|
||||
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);
|
||||
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);
|
||||
if (res.code == HttpStatusCodes.ok) {
|
||||
updateAll();
|
||||
List dataList = res.data;
|
||||
|
||||
// 查找 type 为 app_vsm 的项
|
||||
var vsmItem = dataList.firstWhere(
|
||||
(e) => e['type'] == 'app_vsm',
|
||||
orElse: () => null,
|
||||
);
|
||||
model.body_message_read = vsmItem?['count'] ?? 0;
|
||||
|
||||
// 查找 type 为 app_system 的项
|
||||
var systemItem = dataList.firstWhere(
|
||||
(e) => e['type'] == 'app_system',
|
||||
orElse: () => null,
|
||||
);
|
||||
model.system_message_read = systemItem?['count'] ?? 0;
|
||||
|
||||
updateAll();
|
||||
return res;
|
||||
}
|
||||
} else {
|
||||
return ApiResponse(code: -1, msg: "服务器.失败".tr);
|
||||
}
|
||||
return apiResponse;
|
||||
} catch (e) {
|
||||
EasyDartModule.logger.info("获取消息已读未读: $e");
|
||||
DailyLogUtils.writeLog("获取消息已读未读: $e");
|
||||
}
|
||||
return ApiResponse(code: -1, msg: "未知错误".tr); // Default return statement
|
||||
}
|
||||
|
||||
//更新消息已读
|
||||
Future<ApiResponse> updateMessageStatus({String? type}) async {
|
||||
EasyDartModule.logger.info("更新消息已读状态");
|
||||
DailyLogUtils.writeLog("更新消息已读状态");
|
||||
try {
|
||||
ApiResponse apiResponse = ApiResponse(code: -1, msg: "操作失败".tr);
|
||||
String serviceAddress = ServiceConstant.service_address;
|
||||
String serviceName = ServiceConstant.server_service;
|
||||
String serviceApi = ServiceConstant.message_read;
|
||||
|
||||
// 拼接 URL,添加 type 参数
|
||||
String queryUrl = "$serviceAddress$serviceName$serviceApi";
|
||||
if (type != null && type.isNotEmpty) {
|
||||
queryUrl += "?type=$type";
|
||||
}
|
||||
|
||||
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.post(queryUrl);
|
||||
|
||||
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);
|
||||
return res;
|
||||
} else {
|
||||
return ApiResponse(code: -1, msg: "服务器.失败".tr);
|
||||
}
|
||||
} catch (e) {
|
||||
EasyDartModule.logger.info("更新消息已读状态->$e");
|
||||
DailyLogUtils.writeLog("更新消息已读状态->$e");
|
||||
return ApiResponse(code: -1, msg: "服务器.失败".tr);
|
||||
}
|
||||
}
|
||||
}
|
||||
20
lib/controller/mh/message_controller.g.dart
Normal file
20
lib/controller/mh/message_controller.g.dart
Normal file
@@ -0,0 +1,20 @@
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
|
||||
part of 'message_controller.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// JsonSerializableGenerator
|
||||
// **************************************************************************
|
||||
|
||||
MhMessageModel _$MhMessageModelFromJson(Map<String, dynamic> json) =>
|
||||
MhMessageModel()
|
||||
..type = (json['type'] as num?)?.toInt()
|
||||
..body_message_read = (json['body_message_read'] as num?)?.toInt()
|
||||
..system_message_read = (json['system_message_read'] as num?)?.toInt();
|
||||
|
||||
Map<String, dynamic> _$MhMessageModelToJson(MhMessageModel instance) =>
|
||||
<String, dynamic>{
|
||||
'type': instance.type,
|
||||
'body_message_read': instance.body_message_read,
|
||||
'system_message_read': instance.system_message_read,
|
||||
};
|
||||
177
lib/controller/mh/muser_info_controller.dart
Normal file
177
lib/controller/mh/muser_info_controller.dart
Normal file
@@ -0,0 +1,177 @@
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:ef/ef.dart';
|
||||
import 'package:fluwx/fluwx.dart';
|
||||
import 'package:json_annotation/json_annotation.dart';
|
||||
|
||||
import 'package:path/path.dart' as p;
|
||||
|
||||
import 'package:vbvs_app/controller/mh/user_data.dart';
|
||||
part 'muser_info_controller.g.dart';
|
||||
|
||||
@JsonSerializable()
|
||||
class MUserInfoModel {
|
||||
int? message = 0; //消息数量
|
||||
|
||||
UserModel? user; //用户信息
|
||||
String? token; //token值
|
||||
String? runSystem; //运行系统
|
||||
String? phoneVersion; //手机版本
|
||||
String? deviceId; //手机唯一
|
||||
String? deviceModel; //设备可见型号(如 "iPhone","iPad")
|
||||
String? appVersion; //app版本信息
|
||||
|
||||
@JsonKey(ignore: true)
|
||||
Session? superbase_session;
|
||||
@JsonKey(ignore: true)
|
||||
User? superbase_user;
|
||||
|
||||
String? img_bucket = 'user';
|
||||
int? login = 0; //是否登录0:未登录 1:已登录
|
||||
|
||||
MUserInfoModel();
|
||||
static MUserInfoModel fromJson(Map<String, dynamic> json) =>
|
||||
_$MUserInfoModelFromJson(json);
|
||||
Map<String, dynamic> toJson() => _$MUserInfoModelToJson(this);
|
||||
}
|
||||
|
||||
class MUserInfoController extends GetControllerEx<MUserInfoModel> {
|
||||
// 初始化实例
|
||||
final Fluwx fluwx = Fluwx();
|
||||
|
||||
MUserInfoController() {
|
||||
attr = GetModel(MUserInfoModel()).obs;
|
||||
}
|
||||
|
||||
// Future<void> uploadImg() async {
|
||||
// final ImagePicker picker = ImagePicker();
|
||||
// final XFile? image = await picker.pickImage(source: ImageSource.gallery);
|
||||
// final user = Supabase.instance.client.auth.currentUser;
|
||||
// try {
|
||||
// if (image != null) {
|
||||
// int fileSize = await image.length(); // 获取图片大小,单位为字节
|
||||
// if (fileSize > 1048576) {
|
||||
// // 1 MB = 1024 * 1024 bytes
|
||||
// showToast("头像图片不能超过1MB");
|
||||
// return;
|
||||
// }
|
||||
// final filePath = image.path; // 获取文件路径
|
||||
// final fileExtension = p.extension(filePath); // 获取文件扩展名,包括点(.)
|
||||
// // 获取当前日期并格式化为 yyyy-MM-dd
|
||||
// final String folderName =
|
||||
// DateFormat('yyyy-MM-dd').format(DateTime.now());
|
||||
// final file = File(image.path);
|
||||
// // 构造文件路径,文件会被上传到 record_img 文件夹下的当天日期文件夹
|
||||
// var response = await ef.client.storage
|
||||
// .from(model.img_bucket!)
|
||||
// .upload('$folderName/${Uuid().v4()}$fileExtension', file);
|
||||
// if (response != null) {
|
||||
// String publicUrl =
|
||||
// ef.client.storage.from(model.img_bucket!).getPublicUrl(response);
|
||||
|
||||
// print('文件上传成功: $response');
|
||||
// print('文件上传成功: $publicUrl');
|
||||
// String prefixToRemove = 'user/';
|
||||
// // model.user!.tmpHead = model.user!.head;
|
||||
// model.user!.tmpHead = publicUrl.startsWith(prefixToRemove)
|
||||
// ? response.substring(prefixToRemove.length)
|
||||
// : response;
|
||||
// updateAll();
|
||||
// }
|
||||
// print('/$model.img_bucket');
|
||||
// } else {
|
||||
// print('未选择图片');
|
||||
// return;
|
||||
// }
|
||||
// } catch (e) {
|
||||
// print('上传失败: $e');
|
||||
// }
|
||||
// }
|
||||
|
||||
// updateData() {
|
||||
// UserInfoController controller = Get.find();
|
||||
// UserRepository userRepository = UserRepository();
|
||||
// return userRepository.updateInfo(controller.model.user!);
|
||||
// }
|
||||
|
||||
// autoLogin(String token) async {
|
||||
// final UserInfoController userInfoController = Get.find();
|
||||
// try {
|
||||
// final Map<String, dynamic> requestBody = {
|
||||
// 'token': token,
|
||||
// };
|
||||
|
||||
// var response = await ApiService.request
|
||||
// .post("/api/auth/account/info/autoLogin", data: requestBody);
|
||||
// if (response.statusCode == 200) {
|
||||
// if (response.data != null) {
|
||||
// ApiResponse<UserModel> apiResponse = ApiResponse.fromJson(
|
||||
// response.data,
|
||||
// (json) => UserModel.fromJson(json as Map<String, dynamic>));
|
||||
// if (apiResponse.code == HttpStatusCodes.ok) {
|
||||
// userInfoController.model.user = apiResponse.data;
|
||||
// userInfoController.model.token = response.headers['token']!.first;
|
||||
// userInfoController.model.login = 1;
|
||||
|
||||
// final box = GetStorage();
|
||||
// box.write(
|
||||
// 'user', userInfoController.model.user!.toJson()); // 存储用户信息
|
||||
// box.write('token', userInfoController.model.token); // 存储 token
|
||||
// String efPd = await getValueBySysConfigKey(CommonVariables.efKey);
|
||||
// if (efPd != null && efPd.isNotEmpty) {
|
||||
// await initDataEf(key: efPd);
|
||||
// } else {
|
||||
// print("efPD为空,无法初始化");
|
||||
// // 清除本地缓存
|
||||
// final box = GetStorage();
|
||||
// box.remove('user');
|
||||
// box.remove('token');
|
||||
// userInfoController.model.token = null;
|
||||
// userInfoController.model.user = null;
|
||||
// // 设置成未登录
|
||||
// userInfoController.model.login = 0;
|
||||
// return;
|
||||
// }
|
||||
|
||||
// final AuthResponse res = await ef.client.auth.signInWithPassword(
|
||||
// phone: userInfoController.model.user!.tel,
|
||||
// password: userInfoController.model.user!.exp1!,
|
||||
// );
|
||||
// userInfoController.model.superbase_session = res.session;
|
||||
// userInfoController.model.superbase_user = res.user;
|
||||
// userInfoController.updateAll();
|
||||
// // 登录成功移出网络检查监听
|
||||
// Checknetwork.subscription?.cancel();
|
||||
// }
|
||||
// }
|
||||
// } else {
|
||||
// // 处理非 200 响应
|
||||
// print('Failed to sign in. Status code: ${response.statusCode}');
|
||||
// print('Response data: ${response.data}');
|
||||
// }
|
||||
// } catch (e) {
|
||||
// e.printError();
|
||||
// // 清除本地缓存
|
||||
// final box = GetStorage();
|
||||
// box.remove('user');
|
||||
// box.remove('token');
|
||||
// userInfoController.model.token = null;
|
||||
// userInfoController.model.user = null;
|
||||
// // 设置成未登录
|
||||
// userInfoController.model.login = 0;
|
||||
// }
|
||||
// }
|
||||
|
||||
// // 拉起微信企业客服
|
||||
// Future<void> openWeChatCustomerService() async {
|
||||
// bool isWeChatInstalled = await fluwx.isWeChatInstalled;
|
||||
// if (!isWeChatInstalled) {
|
||||
// showToast("请先安装微信APP,再联系客服", color: color_error);
|
||||
// return;
|
||||
// }
|
||||
// showToast('正在打开微信客服...', color: color_success);
|
||||
// await fluwx.open(
|
||||
// target: CustomerServiceChat(
|
||||
// corpId: CommonVariables.wxCorpId, url: CommonVariables.wxKfUrl));
|
||||
// }
|
||||
}
|
||||
36
lib/controller/mh/muser_info_controller.g.dart
Normal file
36
lib/controller/mh/muser_info_controller.g.dart
Normal file
@@ -0,0 +1,36 @@
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
|
||||
part of 'muser_info_controller.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// JsonSerializableGenerator
|
||||
// **************************************************************************
|
||||
|
||||
MUserInfoModel _$MUserInfoModelFromJson(Map<String, dynamic> json) =>
|
||||
MUserInfoModel()
|
||||
..message = (json['message'] as num?)?.toInt()
|
||||
..user = json['user'] == null
|
||||
? null
|
||||
: UserModel.fromJson(json['user'] as Map<String, dynamic>)
|
||||
..token = json['token'] as String?
|
||||
..runSystem = json['runSystem'] as String?
|
||||
..phoneVersion = json['phoneVersion'] as String?
|
||||
..deviceId = json['deviceId'] as String?
|
||||
..deviceModel = json['deviceModel'] as String?
|
||||
..appVersion = json['appVersion'] as String?
|
||||
..img_bucket = json['img_bucket'] as String?
|
||||
..login = (json['login'] as num?)?.toInt();
|
||||
|
||||
Map<String, dynamic> _$MUserInfoModelToJson(MUserInfoModel instance) =>
|
||||
<String, dynamic>{
|
||||
'message': instance.message,
|
||||
'user': instance.user,
|
||||
'token': instance.token,
|
||||
'runSystem': instance.runSystem,
|
||||
'phoneVersion': instance.phoneVersion,
|
||||
'deviceId': instance.deviceId,
|
||||
'deviceModel': instance.deviceModel,
|
||||
'appVersion': instance.appVersion,
|
||||
'img_bucket': instance.img_bucket,
|
||||
'login': instance.login,
|
||||
};
|
||||
115
lib/controller/mh/my_experience_list_controller.dart
Normal file
115
lib/controller/mh/my_experience_list_controller.dart
Normal file
@@ -0,0 +1,115 @@
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:ef/ef.dart';
|
||||
|
||||
|
||||
class BookExperienceListModel {
|
||||
List bookInfoList = []; //预约列表
|
||||
List experienceStoreModelList = [];
|
||||
}
|
||||
|
||||
class BookExperienceListController
|
||||
extends GetControllerEx<BookExperienceListModel> {
|
||||
BookExperienceListController() {
|
||||
attr = GetModel(BookExperienceListModel()).obs;
|
||||
}
|
||||
|
||||
// resetParm() {
|
||||
// model.bookInfoList = [];
|
||||
// model.experienceStoreModelList = [];
|
||||
// total = 0;
|
||||
// page = 0;
|
||||
// lock = false;
|
||||
// updateAll();
|
||||
// }
|
||||
|
||||
// getAllBook() {
|
||||
// ApiService.reservation
|
||||
// .get(
|
||||
// "/agent/userBook/config/getBookStoreList?storeName=&latitude=31.8512&longitude=117.26061&page=0&size=20000&sort=distance")
|
||||
// .then((d) {
|
||||
// model.experienceStoreModelList = d.data["records"];
|
||||
// updateAll();
|
||||
// });
|
||||
// }
|
||||
|
||||
// int total = 0;
|
||||
// int page = 0;
|
||||
// bool lock = false;
|
||||
|
||||
// getData({int count = 10, Function? finished}) {
|
||||
// if (page != 0 && page * count > total) {
|
||||
// finished?.call();
|
||||
// return;
|
||||
// }
|
||||
// if (lock) {
|
||||
// finished?.call();
|
||||
// return;
|
||||
// }
|
||||
// lock = true;
|
||||
// int page_ = page;
|
||||
// String tel = Get.find<UserInfoController>().model.user?.tel ?? "";
|
||||
// if (tel.isEmpty) {
|
||||
// showToast("用户未存在手机号");
|
||||
// finished?.call();
|
||||
// return;
|
||||
// }
|
||||
// ApiService.reservation
|
||||
// .get(
|
||||
// "/agent/userBook/list?extUserId=$tel&page=$page_&size=$count&sort=create_time,desc")
|
||||
// .then((d) {
|
||||
// lock = false;
|
||||
// finished?.call();
|
||||
// if (page == 0) {
|
||||
// model.bookInfoList = d.data["records"];
|
||||
// } else {
|
||||
// int index = 0;
|
||||
// d.data["records"]?.forEach((item) {
|
||||
// if (model.bookInfoList
|
||||
// .indexWhere((item2) => item2["id"] == item["id"]) ==
|
||||
// -1) {
|
||||
// model.bookInfoList.add(item);
|
||||
// } else {
|
||||
// model.bookInfoList[index] = item;
|
||||
// }
|
||||
// index++;
|
||||
// });
|
||||
// }
|
||||
// page = page_ + 1;
|
||||
// total = d.data["total"];
|
||||
// updateAll();
|
||||
// }).catchError((d) {
|
||||
// lock = false;
|
||||
// finished?.call();
|
||||
// });
|
||||
// }
|
||||
|
||||
// cancelBook(id, {Function? success}) {
|
||||
// String tel = Get.find<UserInfoController>().model.user?.tel ?? "";
|
||||
// if (tel.isEmpty) {
|
||||
// showToast("用户未存在手机号");
|
||||
// return;
|
||||
// }
|
||||
// LoadingDialog.show("提交中...");
|
||||
// ApiService.reservation
|
||||
// .post("/agent/userBook/cancel?extUserId=$tel&id=$id")
|
||||
// .then((d) {
|
||||
// page = 0;
|
||||
// getData(finished: () {
|
||||
// LoadingDialog.hide();
|
||||
// });
|
||||
// success?.call();
|
||||
// }).catchError((d) {
|
||||
// LoadingDialog.hide();
|
||||
// });
|
||||
// }
|
||||
|
||||
// messageAdd(Map data) {
|
||||
// return ApiService.request.post("/api/message/info", data: {
|
||||
// "type": 0,
|
||||
// "status": 1,
|
||||
// "read": 1,
|
||||
// "data": jsonEncode(data)
|
||||
// });
|
||||
// }
|
||||
}
|
||||
111
lib/controller/mh/people_info_controller.dart
Normal file
111
lib/controller/mh/people_info_controller.dart
Normal file
@@ -0,0 +1,111 @@
|
||||
import 'package:ef/ef.dart';
|
||||
import 'package:json_annotation/json_annotation.dart';
|
||||
import 'package:vbvs_app/controller/main_bottom/global_controller.dart';
|
||||
|
||||
part 'people_info_controller.g.dart'; // 由json_serializable自动生成的部分
|
||||
|
||||
class PeopleInfoModel {
|
||||
List<PeopleInfoPojo> peopleList = [PeopleInfoPojo(), PeopleInfoPojo()];
|
||||
}
|
||||
|
||||
@JsonSerializable()
|
||||
class PeopleInfoPojo {
|
||||
String? name;
|
||||
String sex = "男";
|
||||
String? height;
|
||||
String? weight;
|
||||
DateTime? birthday;
|
||||
String? tel;
|
||||
String? emergencyContact;
|
||||
|
||||
PeopleInfoPojo();
|
||||
|
||||
// // 从JSON反序列化时的异常处理
|
||||
|
||||
factory PeopleInfoPojo.fromJson(Map<String, dynamic> json) {
|
||||
try {
|
||||
return _$PeopleInfoPojoFromJson(json);
|
||||
} catch (e) {
|
||||
// 在实际应用中,应该有更细致的异常处理策略和错误日志
|
||||
return PeopleInfoPojo(); // 或者返回一个带有错误信息的特定PeopleInfoModel实例
|
||||
}
|
||||
}
|
||||
|
||||
// 序列化为JSON时的异常处理
|
||||
Map<String, dynamic> toJson() => _$PeopleInfoPojoToJson(this);
|
||||
}
|
||||
|
||||
class PeopleInfoController extends GetControllerEx<PeopleInfoModel> {
|
||||
PeopleInfoController() {
|
||||
attr = GetModel(PeopleInfoModel()).obs;
|
||||
}
|
||||
|
||||
GlobalController get glcontroller => Get.find<GlobalController>();
|
||||
|
||||
// getPeoples() async {
|
||||
// var arr = [];
|
||||
// String bindMacA =
|
||||
// glcontroller.getUpperCaseMac(glcontroller.model.deviceMain["bindMacA"]);
|
||||
// String bindMacB =
|
||||
// glcontroller.getUpperCaseMac(glcontroller.model.deviceMain["bindMacB"]);
|
||||
// arr.add(bindMacA);
|
||||
// if (bindMacB.length > 6) {
|
||||
// arr.add(bindMacB);
|
||||
// } else {
|
||||
// model.peopleList[1] = PeopleInfoPojo();
|
||||
// }
|
||||
// model.peopleList[0] = PeopleInfoPojo();
|
||||
// print("getuser $arr");
|
||||
// var data = await ef.from("app_personnel").select().inFilter("mac", arr);
|
||||
// print("getuser $data");
|
||||
// data?.forEach((d) {
|
||||
// PeopleInfoPojo peopleInfoPojo = PeopleInfoPojo();
|
||||
// peopleInfoPojo.name = d["name"];
|
||||
// peopleInfoPojo.sex = d["gender"] == 1 ? "男" : "女";
|
||||
// peopleInfoPojo.height = d["height"] == null ? null : "${d["height"]}";
|
||||
// peopleInfoPojo.weight = d["weight"] == null ? null : "${d["weight"]}";
|
||||
// if (d["birthday"] != null) {
|
||||
// peopleInfoPojo.birthday = DateTime.parse(d["birthday"]).toLocal();
|
||||
// }
|
||||
// peopleInfoPojo.tel = d["tel"];
|
||||
// peopleInfoPojo.emergencyContact = d["contact"];
|
||||
// if (glcontroller.getUpperCaseMac(d['mac']) == bindMacA) {
|
||||
// model.peopleList[0] = peopleInfoPojo;
|
||||
// }
|
||||
// if (glcontroller.getUpperCaseMac(d['mac']) == bindMacB) {
|
||||
// model.peopleList[1] = peopleInfoPojo;
|
||||
// }
|
||||
// });
|
||||
// updateAll();
|
||||
// attr.value.updateAll();
|
||||
// }
|
||||
|
||||
// savePeoples() async {
|
||||
// String bindMacA =
|
||||
// glcontroller.getUpperCaseMac(glcontroller.model.deviceMain["bindMacA"]);
|
||||
// String bindMacB =
|
||||
// glcontroller.getUpperCaseMac(glcontroller.model.deviceMain["bindMacB"]);
|
||||
// List<Future> arr = [];
|
||||
// for (var i = 0; i < 2; i++) {
|
||||
// if (i == 1 && bindMacB.length < 6) {
|
||||
// break;
|
||||
// }
|
||||
// arr.add(ef.from("app_personnel").update({
|
||||
// "name": model.peopleList[i].name,
|
||||
// "gender": model.peopleList[i].sex == "男" ? 1 : 0,
|
||||
// "height": int.tryParse("${model.peopleList[i].height}"),
|
||||
// "weight": int.tryParse("${model.peopleList[i].weight}"),
|
||||
// "birthday": model.peopleList[i].birthday == null
|
||||
// ? null
|
||||
// : model.peopleList[i].birthday.toString(),
|
||||
// "tel": model.peopleList[i].tel,
|
||||
// "contact": model.peopleList[i].emergencyContact
|
||||
// }).eq("mac", i == 0 ? bindMacA : bindMacB));
|
||||
// }
|
||||
// return Future.wait(arr);
|
||||
// }
|
||||
|
||||
// Future saveOnePeople(mac, data) async {
|
||||
// return ef.from("app_personnel").update(data).eq("mac", mac);
|
||||
// }
|
||||
}
|
||||
30
lib/controller/mh/people_info_controller.g.dart
Normal file
30
lib/controller/mh/people_info_controller.g.dart
Normal file
@@ -0,0 +1,30 @@
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
|
||||
part of 'people_info_controller.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// JsonSerializableGenerator
|
||||
// **************************************************************************
|
||||
|
||||
PeopleInfoPojo _$PeopleInfoPojoFromJson(Map<String, dynamic> json) =>
|
||||
PeopleInfoPojo()
|
||||
..name = json['name'] as String?
|
||||
..sex = json['sex'] as String
|
||||
..height = json['height'] as String?
|
||||
..weight = json['weight'] as String?
|
||||
..birthday = json['birthday'] == null
|
||||
? null
|
||||
: DateTime.parse(json['birthday'] as String)
|
||||
..tel = json['tel'] as String?
|
||||
..emergencyContact = json['emergencyContact'] as String?;
|
||||
|
||||
Map<String, dynamic> _$PeopleInfoPojoToJson(PeopleInfoPojo instance) =>
|
||||
<String, dynamic>{
|
||||
'name': instance.name,
|
||||
'sex': instance.sex,
|
||||
'height': instance.height,
|
||||
'weight': instance.weight,
|
||||
'birthday': instance.birthday?.toIso8601String(),
|
||||
'tel': instance.tel,
|
||||
'emergencyContact': instance.emergencyContact,
|
||||
};
|
||||
68
lib/controller/mh/repair_info_controller.dart
Normal file
68
lib/controller/mh/repair_info_controller.dart
Normal file
@@ -0,0 +1,68 @@
|
||||
import 'package:ef/ef.dart';
|
||||
import 'package:json_annotation/json_annotation.dart';
|
||||
import 'package:vbvs_app/controller/mh/apply_repair_controller.dart';
|
||||
import 'package:vbvs_app/controller/mh/repair_process.dart';
|
||||
|
||||
part 'repair_info_controller.g.dart';
|
||||
|
||||
@JsonSerializable()
|
||||
class RepairInfoModel {
|
||||
String? id; //记录id
|
||||
DateTime? create_time; //提交时间
|
||||
String? status; //状态
|
||||
String? desc; //描述
|
||||
int? record_id; //归属记录id
|
||||
|
||||
List<RepairProcessModel> repairProcessList = []; //审核流程
|
||||
String? device_name;
|
||||
ApplyRepairModel? applyRepairModel;
|
||||
|
||||
RepairInfoModel();
|
||||
|
||||
static RepairInfoModel fromJson(Map<String, dynamic> json) =>
|
||||
_$RepairInfoModelFromJson(json);
|
||||
Map<String, dynamic> toJson() => _$RepairInfoModelToJson(this);
|
||||
}
|
||||
|
||||
class RepairInfoController extends GetControllerEx<RepairInfoModel> {
|
||||
// RepairRepository repairRepository = RepairRepository();
|
||||
RepairInfoController() {
|
||||
attr = GetModel(RepairInfoModel()).obs;
|
||||
}
|
||||
|
||||
// Future<void> initData(ApplyRepairModel applyRepairModel) async {
|
||||
// if (applyRepairModel != null) {
|
||||
// final List<dynamic> fetchedRepairs =
|
||||
// await repairRepository.findData(applyRepairModel.id!);
|
||||
// RepairListController repairListController = Get.find();
|
||||
// final List<dynamic> info = await repairListController.repairRepository
|
||||
// .findRecordData(applyRepairModel.id!);
|
||||
// if (info.isNotEmpty) {
|
||||
// List<ApplyRepairModel> infos = [];
|
||||
// List<dynamic> tmp = info as List<dynamic>;
|
||||
// try {
|
||||
// infos =
|
||||
// tmp.map((repair) => ApplyRepairModel.fromJson(repair)).toList();
|
||||
// model.applyRepairModel = infos.first;
|
||||
// updateAll();
|
||||
// } catch (e) {
|
||||
// print('Error parsing JSON: $e');
|
||||
// }
|
||||
// // model.applyRepairModel = applyRepairModel;
|
||||
// }
|
||||
|
||||
// if (fetchedRepairs != null) {
|
||||
// List<RepairProcessModel> infos = [];
|
||||
// List<dynamic> tmp = fetchedRepairs as List<dynamic>;
|
||||
// try {
|
||||
// infos =
|
||||
// tmp.map((repair) => RepairProcessModel.fromJson(repair)).toList();
|
||||
// model.repairProcessList = infos;
|
||||
// updateAll();
|
||||
// } catch (e) {
|
||||
// print('Error parsing JSON: $e');
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
}
|
||||
37
lib/controller/mh/repair_info_controller.g.dart
Normal file
37
lib/controller/mh/repair_info_controller.g.dart
Normal file
@@ -0,0 +1,37 @@
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
|
||||
part of 'repair_info_controller.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// JsonSerializableGenerator
|
||||
// **************************************************************************
|
||||
|
||||
RepairInfoModel _$RepairInfoModelFromJson(Map<String, dynamic> json) =>
|
||||
RepairInfoModel()
|
||||
..id = json['id'] as String?
|
||||
..create_time = json['create_time'] == null
|
||||
? null
|
||||
: DateTime.parse(json['create_time'] as String)
|
||||
..status = json['status'] as String?
|
||||
..desc = json['desc'] as String?
|
||||
..record_id = (json['record_id'] as num?)?.toInt()
|
||||
..repairProcessList = (json['repairProcessList'] as List<dynamic>)
|
||||
.map((e) => RepairProcessModel.fromJson(e as Map<String, dynamic>))
|
||||
.toList()
|
||||
..device_name = json['device_name'] as String?
|
||||
..applyRepairModel = json['applyRepairModel'] == null
|
||||
? null
|
||||
: ApplyRepairModel.fromJson(
|
||||
json['applyRepairModel'] as Map<String, dynamic>);
|
||||
|
||||
Map<String, dynamic> _$RepairInfoModelToJson(RepairInfoModel instance) =>
|
||||
<String, dynamic>{
|
||||
'id': instance.id,
|
||||
'create_time': instance.create_time?.toIso8601String(),
|
||||
'status': instance.status,
|
||||
'desc': instance.desc,
|
||||
'record_id': instance.record_id,
|
||||
'repairProcessList': instance.repairProcessList,
|
||||
'device_name': instance.device_name,
|
||||
'applyRepairModel': instance.applyRepairModel,
|
||||
};
|
||||
83
lib/controller/mh/repair_list_controller.dart
Normal file
83
lib/controller/mh/repair_list_controller.dart
Normal file
@@ -0,0 +1,83 @@
|
||||
import 'package:ef/ef.dart';
|
||||
import 'package:json_annotation/json_annotation.dart';
|
||||
import 'package:vbvs_app/common/color/appConstants.dart';
|
||||
import 'apply_repair_controller.dart';
|
||||
part 'repair_list_controller.g.dart';
|
||||
|
||||
@JsonSerializable()
|
||||
class RepairListModel {
|
||||
int limit = AppConstants.limit;
|
||||
int offset = 0;
|
||||
bool isLoading = false;
|
||||
bool hasMore = true;
|
||||
|
||||
List<ApplyRepairModel> repairList = [];
|
||||
|
||||
RepairListModel();
|
||||
static RepairListModel fromJson(Map<String, dynamic> json) =>
|
||||
_$RepairListModelFromJson(json);
|
||||
Map<String, dynamic> toJson() => _$RepairListModelToJson(this);
|
||||
}
|
||||
|
||||
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();
|
||||
// }
|
||||
|
||||
// Future<String> addScore(int id, int score) async {
|
||||
// return await repairRepository.addScore(id, score);
|
||||
// }
|
||||
@override
|
||||
void onInit() {
|
||||
super.onInit();
|
||||
loadMockRepairList();
|
||||
}
|
||||
|
||||
void loadMockRepairList() {
|
||||
model.repairList = [
|
||||
ApplyRepairModel()
|
||||
..id = 1001
|
||||
..device_category = '智能床垫 BY-H'
|
||||
..status = '待维修'
|
||||
..create_time = DateTime.now().subtract(Duration(days: 1))
|
||||
..device_id = 'BYH-001',
|
||||
ApplyRepairModel()
|
||||
..id = 1002
|
||||
..device_category = '智能床垫 BY-A'
|
||||
..status = '维修中'
|
||||
..create_time = DateTime.now().subtract(Duration(days: 2))
|
||||
..device_id = 'BYA-002',
|
||||
ApplyRepairModel()
|
||||
..id = 1003
|
||||
..device_category = '智能床垫 BY-C'
|
||||
..status = '已完成'
|
||||
..create_time = DateTime.now().subtract(Duration(days: 3))
|
||||
..device_id = 'BYC-003',
|
||||
];
|
||||
}
|
||||
}
|
||||
26
lib/controller/mh/repair_list_controller.g.dart
Normal file
26
lib/controller/mh/repair_list_controller.g.dart
Normal file
@@ -0,0 +1,26 @@
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
|
||||
part of 'repair_list_controller.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// JsonSerializableGenerator
|
||||
// **************************************************************************
|
||||
|
||||
RepairListModel _$RepairListModelFromJson(Map<String, dynamic> json) =>
|
||||
RepairListModel()
|
||||
..limit = (json['limit'] as num).toInt()
|
||||
..offset = (json['offset'] as num).toInt()
|
||||
..isLoading = json['isLoading'] as bool
|
||||
..hasMore = json['hasMore'] as bool
|
||||
..repairList = (json['repairList'] as List<dynamic>)
|
||||
.map((e) => ApplyRepairModel.fromJson(e as Map<String, dynamic>))
|
||||
.toList();
|
||||
|
||||
Map<String, dynamic> _$RepairListModelToJson(RepairListModel instance) =>
|
||||
<String, dynamic>{
|
||||
'limit': instance.limit,
|
||||
'offset': instance.offset,
|
||||
'isLoading': instance.isLoading,
|
||||
'hasMore': instance.hasMore,
|
||||
'repairList': instance.repairList,
|
||||
};
|
||||
18
lib/controller/mh/repair_process.dart
Normal file
18
lib/controller/mh/repair_process.dart
Normal file
@@ -0,0 +1,18 @@
|
||||
import 'package:json_annotation/json_annotation.dart';
|
||||
|
||||
part 'repair_process.g.dart';
|
||||
|
||||
@JsonSerializable()
|
||||
class RepairProcessModel {
|
||||
String? status; //审核状态
|
||||
DateTime? create_time; //审核时间
|
||||
String? desc; //审核意见
|
||||
int? record_id; //归属记录
|
||||
|
||||
int? deal_user; //处理人
|
||||
|
||||
RepairProcessModel();
|
||||
static RepairProcessModel fromJson(Map<String, dynamic> json) =>
|
||||
_$RepairProcessModelFromJson(json);
|
||||
Map<String, dynamic> toJson() => _$RepairProcessModelToJson(this);
|
||||
}
|
||||
26
lib/controller/mh/repair_process.g.dart
Normal file
26
lib/controller/mh/repair_process.g.dart
Normal file
@@ -0,0 +1,26 @@
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
|
||||
part of 'repair_process.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// JsonSerializableGenerator
|
||||
// **************************************************************************
|
||||
|
||||
RepairProcessModel _$RepairProcessModelFromJson(Map<String, dynamic> json) =>
|
||||
RepairProcessModel()
|
||||
..status = json['status'] as String?
|
||||
..create_time = json['create_time'] == null
|
||||
? null
|
||||
: DateTime.parse(json['create_time'] as String)
|
||||
..desc = json['desc'] as String?
|
||||
..record_id = (json['record_id'] as num?)?.toInt()
|
||||
..deal_user = (json['deal_user'] as num?)?.toInt();
|
||||
|
||||
Map<String, dynamic> _$RepairProcessModelToJson(RepairProcessModel instance) =>
|
||||
<String, dynamic>{
|
||||
'status': instance.status,
|
||||
'create_time': instance.create_time?.toIso8601String(),
|
||||
'desc': instance.desc,
|
||||
'record_id': instance.record_id,
|
||||
'deal_user': instance.deal_user,
|
||||
};
|
||||
20
lib/controller/mh/score_controller.dart
Normal file
20
lib/controller/mh/score_controller.dart
Normal file
@@ -0,0 +1,20 @@
|
||||
import 'package:ef/ef.dart';
|
||||
import 'package:json_annotation/json_annotation.dart';
|
||||
|
||||
part 'score_controller.g.dart';
|
||||
|
||||
@JsonSerializable()
|
||||
class ScoreModel {
|
||||
int? score = 5;
|
||||
|
||||
ScoreModel();
|
||||
static ScoreModel fromJson(Map<String, dynamic> json) =>
|
||||
_$ScoreModelFromJson(json);
|
||||
Map<String, dynamic> toJson() => _$ScoreModelToJson(this);
|
||||
}
|
||||
|
||||
class ScoreController extends GetControllerEx<ScoreModel> {
|
||||
ScoreController() {
|
||||
attr = GetModel(ScoreModel()).obs;
|
||||
}
|
||||
}
|
||||
15
lib/controller/mh/score_controller.g.dart
Normal file
15
lib/controller/mh/score_controller.g.dart
Normal file
@@ -0,0 +1,15 @@
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
|
||||
part of 'score_controller.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// JsonSerializableGenerator
|
||||
// **************************************************************************
|
||||
|
||||
ScoreModel _$ScoreModelFromJson(Map<String, dynamic> json) =>
|
||||
ScoreModel()..score = (json['score'] as num?)?.toInt();
|
||||
|
||||
Map<String, dynamic> _$ScoreModelToJson(ScoreModel instance) =>
|
||||
<String, dynamic>{
|
||||
'score': instance.score,
|
||||
};
|
||||
94
lib/controller/mh/sleeping_habit_controller.dart
Normal file
94
lib/controller/mh/sleeping_habit_controller.dart
Normal file
@@ -0,0 +1,94 @@
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:dio/src/form_data.dart' as formdata;
|
||||
import 'package:ef/ef.dart';
|
||||
import 'package:json_annotation/json_annotation.dart';
|
||||
|
||||
part 'sleeping_habit_controller.g.dart'; // 由json_serializable自动生成的部分
|
||||
|
||||
@JsonSerializable()
|
||||
class SleepingHabitModel {
|
||||
bool rxhxIsStart = false;
|
||||
List<int> rxhxWakeTime = [0, 0];
|
||||
bool rxhxIsBell = false;
|
||||
bool rxhxIsAnMo = false;
|
||||
int rxhxLocation = 0;
|
||||
List rxhxWeeks = [0, 0, 0, 0, 0, 0, 0];
|
||||
|
||||
bool dhgyIsStart = false;
|
||||
|
||||
bool smysIsStart = false;
|
||||
List<int> smysStartTime = [20, 0];
|
||||
List<int> smysEndTime = [9, 0];
|
||||
|
||||
String get rxhxWakeTimeToString {
|
||||
return '${rxhxWakeTime[0]}'.padLeft(2, "0") +
|
||||
":" +
|
||||
'${rxhxWakeTime[1]}'.padLeft(2, "0");
|
||||
}
|
||||
|
||||
String get smysStartTimeToString {
|
||||
return '${smysStartTime[0]}'.padLeft(2, "0") +
|
||||
":" +
|
||||
'${smysStartTime[1]}'.padLeft(2, "0");
|
||||
}
|
||||
|
||||
String get smysEndTimeToString {
|
||||
return '${smysEndTime[0]}'.padLeft(2, "0") +
|
||||
":" +
|
||||
'${smysEndTime[1]}'.padLeft(2, "0");
|
||||
}
|
||||
|
||||
SleepingHabitModel();
|
||||
|
||||
factory SleepingHabitModel.fromJson(Map<String, dynamic> json) {
|
||||
try {
|
||||
return _$SleepingHabitModelFromJson(json);
|
||||
} catch (e) {
|
||||
print("$e");
|
||||
// 在实际应用中,应该有更细致的异常处理策略和错误日志
|
||||
return SleepingHabitModel(); // 或者返回一个带有错误信息的特定AboutModel实例
|
||||
}
|
||||
}
|
||||
Map<String, dynamic> toJson() => _$SleepingHabitModelToJson(this);
|
||||
}
|
||||
|
||||
class SleepingHabitController extends GetControllerEx<SleepingHabitModel> {
|
||||
SleepingHabitController() {
|
||||
attr = GetModel(SleepingHabitModel()).obs;
|
||||
}
|
||||
|
||||
// saveDataApi() {
|
||||
// String mac = Get.find<GlobalController>().model.deviceMain["mac"];
|
||||
// ApiService.request.post("/api/device/info/config",
|
||||
// data: formdata.FormData.fromMap({
|
||||
// "mac": mac,
|
||||
// "type": "sleepHabit",
|
||||
// "data": jsonEncode(model.toJson())
|
||||
// }));
|
||||
// }
|
||||
|
||||
// loadDataApi({int time = 3}) {
|
||||
// String mac = Get.find<GlobalController>().model.deviceMain["mac"];
|
||||
|
||||
// ApiService.request
|
||||
// .get("/api/device/info/config?type=sleepHabit&mac=${mac}")
|
||||
// .then((d) async {
|
||||
// if (d.data["data"] != null && d.data["data"]["data"] != null) {
|
||||
// attr.value.model =
|
||||
// SleepingHabitModel.fromJson(jsonDecode(d.data["data"]["data"]));
|
||||
// print("load ${model.toJson()}");
|
||||
// } else {
|
||||
// attr.value.model = SleepingHabitModel();
|
||||
// print("load error");
|
||||
// }
|
||||
// updateAll();
|
||||
// }).catchError((d) {
|
||||
// if (time > 0) {
|
||||
// loadDataApi(time: time - 1);
|
||||
// } else {
|
||||
// attr.value.model = SleepingHabitModel();
|
||||
// }
|
||||
// });
|
||||
// }
|
||||
}
|
||||
40
lib/controller/mh/sleeping_habit_controller.g.dart
Normal file
40
lib/controller/mh/sleeping_habit_controller.g.dart
Normal file
@@ -0,0 +1,40 @@
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
|
||||
part of 'sleeping_habit_controller.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// JsonSerializableGenerator
|
||||
// **************************************************************************
|
||||
|
||||
SleepingHabitModel _$SleepingHabitModelFromJson(Map<String, dynamic> json) =>
|
||||
SleepingHabitModel()
|
||||
..rxhxIsStart = json['rxhxIsStart'] as bool
|
||||
..rxhxWakeTime = (json['rxhxWakeTime'] as List<dynamic>)
|
||||
.map((e) => (e as num).toInt())
|
||||
.toList()
|
||||
..rxhxIsBell = json['rxhxIsBell'] as bool
|
||||
..rxhxIsAnMo = json['rxhxIsAnMo'] as bool
|
||||
..rxhxLocation = (json['rxhxLocation'] as num).toInt()
|
||||
..rxhxWeeks = json['rxhxWeeks'] as List<dynamic>
|
||||
..dhgyIsStart = json['dhgyIsStart'] as bool
|
||||
..smysIsStart = json['smysIsStart'] as bool
|
||||
..smysStartTime = (json['smysStartTime'] as List<dynamic>)
|
||||
.map((e) => (e as num).toInt())
|
||||
.toList()
|
||||
..smysEndTime = (json['smysEndTime'] as List<dynamic>)
|
||||
.map((e) => (e as num).toInt())
|
||||
.toList();
|
||||
|
||||
Map<String, dynamic> _$SleepingHabitModelToJson(SleepingHabitModel instance) =>
|
||||
<String, dynamic>{
|
||||
'rxhxIsStart': instance.rxhxIsStart,
|
||||
'rxhxWakeTime': instance.rxhxWakeTime,
|
||||
'rxhxIsBell': instance.rxhxIsBell,
|
||||
'rxhxIsAnMo': instance.rxhxIsAnMo,
|
||||
'rxhxLocation': instance.rxhxLocation,
|
||||
'rxhxWeeks': instance.rxhxWeeks,
|
||||
'dhgyIsStart': instance.dhgyIsStart,
|
||||
'smysIsStart': instance.smysIsStart,
|
||||
'smysStartTime': instance.smysStartTime,
|
||||
'smysEndTime': instance.smysEndTime,
|
||||
};
|
||||
22
lib/controller/mh/user_data.dart
Normal file
22
lib/controller/mh/user_data.dart
Normal file
@@ -0,0 +1,22 @@
|
||||
import 'package:json_annotation/json_annotation.dart';
|
||||
|
||||
part 'user_data.g.dart';
|
||||
|
||||
@JsonSerializable()
|
||||
class UserModel {
|
||||
String? uid;
|
||||
String? userName;
|
||||
String? nickName;
|
||||
String? tel;
|
||||
String? avatar;
|
||||
String? exp1;
|
||||
String? exp2;
|
||||
String? head;
|
||||
String? tmpHead;
|
||||
String? tmpNickName;
|
||||
|
||||
UserModel();
|
||||
static UserModel fromJson(Map<String, dynamic> json) =>
|
||||
_$UserModelFromJson(json);
|
||||
Map<String, dynamic> toJson() => _$UserModelToJson(this);
|
||||
}
|
||||
32
lib/controller/mh/user_data.g.dart
Normal file
32
lib/controller/mh/user_data.g.dart
Normal file
@@ -0,0 +1,32 @@
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
|
||||
part of 'user_data.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// JsonSerializableGenerator
|
||||
// **************************************************************************
|
||||
|
||||
UserModel _$UserModelFromJson(Map<String, dynamic> json) => UserModel()
|
||||
..uid = json['uid'] as String?
|
||||
..userName = json['userName'] as String?
|
||||
..nickName = json['nickName'] as String?
|
||||
..tel = json['tel'] as String?
|
||||
..avatar = json['avatar'] as String?
|
||||
..exp1 = json['exp1'] as String?
|
||||
..exp2 = json['exp2'] as String?
|
||||
..head = json['head'] as String?
|
||||
..tmpHead = json['tmpHead'] as String?
|
||||
..tmpNickName = json['tmpNickName'] as String?;
|
||||
|
||||
Map<String, dynamic> _$UserModelToJson(UserModel instance) => <String, dynamic>{
|
||||
'uid': instance.uid,
|
||||
'userName': instance.userName,
|
||||
'nickName': instance.nickName,
|
||||
'tel': instance.tel,
|
||||
'avatar': instance.avatar,
|
||||
'exp1': instance.exp1,
|
||||
'exp2': instance.exp2,
|
||||
'head': instance.head,
|
||||
'tmpHead': instance.tmpHead,
|
||||
'tmpNickName': instance.tmpNickName,
|
||||
};
|
||||
Reference in New Issue
Block a user