设备 预约接口
This commit is contained in:
@@ -1,5 +1,13 @@
|
||||
import 'package:ef/ef.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:json_annotation/json_annotation.dart';
|
||||
import 'package:vbvs_app/common/color/ServiceConstant.dart';
|
||||
import 'package:vbvs_app/common/color/repair_status.dart';
|
||||
import 'package:vbvs_app/common/util/MyUtils.dart';
|
||||
import 'package:vbvs_app/common/util/myDialog/my_dialog_controller.dart';
|
||||
import 'package:vbvs_app/common/util/requestWithLog.dart';
|
||||
import 'package:vbvs_app/controller/user_info_controller.dart';
|
||||
import 'package:vbvs_app/model/user_data.dart';
|
||||
|
||||
part 'apply_repair_controller.g.dart';
|
||||
|
||||
@@ -91,69 +99,122 @@ class ApplyRepairController extends GetControllerEx<ApplyRepairModel> {
|
||||
// }
|
||||
// }
|
||||
|
||||
// //提交
|
||||
// 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}$');
|
||||
//提交
|
||||
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;
|
||||
// }
|
||||
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);
|
||||
String type = "repair_submit_${model.device_id}";
|
||||
String serviceAddress = ServiceConstant.service_address;
|
||||
String serviceName = ServiceConstant.server_service;
|
||||
String serviceApi = ServiceConstant.submit_repair;
|
||||
String queryUrl = "$serviceAddress$serviceName$serviceApi?type=$type";
|
||||
|
||||
// 组织请求数据
|
||||
final UserInfoController userInfoController =
|
||||
Get.find<UserInfoController>();
|
||||
UserModel user = userInfoController.model.user!;
|
||||
|
||||
Map<String, dynamic> data = {
|
||||
'apply_name': model.apply_name,
|
||||
'address': model.address,
|
||||
'desc': model.desc,
|
||||
'device_type': model.device_type,
|
||||
'issue_img': model.issue_img,
|
||||
'tel': model.tel,
|
||||
'uid': user.uid,
|
||||
'device_category': model.device_category,
|
||||
'device_id': model.device_id,
|
||||
'device_name': model.device_name,
|
||||
'status': model.status,
|
||||
};
|
||||
|
||||
// 发起插入请求(这里相当于之前的 saveRepair)
|
||||
requestWithLog(
|
||||
logTitle: "提交报修",
|
||||
method: MyHttpMethod.post,
|
||||
queryUrl: queryUrl,
|
||||
data: data,
|
||||
onSuccess: (res) {
|
||||
if (res.data is List && res.data.isNotEmpty) {
|
||||
final inserted = res.data[0];
|
||||
model.id = inserted['id'];
|
||||
model.create_time = DateTime.tryParse(inserted['create_time']);
|
||||
// TextSelectionOverlay
|
||||
// // saveRepairHistor
|
||||
// saveRepairHistory(
|
||||
// RepairProcessModel()
|
||||
// ..status = model.status
|
||||
// ..record_id = inserted['id'],
|
||||
// );
|
||||
showToast("提交成功!");
|
||||
} else {
|
||||
showToast("提交失败:未返回数据!");
|
||||
}
|
||||
},
|
||||
onFailure: (res) {
|
||||
showToast("提交失败!");
|
||||
},
|
||||
);
|
||||
|
||||
return message;
|
||||
}
|
||||
|
||||
// Future<void> getDeviceList() async {
|
||||
// final UserInfoController userInfoController =
|
||||
|
||||
@@ -5,9 +5,11 @@ import 'package:ef/ef.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/Dio.dart';
|
||||
import 'package:vbvs_app/common/util/MyUtils.dart';
|
||||
import 'package:vbvs_app/common/util/requestWithLog.dart';
|
||||
import 'package:vbvs_app/component/tool/TopSlideNotification.dart';
|
||||
import 'package:vbvs_app/controller/user_info_controller.dart';
|
||||
import 'package:vbvs_app/model/api_response.dart';
|
||||
|
||||
class BookInfoModel {
|
||||
@@ -38,53 +40,23 @@ class BookInfoController extends GetControllerEx<BookInfoModel> {
|
||||
attr = GetModel(BookInfoModel()).obs;
|
||||
}
|
||||
|
||||
// get userInfoController => Get.find<UserInfoController>();
|
||||
get userInfoController => Get.find<UserInfoController>();
|
||||
|
||||
Future<void> getData(String storeId) async {
|
||||
// 初始化模型
|
||||
getData(id) {
|
||||
model.datetimes = [];
|
||||
model.datetimes_index = null;
|
||||
model.dataT = {};
|
||||
updateAll();
|
||||
|
||||
String url =
|
||||
"https://crm-api.swes.com.cn/agent/userBook/config/detailConfigByStore?storeId=$storeId";
|
||||
|
||||
await requestWithLog(
|
||||
logTitle: "获取预约门店时间",
|
||||
method: MyHttpMethod.get,
|
||||
queryUrl: url,
|
||||
successMsg: "获取预约门店时间成功",
|
||||
errorMsg: "获取预约门店时间失败",
|
||||
onSuccess: (res) {
|
||||
final data = res.data;
|
||||
if (data != null) {
|
||||
model.datetimes = data["dateList"] ?? [];
|
||||
model.datetimes_index = 0;
|
||||
model.dataT = data;
|
||||
time_periodChange(); // 原来的 time_periodChange
|
||||
updateAll();
|
||||
}
|
||||
},
|
||||
onFailure: (res) {},
|
||||
);
|
||||
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();
|
||||
});
|
||||
}
|
||||
|
||||
// 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;
|
||||
@@ -95,27 +67,23 @@ class BookInfoController extends GetControllerEx<BookInfoModel> {
|
||||
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"]
|
||||
// });
|
||||
// }
|
||||
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)
|
||||
// });
|
||||
// }
|
||||
messageAdd(Map data) {
|
||||
return ApiService.request.post("/api/message/info",
|
||||
data: {"type": 0, "status": 1, "read": 1, "data": jsonEncode(data)});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -36,33 +36,6 @@ class DeviceListController extends GetControllerEx<DeviceListModel> {
|
||||
attr = GetModel(DeviceListModel()).obs;
|
||||
}
|
||||
|
||||
// @override
|
||||
// void onInit() {
|
||||
// super.onInit();
|
||||
// model.keyword = "";
|
||||
// getDeviceList(); // 正确的初始化数据调用
|
||||
// }
|
||||
|
||||
// getDeviceList({int time = 1}) async {
|
||||
// String search = (model.keyword != null && model.keyword!.isNotEmpty)
|
||||
// ? "?key=${model.keyword}"
|
||||
// : "";
|
||||
// var data = await ApiService.request.get("/api/device/info/list$search");
|
||||
// if (data.data["data"] != null) {
|
||||
// try {
|
||||
// List<dynamic> tmp = data.data["data"] as List<dynamic>;
|
||||
// model.deviceList = tmp.map((obj) => DeviceModel.fromJson(obj)).toList();
|
||||
// model.deviceListWyf = tmp;
|
||||
// } catch (e) {
|
||||
// print(e);
|
||||
// }
|
||||
// } else {
|
||||
// model.deviceList = [];
|
||||
// model.deviceListWyf = [];
|
||||
// }
|
||||
// updateAll();
|
||||
// }
|
||||
|
||||
getDeviceList() async {
|
||||
try {
|
||||
String search = (model.keyword != null && model.keyword!.isNotEmpty)
|
||||
@@ -82,8 +55,8 @@ class DeviceListController extends GetControllerEx<DeviceListModel> {
|
||||
MyUtils.formatResponse(res, "设备.设备列表请求成功".tr, "设备.设备列表请求失败".tr);
|
||||
if (res.code == HttpStatusCodes.ok) {
|
||||
// bindDeviceNum.value = res.total!;
|
||||
model.deviceList =res.data;
|
||||
|
||||
model.deviceList = res.data;
|
||||
|
||||
updateAll();
|
||||
return res;
|
||||
}
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
import 'dart:ui';
|
||||
|
||||
import 'package:ef/ef.dart';
|
||||
|
||||
import 'package:geolocator/geolocator.dart';
|
||||
|
||||
import 'package:json_annotation/json_annotation.dart';
|
||||
import 'package:vbvs_app/controller/weather/weather_controller.dart';
|
||||
import 'package:vbvs_app/common/util/Dio.dart';
|
||||
|
||||
part 'experience_store_list_page.g.dart';
|
||||
|
||||
@@ -27,99 +29,98 @@ class ExperienceStoreListController
|
||||
ExperienceStoreListController() {
|
||||
attr = GetModel(ExperienceStoreListModel()).obs;
|
||||
}
|
||||
WeatherModelController weatherModelController = Get.find();
|
||||
Position? position;
|
||||
double latitude = 31.8512;
|
||||
double longitude = 117.26061;
|
||||
|
||||
// Position? position;
|
||||
// double latitude = 31.8512;
|
||||
// double longitude = 117.26061;
|
||||
int total = 0;
|
||||
int page = 0;
|
||||
bool lock = false;
|
||||
|
||||
// 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();
|
||||
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 weatherModelController.determinePosition();
|
||||
}
|
||||
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();
|
||||
//}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:ef/ef.dart';
|
||||
|
||||
import 'package:vbvs_app/common/util/Dio.dart';
|
||||
import 'package:vbvs_app/common/util/MyUtils.dart';
|
||||
import 'package:vbvs_app/controller/user_info_controller.dart';
|
||||
|
||||
class BookExperienceListModel {
|
||||
List bookInfoList = []; //预约列表
|
||||
@@ -14,102 +16,102 @@ class BookExperienceListController
|
||||
attr = GetModel(BookExperienceListModel()).obs;
|
||||
}
|
||||
|
||||
// resetParm() {
|
||||
// model.bookInfoList = [];
|
||||
// model.experienceStoreModelList = [];
|
||||
// total = 0;
|
||||
// page = 0;
|
||||
// lock = false;
|
||||
// updateAll();
|
||||
// }
|
||||
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();
|
||||
// });
|
||||
// }
|
||||
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;
|
||||
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();
|
||||
// });
|
||||
// }
|
||||
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?.phone ?? "";
|
||||
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();
|
||||
// });
|
||||
// }
|
||||
cancelBook(id, {Function? success}) {
|
||||
String tel = Get.find<UserInfoController>().model.user?.phone ?? "";
|
||||
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)
|
||||
// });
|
||||
// }
|
||||
messageAdd(Map data) {
|
||||
return ApiService.request.post("/api/message/info", data: {
|
||||
"type": 0,
|
||||
"status": 1,
|
||||
"read": 1,
|
||||
"data": jsonEncode(data)
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user