成功预约
This commit is contained in:
parent
3c1995d118
commit
1a88faae34
|
|
@ -18,11 +18,11 @@ subprojects {
|
|||
// println "Namespace set to: ${packageName} for project: ${project.name}"
|
||||
|
||||
// 如果包名不包含 "com.baidu",则设置命名空间
|
||||
if (!packageName.contains('com.baidu')) {
|
||||
if (packageName.contains('com.baidu')) {
|
||||
println "Skipping namespace setting for project ${project.name} as the package name contains 'com.baidu' or 'isar_flutter_libs'"
|
||||
} else {
|
||||
project.android.namespace = packageName
|
||||
println "Namespace set to: ${packageName} for project: ${project.name}"
|
||||
} else {
|
||||
println "Skipping namespace setting for project ${project.name} as the package name contains 'com.baidu'"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,14 +8,10 @@ class ReserveLeftContentView extends StatelessWidget {
|
|||
final double contentWidth = 430;
|
||||
final double inputItemHeight = 36;
|
||||
final ReserveViewModel provider;
|
||||
final Animation<double> animationSizeFactor;
|
||||
final AnimationController animationController;
|
||||
|
||||
const ReserveLeftContentView(
|
||||
{super.key,
|
||||
required this.provider,
|
||||
required this.animationSizeFactor,
|
||||
required this.animationController});
|
||||
required this.provider});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
|
|
@ -33,7 +29,7 @@ class ReserveLeftContentView extends StatelessWidget {
|
|||
|
||||
Widget _buildBookingWidget(BuildContext context) {
|
||||
return SizeTransition(
|
||||
sizeFactor: animationSizeFactor,
|
||||
sizeFactor: provider.animationSizeFactor!,
|
||||
axis: Axis.vertical,
|
||||
axisAlignment: -1, // 设置为 -1,使动画从下往上开始
|
||||
child: Container(
|
||||
|
|
@ -89,7 +85,7 @@ class ReserveLeftContentView extends StatelessWidget {
|
|||
padding: const EdgeInsets.fromLTRB(20, 10, 20, 15),
|
||||
child: InkWell(
|
||||
onTap: () {
|
||||
animationController.forward();
|
||||
provider.showReserveInfoView();
|
||||
},
|
||||
child: Container(
|
||||
decoration: BoxDecoration(
|
||||
|
|
@ -187,7 +183,9 @@ class ReserveLeftContentView extends StatelessWidget {
|
|||
),
|
||||
const Expanded(child: SizedBox()),
|
||||
InkWell(
|
||||
onTap: () {},
|
||||
onTap: () {
|
||||
provider.execCallLog(model);
|
||||
},
|
||||
child: Container(
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(5),
|
||||
|
|
@ -277,7 +275,7 @@ class ReserveLeftContentView extends StatelessWidget {
|
|||
"请选择桌台",
|
||||
style: TextStyle(color: Color(0xff333333), fontSize: 14),
|
||||
),
|
||||
Text(provider.selectedTable?.name ?? "",
|
||||
Text(provider.showTableName,
|
||||
style:
|
||||
const TextStyle(color: Color(0xff333333), fontSize: 14)),
|
||||
],
|
||||
|
|
@ -335,11 +333,13 @@ class ReserveLeftContentView extends StatelessWidget {
|
|||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
||||
children: [
|
||||
_buildBookingActionBtn(context, "预约", () {}),
|
||||
_buildBookingActionBtn(context, "预约", () {
|
||||
provider.commitReserveInfo();
|
||||
}),
|
||||
_buildBookingActionBtn(context, "预约并短信", () {}),
|
||||
_buildBookingActionBtn(context, "发路线", () {}),
|
||||
_buildBookingActionBtn(context, "取消", () {
|
||||
animationController.reverse();
|
||||
provider.hideReserveInfoView();
|
||||
}),
|
||||
],
|
||||
),
|
||||
|
|
|
|||
|
|
@ -87,6 +87,7 @@ class ReserveRightContentView extends StatelessWidget {
|
|||
},
|
||||
tableClickFunc: (table) {
|
||||
yjPrint("table: ${table.name}");
|
||||
provider.clickTable(table);
|
||||
},
|
||||
),
|
||||
);
|
||||
|
|
|
|||
|
|
@ -39,6 +39,8 @@ class ReserveView extends BaseUI with TickerProviderStateMixin {
|
|||
ReserveViewModel provider =
|
||||
getProvider(context, listen: false) as ReserveViewModel;
|
||||
|
||||
provider.setAnimationController(animationController, animationSizeFactor);
|
||||
|
||||
return SizedBox(
|
||||
width: double.infinity,
|
||||
child: Column(
|
||||
|
|
@ -113,7 +115,7 @@ class ReserveView extends BaseUI with TickerProviderStateMixin {
|
|||
),
|
||||
InkWell(
|
||||
onTap: () {
|
||||
provider.loadCallLog();
|
||||
provider.reloadPageData();
|
||||
},
|
||||
child: const SizedBox(
|
||||
width: 40,
|
||||
|
|
@ -148,8 +150,6 @@ class ReserveView extends BaseUI with TickerProviderStateMixin {
|
|||
children: [
|
||||
ReserveLeftContentView(
|
||||
provider: provider,
|
||||
animationSizeFactor: animationSizeFactor,
|
||||
animationController: animationController,
|
||||
),
|
||||
Expanded(
|
||||
child: ReserveRightContentView(
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ import 'package:cashier_reserve/common/base/ui_model.dart';
|
|||
import 'package:cashier_reserve/common/channel/call_log_model.dart';
|
||||
import 'package:cashier_reserve/common/channel/channel_manager.dart';
|
||||
import 'package:cashier_reserve/common/manager/event_manager.dart';
|
||||
import 'package:cashier_reserve/common/utils/utils.dart';
|
||||
import 'package:cashier_reserve/data_model/reserve/table_area_model.dart';
|
||||
import 'package:cashier_reserve/data_model/reserve/table_model.dart';
|
||||
import 'package:cashier_reserve/model/reserve_model.dart';
|
||||
|
|
@ -25,6 +26,10 @@ class ReserveViewModel extends BaseUIModel {
|
|||
};
|
||||
|
||||
PageController pageController = PageController();
|
||||
AnimationController? _animationController;
|
||||
Animation<double>? _animationSizeFactor;
|
||||
|
||||
Animation<double>? get animationSizeFactor => _animationSizeFactor;
|
||||
|
||||
DateTime now = DateTime.now();
|
||||
|
||||
|
|
@ -34,6 +39,7 @@ class ReserveViewModel extends BaseUIModel {
|
|||
|
||||
List<TableAreaModel?>? _tableAreaList;
|
||||
List<TableAreaModel?>? get tableAreaList => _tableAreaList;
|
||||
Map<num, TableAreaModel?> _tableAreaMap = {};
|
||||
|
||||
List<TableModel?>? _tableList;
|
||||
List<TableModel?>? get tableList => _tableList;
|
||||
|
|
@ -41,6 +47,8 @@ class ReserveViewModel extends BaseUIModel {
|
|||
|
||||
List<CallLogModel?>? callLogs = [];
|
||||
|
||||
bool _isShowReserveInfoView = false;
|
||||
|
||||
/// bookingGender 预订人性别 1: 男 2: 女
|
||||
int bookingGender = 1;
|
||||
/// bookingNumController 就餐人数
|
||||
|
|
@ -66,6 +74,8 @@ class ReserveViewModel extends BaseUIModel {
|
|||
/// bookingStandardType 餐标类型
|
||||
String bookingStandardType = "table";
|
||||
|
||||
String showTableName = "";
|
||||
|
||||
TableModel? selectedTable;
|
||||
|
||||
ReserveViewModel() {
|
||||
|
|
@ -99,6 +109,12 @@ class ReserveViewModel extends BaseUIModel {
|
|||
super.dispose();
|
||||
}
|
||||
|
||||
reloadPageData() {
|
||||
loadCallLog();
|
||||
loadTableAreaList();
|
||||
loadAreaTableList(0);
|
||||
}
|
||||
|
||||
void loadCallLog() {
|
||||
ChannelManager.getCallLog("getCallLog");
|
||||
}
|
||||
|
|
@ -110,6 +126,11 @@ class ReserveViewModel extends BaseUIModel {
|
|||
|
||||
_tableAreaList ??= [];
|
||||
|
||||
_tableAreaMap = {};
|
||||
for (var item in _tableAreaList!) {
|
||||
_tableAreaMap[item!.id!] = item;
|
||||
}
|
||||
|
||||
_tableAreaList!.insert(0, TableAreaModel(id: 0, name: "全部"));
|
||||
|
||||
notifyListeners();
|
||||
|
|
@ -135,6 +156,36 @@ class ReserveViewModel extends BaseUIModel {
|
|||
notifyListeners();
|
||||
}
|
||||
|
||||
void commitReserveInfo() async {
|
||||
if (!_checkReserveInfo()) {
|
||||
return;
|
||||
}
|
||||
|
||||
Map<String, dynamic> params = {
|
||||
"shopTableId": selectedTable!.id,
|
||||
"bookingDate": selectedDate,
|
||||
"bookingType": bookingType,
|
||||
"dinerNum": bookingNumController.text,
|
||||
"phoneNumber": bookingPhoneController.text,
|
||||
"bookingPerson": bookingNameController.text,
|
||||
"gender": bookingGender,
|
||||
"bookingTime": '$selectedDate $bookingSelectedTime:00',
|
||||
"diningType": bookingTypeController.text,
|
||||
"focus": bookingFocus ? 1 : 0,
|
||||
"receiveMarketingSms": bookingSms ? 1 : 0,
|
||||
"bookingTableNum": bookingTableNumController.text,
|
||||
"diningStandardPrice": bookingStandardController.text,
|
||||
"diningStandardUnit": bookingStandardType,
|
||||
"remark": bookingRemarkController.text,
|
||||
};
|
||||
|
||||
await ReserveModel.commitReserveInfo(params);
|
||||
|
||||
Utils.toast("预定成功", context);
|
||||
hideReserveInfoView();
|
||||
loadAreaTableList(0);
|
||||
}
|
||||
|
||||
void setSelectedDateIndex(int index) {
|
||||
selectedDateIndex = index;
|
||||
|
||||
|
|
@ -147,6 +198,30 @@ class ReserveViewModel extends BaseUIModel {
|
|||
loadAreaTableList(0);
|
||||
}
|
||||
|
||||
void setAnimationController(AnimationController controller, Animation<double> sizeFactor) {
|
||||
_animationController = controller;
|
||||
_animationSizeFactor = sizeFactor;
|
||||
}
|
||||
|
||||
showReserveInfoView() {
|
||||
_resetReserveData();
|
||||
_isShowReserveInfoView = true;
|
||||
_animationController?.forward();
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
hideReserveInfoView() {
|
||||
_isShowReserveInfoView = false;
|
||||
_animationController?.reverse();
|
||||
}
|
||||
|
||||
execCallLog(CallLogModel? callLog) {
|
||||
showReserveInfoView();
|
||||
bookingPhoneController.text = callLog?.number ?? "";
|
||||
bookingNameController.text = callLog?.name ?? "";
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
updateBookingTime(int hour, int minute) {
|
||||
bookingSelectedTime = "${hour.toString().padLeft(2, '0')}:${minute.toString().padLeft(2, '0')}";
|
||||
notifyListeners();
|
||||
|
|
@ -174,6 +249,70 @@ class ReserveViewModel extends BaseUIModel {
|
|||
notifyListeners();
|
||||
}
|
||||
|
||||
clickTable(TableModel table) {
|
||||
if (_isShowReserveInfoView) {
|
||||
if (table.bookingInfo != null) {
|
||||
Utils.toast("当前台桌已预定", context);
|
||||
return;
|
||||
}
|
||||
selectedTable = table;
|
||||
TableAreaModel? area = _tableAreaMap[table.areaId!];
|
||||
showTableName = "${area?.name ?? ""} - ${table.name}";
|
||||
notifyListeners();
|
||||
}
|
||||
}
|
||||
|
||||
_resetReserveData() {
|
||||
bookingGender = 1;
|
||||
bookingNumController.text = "";
|
||||
bookingPhoneController.text = "";
|
||||
bookingNameController.text = "";
|
||||
bookingTypeController.text = "";
|
||||
bookingTableNumController.text = "";
|
||||
bookingStandardController.text = "";
|
||||
bookingRemarkController.text = "";
|
||||
bookingSelectedTime = "";
|
||||
bookingFocus = false;
|
||||
bookingSms = false;
|
||||
bookingStandardType = "table";
|
||||
selectedTable = null;
|
||||
showTableName = "";
|
||||
}
|
||||
|
||||
bool _checkReserveInfo() {
|
||||
if (selectedTable == null) {
|
||||
Utils.toast("请选择台桌", context);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (bookingNumController.text.isEmpty) {
|
||||
Utils.toast("请输入就餐人数", context);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (bookingPhoneController.text.isEmpty) {
|
||||
Utils.toast("请输入联系电话", context);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (bookingNameController.text.isEmpty) {
|
||||
Utils.toast("请输入预订人姓名", context);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (bookingSelectedTime.isEmpty) {
|
||||
Utils.toast("请选择预订时间", context);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (bookingTypeController.text.isEmpty) {
|
||||
Utils.toast("请输入预订类型", context);
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
String getCurrentDate() {
|
||||
return "${now.year}/${now.month}/${now.day}";
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
import 'package:cashier_reserve/common/print/print.dart';
|
||||
import 'package:cashier_reserve/common/request/request_manager.dart';
|
||||
import 'package:cashier_reserve/data_model/reserve/table_area_model.dart';
|
||||
import 'package:cashier_reserve/data_model/reserve/table_model.dart';
|
||||
|
|
@ -36,4 +37,9 @@ class ReserveModel {
|
|||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
static Future<void> commitReserveInfo(Map<String, dynamic> params) async {
|
||||
final r = await RequestManager.post("/api/booking/shop-table", params);
|
||||
yjPrint(r);
|
||||
}
|
||||
}
|
||||
|
|
@ -298,6 +298,14 @@ packages:
|
|||
url: "https://pub.flutter-io.cn"
|
||||
source: hosted
|
||||
version: "4.0.0-dev.14"
|
||||
isar_flutter_libs:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: isar_flutter_libs
|
||||
sha256: "04a3f4035e213ddb6e78d0132a7c80296a085c2088c2a761b4a42ee5add36983"
|
||||
url: "https://pub.flutter-io.cn"
|
||||
source: hosted
|
||||
version: "4.0.0-dev.14"
|
||||
js:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
|
|
|||
|
|
@ -43,6 +43,7 @@ dependencies:
|
|||
percent_indicator: ^4.0.1
|
||||
event_bus: ^2.0.1
|
||||
hive: ^4.0.0-dev.2
|
||||
isar_flutter_libs: ^4.0.0-dev.13
|
||||
path_provider: ^2.1.0
|
||||
fluttertoast: ^8.2.8
|
||||
encrypt: ^5.0.3
|
||||
|
|
|
|||
Loading…
Reference in New Issue