123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318 |
- //
- // My_CenterVC.m
- // smartRhino
- //
- // Created by armin on 2019/11/1.
- // Copyright © 2019 tederen. All rights reserved.
- //
- #import "My_CenterVC.h"
- #import "My_CenterCell.h"
- #import "MyInfoVC.h"
- #import "SettingVC.h"
- #import "FavoritesViewController.h"
- #import "MyFavoriteVC.h"
- #import "MyCardVC.h"
- #import "NoteBookVC.h"
- #import "MyAccountVC.h"
- #import "MailListVC.h"
- #import "SWQRCodeViewController.h"
- #import "MailListDetailVC.h"
- #import "ChatJoinGroupVC.h"
- #import "TDGroupInfoListVC.h"
- #import "TDQrJoinVC.h"
- #import "LoginPCVC.h"
- @interface My_CenterVC ()<UITableViewDelegate,UITableViewDataSource,SWQRCodeViewControllerDelegate>
- @property (strong,nonatomic) IBOutlet UITableView *tableView;
- @end
- @implementation My_CenterVC
- - (void)viewDidLoad {
- [super viewDidLoad];
-
- self.fd_prefersNavigationBarHidden = YES;
- self.view.backgroundColor = RGB(240, 239, 244);
-
- self.tableView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
- [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(PushSettingVC:) name:DRAWERPUSHVC object:nil];
- self.tableView.delegate = self;
- self.tableView.dataSource = self;
- [self.tableView setScrollEnabled:NO];
- self.tableView.backgroundColor = [UIColor clearColor];
- self.tableView.estimatedRowHeight = 0;
- self.tableView.estimatedSectionHeaderHeight = 0;
- self.tableView.estimatedSectionFooterHeight = 0;
- [UserManager getUserInfoDetail];
- }
- - (void)dealloc
- {
- [[NSNotificationCenter defaultCenter] removeObserver:self];
- }
- - (void)viewWillAppear:(BOOL)animated{
- [super viewWillAppear:animated];
- [self.tableView reloadData];
- }
- - (BOOL)hidesBottomBarWhenPushed
- {
- return NO;
- }
- - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
- return 2;
- }
- - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
- switch (section) {
- case 0:{
- return 1;
- }break;
- default:{
- return 5;
- }break;
- }
- }
- - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
- switch (indexPath.section) {
- case 0:{
- return [My_CenterCell configCell0Height];
- }break;
- default:{
- return [My_CenterCell configCell1Height];
- }break;
- }
- }
- - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
- switch (indexPath.section) {
- case 0:{
- My_CenterCell *cell = [My_CenterCell configCell0:tableView indexPath:indexPath];
- [cell.cell0UserImgView sd_setImageWithURL:[NSURL URLWithString:[AppUserModel sharedAppUserModel].AvatarUrl] placeholderImage:[UIImage imageNamed:@"my_conter_TestUserImg"]];
- NSLog(@"%@",[AppUserModel sharedAppUserModel].Name);
- cell.cell0UserName.text = [AppUserModel sharedAppUserModel].Name;
- cell.cell0Intrt.text = ISEmptyString([AppUserModel sharedAppUserModel].Description) ? @"自我介绍":[AppUserModel sharedAppUserModel].Description ;
- return cell;
- }break;
- default:{
- My_CenterCell *cell = [My_CenterCell configCell1:tableView indexPath:indexPath];
- switch (indexPath.row) {
- case 0: {
- cell.cell1IconImg.image = [UIImage imageNamed:@"mine_account"];
- cell.cell1TitleLabel.text = @"账户";
- }break;
- case 1: {
- cell.cell1IconImg.image = [UIImage imageNamed:@"mine_wuxianka"];
- cell.cell1TitleLabel.text = @"无限卡";
- }break;
- case 2: {
- cell.cell1IconImg.image = [UIImage imageNamed:@"mine_txl_icon"];
- cell.cell1TitleLabel.text = @"通讯录";
- }break;
- case 3: {
- cell.cell1IconImg.image = [UIImage imageNamed:@"mine_scan"];
- cell.cell1TitleLabel.text = @"扫一扫";
- }break;
- default:
- {
- cell.cell1IconImg.image = [UIImage imageNamed:@"my_conter_setting_icon"];
- cell.cell1TitleLabel.text = @"设置";
- }
- break;
- }
- return cell;
- }break;
- }
- }
- - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
- [tableView deselectRowAtIndexPath:indexPath animated:YES];
- switch (indexPath.section) {
- case 0:{
- switch (indexPath.row) {
- case 0:{
- MyInfoVC *vc = [MyInfoVC initMyInfoVC];
- vc.hidesBottomBarWhenPushed = YES;
- [self.navigationController pushViewController:vc animated:YES];
- }break;
- default:
- break;
- }
- }break;
- default:{
- switch (indexPath.row) {
- case 0:{
- MyAccountVC *vc = [MyAccountVC initMyAccountVC];
- vc.hidesBottomBarWhenPushed = YES;
- [self.navigationController pushViewController:vc animated:YES];
- }break;
- case 1:{
- MyCardVC * vc = [MyCardVC initMyCardVC];
- vc.hidesBottomBarWhenPushed = YES;
- [self.navigationController pushViewController:vc animated:YES];
- }break;
- case 2:{
- MailListVC *vc = [MailListVC initMailListVC];
- vc.hidesBottomBarWhenPushed = YES;
- [self.navigationController pushViewController:vc animated:YES];
- }break;
- case 3:{
- [self scanAction];
- }break;
- default:
- {
- SettingVC *vc = [SettingVC initSettingVC];
- vc.hidesBottomBarWhenPushed = YES;
- [self.navigationController pushViewController:vc animated:YES];
- }
- break;
- }
- }break;
- }
-
- }
- - (void)PushSettingVC:(NSNotification *)notification
- {
- NSInteger index = [[notification.userInfo objectForKey:VCINDEX] integerValue];
- switch (index) {
- case 2:
- {
- MyFavoriteVC *vc = [MyFavoriteVC initMyFavoriteVC];
- vc.listType = MyFavoriteListLevelTypeA;
- vc.FolderId = 0;
- vc.operationStateEnum = OperationStateEnum0;
- vc.myTitle = @"我的收藏";
- vc.hidesBottomBarWhenPushed = YES;
- [self.navigationController pushViewController:vc animated:YES];
- }
- break;
- case 3:
- {
- NoteBookVC *vc = [NoteBookVC initNoteBookVC];
- vc.listType = MyNoteBookListLevelTypeA;
- vc.FolderId = 0;
- vc.myTitle = @"我的笔记";
- vc.VisitUserId = 0;
- vc.operationStateEnum = OperationStateEnum0;
- vc.hidesBottomBarWhenPushed = YES;
- [self.navigationController pushViewController:vc animated:YES];
- }
- break;
- case 4:
- {
- MailListVC * vc = [MailListVC initMailListVC];
- vc.hidesBottomBarWhenPushed = YES;
- [self.navigationController pushViewController:vc animated:YES];
- }
- break;
- default:
- {
- SettingVC *vc = [SettingVC initSettingVC];
- vc.hidesBottomBarWhenPushed = YES;
- [self.navigationController pushViewController:vc animated:YES];
- }
- break;
- }
- }
- - (void)scanAction{
- SWQRCodeConfig *config = [[SWQRCodeConfig alloc]init];
- config.scannerType = SWScannerTypeBoth;
- SWQRCodeViewController *qrcodeVC = [[SWQRCodeViewController alloc]init];
- qrcodeVC.codeConfig = config;
- qrcodeVC.delegate = self;
- [self.navigationController pushViewController:qrcodeVC animated:YES];
- }
- #pragma mark - 扫一扫结果
- - (void)scanResult:(NSString *)scanStr{
- ScanResultModel *model = [[ScanResultModel alloc]initWithString:scanStr error:nil];
- NSLog(@"%@",model);
- WEAKSELF
- switch (model.key) {
- case 1:// 用户
- {
- [self scanNetWork:model.value urlStrong:SaoYiSao_Post ScanKey:@"Guid" success:^(id responseObject) {
- NSDictionary *dic = responseObject;
- AddressUserModel *model = [[AddressUserModel alloc] initWithDictionary:dic error:nil];
- dispatch_async(dispatch_get_main_queue(), ^{
- MailListDetailVC *vc = [MailListDetailVC initMailListDetailVC];
- vc.indexId = model.Id;
- vc.isAdd = YES;
- [weakSelf.navigationController pushViewController:vc animated:YES];
- });
- } failure:^(NSError *error) {
- SHOWERROR([ZYCTool handerResultData:error]);
- }];
- }
- break;
- case 2:// 群聊
- {
- [self scanToNetWork:model.value urlStrong:SaoYiSao2_Post success:^(id responseObject) {
- ChatJoinGroupVC * vc = [ChatJoinGroupVC initChatJoinGroupVC];
- vc.dict = responseObject;
- [weakSelf.navigationController pushViewController:vc animated:YES];
- } failure:^(NSError *error) {
- SHOWERROR([ZYCTool handerResultData:error]);
- }];
- }
- break;
- case 3://小组
- {
- [self scanToNetWork:model.value urlStrong:SaoYiSao3_Post success:^(id responseObject) {
- if ([responseObject[@"IsUser"] boolValue]) {
- TDGroupInfoListVC * vc = [TDGroupInfoListVC initTDGroupInfoListVC];
- vc.GroupId = [responseObject[@"Id"] integerValue];
- vc.titleStr = responseObject[@"Name"];
- [weakSelf.navigationController pushViewController:vc animated:YES];
- }else{
- dispatch_async(dispatch_get_main_queue(), ^{
- TDQrJoinVC * vc = [TDQrJoinVC initTDQrJoinVC];
- vc.dict = responseObject;
- [weakSelf.navigationController pushViewController:vc animated:YES];
- });
- }
- } failure:^(NSError *error) {
- SHOWERROR([ZYCTool handerResultData:error]);
- }];
- }
- break;
- case 4://扫码登录
- {
- LoginPCVC * vc = [[LoginPCVC alloc] init];
- vc.key = model.value;
- vc.modalPresentationStyle = UIModalPresentationFullScreen;
- [self presentViewController:vc animated:YES completion:^{
-
- }];
- }
- break;
- default:
- break;
- }
- }
- - (void)scanNetWork:(NSString *)scanStr urlStrong:(NSString *)urlstring ScanKey:(NSString*)key success:(void (^) (id responseObject))successful failure:(void (^) (NSError *error))failure{
- SHOWLOADING
- [[HttpManager sharedHttpManager] POSTUrl:[NSString stringWithFormat:@"%@%@",BaseUrl,urlstring] parameters:@{key:scanStr} responseStyle:JOSN success:^(id _Nonnull responseObject) {
- successful(responseObject);
- REMOVESHOW
- } failure:^(NSError * _Nonnull error) {
- REMOVESHOW
- failure(error);
- }];
- }
- - (void)scanToNetWork:(NSString *)scanStr urlStrong:(NSString *)urlstring success:(void (^) (id responseObject))successful failure:(void (^) (NSError *error))failure{
- SHOWLOADING
- NSString * url = [NSString stringWithFormat:@"%@%@",Host(urlstring),scanStr];
- [[HttpManager sharedHttpManager] GETUrl:url parameters:@{} success:^(id _Nonnull responseObject) {
- REMOVESHOW
- successful(responseObject);
- } failure:^(NSError * _Nonnull error) {
- REMOVESHOW
- }];
- }
- @end
|