12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352 |
- //
- // YMEditProfileViewModel.m
- // MSYOUPAI
- //
- // Created by YoMi on 2024/2/18.
- // Copyright © 2024 MS. All rights reserved.
- //
- #import "YMEditProfileViewModel.h"
- #import "YMPersonalInfoModel.h"
- #import "YMSelectDataTypeModel.h"
- #import "YMEditProfileSelectTagView.h"
- #import "YMEditInfoTypeViewController.h"
- @interface YMEditProfileViewModel ()<TZImagePickerControllerDelegate>
- /// 用户头像
- @property (nonatomic, strong, readwrite) NSString *userAvatar;
- /// 是否隐藏用户头像审核
- @property (nonatomic, assign, readwrite) BOOL isHideUserAvatarUnderReview;
- /// 是否显示添加Cell
- @property (nonatomic, assign, readwrite) BOOL isHideAddCell;
- /// 添加CellViewModel
- @property (nonatomic, strong, readwrite) YMEditProfileAlbumCellViewModel *addCellViewModel;
- /// 相册数据
- @property (nonatomic, strong, readwrite) NSArray <YMEditProfileAlbumCellViewModel *>*albumDataArray;
- /// 用户语音链接
- @property (nonatomic, strong, readwrite) NSString *userVoiceUrl;
- /// 用户语音时长
- @property (nonatomic, assign, readwrite) NSInteger userVoiceDuration;
- /// 是否隐藏用户语音审核
- @property (nonatomic, assign, readwrite) BOOL isHideUserVoiceUnderReview;
- /// 用户昵称
- @property (nonatomic, strong, readwrite) NSString *userNickname;
- /// 信息数据
- @property (nonatomic, strong, readwrite) NSArray <YMEditProfileInfoCellViewModel *>*infoDataArray;
- /// 用户简介
- @property (nonatomic, strong, readwrite) NSString *userIntro;
- /// 标签数据
- @property (nonatomic, strong, readwrite) NSArray <YMEditProfileTagCellViewModel *>*tagDataArray;
- /// 添加相册
- @property (nonatomic, strong, readwrite) RACSubject *addAlbumSubject;
- /// 删除相册
- @property (nonatomic, strong, readwrite) RACSubject *deleteAlbumSubject;
- /// 刷新相册排序
- @property (nonatomic, strong, readwrite) RACSubject *refreshAlbumSortSubject;
- /// 编辑资料操作
- @property (nonatomic, strong, readwrite) RACSubject *editProfileOperationSubject;
- /// 年龄数据
- @property (nonatomic, strong) NSArray *ageDataArray;
- /// 星座数据
- @property (nonatomic, strong) NSArray *constellationDataArray;
- /// 家乡数据
- @property (nonatomic, strong) NSArray *hometownDataArray;
- /// 身高数据
- @property (nonatomic, strong) NSArray *heightDataArray;
- /// 体重数据
- @property (nonatomic, strong) NSArray *weightDataArray;
- /// 年收入数据
- @property (nonatomic, strong) NSArray *annualIncomeDataArray;
- /// 婚姻状态数据
- @property (nonatomic, strong) NSArray *maritalStatusDataArray;
- /// 选中资源
- @property (nonatomic, strong) NSMutableArray *selectedAssets;
- /// 用户Id
- @property (nonatomic, assign) NSInteger userId;
- /// 相册图片链接
- @property (nonatomic, copy) NSString *albumImagesUrl;
- /// 星座Id
- @property (nonatomic, assign) NSInteger constellationId;
- /// 城市Id
- @property (nonatomic, assign) NSString *cityId;
- /// 个人信息模组
- @property (nonatomic, strong) YMPersonalInfoModel *model;
- @end
- @implementation YMEditProfileViewModel
- - (void)ym_initialize{
- [super ym_initialize];
- self.customNavTitle = @"编辑资料";
- self.userId = [self.params integerValueForKey:ParamsId defaultValue:0];
- self.isHideUserAvatarUnderReview = YES;
-
- self.addCellViewModel = [[YMEditProfileAlbumCellViewModel alloc]initWithParams:@{
- @"isAddCell":@(YES),
- @"isHideDeleteButton":@(YES),
- }];
-
- self.isHideUserVoiceUnderReview = YES;
-
- [self defaultInitializePickerData];
-
- self.infoDataArray = [@[
- @{
- @"title":@"昵称",
- @"content":@"去完善",
- ParamsCategoryType:@(YMEditProfileTypeNickname),
- },
- @{
- @"title":@"年龄",
- @"content":@"去完善",
- ParamsCategoryType:@(YMEditProfileTypeAge),
- },
- @{
- @"title":@"星座",
- @"content":@"去完善",
- ParamsCategoryType:@(YMEditProfileTypeConstellation),
- },
- @{
- @"title":@"家乡",
- @"content":@"去完善",
- ParamsCategoryType:@(YMEditProfileTypeHometown),
- },
- @{
- @"title":@"身高",
- @"content":@"去完善",
- ParamsCategoryType:@(YMEditProfileTypeHeight),
- },
- @{
- @"title":@"体重",
- @"content":@"去完善",
- ParamsCategoryType:@(YMEditProfileTypeWeight),
- },
- @{
- @"title":@"年收入",
- @"content":@"去完善",
- ParamsCategoryType:@(YMEditProfileTypeAnnualIncome),
- },
- @{
- @"title":@"婚姻状态",
- @"content":@"去完善",
- ParamsCategoryType:@(YMEditProfileTypeMaritalStatus),
- },
- ].rac_sequence map:^(NSDictionary * _Nullable dic) {
- YMEditProfileInfoCellViewModel *viewModel = [[YMEditProfileInfoCellViewModel alloc]initWithParams:@{
- ParamsModel:dic
- }];
- return viewModel;
- }].array;
-
- @weakify(self)
- [[self.addAlbumSubject takeUntil:self.rac_willDeallocSignal] subscribeNext:^(NSArray <UIImage*> * _Nullable photos) {
-
- NSMutableArray <YMEditProfileAlbumCellViewModel*>*tempArr = [NSMutableArray arrayWithArray:self.albumDataArray];
-
- NSArray *viewModelArr = [photos.rac_sequence map:^id _Nullable(UIImage * _Nullable value) {
- YMEditProfileAlbumCellViewModel *viewModel = [[YMEditProfileAlbumCellViewModel alloc]initWithParams:@{
- @"isAddCell":@(NO),
- @"localAlbum":value,
- @"isHideDeleteButton":@(NO)
- }];
- return viewModel;
- }].array;
-
- [tempArr addObjectsFromArray:viewModelArr];
-
- self.albumDataArray = tempArr.mutableCopy;
-
- self.isHideAddCell = self.albumDataArray.count < 6 ? NO : YES;
-
- NSLog(@"addAlbum:%@",self.albumDataArray);
- [self.refreshUISubject sendNext:@(YMRefreshUI)];
- }];
-
- [[self.deleteAlbumSubject takeUntil:self.rac_willDeallocSignal] subscribeNext:^(NSNumber * _Nullable index) {
- @strongify(self)
-
- NSMutableArray <YMEditProfileAlbumCellViewModel*>*tempArr = [NSMutableArray arrayWithArray:self.albumDataArray];
-
- YMEditProfileAlbumCellViewModel *cellVM = [tempArr objectAtIndex:[index intValue]];
- ///判断当前删除的CellViewModel是网络图片还是本地图片,本地图片则需要删除selectedAssets里面对应本地图片
- if (cellVM.localAlbum != nil) {
-
- [self.selectedAssets enumerateObjectsUsingBlock:^(PHAsset * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
- [[TZImageManager manager] getPhotoWithAsset:obj completion:^(UIImage *photo, NSDictionary *info, BOOL isDegraded) {
- NSData *cellVM_data = UIImagePNGRepresentation(cellVM.localAlbum);
- NSData *asset_data = UIImagePNGRepresentation(photo);
- if ([cellVM_data isEqual:asset_data]) {
- NSLog(@"两个UIImage相同");
- [self.selectedAssets removeObjectAtIndex:idx];
- *stop = YES;
- }
- }];
- }];
-
- }
- [tempArr removeObjectAtIndex:[index intValue]];
-
- self.albumDataArray = tempArr.mutableCopy;
-
- self.isHideAddCell = self.albumDataArray.count < 6 ? NO : YES;
-
- NSLog(@"deleteAlbumSubject:%@",self.albumDataArray);
- [self.refreshUISubject sendNext:@(YMRefreshUI)];
- }];
-
- [[self.refreshAlbumSortSubject takeUntil:self.rac_willDeallocSignal] subscribeNext:^(NSArray <YMEditProfileAlbumCellViewModel *>* _Nullable albumDataArray) {
- self.albumDataArray = albumDataArray;
- NSLog(@"refreshAlbum:%@",self.albumDataArray);
- [self.refreshUISubject sendNext:@(YMRefreshUI)];
- }];
- [[self.editProfileOperationSubject takeUntil:self.rac_willDeallocSignal] subscribeNext:^(id _Nullable value) {
- @strongify(self)
- switch ([value intValue]) {
- case YMEditProfileTypeNickname:
- {
- YMEditInfoTypeViewModel *editInfoTypeVM = [[YMEditInfoTypeViewModel alloc]initWithParams:@{
- ParamsCategoryType:@(YMEditInfoTypeNickname),
- ParamsEditContent:self.userNickname
- }];
- editInfoTypeVM.nicknameBlock = ^(NSString * _Nonnull nickname) {
- @strongify(self)
- self.userNickname = nickname;
- self.infoDataArray = [self.infoDataArray.rac_sequence map:^id _Nullable(YMEditProfileInfoCellViewModel * _Nullable viewModel) {
- switch (viewModel.editProfileType) {
- case YMEditProfileTypeNickname:
- {
- viewModel.infoContent = self.userNickname;
- }
- break;
- default:
- break;
- }
- return viewModel;
- }].array;
- [self.refreshUISubject sendNext:@(YMRefreshUI)];
- };
- [YMRouter openURL:stringFormat(@"%@%@",YM_ROUTER_URL_PREFIX,YM_ROUTER_EDIT_INFO_TYPE) withUserInfo:@{
- RouterViewModel:editInfoTypeVM
- } completion:nil];
- }
- break;
- case YMEditProfileTypeAge:
- {
- [self openAgePickerPopupView];
- }
- break;
- case YMEditProfileTypeConstellation:
- {
- [self openConstellationPickerPopupView];
- }
- break;
- case YMEditProfileTypeHometown:
- {
- [self openHometownPickerPopupView];
- }
- break;
- case YMEditProfileTypeHeight:
- {
- [self openHeightPickerPopupView];
- }
- break;
- case YMEditProfileTypeWeight:
- {
- [self openWeightPickerPopupView];
- }
- break;
- case YMEditProfileTypeAnnualIncome:
- {
- [self openAnnualIncomePickerPopupView];
- }
- break;
- case YMEditProfileTypeMaritalStatus:
- {
- [self openMaritalStatusPickerPopupView];
- }
- break;
- case YMEditProfileTypeIntro:
- {
- YMEditInfoTypeViewModel *editInfoTypeVM = [[YMEditInfoTypeViewModel alloc]initWithParams:@{
- ParamsCategoryType:@(YMEditInfoTypeIntro),
- ParamsEditContent:self.userIntro
- }];
- editInfoTypeVM.introBlock = ^(NSString * _Nonnull intro) {
- @strongify(self)
- self.userIntro = intro;
- };
- [YMRouter openURL:stringFormat(@"%@%@",YM_ROUTER_URL_PREFIX,YM_ROUTER_EDIT_INFO_TYPE) withUserInfo:@{
- RouterViewModel:editInfoTypeVM
- } completion:nil];
- }
- break;
- case YMEditProfileTypeTag:
- {
- // YMEditInfoTypeViewModel *editInfoTypeVM = [[YMEditInfoTypeViewModel alloc]initWithParams:@{
- // ParamsCategoryType:@(YMEditInfoTypeTag),
- // }];
- // editInfoTypeVM.tagBlock = ^(NSArray<YMEditInfoTypeTagCellViewModel *> * _Nonnull selectedTagArray) {
- // @strongify(self)
- // self.tagDataArray = [selectedTagArray.rac_sequence map:^(YMEditInfoTypeTagCellViewModel * _Nullable cellVM) {
- // YMTagModel *model = [[YMTagModel alloc]init];
- // model.tag_id = cellVM.tagId;
- // model.name = cellVM.tagText;
- // YMEditProfileTagCellViewModel *viewModel = [[YMEditProfileTagCellViewModel alloc]initWithParams:@{
- // ParamsModel:model
- // }];
- // return viewModel;
- // }].array;
- // [self.refreshUISubject sendNext:@(YMRefreshUI)];
- // };
- // [YMRouter openURL:stringFormat(@"%@%@",YM_ROUTER_URL_PREFIX,YM_ROUTER_EDIT_INFO_TYPE) withUserInfo:@{
- // RouterViewModel:editInfoTypeVM
- // } completion:nil];
- [self openMyTagPopupView];
- }
- break;
- default:
- break;
- }
- }];
-
- }
- - (void)getEditProfileInfoData{
-
- @weakify(self)
- [ZCHUDHelper showWithStatus:@"加载中..."];
- [LCHttpHelper requestWithURLString:GetUserInfo parameters:@{
- @"user_id":@(self.userId)
- } needToken:YES type:HttpRequestTypePost success:^(id responseObject) {
- @strongify(self)
- NSDictionary* dict = (NSDictionary*)responseObject;
- NSInteger code = [[dict objectForKey:@"code"] integerValue];
- if (code == 0) {
- [ZCHUDHelper dismiss];
- self.model = [YMPersonalInfoModel yy_modelWithJSON:[dict dictionaryValueForKey:@"data" defaultValue:@{}]];
- self.userAvatar = OCStringIsEmpty(self.model.avatar_auth) ? self.model.avatar : self.model.avatar_auth;
- self.isHideUserAvatarUnderReview = self.model.avatar_auth_status == 0 ? NO : YES;
- self.albumDataArray = [self.model.albums_list.rac_sequence map:^id _Nullable(YMAlbumsListModel * _Nullable value) {
- YMEditProfileAlbumCellViewModel *viewModel = [[YMEditProfileAlbumCellViewModel alloc]initWithParams:@{
- @"isAddCell":@(NO),
- @"networkAlbum":value.url,
- @"isHideDeleteButton":@(NO)
- }];
- return viewModel;
- }].array;
- self.userVoiceUrl = self.model.voice.voice;
- self.userVoiceDuration = self.model.voice.voice_time;
- self.isHideUserVoiceUnderReview = self.model.voice.voice_status == 0 && !OCStringIsEmpty(self.model.voice.voice) ? NO : YES;
- self.userNickname = self.model.nickname;
- self.infoDataArray = [self.infoDataArray.rac_sequence map:^(YMEditProfileInfoCellViewModel * _Nullable viewModel) {
- switch (viewModel.editProfileType) {
- case YMEditProfileTypeNickname:
- {
- viewModel.infoContent = self.userNickname;
- }
- break;
- case YMEditProfileTypeAge:
- {
- viewModel.infoContent = self.model.basic_info_detail.age;
- }
- break;
- case YMEditProfileTypeConstellation:
- {
- NSArray * constellationDataArray = @[
- @"保密",
- @"白羊座",
- @"金牛座",
- @"双子座",
- @"巨蟹座",
- @"狮子座",
- @"处女座",
- @"天秤座",
- @"天蝎座",
- @"射手座",
- @"摩羯座",
- @"水瓶座",
- @"双鱼座",
- ];
- viewModel.infoContent = constellationDataArray[self.model.basic_info_detail.signs > 12 ? 0 : self.model.basic_info_detail.signs];
- }
- break;
- case YMEditProfileTypeHometown:
- {
- viewModel.infoContent = self.model.basic_info_detail.city;
- }
- break;
- case YMEditProfileTypeHeight:
- {
- NSString *height = [self.model.basic_info_detail.height stringByReplacingOccurrencesOfString:@"cm" withString:@""];
- if ([height isEqualToString:@"0"] || OCStringIsEmpty(height)) {
- viewModel.infoContent = @"请完善";
- } else {
- viewModel.infoContent = self.model.basic_info_detail.height;
- }
-
- }
- break;
- case YMEditProfileTypeWeight:
- {
-
- NSString *height = [self.model.basic_info_detail.weight stringByReplacingOccurrencesOfString:@"kg" withString:@""];
- if ([height isEqualToString:@"0"] || OCStringIsEmpty(height)) {
- viewModel.infoContent = @"请完善";
- } else {
- viewModel.infoContent = self.model.basic_info_detail.weight;
- }
- }
- break;
- case YMEditProfileTypeAnnualIncome:
- {
- if (OCStringIsEmpty(self.model.basic_info_detail.annual_income)) {
- viewModel.infoContent = @"请完善";
- } else {
- viewModel.infoContent = self.model.basic_info_detail.annual_income;
- }
- }
- break;
- case YMEditProfileTypeMaritalStatus:
- {
- if (OCStringIsEmpty(self.model.basic_info_detail.is_marriage)) {
- viewModel.infoContent = @"请完善";
- } else {
- viewModel.infoContent = self.model.basic_info_detail.is_marriage;
- }
-
- }
- break;
- default:
- break;
- }
- if (OCStringIsEmpty(viewModel.infoContent) || [viewModel.infoContent isEqualToString:@"请完善"]) {
- viewModel.infoContentColor = HexColorFromRGB(0x9c9c9c);
- } else {
- viewModel.infoContentColor = HexColorFromRGB(0x333333);
- }
- return viewModel;
- }].array;
-
-
- self.userIntro = [self.model.sign containsString:@"这个人很懒,什么都没有留下"] ? @"" : self.model.sign;
-
- self.tagDataArray = [self.model.label.rac_sequence map:^(YMTagModel * _Nullable model) {
- YMEditProfileTagCellViewModel *viewModel = [[YMEditProfileTagCellViewModel alloc]initWithParams:@{
- ParamsModel:model
- }];
- return viewModel;
- }].array;
-
- [self.refreshUISubject sendNext:@(YMRefreshUI)];
- }else{
- [ZCHUDHelper showTitle:[dict stringValueForKey:@"message" defaultValue:@""]];
- [self.refreshUISubject sendNext:@(YMRefreshUI)];
-
- }
- } failure:^(NSError *error) {
- [ZCHUDHelper showTitle:error.localizedDescription];
- [self.refreshUISubject sendNext:@(YMRefreshUI)];
- }];
-
- [LCHttpHelper requestWithURLString:api_getSelectData parameters:@{} needToken:YES type:HttpRequestTypePost success:^(id responseObject) {
- NSDictionary* dict = (NSDictionary*)responseObject;
- NSInteger code = [[dict objectForKey:@"code"] integerValue];
- if (code == 0) {
- YMSelectDataTypeModel *model = [YMSelectDataTypeModel yy_modelWithJSON:[dict dictionaryValueForKey:@"data" defaultValue:@{}]];
- }
- } failure:^(NSError *error) {
- [ZCHUDHelper showTitle:error.localizedDescription];
- }];
- }
- - (void)uploadAlbumData{
-
- NSArray <NSString*> *networkAlbumPhotos = [[self.albumDataArray.rac_sequence filter:^BOOL(YMEditProfileAlbumCellViewModel * _Nullable viewModel) {
- if (!OCStringIsEmpty(viewModel.networkAlbum)) {
- return YES;
- } else {
- return NO;
- }
- }] map:^id _Nullable(YMEditProfileAlbumCellViewModel * _Nullable viewModel) {
- return viewModel.networkAlbum;
- }].array;
-
- NSArray <UIImage*> *localAlbumPhotos = [[self.albumDataArray.rac_sequence filter:^BOOL(YMEditProfileAlbumCellViewModel * _Nullable viewModel) {
- if (viewModel.localAlbum != nil) {
- return YES;
- } else {
- return NO;
- }
- }] map:^id _Nullable(YMEditProfileAlbumCellViewModel * _Nullable viewModel) {
- return viewModel.localAlbum;
- }].array;
-
- if (localAlbumPhotos.count > 0) {
- [ZCHUDHelper showWithStatus:@"正在上传相册..."];
- [LCCommonHttp uploadWithImages:localAlbumPhotos Type:@"album" successBlock:^(NSArray<NSString *> *ossImagePaths) {
- [ZCHUDHelper dismiss];
- NSMutableArray *tempUrlArray = [NSMutableArray array];
- [tempUrlArray addObjectsFromArray:networkAlbumPhotos];
- [tempUrlArray addObjectsFromArray:ossImagePaths];
- self.albumImagesUrl = [tempUrlArray componentsJoinedByString:@","];
- [self saveEditProfileInfoData];
- }];
- }else{
- NSArray <NSString*> *networkAlbumPhotos = [[self.albumDataArray.rac_sequence filter:^BOOL(YMEditProfileAlbumCellViewModel * _Nullable viewModel) {
- if (!OCStringIsEmpty(viewModel.networkAlbum)) {
- return YES;
- } else {
- return NO;
- }
- }] map:^id _Nullable(YMEditProfileAlbumCellViewModel * _Nullable viewModel) {
- return viewModel.networkAlbum;
- }].array;
-
- NSMutableArray *tempUrlArray = [NSMutableArray array];
- [tempUrlArray addObjectsFromArray:networkAlbumPhotos];
- self.albumImagesUrl = [tempUrlArray componentsJoinedByString:@","];
-
- [self saveEditProfileInfoData];
- }
- }
- - (void)saveEditProfileInfoData{
- @weakify(self)
- [ZCHUDHelper showWithStatus:@"保存中..."];
-
- NSMutableDictionary *params = [NSMutableDictionary dictionary];
- [params setObject:@(self.userId) forKey:@"user_id"];
- ///头像
- if (![self.userAvatar isEqualToString:self.model.avatar]) {
- [params setObject:self.userAvatar forKey:@"avatar"];
- }
-
- ///相册
- NSArray *oldAlbumArr = [[self.model.albums_list.rac_sequence filter:^BOOL(YMAlbumsListModel * _Nullable value) {
- if (value.is_video) {
- return NO;
- } else {
- return YES;
- }
- }] map:^id _Nullable(YMAlbumsListModel * _Nullable value) {
- return value.url;
- }].array;
-
- NSString *oldImageUrl = [oldAlbumArr componentsJoinedByString:@","];
-
- if (![self.albumImagesUrl isEqualToString:oldImageUrl]){
- [params setObject:self.albumImagesUrl forKey:@"albums"];
- }
-
- ///语音
- if (![self.userVoiceUrl isEqualToString:self.model.voice.voice]) {
- [params setObject:self.userVoiceUrl forKey:@"voice"];
- [params setObject:@(self.userVoiceDuration) forKey:@"voice_time"];
- }
-
- [self.infoDataArray enumerateObjectsUsingBlock:^(YMEditProfileInfoCellViewModel * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
-
- switch (obj.editProfileType) {
- case YMEditProfileTypeNickname:
- {
- ///昵称
- if (![obj.infoContent isEqualToString:self.model.nickname] && ![obj.infoContent isEqualToString:@"请完善"]) {
- [params setObject:obj.infoContent forKey:@"nickname"];
- }
- }
- break;
- case YMEditProfileTypeAge:
- {
- ///年龄
- if (![obj.infoContent isEqualToString:self.model.basic_info_detail.age] && ![obj.infoContent isEqualToString:@"请完善"]) {
- [params setObject:obj.infoContent forKey:@"age"];
- }
- }
- break;
- case YMEditProfileTypeConstellation:
- {
- ///星座
- if (self.constellationId != self.model.basic_info_detail.signs && ![obj.infoContent isEqualToString:@"请完善"]) {
- [params setObject:@(self.constellationId) forKey:@"signs"];
- }
- }
- break;
- case YMEditProfileTypeHometown:
- {
- ///家乡
- if (![self.cityId isEqualToString:self.model.basic_info_detail.city] && ![obj.infoContent isEqualToString:@"请完善"]) {
- [params setObject:self.cityId forKey:@"cityId"];
- }
- }
- break;
- case YMEditProfileTypeHeight:
- {
- ///身高
- if (![obj.infoContent isEqualToString:self.model.basic_info_detail.height] && ![obj.infoContent isEqualToString:@"请完善"]) {
- [params setObject:obj.infoContent forKey:@"height"];
- }
- }
- break;
- case YMEditProfileTypeWeight:
- {
- ///体重
- if (![obj.infoContent isEqualToString:self.model.basic_info_detail.weight] && ![obj.infoContent isEqualToString:@"请完善"]) {
- [params setObject:obj.infoContent forKey:@"weight"];
- }
- }
- break;
- case YMEditProfileTypeAnnualIncome:
- {
- ///年收入
- if (![obj.infoContent isEqualToString:self.model.basic_info_detail.annual_income] && ![obj.infoContent isEqualToString:@"请完善"]) {
- [params setObject:obj.infoContent forKey:@"annual_income"];
- }
- }
- break;
- case YMEditProfileTypeMaritalStatus:
- {
- ///婚姻状态
- if (![obj.infoContent isEqualToString:self.model.basic_info_detail.is_marriage] && ![obj.infoContent isEqualToString:@"请完善"]) {
- [params setObject:obj.infoContent forKey:@"is_marriage"];
- }
- }
- break;
- default:
- break;
- }
- }];
-
- ///简介
- if (![self.userIntro isEqualToString:self.model.sign]) {
- [params setObject:self.userIntro forKey:@"signature"];
- }
-
- ///标签
- NSArray *newTagArr = [self.tagDataArray.rac_sequence map:^id _Nullable(YMEditProfileTagCellViewModel * _Nullable value) {
- return @(value.tagId);
- }].array;
- NSArray *oldTagArr = [self.model.label.rac_sequence map:^id _Nullable(YMTagModel * _Nullable value) {
- return @(value.tag_id);
- }].array;
-
- NSString *newTagStr = [newTagArr componentsJoinedByString:@","];
-
- NSString *oldTagStr = [oldTagArr componentsJoinedByString:@","];
-
- if (![newTagStr isEqualToString:oldTagStr]){
- [params setObject:newTagStr forKey:@"label"];
- }
-
- [LCHttpHelper requestWithURLString:api_Improve_data parameters:params needToken:YES type:HttpRequestTypePost success:^(id responseObject) {
- @strongify(self)
- NSDictionary* dict = (NSDictionary*)responseObject;
- NSInteger code = [[dict objectForKey:@"code"] integerValue];
- if (code == 0) {
- [ZCHUDHelper dismiss];
- [[YMGlobalUtils getCurrentVC].navigationController popViewControllerAnimated:YES];
- }else{
- [ZCHUDHelper showTitle:[dict stringValueForKey:@"message" defaultValue:@""]];
-
- }
- } failure:^(NSError *error) {
- [ZCHUDHelper showTitle:error.localizedDescription];
- }];
- }
- - (void)gotoSoundShowcase{
- if (self.isHideUserVoiceUnderReview) {
- YMSoundShowcaseViewModel *soundShowcaseVM = [[YMSoundShowcaseViewModel alloc]initWithParams:@{}];
- @weakify(self)
- soundShowcaseVM.templateVoiceBlock = ^(NSString * _Nonnull voiceUrl, NSInteger voiceDuration) {
- @strongify(self)
- self.userVoiceUrl = voiceUrl;
- self.userVoiceDuration = voiceDuration;
- };
- [YMRouter openURL:stringFormat(@"%@%@", YM_ROUTER_URL_PREFIX, YM_ROUTER_SOUND_SHOWCASE) withUserInfo:@{
- RouterViewModel:soundShowcaseVM
- } completion:nil];
- } else {
- [ZCHUDHelper showTitle:@"正在审核语音中,请耐心等待" showtime:1.5];
- }
-
- }
- #pragma mark - 默认初始化选择器数据
- - (void)defaultInitializePickerData{
- NSMutableArray *ageDataArray = [NSMutableArray array];
- for (int i = 18; i<=60; i++) {
- [ageDataArray addObject:@{
- @"rowName":stringFormat(@"%d岁",i)
- }];
- }
- self.ageDataArray = ageDataArray.mutableCopy;
-
- self.constellationDataArray = @[
- @{
- @"rowName":@"保密"
- },
- @{
- @"rowName":@"白羊座(3.21 - 4.19)"
- },
- @{
- @"rowName":@"金牛座(4.20 - 5.20)"
- },
- @{
- @"rowName":@"双子座(5.21 - 6.21)"
- },
- @{
- @"rowName":@"巨蟹座(6.22 - 7.22)"
- },
- @{
- @"rowName":@"狮子座(7.23 - 8.22)"
- },
- @{
- @"rowName":@"处女座(8.23 - 9.22)"
- },
- @{
- @"rowName":@"天秤座(9.23 - 10.23)"
- },
- @{
- @"rowName":@"天蝎座(10.24 - 11.22)"
- },
- @{
- @"rowName":@"射手座(11.23 - 12.21)"
- },
- @{
- @"rowName":@"摩羯座(12.22 - 1.19)"
- },
- @{
- @"rowName":@"水瓶座(1.20 - 2.18)"
- },
- @{
- @"rowName":@"双鱼座(2.19 - 3.20)"
- },
- ];
-
- NSMutableArray *heightDataArray = [NSMutableArray array];
- for (int i = 60; i<=200; i++) {
- [heightDataArray addObject:@{
- @"rowName":stringFormat(@"%dcm",i)
- }];
- }
- self.heightDataArray = heightDataArray.mutableCopy;
-
- NSMutableArray *weightDataArray = [NSMutableArray array];
- for (int i = 40; i<=100; i++) {
- [weightDataArray addObject:@{
- @"rowName":stringFormat(@"%dkg",i)
- }];
- }
- self.weightDataArray = weightDataArray.mutableCopy;
-
- self.annualIncomeDataArray = @[
- @{
- @"rowName":@"保密"
- },
- @{
- @"rowName":@"5万以下"
- },
- @{
- @"rowName":@"5万 - 10万"
- },
- @{
- @"rowName":@"10万 - 20万"
- },
- @{
- @"rowName":@"20万 - 30万"
- },
- @{
- @"rowName":@"30万 - 50万"
- },
- @{
- @"rowName":@"50万以上"
- },
- ];
-
- self.maritalStatusDataArray = @[
- @{
- @"rowName":@"单身"
- },
- @{
- @"rowName":@"寻爱中"
- },
- @{
- @"rowName":@"有伴侣"
- },
- @{
- @"rowName":@"已婚"
- },
- @{
- @"rowName":@"离异"
- },
- ];
- }
- #pragma mark - 头像选择器
- - (void)openAvatarPickerPopupView{
- if (self.isHideUserAvatarUnderReview) {
- TZImagePickerController *imagePickerVC = [[TZImagePickerController alloc] initWithMaxImagesCount:1 columnNumber:4 delegate:self];
- [LCTZImageConfigHelper setDefaultTZImageConfig:imagePickerVC];
- imagePickerVC.allowTakePicture = YES;
- imagePickerVC.allowPickingVideo = NO;
- imagePickerVC.allowPickingImage = YES;
- imagePickerVC.allowPickingOriginalPhoto = NO;
- imagePickerVC.showSelectBtn = NO;
- imagePickerVC.allowCrop = YES;
- imagePickerVC.sortAscendingByModificationDate = YES;
- [imagePickerVC setDidFinishPickingPhotosHandle:^(NSArray<UIImage *> *photos, NSArray *assets, BOOL isSelectOriginalPhoto) {
- //1通过,0待审核,2,未通过
- [LCCommonHttp uploadWithImages:photos Type:@"avatar" successBlock:^(NSArray<NSString *> *ossImagePaths) {
- NSString *uploadImage = ossImagePaths.firstObject;
- self.userAvatar = uploadImage;
- }];
- }];
- imagePickerVC.modalPresentationStyle = UIModalPresentationFullScreen;
- [[YMGlobalUtils getCurrentVC] presentViewController:imagePickerVC animated:YES completion:nil];
- } else {
- [ZCHUDHelper showTitle:@"正在审核头像中,请耐心等待" showtime:1.5];
- }
-
- }
- #pragma mark - 相册选择器
- - (void)openAlbumPickerPopupView{
- NSLog(@"可选数量:%ld",6 - self.albumDataArray.count);
- TZImagePickerController *imagePickerVC = [[TZImagePickerController alloc] initWithMaxImagesCount:6 columnNumber:4 delegate:self];
- [LCTZImageConfigHelper setDefaultTZImageConfig:imagePickerVC];
- imagePickerVC.selectedAssets = self.selectedAssets;
- imagePickerVC.allowTakePicture = NO;
- imagePickerVC.allowTakeVideo = NO;
- imagePickerVC.allowPickingVideo = NO;
- imagePickerVC.allowPickingImage = YES;
- imagePickerVC.showSelectBtn = YES;
- imagePickerVC.allowPickingOriginalPhoto = YES;
- imagePickerVC.showSelectedIndex = YES;
- imagePickerVC.sortAscendingByModificationDate = YES;
- [imagePickerVC setDidFinishPickingPhotosHandle:^(NSArray<UIImage *> *photos, NSArray *assets, BOOL isSelectOriginalPhoto) {
- [self.selectedAssets removeAllObjects];
- [self.selectedAssets addObjectsFromArray:assets?:@[]];
- [self.addAlbumSubject sendNext:photos];
- }];
- imagePickerVC.modalPresentationStyle = UIModalPresentationFullScreen;
- [[YMGlobalUtils getCurrentVC] presentViewController:imagePickerVC animated:YES completion:nil];
-
- }
- #pragma mark - 年龄选择器
- - (void)openAgePickerPopupView{
- YMPickerViewModel *pickerVM = [[YMPickerViewModel alloc]initWithParams:@{
- @"componentDataSource":@[
- @{
- @"componentName":@"年龄",
- @"rowDataSource":self.ageDataArray?:@[]
- }
- ]
- }];
- YMPickerPopupView *customView = [[YMPickerPopupView alloc]init];
- [customView ym_bindViewModel:pickerVM];
- customView.titleText = @"请选择年龄";
-
- YMPopupView *popupView = [YMPopupView initWithCustomView:customView parentView:nil popStyle:YMPopupStyleSmoothFromBottom dismissStyle:YMDismissStyleSmoothToBottom];
- popupView.priority = 999;
- popupView.cornerRadius = adapt(10);
- popupView.rectCorners = UIRectCornerTopLeft|UIRectCornerTopRight;
- popupView.positionStyle = YMPositionStyleBottom;
- popupView.isClickBgDismiss = YES;
- popupView.isHideBg = NO;
- popupView.bgAlpha = 0.5;
- @weakify(popupView)
- customView.buttonBlock = ^(BOOL isConfirm, NSArray<NSDictionary *> * _Nonnull currentSelectedDataArray) {
- @strongify(popupView)
- if (isConfirm) {
- NSLog(@"%@",currentSelectedDataArray);
- self.infoDataArray = [self.infoDataArray.rac_sequence map:^id _Nullable(YMEditProfileInfoCellViewModel * _Nullable viewModel) {
- switch (viewModel.editProfileType) {
-
- case YMEditProfileTypeAge:
- {
- viewModel.infoContent = [currentSelectedDataArray.firstObject stringValueForKey:@"currentSelectedValue" defaultValue:@""];
- }
- break;
- default:
- break;
- }
- return viewModel;
- }].array;
- [self.refreshUISubject sendNext:@(YMRefreshUI)];
- }
- [popupView dismissWithStyle:YMDismissStyleSmoothToBottom duration:2.0];
- };
- [popupView pop];
- }
- #pragma mark - 星座选择器
- - (void)openConstellationPickerPopupView{
-
-
- YMPickerViewModel *constellationPickerVM = [[YMPickerViewModel alloc]initWithParams:@{
- @"componentDataSource":@[
- @{
- @"componentName":@"星座",
- @"rowDataSource":self.constellationDataArray?:@[]
- }
- ]
- }];
-
- YMPickerPopupView *customView = [[YMPickerPopupView alloc]init];
- [customView ym_bindViewModel:constellationPickerVM];
- customView.titleText = @"请选择星座";
-
- YMPopupView *popupView = [YMPopupView initWithCustomView:customView parentView:nil popStyle:YMPopupStyleSmoothFromBottom dismissStyle:YMDismissStyleSmoothToBottom];
- popupView.priority = 999;
- popupView.cornerRadius = adapt(10);
- popupView.rectCorners = UIRectCornerTopLeft|UIRectCornerTopRight;
- popupView.positionStyle = YMPositionStyleBottom;
- popupView.isClickBgDismiss = YES;
- popupView.isHideBg = NO;
- popupView.bgAlpha = 0.5;
- @weakify(popupView)
- customView.buttonBlock = ^(BOOL isConfirm, NSArray<NSDictionary *> * _Nonnull currentSelectedDataArray) {
- @strongify(popupView)
- if (isConfirm) {
- self.infoDataArray = [self.infoDataArray.rac_sequence map:^id _Nullable(YMEditProfileInfoCellViewModel * _Nullable viewModel) {
- switch (viewModel.editProfileType) {
-
- case YMEditProfileTypeConstellation:
- {
- self.constellationId = [currentSelectedDataArray.firstObject integerValueForKey:@"currentSelectedRowIndex" defaultValue:0];
-
- viewModel.infoContent = [currentSelectedDataArray.firstObject stringValueForKey:@"currentSelectedValue" defaultValue:@""];
- }
- break;
- default:
- break;
- }
- return viewModel;
- }].array;
- [self.refreshUISubject sendNext:@(YMRefreshUI)];
- }
- [popupView dismissWithStyle:YMDismissStyleSmoothToBottom duration:2.0];
- };
- [popupView pop];
- }
- #pragma mark - 家乡选择器
- - (void)openHometownPickerPopupView{
-
- YMCityPickerPopupView *customView = [[YMCityPickerPopupView alloc]init];
- customView.titleText = @"请选择家乡";
-
- YMPopupView *popupView = [YMPopupView initWithCustomView:customView parentView:nil popStyle:YMPopupStyleSmoothFromBottom dismissStyle:YMDismissStyleSmoothToBottom];
- popupView.priority = 999;
- popupView.cornerRadius = adapt(10);
- popupView.rectCorners = UIRectCornerTopLeft|UIRectCornerTopRight;
- popupView.positionStyle = YMPositionStyleBottom;
- popupView.isClickBgDismiss = YES;
- popupView.isHideBg = NO;
- popupView.bgAlpha = 0.5;
- @weakify(popupView)
- customView.buttonBlock = ^(BOOL isConfirm, NSString * _Nonnull provinceId, NSString * _Nonnull provinceName, NSString * _Nonnull cityId, NSString * _Nonnull cityName) {
- @strongify(popupView)
- if (isConfirm) {
- NSLog(@"%@\n%@\n%@\n%@",provinceId,provinceName,cityId,cityName);
-
- NSDictionary *cityCodeDic = [OCUserDefaults objectForKey:kCITY_CODE_DIC];
- if (!OCDictionaryIsEmpty(cityCodeDic)) {
- [cityCodeDic enumerateKeysAndObjectsUsingBlock:^(id _Nonnull key, id _Nonnull obj, BOOL * _Nonnull stop) {
- if ([cityName containsString:obj]) {
- self.cityId = key;
- NSLog(@"当前城市Code:%@",self.cityId);
- *stop = YES;
- }else{
- ///如果选择器返回的城市和列表城市对应不上,在遍历查询一直赋予0,让其设置为“保密”
- self.cityId = @"0";
- }
- }];
- } else if (!OCDictionaryIsEmpty([YMGlobalUtils shared].cityCodeDic)) {
- [[YMGlobalUtils shared].cityCodeDic enumerateKeysAndObjectsUsingBlock:^(id _Nonnull key, id _Nonnull obj, BOOL * _Nonnull stop) {
- if ([cityName containsString:obj]) {
- self.cityId = key;
- NSLog(@"当前城市Code:%@",self.cityId);
- *stop = YES;
- }else{
- ///如果选择器返回的城市和列表城市对应不上,在遍历查询一直赋予0,让其设置为“保密”
- self.cityId = @"0";
- }
- }];
- } else {
-
- }
-
- self.infoDataArray = [self.infoDataArray.rac_sequence map:^id _Nullable(YMEditProfileInfoCellViewModel * _Nullable viewModel) {
- switch (viewModel.editProfileType) {
-
- case YMEditProfileTypeHometown:
- {
- viewModel.infoContent = cityName;
- }
- break;
- default:
- break;
- }
- if (OCStringIsEmpty(viewModel.infoContent) || [viewModel.infoContent isEqualToString:@"请完善"]) {
- viewModel.infoContentColor = HexColorFromRGB(0x9c9c9c);
- } else {
- viewModel.infoContentColor = HexColorFromRGB(0x333333);
- }
- return viewModel;
- }].array;
- [self.refreshUISubject sendNext:@(YMRefreshUI)];
- }
- [popupView dismissWithStyle:YMDismissStyleSmoothToBottom duration:2.0];
- };
- [popupView pop];
- }
- #pragma mark - 身高选择器
- - (void)openHeightPickerPopupView{
-
-
- YMPickerViewModel *heightPickerVM = [[YMPickerViewModel alloc]initWithParams:@{
- @"componentDataSource":@[
- @{
- @"componentName":@"身高",
- @"rowDataSource":self.heightDataArray?:@[]
- }
- ]
- }];
-
- YMPickerPopupView *customView = [[YMPickerPopupView alloc]init];
- [customView ym_bindViewModel:heightPickerVM];
- customView.titleText = @"请选择身高";
-
- YMPopupView *popupView = [YMPopupView initWithCustomView:customView parentView:nil popStyle:YMPopupStyleSmoothFromBottom dismissStyle:YMDismissStyleSmoothToBottom];
- popupView.priority = 999;
- popupView.cornerRadius = adapt(10);
- popupView.rectCorners = UIRectCornerTopLeft|UIRectCornerTopRight;
- popupView.positionStyle = YMPositionStyleBottom;
- popupView.isClickBgDismiss = YES;
- popupView.isHideBg = NO;
- popupView.bgAlpha = 0.5;
- @weakify(popupView)
- customView.buttonBlock = ^(BOOL isConfirm, NSArray<NSDictionary *> * _Nonnull currentSelectedDataArray) {
- @strongify(popupView)
- if (isConfirm) {
- self.infoDataArray = [self.infoDataArray.rac_sequence map:^id _Nullable(YMEditProfileInfoCellViewModel * _Nullable viewModel) {
- switch (viewModel.editProfileType) {
-
- case YMEditProfileTypeHeight:
- {
- viewModel.infoContent = [currentSelectedDataArray.firstObject stringValueForKey:@"currentSelectedValue" defaultValue:@""];
- }
- break;
- default:
- break;
- }
- return viewModel;
- }].array;
- [self.refreshUISubject sendNext:@(YMRefreshUI)];
- }
- [popupView dismissWithStyle:YMDismissStyleSmoothToBottom duration:2.0];
- };
- [popupView pop];
- }
- #pragma mark - 体重选择器
- - (void)openWeightPickerPopupView{
-
-
- YMPickerViewModel *weightPickerVM = [[YMPickerViewModel alloc]initWithParams:@{
- @"componentDataSource":@[
- @{
- @"componentName":@"体重",
- @"rowDataSource":self.weightDataArray?:@[]
- }
- ]
- }];
-
- YMPickerPopupView *customView = [[YMPickerPopupView alloc]init];
- [customView ym_bindViewModel:weightPickerVM];
- customView.titleText = @"请选择体重";
-
- YMPopupView *popupView = [YMPopupView initWithCustomView:customView parentView:nil popStyle:YMPopupStyleSmoothFromBottom dismissStyle:YMDismissStyleSmoothToBottom];
- popupView.priority = 999;
- popupView.cornerRadius = adapt(10);
- popupView.rectCorners = UIRectCornerTopLeft|UIRectCornerTopRight;
- popupView.positionStyle = YMPositionStyleBottom;
- popupView.isClickBgDismiss = YES;
- popupView.isHideBg = NO;
- popupView.bgAlpha = 0.5;
- @weakify(popupView)
- customView.buttonBlock = ^(BOOL isConfirm, NSArray<NSDictionary *> * _Nonnull currentSelectedDataArray) {
- @strongify(popupView)
- if (isConfirm) {
- self.infoDataArray = [self.infoDataArray.rac_sequence map:^id _Nullable(YMEditProfileInfoCellViewModel * _Nullable viewModel) {
- switch (viewModel.editProfileType) {
-
- case YMEditProfileTypeWeight:
- {
- viewModel.infoContent = [currentSelectedDataArray.firstObject stringValueForKey:@"currentSelectedValue" defaultValue:@""];
- }
- break;
- default:
- break;
- }
- return viewModel;
- }].array;
- [self.refreshUISubject sendNext:@(YMRefreshUI)];
- }
- [popupView dismissWithStyle:YMDismissStyleSmoothToBottom duration:2.0];
- };
- [popupView pop];
- }
- #pragma mark - 年收入选择器
- - (void)openAnnualIncomePickerPopupView{
-
-
- YMPickerViewModel *annualIncomePickerVM = [[YMPickerViewModel alloc]initWithParams:@{
- @"componentDataSource":@[
- @{
- @"componentName":@"年收入",
- @"rowDataSource":self.annualIncomeDataArray?:@[]
- }
- ]
- }];
-
- YMPickerPopupView *customView = [[YMPickerPopupView alloc]init];
- [customView ym_bindViewModel:annualIncomePickerVM];
- customView.titleText = @"请选择年收入";
-
- YMPopupView *popupView = [YMPopupView initWithCustomView:customView parentView:nil popStyle:YMPopupStyleSmoothFromBottom dismissStyle:YMDismissStyleSmoothToBottom];
- popupView.priority = 999;
- popupView.cornerRadius = adapt(10);
- popupView.rectCorners = UIRectCornerTopLeft|UIRectCornerTopRight;
- popupView.positionStyle = YMPositionStyleBottom;
- popupView.isClickBgDismiss = YES;
- popupView.isHideBg = NO;
- popupView.bgAlpha = 0.5;
- @weakify(popupView)
- customView.buttonBlock = ^(BOOL isConfirm, NSArray<NSDictionary *> * _Nonnull currentSelectedDataArray) {
- @strongify(popupView)
- if (isConfirm) {
- self.infoDataArray = [self.infoDataArray.rac_sequence map:^id _Nullable(YMEditProfileInfoCellViewModel * _Nullable viewModel) {
- switch (viewModel.editProfileType) {
-
- case YMEditProfileTypeAnnualIncome:
- {
- viewModel.infoContent = [currentSelectedDataArray.firstObject stringValueForKey:@"currentSelectedValue" defaultValue:@""];
- }
- break;
- default:
- break;
- }
- return viewModel;
- }].array;
- [self.refreshUISubject sendNext:@(YMRefreshUI)];
- }
- [popupView dismissWithStyle:YMDismissStyleSmoothToBottom duration:2.0];
- };
- [popupView pop];
- }
- #pragma mark - 婚姻状态选择器
- - (void)openMaritalStatusPickerPopupView{
-
-
- YMPickerViewModel *maritalStatusPickerVM = [[YMPickerViewModel alloc]initWithParams:@{
- @"componentDataSource":@[
- @{
- @"componentName":@"婚姻状态",
- @"rowDataSource":self.maritalStatusDataArray?:@[]
- }
- ]
- }];
-
- YMPickerPopupView *customView = [[YMPickerPopupView alloc]init];
- [customView ym_bindViewModel:maritalStatusPickerVM];
- customView.titleText = @"请选择婚姻状态";
-
- YMPopupView *popupView = [YMPopupView initWithCustomView:customView parentView:nil popStyle:YMPopupStyleSmoothFromBottom dismissStyle:YMDismissStyleSmoothToBottom];
- popupView.priority = 999;
- popupView.cornerRadius = adapt(10);
- popupView.rectCorners = UIRectCornerTopLeft|UIRectCornerTopRight;
- popupView.positionStyle = YMPositionStyleBottom;
- popupView.isClickBgDismiss = YES;
- popupView.isHideBg = NO;
- popupView.bgAlpha = 0.5;
- @weakify(popupView)
- customView.buttonBlock = ^(BOOL isConfirm, NSArray<NSDictionary *> * _Nonnull currentSelectedDataArray) {
- @strongify(popupView)
- if (isConfirm) {
- self.infoDataArray = [self.infoDataArray.rac_sequence map:^id _Nullable(YMEditProfileInfoCellViewModel * _Nullable viewModel) {
- switch (viewModel.editProfileType) {
-
- case YMEditProfileTypeMaritalStatus:
- {
- viewModel.infoContent = [currentSelectedDataArray.firstObject stringValueForKey:@"currentSelectedValue" defaultValue:@""];
- }
- break;
- default:
- break;
- }
- return viewModel;
- }].array;
- [self.refreshUISubject sendNext:@(YMRefreshUI)];
- }
- [popupView dismissWithStyle:YMDismissStyleSmoothToBottom duration:2.0];
- };
- [popupView pop];
- }
- #pragma mark - 我的标签
- - (void)openMyTagPopupView {
- @weakify(self)
- YMEditInfoTypeViewModel *editInfoTypeVM = [[YMEditInfoTypeViewModel alloc]initWithParams:@{
- ParamsCategoryType:@(YMEditInfoTypeTag),
- }];
- // [YMRouter openURL:stringFormat(@"%@%@",YM_ROUTER_URL_PREFIX,YM_ROUTER_EDIT_INFO_TYPE) withUserInfo:@{
- // RouterViewModel:editInfoTypeVM
- // } completion:nil];
- YMEditInfoTypeViewController *vc = [[YMEditInfoTypeViewController alloc] initWithViewModel:editInfoTypeVM];
- // YMEditProfileSelectTagView *customView = [[YMEditProfileSelectTagView alloc]init];
- // [customView ym_bindViewModel:editInfoTypeVM];
-
- YMPopupView *popupView = [YMPopupView initWithCustomView:vc.view parentView:nil popStyle:YMPopupStyleSmoothFromBottom dismissStyle:YMDismissStyleSmoothToBottom];
-
- vc.cancelButnBlock = ^{
- [popupView dismiss];
- };
- vc.saveButnBlock = ^{
- [editInfoTypeVM saveEditInfo];
- [popupView dismiss];
- };
- editInfoTypeVM.tagBlock = ^(NSArray<YMEditInfoTypeTagCellViewModel *> * _Nonnull selectedTagArray) {
- @strongify(self)
- self.tagDataArray = [selectedTagArray.rac_sequence map:^(YMEditInfoTypeTagCellViewModel * _Nullable cellVM) {
- YMTagModel *model = [[YMTagModel alloc]init];
- model.tag_id = cellVM.tagId;
- model.name = cellVM.tagText;
- YMEditInfoTypeTagCellViewModel *viewModel = [[YMEditInfoTypeTagCellViewModel alloc] initWithParams:@{
- ParamsModel:model
- }];
- return viewModel;
- }].array;
- [popupView dismiss];
- [self.refreshUISubject sendNext:@(YMRefreshUI)];
- };
-
- UIButton *cancelButn = [UIButton buttonWithType:(UIButtonTypeCustom)];
- cancelButn.backgroundColor = [UIColor whiteColor];
- cancelButn.titleLabel.font = LCFont(13);
- [cancelButn setTitle:@"取消" forState:UIControlStateNormal];
- [cancelButn setTitleColor:LCTextGray forState:UIControlStateNormal];
- WS(weakSelf)
- [[[cancelButn rac_signalForControlEvents:UIControlEventTouchUpInside] takeUntil:self.rac_willDeallocSignal] subscribeNext:^(id x) {
- [popupView dismiss];
- }];
-
- UIButton *saveButn = [UIButton buttonWithType:(UIButtonTypeCustom)];
- saveButn.titleLabel.font = LCFont(13);
- [saveButn setTitle:@"保存" forState:UIControlStateNormal];
- [saveButn setTitleColor:MAINGRIDTitleC forState:UIControlStateNormal];
- [saveButn ym_setGradientBackgroundWithColors:kMainGradColors locations:kMainGradLocation startPoint:kMainGradStartP endPoint:kMainGradEndP];
- saveButn.layer.cornerRadius = adapt(8);
- saveButn.layer.masksToBounds = YES;
- [[[saveButn rac_signalForControlEvents:UIControlEventTouchUpInside] takeUntil:self.rac_willDeallocSignal] subscribeNext:^(id x) {
- editInfoTypeVM.tagBlock(vc.viewModel.selectedTagArray);
- }];
-
- vc.ym_customNavView.hidden = YES;
- [vc.view addSubview:cancelButn];
- [vc.view addSubview:saveButn];
- [vc.view mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.right.bottom.equalTo(popupView);
- make.height.equalTo(popupView).multipliedBy(0.5);
- }];
- [cancelButn mas_makeConstraints:^(MASConstraintMaker *make) {
- make.top.equalTo(vc.view).offset(13);
- make.left.equalTo(vc.view).offset(13);
- make.width.mas_equalTo(70);
- make.height.mas_equalTo(44);
- }];
- [saveButn mas_makeConstraints:^(MASConstraintMaker *make) {
- make.top.equalTo(vc.view).offset(13);
- make.right.equalTo(vc.view).offset(-13);
- make.width.mas_equalTo(70);
- make.height.mas_equalTo(44);
- }];
-
-
-
- popupView.priority = 999;
- popupView.cornerRadius = adapt(10);
- popupView.rectCorners = UIRectCornerTopLeft|UIRectCornerTopRight;
- popupView.positionStyle = YMPositionStyleBottom;
- popupView.isClickBgDismiss = YES;
- popupView.isHideBg = NO;
- popupView.bgAlpha = 0.5;
- @weakify(popupView)
- // customView.buttonBlock = ^(BOOL isConfirm, NSArray<NSDictionary *> * _Nonnull currentSelectedDataArray) {
- // @strongify(popupView)
- // if (isConfirm) {
- // self.infoDataArray = [self.infoDataArray.rac_sequence map:^id _Nullable(YMEditProfileInfoCellViewModel * _Nullable viewModel) {
- // switch (viewModel.editProfileType) {
- //
- // case YMEditProfileTypeMaritalStatus:
- // {
- // viewModel.infoContent = [currentSelectedDataArray.firstObject stringValueForKey:@"currentSelectedValue" defaultValue:@""];
- // }
- // break;
- // default:
- // break;
- // }
- // return viewModel;
- // }].array;
- // [self.refreshUISubject sendNext:@(YMRefreshUI)];
- // }
- // [popupView dismissWithStyle:YMDismissStyleSmoothToBottom duration:2.0];
- // };
- [popupView pop];
- }
- - (RACSubject *)addAlbumSubject{
- if (!_addAlbumSubject) {
- _addAlbumSubject = [RACSubject subject];
- }
- return _addAlbumSubject;
- }
- - (RACSubject *)deleteAlbumSubject{
- if (!_deleteAlbumSubject) {
- _deleteAlbumSubject = [RACSubject subject];
- }
- return _deleteAlbumSubject;
- }
- - (RACSubject *)refreshAlbumSortSubject{
- if (!_refreshAlbumSortSubject) {
- _refreshAlbumSortSubject = [RACSubject subject];
- }
- return _refreshAlbumSortSubject;
- }
- - (RACSubject *)editProfileOperationSubject{
- if (!_editProfileOperationSubject) {
- _editProfileOperationSubject = [RACSubject subject];
- }
- return _editProfileOperationSubject;
- }
- - (NSMutableArray *)selectedAssets{
- if (!_selectedAssets) {
- _selectedAssets = [NSMutableArray array];
- }
- return _selectedAssets;
- }
- @end
|