YMEditProfileViewModel.m 54 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352
  1. //
  2. // YMEditProfileViewModel.m
  3. // MSYOUPAI
  4. //
  5. // Created by YoMi on 2024/2/18.
  6. // Copyright © 2024 MS. All rights reserved.
  7. //
  8. #import "YMEditProfileViewModel.h"
  9. #import "YMPersonalInfoModel.h"
  10. #import "YMSelectDataTypeModel.h"
  11. #import "YMEditProfileSelectTagView.h"
  12. #import "YMEditInfoTypeViewController.h"
  13. @interface YMEditProfileViewModel ()<TZImagePickerControllerDelegate>
  14. /// 用户头像
  15. @property (nonatomic, strong, readwrite) NSString *userAvatar;
  16. /// 是否隐藏用户头像审核
  17. @property (nonatomic, assign, readwrite) BOOL isHideUserAvatarUnderReview;
  18. /// 是否显示添加Cell
  19. @property (nonatomic, assign, readwrite) BOOL isHideAddCell;
  20. /// 添加CellViewModel
  21. @property (nonatomic, strong, readwrite) YMEditProfileAlbumCellViewModel *addCellViewModel;
  22. /// 相册数据
  23. @property (nonatomic, strong, readwrite) NSArray <YMEditProfileAlbumCellViewModel *>*albumDataArray;
  24. /// 用户语音链接
  25. @property (nonatomic, strong, readwrite) NSString *userVoiceUrl;
  26. /// 用户语音时长
  27. @property (nonatomic, assign, readwrite) NSInteger userVoiceDuration;
  28. /// 是否隐藏用户语音审核
  29. @property (nonatomic, assign, readwrite) BOOL isHideUserVoiceUnderReview;
  30. /// 用户昵称
  31. @property (nonatomic, strong, readwrite) NSString *userNickname;
  32. /// 信息数据
  33. @property (nonatomic, strong, readwrite) NSArray <YMEditProfileInfoCellViewModel *>*infoDataArray;
  34. /// 用户简介
  35. @property (nonatomic, strong, readwrite) NSString *userIntro;
  36. /// 标签数据
  37. @property (nonatomic, strong, readwrite) NSArray <YMEditProfileTagCellViewModel *>*tagDataArray;
  38. /// 添加相册
  39. @property (nonatomic, strong, readwrite) RACSubject *addAlbumSubject;
  40. /// 删除相册
  41. @property (nonatomic, strong, readwrite) RACSubject *deleteAlbumSubject;
  42. /// 刷新相册排序
  43. @property (nonatomic, strong, readwrite) RACSubject *refreshAlbumSortSubject;
  44. /// 编辑资料操作
  45. @property (nonatomic, strong, readwrite) RACSubject *editProfileOperationSubject;
  46. /// 年龄数据
  47. @property (nonatomic, strong) NSArray *ageDataArray;
  48. /// 星座数据
  49. @property (nonatomic, strong) NSArray *constellationDataArray;
  50. /// 家乡数据
  51. @property (nonatomic, strong) NSArray *hometownDataArray;
  52. /// 身高数据
  53. @property (nonatomic, strong) NSArray *heightDataArray;
  54. /// 体重数据
  55. @property (nonatomic, strong) NSArray *weightDataArray;
  56. /// 年收入数据
  57. @property (nonatomic, strong) NSArray *annualIncomeDataArray;
  58. /// 婚姻状态数据
  59. @property (nonatomic, strong) NSArray *maritalStatusDataArray;
  60. /// 选中资源
  61. @property (nonatomic, strong) NSMutableArray *selectedAssets;
  62. /// 用户Id
  63. @property (nonatomic, assign) NSInteger userId;
  64. /// 相册图片链接
  65. @property (nonatomic, copy) NSString *albumImagesUrl;
  66. /// 星座Id
  67. @property (nonatomic, assign) NSInteger constellationId;
  68. /// 城市Id
  69. @property (nonatomic, assign) NSString *cityId;
  70. /// 个人信息模组
  71. @property (nonatomic, strong) YMPersonalInfoModel *model;
  72. @end
  73. @implementation YMEditProfileViewModel
  74. - (void)ym_initialize{
  75. [super ym_initialize];
  76. self.customNavTitle = @"编辑资料";
  77. self.userId = [self.params integerValueForKey:ParamsId defaultValue:0];
  78. self.isHideUserAvatarUnderReview = YES;
  79. self.addCellViewModel = [[YMEditProfileAlbumCellViewModel alloc]initWithParams:@{
  80. @"isAddCell":@(YES),
  81. @"isHideDeleteButton":@(YES),
  82. }];
  83. self.isHideUserVoiceUnderReview = YES;
  84. [self defaultInitializePickerData];
  85. self.infoDataArray = [@[
  86. @{
  87. @"title":@"昵称",
  88. @"content":@"去完善",
  89. ParamsCategoryType:@(YMEditProfileTypeNickname),
  90. },
  91. @{
  92. @"title":@"年龄",
  93. @"content":@"去完善",
  94. ParamsCategoryType:@(YMEditProfileTypeAge),
  95. },
  96. @{
  97. @"title":@"星座",
  98. @"content":@"去完善",
  99. ParamsCategoryType:@(YMEditProfileTypeConstellation),
  100. },
  101. @{
  102. @"title":@"家乡",
  103. @"content":@"去完善",
  104. ParamsCategoryType:@(YMEditProfileTypeHometown),
  105. },
  106. @{
  107. @"title":@"身高",
  108. @"content":@"去完善",
  109. ParamsCategoryType:@(YMEditProfileTypeHeight),
  110. },
  111. @{
  112. @"title":@"体重",
  113. @"content":@"去完善",
  114. ParamsCategoryType:@(YMEditProfileTypeWeight),
  115. },
  116. @{
  117. @"title":@"年收入",
  118. @"content":@"去完善",
  119. ParamsCategoryType:@(YMEditProfileTypeAnnualIncome),
  120. },
  121. @{
  122. @"title":@"婚姻状态",
  123. @"content":@"去完善",
  124. ParamsCategoryType:@(YMEditProfileTypeMaritalStatus),
  125. },
  126. ].rac_sequence map:^(NSDictionary * _Nullable dic) {
  127. YMEditProfileInfoCellViewModel *viewModel = [[YMEditProfileInfoCellViewModel alloc]initWithParams:@{
  128. ParamsModel:dic
  129. }];
  130. return viewModel;
  131. }].array;
  132. @weakify(self)
  133. [[self.addAlbumSubject takeUntil:self.rac_willDeallocSignal] subscribeNext:^(NSArray <UIImage*> * _Nullable photos) {
  134. NSMutableArray <YMEditProfileAlbumCellViewModel*>*tempArr = [NSMutableArray arrayWithArray:self.albumDataArray];
  135. NSArray *viewModelArr = [photos.rac_sequence map:^id _Nullable(UIImage * _Nullable value) {
  136. YMEditProfileAlbumCellViewModel *viewModel = [[YMEditProfileAlbumCellViewModel alloc]initWithParams:@{
  137. @"isAddCell":@(NO),
  138. @"localAlbum":value,
  139. @"isHideDeleteButton":@(NO)
  140. }];
  141. return viewModel;
  142. }].array;
  143. [tempArr addObjectsFromArray:viewModelArr];
  144. self.albumDataArray = tempArr.mutableCopy;
  145. self.isHideAddCell = self.albumDataArray.count < 6 ? NO : YES;
  146. NSLog(@"addAlbum:%@",self.albumDataArray);
  147. [self.refreshUISubject sendNext:@(YMRefreshUI)];
  148. }];
  149. [[self.deleteAlbumSubject takeUntil:self.rac_willDeallocSignal] subscribeNext:^(NSNumber * _Nullable index) {
  150. @strongify(self)
  151. NSMutableArray <YMEditProfileAlbumCellViewModel*>*tempArr = [NSMutableArray arrayWithArray:self.albumDataArray];
  152. YMEditProfileAlbumCellViewModel *cellVM = [tempArr objectAtIndex:[index intValue]];
  153. ///判断当前删除的CellViewModel是网络图片还是本地图片,本地图片则需要删除selectedAssets里面对应本地图片
  154. if (cellVM.localAlbum != nil) {
  155. [self.selectedAssets enumerateObjectsUsingBlock:^(PHAsset * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
  156. [[TZImageManager manager] getPhotoWithAsset:obj completion:^(UIImage *photo, NSDictionary *info, BOOL isDegraded) {
  157. NSData *cellVM_data = UIImagePNGRepresentation(cellVM.localAlbum);
  158. NSData *asset_data = UIImagePNGRepresentation(photo);
  159. if ([cellVM_data isEqual:asset_data]) {
  160. NSLog(@"两个UIImage相同");
  161. [self.selectedAssets removeObjectAtIndex:idx];
  162. *stop = YES;
  163. }
  164. }];
  165. }];
  166. }
  167. [tempArr removeObjectAtIndex:[index intValue]];
  168. self.albumDataArray = tempArr.mutableCopy;
  169. self.isHideAddCell = self.albumDataArray.count < 6 ? NO : YES;
  170. NSLog(@"deleteAlbumSubject:%@",self.albumDataArray);
  171. [self.refreshUISubject sendNext:@(YMRefreshUI)];
  172. }];
  173. [[self.refreshAlbumSortSubject takeUntil:self.rac_willDeallocSignal] subscribeNext:^(NSArray <YMEditProfileAlbumCellViewModel *>* _Nullable albumDataArray) {
  174. self.albumDataArray = albumDataArray;
  175. NSLog(@"refreshAlbum:%@",self.albumDataArray);
  176. [self.refreshUISubject sendNext:@(YMRefreshUI)];
  177. }];
  178. [[self.editProfileOperationSubject takeUntil:self.rac_willDeallocSignal] subscribeNext:^(id _Nullable value) {
  179. @strongify(self)
  180. switch ([value intValue]) {
  181. case YMEditProfileTypeNickname:
  182. {
  183. YMEditInfoTypeViewModel *editInfoTypeVM = [[YMEditInfoTypeViewModel alloc]initWithParams:@{
  184. ParamsCategoryType:@(YMEditInfoTypeNickname),
  185. ParamsEditContent:self.userNickname
  186. }];
  187. editInfoTypeVM.nicknameBlock = ^(NSString * _Nonnull nickname) {
  188. @strongify(self)
  189. self.userNickname = nickname;
  190. self.infoDataArray = [self.infoDataArray.rac_sequence map:^id _Nullable(YMEditProfileInfoCellViewModel * _Nullable viewModel) {
  191. switch (viewModel.editProfileType) {
  192. case YMEditProfileTypeNickname:
  193. {
  194. viewModel.infoContent = self.userNickname;
  195. }
  196. break;
  197. default:
  198. break;
  199. }
  200. return viewModel;
  201. }].array;
  202. [self.refreshUISubject sendNext:@(YMRefreshUI)];
  203. };
  204. [YMRouter openURL:stringFormat(@"%@%@",YM_ROUTER_URL_PREFIX,YM_ROUTER_EDIT_INFO_TYPE) withUserInfo:@{
  205. RouterViewModel:editInfoTypeVM
  206. } completion:nil];
  207. }
  208. break;
  209. case YMEditProfileTypeAge:
  210. {
  211. [self openAgePickerPopupView];
  212. }
  213. break;
  214. case YMEditProfileTypeConstellation:
  215. {
  216. [self openConstellationPickerPopupView];
  217. }
  218. break;
  219. case YMEditProfileTypeHometown:
  220. {
  221. [self openHometownPickerPopupView];
  222. }
  223. break;
  224. case YMEditProfileTypeHeight:
  225. {
  226. [self openHeightPickerPopupView];
  227. }
  228. break;
  229. case YMEditProfileTypeWeight:
  230. {
  231. [self openWeightPickerPopupView];
  232. }
  233. break;
  234. case YMEditProfileTypeAnnualIncome:
  235. {
  236. [self openAnnualIncomePickerPopupView];
  237. }
  238. break;
  239. case YMEditProfileTypeMaritalStatus:
  240. {
  241. [self openMaritalStatusPickerPopupView];
  242. }
  243. break;
  244. case YMEditProfileTypeIntro:
  245. {
  246. YMEditInfoTypeViewModel *editInfoTypeVM = [[YMEditInfoTypeViewModel alloc]initWithParams:@{
  247. ParamsCategoryType:@(YMEditInfoTypeIntro),
  248. ParamsEditContent:self.userIntro
  249. }];
  250. editInfoTypeVM.introBlock = ^(NSString * _Nonnull intro) {
  251. @strongify(self)
  252. self.userIntro = intro;
  253. };
  254. [YMRouter openURL:stringFormat(@"%@%@",YM_ROUTER_URL_PREFIX,YM_ROUTER_EDIT_INFO_TYPE) withUserInfo:@{
  255. RouterViewModel:editInfoTypeVM
  256. } completion:nil];
  257. }
  258. break;
  259. case YMEditProfileTypeTag:
  260. {
  261. // YMEditInfoTypeViewModel *editInfoTypeVM = [[YMEditInfoTypeViewModel alloc]initWithParams:@{
  262. // ParamsCategoryType:@(YMEditInfoTypeTag),
  263. // }];
  264. // editInfoTypeVM.tagBlock = ^(NSArray<YMEditInfoTypeTagCellViewModel *> * _Nonnull selectedTagArray) {
  265. // @strongify(self)
  266. // self.tagDataArray = [selectedTagArray.rac_sequence map:^(YMEditInfoTypeTagCellViewModel * _Nullable cellVM) {
  267. // YMTagModel *model = [[YMTagModel alloc]init];
  268. // model.tag_id = cellVM.tagId;
  269. // model.name = cellVM.tagText;
  270. // YMEditProfileTagCellViewModel *viewModel = [[YMEditProfileTagCellViewModel alloc]initWithParams:@{
  271. // ParamsModel:model
  272. // }];
  273. // return viewModel;
  274. // }].array;
  275. // [self.refreshUISubject sendNext:@(YMRefreshUI)];
  276. // };
  277. // [YMRouter openURL:stringFormat(@"%@%@",YM_ROUTER_URL_PREFIX,YM_ROUTER_EDIT_INFO_TYPE) withUserInfo:@{
  278. // RouterViewModel:editInfoTypeVM
  279. // } completion:nil];
  280. [self openMyTagPopupView];
  281. }
  282. break;
  283. default:
  284. break;
  285. }
  286. }];
  287. }
  288. - (void)getEditProfileInfoData{
  289. @weakify(self)
  290. [ZCHUDHelper showWithStatus:@"加载中..."];
  291. [LCHttpHelper requestWithURLString:GetUserInfo parameters:@{
  292. @"user_id":@(self.userId)
  293. } needToken:YES type:HttpRequestTypePost success:^(id responseObject) {
  294. @strongify(self)
  295. NSDictionary* dict = (NSDictionary*)responseObject;
  296. NSInteger code = [[dict objectForKey:@"code"] integerValue];
  297. if (code == 0) {
  298. [ZCHUDHelper dismiss];
  299. self.model = [YMPersonalInfoModel yy_modelWithJSON:[dict dictionaryValueForKey:@"data" defaultValue:@{}]];
  300. self.userAvatar = OCStringIsEmpty(self.model.avatar_auth) ? self.model.avatar : self.model.avatar_auth;
  301. self.isHideUserAvatarUnderReview = self.model.avatar_auth_status == 0 ? NO : YES;
  302. self.albumDataArray = [self.model.albums_list.rac_sequence map:^id _Nullable(YMAlbumsListModel * _Nullable value) {
  303. YMEditProfileAlbumCellViewModel *viewModel = [[YMEditProfileAlbumCellViewModel alloc]initWithParams:@{
  304. @"isAddCell":@(NO),
  305. @"networkAlbum":value.url,
  306. @"isHideDeleteButton":@(NO)
  307. }];
  308. return viewModel;
  309. }].array;
  310. self.userVoiceUrl = self.model.voice.voice;
  311. self.userVoiceDuration = self.model.voice.voice_time;
  312. self.isHideUserVoiceUnderReview = self.model.voice.voice_status == 0 && !OCStringIsEmpty(self.model.voice.voice) ? NO : YES;
  313. self.userNickname = self.model.nickname;
  314. self.infoDataArray = [self.infoDataArray.rac_sequence map:^(YMEditProfileInfoCellViewModel * _Nullable viewModel) {
  315. switch (viewModel.editProfileType) {
  316. case YMEditProfileTypeNickname:
  317. {
  318. viewModel.infoContent = self.userNickname;
  319. }
  320. break;
  321. case YMEditProfileTypeAge:
  322. {
  323. viewModel.infoContent = self.model.basic_info_detail.age;
  324. }
  325. break;
  326. case YMEditProfileTypeConstellation:
  327. {
  328. NSArray * constellationDataArray = @[
  329. @"保密",
  330. @"白羊座",
  331. @"金牛座",
  332. @"双子座",
  333. @"巨蟹座",
  334. @"狮子座",
  335. @"处女座",
  336. @"天秤座",
  337. @"天蝎座",
  338. @"射手座",
  339. @"摩羯座",
  340. @"水瓶座",
  341. @"双鱼座",
  342. ];
  343. viewModel.infoContent = constellationDataArray[self.model.basic_info_detail.signs > 12 ? 0 : self.model.basic_info_detail.signs];
  344. }
  345. break;
  346. case YMEditProfileTypeHometown:
  347. {
  348. viewModel.infoContent = self.model.basic_info_detail.city;
  349. }
  350. break;
  351. case YMEditProfileTypeHeight:
  352. {
  353. NSString *height = [self.model.basic_info_detail.height stringByReplacingOccurrencesOfString:@"cm" withString:@""];
  354. if ([height isEqualToString:@"0"] || OCStringIsEmpty(height)) {
  355. viewModel.infoContent = @"请完善";
  356. } else {
  357. viewModel.infoContent = self.model.basic_info_detail.height;
  358. }
  359. }
  360. break;
  361. case YMEditProfileTypeWeight:
  362. {
  363. NSString *height = [self.model.basic_info_detail.weight stringByReplacingOccurrencesOfString:@"kg" withString:@""];
  364. if ([height isEqualToString:@"0"] || OCStringIsEmpty(height)) {
  365. viewModel.infoContent = @"请完善";
  366. } else {
  367. viewModel.infoContent = self.model.basic_info_detail.weight;
  368. }
  369. }
  370. break;
  371. case YMEditProfileTypeAnnualIncome:
  372. {
  373. if (OCStringIsEmpty(self.model.basic_info_detail.annual_income)) {
  374. viewModel.infoContent = @"请完善";
  375. } else {
  376. viewModel.infoContent = self.model.basic_info_detail.annual_income;
  377. }
  378. }
  379. break;
  380. case YMEditProfileTypeMaritalStatus:
  381. {
  382. if (OCStringIsEmpty(self.model.basic_info_detail.is_marriage)) {
  383. viewModel.infoContent = @"请完善";
  384. } else {
  385. viewModel.infoContent = self.model.basic_info_detail.is_marriage;
  386. }
  387. }
  388. break;
  389. default:
  390. break;
  391. }
  392. if (OCStringIsEmpty(viewModel.infoContent) || [viewModel.infoContent isEqualToString:@"请完善"]) {
  393. viewModel.infoContentColor = HexColorFromRGB(0x9c9c9c);
  394. } else {
  395. viewModel.infoContentColor = HexColorFromRGB(0x333333);
  396. }
  397. return viewModel;
  398. }].array;
  399. self.userIntro = [self.model.sign containsString:@"这个人很懒,什么都没有留下"] ? @"" : self.model.sign;
  400. self.tagDataArray = [self.model.label.rac_sequence map:^(YMTagModel * _Nullable model) {
  401. YMEditProfileTagCellViewModel *viewModel = [[YMEditProfileTagCellViewModel alloc]initWithParams:@{
  402. ParamsModel:model
  403. }];
  404. return viewModel;
  405. }].array;
  406. [self.refreshUISubject sendNext:@(YMRefreshUI)];
  407. }else{
  408. [ZCHUDHelper showTitle:[dict stringValueForKey:@"message" defaultValue:@""]];
  409. [self.refreshUISubject sendNext:@(YMRefreshUI)];
  410. }
  411. } failure:^(NSError *error) {
  412. [ZCHUDHelper showTitle:error.localizedDescription];
  413. [self.refreshUISubject sendNext:@(YMRefreshUI)];
  414. }];
  415. [LCHttpHelper requestWithURLString:api_getSelectData parameters:@{} needToken:YES type:HttpRequestTypePost success:^(id responseObject) {
  416. NSDictionary* dict = (NSDictionary*)responseObject;
  417. NSInteger code = [[dict objectForKey:@"code"] integerValue];
  418. if (code == 0) {
  419. YMSelectDataTypeModel *model = [YMSelectDataTypeModel yy_modelWithJSON:[dict dictionaryValueForKey:@"data" defaultValue:@{}]];
  420. }
  421. } failure:^(NSError *error) {
  422. [ZCHUDHelper showTitle:error.localizedDescription];
  423. }];
  424. }
  425. - (void)uploadAlbumData{
  426. NSArray <NSString*> *networkAlbumPhotos = [[self.albumDataArray.rac_sequence filter:^BOOL(YMEditProfileAlbumCellViewModel * _Nullable viewModel) {
  427. if (!OCStringIsEmpty(viewModel.networkAlbum)) {
  428. return YES;
  429. } else {
  430. return NO;
  431. }
  432. }] map:^id _Nullable(YMEditProfileAlbumCellViewModel * _Nullable viewModel) {
  433. return viewModel.networkAlbum;
  434. }].array;
  435. NSArray <UIImage*> *localAlbumPhotos = [[self.albumDataArray.rac_sequence filter:^BOOL(YMEditProfileAlbumCellViewModel * _Nullable viewModel) {
  436. if (viewModel.localAlbum != nil) {
  437. return YES;
  438. } else {
  439. return NO;
  440. }
  441. }] map:^id _Nullable(YMEditProfileAlbumCellViewModel * _Nullable viewModel) {
  442. return viewModel.localAlbum;
  443. }].array;
  444. if (localAlbumPhotos.count > 0) {
  445. [ZCHUDHelper showWithStatus:@"正在上传相册..."];
  446. [LCCommonHttp uploadWithImages:localAlbumPhotos Type:@"album" successBlock:^(NSArray<NSString *> *ossImagePaths) {
  447. [ZCHUDHelper dismiss];
  448. NSMutableArray *tempUrlArray = [NSMutableArray array];
  449. [tempUrlArray addObjectsFromArray:networkAlbumPhotos];
  450. [tempUrlArray addObjectsFromArray:ossImagePaths];
  451. self.albumImagesUrl = [tempUrlArray componentsJoinedByString:@","];
  452. [self saveEditProfileInfoData];
  453. }];
  454. }else{
  455. NSArray <NSString*> *networkAlbumPhotos = [[self.albumDataArray.rac_sequence filter:^BOOL(YMEditProfileAlbumCellViewModel * _Nullable viewModel) {
  456. if (!OCStringIsEmpty(viewModel.networkAlbum)) {
  457. return YES;
  458. } else {
  459. return NO;
  460. }
  461. }] map:^id _Nullable(YMEditProfileAlbumCellViewModel * _Nullable viewModel) {
  462. return viewModel.networkAlbum;
  463. }].array;
  464. NSMutableArray *tempUrlArray = [NSMutableArray array];
  465. [tempUrlArray addObjectsFromArray:networkAlbumPhotos];
  466. self.albumImagesUrl = [tempUrlArray componentsJoinedByString:@","];
  467. [self saveEditProfileInfoData];
  468. }
  469. }
  470. - (void)saveEditProfileInfoData{
  471. @weakify(self)
  472. [ZCHUDHelper showWithStatus:@"保存中..."];
  473. NSMutableDictionary *params = [NSMutableDictionary dictionary];
  474. [params setObject:@(self.userId) forKey:@"user_id"];
  475. ///头像
  476. if (![self.userAvatar isEqualToString:self.model.avatar]) {
  477. [params setObject:self.userAvatar forKey:@"avatar"];
  478. }
  479. ///相册
  480. NSArray *oldAlbumArr = [[self.model.albums_list.rac_sequence filter:^BOOL(YMAlbumsListModel * _Nullable value) {
  481. if (value.is_video) {
  482. return NO;
  483. } else {
  484. return YES;
  485. }
  486. }] map:^id _Nullable(YMAlbumsListModel * _Nullable value) {
  487. return value.url;
  488. }].array;
  489. NSString *oldImageUrl = [oldAlbumArr componentsJoinedByString:@","];
  490. if (![self.albumImagesUrl isEqualToString:oldImageUrl]){
  491. [params setObject:self.albumImagesUrl forKey:@"albums"];
  492. }
  493. ///语音
  494. if (![self.userVoiceUrl isEqualToString:self.model.voice.voice]) {
  495. [params setObject:self.userVoiceUrl forKey:@"voice"];
  496. [params setObject:@(self.userVoiceDuration) forKey:@"voice_time"];
  497. }
  498. [self.infoDataArray enumerateObjectsUsingBlock:^(YMEditProfileInfoCellViewModel * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
  499. switch (obj.editProfileType) {
  500. case YMEditProfileTypeNickname:
  501. {
  502. ///昵称
  503. if (![obj.infoContent isEqualToString:self.model.nickname] && ![obj.infoContent isEqualToString:@"请完善"]) {
  504. [params setObject:obj.infoContent forKey:@"nickname"];
  505. }
  506. }
  507. break;
  508. case YMEditProfileTypeAge:
  509. {
  510. ///年龄
  511. if (![obj.infoContent isEqualToString:self.model.basic_info_detail.age] && ![obj.infoContent isEqualToString:@"请完善"]) {
  512. [params setObject:obj.infoContent forKey:@"age"];
  513. }
  514. }
  515. break;
  516. case YMEditProfileTypeConstellation:
  517. {
  518. ///星座
  519. if (self.constellationId != self.model.basic_info_detail.signs && ![obj.infoContent isEqualToString:@"请完善"]) {
  520. [params setObject:@(self.constellationId) forKey:@"signs"];
  521. }
  522. }
  523. break;
  524. case YMEditProfileTypeHometown:
  525. {
  526. ///家乡
  527. if (![self.cityId isEqualToString:self.model.basic_info_detail.city] && ![obj.infoContent isEqualToString:@"请完善"]) {
  528. [params setObject:self.cityId forKey:@"cityId"];
  529. }
  530. }
  531. break;
  532. case YMEditProfileTypeHeight:
  533. {
  534. ///身高
  535. if (![obj.infoContent isEqualToString:self.model.basic_info_detail.height] && ![obj.infoContent isEqualToString:@"请完善"]) {
  536. [params setObject:obj.infoContent forKey:@"height"];
  537. }
  538. }
  539. break;
  540. case YMEditProfileTypeWeight:
  541. {
  542. ///体重
  543. if (![obj.infoContent isEqualToString:self.model.basic_info_detail.weight] && ![obj.infoContent isEqualToString:@"请完善"]) {
  544. [params setObject:obj.infoContent forKey:@"weight"];
  545. }
  546. }
  547. break;
  548. case YMEditProfileTypeAnnualIncome:
  549. {
  550. ///年收入
  551. if (![obj.infoContent isEqualToString:self.model.basic_info_detail.annual_income] && ![obj.infoContent isEqualToString:@"请完善"]) {
  552. [params setObject:obj.infoContent forKey:@"annual_income"];
  553. }
  554. }
  555. break;
  556. case YMEditProfileTypeMaritalStatus:
  557. {
  558. ///婚姻状态
  559. if (![obj.infoContent isEqualToString:self.model.basic_info_detail.is_marriage] && ![obj.infoContent isEqualToString:@"请完善"]) {
  560. [params setObject:obj.infoContent forKey:@"is_marriage"];
  561. }
  562. }
  563. break;
  564. default:
  565. break;
  566. }
  567. }];
  568. ///简介
  569. if (![self.userIntro isEqualToString:self.model.sign]) {
  570. [params setObject:self.userIntro forKey:@"signature"];
  571. }
  572. ///标签
  573. NSArray *newTagArr = [self.tagDataArray.rac_sequence map:^id _Nullable(YMEditProfileTagCellViewModel * _Nullable value) {
  574. return @(value.tagId);
  575. }].array;
  576. NSArray *oldTagArr = [self.model.label.rac_sequence map:^id _Nullable(YMTagModel * _Nullable value) {
  577. return @(value.tag_id);
  578. }].array;
  579. NSString *newTagStr = [newTagArr componentsJoinedByString:@","];
  580. NSString *oldTagStr = [oldTagArr componentsJoinedByString:@","];
  581. if (![newTagStr isEqualToString:oldTagStr]){
  582. [params setObject:newTagStr forKey:@"label"];
  583. }
  584. [LCHttpHelper requestWithURLString:api_Improve_data parameters:params needToken:YES type:HttpRequestTypePost success:^(id responseObject) {
  585. @strongify(self)
  586. NSDictionary* dict = (NSDictionary*)responseObject;
  587. NSInteger code = [[dict objectForKey:@"code"] integerValue];
  588. if (code == 0) {
  589. [ZCHUDHelper dismiss];
  590. [[YMGlobalUtils getCurrentVC].navigationController popViewControllerAnimated:YES];
  591. }else{
  592. [ZCHUDHelper showTitle:[dict stringValueForKey:@"message" defaultValue:@""]];
  593. }
  594. } failure:^(NSError *error) {
  595. [ZCHUDHelper showTitle:error.localizedDescription];
  596. }];
  597. }
  598. - (void)gotoSoundShowcase{
  599. if (self.isHideUserVoiceUnderReview) {
  600. YMSoundShowcaseViewModel *soundShowcaseVM = [[YMSoundShowcaseViewModel alloc]initWithParams:@{}];
  601. @weakify(self)
  602. soundShowcaseVM.templateVoiceBlock = ^(NSString * _Nonnull voiceUrl, NSInteger voiceDuration) {
  603. @strongify(self)
  604. self.userVoiceUrl = voiceUrl;
  605. self.userVoiceDuration = voiceDuration;
  606. };
  607. [YMRouter openURL:stringFormat(@"%@%@", YM_ROUTER_URL_PREFIX, YM_ROUTER_SOUND_SHOWCASE) withUserInfo:@{
  608. RouterViewModel:soundShowcaseVM
  609. } completion:nil];
  610. } else {
  611. [ZCHUDHelper showTitle:@"正在审核语音中,请耐心等待" showtime:1.5];
  612. }
  613. }
  614. #pragma mark - 默认初始化选择器数据
  615. - (void)defaultInitializePickerData{
  616. NSMutableArray *ageDataArray = [NSMutableArray array];
  617. for (int i = 18; i<=60; i++) {
  618. [ageDataArray addObject:@{
  619. @"rowName":stringFormat(@"%d岁",i)
  620. }];
  621. }
  622. self.ageDataArray = ageDataArray.mutableCopy;
  623. self.constellationDataArray = @[
  624. @{
  625. @"rowName":@"保密"
  626. },
  627. @{
  628. @"rowName":@"白羊座(3.21 - 4.19)"
  629. },
  630. @{
  631. @"rowName":@"金牛座(4.20 - 5.20)"
  632. },
  633. @{
  634. @"rowName":@"双子座(5.21 - 6.21)"
  635. },
  636. @{
  637. @"rowName":@"巨蟹座(6.22 - 7.22)"
  638. },
  639. @{
  640. @"rowName":@"狮子座(7.23 - 8.22)"
  641. },
  642. @{
  643. @"rowName":@"处女座(8.23 - 9.22)"
  644. },
  645. @{
  646. @"rowName":@"天秤座(9.23 - 10.23)"
  647. },
  648. @{
  649. @"rowName":@"天蝎座(10.24 - 11.22)"
  650. },
  651. @{
  652. @"rowName":@"射手座(11.23 - 12.21)"
  653. },
  654. @{
  655. @"rowName":@"摩羯座(12.22 - 1.19)"
  656. },
  657. @{
  658. @"rowName":@"水瓶座(1.20 - 2.18)"
  659. },
  660. @{
  661. @"rowName":@"双鱼座(2.19 - 3.20)"
  662. },
  663. ];
  664. NSMutableArray *heightDataArray = [NSMutableArray array];
  665. for (int i = 60; i<=200; i++) {
  666. [heightDataArray addObject:@{
  667. @"rowName":stringFormat(@"%dcm",i)
  668. }];
  669. }
  670. self.heightDataArray = heightDataArray.mutableCopy;
  671. NSMutableArray *weightDataArray = [NSMutableArray array];
  672. for (int i = 40; i<=100; i++) {
  673. [weightDataArray addObject:@{
  674. @"rowName":stringFormat(@"%dkg",i)
  675. }];
  676. }
  677. self.weightDataArray = weightDataArray.mutableCopy;
  678. self.annualIncomeDataArray = @[
  679. @{
  680. @"rowName":@"保密"
  681. },
  682. @{
  683. @"rowName":@"5万以下"
  684. },
  685. @{
  686. @"rowName":@"5万 - 10万"
  687. },
  688. @{
  689. @"rowName":@"10万 - 20万"
  690. },
  691. @{
  692. @"rowName":@"20万 - 30万"
  693. },
  694. @{
  695. @"rowName":@"30万 - 50万"
  696. },
  697. @{
  698. @"rowName":@"50万以上"
  699. },
  700. ];
  701. self.maritalStatusDataArray = @[
  702. @{
  703. @"rowName":@"单身"
  704. },
  705. @{
  706. @"rowName":@"寻爱中"
  707. },
  708. @{
  709. @"rowName":@"有伴侣"
  710. },
  711. @{
  712. @"rowName":@"已婚"
  713. },
  714. @{
  715. @"rowName":@"离异"
  716. },
  717. ];
  718. }
  719. #pragma mark - 头像选择器
  720. - (void)openAvatarPickerPopupView{
  721. if (self.isHideUserAvatarUnderReview) {
  722. TZImagePickerController *imagePickerVC = [[TZImagePickerController alloc] initWithMaxImagesCount:1 columnNumber:4 delegate:self];
  723. [LCTZImageConfigHelper setDefaultTZImageConfig:imagePickerVC];
  724. imagePickerVC.allowTakePicture = YES;
  725. imagePickerVC.allowPickingVideo = NO;
  726. imagePickerVC.allowPickingImage = YES;
  727. imagePickerVC.allowPickingOriginalPhoto = NO;
  728. imagePickerVC.showSelectBtn = NO;
  729. imagePickerVC.allowCrop = YES;
  730. imagePickerVC.sortAscendingByModificationDate = YES;
  731. [imagePickerVC setDidFinishPickingPhotosHandle:^(NSArray<UIImage *> *photos, NSArray *assets, BOOL isSelectOriginalPhoto) {
  732. //1通过,0待审核,2,未通过
  733. [LCCommonHttp uploadWithImages:photos Type:@"avatar" successBlock:^(NSArray<NSString *> *ossImagePaths) {
  734. NSString *uploadImage = ossImagePaths.firstObject;
  735. self.userAvatar = uploadImage;
  736. }];
  737. }];
  738. imagePickerVC.modalPresentationStyle = UIModalPresentationFullScreen;
  739. [[YMGlobalUtils getCurrentVC] presentViewController:imagePickerVC animated:YES completion:nil];
  740. } else {
  741. [ZCHUDHelper showTitle:@"正在审核头像中,请耐心等待" showtime:1.5];
  742. }
  743. }
  744. #pragma mark - 相册选择器
  745. - (void)openAlbumPickerPopupView{
  746. NSLog(@"可选数量:%ld",6 - self.albumDataArray.count);
  747. TZImagePickerController *imagePickerVC = [[TZImagePickerController alloc] initWithMaxImagesCount:6 columnNumber:4 delegate:self];
  748. [LCTZImageConfigHelper setDefaultTZImageConfig:imagePickerVC];
  749. imagePickerVC.selectedAssets = self.selectedAssets;
  750. imagePickerVC.allowTakePicture = NO;
  751. imagePickerVC.allowTakeVideo = NO;
  752. imagePickerVC.allowPickingVideo = NO;
  753. imagePickerVC.allowPickingImage = YES;
  754. imagePickerVC.showSelectBtn = YES;
  755. imagePickerVC.allowPickingOriginalPhoto = YES;
  756. imagePickerVC.showSelectedIndex = YES;
  757. imagePickerVC.sortAscendingByModificationDate = YES;
  758. [imagePickerVC setDidFinishPickingPhotosHandle:^(NSArray<UIImage *> *photos, NSArray *assets, BOOL isSelectOriginalPhoto) {
  759. [self.selectedAssets removeAllObjects];
  760. [self.selectedAssets addObjectsFromArray:assets?:@[]];
  761. [self.addAlbumSubject sendNext:photos];
  762. }];
  763. imagePickerVC.modalPresentationStyle = UIModalPresentationFullScreen;
  764. [[YMGlobalUtils getCurrentVC] presentViewController:imagePickerVC animated:YES completion:nil];
  765. }
  766. #pragma mark - 年龄选择器
  767. - (void)openAgePickerPopupView{
  768. YMPickerViewModel *pickerVM = [[YMPickerViewModel alloc]initWithParams:@{
  769. @"componentDataSource":@[
  770. @{
  771. @"componentName":@"年龄",
  772. @"rowDataSource":self.ageDataArray?:@[]
  773. }
  774. ]
  775. }];
  776. YMPickerPopupView *customView = [[YMPickerPopupView alloc]init];
  777. [customView ym_bindViewModel:pickerVM];
  778. customView.titleText = @"请选择年龄";
  779. YMPopupView *popupView = [YMPopupView initWithCustomView:customView parentView:nil popStyle:YMPopupStyleSmoothFromBottom dismissStyle:YMDismissStyleSmoothToBottom];
  780. popupView.priority = 999;
  781. popupView.cornerRadius = adapt(10);
  782. popupView.rectCorners = UIRectCornerTopLeft|UIRectCornerTopRight;
  783. popupView.positionStyle = YMPositionStyleBottom;
  784. popupView.isClickBgDismiss = YES;
  785. popupView.isHideBg = NO;
  786. popupView.bgAlpha = 0.5;
  787. @weakify(popupView)
  788. customView.buttonBlock = ^(BOOL isConfirm, NSArray<NSDictionary *> * _Nonnull currentSelectedDataArray) {
  789. @strongify(popupView)
  790. if (isConfirm) {
  791. NSLog(@"%@",currentSelectedDataArray);
  792. self.infoDataArray = [self.infoDataArray.rac_sequence map:^id _Nullable(YMEditProfileInfoCellViewModel * _Nullable viewModel) {
  793. switch (viewModel.editProfileType) {
  794. case YMEditProfileTypeAge:
  795. {
  796. viewModel.infoContent = [currentSelectedDataArray.firstObject stringValueForKey:@"currentSelectedValue" defaultValue:@""];
  797. }
  798. break;
  799. default:
  800. break;
  801. }
  802. return viewModel;
  803. }].array;
  804. [self.refreshUISubject sendNext:@(YMRefreshUI)];
  805. }
  806. [popupView dismissWithStyle:YMDismissStyleSmoothToBottom duration:2.0];
  807. };
  808. [popupView pop];
  809. }
  810. #pragma mark - 星座选择器
  811. - (void)openConstellationPickerPopupView{
  812. YMPickerViewModel *constellationPickerVM = [[YMPickerViewModel alloc]initWithParams:@{
  813. @"componentDataSource":@[
  814. @{
  815. @"componentName":@"星座",
  816. @"rowDataSource":self.constellationDataArray?:@[]
  817. }
  818. ]
  819. }];
  820. YMPickerPopupView *customView = [[YMPickerPopupView alloc]init];
  821. [customView ym_bindViewModel:constellationPickerVM];
  822. customView.titleText = @"请选择星座";
  823. YMPopupView *popupView = [YMPopupView initWithCustomView:customView parentView:nil popStyle:YMPopupStyleSmoothFromBottom dismissStyle:YMDismissStyleSmoothToBottom];
  824. popupView.priority = 999;
  825. popupView.cornerRadius = adapt(10);
  826. popupView.rectCorners = UIRectCornerTopLeft|UIRectCornerTopRight;
  827. popupView.positionStyle = YMPositionStyleBottom;
  828. popupView.isClickBgDismiss = YES;
  829. popupView.isHideBg = NO;
  830. popupView.bgAlpha = 0.5;
  831. @weakify(popupView)
  832. customView.buttonBlock = ^(BOOL isConfirm, NSArray<NSDictionary *> * _Nonnull currentSelectedDataArray) {
  833. @strongify(popupView)
  834. if (isConfirm) {
  835. self.infoDataArray = [self.infoDataArray.rac_sequence map:^id _Nullable(YMEditProfileInfoCellViewModel * _Nullable viewModel) {
  836. switch (viewModel.editProfileType) {
  837. case YMEditProfileTypeConstellation:
  838. {
  839. self.constellationId = [currentSelectedDataArray.firstObject integerValueForKey:@"currentSelectedRowIndex" defaultValue:0];
  840. viewModel.infoContent = [currentSelectedDataArray.firstObject stringValueForKey:@"currentSelectedValue" defaultValue:@""];
  841. }
  842. break;
  843. default:
  844. break;
  845. }
  846. return viewModel;
  847. }].array;
  848. [self.refreshUISubject sendNext:@(YMRefreshUI)];
  849. }
  850. [popupView dismissWithStyle:YMDismissStyleSmoothToBottom duration:2.0];
  851. };
  852. [popupView pop];
  853. }
  854. #pragma mark - 家乡选择器
  855. - (void)openHometownPickerPopupView{
  856. YMCityPickerPopupView *customView = [[YMCityPickerPopupView alloc]init];
  857. customView.titleText = @"请选择家乡";
  858. YMPopupView *popupView = [YMPopupView initWithCustomView:customView parentView:nil popStyle:YMPopupStyleSmoothFromBottom dismissStyle:YMDismissStyleSmoothToBottom];
  859. popupView.priority = 999;
  860. popupView.cornerRadius = adapt(10);
  861. popupView.rectCorners = UIRectCornerTopLeft|UIRectCornerTopRight;
  862. popupView.positionStyle = YMPositionStyleBottom;
  863. popupView.isClickBgDismiss = YES;
  864. popupView.isHideBg = NO;
  865. popupView.bgAlpha = 0.5;
  866. @weakify(popupView)
  867. customView.buttonBlock = ^(BOOL isConfirm, NSString * _Nonnull provinceId, NSString * _Nonnull provinceName, NSString * _Nonnull cityId, NSString * _Nonnull cityName) {
  868. @strongify(popupView)
  869. if (isConfirm) {
  870. NSLog(@"%@\n%@\n%@\n%@",provinceId,provinceName,cityId,cityName);
  871. NSDictionary *cityCodeDic = [OCUserDefaults objectForKey:kCITY_CODE_DIC];
  872. if (!OCDictionaryIsEmpty(cityCodeDic)) {
  873. [cityCodeDic enumerateKeysAndObjectsUsingBlock:^(id _Nonnull key, id _Nonnull obj, BOOL * _Nonnull stop) {
  874. if ([cityName containsString:obj]) {
  875. self.cityId = key;
  876. NSLog(@"当前城市Code:%@",self.cityId);
  877. *stop = YES;
  878. }else{
  879. ///如果选择器返回的城市和列表城市对应不上,在遍历查询一直赋予0,让其设置为“保密”
  880. self.cityId = @"0";
  881. }
  882. }];
  883. } else if (!OCDictionaryIsEmpty([YMGlobalUtils shared].cityCodeDic)) {
  884. [[YMGlobalUtils shared].cityCodeDic enumerateKeysAndObjectsUsingBlock:^(id _Nonnull key, id _Nonnull obj, BOOL * _Nonnull stop) {
  885. if ([cityName containsString:obj]) {
  886. self.cityId = key;
  887. NSLog(@"当前城市Code:%@",self.cityId);
  888. *stop = YES;
  889. }else{
  890. ///如果选择器返回的城市和列表城市对应不上,在遍历查询一直赋予0,让其设置为“保密”
  891. self.cityId = @"0";
  892. }
  893. }];
  894. } else {
  895. }
  896. self.infoDataArray = [self.infoDataArray.rac_sequence map:^id _Nullable(YMEditProfileInfoCellViewModel * _Nullable viewModel) {
  897. switch (viewModel.editProfileType) {
  898. case YMEditProfileTypeHometown:
  899. {
  900. viewModel.infoContent = cityName;
  901. }
  902. break;
  903. default:
  904. break;
  905. }
  906. if (OCStringIsEmpty(viewModel.infoContent) || [viewModel.infoContent isEqualToString:@"请完善"]) {
  907. viewModel.infoContentColor = HexColorFromRGB(0x9c9c9c);
  908. } else {
  909. viewModel.infoContentColor = HexColorFromRGB(0x333333);
  910. }
  911. return viewModel;
  912. }].array;
  913. [self.refreshUISubject sendNext:@(YMRefreshUI)];
  914. }
  915. [popupView dismissWithStyle:YMDismissStyleSmoothToBottom duration:2.0];
  916. };
  917. [popupView pop];
  918. }
  919. #pragma mark - 身高选择器
  920. - (void)openHeightPickerPopupView{
  921. YMPickerViewModel *heightPickerVM = [[YMPickerViewModel alloc]initWithParams:@{
  922. @"componentDataSource":@[
  923. @{
  924. @"componentName":@"身高",
  925. @"rowDataSource":self.heightDataArray?:@[]
  926. }
  927. ]
  928. }];
  929. YMPickerPopupView *customView = [[YMPickerPopupView alloc]init];
  930. [customView ym_bindViewModel:heightPickerVM];
  931. customView.titleText = @"请选择身高";
  932. YMPopupView *popupView = [YMPopupView initWithCustomView:customView parentView:nil popStyle:YMPopupStyleSmoothFromBottom dismissStyle:YMDismissStyleSmoothToBottom];
  933. popupView.priority = 999;
  934. popupView.cornerRadius = adapt(10);
  935. popupView.rectCorners = UIRectCornerTopLeft|UIRectCornerTopRight;
  936. popupView.positionStyle = YMPositionStyleBottom;
  937. popupView.isClickBgDismiss = YES;
  938. popupView.isHideBg = NO;
  939. popupView.bgAlpha = 0.5;
  940. @weakify(popupView)
  941. customView.buttonBlock = ^(BOOL isConfirm, NSArray<NSDictionary *> * _Nonnull currentSelectedDataArray) {
  942. @strongify(popupView)
  943. if (isConfirm) {
  944. self.infoDataArray = [self.infoDataArray.rac_sequence map:^id _Nullable(YMEditProfileInfoCellViewModel * _Nullable viewModel) {
  945. switch (viewModel.editProfileType) {
  946. case YMEditProfileTypeHeight:
  947. {
  948. viewModel.infoContent = [currentSelectedDataArray.firstObject stringValueForKey:@"currentSelectedValue" defaultValue:@""];
  949. }
  950. break;
  951. default:
  952. break;
  953. }
  954. return viewModel;
  955. }].array;
  956. [self.refreshUISubject sendNext:@(YMRefreshUI)];
  957. }
  958. [popupView dismissWithStyle:YMDismissStyleSmoothToBottom duration:2.0];
  959. };
  960. [popupView pop];
  961. }
  962. #pragma mark - 体重选择器
  963. - (void)openWeightPickerPopupView{
  964. YMPickerViewModel *weightPickerVM = [[YMPickerViewModel alloc]initWithParams:@{
  965. @"componentDataSource":@[
  966. @{
  967. @"componentName":@"体重",
  968. @"rowDataSource":self.weightDataArray?:@[]
  969. }
  970. ]
  971. }];
  972. YMPickerPopupView *customView = [[YMPickerPopupView alloc]init];
  973. [customView ym_bindViewModel:weightPickerVM];
  974. customView.titleText = @"请选择体重";
  975. YMPopupView *popupView = [YMPopupView initWithCustomView:customView parentView:nil popStyle:YMPopupStyleSmoothFromBottom dismissStyle:YMDismissStyleSmoothToBottom];
  976. popupView.priority = 999;
  977. popupView.cornerRadius = adapt(10);
  978. popupView.rectCorners = UIRectCornerTopLeft|UIRectCornerTopRight;
  979. popupView.positionStyle = YMPositionStyleBottom;
  980. popupView.isClickBgDismiss = YES;
  981. popupView.isHideBg = NO;
  982. popupView.bgAlpha = 0.5;
  983. @weakify(popupView)
  984. customView.buttonBlock = ^(BOOL isConfirm, NSArray<NSDictionary *> * _Nonnull currentSelectedDataArray) {
  985. @strongify(popupView)
  986. if (isConfirm) {
  987. self.infoDataArray = [self.infoDataArray.rac_sequence map:^id _Nullable(YMEditProfileInfoCellViewModel * _Nullable viewModel) {
  988. switch (viewModel.editProfileType) {
  989. case YMEditProfileTypeWeight:
  990. {
  991. viewModel.infoContent = [currentSelectedDataArray.firstObject stringValueForKey:@"currentSelectedValue" defaultValue:@""];
  992. }
  993. break;
  994. default:
  995. break;
  996. }
  997. return viewModel;
  998. }].array;
  999. [self.refreshUISubject sendNext:@(YMRefreshUI)];
  1000. }
  1001. [popupView dismissWithStyle:YMDismissStyleSmoothToBottom duration:2.0];
  1002. };
  1003. [popupView pop];
  1004. }
  1005. #pragma mark - 年收入选择器
  1006. - (void)openAnnualIncomePickerPopupView{
  1007. YMPickerViewModel *annualIncomePickerVM = [[YMPickerViewModel alloc]initWithParams:@{
  1008. @"componentDataSource":@[
  1009. @{
  1010. @"componentName":@"年收入",
  1011. @"rowDataSource":self.annualIncomeDataArray?:@[]
  1012. }
  1013. ]
  1014. }];
  1015. YMPickerPopupView *customView = [[YMPickerPopupView alloc]init];
  1016. [customView ym_bindViewModel:annualIncomePickerVM];
  1017. customView.titleText = @"请选择年收入";
  1018. YMPopupView *popupView = [YMPopupView initWithCustomView:customView parentView:nil popStyle:YMPopupStyleSmoothFromBottom dismissStyle:YMDismissStyleSmoothToBottom];
  1019. popupView.priority = 999;
  1020. popupView.cornerRadius = adapt(10);
  1021. popupView.rectCorners = UIRectCornerTopLeft|UIRectCornerTopRight;
  1022. popupView.positionStyle = YMPositionStyleBottom;
  1023. popupView.isClickBgDismiss = YES;
  1024. popupView.isHideBg = NO;
  1025. popupView.bgAlpha = 0.5;
  1026. @weakify(popupView)
  1027. customView.buttonBlock = ^(BOOL isConfirm, NSArray<NSDictionary *> * _Nonnull currentSelectedDataArray) {
  1028. @strongify(popupView)
  1029. if (isConfirm) {
  1030. self.infoDataArray = [self.infoDataArray.rac_sequence map:^id _Nullable(YMEditProfileInfoCellViewModel * _Nullable viewModel) {
  1031. switch (viewModel.editProfileType) {
  1032. case YMEditProfileTypeAnnualIncome:
  1033. {
  1034. viewModel.infoContent = [currentSelectedDataArray.firstObject stringValueForKey:@"currentSelectedValue" defaultValue:@""];
  1035. }
  1036. break;
  1037. default:
  1038. break;
  1039. }
  1040. return viewModel;
  1041. }].array;
  1042. [self.refreshUISubject sendNext:@(YMRefreshUI)];
  1043. }
  1044. [popupView dismissWithStyle:YMDismissStyleSmoothToBottom duration:2.0];
  1045. };
  1046. [popupView pop];
  1047. }
  1048. #pragma mark - 婚姻状态选择器
  1049. - (void)openMaritalStatusPickerPopupView{
  1050. YMPickerViewModel *maritalStatusPickerVM = [[YMPickerViewModel alloc]initWithParams:@{
  1051. @"componentDataSource":@[
  1052. @{
  1053. @"componentName":@"婚姻状态",
  1054. @"rowDataSource":self.maritalStatusDataArray?:@[]
  1055. }
  1056. ]
  1057. }];
  1058. YMPickerPopupView *customView = [[YMPickerPopupView alloc]init];
  1059. [customView ym_bindViewModel:maritalStatusPickerVM];
  1060. customView.titleText = @"请选择婚姻状态";
  1061. YMPopupView *popupView = [YMPopupView initWithCustomView:customView parentView:nil popStyle:YMPopupStyleSmoothFromBottom dismissStyle:YMDismissStyleSmoothToBottom];
  1062. popupView.priority = 999;
  1063. popupView.cornerRadius = adapt(10);
  1064. popupView.rectCorners = UIRectCornerTopLeft|UIRectCornerTopRight;
  1065. popupView.positionStyle = YMPositionStyleBottom;
  1066. popupView.isClickBgDismiss = YES;
  1067. popupView.isHideBg = NO;
  1068. popupView.bgAlpha = 0.5;
  1069. @weakify(popupView)
  1070. customView.buttonBlock = ^(BOOL isConfirm, NSArray<NSDictionary *> * _Nonnull currentSelectedDataArray) {
  1071. @strongify(popupView)
  1072. if (isConfirm) {
  1073. self.infoDataArray = [self.infoDataArray.rac_sequence map:^id _Nullable(YMEditProfileInfoCellViewModel * _Nullable viewModel) {
  1074. switch (viewModel.editProfileType) {
  1075. case YMEditProfileTypeMaritalStatus:
  1076. {
  1077. viewModel.infoContent = [currentSelectedDataArray.firstObject stringValueForKey:@"currentSelectedValue" defaultValue:@""];
  1078. }
  1079. break;
  1080. default:
  1081. break;
  1082. }
  1083. return viewModel;
  1084. }].array;
  1085. [self.refreshUISubject sendNext:@(YMRefreshUI)];
  1086. }
  1087. [popupView dismissWithStyle:YMDismissStyleSmoothToBottom duration:2.0];
  1088. };
  1089. [popupView pop];
  1090. }
  1091. #pragma mark - 我的标签
  1092. - (void)openMyTagPopupView {
  1093. @weakify(self)
  1094. YMEditInfoTypeViewModel *editInfoTypeVM = [[YMEditInfoTypeViewModel alloc]initWithParams:@{
  1095. ParamsCategoryType:@(YMEditInfoTypeTag),
  1096. }];
  1097. // [YMRouter openURL:stringFormat(@"%@%@",YM_ROUTER_URL_PREFIX,YM_ROUTER_EDIT_INFO_TYPE) withUserInfo:@{
  1098. // RouterViewModel:editInfoTypeVM
  1099. // } completion:nil];
  1100. YMEditInfoTypeViewController *vc = [[YMEditInfoTypeViewController alloc] initWithViewModel:editInfoTypeVM];
  1101. // YMEditProfileSelectTagView *customView = [[YMEditProfileSelectTagView alloc]init];
  1102. // [customView ym_bindViewModel:editInfoTypeVM];
  1103. YMPopupView *popupView = [YMPopupView initWithCustomView:vc.view parentView:nil popStyle:YMPopupStyleSmoothFromBottom dismissStyle:YMDismissStyleSmoothToBottom];
  1104. vc.cancelButnBlock = ^{
  1105. [popupView dismiss];
  1106. };
  1107. vc.saveButnBlock = ^{
  1108. [editInfoTypeVM saveEditInfo];
  1109. [popupView dismiss];
  1110. };
  1111. editInfoTypeVM.tagBlock = ^(NSArray<YMEditInfoTypeTagCellViewModel *> * _Nonnull selectedTagArray) {
  1112. @strongify(self)
  1113. self.tagDataArray = [selectedTagArray.rac_sequence map:^(YMEditInfoTypeTagCellViewModel * _Nullable cellVM) {
  1114. YMTagModel *model = [[YMTagModel alloc]init];
  1115. model.tag_id = cellVM.tagId;
  1116. model.name = cellVM.tagText;
  1117. YMEditInfoTypeTagCellViewModel *viewModel = [[YMEditInfoTypeTagCellViewModel alloc] initWithParams:@{
  1118. ParamsModel:model
  1119. }];
  1120. return viewModel;
  1121. }].array;
  1122. [popupView dismiss];
  1123. [self.refreshUISubject sendNext:@(YMRefreshUI)];
  1124. };
  1125. UIButton *cancelButn = [UIButton buttonWithType:(UIButtonTypeCustom)];
  1126. cancelButn.backgroundColor = [UIColor whiteColor];
  1127. cancelButn.titleLabel.font = LCFont(13);
  1128. [cancelButn setTitle:@"取消" forState:UIControlStateNormal];
  1129. [cancelButn setTitleColor:LCTextGray forState:UIControlStateNormal];
  1130. WS(weakSelf)
  1131. [[[cancelButn rac_signalForControlEvents:UIControlEventTouchUpInside] takeUntil:self.rac_willDeallocSignal] subscribeNext:^(id x) {
  1132. [popupView dismiss];
  1133. }];
  1134. UIButton *saveButn = [UIButton buttonWithType:(UIButtonTypeCustom)];
  1135. saveButn.titleLabel.font = LCFont(13);
  1136. [saveButn setTitle:@"保存" forState:UIControlStateNormal];
  1137. [saveButn setTitleColor:MAINGRIDTitleC forState:UIControlStateNormal];
  1138. [saveButn ym_setGradientBackgroundWithColors:kMainGradColors locations:kMainGradLocation startPoint:kMainGradStartP endPoint:kMainGradEndP];
  1139. saveButn.layer.cornerRadius = adapt(8);
  1140. saveButn.layer.masksToBounds = YES;
  1141. [[[saveButn rac_signalForControlEvents:UIControlEventTouchUpInside] takeUntil:self.rac_willDeallocSignal] subscribeNext:^(id x) {
  1142. editInfoTypeVM.tagBlock(vc.viewModel.selectedTagArray);
  1143. }];
  1144. vc.ym_customNavView.hidden = YES;
  1145. [vc.view addSubview:cancelButn];
  1146. [vc.view addSubview:saveButn];
  1147. [vc.view mas_makeConstraints:^(MASConstraintMaker *make) {
  1148. make.left.right.bottom.equalTo(popupView);
  1149. make.height.equalTo(popupView).multipliedBy(0.5);
  1150. }];
  1151. [cancelButn mas_makeConstraints:^(MASConstraintMaker *make) {
  1152. make.top.equalTo(vc.view).offset(13);
  1153. make.left.equalTo(vc.view).offset(13);
  1154. make.width.mas_equalTo(70);
  1155. make.height.mas_equalTo(44);
  1156. }];
  1157. [saveButn mas_makeConstraints:^(MASConstraintMaker *make) {
  1158. make.top.equalTo(vc.view).offset(13);
  1159. make.right.equalTo(vc.view).offset(-13);
  1160. make.width.mas_equalTo(70);
  1161. make.height.mas_equalTo(44);
  1162. }];
  1163. popupView.priority = 999;
  1164. popupView.cornerRadius = adapt(10);
  1165. popupView.rectCorners = UIRectCornerTopLeft|UIRectCornerTopRight;
  1166. popupView.positionStyle = YMPositionStyleBottom;
  1167. popupView.isClickBgDismiss = YES;
  1168. popupView.isHideBg = NO;
  1169. popupView.bgAlpha = 0.5;
  1170. @weakify(popupView)
  1171. // customView.buttonBlock = ^(BOOL isConfirm, NSArray<NSDictionary *> * _Nonnull currentSelectedDataArray) {
  1172. // @strongify(popupView)
  1173. // if (isConfirm) {
  1174. // self.infoDataArray = [self.infoDataArray.rac_sequence map:^id _Nullable(YMEditProfileInfoCellViewModel * _Nullable viewModel) {
  1175. // switch (viewModel.editProfileType) {
  1176. //
  1177. // case YMEditProfileTypeMaritalStatus:
  1178. // {
  1179. // viewModel.infoContent = [currentSelectedDataArray.firstObject stringValueForKey:@"currentSelectedValue" defaultValue:@""];
  1180. // }
  1181. // break;
  1182. // default:
  1183. // break;
  1184. // }
  1185. // return viewModel;
  1186. // }].array;
  1187. // [self.refreshUISubject sendNext:@(YMRefreshUI)];
  1188. // }
  1189. // [popupView dismissWithStyle:YMDismissStyleSmoothToBottom duration:2.0];
  1190. // };
  1191. [popupView pop];
  1192. }
  1193. - (RACSubject *)addAlbumSubject{
  1194. if (!_addAlbumSubject) {
  1195. _addAlbumSubject = [RACSubject subject];
  1196. }
  1197. return _addAlbumSubject;
  1198. }
  1199. - (RACSubject *)deleteAlbumSubject{
  1200. if (!_deleteAlbumSubject) {
  1201. _deleteAlbumSubject = [RACSubject subject];
  1202. }
  1203. return _deleteAlbumSubject;
  1204. }
  1205. - (RACSubject *)refreshAlbumSortSubject{
  1206. if (!_refreshAlbumSortSubject) {
  1207. _refreshAlbumSortSubject = [RACSubject subject];
  1208. }
  1209. return _refreshAlbumSortSubject;
  1210. }
  1211. - (RACSubject *)editProfileOperationSubject{
  1212. if (!_editProfileOperationSubject) {
  1213. _editProfileOperationSubject = [RACSubject subject];
  1214. }
  1215. return _editProfileOperationSubject;
  1216. }
  1217. - (NSMutableArray *)selectedAssets{
  1218. if (!_selectedAssets) {
  1219. _selectedAssets = [NSMutableArray array];
  1220. }
  1221. return _selectedAssets;
  1222. }
  1223. @end