From 20877a3eb11699ec701507d0b5d576fe6b906b6a Mon Sep 17 00:00:00 2001 From: userGyl Date: Thu, 11 Dec 2025 10:36:59 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=BC=B9=E7=AA=97=E9=99=90?= =?UTF-8?q?=E5=88=B6=E6=9D=A1=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../lib/pages/b_page/site/controller.dart | 5 +-- .../lib/pages/c_page/car_info/controller.dart | 2 +- .../pages/c_page/reservation/controller.dart | 33 +++++++++++++++---- 3 files changed, 30 insertions(+), 10 deletions(-) diff --git a/ln_jq_app/lib/pages/b_page/site/controller.dart b/ln_jq_app/lib/pages/b_page/site/controller.dart index 922d807..82147ca 100644 --- a/ln_jq_app/lib/pages/b_page/site/controller.dart +++ b/ln_jq_app/lib/pages/b_page/site/controller.dart @@ -521,15 +521,16 @@ class SiteController extends GetxController with BaseControllerMixin { } dismissLoading(); - //addStatus 1完成 2未加 -1拒绝 + //1完成 2未加 -1拒绝 if (addStatus == 1) { item.status = ReservationStatus.completed; item.amount = "${addHydAmount}kg"; } else if (addStatus == -1) { item.status = ReservationStatus.rejected; } else if (addStatus == 2) { - item.status = ReservationStatus.pending; + item.status = ReservationStatus.unadded; } + updateUi(); } catch (e) { dismissLoading(); diff --git a/ln_jq_app/lib/pages/c_page/car_info/controller.dart b/ln_jq_app/lib/pages/c_page/car_info/controller.dart index 871c06a..ac95c15 100644 --- a/ln_jq_app/lib/pages/c_page/car_info/controller.dart +++ b/ln_jq_app/lib/pages/c_page/car_info/controller.dart @@ -32,7 +32,7 @@ class CarInfoController extends GetxController with BaseControllerMixin { void onReady() { super.onReady(); // 如果未绑定车辆,且本次会话尚未提示过,则弹出提示 - if (!StorageService.to.hasShownBindVehicleDialog) { + if (!StorageService.to.hasShownBindVehicleDialog && StorageService.to.isLoggedIn) { Future.delayed(const Duration(milliseconds: 500), () { DialogX.to.showConfirmDialog( title: '当前尚未绑定车辆', diff --git a/ln_jq_app/lib/pages/c_page/reservation/controller.dart b/ln_jq_app/lib/pages/c_page/reservation/controller.dart index 2c37ac3..f2d79f3 100644 --- a/ln_jq_app/lib/pages/c_page/reservation/controller.dart +++ b/ln_jq_app/lib/pages/c_page/reservation/controller.dart @@ -1,3 +1,5 @@ +import 'dart:async'; + import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:get/get.dart'; @@ -116,8 +118,12 @@ class C_ReservationController extends GetxController with BaseControllerMixin { ), CupertinoButton( onPressed: () { - final bool isChangingToToday = tempDate.isAtSameMomentAs(today) && !selectedDate.value.isAtSameMomentAs(today); - final bool isDateChanged = !tempDate.isAtSameMomentAs(selectedDate.value); + final bool isChangingToToday = + tempDate.isAtSameMomentAs(today) && + !selectedDate.value.isAtSameMomentAs(today); + final bool isDateChanged = !tempDate.isAtSameMomentAs( + selectedDate.value, + ); // 更新选中的日期 selectedDate.value = tempDate; @@ -144,8 +150,10 @@ class C_ReservationController extends GetxController with BaseControllerMixin { child: CupertinoDatePicker( mode: CupertinoDatePickerMode.date, initialDateTime: selectedDate.value, - minimumDate: today, // 最小可选日期为今天 - maximumDate: tomorrow, // 最大可选日期为明天 + minimumDate: today, + // 最小可选日期为今天 + maximumDate: tomorrow, + // 最大可选日期为明天 // --------------------- onDateTimeChanged: (DateTime newDate) { tempDate = newDate; @@ -424,7 +432,7 @@ class C_ReservationController extends GetxController with BaseControllerMixin { ); //打开预约列表 - Future.delayed(const Duration(milliseconds: 800), () { + Future.delayed(const Duration(milliseconds: 500), () { getReservationList(); }); } else { @@ -442,8 +450,16 @@ class C_ReservationController extends GetxController with BaseControllerMixin { // 新增预约数据列表 List reservationList = []; + // --- 用于防抖的 Timer --- + Timer? _debounce; + //查看预约列表 void getReservationList() async { + if (_debounce?.isActive ?? false) { + return; + } + _debounce = Timer(const Duration(seconds: 1), () {}); + showLoading("加载中"); try { @@ -596,7 +612,7 @@ class C_ReservationController extends GetxController with BaseControllerMixin { ), ), ), - !reservation.hasEdit + !reservation.hasEdit || plateNumber.isEmpty ? SizedBox() : GestureDetector( onTap: () async { @@ -837,7 +853,7 @@ class C_ReservationController extends GetxController with BaseControllerMixin { HttpService.to.dio.options.headers = originalHeaders; // 如果未绑定车辆,且本次会话尚未提示过,则弹出提示 - if (!StorageService.to.hasShownBindVehicleDialog) { + if (!StorageService.to.hasShownBindVehicleDialog && StorageService.to.isLoggedIn) { Future.delayed(const Duration(milliseconds: 500), () { DialogX.to.showConfirmDialog( title: '当前尚未绑定车辆', @@ -864,6 +880,9 @@ class C_ReservationController extends GetxController with BaseControllerMixin { void onClose() { amountController.dispose(); plateNumberController.dispose(); + if (_debounce != null) { + _debounce?.cancel(); + } super.onClose(); } }