MyInfoVC.m 18 KB

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