home_view_model.dart 2.0 KB

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