// // MSYMineinfoEditVC.m // AliyunOSSiOS // // Created by admin on 2022/3/1. // #import "MSYMineinfoEditVC.h" #import "MSYMineInfoProgressCell.h" #import "YOUPAIMineInfoHeadCell.h" #import "YOUPAIMineNickNameCell.h" #import "YOUPAIMineInfoPhotoCell.h" #import "LZAlertWindow.h" #import "YOUPAIMineLabelEditVC.h" #import "YOUPAILCUpdateNickVC.h" #import "YOUPAILZBigCastAudioSetVC.h" #import "YOUPAILCUpdateCityVC.h" #import "YOUPAILZUpdateSignVC.h" #import "UIViewController+YOUPAIUPImage.h" #import "UIViewController+TFPresent.h" #import "UIViewController+YOUPAIYBImageBrowser.h" #import "UIViewController+TFPresent.h" #import "YOUPAIMineInfoScanImageCell.h" #import "YYKit.h" typedef enum MINEINFOEDIT_TYPE { MINEINFOEDIT_PROGRESS=0, // 进度 MINEINFOEDIT_HEAD=1, // 头像 MINEINFOEDIT_NICKNAME = 2, // 昵称 MINEINFOEDIT_PHOTO, // 相册 MINEINFOEDIT_VIDEO, // 视频 MINEINFOEDIT_VOICE, // 声音 MINEINFOEDIT_BRIIRTHDAY, // 生日 MINEINFOEDIT_ADDRESS, // 地址 MINEINFOEDIT_HEIGHT,// 身高 MINEINFOEDIT_WEIGHT,// 体重 MINEINFOEDIT_PROFESSINON, // 职业 // MINEINFOEDIT_INCOME, // 收入 // MINEINFOEDIT_EDUCATION, // 学历 // MINEINFOEDIT_MARITAL, // 婚姻 MINEINFOEDIT_INTRODUCE, // 自我介绍 MINEINFOEDIT_LABEL, // 标签 } MINEINFOEDIT_TYPE; @interface MSYMineinfoEditVC () @property(strong, nonatomic) UIBarButtonItem *rightItem; /** // 头像认证结果 1 认证成功 可以提交 2 人工审核 提交接口无需提交 */ @property(assign, nonatomic) NSInteger youpaipCompareAvatar; @property(strong, nonatomic) NSDictionary* selectData; @end @implementation MSYMineinfoEditVC -(UITableView *)tableView{ if (_tableView == nil){ _tableView = [UITableView new]; _tableView.dataSource = self; _tableView.delegate = self; [_tableView registerClass:[UITableViewCell class] forCellReuseIdentifier:@"cell"]; [_tableView setSeparatorStyle:UITableViewCellSeparatorStyleNone]; [_tableView registerClass:[MSYMineInfoProgressCell class] forCellReuseIdentifier:@"MSYMineInfoProgressCell"]; [_tableView registerClass:[YOUPAIMineInfoHeadCell class] forCellReuseIdentifier:@"YOUPAIMineInfoHeadCell"]; [_tableView registerClass:[YOUPAIMineNickNameCell class] forCellReuseIdentifier:@"YOUPAIMineNickNameCell"]; [_tableView registerClass:[YOUPAIMineVoiceCell class] forCellReuseIdentifier:@"YOUPAIMineVoiceCell"]; [_tableView registerClass:[YOUPAIMineBirthdayCell class] forCellReuseIdentifier:@"YOUPAIMineBirthdayCell"]; [_tableView registerClass:[YOUPAIMineAddressCell class] forCellReuseIdentifier:@"YOUPAIMineAddressCell"]; [_tableView registerClass:[YOUPAIMineHeightCell class] forCellReuseIdentifier:@"YOUPAIMineHeightCell"]; [_tableView registerClass:[YOUPAIMineProfessionCell class] forCellReuseIdentifier:@"YOUPAIMineProfessionCell"]; [_tableView registerClass:[YOUPAIMineIncomeCell class] forCellReuseIdentifier:@"YOUPAIMineIncomeCell"]; [_tableView registerClass:[YOUPAIMineEducationCell class] forCellReuseIdentifier:@"YOUPAIMineEducationCell"]; [_tableView registerClass:[YOUPAIMineMaritalStatusCell class] forCellReuseIdentifier:@"YOUPAIMineMaritalStatusCell"]; [_tableView registerClass:[YOUPAIMineIntroduceCell class] forCellReuseIdentifier:@"YOUPAIMineIntroduceCell"]; [_tableView registerClass:[YOUPAIMineLabelCell class] forCellReuseIdentifier:@"YOUPAIMineLabelCell"]; [_tableView registerClass:[YOUPAIMineInfoPhotoCell class] forCellReuseIdentifier:@"YOUPAIMineInfoPhotoCell"]; [_tableView registerClass:[YOUPAIMineInfoVideoCell class] forCellReuseIdentifier:@"YOUPAIMineInfoVideoCell"]; } return _tableView; } -(UIBarButtonItem *)rightItem{ if (_rightItem == nil){ UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom]; [button addTarget:self action:@selector(youpaifAPIEditUserInfo) forControlEvents:UIControlEventTouchUpInside]; button.frame = CGRectMake(0, 0, 56, 24); [button setTitle:@"保存" forState:0]; [button setTitleColor:LZ7C69FEColor forState:0]; // [button setBackgroundColor:HexColorFromRGB(0xFF5CA2)]; button.titleLabel.font = LCFont14; button.layer.cornerRadius = 12; button.layer.masksToBounds = YES; [self.view addSubview:button]; // 设置rightBarButtonItem _rightItem = [[UIBarButtonItem alloc] initWithCustomView:button]; } return _rightItem; } - (void)viewDidLoad { [super viewDidLoad]; self.title = @"编辑资料"; self.navigationItem.rightBarButtonItem = self.rightItem; [self.view addSubview:self.tableView]; [self makelayout]; [self youpaifAPIloadUserInfo]; [self youpaifgetSelectData]; } - (void)viewWillAppear:(BOOL)animated { [super viewWillAppear:animated]; self.navigationController.navigationBar.hidden = NO; } -(void)makelayout{ [_tableView mas_makeConstraints:^(MASConstraintMaker *make) { make.top.mas_equalTo(NavBarHeight); make.bottom.mas_equalTo(0).offset(-SafeHeight); make.left.mas_equalTo(0); make.right.mas_equalTo(0); }]; } -(YOUPAIUesrInfoEditModel *)youpaipRequestData{ if (_youpaipRequestData == nil){ _youpaipRequestData = [YOUPAIUesrInfoEditModel new]; } return _youpaipRequestData; } @end // MARK: tablevie delegate @implementation MSYMineinfoEditVC (tableview) -(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{ return 1; } -(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{ return 16; } - (nonnull UITableViewCell *)tableView:(nonnull UITableView *)tableView cellForRowAtIndexPath:(nonnull NSIndexPath *)indexPath { if (indexPath.row == MINEINFOEDIT_PROGRESS) { MSYMineInfoProgressCell *cell = [tableView dequeueReusableCellWithIdentifier:@"MSYMineInfoProgressCell" forIndexPath:indexPath]; [cell.rightArrow setHidden:true]; CGFloat progress = [_youpaipRequestData youpaifProgress] ; cell.progressView.progress = progress; cell.progressLab.text = [NSString stringWithFormat:@"%0.1f%%",progress*100]; NSDictionary *task = self.youpaipshowModel.task; NSDictionary *headtask = task[@"over_task"]; BOOL isshow = ([[headtask objectForKey:@"is_show"] intValue] == 1); if (isshow && progress<1){ [cell.bubbleLab setHidden:NO]; cell.bubbleLab.text = headtask[@"des"]; }else{ [cell.bubbleLab setHidden:true]; } return cell; }else if (indexPath.row == MINEINFOEDIT_HEAD) { YOUPAIMineInfoHeadCell *cell = [tableView dequeueReusableCellWithIdentifier:@"YOUPAIMineInfoHeadCell" forIndexPath:indexPath]; [cell.rightArrow setHidden:false]; if (self.youpaipRequestData.youpaipavatar.length>0){ NSURL *url = [[LCTools getImageUrlWithAddress:self.youpaipRequestData.youpaipavatar] urlWithImageScale:60]; [cell.headImageView sd_setImageWithURL:url placeholderImage:[UIImage imageNamed:@""]]; } NSDictionary *task = self.youpaipshowModel.task; NSDictionary *headtask = task[@"avatar_task"]; BOOL isshow = ([[headtask objectForKey:@"is_show"] intValue] == 1); if (isshow){ [cell.bubbleLab setHidden:NO]; cell.bubbleLab.text = headtask[@"des"]; }else{ [cell.bubbleLab setHidden:YES]; } return cell; } else if (indexPath.row == MINEINFOEDIT_NICKNAME) { YOUPAIMineNickNameCell *cell = [tableView dequeueReusableCellWithIdentifier:@"YOUPAIMineNickNameCell" forIndexPath:indexPath]; [cell.rightArrow setHidden:false]; cell.vlaueLab.text = self.youpaipRequestData.youpaipnickname; cell.vlaueLab.textColor = LZ273145Color; return cell; } else if (indexPath.row == MINEINFOEDIT_PHOTO) { YOUPAIMineInfoPhotoCell *cell = [tableView dequeueReusableCellWithIdentifier:@"YOUPAIMineInfoPhotoCell" forIndexPath:indexPath]; [cell.rightArrow setHidden:true]; cell.delegate = (id)self; cell.youpaipimages = _youpaipRequestData.youpaipalbums; [cell.collectionView reloadData]; if (_youpaipRequestData.youpaipalbums.count>0){ [cell.bubbleLab setHidden:YES]; } cell.titleLab.text =[NSString stringWithFormat:@"展示照片(%zd/6)",_youpaipRequestData.youpaipalbums.count] ; NSDictionary *task = self.youpaipshowModel.task; NSDictionary *headtask = task[@"album_task"]; BOOL isshow = ([[headtask objectForKey:@"is_show"] intValue] == 1); if (isshow){ [cell.bubbleLab setHidden:NO]; cell.bubbleLab.text = headtask[@"des"]; }else{ [cell.bubbleLab setHidden:YES]; } return cell; } else if (indexPath.row == MINEINFOEDIT_VIDEO) { YOUPAIMineInfoVideoCell *cell = [tableView dequeueReusableCellWithIdentifier:@"YOUPAIMineInfoVideoCell" forIndexPath:indexPath]; [cell.rightArrow setHidden:true]; cell.delegate = (id)self; [cell.bubbleLab setHidden:true]; if (_youpaipRequestData.youpaipvideo.length>0){ NSURL *url = [LCTools getImageUrlWithAddress:_youpaipRequestData.youpaipvideo]; cell.youpaipImageView.image = [UIImage imageWithVideo:url]; cell.youpaipImageView.contentMode = UIViewContentModeScaleAspectFill; [cell.youpaipplayerImageView setHidden:false] ; }else{ cell.youpaipImageView.image = [UIImage imageNamed:@"icon_180_up_plus"]; [cell.youpaipplayerImageView setHidden:true] ; cell.youpaipImageView.contentMode = UIViewContentModeCenter; // 男的删掉,女的保留 if (self.youpaipshowModel.youpaipgender == 1){ NSDictionary *task = self.youpaipshowModel.task; NSDictionary *headtask = task[@"video_task"]; BOOL isshow = ([[headtask objectForKey:@"is_show"] intValue] == 1); if (isshow){ [cell.bubbleLab setHidden:NO]; cell.bubbleLab.text = headtask[@"des"]; }else{ [cell.bubbleLab setHidden:YES]; } } } return cell; } else if (indexPath.row == MINEINFOEDIT_VOICE) { // 声音展示 YOUPAIMineVoiceCell *cell = [tableView dequeueReusableCellWithIdentifier:@"YOUPAIMineVoiceCell" forIndexPath:indexPath]; [cell.rightArrow setHidden:false]; if ([self.youpaipRequestData.youpaipvoice length]>0){ cell.vlaueLab.text = @"重新录制"; cell.vlaueLab.textColor = LZ273145Color; }else{ cell.vlaueLab.text = @"去录制"; cell.vlaueLab.textColor = LZA3AABEColor; } return cell; } else if (indexPath.row == MINEINFOEDIT_BRIIRTHDAY) { // 生日 YOUPAIMineBirthdayCell *cell = [tableView dequeueReusableCellWithIdentifier:@"YOUPAIMineBirthdayCell" forIndexPath:indexPath]; [cell.rightArrow setHidden:false]; if (self.youpaipRequestData.youpaipbirthday.length>0){ cell.vlaueLab.text = self.youpaipRequestData.youpaipbirthday; cell.vlaueLab.textColor = LZ273145Color; }else{ cell.vlaueLab.textColor = LZA3AABEColor; } return cell; } else if (indexPath.row == MINEINFOEDIT_ADDRESS ) { // 所在地 YOUPAIMineAddressCell *cell = [tableView dequeueReusableCellWithIdentifier:@"YOUPAIMineAddressCell" forIndexPath:indexPath]; [cell.rightArrow setHidden:false]; cell.vlaueLab.text = self.youpaipRequestData.youpaipcityId; cell.vlaueLab.textColor = LZ273145Color; return cell; } else if (indexPath.row == MINEINFOEDIT_HEIGHT) { // 身高 YOUPAIMineHeightCell *cell = [tableView dequeueReusableCellWithIdentifier:@"YOUPAIMineHeightCell" forIndexPath:indexPath]; [cell.rightArrow setHidden:false]; cell.titleLab.text = @"身高"; if ([self.youpaipRequestData.youpaipheight intValue]>0){ cell.vlaueLab.text = self.youpaipRequestData.youpaipheight; cell.vlaueLab.textColor = LZ273145Color; }else{ cell.vlaueLab.text = @"去完善"; cell.vlaueLab.textColor = LZA3AABEColor; } return cell; } else if (indexPath.row == MINEINFOEDIT_WEIGHT) { // 体重 YOUPAIMineHeightCell *cell = [tableView dequeueReusableCellWithIdentifier:@"YOUPAIMineHeightCell" forIndexPath:indexPath]; [cell.rightArrow setHidden:false]; cell.titleLab.text = @"体重"; if ([self.youpaipRequestData.youpaipweight intValue]>0){ cell.vlaueLab.text = self.youpaipRequestData.youpaipweight; cell.vlaueLab.textColor = LZ273145Color; }else{ cell.vlaueLab.text = @"去完善"; cell.vlaueLab.textColor = LZA3AABEColor; } return cell; } else if (indexPath.row == MINEINFOEDIT_PROFESSINON) { // 职业 YOUPAIMineProfessionCell *cell = [tableView dequeueReusableCellWithIdentifier:@"YOUPAIMineProfessionCell" forIndexPath:indexPath]; [cell.rightArrow setHidden:false]; if ([self.youpaipRequestData.youpaipoccupation length]>0){ cell.vlaueLab.text = self.youpaipRequestData.youpaipoccupation; cell.vlaueLab.textColor = LZ273145Color; }else{ cell.vlaueLab.text = @"去完善"; cell.vlaueLab.textColor = LZA3AABEColor; } return cell; } // else if (indexPath.row == MINEINFOEDIT_INCOME ) { // 年收入 // YOUPAIMineIncomeCell *cell = [tableView dequeueReusableCellWithIdentifier:@"YOUPAIMineIncomeCell" forIndexPath:indexPath]; // [cell.rightArrow setHidden:false]; // if ([self.youpaipRequestData.youpaipannual_income length]>0){ // cell.vlaueLab.text = self.youpaipRequestData.youpaipannual_income; // cell.vlaueLab.textColor = LZ273145Color; // }else{ // cell.vlaueLab.text = @"去完善"; // cell.vlaueLab.textColor = LZA3AABEColor; // } // // return cell; // // } // else if (indexPath.row == MINEINFOEDIT_EDUCATION) { // 学历 // YOUPAIMineEducationCell *cell = [tableView dequeueReusableCellWithIdentifier:@"YOUPAIMineEducationCell" forIndexPath:indexPath]; // [cell.rightArrow setHidden:false]; // if ([self.youpaipRequestData.youpaipeducation length]>0){ // cell.vlaueLab.text = self.youpaipRequestData.youpaipeducation; // cell.vlaueLab.textColor = LZ273145Color; // }else{ // cell.vlaueLab.text = @"去完善"; // cell.vlaueLab.textColor = LZA3AABEColor; // } // return cell; // // } // else if (indexPath.row == MINEINFOEDIT_MARITAL) { // 婚姻状态 // YOUPAIMineMaritalStatusCell *cell = [tableView dequeueReusableCellWithIdentifier:@"YOUPAIMineMaritalStatusCell" forIndexPath:indexPath]; // [cell.rightArrow setHidden:false]; // if ([self.youpaipRequestData.youpaipis_marriage length]>0){ // cell.vlaueLab.text = self.youpaipRequestData.youpaipis_marriage; // cell.vlaueLab.textColor = LZ273145Color; // }else{ // cell.vlaueLab.text = @"去完善"; // cell.vlaueLab.textColor = LZA3AABEColor; // } // // return cell; // // } else if (indexPath.row == MINEINFOEDIT_INTRODUCE) { //自我介绍 YOUPAIMineIntroduceCell *cell = [tableView dequeueReusableCellWithIdentifier:@"YOUPAIMineIntroduceCell" forIndexPath:indexPath]; [cell.rightArrow setHidden:false]; if (_youpaipRequestData.youpaipsignature.length>0){ cell.vlaueLab.text = _youpaipRequestData.youpaipsignature; [cell.statusLab setHidden:true]; [cell.bubbleLab setHidden:true]; cell.vlaueLab.textColor = LZ273145Color; }else{ cell.vlaueLab.text = @"添加自我介绍,更容易获得别人的关注哦~"; [cell.statusLab setHidden:false]; cell.vlaueLab.textColor = LZA3AABEColor; } NSDictionary *task = self.youpaipshowModel.task; NSDictionary *headtask = task[@"sign_task"]; BOOL isshow = ([[headtask objectForKey:@"is_show"] intValue] == 1); if (isshow){ [cell.bubbleLab setHidden:NO]; cell.bubbleLab.text = headtask[@"des"]; }else{ [cell.bubbleLab setHidden:YES]; } return cell; } else if (indexPath.row == MINEINFOEDIT_LABEL) { //标签 YOUPAIMineLabelCell *cell = [tableView dequeueReusableCellWithIdentifier:@"YOUPAIMineLabelCell" forIndexPath:indexPath]; [cell.rightArrow setHidden:false]; if (self.youpaipRequestData.youpaiplabel.count>0){ cell.dataSouce = self.youpaipRequestData.youpaiplabel; [cell reloadData]; [cell.statusLab setHidden:true]; [cell.stackView setHidden:false]; [cell.vlaueLab setHidden:true]; }else{ [cell.vlaueLab setHidden:false]; [cell.stackView setHidden:true]; [cell.vlaueLab setHidden:false]; [cell.statusLab setHidden:false]; } return cell; } else{ UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell" forIndexPath:indexPath]; return cell; } } -(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{ if (indexPath.row == MINEINFOEDIT_PROGRESS){ return 95; }else if (indexPath.row == MINEINFOEDIT_PHOTO){ return YOUPAIMineInfoPhotoCell.cellheight; } else if (indexPath.row == MINEINFOEDIT_VIDEO){ return YOUPAIMineInfoVideoCell.cellheight; } else if (indexPath.row == MINEINFOEDIT_INTRODUCE){ return 77.5; } else if (indexPath.row == MINEINFOEDIT_LABEL){ return 77.5; } else{ return 54; } } - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{ if (indexPath.row == MINEINFOEDIT_PROGRESS){ } else if(indexPath.row ==MINEINFOEDIT_HEAD){ // 头像 [self youpaifSelectAvatar]; } else if(indexPath.row ==MINEINFOEDIT_NICKNAME){ // 昵称 YOUPAILCUpdateNickVC* nickVC = [[YOUPAILCUpdateNickVC alloc]init]; nickVC.youpaipnickName = [LCSaveModel getUserModel].youpaipuserinfo.youpaipnickname; @weakify(self); nickVC.youpaipblock = ^(NSString *nickname) { @strongify(self); self.youpaipRequestData.youpaipnickname = nickname; [self.tableView reloadData]; }; [self.navigationController pushViewController:nickVC animated:YES]; } else if(indexPath.row ==MINEINFOEDIT_VOICE){ // 声音展示 YOUPAILZBigCastAudioSetVC *vc = [[YOUPAILZBigCastAudioSetVC alloc] init]; @weakify(self); [vc setSuccessBlock:^(NSString * _Nonnull mp3, NSInteger mp3_second) { @strongify(self); self.youpaipRequestData.youpaipvoice = mp3; self.youpaipRequestData.youpaipvoice_time = mp3_second; [self.tableView reloadData]; }]; [self.navigationController pushViewController:vc animated:YES]; } else if(indexPath.row ==MINEINFOEDIT_BRIIRTHDAY){ // 生日 [self youpaifSelectBirthday]; } else if(indexPath.row ==MINEINFOEDIT_ADDRESS){ // 所在地 YOUPAILCUpdateCityVC* cityVC = [[YOUPAILCUpdateCityVC alloc]init]; cityVC.youpaipcityName = [LCSaveModel getUserModel].youpaipuserinfo.youpaipcity; @weakify(self); cityVC.youpaipblock = ^(NSString *cityName) { @strongify(self); self.youpaipRequestData.youpaipcityId = cityName; [self.tableView reloadData]; }; [self.navigationController pushViewController:cityVC animated:YES]; } else if(indexPath.row ==MINEINFOEDIT_HEIGHT){ // 身高 YOUPAIPickerSelectValueVC *vc = [YOUPAIPickerSelectValueVC new]; vc.dataSouce = [self.selectData objectForKey:@"height"]; @weakify(self); [vc setDidFinishSelectBlock:^(NSString * _Nonnull value) { @strongify(self); self.youpaipRequestData.youpaipheight = value; [self.tableView reloadData]; }]; [self TFPresentVC:vc completion:nil]; } else if(indexPath.row == MINEINFOEDIT_WEIGHT){ // 身高 YOUPAIPickerSelectValueVC *vc = [YOUPAIPickerSelectValueVC new]; vc.dataSouce = [self.selectData objectForKey:@"weight"]; @weakify(self); [vc setDidFinishSelectBlock:^(NSString * _Nonnull value) { @strongify(self); self.youpaipRequestData.youpaipweight = value; [self.tableView reloadData]; }]; [self TFPresentVC:vc completion:nil]; } else if(indexPath.row ==MINEINFOEDIT_PROFESSINON){ // 职业 [self youpaifSelectOccupation]; } // else if(indexPath.row ==MINEINFOEDIT_INCOME){ // 年收入 // // YOUPAIPickerSelectValueVC *vc = [YOUPAIPickerSelectValueVC new]; // vc.dataSouce = [_selectData objectForKey:@"annual_income"]; // @weakify(self); // [vc setDidFinishSelectBlock:^(NSString * _Nonnull value) { // @strongify(self); // self.youpaipRequestData.youpaipannual_income = value; // [self.tableView reloadData]; // }]; // [self TFPresentVC:vc completion:nil]; // // } // else if(indexPath.row ==MINEINFOEDIT_EDUCATION){ // 学历 // YOUPAIPickerSelectValueVC *vc = [YOUPAIPickerSelectValueVC new]; // vc.dataSouce = [_selectData objectForKey:@"education"]; // @weakify(self); // [vc setDidFinishSelectBlock:^(NSString * _Nonnull value) { // @strongify(self); // self.youpaipRequestData.youpaipeducation = value; // [self.tableView reloadData]; // }]; // [self TFPresentVC:vc completion:nil]; // // // } // else if(indexPath.row ==MINEINFOEDIT_MARITAL){ // 婚姻 // YOUPAIPickerSelectValueVC *vc = [YOUPAIPickerSelectValueVC new]; // vc.dataSouce = [_selectData objectForKey:@"is_marriage"]; // @weakify(self); // [vc setDidFinishSelectBlock:^(NSString * _Nonnull value) { // @strongify(self); // self.youpaipRequestData.youpaipis_marriage = value; // [self.tableView reloadData]; // }]; // [self TFPresentVC:vc completion:nil]; // // } else if(indexPath.row ==MINEINFOEDIT_INTRODUCE){ // 自我介绍 YOUPAILZUpdateSignVC* signVC = [[YOUPAILZUpdateSignVC alloc]init]; signVC.youpaipsign = self.youpaipRequestData.youpaipsignature; signVC.youpaipblock = ^(NSString *sign) { self.youpaipRequestData.youpaipsignature= sign; [self.tableView reloadData]; }; [self.navigationController pushViewController:signVC animated:YES]; } else if(indexPath.row ==MINEINFOEDIT_LABEL){ // 个人标签 YOUPAIMineLabelEditVC *vc = [YOUPAIMineLabelEditVC new]; [vc setDidFinishSaveBlock:^(NSArray * _Nonnull value) { self.youpaipRequestData.youpaiplabel = value; [self.tableView reloadData]; }]; [self.navigationController pushViewController:vc animated:YES]; }else{ } } @end @implementation MSYMineinfoEditVC(MineInfoPhoto) -(void)youpaifupdateImage:(NSInteger)row{ @weakify(self); [self youpaifUploadImgType:@"album" configTZ:nil uploadBlock:nil fineshBlock:^(NSArray * _Nonnull imgurls, NSError * _Nonnull error) { @strongify(self); if (row < self.youpaipRequestData.youpaipalbums.count){ // 替换 [self.youpaipRequestData.youpaipalbums replaceObjectAtIndex:row withObject:imgurls.firstObject]; }else{ // 新增 [self.youpaipRequestData.youpaipalbums addObjectsFromArray:imgurls]; } [self.tableView reloadData]; }]; } // MARK: YOUPAIMineInfoPhotoCellDelegate -(void)mineInfoPhotoCellhandle:(YOUPAIMineInfoPhotoCell *)cell indexpath:(NSIndexPath *)indexPath{ if (indexPath.row < self.youpaipRequestData.youpaipalbums.count){ [self youapifScanAlbums:indexPath.row]; }else{ [self youpaifupdateImage:indexPath.row]; } } @end // MARK: 头像 @implementation MSYMineinfoEditVC(avatar) -(void)youpaifSelectAvatar{ // if (![LCTools isRealNameAuthentication]){ // return; // } @weakify(self); [self youpaifUploadImgType:@"album" configTZ:nil uploadBlock:nil fineshBlock:^(NSArray * _Nonnull imgurls, NSError * _Nonnull error) { @strongify(self); [self youpaifcompareFacesAvatar:imgurls.firstObject]; }]; } // 头像验证 -(void)youpaifcompareFacesAvatar:(NSString*)url{ @weakify(self); self.youpaipCompareAvatar = -1; // 如果是男用户,无需比对 if (self.youpaipshowModel.youpaipgender != 1){ self.youpaipRequestData.youpaipavatar = url; [self.tableView reloadData]; return; } [LCHttpHelper requestWithURLString:api_compareFacesAvatar parameters:@{@"avatar":url} needToken:YES type:HttpRequestTypePost success:^(id responseObject) { @strongify(self); NSDictionary* dict = (NSDictionary*)responseObject; NSInteger code = [[dict objectForKey:@"code"] integerValue]; NSString* msg = [dict objectForKey:@"message"]; self.youpaipCompareAvatar = code; switch (code) { case 0: // 认证通过 self.youpaipRequestData.youpaipavatar = url; [self.tableView reloadData]; break; case 1006: // 识别失败 self.youpaipRequestData.youpaipavatar = url; [self.tableView reloadData]; [self youpaifAlertCompareFacesAvatar]; break; case 1007: // 请先认证 [self youpaifAlertGoCompareAvatar]; break; default: [ZCHUDHelper showTitle:msg]; break; } } failure:^(NSError *error) { [ZCHUDHelper showTitle:@"头像识别失败"]; }]; } // 去认证 提示框 -(void)youpaifAlertGoCompareAvatar{ @weakify(self); LZAlertAction *cancelAction = [LZAlertAction actionWithTitle:@"取消" handler:^(LZAlertAction *action) { @strongify(self); self.youpaipCompareAvatar = -1;// self.youpaipRequestData.youpaipavatar = self.youpaipshowModel.youpaipavatar; [self.tableView reloadData]; }]; cancelAction.cornerRadius = 24; cancelAction.bgColor = LZF5F4F7Color; cancelAction.color = LZ273145Color; LZAlertAction *confimAction = [LZAlertAction actionWithTitle:@"去认证" handler:^(LZAlertAction *action) { @strongify(self); // 将头像重置到原来url self.youpaipRequestData.youpaipavatar = self.youpaipshowModel.youpaipavatar; [self.tableView reloadData]; [LCTools youpaifrealNameAuthentication]; }]; confimAction.cornerRadius = 24.0f; confimAction.bgColor = [UIColor colorWithPatternImage:[LCTools ColorImage:CGSizeMake((KScreenWidth - 108.0f)/2, 48.0f) FromColors:@[LZBFB6FFColor,LZ7C69FEColor] ByGradientType:GradientLeftToRight]]; LZAlertWindow *alert = [LZAlertWindow alertWithTitle:nil content:@"为保证头像真实性,需要认证后才可以上传头像(认证还有新手奖励哦)" action:@[cancelAction,confimAction]]; alert.contentTextAlignment = NSTextAlignmentCenter; [self TFPresentVC:alert completion:^{}]; } // 人工认证提示框 -(void)youpaifAlertCompareFacesAvatar{ @weakify(self); LZAlertAction *cancelAction = [LZAlertAction actionWithTitle:@"取消" handler:^(LZAlertAction *action) { @strongify(self); self.youpaipCompareAvatar = -1;// self.youpaipRequestData.youpaipavatar = self.youpaipshowModel.youpaipavatar; [self.tableView reloadData]; }]; cancelAction.cornerRadius = 24; cancelAction.bgColor = LZF5F4F7Color; cancelAction.color = LZ273145Color; LZAlertAction *confimAction = [LZAlertAction actionWithTitle:@"重新上传" handler:^(LZAlertAction *action) { @strongify(self); // 将头像重置到原来url self.youpaipRequestData.youpaipavatar = self.youpaipshowModel.youpaipavatar; [self.tableView reloadData]; [self youpaifSelectAvatar]; }]; confimAction.cornerRadius = 24.0f; confimAction.bgColor = [UIColor colorWithPatternImage:[LCTools ColorImage:CGSizeMake((KScreenWidth - 130.0f), 48.0f) FromColors:@[LZBFB6FFColor,LZ7C69FEColor] ByGradientType:GradientLeftToRight]]; LZAlertAction *compare = [LZAlertAction actionWithTitle:@"提交人工审核" handler:^(LZAlertAction *action) { self.youpaipCompareAvatar = 2;// 人工审核 }]; compare.cornerRadius = 24.0f; compare.bgColor = [UIColor colorWithPatternImage:[LCTools ColorImage:CGSizeMake((KScreenWidth - 130.0f), 48.0f) FromColors:@[LZBFB6FFColor,LZ7C69FEColor] ByGradientType:GradientLeftToRight]]; LZAlertWindow *alert = [LZAlertWindow alertWithTitle:nil content:@"上次的头像与你的认证面容对比不通过,你可以重新上传或提交人工审核" action:@[compare,confimAction,cancelAction]]; alert.contentTextAlignment = NSTextAlignmentCenter; [self TFPresentVC:alert completion:^{}]; } @end // MARK: 生日 @implementation MSYMineinfoEditVC(Birthday) -(void)youpaifSelectBirthday{ YOUPAISelectBirthdayPickVC *vc = [YOUPAISelectBirthdayPickVC new]; vc.delegate = self; [self TFPresentVC:vc completion:nil]; } - (void)didSelectBirthday:(nonnull YOUPAISelectBirthdayPickVC *)vc birthday:(nonnull NSDateComponents *)birthday { NSInteger year=[birthday year]; NSInteger month=[birthday month]; NSInteger day=[birthday day]; NSString *birthdayStr = [NSString stringWithFormat:@"%ld-%ld-%ld",year,month,day]; _youpaipRequestData.youpaipbirthday = birthdayStr; [_tableView reloadData]; } @end // MARK: 年收入 @implementation MSYMineinfoEditVC(incom) @end // MARK: 职业 @implementation MSYMineinfoEditVC(Occupation) -(void)youpaifSelectOccupation{ YOUPAISelectOccupationVC *vc = [YOUPAISelectOccupationVC new]; vc.dataSouce = [_selectData objectForKey:@"occupation"]; vc.delegate = self; [self TFPresentVC:vc completion:nil]; } - (void)didSelectOccupation:(YOUPAISelectOccupationVC *)vc occupation:(NSString *)occupation{ _youpaipRequestData.youpaipoccupation = occupation; [_tableView reloadData]; } @end //MARK: 视频 @implementation MSYMineinfoEditVC(Video) -(void)mineInfoVideoCellhandle:(YOUPAIMineInfoVideoCell *)cell{ if (_youpaipRequestData.youpaipvideo.length>0){ [self youapifScanVideo]; return; }else{ [self youpaifselectVideo]; } } -(void)youpaifselectVideo{ @weakify(self); [self youpaifTZSelectVideo:nil didSelect:^(UIImage * _Nullable coverImage, AVURLAsset * _Nullable asset, NSError * _Nullable error) { @strongify(self); if(error){ [ZCHUDHelper showTitle:error.localizedDescription]; return; } // 视频时长 CMTime time = [asset duration]; int seconds = ceil(time.value/time.timescale); seconds = MIN(seconds, 15); [ZCHUDHelper showWithStatus:@"正在裁剪..."]; [self youpaifCutVideo:asset start:0 end:seconds completion:^(NSURL * outputURL, Float64 videoDuration, NSError * error) { @strongify(self); if(error){ [ZCHUDHelper showTitle:error.localizedDescription]; return; } [ZCHUDHelper showTitle:@"裁剪完成"]; [self updateVideo:outputURL coverImage:coverImage]; }]; }]; } -(void)updateVideo:(NSURL*)path coverImage:(UIImage*) coverImage{ NSString *urlstr = path.resourceSpecifier; [ZCHUDHelper showWithStatus:@"正在上传..."]; @weakify(self); [LCCommonHttp uploadWithVideoPath:urlstr Type:@"album" successBlock:^(NSString *ossFilePath) { @strongify(self); self.youpaipRequestData.youpaipvideo = ossFilePath; [ZCHUDHelper showTitle:@"上传完成"]; [self.tableView reloadData]; }]; } @end // 查看视频/图片 @implementation MSYMineinfoEditVC(ScanImagevideo) -(void)youapifScanAlbums:(NSInteger)index{ YBImageBrowser *browser = [YBImageBrowser new]; browser.shouldHideStatusBar = false; browser.tag = 0; browser.dataSource = self; browser.currentPage = index; [browser.defaultToolViewHandler.topView.operationButton setHidden:false]; [browser.defaultToolViewHandler.topView.operationButton setTitle:@"删除" forState:UIControlStateNormal]; [browser.defaultToolViewHandler.topView.operationButton setImage:NULL forState:UIControlStateNormal]; @weakify(self); [browser.defaultToolViewHandler.topView setClickOperation:^(YBIBTopViewOperationType type) { @strongify(self); NSInteger row = browser.currentPage; [self.youpaipRequestData.youpaipalbums removeObjectAtIndex:row]; [self.tableView reloadData]; [browser hide]; }]; [browser show]; } -(void)youapifScanVideo{ YBImageBrowser *browser = [YBImageBrowser new]; browser.tag = 1; browser.dataSource = self; browser.currentPage = 0; [browser.defaultToolViewHandler.topView.operationButton setHidden:false]; [browser show]; [browser.defaultToolViewHandler.topView.operationButton setHidden:false]; [browser.defaultToolViewHandler.topView.operationButton setTitle:@"删除" forState:UIControlStateNormal]; [browser.defaultToolViewHandler.topView.operationButton setImage:NULL forState:UIControlStateNormal]; @weakify(self); [browser.defaultToolViewHandler.topView setClickOperation:^(YBIBTopViewOperationType type) { @strongify(self); self.youpaipRequestData.youpaipvideo = @""; [self.tableView reloadData]; [browser hide]; }]; } // 实现 协议方法配置数据源 - (NSInteger)yb_numberOfCellsInImageBrowser:(YBImageBrowser *)imageBrowser{ NSInteger tag = imageBrowser.tag; if (tag == 0){ return self.youpaipRequestData.youpaipalbums.count; }else{ return 1; } } - (id)yb_imageBrowser:(YBImageBrowser *)imageBrowser dataForCellAtIndex:(NSInteger)index{ NSInteger tag = imageBrowser.tag; if (tag == 0){ YOUPAIMineInfoScanImageData *data = [YOUPAIMineInfoScanImageData new]; NSURL *url = [LCTools getImageUrlWithAddress:self.youpaipRequestData.youpaipalbums[index]]; data.imageURL = url; // data.sourceObject = ...; return data; }else{ YBIBVideoData *data = [YBIBVideoData new]; data.videoURL = [LCTools getImageUrlWithAddress:self.youpaipRequestData.youpaipvideo]; return data; } } @end @implementation MSYMineinfoEditVC (API) -(void)youpaifreloadRequestData{ if (self.youpaipshowModel == nil){ return; } // birthday:生日 _youpaipRequestData.youpaipbirthday = _youpaipshowModel.youpaipBasicInfoDetail.youpaipbirthday; // height:升高 _youpaipRequestData.youpaipheight = _youpaipshowModel.youpaipBasicInfoDetail.youpaipheight; // weight:体重 _youpaipRequestData.youpaipweight = _youpaipshowModel.youpaipBasicInfoDetail.youpaipweight; // occupation:职业 _youpaipRequestData.youpaipoccupation = _youpaipshowModel.youpaipBasicInfoDetail.youpaipoccupation; // cityId:城市id _youpaipRequestData.youpaipcityId = _youpaipshowModel.youpaipBasicInfoDetail.youpaipcity; // annual_income:收入 _youpaipRequestData.youpaipannual_income = _youpaipshowModel.youpaipBasicInfoDetail.youpaipannual_income; // education:教育 _youpaipRequestData.youpaipeducation = _youpaipshowModel.youpaipBasicInfoDetail.youpaipeducation; // is_marriage:婚姻状态 _youpaipRequestData.youpaipis_marriage = _youpaipshowModel.youpaipBasicInfoDetail.youpaipis_marriage; // label:标签 _youpaipRequestData.youpaiplabel = _youpaipshowModel.youpaiplabel_list; // avatar:头像 _youpaipRequestData.youpaipavatar = _youpaipshowModel.youpaipavatar; // nickname:昵称 _youpaipRequestData.youpaipnickname = _youpaipshowModel.youpaipnickname; // albums:视频 _youpaipRequestData.youpaipvideo = _youpaipshowModel.youpaipvideo; // albums:相册 [_youpaipRequestData.youpaipalbums removeAllObjects]; for (YOUPAIAlbumModel *item in _youpaipshowModel.youpaipalbums_list) { if (item.youpaipis_video){ }else{ [_youpaipRequestData.youpaipalbums addObject:item.youpaipurl]; } } // sign 签名 if ([_youpaipshowModel.youpaipsign isEqualToString:@"这个人很懒,什么都没有留下…"]){ _youpaipRequestData.youpaipsignature = @""; }else{ _youpaipRequestData.youpaipsignature = _youpaipshowModel.youpaipsign; } // voice 语音 _youpaipRequestData.youpaipvoice = _youpaipshowModel.youpaipvoice.youpaipvoice; // voice_time:语音时长 _youpaipRequestData.youpaipvoice_time = _youpaipshowModel.youpaipvoice.youpaipvoice_time; // 视频 // _youpaipRequestData.youpaipvideo = _youpaipshowModel.youpaipvideo_status; [self.tableView reloadData]; } -(void)youpaifAPIloadUserInfo{ NSDictionary *params = @{ @"user_id":[LCSaveModel getUserModel].youpaipuserinfo.youpaipuser_id }; @weakify(self); [self.tableView setHidden:true]; [LCHttpHelper requestWithURLString:GetUserInfo parameters:params needToken:YES type:(HttpRequestTypePost) success:^(id responseObject) { @strongify(self); [self.tableView setHidden:false]; NSDictionary* dict = (NSDictionary*)responseObject; NSInteger code = [[dict objectForKey:@"code"] integerValue]; if (code==0) {//成功 self.youpaipshowModel = [YOUPAILCUserShowModel mj_objectWithKeyValues:[dict objectForKey:@"data"]]; [self youpaifreloadRequestData]; } } failure:^(NSError *error) { [self.view setAlpha:1]; [ZCHUDHelper showTitle:error.localizedDescription]; }]; } -(void)youpaifAPIEditUserInfo{ NSMutableDictionary *params = [[NSMutableDictionary alloc] initWithDictionary: @{}]; // 如果已经认证通过,无需提交头像 if (self.youpaipCompareAvatar == 0 ){ [params removeObjectForKey:@"avatar"]; } // 生日 if (![_youpaipshowModel.youpaipBasicInfoDetail.youpaipbirthday isEqualToString:_youpaipRequestData.youpaipbirthday]){ params[@"birthday"] = _youpaipRequestData.youpaipbirthday; } // 身高 if (![_youpaipshowModel.youpaipBasicInfoDetail.youpaipheight isEqualToString:_youpaipRequestData.youpaipheight]){ params[@"height"] = _youpaipRequestData.youpaipheight; } // 体重 if (![_youpaipshowModel.youpaipBasicInfoDetail.youpaipweight isEqualToString:_youpaipRequestData.youpaipweight]){ params[@"weight"] = _youpaipRequestData.youpaipweight; } // 城市 if (![_youpaipshowModel.youpaipBasicInfoDetail.youpaipcity isEqualToString:_youpaipRequestData.youpaipcityId]){ params[@"cityId"] = _youpaipRequestData.youpaipcityId; } // 职业 if (![_youpaipshowModel.youpaipBasicInfoDetail.youpaipoccupation isEqualToString:_youpaipRequestData.youpaipoccupation]){ params[@"occupation"] = _youpaipRequestData.youpaipoccupation; } // 收入 if (![_youpaipshowModel.youpaipBasicInfoDetail.youpaipannual_income isEqualToString:_youpaipRequestData.youpaipannual_income]){ params[@"annual_income"] = _youpaipRequestData.youpaipannual_income; } // 学历 if (![ _youpaipshowModel.youpaipBasicInfoDetail.youpaipeducation isEqualToString:_youpaipRequestData.youpaipeducation]){ params[@"education"] = _youpaipRequestData.youpaipeducation; } // 婚姻 if (![_youpaipshowModel.youpaipBasicInfoDetail.youpaipis_marriage isEqualToString:_youpaipRequestData.youpaipis_marriage]){ params[@"is_marriage"] = _youpaipRequestData.youpaipis_marriage; } // 标签 NSMutableArray *names = [NSMutableArray new]; for (YOUPAIZYLabelModel *item in _youpaipRequestData.youpaiplabel) { [names addObject:item.youpaiptag_id]; } NSString *newname = [names componentsJoinedByString:@","]; NSMutableArray *names2 = [NSMutableArray new]; for (YOUPAIZYLabelModel *item in _youpaipshowModel.youpaiplabel_list) { [names2 addObject:item.youpaiptag_id]; } NSString *oldnames = [names2 componentsJoinedByString:@","]; if (![newname isEqualToString:oldnames]){ params[@"label"] = newname; } // 头像 if (![_youpaipshowModel.youpaipavatar isEqualToString:_youpaipRequestData.youpaipavatar]){ params[@"avatar"] = _youpaipRequestData.youpaipavatar; } // 昵称 if (![_youpaipshowModel.youpaipnickname isEqualToString:_youpaipRequestData.youpaipnickname]){ params[@"nickname"] = _youpaipRequestData.youpaipnickname; } // 签名 if (![_youpaipshowModel.youpaipsign isEqualToString:_youpaipRequestData.youpaipsignature] && ![_youpaipRequestData.youpaipsignature isEqualToString:@""]){ params[@"signature"] = _youpaipRequestData.youpaipsignature; } // 语音 if (![_youpaipshowModel.youpaipvoice.youpaipvoice isEqualToString:_youpaipRequestData.youpaipvoice] && _youpaipRequestData.youpaipvoice != nil){ params[@"voice"] = _youpaipRequestData.youpaipvoice; params[@"voice_time"] = @([_youpaipRequestData youpaipvoice_time]); } // 视频 if (![_youpaipshowModel.youpaipvideo isEqualToString:_youpaipRequestData.youpaipvideo]){ params[@"video"] = _youpaipRequestData.youpaipvideo; } // 相册 NSString *newal = [_youpaipRequestData.youpaipalbums componentsJoinedByString:@","]; NSMutableArray *olds = [NSMutableArray new]; for (YOUPAIAlbumModel *item in _youpaipshowModel.youpaipalbums_list) { if (item.youpaipis_video){ }else{ [olds addObject:item.youpaipurl]; } } NSString *oldalbums = [olds componentsJoinedByString:@","]; if (![newal isEqualToString:oldalbums]){ params[@"albums"] = newal; } @weakify(self); [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 showTitle:@"提交成功"]; [self.navigationController popViewControllerAnimated:false]; } } failure:^(NSError *error) { [ZCHUDHelper showTitle:error.localizedDescription]; }]; } -(void)youpaifgetSelectData{ @weakify(self); NSDictionary *params = @{}; [LCHttpHelper requestWithURLString:api_getSelectData parameters:params needToken:YES type:(HttpRequestTypePost) success:^(id responseObject) { @strongify(self); [self.view setAlpha:1]; NSDictionary* dict = (NSDictionary*)responseObject; NSInteger code = [[dict objectForKey:@"code"] integerValue]; if (code==0) {//成功 self.selectData = [dict objectForKey:@"data"] ; } } failure:^(NSError *error) { [ZCHUDHelper showTitle:error.localizedDescription]; }]; } @end