home_follow_cubit.dart 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. import 'package:bloc/bloc.dart';
  2. import 'package:meta/meta.dart';
  3. import 'package:common_project/common_project.dart';
  4. import 'package:module_home/dso/apis/home_main_api.dart';
  5. import 'package:module_home/model/home_hot_room_list_model.dart';
  6. part 'home_follow_state.dart';
  7. class HomeFollowCubit extends Cubit<HomeFollowState> {
  8. HomeFollowCubit() : super(HomeFollowState().init()) {
  9. myFavRoom();
  10. getHotRooms();
  11. }
  12. void myFavRoom()async{
  13. MeFavRoomModel model = await HomeMainApi.getFavRoomList(1);
  14. if(model.success == true && model.data != null){
  15. if(model.data!.list != null){
  16. emit(state.clone()..favRoomItems = model.data!.list!);
  17. }
  18. } else {
  19. emit(state.clone()..favRoomItems = []);
  20. }
  21. }
  22. void getHotRooms()async {
  23. HomeHotRoomListModel model = await HomeMainApi.getHotRoomList(pageIndex: 1, categoryId: "6");
  24. if(model.success == true && model.data != null){
  25. if(model.data!.list != null && model.data!.list!.length > 0){
  26. emit(state.clone()..hotRoomItems = model.data!.list);
  27. }
  28. }
  29. }
  30. }