My_CenterVC.m 12 KB

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