chooseVisitTimeBottomFooter_vm.dart 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. import 'package:cpt_services/components/chooseVisitTimeTitle_vm.dart';
  2. import 'package:cpt_services/modules/services/service_order_confirm/service_order_confirm_vm.dart';
  3. import 'package:flutter/cupertino.dart';
  4. import 'package:flutter/material.dart';
  5. import 'package:plugin_platform/engine/toast/toast_engine.dart';
  6. import 'package:riverpod_annotation/riverpod_annotation.dart';
  7. import 'package:router/ext/auto_router_extensions.dart';
  8. import 'package:shared/utils/log_utils.dart';
  9. import 'package:widgets/dialog/dialog_content_wrap.dart';
  10. import '../../../respository/services_respository.dart';
  11. import 'chooseVisitTimeContent_vm.dart';
  12. part 'chooseVisitTimeBottomFooter_vm.g.dart';
  13. List<Map<String, dynamic>> airConditionList = [
  14. {
  15. "name": "Hanging air conditioner (unit)",
  16. "id": 1,
  17. "price": 40.0,
  18. },
  19. {
  20. "name": "Cabinet air conditioner (unit)",
  21. "id": 2,
  22. "price": 50.0,
  23. },
  24. {
  25. "name": "Cylindrical air conditioner (unit)",
  26. "id": 3,
  27. "price": 60.0,
  28. },
  29. {
  30. "name": "Central air conditioning (group)",
  31. "id": 4,
  32. "price": 70.0,
  33. },
  34. ];
  35. @riverpod
  36. class ChooseVisitTimeBottomFooterVm extends _$ChooseVisitTimeBottomFooterVm {
  37. // late ServicesRespository serviceRespositoryInstance;
  38. @override
  39. build(){
  40. // 引入数据仓库
  41. // serviceRespositoryInstance = ref.read(servicesRespositoryProvider);
  42. final state = null;
  43. Log.d("--------------------------build---------------------");
  44. return state;
  45. }
  46. handlerChangeNum(BuildContext context, int num, int index){
  47. // state.airConditionList[index].num = num;
  48. // state = state.copyWith(
  49. // airConditionList: state.airConditionList,
  50. // );
  51. }
  52. // 预约时间点击了confirm
  53. handlerClickVisitTimeConfirm(BuildContext context,{required int id, required String cleanServiceType} ){
  54. Log.d("handlerClickVisitTimeConfirm");
  55. final visitTimeContentVm = ref.read(chooseVisitTimeContentVmProvider.notifier);
  56. if(visitTimeContentVm.state.allSelectedTimeList !=null && visitTimeContentVm.state.allSelectedTimeList!.isNotEmpty ){
  57. // 有选中的时间
  58. // 关闭 visitTime 弹框
  59. // 需要更新 confirmOrdervm 的 visitTime
  60. final serviceOrderConfrimVm = ref.read(serviceOrderConfirmVmProvider.notifier);
  61. final visitTimeTitleVm = ref.read(chooseVisitTimeTitleVmProvider.notifier);
  62. final visitTimeContentVm = ref.read(chooseVisitTimeContentVmProvider.notifier);
  63. // String visitTime = visitTimeTitleVm.state.currentSelectDayInfoItem.date! + ' ' + visitTimeContentVm.state.allSelectedTimeList!.first?.time!;
  64. String visitTime = visitTimeContentVm.state.allSelectedTimeList!.first?.time!??'';
  65. serviceOrderConfrimVm.handlerHideVisitTimeDialog();
  66. serviceOrderConfrimVm.handlerUpdateVisitTime(visitTime);
  67. }else {
  68. // 没有选中预约时间
  69. ToastEngine.show("Please Choose Visit Time");
  70. }
  71. }
  72. }