XYModifyUserInfoViewModel.m 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511
  1. //
  2. // XYModifyUserInfoViewModel.m
  3. // Starbuds
  4. //
  5. // Created by 翟玉磊 on 2019/12/24.
  6. // Copyright © 2019 翟玉磊. All rights reserved.
  7. //
  8. #import "XYModifyUserInfoViewModel.h"
  9. #import "XYModifyUserInfoListModel.h"
  10. #import "XYUserOtherInfoManager.h"
  11. #import "XYCountryPhoneCodeModel.h"
  12. @interface XYModifyUserInfoViewModel(){
  13. }
  14. @property (nonatomic, strong) NSArray *profileNewArrs;
  15. @property (nonatomic, strong) NSArray *photoAblumArrs;
  16. @end
  17. @implementation XYModifyUserInfoViewModel
  18. - (instancetype)initWithInfoType:(ModifyUserInfo_Type)infoType; {
  19. if (self = [super init]) {
  20. _infoType = infoType;
  21. if (_infoType != ModifyUserInfo_Type_Main) {
  22. _userId = [XYUserInfoManager nowUser].userId;
  23. }
  24. [self initValue];
  25. }
  26. return self;
  27. }
  28. - (void)initValue {
  29. [self.dataSource removeAllObjects];
  30. XYUserInfoModel *nowUser = [XYUserInfoManager nowUser];
  31. if (self.infoType == ModifyUserInfo_Type_User || self.infoType == ModifyUserInfo_Type_Main) {
  32. if (self.infoType == ModifyUserInfo_Type_User) {
  33. XYModifyUserInfoListModel *userAvatarModel = [[XYModifyUserInfoListModel alloc] init];
  34. userAvatarModel.itemName = kLocalizedString(@"头像");
  35. userAvatarModel.isShowMore = YES;
  36. userAvatarModel.isShowBottomLine = YES;
  37. userAvatarModel.itemValue = nowUser.userAvatar;
  38. userAvatarModel.cellHeight = 58;
  39. [self.dataSource addObject:userAvatarModel];
  40. XYModifyUserInfoListModel *userNameModel = [[XYModifyUserInfoListModel alloc] init];
  41. userNameModel.itemName = kLocalizedString(@"昵称");
  42. userNameModel.isShowMore = YES;
  43. userNameModel.isShowBottomLine = YES;
  44. userNameModel.itemValue = nowUser.userName;
  45. userNameModel.cellHeight = 50;
  46. [self.dataSource addObject:userNameModel];
  47. NSString *sexStr = @"";
  48. if (nowUser.userSex == 0) {
  49. sexStr = kLocalizedString(@"保密");
  50. }else if (nowUser.userSex == 1) {
  51. sexStr = kLocalizedString(@"男士");
  52. }else if (nowUser.userSex == 2) {
  53. sexStr = kLocalizedString(@"女士");
  54. }
  55. XYModifyUserInfoListModel *sexModel = [[XYModifyUserInfoListModel alloc] init];
  56. sexModel.itemName = kLocalizedString(@"性别");
  57. sexModel.isShowMore = YES;
  58. sexModel.isShowBottomLine = YES;
  59. sexModel.itemValue = sexStr;
  60. sexModel.cellHeight = 50;
  61. [self.dataSource addObject:sexModel];
  62. XYModifyUserInfoListModel *ageModel = [[XYModifyUserInfoListModel alloc] init];
  63. ageModel.itemName = kLocalizedString(@"生日");
  64. ageModel.isShowMore = YES;
  65. ageModel.isShowBottomLine = YES;
  66. NSString *strTime = [XYUserInfoManager nowUser].userBornTime;
  67. ageModel.itemValue = [SystemTimeObject timestampSwitchTime:strTime andFormatter:@"yyyy-MM-dd"];
  68. ageModel.cellHeight = 50;
  69. [self.dataSource addObject:ageModel];
  70. if ([[XYUserInfoManager nowUser].countryId isEqualToString:@"1"]) {
  71. XYModifyUserInfoListModel *countryModel = [[XYModifyUserInfoListModel alloc] init];
  72. countryModel.itemName = kLocalizedString(@"国家");
  73. countryModel.isShowMore = YES;
  74. countryModel.isShowBottomLine = YES;
  75. countryModel.itemValue = StringIsEmpty(nowUser.countryName)?kLocalizedString(@"请选择"):nowUser.countryName;
  76. countryModel.cellHeight = 50;
  77. [self.dataSource addObject:countryModel];
  78. XYModifyUserInfoListModel *cityModel = [[XYModifyUserInfoListModel alloc] init];
  79. cityModel.itemName = kLocalizedString(@"城市");
  80. cityModel.isShowMore = YES;
  81. cityModel.isShowBottomLine = YES;
  82. cityModel.itemValue = StringIsEmpty(nowUser.areaCity)?kLocalizedString(@"请选择"):nowUser.areaCity;
  83. cityModel.cellHeight = 50;
  84. [self.dataSource addObject:cityModel];
  85. }else {
  86. XYModifyUserInfoListModel *countryModel = [[XYModifyUserInfoListModel alloc] init];
  87. countryModel.itemName = kLocalizedString(@"国家");
  88. countryModel.isShowMore = YES;
  89. countryModel.isShowBottomLine = YES;
  90. countryModel.itemValue = StringIsEmpty(nowUser.countryName)?kLocalizedString(@"请选择"):nowUser.countryName;
  91. countryModel.cellHeight = 50;
  92. [self.dataSource addObject:countryModel];
  93. }
  94. XYModifyUserInfoListModel *sectionlyModel0 = [[XYModifyUserInfoListModel alloc] init];
  95. sectionlyModel0.groupName = kLocalizedString(@"个性签名");
  96. sectionlyModel0.isSection = YES;
  97. sectionlyModel0.cellHeight = 38;
  98. [self.dataSource addObject:sectionlyModel0];
  99. XYModifyUserInfoListModel *userIntroModel = [[XYModifyUserInfoListModel alloc] init];
  100. userIntroModel.itemType = XYModifyTtem_INPUT_SIGN;
  101. userIntroModel.cellHeight = 72;
  102. userIntroModel.itemValue = nowUser.userSign;
  103. [self.dataSource addObject:userIntroModel];
  104. //if (userIntroModel.itemValue.length) {
  105. sectionlyModel0.groupScore = -1;
  106. //}
  107. }else{
  108. if (self.photoAblumArrs.count) {
  109. //相册
  110. XYModifyUserInfoListModel *photoModel = [[XYModifyUserInfoListModel alloc] init];
  111. photoModel.itemType = XYModifyTtem_PHOTO_ABLUM;
  112. photoModel.cellHeight = 162;
  113. photoModel.groupScore = 100;
  114. [self.dataSource addObject:photoModel];
  115. photoModel.photoAlbumArrs = [[NSMutableArray alloc] init];
  116. for (NSDictionary *dict in self.photoAblumArrs) {
  117. XYFeedModel *model = XYFeedModel.new;
  118. [model yy_modelSetWithDictionary:dict];
  119. [photoModel.photoAlbumArrs addObject:model];
  120. }
  121. }
  122. }
  123. if (([XYUserInfoManager nowUser].userScore < 50) && (self.infoType == ModifyUserInfo_Type_Main) && ([self.userId isEqualToString:[XYUserInfoManager nowUser].userId])) {
  124. XYModifyUserInfoListModel *userInfoEditAlertModel = [[XYModifyUserInfoListModel alloc] init];
  125. userInfoEditAlertModel.itemType = XYModifyTtem_USERINFO_EDITALERT;
  126. userInfoEditAlertModel.cellHeight = 100;
  127. userInfoEditAlertModel.groupScore = 100;
  128. [self.dataSource addObject:userInfoEditAlertModel];
  129. }
  130. NSMutableArray *answerArrs = [[NSMutableArray alloc] init];
  131. //profileNew接口数据(资料配置项数据)
  132. for (NSDictionary *groupDict in self.profileNewArrs) {
  133. XYModifyUserInfoListModel *sectionlyModel0 = [[XYModifyUserInfoListModel alloc] init];
  134. [sectionlyModel0 yy_modelSetWithDictionary:groupDict];
  135. sectionlyModel0.isSection = YES;
  136. sectionlyModel0.cellHeight = 38;//section默认高
  137. sectionlyModel0.userInfoType = self.infoType;
  138. [self.dataSource addObject:sectionlyModel0];
  139. NSArray *childArrs = groupDict[@"childItems"];
  140. for (NSDictionary *childDIct in childArrs) {
  141. XYModifyUserInfoListModel *model = [[XYModifyUserInfoListModel alloc] init];
  142. [model yy_modelSetWithDictionary:groupDict];
  143. [model yy_modelSetWithDictionary:childDIct];
  144. model.userInfoType = self.infoType;
  145. if (self.infoType == ModifyUserInfo_Type_Main) { model.groupScore = 0; }
  146. model.tagColor = model.tagColor?model.tagColor:@"000000";
  147. model.textColor = model.textColor?model.textColor:@"FFFFFF";
  148. model.cellHeight = 50;//cell默认高
  149. [self.dataSource addObject:model];
  150. if(model.itemType == XYModifyTtem_SINGLE_OPTION){
  151. //选项数组(用逗号分隔字符串)
  152. NSData *itemOptionsData = [model.itemOptions dataUsingEncoding:NSUTF8StringEncoding];
  153. NSArray *optionsarray = [NSJSONSerialization JSONObjectWithData:itemOptionsData options:NSJSONReadingMutableContainers error:nil];
  154. for (int i= 0 ; i< optionsarray.count;i++) {
  155. NSDictionary *dict = optionsarray[i];
  156. if (i == 0) {
  157. model.itemOptions = dict[@"content"];
  158. }else{
  159. model.itemOptions = [NSString stringWithFormat:@"%@,%@",model.itemOptions,dict[@"content"]];
  160. }
  161. }
  162. }else if(model.itemType == XYModifyTtem_MULTI_OPTION){
  163. //选项数组(用逗号分隔字符串)
  164. NSData *itemOptionsData = [model.itemOptions dataUsingEncoding:NSUTF8StringEncoding];
  165. NSArray *optionsarray = [NSJSONSerialization JSONObjectWithData:itemOptionsData options:NSJSONReadingMutableContainers error:nil];
  166. for (int i= 0 ; i< optionsarray.count;i++) {
  167. NSDictionary *dict = optionsarray[i];
  168. if (i == 0) {
  169. model.itemOptions = dict[@"content"];
  170. }else{
  171. model.itemOptions = [NSString stringWithFormat:@"%@,%@",model.itemOptions,dict[@"content"]];
  172. }
  173. }
  174. //值数组
  175. if (model.itemValue.length) {
  176. float tagWidth = kScreenWidth;
  177. if (self.infoType == ModifyUserInfo_Type_Main) {
  178. //和标题下行显示
  179. model.cellHeight = 40;
  180. XYModifyUserInfoListModel *sectionModel;
  181. for (XYModifyUserInfoListModel *tempModel in self.dataSource) {
  182. if (tempModel.isSection) {
  183. sectionModel = tempModel;
  184. }
  185. }
  186. //和标题同行显示
  187. if ([sectionModel.groupName isEqualToString:model.itemName]) {
  188. tagWidth = kScreenWidth + 1;
  189. model.cellHeight = 10;
  190. }
  191. }
  192. model.tagWidth = tagWidth;
  193. NSArray *tags = [model.itemValue componentsSeparatedByString:@","];
  194. XYTagListView *taglistView = [XYTagListView getTagView:tags andBgColor:[UIColor colorWithHexString:model.tagColor alpha:1] andTextColor:[UIColor colorWithHexString:model.textColor alpha:1] andWidth:tagWidth-10];
  195. model.cellHeight = model.cellHeight + taglistView.height + 12;
  196. [taglistView removeFromSuperview];
  197. taglistView = nil;
  198. }
  199. }else if(model.itemType == XYModifyTtem_INPUT_CONTENT){
  200. float itemValueHeight = [HandleString autoLabelWith:model.itemValue withSize:CGSizeMake(kScreenWidth-140, MAXFLOAT) withFont:Font(14) withLines:0].height;
  201. model.cellHeight = (itemValueHeight+30)>50?(itemValueHeight+30):50;
  202. }else if(model.itemType == XYModifyTtem_ADD_QA){//用数组单独处理
  203. //[self parseAnswerData:groupDict];
  204. //break;
  205. //问题标题和答案 yymodel已处理
  206. //"itemName" : "想去哪儿?",
  207. //"itemValue" : "阿萨德",
  208. [self.dataSource removeLastObject];
  209. [answerArrs addObject:model];
  210. //model.itemOptions 处理为字符串逗号分隔
  211. //问题选项数据处理
  212. NSData *itemOptionsData = [model.itemOptions dataUsingEncoding:NSUTF8StringEncoding];
  213. NSDictionary *itemoptionsDict = [NSJSONSerialization JSONObjectWithData:itemOptionsData options:NSJSONReadingMutableContainers error:nil];
  214. model.moduleId = [itemoptionsDict[@"moduleId"] integerValue];
  215. NSArray *optionsarray = itemoptionsDict[@"list"];
  216. for (int i = 0 ; i< optionsarray.count;i++) {
  217. NSDictionary *dict = optionsarray[i];
  218. if (i == 0) {
  219. model.itemOptions = dict[@"content"];
  220. }else{
  221. model.itemOptions = [NSString stringWithFormat:@"%@,%@",model.itemOptions,dict[@"content"]];
  222. }
  223. }
  224. }
  225. }
  226. }
  227. //查看用户主页childItems有答案时加入数组
  228. int answerItemValueCount = 0;
  229. for (XYModifyUserInfoListModel *tempmodel in answerArrs) {
  230. answerItemValueCount++;
  231. if (self.infoType == ModifyUserInfo_Type_Main) {
  232. if (!StringIsEmpty(tempmodel.itemValue)) {
  233. [self.dataSource addObject:tempmodel];
  234. }
  235. }else{
  236. [self.dataSource addObject:tempmodel];
  237. }
  238. float questionHeight = [HandleString autoLabelWith:tempmodel.itemName withSize:CGSizeMake(kScreenWidth-85, MAXFLOAT) withFont:Font(14) withLines:0].height;
  239. float answerHeight = [HandleString autoLabelWith:tempmodel.itemValue withSize:CGSizeMake(kScreenWidth-85, MAXFLOAT) withFont:Font(14) withLines:0].height;
  240. tempmodel.cellHeight = 15 + (questionHeight>10?questionHeight:20) + 4 + (answerHeight>10?answerHeight:20);
  241. }
  242. // //childItems没有答案,默认一个入口答题model
  243. // if (!answerItemValueCount) {
  244. // XYModifyUserInfoListModel *tempmodel = [answerArrs firstObject];
  245. // tempmodel.cellHeight = 260;
  246. // [self.dataSource addObject:tempmodel];
  247. // }
  248. if (self.infoType == ModifyUserInfo_Type_Main) {
  249. NSMutableArray *arr = [[NSMutableArray alloc] init];
  250. for (int i = 0 ; i < self.dataSource.count ; i++) {
  251. XYModifyUserInfoListModel *model = self.dataSource[i];
  252. model.userInfoType = self.infoType;
  253. if (!StringIsEmpty(model.itemValue) || model.groupScore > 0) {
  254. [arr addObject:model];
  255. if ([model.groupKey isEqualToString:@"profile"]) {
  256. model.groupName = @"基本信息";
  257. }
  258. }
  259. }
  260. [self.dataSource removeAllObjects];
  261. self.dataSource = arr;
  262. }
  263. // [self.dataSource addObject:[EmptyCellModel createModelWithIsShowTopLine:NO isShowBottomLine:NO cellHeight:10.0f]];
  264. //
  265. // 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)]]];
  266. // [self.dataSource addObject:phoneModel];
  267. // [self.dataSource addObject:[EmptyCellModel createModelWithIsShowTopLine:NO isShowBottomLine:NO cellHeight:10.0f]];
  268. /*//改为ProfileNew接口获取数据
  269. XYModifyUserInfoListModel *sectionlyModel = [XYModifyUserInfoListModel createModelWithTitle:kLocalizedString(@"其他信息") isShowMore:NO isShowBottomLine:NO content:@""];
  270. sectionlyModel.isSection = YES;
  271. sectionlyModel.cellHeight = 38.0f;
  272. [self.dataSource addObject:sectionlyModel];
  273. if ([[XYUserInfoManager nowUser].countryId isEqualToString:@"1"]) {
  274. XYModifyUserInfoListModel *countryModel = [XYModifyUserInfoListModel createModelWithTitle:kLocalizedString(@"国家") isShowMore:NO isShowBottomLine:YES content:StringIsEmpty(nowUser.countryName)?kLocalizedString(@"请选择"):nowUser.countryName];
  275. [self.dataSource addObject:countryModel];
  276. XYModifyUserInfoListModel *cityModel = [XYModifyUserInfoListModel createModelWithTitle:kLocalizedString(@"城市") isShowMore:NO isShowBottomLine:YES content:StringIsEmpty(nowUser.areaCity)?kLocalizedString(@"请选择"):nowUser.areaCity];
  277. [self.dataSource addObject:cityModel];
  278. }else {
  279. XYModifyUserInfoListModel *countryModel = [XYModifyUserInfoListModel createModelWithTitle:kLocalizedString(@"国家") isShowMore:NO isShowBottomLine:YES content:StringIsEmpty(nowUser.countryName)?kLocalizedString(@"请选择"):nowUser.countryName];
  280. [self.dataSource addObject:countryModel];
  281. }
  282. XYModifyUserInfoListModel *incomeModel = [XYModifyUserInfoListModel createModelWithTitle:kLocalizedString(@"收入") isShowMore:YES isShowBottomLine:YES content:StringIsEmpty(nowUser.userIncome)?@"":nowUser.userIncome];
  283. [self.dataSource addObject:incomeModel];
  284. XYModifyUserInfoListModel *weightModel = [XYModifyUserInfoListModel createModelWithTitle:kLocalizedString(@"体重") isShowMore:YES isShowBottomLine:YES content:nowUser.userWeight == 0?@"":[NSString stringWithFormat:@"%dkg", (int)nowUser.userWeight]];
  285. [self.dataSource addObject:weightModel];
  286. XYModifyUserInfoListModel *heightModel = [XYModifyUserInfoListModel createModelWithTitle:kLocalizedString(@"身高") isShowMore:YES isShowBottomLine:YES content:nowUser.userHeight == 0?@"":[NSString stringWithFormat:@"%dcm", (int)nowUser.userHeight]];
  287. [self.dataSource addObject:heightModel];
  288. XYModifyUserInfoListModel *userConstellationModel = [XYModifyUserInfoListModel createModelWithTitle:kLocalizedString(@"星座") isShowMore:YES isShowBottomLine:YES content:nowUser.userConstellation == 0?@"":[XYUserOtherInfoManager getConstellationValueWithKey:nowUser.userConstellation]];
  289. [self.dataSource addObject:userConstellationModel];
  290. XYModifyUserInfoListModel *purposeModel = [XYModifyUserInfoListModel createModelWithTitle:kLocalizedString(@"交友目的") isShowMore:YES isShowBottomLine:YES content:StringIsEmpty(nowUser.userMarkingFriends)?@"":nowUser.userMarkingFriends];
  291. [self.dataSource addObject:purposeModel];
  292. XYModifyUserInfoListModel *emotionModel = [XYModifyUserInfoListModel createModelWithTitle:kLocalizedString(@"情感状况") isShowMore:YES isShowBottomLine:YES content:StringIsEmpty(nowUser.userMarriage)?@"":nowUser.userMarriage];
  293. [self.dataSource addObject:emotionModel];
  294. XYModifyUserInfoListModel *hobbyModel = [XYModifyUserInfoListModel createModelWithTitle:kLocalizedString(@"兴趣爱好") isShowMore:YES isShowBottomLine:YES content:StringIsEmpty(nowUser.userHobby)?@"":nowUser.userHobby];
  295. [self.dataSource addObject:hobbyModel];
  296. XYModifyUserInfoListModel *individualityModel = [XYModifyUserInfoListModel createModelWithTitle:kLocalizedString(@"个性标签") isShowMore:YES isShowBottomLine:YES content:StringIsEmpty(nowUser.userTags)?@"":nowUser.userTags];
  297. [self.dataSource addObject:individualityModel];
  298. // [self.dataSource addObject:[EmptyCellModel createModelWithIsShowTopLine:NO isShowBottomLine:NO cellHeight:40.0f]];
  299. */
  300. }else {
  301. XYModifyUserInfoListModel *noModel = [XYModifyUserInfoListModel createModelWithTitle:@"ID" isShowMore:NO isShowBottomLine:YES content:[XYUserInfoManager nowUser].userNo];
  302. [self.dataSource addObject:noModel];
  303. XYModifyUserInfoListModel *coverModel = [XYModifyUserInfoListModel createModelWithTitle:kLocalizedString(@"颜值封面") isShowMore:YES isShowBottomLine:NO content:@""];
  304. [self.dataSource addObject:coverModel];
  305. }
  306. }
  307. //- (void)parseAnswerData:(NSDictionary *)groupDict{
  308. // XYModifyUserInfoListModel *sectionlyModel0 = [[XYModifyUserInfoListModel alloc] init];
  309. // [sectionlyModel0 yy_modelSetWithDictionary:groupDict];
  310. // [self.dataSource addObject:sectionlyModel0];
  311. //
  312. // sectionlyModel0.answerChildArrs = [[NSMutableArray alloc] init];
  313. //
  314. // NSArray *childArrs = groupDict[@"childItems"];
  315. // for (NSDictionary *childDict in childArrs) {
  316. // XYModifyUserInfoListModel *childmodel = [[XYModifyUserInfoListModel alloc] init];
  317. // [childmodel yy_modelSetWithDictionary:childDict];
  318. // [sectionlyModel0.answerChildArrs addObject:childmodel];
  319. // sectionlyModel0.itemType = childmodel.itemType;
  320. //
  321. // childmodel.answerChildItemOptionsArrs = [[NSMutableArray alloc] init];
  322. //
  323. // NSData *itemOptionsData = [childmodel.itemOptions dataUsingEncoding:NSUTF8StringEncoding];
  324. // NSDictionary *itemoptionsDict = [NSJSONSerialization JSONObjectWithData:itemOptionsData options:NSJSONReadingMutableContainers error:nil];
  325. // NSArray *optionsarray = itemoptionsDict[@"list"];
  326. // for (NSDictionary *itemDict in optionsarray) {
  327. // XYModifyUserInfoListModel *model1 = [[XYModifyUserInfoListModel alloc] init];
  328. // [childmodel.answerChildItemOptionsArrs addObject:model1];
  329. // model1.itemName = itemDict[@"content"];
  330. // model1.questionId = [itemDict[@"questionId"] integerValue];
  331. // model1.moduleId = [itemoptionsDict[@"moduleId"]integerValue];
  332. // }
  333. // }
  334. //
  335. // sectionlyModel0.answerView = [XYUserMainInformationAnswerView getAnswerView:sectionlyModel0];
  336. // sectionlyModel0.cellHeight = 15 + sectionlyModel0.cellHeight + sectionlyModel0.answerView.height + 15;
  337. //
  338. //}
  339. - (void)loadData:(SuccessHandler)success failure:(FailureHandler)failure {
  340. dispatch_group_t group = dispatch_group_create();
  341. dispatch_queue_t queue = dispatch_queue_create("modify.user.info.queue", DISPATCH_QUEUE_SERIAL);
  342. if (self.infoType != ModifyUserInfo_Type_Main) {//用户主页外层以获取
  343. dispatch_group_enter(group);
  344. dispatch_async(queue, ^{
  345. [[XYUserAPIManager new] getProfileSuccessHandler:^(ZYLResponseModel *responseModel) {
  346. dispatch_group_leave(group);
  347. } failureHandler:^(ZYLNetworkError *error) {
  348. dispatch_group_leave(group);
  349. }];
  350. });
  351. }
  352. if (self.infoType != ModifyUserInfo_Type_Main) {
  353. dispatch_group_enter(group);
  354. dispatch_async(queue, ^{
  355. [[XYUserAPIManager new] getBingAccountSuccessHandler:^(ZYLResponseModel *responseModel) {
  356. self.userPhone = responseModel.data[@"userPhone"];
  357. dispatch_group_leave(group);
  358. } failureHandler:^(ZYLNetworkError *error) {
  359. dispatch_group_leave(group);
  360. }];
  361. });
  362. }
  363. dispatch_group_enter(group);
  364. dispatch_async(queue, ^{
  365. [[XYUserAPIManager new] getProfileNew:self.userId successHandler:^(ZYLResponseModel *responseModel) {
  366. self.profileNewArrs = responseModel.data[@"list"];
  367. dispatch_group_leave(group);
  368. } failureHandler:^(ZYLNetworkError *error) {
  369. dispatch_group_leave(group);
  370. }];
  371. });
  372. if (self.infoType == ModifyUserInfo_Type_Main) {
  373. dispatch_group_enter(group);
  374. dispatch_async(queue, ^{
  375. [[XYFeedAPIManager new] getPhotoListWithLastId:self.lastId userId:self.userId successHandler:^(ZYLResponseModel *responseModel) {
  376. self.photoAblumArrs = responseModel.data[@"list"];
  377. dispatch_group_leave(group);
  378. // NSArray *list = responseModel.data[@"list"];
  379. // if ([self.lastId isEqualToString:@"0"]) {
  380. // [self.dataSource removeAllObjects];
  381. // if (list.count > 0 && [self.userId isEqualToString:[XYUserInfoManager nowUser].userId]) {
  382. // XYFeedModel *model = XYFeedModel.new;
  383. // [self.dataSource addObject:model];
  384. // }
  385. // }
  386. // for (NSDictionary *dict in list) {
  387. // XYFeedModel *model = XYFeedModel.new;
  388. // [model yy_modelSetWithDictionary:dict];
  389. // [self.dataSource addObject:model];
  390. // }
  391. // self.lastId = responseModel.data[@"lastId"];
  392. // self.perPage = [responseModel.data[@"pageSize"] integerValue];
  393. // !success?:success(self.dataSource);
  394. } failureHandler:^(ZYLNetworkError *error) {
  395. // !failure?:failure(error);
  396. dispatch_group_leave(group);
  397. }];
  398. });
  399. }
  400. dispatch_group_notify(group, queue, ^{
  401. dispatch_async(dispatch_get_main_queue(), ^{
  402. [self initValue];
  403. !success?:success(self.dataSource);
  404. });
  405. });
  406. }
  407. - (void)getCountryList:(SuccessHandler)success failure:(FailureHandler)failure {
  408. if (self.infoType != ModifyUserInfo_Type_Main) {
  409. [[XYConfigAPIManager new] getCountryPhoneCodeSuccessHandler:^(ZYLResponseModel *responseModel) {
  410. [self.countryList removeAllObjects];
  411. for (NSDictionary *dict in responseModel.data[@"list"]) {
  412. XYCountryPhoneCodeModel *model = [XYCountryPhoneCodeModel new];
  413. [model yy_modelSetWithDictionary:dict];
  414. [self.countryList addObject:model];
  415. }
  416. !success?:success(self.dataSource);
  417. } failureHandler:^(ZYLNetworkError *error) {
  418. !failure?:failure(error);
  419. }];
  420. }
  421. }
  422. - (NSMutableArray *)countryList {
  423. if (!_countryList) {
  424. _countryList = [NSMutableArray array];
  425. }
  426. return _countryList;
  427. }
  428. @end