MyInfoVC.m 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472
  1. //
  2. // MyInfoVC.m
  3. // smartRhino
  4. //
  5. // Created by armin on 2019/11/1.
  6. // Copyright © 2019 tederen. All rights reserved.
  7. //
  8. #import "MyInfoVC.h"
  9. #import "MyInfoCell.h"
  10. #import "ShowPhotoCameraAlertView.h"
  11. #import "EditUserNickVC.h"
  12. #import "ShowGenderAlertView.h"
  13. #import "EditMySignOrBriefVC.h"
  14. #import "EditPhoneOrEmailVC.h"
  15. #import "H5ViewController.h"
  16. #import "H6ViewController.h"
  17. #import "MyUserIconVC.h"
  18. #import "MyQRCodeVC.h"
  19. #import "NoteBookShareVC.h"
  20. #import "ShareListVC.h"
  21. #import "MyTDGroupViewController.h"
  22. #import "MoveViewController.h"
  23. @interface MyInfoVC ()<UITableViewDelegate,UITableViewDataSource,NoteBookShareVCDelegate>
  24. @property (strong,nonatomic) IBOutlet UITableView *tableView;
  25. @property (strong,nonatomic) UIImageView *showUserTestUserImg;
  26. @property (strong,nonatomic) UILabel *showUserGenderLabel;
  27. @property (strong,nonatomic) MyQRCodeVC *qrVC;
  28. @property (strong,nonatomic) NoteBookShareVC *noteBookShareVC;
  29. @property (strong,nonatomic) UIImage *shareImage;
  30. @end
  31. @implementation MyInfoVC
  32. +(MyInfoVC *)initMyInfoVC{
  33. MyInfoVC *controller = [StoryboardManager.shared.myCenter instantiateViewControllerWithIdentifier:@"MyInfoVC"];
  34. return controller;
  35. }
  36. - (void)viewDidLoad {
  37. [super viewDidLoad];
  38. self.fd_prefersNavigationBarHidden = YES;
  39. self.view.backgroundColor = RGB(238, 238, 238);
  40. if (@available(iOS 11.0, *)) {
  41. self.tableView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
  42. } else {
  43. self.automaticallyAdjustsScrollViewInsets = NO;
  44. }
  45. self.tableView.delegate = self;
  46. self.tableView.dataSource = self;
  47. self.tableView.backgroundColor = [UIColor clearColor];
  48. self.tableView.estimatedRowHeight = 0;
  49. self.tableView.estimatedSectionHeaderHeight = 0;
  50. self.tableView.estimatedSectionFooterHeight = 0;
  51. [self.view addSubview:self.qrVC.view];
  52. [self.view addSubview:self.noteBookShareVC.view];
  53. }
  54. - (void)viewWillAppear:(BOOL)animated{
  55. [super viewWillAppear:animated];
  56. [self.tableView reloadData];
  57. }
  58. - (void)viewDidAppear:(BOOL)animated{
  59. [super viewDidAppear:animated];
  60. [self.tableView reloadData];
  61. }
  62. - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
  63. return 3;
  64. }
  65. - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
  66. switch (section) {
  67. case 0:{
  68. return 3;
  69. }break;
  70. case 1:{
  71. return 3;
  72. }break;
  73. case 2:{
  74. return 3;
  75. }break;
  76. default:break;
  77. }
  78. return 0;
  79. }
  80. - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
  81. switch (indexPath.section) {
  82. case 0:{
  83. return [MyInfoCell configCell0Height];
  84. }break;
  85. case 1:{
  86. return [MyInfoCell configCell1Height];
  87. }break;
  88. case 2:{
  89. return [MyInfoCell configCell1Height];
  90. }break;
  91. default:break;
  92. }
  93. return 0;
  94. }
  95. - (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{
  96. UIView *headerView = [[UIView alloc]init];
  97. [headerView setBackgroundColor:RGBA(238, 238, 238, 1)];
  98. return headerView;
  99. }
  100. - (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section{
  101. UIView *headerView = [[UIView alloc]init];
  102. [headerView setBackgroundColor:RGBA(238, 238, 238, 1)];
  103. return headerView;
  104. }
  105. - (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
  106. return 0;
  107. }
  108. - (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section{
  109. if(section == 0 || section == 1){
  110. return 10;
  111. }
  112. return 0;
  113. }
  114. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
  115. WS(weakSelf);
  116. switch (indexPath.section) {
  117. case 0:{
  118. switch (indexPath.row) {
  119. case 0:{
  120. MyInfoCell *cell = [MyInfoCell configCell0:tableView indexPath:indexPath];
  121. cell.cell0TitleLabel.text = @"头像";
  122. cell.cell0UserImgView.hidden = NO;
  123. [cell.cell0UserImgView sd_setImageWithURL:[NSURL URLWithString:[AppUserModel sharedAppUserModel].AvatarUrl]];
  124. // UITapGestureRecognizer * tap = [[UITapGestureRecognizer alloc] initWithActionBlock:^(id _Nonnull sender) {
  125. // MyUserIconVC * vc = [MyUserIconVC initMyUserIconVC];
  126. // [weakSelf.navigationController pushViewController:vc animated:YES];
  127. // }];
  128. // [cell.cell0UserImgView addGestureRecognizer:tap];
  129. // cell.cell0UserImgView.userInteractionEnabled = YES;
  130. self.showUserTestUserImg = cell.cell0UserImgView;
  131. return cell;
  132. }break;
  133. case 1:{
  134. MyInfoCell *cell = [MyInfoCell configCell1:tableView indexPath:indexPath];
  135. cell.cell1TitleLabel.text = @"姓名";
  136. cell.cell1ValueLabel.text = ISEmptyString([AppUserModel sharedAppUserModel].Name) ? @"": [self showStringLength:[AppUserModel sharedAppUserModel].Name];
  137. cell.cell1ValueLabel.textColor = UIColorHex(#3D95ED);
  138. return cell;
  139. }break;
  140. case 2:{
  141. MyInfoCell *cell = [MyInfoCell configCell0:tableView indexPath:indexPath];
  142. cell.cell0TitleLabel.text = @"性别";
  143. cell.cell0ValueLabel.text = [[AppUserModel sharedAppUserModel].Gender isEqualToString:@"Male"] ? @"男":@"女";
  144. cell.cell0LineView.hidden = YES;
  145. self.showUserGenderLabel = cell.cell0ValueLabel;
  146. return cell;
  147. }break;
  148. default:
  149. break;
  150. }
  151. }break;
  152. case 1:{
  153. switch (indexPath.row) {
  154. case 0:{
  155. MyInfoCell *cell = [MyInfoCell configCell1:tableView indexPath:indexPath];
  156. cell.cell1TitleLabel.text = @"单位";
  157. cell.cell1ValueLabel.text = ISEmptyString([AppUserModel sharedAppUserModel].DepartmentName) ? @"暂无单位": [self showStringLength:[AppUserModel sharedAppUserModel].DepartmentName];
  158. return cell;
  159. }break;
  160. case 1:{
  161. MyInfoCell *cell = [MyInfoCell configCell0:tableView indexPath:indexPath];
  162. cell.cell0TitleLabel.text = @"自我介绍";
  163. cell.cell0ValueLabel.text = @"";//ISEmptyString([AppUserModel sharedAppUserModel].description) ? @"":[self showStringLength:[AppUserModel sharedAppUserModel].Description]
  164. return cell;
  165. }break;
  166. case 2:{
  167. MyInfoCell *cell = [MyInfoCell configCell0:tableView indexPath:indexPath];
  168. cell.cell0TitleLabel.text = @"我的签名";
  169. cell.cell0ValueLabel.text = @"";//ISEmptyString([AppUserModel sharedAppUserModel].Signature) ? @"广西出版集团撰稿人":[self showStringLength:[AppUserModel sharedAppUserModel].Signature]
  170. cell.cell0LineView.hidden = YES;
  171. return cell;
  172. }break;
  173. default:
  174. break;
  175. }
  176. }break;
  177. case 2:{
  178. switch (indexPath.row) {
  179. case 0:{
  180. MyInfoCell *cell = [MyInfoCell configCell0:tableView indexPath:indexPath];
  181. cell.cell0TitleLabel.text = @"二维码";
  182. cell.cell0ErWeiMaImgView.hidden = NO;
  183. cell.cell0ErWeiMaImgView.image = [UIImage imageNamed:@"my_qrcode_code_icon"];
  184. return cell;
  185. }break;
  186. case 1:{
  187. MyInfoCell *cell = [MyInfoCell configCell0:tableView indexPath:indexPath];
  188. cell.cell0TitleLabel.text = @"手机号";
  189. cell.cell0ValueLabel.text = @"";//ISEmptyString([AppUserModel sharedAppUserModel].Phone) ? @"":[AppUserModel sharedAppUserModel].Phone
  190. return cell;
  191. }break;
  192. case 2:{
  193. MyInfoCell *cell = [MyInfoCell configCell0:tableView indexPath:indexPath];
  194. cell.cell0TitleLabel.text = @"邮箱";
  195. cell.cell0ValueLabel.text = @"";//ISEmptyString([AppUserModel sharedAppUserModel].Email) ? @"":[AppUserModel sharedAppUserModel].Email;
  196. cell.cell0LineView.hidden = YES;
  197. return cell;
  198. }break;
  199. default:
  200. break;
  201. }
  202. }break;
  203. default:break;
  204. }
  205. return nil;
  206. }
  207. - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
  208. [tableView deselectRowAtIndexPath:indexPath animated:YES];
  209. WS(weakSelf);
  210. switch (indexPath.section) {
  211. case 0:{
  212. switch (indexPath.row) {
  213. case 0:{
  214. MyUserIconVC * vc = [MyUserIconVC initMyUserIconVC];
  215. [self.navigationController pushViewController:vc animated:YES];
  216. }break;
  217. case 1:{
  218. // EditMySignOrBriefVC *vc = [EditMySignOrBriefVC initEditMySignOrBriefVC];
  219. // vc.pagetype = EditMySignOrBriefPageType3;
  220. // vc.hidesBottomBarWhenPushed = YES;
  221. // [self.navigationController pushViewController:vc animated:YES];
  222. }break;
  223. case 2:{
  224. [[ShowGenderAlertView initShowGenderAlertViewWithGender:self.showUserGenderLabel.text confirm:^(NSString * _Nonnull gender) {
  225. weakSelf.showUserGenderLabel.text = gender;
  226. NSString *sexType = [gender isEqualToString:@"男"] ? @"Male":@"Female";
  227. SHOWLOADING
  228. [UserManager updateUserInfoDetail:Sex Param:sexType Success:^(id _Nonnull responseObject) {
  229. REMOVESHOW
  230. [UserManager getUserInfoDetail];
  231. } failure:^(NSError * _Nonnull error) {
  232. REMOVESHOW
  233. SHOWERROR([ZYCTool handerResultData:error]);
  234. }];
  235. } cancle:^{
  236. }] showWithAnimation:kAlertAnimationBottom];
  237. }break;
  238. default:
  239. break;
  240. }
  241. }break;
  242. case 1:{
  243. switch (indexPath.row) {
  244. case 0:{
  245. }break;
  246. case 1:{
  247. EditMySignOrBriefVC *vc = [EditMySignOrBriefVC initEditMySignOrBriefVC];
  248. vc.pagetype = EditMySignOrBriefPageType2;
  249. vc.hidesBottomBarWhenPushed = YES;
  250. [self.navigationController pushViewController:vc animated:YES];
  251. }break;
  252. case 2:{
  253. EditMySignOrBriefVC *vc = [EditMySignOrBriefVC initEditMySignOrBriefVC];
  254. vc.pagetype = EditMySignOrBriefPageType1;
  255. vc.hidesBottomBarWhenPushed = YES;
  256. [self.navigationController pushViewController:vc animated:YES];
  257. }break;
  258. default:
  259. break;
  260. }
  261. }break;
  262. case 2:{
  263. switch (indexPath.row) {
  264. case 0:{
  265. [self.noteBookShareVC initNoteBookShareData];
  266. self.qrVC.view.hidden = NO;
  267. WS(weakSelf);
  268. self.qrVC.ClickShareBlock = ^(UIImage * _Nonnull image) {
  269. if (image) {
  270. weakSelf.shareImage = image;
  271. weakSelf.noteBookShareVC.view.hidden = NO;
  272. }else{
  273. SHOWERROR(@"分享失败");
  274. }
  275. };
  276. }break;
  277. case 1:{
  278. EditPhoneOrEmailVC *vc = [EditPhoneOrEmailVC initEditPhoneOrEmailVC];
  279. vc.pageType = BindingOrChangePhoneOrEmailPageType1;
  280. [self.navigationController pushViewController:vc animated:YES];
  281. // H6ViewController *vc = [[H6ViewController alloc] init];
  282. // vc.hidesBottomBarWhenPushed = YES;
  283. // [self.navigationController pushViewController:vc animated:YES];
  284. }break;
  285. case 2:{
  286. if (ISEmptyString([AppUserModel sharedAppUserModel].Email)) {
  287. EditPhoneOrEmailVC *vc = [EditPhoneOrEmailVC initEditPhoneOrEmailVC];
  288. vc.pageType = BindingOrChangePhoneOrEmailPageType4;
  289. [self.navigationController pushViewController:vc animated:YES];
  290. }else{
  291. EditPhoneOrEmailVC *vc = [EditPhoneOrEmailVC initEditPhoneOrEmailVC];
  292. vc.pageType = BindingOrChangePhoneOrEmailPageType2;
  293. [self.navigationController pushViewController:vc animated:YES];
  294. }
  295. }break;
  296. default:
  297. break;
  298. }
  299. }break;
  300. default:
  301. break;
  302. }
  303. }
  304. - (MyQRCodeVC *)qrVC
  305. {
  306. if (!_qrVC) {
  307. _qrVC = [MyQRCodeVC initMyQRCodeVC];
  308. _qrVC.view.hidden = YES;
  309. }
  310. return _qrVC;
  311. }
  312. - (NoteBookShareVC *)noteBookShareVC{
  313. if (_noteBookShareVC == nil) {
  314. _noteBookShareVC = [NoteBookShareVC initNoteBookShareVC];
  315. [_noteBookShareVC.view setFrame:CGRectMake(0,0, SCREEN_WIDTH, SCREEN_HEIGHT)];
  316. [_noteBookShareVC.view setHidden:YES];
  317. _noteBookShareVC.delegate = self;
  318. }
  319. return _noteBookShareVC;
  320. }
  321. -(void)userSelectType:(NSString *)typeName WithIndexPath:(NSIndexPath *)indexPath{
  322. self.noteBookShareVC.view.hidden = !self.noteBookShareVC.view.hidden;
  323. if ([typeName isEqualToString:@"发给微信好友"]) {
  324. [self returnToWechatSession];
  325. }else if ([typeName isEqualToString:@"发到朋友圈"]){
  326. [self returnToWechatTimeLine];
  327. }else if ([typeName isEqualToString:@"发到微博"]){
  328. [self returnToSina];
  329. }else if ([typeName isEqualToString:@"发给QQ好友"]){
  330. [self returnToQQ];
  331. }else if ([typeName isEqualToString:@"发到消息"]){
  332. [self returnToMessage];
  333. }else if ([typeName isEqualToString:@"发到小组"]){
  334. [self returnToGroup];
  335. }else if ([typeName isEqualToString:@"发到笔记"]){
  336. [self returnToNote];
  337. }else if ([typeName isEqualToString:@"发到话题"]){
  338. [self returnToTopic];
  339. }else{
  340. }
  341. NSLog(@"111");
  342. }
  343. #pragma mark - 分享功能
  344. - (void)shareWebPageToPlatformType:(UMSocialPlatformType)platformType
  345. {
  346. //创建分享消息对象
  347. UMSocialMessageObject *messageObject = [UMSocialMessageObject messageObject];
  348. messageObject.title = @"二维码";
  349. //创建网页内容对象
  350. UMShareImageObject *shareObject = [[UMShareImageObject alloc] init];
  351. //获取图片
  352. shareObject.shareImage = self.shareImage;
  353. //分享消息对象设置分享内容对象
  354. messageObject.shareObject = shareObject;
  355. //调用分享接口
  356. [[UMSocialManager defaultManager] shareToPlatform:platformType messageObject:messageObject currentViewController:self completion:^(id data, NSError *error) {
  357. if (error) {
  358. NSLog(@"************Share fail with error %@*********",error);
  359. }else{
  360. NSLog(@"response data is %@",data);
  361. }
  362. }];
  363. }
  364. - (void)returnToWechatSession
  365. {
  366. [self shareWebPageToPlatformType:UMSocialPlatformType_WechatSession];
  367. }
  368. - (void)returnToWechatTimeLine
  369. {
  370. [self shareWebPageToPlatformType:UMSocialPlatformType_WechatTimeLine];
  371. }
  372. - (void)returnToSina
  373. {
  374. [self shareWebPageToPlatformType:UMSocialPlatformType_Sina];
  375. }
  376. - (void)returnToQQ
  377. {
  378. [self shareWebPageToPlatformType:UMSocialPlatformType_QQ];
  379. }
  380. - (void)returnToMessage
  381. {
  382. ShareListVC * vc = [ShareListVC initShareListVC];
  383. FlowAttachmentsModel * model = [[FlowAttachmentsModel alloc] init];
  384. model.SoureTypeId = CollectModel_Image;
  385. model.MinUrl = [AppUserModel sharedAppUserModel].QRCoder;
  386. model.Url = [AppUserModel sharedAppUserModel].QRCoder;
  387. vc.sendModel = model;
  388. vc.isReturn = YES;
  389. [self.navigationController pushViewController:vc animated:YES];
  390. }
  391. - (void)returnToGroup
  392. {
  393. MyTDGroupViewController * vc = [[MyTDGroupViewController alloc] init];
  394. vc.type = CollectModel_Toipc;
  395. FlowAttachmentsModel * model = [[FlowAttachmentsModel alloc] init];
  396. model.SoureTypeId = CollectModel_Image;
  397. model.MinUrl = [AppUserModel sharedAppUserModel].QRCoder;
  398. model.Url = [AppUserModel sharedAppUserModel].QRCoder;
  399. vc.sendModel = model;
  400. vc.sendImage = self.shareImage;
  401. vc.isReturn = YES;
  402. [self.navigationController pushViewController:vc animated:YES];
  403. }
  404. - (void)returnToNote
  405. {
  406. MoveViewController * vc = [MoveViewController initMoveViewController];
  407. vc.isFromCreateBookVc = YES;
  408. vc.CollectionType = CollectModel_NoteBook;
  409. vc.TypeId = CreateNotesType;
  410. vc.titleStr = @"我的笔记";
  411. vc.ParentId = 0;
  412. FlowAttachmentsModel * model = [[FlowAttachmentsModel alloc] init];
  413. model.SoureTypeId = CollectModel_Image;
  414. model.MinUrl = [AppUserModel sharedAppUserModel].QRCoder;
  415. model.Url = [AppUserModel sharedAppUserModel].QRCoder;
  416. vc.sendModel = model;
  417. vc.sendImage = self.shareImage;
  418. vc.isReturn = YES;
  419. [self.navigationController pushViewController:vc animated:YES];
  420. }
  421. - (void)returnToTopic
  422. {
  423. MyTDTopicCreateVC * vc = [MyTDTopicCreateVC initMyTDTopicCreateVC];
  424. vc.type = CollectModel_NewTopic;
  425. FlowAttachmentsModel * model = [[FlowAttachmentsModel alloc] init];
  426. model.SoureTypeId = CollectModel_Image;
  427. model.MinUrl = [AppUserModel sharedAppUserModel].QRCoder;
  428. model.Url = [AppUserModel sharedAppUserModel].QRCoder;
  429. vc.sendModel = model;
  430. vc.sendImage = self.shareImage;
  431. vc.isReturn = YES;
  432. [self.navigationController pushViewController:vc animated:YES];
  433. }
  434. - (void)uploadImage{
  435. }
  436. - (NSString *)showStringLength:(NSString *)str
  437. {
  438. if (str.length >= 20) {
  439. NSString * newStr = [str substringToIndex:10];
  440. return [NSString stringWithFormat:@"%@...",newStr];
  441. }
  442. return str;
  443. }
  444. @end