XYMarkingFriendsSkillListViewModel.m 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. //
  2. // XYMarkingFriendsSkillListViewModel.m
  3. // Starbuds
  4. //
  5. // Created by 翟玉磊 on 2020/12/7.
  6. // Copyright © 2020 翟玉磊. All rights reserved.
  7. //
  8. #import "XYMarkingFriendsSkillListViewModel.h"
  9. #import "XYSkillUserModel.h"
  10. #import "XYFamilyAPIManager.h"
  11. @implementation XYMarkingFriendsSkillListViewModel
  12. - (instancetype)init
  13. {
  14. self = [super init];
  15. if (self) {
  16. self.shouldPullUpToLoadMore = YES;
  17. }
  18. return self;
  19. }
  20. - (void)loadData:(SuccessHandler)success failure:(FailureHandler)failure {
  21. self.pullDown?self.page=1:self.page++;
  22. [[XYFamilyAPIManager new] getSkillUserListWithPageIndex:self.page skillId:self.skillId successHandler:^(ZYLResponseModel *responseModel) {
  23. if (self.page == 1) {
  24. [self.dataSource removeAllObjects];
  25. }
  26. for (NSDictionary *dict in responseModel.data[@"list"]) {
  27. XYSkillUserModel *model = XYSkillUserModel.new;
  28. [model yy_modelSetWithDictionary:dict];
  29. model.cellHeight = [XYSkillUserModel getFriendsCellHeightWithModel:model];
  30. [self.dataSource addObject:model];
  31. }
  32. !success?:success(responseModel);
  33. } failureHandler:^(ZYLNetworkError *error) {
  34. !failure?:failure(error);
  35. }];
  36. }
  37. @end