122 lines
3.5 KiB
Dart
122 lines
3.5 KiB
Dart
import 'dart:convert';
|
|
|
|
import 'package:EasyDartModule/EasyDartModule.dart';
|
|
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/MyUtils.dart';
|
|
import 'package:vbvs_app/common/util/requestWithLog.dart';
|
|
import 'package:vbvs_app/component/tool/TopSlideNotification.dart';
|
|
import 'package:vbvs_app/model/api_response.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();
|
|
BookInfoModel.fromJson(Map<String, dynamic> json) {
|
|
// dateTime = json['dateTime'];
|
|
userName = json['userName'];
|
|
userPhone = json['userPhone'];
|
|
time_period = json['time_period'];
|
|
// select_time = json['select_time'];
|
|
select_time_index = json['select_time_index'];
|
|
}
|
|
}
|
|
|
|
class BookInfoController extends GetControllerEx<BookInfoModel> {
|
|
BookInfoController() {
|
|
attr = GetModel(BookInfoModel()).obs;
|
|
}
|
|
|
|
// get userInfoController => Get.find<UserInfoController>();
|
|
|
|
Future<void> getData(String storeId) async {
|
|
// 初始化模型
|
|
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) {},
|
|
);
|
|
}
|
|
|
|
// 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)
|
|
// });
|
|
// }
|
|
}
|