// // MyInfoVC.m // smartRhino // // Created by armin on 2019/11/1. // Copyright © 2019 tederen. All rights reserved. // #import "MyInfoVC.h" #import "MyInfoCell.h" #import "ShowPhotoCameraAlertView.h" #import "EditUserNickVC.h" #import "ShowGenderAlertView.h" #import "EditMySignOrBriefVC.h" #import "EditPhoneOrEmailVC.h" #import "H5ViewController.h" #import "H6ViewController.h" #import "MyUserIconVC.h" #import "MyQRCodeVC.h" #import "NoteBookShareVC.h" #import "ShareListVC.h" #import "MyTDGroupViewController.h" #import "MoveViewController.h" @interface MyInfoVC () @property (strong,nonatomic) IBOutlet UITableView *tableView; @property (strong,nonatomic) UIImageView *showUserTestUserImg; @property (strong,nonatomic) UILabel *showUserGenderLabel; @property (strong,nonatomic) MyQRCodeVC *qrVC; @property (strong,nonatomic) NoteBookShareVC *noteBookShareVC; @property (strong,nonatomic) UIImage *shareImage; @end @implementation MyInfoVC +(MyInfoVC *)initMyInfoVC{ MyInfoVC *controller = [StoryboardManager.shared.myCenter instantiateViewControllerWithIdentifier:@"MyInfoVC"]; return controller; } - (void)viewDidLoad { [super viewDidLoad]; self.fd_prefersNavigationBarHidden = YES; self.view.backgroundColor = RGB(238, 238, 238); self.tableView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever; self.tableView.delegate = self; self.tableView.dataSource = self; self.tableView.backgroundColor = [UIColor clearColor]; self.tableView.estimatedRowHeight = 0; self.tableView.estimatedSectionHeaderHeight = 0; self.tableView.estimatedSectionFooterHeight = 0; [self.view addSubview:self.qrVC.view]; [self.view addSubview:self.noteBookShareVC.view]; } - (void)viewWillAppear:(BOOL)animated{ [super viewWillAppear:animated]; [self.tableView reloadData]; } - (void)viewDidAppear:(BOOL)animated{ [super viewDidAppear:animated]; [self.tableView reloadData]; } - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{ return 3; } - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{ switch (section) { case 0:{ return 3; }break; case 1:{ return 3; }break; case 2:{ return 3; }break; default:break; } return 0; } - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{ switch (indexPath.section) { case 0:{ return [MyInfoCell configCell0Height]; }break; case 1:{ return [MyInfoCell configCell1Height]; }break; case 2:{ return [MyInfoCell configCell1Height]; }break; default:break; } return 0; } - (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{ UIView *headerView = [[UIView alloc]init]; [headerView setBackgroundColor:RGBA(238, 238, 238, 1)]; return headerView; } - (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section{ UIView *headerView = [[UIView alloc]init]; [headerView setBackgroundColor:RGBA(238, 238, 238, 1)]; return headerView; } - (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{ return 0; } - (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section{ if(section == 0 || section == 1){ return 10; } return 0; } - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{ WS(weakSelf); switch (indexPath.section) { case 0:{ switch (indexPath.row) { case 0:{ MyInfoCell *cell = [MyInfoCell configCell0:tableView indexPath:indexPath]; cell.cell0TitleLabel.text = @"头像"; cell.cell0UserImgView.hidden = NO; [cell.cell0UserImgView sd_setImageWithURL:[NSURL URLWithString:[AppUserModel sharedAppUserModel].AvatarUrl]]; // UITapGestureRecognizer * tap = [[UITapGestureRecognizer alloc] initWithActionBlock:^(id _Nonnull sender) { // MyUserIconVC * vc = [MyUserIconVC initMyUserIconVC]; // [weakSelf.navigationController pushViewController:vc animated:YES]; // }]; // [cell.cell0UserImgView addGestureRecognizer:tap]; // cell.cell0UserImgView.userInteractionEnabled = YES; self.showUserTestUserImg = cell.cell0UserImgView; return cell; }break; case 1:{ MyInfoCell *cell = [MyInfoCell configCell1:tableView indexPath:indexPath]; cell.cell1TitleLabel.text = @"姓名"; cell.cell1ValueLabel.text = ISEmptyString([AppUserModel sharedAppUserModel].Name) ? @"": [self showStringLength:[AppUserModel sharedAppUserModel].Name]; cell.cell1ValueLabel.textColor = UIColorHex(#3D95ED); return cell; }break; case 2:{ MyInfoCell *cell = [MyInfoCell configCell0:tableView indexPath:indexPath]; cell.cell0TitleLabel.text = @"性别"; cell.cell0ValueLabel.text = [[AppUserModel sharedAppUserModel].Gender isEqualToString:@"Male"] ? @"男":@"女"; cell.cell0LineView.hidden = YES; self.showUserGenderLabel = cell.cell0ValueLabel; return cell; }break; default: break; } }break; case 1:{ switch (indexPath.row) { case 0:{ MyInfoCell *cell = [MyInfoCell configCell1:tableView indexPath:indexPath]; cell.cell1TitleLabel.text = @"单位"; cell.cell1ValueLabel.text = ISEmptyString([AppUserModel sharedAppUserModel].DepartmentName) ? @"暂无单位": [self showStringLength:[AppUserModel sharedAppUserModel].DepartmentName]; return cell; }break; case 1:{ MyInfoCell *cell = [MyInfoCell configCell0:tableView indexPath:indexPath]; cell.cell0TitleLabel.text = @"自我介绍"; cell.cell0ValueLabel.text = @"";//ISEmptyString([AppUserModel sharedAppUserModel].description) ? @"":[self showStringLength:[AppUserModel sharedAppUserModel].Description] return cell; }break; case 2:{ MyInfoCell *cell = [MyInfoCell configCell0:tableView indexPath:indexPath]; cell.cell0TitleLabel.text = @"我的签名"; cell.cell0ValueLabel.text = @"";//ISEmptyString([AppUserModel sharedAppUserModel].Signature) ? @"广西出版集团撰稿人":[self showStringLength:[AppUserModel sharedAppUserModel].Signature] cell.cell0LineView.hidden = YES; return cell; }break; default: break; } }break; case 2:{ switch (indexPath.row) { case 0:{ MyInfoCell *cell = [MyInfoCell configCell0:tableView indexPath:indexPath]; cell.cell0TitleLabel.text = @"二维码"; cell.cell0ErWeiMaImgView.hidden = NO; cell.cell0ErWeiMaImgView.image = [UIImage imageNamed:@"my_qrcode_code_icon"]; return cell; }break; case 1:{ MyInfoCell *cell = [MyInfoCell configCell0:tableView indexPath:indexPath]; cell.cell0TitleLabel.text = @"手机号"; cell.cell0ValueLabel.text = @"";//ISEmptyString([AppUserModel sharedAppUserModel].Phone) ? @"":[AppUserModel sharedAppUserModel].Phone return cell; }break; case 2:{ MyInfoCell *cell = [MyInfoCell configCell0:tableView indexPath:indexPath]; cell.cell0TitleLabel.text = @"邮箱"; cell.cell0ValueLabel.text = @"";//ISEmptyString([AppUserModel sharedAppUserModel].Email) ? @"":[AppUserModel sharedAppUserModel].Email; cell.cell0LineView.hidden = YES; return cell; }break; default: break; } }break; default:break; } return nil; } - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{ [tableView deselectRowAtIndexPath:indexPath animated:YES]; WS(weakSelf); switch (indexPath.section) { case 0:{ switch (indexPath.row) { case 0:{ MyUserIconVC * vc = [MyUserIconVC initMyUserIconVC]; [self.navigationController pushViewController:vc animated:YES]; }break; case 1:{ // EditMySignOrBriefVC *vc = [EditMySignOrBriefVC initEditMySignOrBriefVC]; // vc.pagetype = EditMySignOrBriefPageType3; // vc.hidesBottomBarWhenPushed = YES; // [self.navigationController pushViewController:vc animated:YES]; }break; case 2:{ [[ShowGenderAlertView initShowGenderAlertViewWithGender:self.showUserGenderLabel.text confirm:^(NSString * _Nonnull gender) { weakSelf.showUserGenderLabel.text = gender; NSString *sexType = [gender isEqualToString:@"男"] ? @"Male":@"Female"; SHOWLOADING [UserManager updateUserInfoDetail:Sex Param:sexType Success:^(id _Nonnull responseObject) { REMOVESHOW [UserManager getUserInfoDetail]; } failure:^(NSError * _Nonnull error) { REMOVESHOW SHOWERROR([ZYCTool handerResultData:error]); }]; } cancle:^{ }] showWithAnimation:kAlertAnimationBottom]; }break; default: break; } }break; case 1:{ switch (indexPath.row) { case 0:{ }break; case 1:{ EditMySignOrBriefVC *vc = [EditMySignOrBriefVC initEditMySignOrBriefVC]; vc.pagetype = EditMySignOrBriefPageType2; vc.hidesBottomBarWhenPushed = YES; [self.navigationController pushViewController:vc animated:YES]; }break; case 2:{ EditMySignOrBriefVC *vc = [EditMySignOrBriefVC initEditMySignOrBriefVC]; vc.pagetype = EditMySignOrBriefPageType1; vc.hidesBottomBarWhenPushed = YES; [self.navigationController pushViewController:vc animated:YES]; }break; default: break; } }break; case 2:{ switch (indexPath.row) { case 0:{ [self.noteBookShareVC initNoteBookShareData]; self.qrVC.view.hidden = NO; WS(weakSelf); self.qrVC.ClickShareBlock = ^(UIImage * _Nonnull image) { if (image) { weakSelf.shareImage = image; weakSelf.noteBookShareVC.view.hidden = NO; }else{ SHOWERROR(@"分享失败"); } }; }break; case 1:{ EditPhoneOrEmailVC *vc = [EditPhoneOrEmailVC initEditPhoneOrEmailVC]; vc.pageType = BindingOrChangePhoneOrEmailPageType1; [self.navigationController pushViewController:vc animated:YES]; // H6ViewController *vc = [[H6ViewController alloc] init]; // vc.hidesBottomBarWhenPushed = YES; // [self.navigationController pushViewController:vc animated:YES]; }break; case 2:{ if (ISEmptyString([AppUserModel sharedAppUserModel].Email)) { EditPhoneOrEmailVC *vc = [EditPhoneOrEmailVC initEditPhoneOrEmailVC]; vc.pageType = BindingOrChangePhoneOrEmailPageType4; [self.navigationController pushViewController:vc animated:YES]; }else{ EditPhoneOrEmailVC *vc = [EditPhoneOrEmailVC initEditPhoneOrEmailVC]; vc.pageType = BindingOrChangePhoneOrEmailPageType2; [self.navigationController pushViewController:vc animated:YES]; } }break; default: break; } }break; default: break; } } - (MyQRCodeVC *)qrVC { if (!_qrVC) { _qrVC = [MyQRCodeVC initMyQRCodeVC]; _qrVC.view.hidden = YES; } return _qrVC; } - (NoteBookShareVC *)noteBookShareVC{ if (_noteBookShareVC == nil) { _noteBookShareVC = [NoteBookShareVC initNoteBookShareVC]; [_noteBookShareVC.view setFrame:CGRectMake(0,0, SCREEN_WIDTH, SCREEN_HEIGHT)]; [_noteBookShareVC.view setHidden:YES]; _noteBookShareVC.delegate = self; } return _noteBookShareVC; } -(void)userSelectType:(NSString *)typeName WithIndexPath:(NSIndexPath *)indexPath{ self.noteBookShareVC.view.hidden = !self.noteBookShareVC.view.hidden; if ([typeName isEqualToString:@"发给微信好友"]) { [self returnToWechatSession]; }else if ([typeName isEqualToString:@"发到朋友圈"]){ [self returnToWechatTimeLine]; }else if ([typeName isEqualToString:@"发到微博"]){ [self returnToSina]; }else if ([typeName isEqualToString:@"发给QQ好友"]){ [self returnToQQ]; }else if ([typeName isEqualToString:@"发到消息"]){ [self returnToMessage]; }else if ([typeName isEqualToString:@"发到小组"]){ [self returnToGroup]; }else if ([typeName isEqualToString:@"发到笔记"]){ [self returnToNote]; }else if ([typeName isEqualToString:@"发到话题"]){ [self returnToTopic]; }else{ } NSLog(@"111"); } #pragma mark - 分享功能 - (void)shareWebPageToPlatformType:(UMSocialPlatformType)platformType { //创建分享消息对象 UMSocialMessageObject *messageObject = [UMSocialMessageObject messageObject]; messageObject.title = @"二维码"; //创建网页内容对象 UMShareImageObject *shareObject = [[UMShareImageObject alloc] init]; //获取图片 shareObject.shareImage = self.shareImage; //分享消息对象设置分享内容对象 messageObject.shareObject = shareObject; //调用分享接口 [[UMSocialManager defaultManager] shareToPlatform:platformType messageObject:messageObject currentViewController:self completion:^(id data, NSError *error) { if (error) { NSLog(@"************Share fail with error %@*********",error); }else{ NSLog(@"response data is %@",data); } }]; } - (void)returnToWechatSession { [self shareWebPageToPlatformType:UMSocialPlatformType_WechatSession]; } - (void)returnToWechatTimeLine { [self shareWebPageToPlatformType:UMSocialPlatformType_WechatTimeLine]; } - (void)returnToSina { [self shareWebPageToPlatformType:UMSocialPlatformType_Sina]; } - (void)returnToQQ { [self shareWebPageToPlatformType:UMSocialPlatformType_QQ]; } - (void)returnToMessage { ShareListVC * vc = [ShareListVC initShareListVC]; FlowAttachmentsModel * model = [[FlowAttachmentsModel alloc] init]; model.SoureTypeId = CollectModel_Image; model.MinUrl = [AppUserModel sharedAppUserModel].QRCoder; model.Url = [AppUserModel sharedAppUserModel].QRCoder; vc.sendModel = model; vc.isReturn = YES; [self.navigationController pushViewController:vc animated:YES]; } - (void)returnToGroup { MyTDGroupViewController * vc = [[MyTDGroupViewController alloc] init]; vc.type = CollectModel_Toipc; FlowAttachmentsModel * model = [[FlowAttachmentsModel alloc] init]; model.SoureTypeId = CollectModel_Image; model.MinUrl = [AppUserModel sharedAppUserModel].QRCoder; model.Url = [AppUserModel sharedAppUserModel].QRCoder; vc.sendModel = model; vc.sendImage = self.shareImage; vc.isReturn = YES; [self.navigationController pushViewController:vc animated:YES]; } - (void)returnToNote { MoveViewController * vc = [MoveViewController initMoveViewController]; vc.isFromCreateBookVc = YES; vc.CollectionType = CollectModel_NoteBook; vc.TypeId = CreateNotesType; vc.titleStr = @"我的笔记"; vc.ParentId = 0; FlowAttachmentsModel * model = [[FlowAttachmentsModel alloc] init]; model.SoureTypeId = CollectModel_Image; model.MinUrl = [AppUserModel sharedAppUserModel].QRCoder; model.Url = [AppUserModel sharedAppUserModel].QRCoder; vc.sendModel = model; vc.sendImage = self.shareImage; vc.isReturn = YES; [self.navigationController pushViewController:vc animated:YES]; } - (void)returnToTopic { MyTDTopicCreateVC * vc = [MyTDTopicCreateVC initMyTDTopicCreateVC]; vc.type = CollectModel_NewTopic; FlowAttachmentsModel * model = [[FlowAttachmentsModel alloc] init]; model.SoureTypeId = CollectModel_Image; model.MinUrl = [AppUserModel sharedAppUserModel].QRCoder; model.Url = [AppUserModel sharedAppUserModel].QRCoder; vc.sendModel = model; vc.sendImage = self.shareImage; vc.isReturn = YES; [self.navigationController pushViewController:vc animated:YES]; } - (void)uploadImage{ } - (NSString *)showStringLength:(NSString *)str { if (str.length >= 20) { NSString * newStr = [str substringToIndex:10]; return [NSString stringWithFormat:@"%@...",newStr]; } return str; } @end