| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241 |
- //
- // JOOAEmergencyViewController.m
- // shiku_im
- //
- // Created by jobor Zhou on 2016/10/10.
- // Copyright © 2016年 Reese. All rights reserved.
- //
- #import "JOOAEmergencyViewController.h"
- #import "AFNetworking.h"
- #import "LYAlerterView.h"
- @interface JOOAEmergencyViewController ()
- @end
- @implementation JOOAEmergencyViewController
- - (void)viewDidLoad {
- [super viewDidLoad];
- [self setupNav];
-
- [self setUpData];
-
- [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设置导航栏背景颜色
- //2设置导航栏背景颜色
-
- if (statusX) {
-
- [self.navigationController.navigationBar setBackgroundImage:[UIImage imageNamed:@"UU_newbg3"] forBarMetrics:UIBarMetricsDefault];
-
- }else{
-
- [self.navigationController.navigationBar setBackgroundImage:[UIImage imageNamed:@"UU_newbg2"] forBarMetrics:UIBarMetricsDefault];
-
- }
-
- //3设置导航栏左右按钮
- // UIButton * quxiao=[UIButton buttonWithType:UIButtonTypeCustom];
- 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 setLeftBarButtonItem:bbi2];
- self.navigationController.navigationBar.tintColor = [UIColor whiteColor];
-
-
- UIButton *rigntBtn = [UIButton new];
- rigntBtn.frame = CGRectMake(0, 0, 20, 20);
- UIImageView *imageView = [[UIImageView alloc]initWithFrame:CGRectMake(5, 5, 20, 20)];
- imageView.image = [UIImage imageNamed:@"crm_main_add"];
- [rigntBtn addSubview:imageView];
- [rigntBtn addTarget:self action:@selector(createHYB) forControlEvents:UIControlEventTouchUpInside];
- UIBarButtonItem *creatBtn = [[UIBarButtonItem alloc]initWithCustomView:rigntBtn];
- self.navigationItem.rightBarButtonItems = @[creatBtn];
-
- }
- - (void)createHYB
- {
- UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"请输入" message:@"" delegate:self cancelButtonTitle:Localized(@"UU_custom_cancle") otherButtonTitles:@"确定", nil];
- [alert setAlertViewStyle:UIAlertViewStylePlainTextInput];
- UITextField *txtName = [alert textFieldAtIndex:0];
- txtName.placeholder = @"请输入";
- [alert show];
-
- }
- -(void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex{
- if (buttonIndex == 1) {
-
- UITextField *txt = [alertView textFieldAtIndex:0];
-
- [self.navigationController dismissViewControllerAnimated:YES completion:^{
-
- self.selectDegree(txt.text);
- }];
-
-
- }
-
-
- }
- - (void)backView
- {
- [self dismissViewControllerAnimated:YES completion:nil];
- }
- - (void)backAddressName:(backDegree)selectDegree
- {
- self.selectDegree=selectDegree;
- }
- - (void)setUpData
- {
-
- if (self.dataArray.count==0)
- {
- self.dataArray=[[NSMutableArray alloc]initWithArray:@[@"紧急",@"非常紧急",@"一般",@"不急"]];
- [self.tableView reloadData];
-
- }else{
-
- if (!g_B2BUser)
- {
- [self getShangjiState];
- }
-
-
- }
-
-
-
- }
-
- -(void)getShangjiState //获取商机阶段数据
- {
- NSString *sessionId=[[NSUserDefaults standardUserDefaults] stringForKey:@"sessionId"];
- NSString *ip=[UASUserInfo shareManager].urlIp;
- NSString *master = [[[NSUserDefaults standardUserDefaults] objectForKey:@"masterDic"]objectForKey:@"ma_user"];
- NSString *sessionUser = [[NSUserDefaults standardUserDefaults] objectForKey:@"erpaccount"];
-
- NSString *url = [NSString stringWithFormat:@"%@mobile/crm/getBusinessChanceStage.action?sessionId=%@&master=%@&sessionUser=%@",ip,sessionId,master,sessionUser];
- url = [url stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
-
-
- UASNetworkManager *manager = [UASNetworkManager shareManager];
- manager.responseSerializer = [AFJSONResponseSerializer serializer];
- //拼接sessionID
- NSString *paramSessionId=[@"" stringByAppendingFormat:@"JSESSIONID=%@",sessionId];
- //设置cookie
- [manager.requestSerializer setValue:paramSessionId forHTTPHeaderField:@"Cookie"];
- [manager.requestSerializer setValue:[NSString stringWithFormat:@"%@",g_sessionUser] forHTTPHeaderField:@"sessionUser"];
- [manager request:url method:POST parameters:nil progress:nil success:^(NSURLSessionDataTask *task, id responseObject) {
- DLog(@"------:%@",responseObject);
- NSString *sessionId = [NSString stringWithFormat:@"%@",responseObject[@"sessionId"]];
- if (![sessionId isEqualToString:@"(null)"]) {
- [[NSUserDefaults standardUserDefaults] setObject:sessionId forKey:@"sessionId"];
- }
-
- NSMutableArray * arr=[[NSMutableArray alloc]init];
- for (id obj in responseObject[@"stages"]) {
-
-
- [arr addObject:[obj objectForKey:@"BS_NAME"]];
- }
- for (int i=0; i<self.dataArray.count; i++)
- {
- [arr insertObject:self.dataArray[i] atIndex:0];
- }
-
- self.dataArray=nil;
-
-
- self.dataArray=[[NSMutableArray alloc]initWithArray:arr];
- [self.tableView reloadData];
-
- } failure:^(NSURLSessionDataTask *task, NSError *error) {
- DLog(@"请求失败:%@",error);
- [JOShowMessageFromNavi showDropViewWithMessage:@"商机阶段数据请求失败" ToNavi:self.navigationController withColor:nil];
- }];
- }
- - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
- {
- [tableView deselectRowAtIndexPath:indexPath animated:NO];
- [self.navigationController dismissViewControllerAnimated:YES completion:^{
-
- self.selectDegree(self.dataArray[indexPath.row]);
- }];
- }
- - (NSInteger )tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
- {
- return self.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=self.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
|