123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468 |
- //
- // 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 ()<UITableViewDelegate,UITableViewDataSource,NoteBookShareVCDelegate>
- @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
|