123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441 |
- //
- // 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 "LYLPhotoTailoringTool.h"
- #import "EditUserNickVC.h"
- #import "ShowGenderAlertView.h"
- #import "EditMySignOrBriefVC.h"
- #import "MyQRCodeVC.h"
- #import "EditPhoneOrEmailVC.h"
- #import "H5ViewController.h"
- #import "H6ViewController.h"
- #import "MyUserIconVC.h"
- @interface MyInfoVC ()<UITableViewDelegate,UITableViewDataSource>
- @property (strong,nonatomic) IBOutlet UITableView *tableView;
- @property (strong,nonatomic) UIImageView *showUserTestUserImg;
- @property (strong,nonatomic) UILabel *showUserGenderLabel;
- @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);
-
- if (@available(iOS 11.0, *)) {
- self.tableView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
- } else {
- self.automaticallyAdjustsScrollViewInsets = NO;
- }
- 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;
- }
- - (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 configCell0:tableView indexPath:indexPath];
- cell.cell0TitleLabel.text = @"昵称";
- cell.cell0ValueLabel.text = [self showStringLength:[AppUserModel sharedAppUserModel].Nick];
- 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:{
- [[ShowPhotoCameraAlertView initShowPhotoCameraAlertViewConfirm:^(ShowPhotoCameraType type) {
- if(type == ShowPhotoCameraType1){
- NSLog(@"相册");
- [[LYLPhotoTailoringTool sharedTool] selectPhotoWithPhoroOrCamera:SelectPhotoWithTypePhoroOrCamera2 crop:YES showImgBlock:^(NSString *imageUrlStr) {
- NSLog(@"111111");
- } choosImgBlock:^(UIImage *image) {
- NSLog(@"aaaaaa");
- self.showUserTestUserImg.image = image;
- SHOWLOADING
- [[HttpManager sharedHttpManager] HeaderUploadUrl:[NSString stringWithFormat:@"%@%@",BaseUrl,Modify_UserImage_Post] parameters:@{@"":@""} pictureData:UIImageJPEGRepresentation(image,1.0f) pictureKey:@"file" success:^(id _Nonnull responseObject) {
- NSDictionary *dic = responseObject;
- NSLog(@"/n图片上传成功=====绝对路径=====/n%@",responseObject[@"AbsolutePath"]);
- NSLog(@"/n图片上传成功=====相对路径=====/n%@",responseObject[@"RelativePath"]);
- [UserManager updateUserInfoDetail:IMAGE Param:dic[@"RelativePath"] Success:^(id _Nonnull responseObject) {
- REMOVESHOW;
- [[HttpManager sharedHttpManager] GETUrl:[NSString stringWithFormat:@"%@%@",BaseUrl,UserDetailGet] parameters:@{} success:^(id _Nonnull responseObject) {
- NSDictionary *dic = responseObject;
- [[AppUserModel sharedAppUserModel] modelSetWithDictionary:dic];
- dispatch_async(dispatch_get_main_queue(), ^{
- [weakSelf.tableView reloadRowAtIndexPath:[NSIndexPath indexPathForRow:0 inSection:0] withRowAnimation:UITableViewRowAnimationAutomatic];
- });
- } failure:^(NSError * _Nonnull error) {
- }];
- } failure:^(NSError * _Nonnull error) {
- REMOVESHOW
- SHOWERROR([ZYCTool handerResultData:error])
- }];
- } failure:^(NSError * _Nonnull error) {
- REMOVESHOW
- SHOWERROR([ZYCTool handerResultData:error])
- }];
- }];
- }else if (type == ShowPhotoCameraType2){
- NSLog(@"相机");
- TZImagePickerController *imagePickerVc = [[TZImagePickerController alloc] initWithMaxImagesCount:1 delegate:nil];
- [imagePickerVc setNavLeftBarButtonSettingBlock:^(UIButton *leftButton){
- leftButton.hidden = YES;
- }];
- imagePickerVc.showSelectBtn = NO;
- imagePickerVc.allowCrop = YES;
- imagePickerVc.cropRect = CGRectMake(0, (SCREEN_HEIGHT - SCREEN_WIDTH) * 0.5, SCREEN_WIDTH, SCREEN_WIDTH);
- imagePickerVc.allowTakePicture = NO;
- imagePickerVc.allowTakeVideo = NO;
- imagePickerVc.allowPickingOriginalPhoto = NO;
- imagePickerVc.allowPickingGif = NO;
- [imagePickerVc setIsStatusBarDefault:YES];
- [imagePickerVc setNaviTitleColor:[UIColor blackColor]];
- [imagePickerVc setBarItemTextColor:[UIColor blackColor]];
- [imagePickerVc setDidFinishPickingPhotosHandle:^(NSArray<UIImage *> *photos, NSArray *assets, BOOL isSelectOriginalPhoto) {
- PHAsset *asset = assets.firstObject;
- switch (asset.mediaType) {
- case PHAssetMediaTypeVideo: {
- } break;
- case PHAssetMediaTypeImage: {
- UIImage * image = photos.firstObject;
- [[HttpManager sharedHttpManager] HeaderUploadUrl:[NSString stringWithFormat:@"%@%@",BaseUrl,Modify_UserImage_Post] parameters:@{} pictureData:UIImageJPEGRepresentation(image,1.0f) pictureKey:@"file" success:^(id _Nonnull responseObject) {
-
- NSDictionary *dic = responseObject;
- NSLog(@"/n图片上传成功=====绝对路径=====/n%@",responseObject[@"AbsolutePath"]);
- NSLog(@"/n图片上传成功=====相对路径=====/n%@",responseObject[@"RelativePath"]);
-
- [UserManager updateUserInfoDetail:IMAGE Param:dic[@"RelativePath"] Success:^(id _Nonnull responseObject) {
- REMOVESHOW;
- [[HttpManager sharedHttpManager] GETUrl:[NSString stringWithFormat:@"%@%@",BaseUrl,UserDetailGet] parameters:@{} success:^(id _Nonnull responseObject) {
- NSDictionary *dic = responseObject;
- [[AppUserModel sharedAppUserModel] modelSetWithDictionary:dic];
- dispatch_async(dispatch_get_main_queue(), ^{
- [weakSelf.tableView reloadRowAtIndexPath:[NSIndexPath indexPathForRow:0 inSection:0] withRowAnimation:UITableViewRowAnimationAutomatic];
- });
- } failure:^(NSError * _Nonnull error) {
- }];
- } failure:^(NSError * _Nonnull error) {
- REMOVESHOW
- SHOWERROR([ZYCTool handerResultData:error])
- }];
-
- } failure:^(NSError * _Nonnull error) {
- REMOVESHOW
- SHOWERROR([ZYCTool handerResultData:error])
- }];
- } break;
- case PHAssetMediaTypeAudio:
- break;
- case PHAssetMediaTypeUnknown:
- break;
- default: break;
- }
- }];
- [self presentViewController:imagePickerVc animated:YES completion:nil];
- // [[LYLPhotoTailoringTool sharedTool] selectPhotoWithPhoroOrCamera:SelectPhotoWithTypePhoroOrCamera2 crop:YES showImgBlock:^(NSString *imageUrlStr) {
- // NSLog(@"222222");
- //
- // } choosImgBlock:^(UIImage *image) {
- // NSLog(@"oooooo");
- // self.showUserTestUserImg.image = image;
- //
- // [[HttpManager sharedHttpManager] HeaderUploadUrl:[NSString stringWithFormat:@"%@%@",BaseUrl,Modify_UserImage_Post] parameters:@{@"":@""} pictureData:UIImageJPEGRepresentation(image,1.0f) pictureKey:@"file" success:^(id _Nonnull responseObject) {
- //
- // NSDictionary *dic = responseObject;
- // NSLog(@"/n图片上传成功=====绝对路径=====/n%@",responseObject[@"AbsolutePath"]);
- // NSLog(@"/n图片上传成功=====相对路径=====/n%@",responseObject[@"RelativePath"]);
- //
- // [UserManager updateUserInfoDetail:IMAGE Param:dic[@"RelativePath"] Success:^(id _Nonnull responseObject) {
- // REMOVESHOW;
- // SHOWSUCCESS(@"修改成功");
- // } failure:^(NSError * _Nonnull error) {
- // REMOVESHOW
- // SHOWERROR([ZYCTool handerResultData:error])
- // }];
- //
- // } failure:^(NSError * _Nonnull error) {
- // REMOVESHOW
- // SHOWERROR([ZYCTool handerResultData:error])
- // }];
- // }];
- }
- } cancle:^{
- }] showWithAnimation:kAlertAnimationBottom];
- }break;
- case 1:{
- EditMySignOrBriefVC *vc = [EditMySignOrBriefVC initEditMySignOrBriefVC];
- vc.pagetype = EditMySignOrBriefPageType3;
- vc.hidesBottomBarWhenPushed = YES;
- [self.navigationController pushViewController:vc animated:YES];
- }break;
- case 2:{
- WS(weakSelf);
- [[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:{
- MyQRCodeVC *vc = [MyQRCodeVC initMyQRCodeVC];
- vc.hidesBottomBarWhenPushed = YES;
- [self.navigationController pushViewController:vc animated:YES];
- // H5ViewController *vc = [[H5ViewController alloc] init];
- // vc.hidesBottomBarWhenPushed = YES;
- // [self.navigationController pushViewController:vc animated:YES];
- }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;
- }
- }
- - (void)uploadImage{
- }
- - (NSString *)showStringLength:(NSString *)str
- {
- if (str.length >= 20) {
- NSString * newStr = [str substringToIndex:10];
- return [NSString stringWithFormat:@"%@...",newStr];
- }
- return str;
- }
- @end
|