123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511 |
- //
- // XYModifyUserInfoViewModel.m
- // Starbuds
- //
- // Created by 翟玉磊 on 2019/12/24.
- // Copyright © 2019 翟玉磊. All rights reserved.
- //
- #import "XYModifyUserInfoViewModel.h"
- #import "XYModifyUserInfoListModel.h"
- #import "XYUserOtherInfoManager.h"
- #import "XYCountryPhoneCodeModel.h"
- @interface XYModifyUserInfoViewModel(){
-
- }
- @property (nonatomic, strong) NSArray *profileNewArrs;
- @property (nonatomic, strong) NSArray *photoAblumArrs;
- @end
- @implementation XYModifyUserInfoViewModel
- - (instancetype)initWithInfoType:(ModifyUserInfo_Type)infoType; {
- if (self = [super init]) {
- _infoType = infoType;
- if (_infoType != ModifyUserInfo_Type_Main) {
- _userId = [XYUserInfoManager nowUser].userId;
- }
- [self initValue];
- }
- return self;
- }
- - (void)initValue {
-
- [self.dataSource removeAllObjects];
-
- XYUserInfoModel *nowUser = [XYUserInfoManager nowUser];
-
- if (self.infoType == ModifyUserInfo_Type_User || self.infoType == ModifyUserInfo_Type_Main) {
-
- if (self.infoType == ModifyUserInfo_Type_User) {
- XYModifyUserInfoListModel *userAvatarModel = [[XYModifyUserInfoListModel alloc] init];
- userAvatarModel.itemName = kLocalizedString(@"头像");
- userAvatarModel.isShowMore = YES;
- userAvatarModel.isShowBottomLine = YES;
- userAvatarModel.itemValue = nowUser.userAvatar;
- userAvatarModel.cellHeight = 58;
- [self.dataSource addObject:userAvatarModel];
-
- XYModifyUserInfoListModel *userNameModel = [[XYModifyUserInfoListModel alloc] init];
- userNameModel.itemName = kLocalizedString(@"昵称");
- userNameModel.isShowMore = YES;
- userNameModel.isShowBottomLine = YES;
- userNameModel.itemValue = nowUser.userName;
- userNameModel.cellHeight = 50;
- [self.dataSource addObject:userNameModel];
-
- NSString *sexStr = @"";
- if (nowUser.userSex == 0) {
- sexStr = kLocalizedString(@"保密");
- }else if (nowUser.userSex == 1) {
- sexStr = kLocalizedString(@"男士");
- }else if (nowUser.userSex == 2) {
- sexStr = kLocalizedString(@"女士");
- }
-
- XYModifyUserInfoListModel *sexModel = [[XYModifyUserInfoListModel alloc] init];
- sexModel.itemName = kLocalizedString(@"性别");
- sexModel.isShowMore = YES;
- sexModel.isShowBottomLine = YES;
- sexModel.itemValue = sexStr;
- sexModel.cellHeight = 50;
- [self.dataSource addObject:sexModel];
-
- XYModifyUserInfoListModel *ageModel = [[XYModifyUserInfoListModel alloc] init];
- ageModel.itemName = kLocalizedString(@"生日");
- ageModel.isShowMore = YES;
- ageModel.isShowBottomLine = YES;
- NSString *strTime = [XYUserInfoManager nowUser].userBornTime;
- ageModel.itemValue = [SystemTimeObject timestampSwitchTime:strTime andFormatter:@"yyyy-MM-dd"];
- ageModel.cellHeight = 50;
- [self.dataSource addObject:ageModel];
-
- if ([[XYUserInfoManager nowUser].countryId isEqualToString:@"1"]) {
- XYModifyUserInfoListModel *countryModel = [[XYModifyUserInfoListModel alloc] init];
- countryModel.itemName = kLocalizedString(@"国家");
- countryModel.isShowMore = YES;
- countryModel.isShowBottomLine = YES;
- countryModel.itemValue = StringIsEmpty(nowUser.countryName)?kLocalizedString(@"请选择"):nowUser.countryName;
- countryModel.cellHeight = 50;
- [self.dataSource addObject:countryModel];
-
- XYModifyUserInfoListModel *cityModel = [[XYModifyUserInfoListModel alloc] init];
- cityModel.itemName = kLocalizedString(@"城市");
- cityModel.isShowMore = YES;
- cityModel.isShowBottomLine = YES;
- cityModel.itemValue = StringIsEmpty(nowUser.areaCity)?kLocalizedString(@"请选择"):nowUser.areaCity;
- cityModel.cellHeight = 50;
- [self.dataSource addObject:cityModel];
-
- }else {
- XYModifyUserInfoListModel *countryModel = [[XYModifyUserInfoListModel alloc] init];
- countryModel.itemName = kLocalizedString(@"国家");
- countryModel.isShowMore = YES;
- countryModel.isShowBottomLine = YES;
- countryModel.itemValue = StringIsEmpty(nowUser.countryName)?kLocalizedString(@"请选择"):nowUser.countryName;
- countryModel.cellHeight = 50;
- [self.dataSource addObject:countryModel];
- }
-
- XYModifyUserInfoListModel *sectionlyModel0 = [[XYModifyUserInfoListModel alloc] init];
- sectionlyModel0.groupName = kLocalizedString(@"个性签名");
- sectionlyModel0.isSection = YES;
- sectionlyModel0.cellHeight = 38;
- [self.dataSource addObject:sectionlyModel0];
-
- XYModifyUserInfoListModel *userIntroModel = [[XYModifyUserInfoListModel alloc] init];
- userIntroModel.itemType = XYModifyTtem_INPUT_SIGN;
- userIntroModel.cellHeight = 72;
- userIntroModel.itemValue = nowUser.userSign;
- [self.dataSource addObject:userIntroModel];
- //if (userIntroModel.itemValue.length) {
- sectionlyModel0.groupScore = -1;
- //}
-
- }else{
- if (self.photoAblumArrs.count) {
- //相册
- XYModifyUserInfoListModel *photoModel = [[XYModifyUserInfoListModel alloc] init];
- photoModel.itemType = XYModifyTtem_PHOTO_ABLUM;
- photoModel.cellHeight = 162;
- photoModel.groupScore = 100;
- [self.dataSource addObject:photoModel];
-
- photoModel.photoAlbumArrs = [[NSMutableArray alloc] init];
- for (NSDictionary *dict in self.photoAblumArrs) {
- XYFeedModel *model = XYFeedModel.new;
- [model yy_modelSetWithDictionary:dict];
- [photoModel.photoAlbumArrs addObject:model];
- }
-
- }
- }
-
- if (([XYUserInfoManager nowUser].userScore < 50) && (self.infoType == ModifyUserInfo_Type_Main) && ([self.userId isEqualToString:[XYUserInfoManager nowUser].userId])) {
- XYModifyUserInfoListModel *userInfoEditAlertModel = [[XYModifyUserInfoListModel alloc] init];
- userInfoEditAlertModel.itemType = XYModifyTtem_USERINFO_EDITALERT;
- userInfoEditAlertModel.cellHeight = 100;
- userInfoEditAlertModel.groupScore = 100;
- [self.dataSource addObject:userInfoEditAlertModel];
- }
-
- NSMutableArray *answerArrs = [[NSMutableArray alloc] init];
-
- //profileNew接口数据(资料配置项数据)
- for (NSDictionary *groupDict in self.profileNewArrs) {
-
- XYModifyUserInfoListModel *sectionlyModel0 = [[XYModifyUserInfoListModel alloc] init];
- [sectionlyModel0 yy_modelSetWithDictionary:groupDict];
- sectionlyModel0.isSection = YES;
- sectionlyModel0.cellHeight = 38;//section默认高
- sectionlyModel0.userInfoType = self.infoType;
- [self.dataSource addObject:sectionlyModel0];
-
- NSArray *childArrs = groupDict[@"childItems"];
- for (NSDictionary *childDIct in childArrs) {
- XYModifyUserInfoListModel *model = [[XYModifyUserInfoListModel alloc] init];
- [model yy_modelSetWithDictionary:groupDict];
-
- [model yy_modelSetWithDictionary:childDIct];
-
- model.userInfoType = self.infoType;
-
- if (self.infoType == ModifyUserInfo_Type_Main) { model.groupScore = 0; }
-
- model.tagColor = model.tagColor?model.tagColor:@"000000";
- model.textColor = model.textColor?model.textColor:@"FFFFFF";
-
- model.cellHeight = 50;//cell默认高
- [self.dataSource addObject:model];
-
- if(model.itemType == XYModifyTtem_SINGLE_OPTION){
- //选项数组(用逗号分隔字符串)
- NSData *itemOptionsData = [model.itemOptions dataUsingEncoding:NSUTF8StringEncoding];
- NSArray *optionsarray = [NSJSONSerialization JSONObjectWithData:itemOptionsData options:NSJSONReadingMutableContainers error:nil];
-
- for (int i= 0 ; i< optionsarray.count;i++) {
- NSDictionary *dict = optionsarray[i];
- if (i == 0) {
- model.itemOptions = dict[@"content"];
- }else{
- model.itemOptions = [NSString stringWithFormat:@"%@,%@",model.itemOptions,dict[@"content"]];
- }
- }
-
- }else if(model.itemType == XYModifyTtem_MULTI_OPTION){
- //选项数组(用逗号分隔字符串)
- NSData *itemOptionsData = [model.itemOptions dataUsingEncoding:NSUTF8StringEncoding];
- NSArray *optionsarray = [NSJSONSerialization JSONObjectWithData:itemOptionsData options:NSJSONReadingMutableContainers error:nil];
-
- for (int i= 0 ; i< optionsarray.count;i++) {
- NSDictionary *dict = optionsarray[i];
- if (i == 0) {
- model.itemOptions = dict[@"content"];
- }else{
- model.itemOptions = [NSString stringWithFormat:@"%@,%@",model.itemOptions,dict[@"content"]];
- }
- }
-
- //值数组
- if (model.itemValue.length) {
- float tagWidth = kScreenWidth;
- if (self.infoType == ModifyUserInfo_Type_Main) {
- //和标题下行显示
- model.cellHeight = 40;
-
- XYModifyUserInfoListModel *sectionModel;
- for (XYModifyUserInfoListModel *tempModel in self.dataSource) {
- if (tempModel.isSection) {
- sectionModel = tempModel;
- }
- }
- //和标题同行显示
- if ([sectionModel.groupName isEqualToString:model.itemName]) {
- tagWidth = kScreenWidth + 1;
- model.cellHeight = 10;
- }
- }
- model.tagWidth = tagWidth;
- NSArray *tags = [model.itemValue componentsSeparatedByString:@","];
- XYTagListView *taglistView = [XYTagListView getTagView:tags andBgColor:[UIColor colorWithHexString:model.tagColor alpha:1] andTextColor:[UIColor colorWithHexString:model.textColor alpha:1] andWidth:tagWidth-10];
- model.cellHeight = model.cellHeight + taglistView.height + 12;
- [taglistView removeFromSuperview];
- taglistView = nil;
-
- }
-
- }else if(model.itemType == XYModifyTtem_INPUT_CONTENT){
- float itemValueHeight = [HandleString autoLabelWith:model.itemValue withSize:CGSizeMake(kScreenWidth-140, MAXFLOAT) withFont:Font(14) withLines:0].height;
- model.cellHeight = (itemValueHeight+30)>50?(itemValueHeight+30):50;
-
- }else if(model.itemType == XYModifyTtem_ADD_QA){//用数组单独处理
- //[self parseAnswerData:groupDict];
- //break;
-
- //问题标题和答案 yymodel已处理
- //"itemName" : "想去哪儿?",
- //"itemValue" : "阿萨德",
- [self.dataSource removeLastObject];
- [answerArrs addObject:model];
-
- //model.itemOptions 处理为字符串逗号分隔
-
- //问题选项数据处理
- NSData *itemOptionsData = [model.itemOptions dataUsingEncoding:NSUTF8StringEncoding];
- NSDictionary *itemoptionsDict = [NSJSONSerialization JSONObjectWithData:itemOptionsData options:NSJSONReadingMutableContainers error:nil];
- model.moduleId = [itemoptionsDict[@"moduleId"] integerValue];
- NSArray *optionsarray = itemoptionsDict[@"list"];
- for (int i = 0 ; i< optionsarray.count;i++) {
- NSDictionary *dict = optionsarray[i];
- if (i == 0) {
- model.itemOptions = dict[@"content"];
- }else{
- model.itemOptions = [NSString stringWithFormat:@"%@,%@",model.itemOptions,dict[@"content"]];
- }
- }
-
- }
- }
- }
-
- //查看用户主页childItems有答案时加入数组
- int answerItemValueCount = 0;
- for (XYModifyUserInfoListModel *tempmodel in answerArrs) {
-
- answerItemValueCount++;
- if (self.infoType == ModifyUserInfo_Type_Main) {
- if (!StringIsEmpty(tempmodel.itemValue)) {
- [self.dataSource addObject:tempmodel];
- }
- }else{
- [self.dataSource addObject:tempmodel];
- }
-
- float questionHeight = [HandleString autoLabelWith:tempmodel.itemName withSize:CGSizeMake(kScreenWidth-85, MAXFLOAT) withFont:Font(14) withLines:0].height;
- float answerHeight = [HandleString autoLabelWith:tempmodel.itemValue withSize:CGSizeMake(kScreenWidth-85, MAXFLOAT) withFont:Font(14) withLines:0].height;
- tempmodel.cellHeight = 15 + (questionHeight>10?questionHeight:20) + 4 + (answerHeight>10?answerHeight:20);
-
- }
-
- // //childItems没有答案,默认一个入口答题model
- // if (!answerItemValueCount) {
- // XYModifyUserInfoListModel *tempmodel = [answerArrs firstObject];
- // tempmodel.cellHeight = 260;
- // [self.dataSource addObject:tempmodel];
- // }
-
- if (self.infoType == ModifyUserInfo_Type_Main) {
- NSMutableArray *arr = [[NSMutableArray alloc] init];
- for (int i = 0 ; i < self.dataSource.count ; i++) {
- XYModifyUserInfoListModel *model = self.dataSource[i];
- model.userInfoType = self.infoType;
- if (!StringIsEmpty(model.itemValue) || model.groupScore > 0) {
- [arr addObject:model];
- if ([model.groupKey isEqualToString:@"profile"]) {
- model.groupName = @"基本信息";
- }
- }
- }
-
- [self.dataSource removeAllObjects];
- self.dataSource = arr;
- }
-
- // [self.dataSource addObject:[EmptyCellModel createModelWithIsShowTopLine:NO isShowBottomLine:NO cellHeight:10.0f]];
- //
- // XYModifyUserInfoListModel *phoneModel = [XYModifyUserInfoListModel createModelWithTitle:kLocalizedString(@"绑定手机") isShowMore:StringIsNotEmpty(self.userPhone)?NO:YES isShowBottomLine:NO content:StringIsEmpty(self.userPhone)?kLocalizedString(@"去绑定"):[NSString stringWithFormat:@"已绑定 %@", [self.userPhone substringWithRange:NSMakeRange(self.userPhone.length-4, 4)]]];
- // [self.dataSource addObject:phoneModel];
-
- // [self.dataSource addObject:[EmptyCellModel createModelWithIsShowTopLine:NO isShowBottomLine:NO cellHeight:10.0f]];
-
- /*//改为ProfileNew接口获取数据
-
- XYModifyUserInfoListModel *sectionlyModel = [XYModifyUserInfoListModel createModelWithTitle:kLocalizedString(@"其他信息") isShowMore:NO isShowBottomLine:NO content:@""];
- sectionlyModel.isSection = YES;
- sectionlyModel.cellHeight = 38.0f;
- [self.dataSource addObject:sectionlyModel];
-
- if ([[XYUserInfoManager nowUser].countryId isEqualToString:@"1"]) {
- XYModifyUserInfoListModel *countryModel = [XYModifyUserInfoListModel createModelWithTitle:kLocalizedString(@"国家") isShowMore:NO isShowBottomLine:YES content:StringIsEmpty(nowUser.countryName)?kLocalizedString(@"请选择"):nowUser.countryName];
- [self.dataSource addObject:countryModel];
-
- XYModifyUserInfoListModel *cityModel = [XYModifyUserInfoListModel createModelWithTitle:kLocalizedString(@"城市") isShowMore:NO isShowBottomLine:YES content:StringIsEmpty(nowUser.areaCity)?kLocalizedString(@"请选择"):nowUser.areaCity];
- [self.dataSource addObject:cityModel];
-
- }else {
- XYModifyUserInfoListModel *countryModel = [XYModifyUserInfoListModel createModelWithTitle:kLocalizedString(@"国家") isShowMore:NO isShowBottomLine:YES content:StringIsEmpty(nowUser.countryName)?kLocalizedString(@"请选择"):nowUser.countryName];
- [self.dataSource addObject:countryModel];
- }
-
- XYModifyUserInfoListModel *incomeModel = [XYModifyUserInfoListModel createModelWithTitle:kLocalizedString(@"收入") isShowMore:YES isShowBottomLine:YES content:StringIsEmpty(nowUser.userIncome)?@"":nowUser.userIncome];
- [self.dataSource addObject:incomeModel];
-
- XYModifyUserInfoListModel *weightModel = [XYModifyUserInfoListModel createModelWithTitle:kLocalizedString(@"体重") isShowMore:YES isShowBottomLine:YES content:nowUser.userWeight == 0?@"":[NSString stringWithFormat:@"%dkg", (int)nowUser.userWeight]];
- [self.dataSource addObject:weightModel];
-
- XYModifyUserInfoListModel *heightModel = [XYModifyUserInfoListModel createModelWithTitle:kLocalizedString(@"身高") isShowMore:YES isShowBottomLine:YES content:nowUser.userHeight == 0?@"":[NSString stringWithFormat:@"%dcm", (int)nowUser.userHeight]];
- [self.dataSource addObject:heightModel];
-
- XYModifyUserInfoListModel *userConstellationModel = [XYModifyUserInfoListModel createModelWithTitle:kLocalizedString(@"星座") isShowMore:YES isShowBottomLine:YES content:nowUser.userConstellation == 0?@"":[XYUserOtherInfoManager getConstellationValueWithKey:nowUser.userConstellation]];
- [self.dataSource addObject:userConstellationModel];
-
- XYModifyUserInfoListModel *purposeModel = [XYModifyUserInfoListModel createModelWithTitle:kLocalizedString(@"交友目的") isShowMore:YES isShowBottomLine:YES content:StringIsEmpty(nowUser.userMarkingFriends)?@"":nowUser.userMarkingFriends];
- [self.dataSource addObject:purposeModel];
-
- XYModifyUserInfoListModel *emotionModel = [XYModifyUserInfoListModel createModelWithTitle:kLocalizedString(@"情感状况") isShowMore:YES isShowBottomLine:YES content:StringIsEmpty(nowUser.userMarriage)?@"":nowUser.userMarriage];
- [self.dataSource addObject:emotionModel];
-
- XYModifyUserInfoListModel *hobbyModel = [XYModifyUserInfoListModel createModelWithTitle:kLocalizedString(@"兴趣爱好") isShowMore:YES isShowBottomLine:YES content:StringIsEmpty(nowUser.userHobby)?@"":nowUser.userHobby];
- [self.dataSource addObject:hobbyModel];
-
- XYModifyUserInfoListModel *individualityModel = [XYModifyUserInfoListModel createModelWithTitle:kLocalizedString(@"个性标签") isShowMore:YES isShowBottomLine:YES content:StringIsEmpty(nowUser.userTags)?@"":nowUser.userTags];
- [self.dataSource addObject:individualityModel];
- // [self.dataSource addObject:[EmptyCellModel createModelWithIsShowTopLine:NO isShowBottomLine:NO cellHeight:40.0f]];
- */
-
- }else {
- XYModifyUserInfoListModel *noModel = [XYModifyUserInfoListModel createModelWithTitle:@"ID" isShowMore:NO isShowBottomLine:YES content:[XYUserInfoManager nowUser].userNo];
- [self.dataSource addObject:noModel];
-
- XYModifyUserInfoListModel *coverModel = [XYModifyUserInfoListModel createModelWithTitle:kLocalizedString(@"颜值封面") isShowMore:YES isShowBottomLine:NO content:@""];
- [self.dataSource addObject:coverModel];
- }
- }
- //- (void)parseAnswerData:(NSDictionary *)groupDict{
- // XYModifyUserInfoListModel *sectionlyModel0 = [[XYModifyUserInfoListModel alloc] init];
- // [sectionlyModel0 yy_modelSetWithDictionary:groupDict];
- // [self.dataSource addObject:sectionlyModel0];
- //
- // sectionlyModel0.answerChildArrs = [[NSMutableArray alloc] init];
- //
- // NSArray *childArrs = groupDict[@"childItems"];
- // for (NSDictionary *childDict in childArrs) {
- // XYModifyUserInfoListModel *childmodel = [[XYModifyUserInfoListModel alloc] init];
- // [childmodel yy_modelSetWithDictionary:childDict];
- // [sectionlyModel0.answerChildArrs addObject:childmodel];
- // sectionlyModel0.itemType = childmodel.itemType;
- //
- // childmodel.answerChildItemOptionsArrs = [[NSMutableArray alloc] init];
- //
- // NSData *itemOptionsData = [childmodel.itemOptions dataUsingEncoding:NSUTF8StringEncoding];
- // NSDictionary *itemoptionsDict = [NSJSONSerialization JSONObjectWithData:itemOptionsData options:NSJSONReadingMutableContainers error:nil];
- // NSArray *optionsarray = itemoptionsDict[@"list"];
- // for (NSDictionary *itemDict in optionsarray) {
- // XYModifyUserInfoListModel *model1 = [[XYModifyUserInfoListModel alloc] init];
- // [childmodel.answerChildItemOptionsArrs addObject:model1];
- // model1.itemName = itemDict[@"content"];
- // model1.questionId = [itemDict[@"questionId"] integerValue];
- // model1.moduleId = [itemoptionsDict[@"moduleId"]integerValue];
- // }
- // }
- //
- // sectionlyModel0.answerView = [XYUserMainInformationAnswerView getAnswerView:sectionlyModel0];
- // sectionlyModel0.cellHeight = 15 + sectionlyModel0.cellHeight + sectionlyModel0.answerView.height + 15;
- //
- //}
- - (void)loadData:(SuccessHandler)success failure:(FailureHandler)failure {
-
- dispatch_group_t group = dispatch_group_create();
- dispatch_queue_t queue = dispatch_queue_create("modify.user.info.queue", DISPATCH_QUEUE_SERIAL);
-
- if (self.infoType != ModifyUserInfo_Type_Main) {//用户主页外层以获取
- dispatch_group_enter(group);
- dispatch_async(queue, ^{
- [[XYUserAPIManager new] getProfileSuccessHandler:^(ZYLResponseModel *responseModel) {
- dispatch_group_leave(group);
- } failureHandler:^(ZYLNetworkError *error) {
- dispatch_group_leave(group);
- }];
- });
- }
-
- if (self.infoType != ModifyUserInfo_Type_Main) {
- dispatch_group_enter(group);
- dispatch_async(queue, ^{
- [[XYUserAPIManager new] getBingAccountSuccessHandler:^(ZYLResponseModel *responseModel) {
- self.userPhone = responseModel.data[@"userPhone"];
- dispatch_group_leave(group);
- } failureHandler:^(ZYLNetworkError *error) {
- dispatch_group_leave(group);
- }];
- });
- }
-
- dispatch_group_enter(group);
- dispatch_async(queue, ^{
- [[XYUserAPIManager new] getProfileNew:self.userId successHandler:^(ZYLResponseModel *responseModel) {
- self.profileNewArrs = responseModel.data[@"list"];
- dispatch_group_leave(group);
- } failureHandler:^(ZYLNetworkError *error) {
- dispatch_group_leave(group);
- }];
- });
-
- if (self.infoType == ModifyUserInfo_Type_Main) {
- dispatch_group_enter(group);
- dispatch_async(queue, ^{
- [[XYFeedAPIManager new] getPhotoListWithLastId:self.lastId userId:self.userId successHandler:^(ZYLResponseModel *responseModel) {
- self.photoAblumArrs = responseModel.data[@"list"];
- dispatch_group_leave(group);
- // NSArray *list = responseModel.data[@"list"];
- // if ([self.lastId isEqualToString:@"0"]) {
- // [self.dataSource removeAllObjects];
- // if (list.count > 0 && [self.userId isEqualToString:[XYUserInfoManager nowUser].userId]) {
- // XYFeedModel *model = XYFeedModel.new;
- // [self.dataSource addObject:model];
- // }
- // }
- // for (NSDictionary *dict in list) {
- // XYFeedModel *model = XYFeedModel.new;
- // [model yy_modelSetWithDictionary:dict];
- // [self.dataSource addObject:model];
- // }
- // self.lastId = responseModel.data[@"lastId"];
- // self.perPage = [responseModel.data[@"pageSize"] integerValue];
- // !success?:success(self.dataSource);
- } failureHandler:^(ZYLNetworkError *error) {
- // !failure?:failure(error);
- dispatch_group_leave(group);
- }];
-
- });
- }
-
- dispatch_group_notify(group, queue, ^{
- dispatch_async(dispatch_get_main_queue(), ^{
- [self initValue];
- !success?:success(self.dataSource);
- });
- });
- }
- - (void)getCountryList:(SuccessHandler)success failure:(FailureHandler)failure {
- if (self.infoType != ModifyUserInfo_Type_Main) {
- [[XYConfigAPIManager new] getCountryPhoneCodeSuccessHandler:^(ZYLResponseModel *responseModel) {
- [self.countryList removeAllObjects];
- for (NSDictionary *dict in responseModel.data[@"list"]) {
- XYCountryPhoneCodeModel *model = [XYCountryPhoneCodeModel new];
- [model yy_modelSetWithDictionary:dict];
- [self.countryList addObject:model];
- }
- !success?:success(self.dataSource);
- } failureHandler:^(ZYLNetworkError *error) {
- !failure?:failure(error);
- }];
- }
- }
- - (NSMutableArray *)countryList {
- if (!_countryList) {
- _countryList = [NSMutableArray array];
- }
- return _countryList;
- }
- @end
|