My_CenterVC.m 11 KB

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