status_card_item_vm.dart 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. import 'package:flutter/cupertino.dart';
  2. import 'package:flutter/material.dart';
  3. import 'package:riverpod_annotation/riverpod_annotation.dart';
  4. import 'package:router/ext/auto_router_extensions.dart';
  5. import 'package:shared/utils/log_utils.dart';
  6. import '../../../respository/services_respository.dart';
  7. import '../constants_services.dart';
  8. import '../modules/services/service_evaluate_create/service_evaluate_create_page.dart';
  9. part 'status_card_item_vm.g.dart';
  10. @riverpod
  11. class StatusCardItemVm extends _$StatusCardItemVm {
  12. late ServicesRespository serviceRespositoryInstance;
  13. late int _serviceId;
  14. late int _serviceTypeCode;
  15. late int _serviceStatusCode;
  16. initState(){
  17. Log.d("--------------------------initState---------------------");
  18. return null;
  19. }
  20. @override
  21. build(){
  22. // 引入数据仓库
  23. // serviceRespositoryInstance = ref.read(servicesRespositoryProvider);
  24. final state = initState();
  25. Log.d("--------------------------build---------------------");
  26. return state;
  27. }
  28. // void changeLoadingState(LoadState loadState, String? errorMsg) {
  29. // state = state.copyWith(
  30. // loadingState: loadState,
  31. // errorMessage: errorMsg
  32. // );
  33. // }
  34. setInitData(BuildContext context,int serviceId, int serviceTypeCode, int serviceStatusCode){
  35. _serviceId = serviceId;
  36. _serviceTypeCode = serviceTypeCode;
  37. _serviceStatusCode = serviceStatusCode;
  38. }
  39. handlerClickActionBtn(BuildContext context, Map<String, dynamic> actionBtn){
  40. final actionBtnCode = actionBtn['code']!.toString();
  41. switch (actionBtnCode) {
  42. case '0':
  43. // context.router.pushNamed('/detail');
  44. break;
  45. case '1':
  46. // context.router.pushNamed('/detail');
  47. break;
  48. case '2':
  49. // context.router.pushNamed('/detail');
  50. break;
  51. case '3':
  52. // context.router.pushNamed('/detail');
  53. break;
  54. case '4':
  55. // 去评价
  56. // context.router.pushNamed('/detail');
  57. ServiceEvaluateCreatePage.startInstance(id: _serviceId, serviceTypeCode: _serviceTypeCode,);
  58. break;
  59. default:
  60. break;
  61. }
  62. }
  63. }