| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214 |
- //
- // JOGETAddressTableViewController.m
- // shiku_im
- //
- // Created by jobor Zhou on 16/9/29.
- // Copyright © 2016年 Reese. All rights reserved.
- //
- #import "JOGETAddressTableViewController.h"
- #import "UITableView+WFEmpty.h"
- @interface JOGETAddressTableViewController ()
- {
- NSMutableArray * _dataArray;
- NSMutableArray * _dataBrray;
- }
- @end
- @implementation JOGETAddressTableViewController
- - (void)viewDidLoad {
-
- [super viewDidLoad];
- _dataArray=[[NSMutableArray alloc]init];
- _dataBrray=[[NSMutableArray alloc]init];
-
- [self setupNav];
-
- [self getDataFromServer];
-
- [self setExtraCellLineHidden:self.tableView];
- }
- /**
- * 设置导航栏内容
- */
- - (void)setupNav
- {
-
- //1,设置标题
- UILabel * laebl=[[UILabel alloc]initWithFrame:CGRectMake(0,0,200,40)];
- laebl.text=@"请选择会议地点";
- laebl.font=FONT_SIZE(18);
- laebl.textAlignment=1;
- laebl.textColor=[UIColor whiteColor];
- self.navigationItem.titleView=laebl;
-
- //2设置导航栏背景颜色
-
- if(iPhoneX){
-
- [self.navigationController.navigationBar setBackgroundImage:[UIImage imageNamed:@"UU_newPG0X"] forBarPosition:UIBarPositionAny barMetrics:UIBarMetricsDefault];
-
- }else{
-
- [self.navigationController.navigationBar setBackgroundImage:[UIImage imageNamed:@"UU_newPG0"] forBarPosition:UIBarPositionAny barMetrics:UIBarMetricsDefault];
-
- }
-
- //3设置导航栏左右按钮
- UIButton *btn2 = [UIButton buttonWithType:UIButtonTypeSystem];
- btn2.frame = CGRectMake(0, 5, 22, 22);
- UIImageView *image = [[UIImageView alloc]initWithFrame:CGRectMake(0, iOS11?5:0, 22, 22)];
- image.image = [UIImage imageNamed:@"icon_back_nor3"];
- [btn2 addSubview:image];
- [btn2 addTarget:self action:@selector(backView) forControlEvents:UIControlEventTouchUpInside];
- UIBarButtonItem *bbi2 = [[UIBarButtonItem alloc]initWithCustomView:btn2];
- self.navigationItem.leftBarButtonItems = @[bbi2];
- self.navigationController.navigationBar.tintColor = [UIColor whiteColor];
-
- }
- - (void)backView
- {
- [self dismissViewControllerAnimated:YES completion:nil];
- }
- - (void)backAddressName:(backAddress)selectAddressName
- {
- self.selectAddressName=selectAddressName;
- }
- - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
- {
- [self.navigationController dismissViewControllerAnimated:YES completion:^{
-
- self.selectAddressName(_dataArray[indexPath.row],_dataBrray[indexPath.row]);
- }];
- }
- - (void)getDataFromServer
- {
- [_dataArray removeAllObjects];
- //1,创建一个网络请求管理对象
- UASNetworkManager *manager1 = [UASNetworkManager shareManager];
- manager1.responseSerializer=[AFHTTPResponseSerializer serializer];
-
- //2,取出sessionID和IP
- NSUserDefaults *userDefault=[NSUserDefaults standardUserDefaults];
-
- NSString *sessionId=[userDefault stringForKey:@"sessionId"];
-
- NSString * ips=[UASUserInfo shareManager].urlIp;
-
- NSString * userID=[userDefault objectForKey:@"erpaccount"];
- //3.拼接sessionID
- NSString *paramSessionId=[@"" stringByAppendingFormat:@"JSESSIONID=%@",sessionId];
- //4.设置cookie
- [manager1.requestSerializer setValue:paramSessionId forHTTPHeaderField:@"Cookie"];
-
- NSString *currentMaster=[[userDefault objectForKey:@"masterDic"] objectForKey:@"ma_user"];
- /**
- url:http://218.17.158.219:8090/ERP//mobile/common/list.action
- parms:{emcode=CHENAP, condition=1=1, sessionId=2E3D6B1C3725FC641C5E381A4D95F01B, caller=MeetingRoom, page=1, currentMaster=UAS, pageSize=30}
- */
-
- //param.put('condition', 'mr_statuscode='AUDITED'');
- //5,接口
- NSString * urlAddress=@"mobile/common/list.action";
-
- NSString * caller=@"MeetingRoom";
-
- NSString *url=[@"" stringByAppendingFormat:@"%@%@?emcode=%@&condition=%@&sessionId=%@&caller=%@&page=%@¤tMaster=%@&pageSize=%@",ips,urlAddress,userID,@"mr_statuscode='AUDITED'",sessionId,caller,@"1",currentMaster,@"30"];
-
-
- DLog(@"url=%@",url);
-
-
- //7.二进制数据转换
- NSString *urlStringUTF8 = [url stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
- [manager1 request:url method:GET parameters:nil progress:nil success:^(NSURLSessionDataTask *task, id responseObject) {
- NSData *data=responseObject;
- //1,系统自带的nsjson解析数据
- id rootDic =[NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingMutableContainers error:nil];
- // DLog(@"请求会议标签成功:%@",rootDic);
-
- if ([[rootDic allKeys] containsObject:@"sessionId"]==YES)
- {
- NSString * sessionId=[NSString stringWithFormat:@"%@",[rootDic objectForKey:@"sessionId"]];
- [[NSUserDefaults standardUserDefaults] setObject:sessionId forKey:@"sessionId"];
- }
- /**
- "mr_code" = 2016070001;
- "mr_name" = test;
- */
-
- NSMutableArray * arr=[[NSMutableArray alloc]init];
- arr=[rootDic objectForKey:@"listdata"];
-
- for (NSDictionary * obj in arr)
- {
- [_dataArray addObject:[NSString stringWithFormat:@"%@",[obj objectForKey:@"mr_name"]] ];
- [_dataBrray addObject:[NSString stringWithFormat:@"%@",[obj objectForKey:@"mr_code"]]];
-
- }
-
- if(_dataArray.count == 0)
- {
- [self.tableView addEmptyViewWithImageName:@"crm_all_noData" title:@""];
- }
- [self.tableView reloadData];
-
- } failure:^(NSURLSessionDataTask *task, NSError *error) {
- DLog(@"什么错误呀==%@",error);
- [self.tableView addEmptyViewWithImageName:@"crm_all_noData" title:@""];
- [((AppDelegate*)[[UIApplication sharedApplication] delegate]) showAlertController:self withMessage:@"获取失败"];
- }];
-
- }
- - (NSInteger )tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
- {
- return _dataArray.count;
-
- }
- - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
- {
- static NSString *identifier = @"cell";
- UITableViewCell * cell=[[UITableViewCell alloc]initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:identifier];
- cell.selectionStyle = UITableViewCellSelectionStyleNone;
-
- cell.backgroundColor=[UIColor whiteColor];
-
- cell.textLabel.text=_dataArray[indexPath.row];
- cell.textLabel.font = FONT_SIZE(15);
- return cell;
- }
- -(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
- {
- return 40 + cellScale;
- }
- /**
- 去掉分割线
- */
- - (void)setExtraCellLineHidden: (UITableView *)tableView
- {
-
- UIView *view = [UIView new];
-
- view.backgroundColor = [UIColor clearColor];
-
- [tableView setTableFooterView:view];
- }
- @end
|