My_CenterVC.m 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319
  1. //
  2. // My_CenterVC.m
  3. // smartRhino
  4. //
  5. // Created by armin on 2019/11/1.
  6. // Copyright © 2019 tederen. All rights reserved.
  7. //
  8. #import "My_CenterVC.h"
  9. #import "My_CenterCell.h"
  10. #import "MyInfoVC.h"
  11. #import "SettingVC.h"
  12. #import "FavoritesViewController.h"
  13. #import "MyFavoriteVC.h"
  14. #import "MyCardVC.h"
  15. #import "NoteBookVC.h"
  16. #import "MyAccountVC.h"
  17. #import "MailListVC.h"
  18. #import "SWQRCodeViewController.h"
  19. #import "MailListDetailVC.h"
  20. #import "ChatJoinGroupVC.h"
  21. #import "TDGroupInfoListVC.h"
  22. #import "TDQrJoinVC.h"
  23. @interface My_CenterVC ()<UITableViewDelegate,UITableViewDataSource,SWQRCodeViewControllerDelegate>
  24. @property (strong,nonatomic) IBOutlet UITableView *tableView;
  25. @end
  26. @implementation My_CenterVC
  27. - (void)viewDidLoad {
  28. [super viewDidLoad];
  29. self.fd_prefersNavigationBarHidden = YES;
  30. self.view.backgroundColor = RGB(240, 239, 244);
  31. if (@available(iOS 11.0, *)) {
  32. self.tableView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
  33. } else {
  34. self.automaticallyAdjustsScrollViewInsets = NO;
  35. }
  36. [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(PushSettingVC:) name:DRAWERPUSHVC object:nil];
  37. self.tableView.delegate = self;
  38. self.tableView.dataSource = self;
  39. [self.tableView setScrollEnabled:NO];
  40. self.tableView.backgroundColor = [UIColor clearColor];
  41. self.tableView.estimatedRowHeight = 0;
  42. self.tableView.estimatedSectionHeaderHeight = 0;
  43. self.tableView.estimatedSectionFooterHeight = 0;
  44. [UserManager getUserInfoDetail];
  45. }
  46. - (void)dealloc
  47. {
  48. [[NSNotificationCenter defaultCenter] removeObserver:self];
  49. }
  50. - (void)viewWillAppear:(BOOL)animated{
  51. [super viewWillAppear:animated];
  52. [self.tableView reloadData];
  53. }
  54. - (BOOL)hidesBottomBarWhenPushed
  55. {
  56. return NO;
  57. }
  58. - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
  59. return 2;
  60. }
  61. - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
  62. switch (section) {
  63. case 0:{
  64. return 1;
  65. }break;
  66. case 1:{
  67. return 5;
  68. }break;
  69. default:break;
  70. }
  71. return 0;
  72. }
  73. - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
  74. switch (indexPath.section) {
  75. case 0:{
  76. return [My_CenterCell configCell0Height];
  77. }break;
  78. case 1:{
  79. return [My_CenterCell configCell1Height];
  80. }break;
  81. default:break;
  82. }
  83. return 0;
  84. }
  85. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
  86. switch (indexPath.section) {
  87. case 0:{
  88. My_CenterCell *cell = [My_CenterCell configCell0:tableView indexPath:indexPath];
  89. [cell.cell0UserImgView sd_setImageWithURL:[NSURL URLWithString:[AppUserModel sharedAppUserModel].AvatarUrl] placeholderImage:[UIImage imageNamed:@"my_conter_TestUserImg"]];
  90. NSLog(@"%@",[AppUserModel sharedAppUserModel].Name);
  91. cell.cell0UserName.text = ISEmptyString([AppUserModel sharedAppUserModel].Nick) ? @"昵称":[AppUserModel sharedAppUserModel].Name;
  92. cell.cell0Intrt.text = ISEmptyString([AppUserModel sharedAppUserModel].Description) ? @"自我介绍":[AppUserModel sharedAppUserModel].Description ;
  93. return cell;
  94. }break;
  95. case 1:{
  96. My_CenterCell *cell = [My_CenterCell configCell1:tableView indexPath:indexPath];
  97. switch (indexPath.row) {
  98. case 0: {
  99. cell.cell1IconImg.image = [UIImage imageNamed:@"mine_account"];
  100. cell.cell1TitleLabel.text = @"账户";
  101. }break;
  102. case 1: {
  103. cell.cell1IconImg.image = [UIImage imageNamed:@"mine_wuxianka"];
  104. cell.cell1TitleLabel.text = @"无限卡";
  105. }break;
  106. case 2: {
  107. cell.cell1IconImg.image = [UIImage imageNamed:@"mine_txl_icon"];
  108. cell.cell1TitleLabel.text = @"通讯录";
  109. }break;
  110. case 3: {
  111. cell.cell1IconImg.image = [UIImage imageNamed:@"mine_scan"];
  112. cell.cell1TitleLabel.text = @"扫一扫";
  113. }break;
  114. default:
  115. {
  116. cell.cell1IconImg.image = [UIImage imageNamed:@"my_conter_setting_icon"];
  117. cell.cell1TitleLabel.text = @"设置";
  118. }
  119. break;
  120. }
  121. return cell;
  122. }break;
  123. default:break;
  124. }
  125. return nil;
  126. }
  127. - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
  128. [tableView deselectRowAtIndexPath:indexPath animated:YES];
  129. switch (indexPath.section) {
  130. case 0:{
  131. switch (indexPath.row) {
  132. case 0:{
  133. MyInfoVC *vc = [MyInfoVC initMyInfoVC];
  134. vc.hidesBottomBarWhenPushed = YES;
  135. [self.navigationController pushViewController:vc animated:YES];
  136. }break;
  137. default:
  138. break;
  139. }
  140. }break;
  141. case 1:{
  142. switch (indexPath.row) {
  143. case 0:{
  144. MyAccountVC *vc = [MyAccountVC initMyAccountVC];
  145. vc.hidesBottomBarWhenPushed = YES;
  146. [self.navigationController pushViewController:vc animated:YES];
  147. }break;
  148. case 1:{
  149. MyCardVC * vc = [MyCardVC initMyCardVC];
  150. vc.hidesBottomBarWhenPushed = YES;
  151. [self.navigationController pushViewController:vc animated:YES];
  152. }break;
  153. case 2:{
  154. MailListVC *vc = [MailListVC initMailListVC];
  155. vc.hidesBottomBarWhenPushed = YES;
  156. [self.navigationController pushViewController:vc animated:YES];
  157. }break;
  158. case 3:{
  159. [self scanAction];
  160. }break;
  161. default:
  162. {
  163. SettingVC *vc = [SettingVC initSettingVC];
  164. vc.hidesBottomBarWhenPushed = YES;
  165. [self.navigationController pushViewController:vc animated:YES];
  166. }
  167. break;
  168. }
  169. }break;
  170. default:
  171. break;
  172. }
  173. }
  174. - (void)PushSettingVC:(NSNotification *)notification
  175. {
  176. NSInteger index = [[notification.userInfo objectForKey:VCINDEX] integerValue];
  177. switch (index) {
  178. case 2:
  179. {
  180. MyFavoriteVC *vc = [MyFavoriteVC initMyFavoriteVC];
  181. vc.listType = MyFavoriteListLevelTypeA;
  182. vc.FolderId = 0;
  183. vc.operationStateEnum = OperationStateEnum0;
  184. vc.myTitle = @"我的收藏";
  185. vc.hidesBottomBarWhenPushed = YES;
  186. [self.navigationController pushViewController:vc animated:YES];
  187. }
  188. break;
  189. case 3:
  190. {
  191. NoteBookVC *vc = [NoteBookVC initNoteBookVC];
  192. vc.listType = MyNoteBookListLevelTypeA;
  193. vc.FolderId = 0;
  194. vc.myTitle = @"我的笔记";
  195. vc.VisitUserId = 0;
  196. vc.operationStateEnum = OperationStateEnum0;
  197. vc.hidesBottomBarWhenPushed = YES;
  198. [self.navigationController pushViewController:vc animated:YES];
  199. }
  200. break;
  201. case 4:
  202. {
  203. MailListVC * vc = [MailListVC initMailListVC];
  204. vc.hidesBottomBarWhenPushed = YES;
  205. [self.navigationController pushViewController:vc animated:YES];
  206. }
  207. break;
  208. default:
  209. {
  210. SettingVC *vc = [SettingVC initSettingVC];
  211. vc.hidesBottomBarWhenPushed = YES;
  212. [self.navigationController pushViewController:vc animated:YES];
  213. }
  214. break;
  215. }
  216. }
  217. - (void)scanAction{
  218. SWQRCodeConfig *config = [[SWQRCodeConfig alloc]init];
  219. config.scannerType = SWScannerTypeBoth;
  220. SWQRCodeViewController *qrcodeVC = [[SWQRCodeViewController alloc]init];
  221. qrcodeVC.codeConfig = config;
  222. qrcodeVC.delegate = self;
  223. [self.navigationController pushViewController:qrcodeVC animated:YES];
  224. }
  225. #pragma mark - 扫一扫结果
  226. - (void)scanResult:(NSString *)scanStr{
  227. ScanResultModel *model = [[ScanResultModel alloc]initWithString:scanStr error:nil];
  228. NSLog(@"%@",model);
  229. WEAKSELF
  230. switch (model.key) {
  231. case 1:// 用户
  232. {
  233. [self scanNetWork:model.value urlStrong:SaoYiSao_Post ScanKey:@"Guid" success:^(id responseObject) {
  234. NSDictionary *dic = responseObject;
  235. AddressUserModel *model = [[AddressUserModel alloc] initWithDictionary:dic error:nil];
  236. dispatch_async(dispatch_get_main_queue(), ^{
  237. MailListDetailVC *vc = [MailListDetailVC initMailListDetailVC];
  238. vc.indexId = model.Id;
  239. vc.isAdd = YES;
  240. [weakSelf.navigationController pushViewController:vc animated:YES];
  241. });
  242. } failure:^(NSError *error) {
  243. SHOWERROR([ZYCTool handerResultData:error]);
  244. }];
  245. }
  246. break;
  247. case 2:// 群聊
  248. {
  249. [self scanToNetWork:model.value urlStrong:SaoYiSao2_Post success:^(id responseObject) {
  250. ChatJoinGroupVC * vc = [ChatJoinGroupVC initChatJoinGroupVC];
  251. vc.dict = responseObject;
  252. [weakSelf.navigationController pushViewController:vc animated:YES];
  253. } failure:^(NSError *error) {
  254. SHOWERROR([ZYCTool handerResultData:error]);
  255. }];
  256. }
  257. break;
  258. case 3://小组
  259. {
  260. [self scanToNetWork:model.value urlStrong:SaoYiSao3_Post success:^(id responseObject) {
  261. if ([responseObject[@"IsUser"] boolValue]) {
  262. TDGroupInfoListVC * vc = [TDGroupInfoListVC initTDGroupInfoListVC];
  263. vc.GroupId = [responseObject[@"Id"] integerValue];
  264. vc.titleStr = responseObject[@"Name"];
  265. [weakSelf.navigationController pushViewController:vc animated:YES];
  266. }else{
  267. dispatch_async(dispatch_get_main_queue(), ^{
  268. TDQrJoinVC * vc = [TDQrJoinVC initTDQrJoinVC];
  269. vc.dict = responseObject;
  270. [weakSelf.navigationController pushViewController:vc animated:YES];
  271. });
  272. }
  273. } failure:^(NSError *error) {
  274. SHOWERROR([ZYCTool handerResultData:error]);
  275. }];
  276. }
  277. break;
  278. default:
  279. break;
  280. }
  281. }
  282. - (void)scanNetWork:(NSString *)scanStr urlStrong:(NSString *)urlstring ScanKey:(NSString*)key success:(void (^) (id responseObject))successful failure:(void (^) (NSError *error))failure{
  283. SHOWLOADING
  284. [[HttpManager sharedHttpManager] POSTUrl:[NSString stringWithFormat:@"%@%@",BaseUrl,urlstring] parameters:@{key:scanStr} responseStyle:JOSN success:^(id _Nonnull responseObject) {
  285. successful(responseObject);
  286. REMOVESHOW
  287. } failure:^(NSError * _Nonnull error) {
  288. REMOVESHOW
  289. failure(error);
  290. }];
  291. }
  292. - (void)scanToNetWork:(NSString *)scanStr urlStrong:(NSString *)urlstring success:(void (^) (id responseObject))successful failure:(void (^) (NSError *error))failure{
  293. SHOWLOADING
  294. NSString * url = [NSString stringWithFormat:@"%@%@",Host(urlstring),scanStr];
  295. [[HttpManager sharedHttpManager] GETUrl:url parameters:@{} success:^(id _Nonnull responseObject) {
  296. REMOVESHOW
  297. successful(responseObject);
  298. } failure:^(NSError * _Nonnull error) {
  299. REMOVESHOW
  300. }];
  301. }
  302. @end