home_view_model.dart 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. import 'package:cpt_main/modules/notification/notification_page.dart';
  2. import 'package:plugin_platform/engine/toast/toast_engine.dart';
  3. import 'package:riverpod_annotation/riverpod_annotation.dart';
  4. import 'package:router/componentRouter/community_service.dart';
  5. import 'package:router/componentRouter/component_service_manager.dart';
  6. import 'home_state.dart';
  7. part 'home_view_model.g.dart';
  8. @riverpod
  9. class HomeViewModel extends _$HomeViewModel {
  10. @override
  11. HomeState build() {
  12. return HomeState();
  13. }
  14. /// 根据索引触发点击的事件
  15. void switchCategory(int index) {
  16. switch (index) {
  17. case 0:
  18. //设备
  19. ComponentServiceManager().facilityService.startFacilityPage();
  20. break;
  21. case 1:
  22. //表单
  23. ComponentServiceManager().formService.startFormPage();
  24. break;
  25. case 2:
  26. //公告板
  27. ComponentServiceManager().noticeBoardService.startNoticeBoardPage();
  28. break;
  29. case 3:
  30. //房产
  31. ComponentServiceManager().propertyService.startPropertyPage();
  32. break;
  33. case 4:
  34. //广告服务
  35. ComponentServiceManager().servicesService.startServicePage();
  36. break;
  37. case 5:
  38. //社区
  39. ComponentServiceManager().communityService.startCommunityPage();
  40. break;
  41. }
  42. }
  43. //去消息通知页面
  44. void gotoNotificationPage() {
  45. NotificationPage.startInstance();
  46. }
  47. void gotoPaymentPage() {
  48. ComponentServiceManager().paymentService.startPaymentPage();
  49. }
  50. void gotoRewardsPage() {
  51. ComponentServiceManager().rewardsService.startRewardsPage();
  52. }
  53. void gotoLastNewsPage(){
  54. ToastEngine.show("去最近新闻的页面");
  55. }
  56. void gotoPropertyNewsPage(){
  57. ToastEngine.show("去房产新闻的页面");
  58. }
  59. void gotoManageGuidePage(){
  60. ToastEngine.show("去管理员指引的页面");
  61. }
  62. }