// // XYMarkingFriendsSkillListViewModel.m // Starbuds // // Created by 翟玉磊 on 2020/12/7. // Copyright © 2020 翟玉磊. All rights reserved. // #import "XYMarkingFriendsSkillListViewModel.h" #import "XYSkillUserModel.h" #import "XYFamilyAPIManager.h" @implementation XYMarkingFriendsSkillListViewModel - (instancetype)init { self = [super init]; if (self) { self.shouldPullUpToLoadMore = YES; } return self; } - (void)loadData:(SuccessHandler)success failure:(FailureHandler)failure { self.pullDown?self.page=1:self.page++; [[XYFamilyAPIManager new] getSkillUserListWithPageIndex:self.page skillId:self.skillId successHandler:^(ZYLResponseModel *responseModel) { if (self.page == 1) { [self.dataSource removeAllObjects]; } for (NSDictionary *dict in responseModel.data[@"list"]) { XYSkillUserModel *model = XYSkillUserModel.new; [model yy_modelSetWithDictionary:dict]; model.cellHeight = [XYSkillUserModel getFriendsCellHeightWithModel:model]; [self.dataSource addObject:model]; } !success?:success(responseModel); } failureHandler:^(ZYLNetworkError *error) { !failure?:failure(error); }]; } @end