IVTInformViewController.m 4.52 KB
//
//  IVTInformViewController.m
//  IVTMeLiveTwo
//
//  Created by xrg on 16/10/14.
//  Copyright © 2016年 QLQ. All rights reserved.
//

#import "IVTInformViewController.h"
#import "Masonry.h"
#import "UIFont+IVTMeFont.h"
#import "UIColor+IVTMeColor.h"
#import "SVProgressHUD.h"
#import "AFNetworking.h"
#import "AFURLSessionManager.h"


@interface IVTInformViewController ()<UITableViewDataSource,UITableViewDelegate>
{
    NSArray *juBaoContentArray;
    NSInteger currentSelectedRow;
}
@property (nonatomic, strong) UITableView *informTabelView;
@property (nonatomic, retain) NSIndexPath *selectedIndexPath;
@end
@implementation IVTInformViewController
- (void)viewDidLoad {
    
    [super viewDidLoad];
    
    juBaoContentArray = [NSArray arrayWithObjects:@"色情低俗",@"政治敏感",@"谣言",@"欺诈骗钱",@"违法(暴力恐怖、违禁品等)",@"未成年",@"其他", nil];
    currentSelectedRow = 0;
    
    [self creatTableView];
    
    //    _stateDic = [[NSMutableDictionary alloc] initWithDictionary:[[NSUserDefaults standardUserDefaults] objectForKey:@"state"]];
    
    //    NSInteger row =  [[[NSUserDefaults standardUserDefaults] objectForKey:@"lastRow"] integerValue];
    
    //    self.selectedIndexPath = [NSIndexPath indexPathForRow:row inSection:0];
    
    // Do any additional setup after loading the view.
}
- (void)creatTableView
{
    _informTabelView = [[UITableView alloc] initWithFrame:CGRectMake(0, 0,kScreenWidth ,kScreenHeight) style:UITableViewStyleGrouped];
    _informTabelView.delegate = self;
    _informTabelView.dataSource = self;
    
    _informTabelView.backgroundColor = [UIColor IVTBackgroundColor];
    [self.view addSubview:_informTabelView];
}

#pragma mark - tableview代理方法
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return 7;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *CellIdentifier = @"Cell";
    
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    if (cell == nil) {
        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
    }
    if (indexPath.row == currentSelectedRow) {
        cell.accessoryType = UITableViewCellAccessoryCheckmark;
    }
    else{
        cell.accessoryType = UITableViewCellAccessoryNone;
    }
    cell.textLabel.text = [juBaoContentArray objectAtIndex:indexPath.row];
    
    
    return cell;
    
}


- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    if (currentSelectedRow != indexPath.row) {
        NSIndexPath *oldSelectedIndexPath = [NSIndexPath indexPathForRow:currentSelectedRow inSection:0];
        currentSelectedRow = indexPath.row;
        
        [tableView reloadRowsAtIndexPaths:[NSArray arrayWithObjects:oldSelectedIndexPath,indexPath, nil] withRowAnimation:UITableViewRowAnimationFade];
    }
}

- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section
{
    return @"请选择举报原因";
}

- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
    return 40;
}

- (void)sendInform:(id)sender
{
    //    dic = @{@"Membership_Id1":@(10016)}
    
    UIImage *imagePicker = [UIImage imageNamed:@"返回键"];
    NSData *imageData = UIImageJPEGRepresentation(imagePicker, 0.4);
    //    UIImage *image = [UIImage imageWithData:imageData];
    NSDictionary *dict1 = @{@"userId":@([[IVTAccountTool getUserId] intValue]),@"liveId":@([self.liveId intValue]),@"reason":juBaoContentArray[currentSelectedRow]};
    
    //    [[IVTNetworkAPIClient sharedClient] sendReprot:imageData success:^(NSDictionary *successData) {
    //        LRLog(@"~");
    //    } error:^(ErrorCode errorCode) {
    //        LRLog(@"~");
    //    } failure:^(NSError *failureError) {
    //        LRLog(@"~");
    //    }];
    
    [[IVTNetworkAPIClient sharedClient] sendReprot:imageData paramDict:dict1 success:^(NSDictionary *successData) {
        LRLog(@"~");
    } error:^(NSDictionary *successData) {
//        LRLog(@"~");
    } failure:^(NSError *failureError) {
        LRLog(@"~");
    }];
}



//取消按钮点击
-(void)backToTopPage:(id)sender{
    
    [self.navigationController popViewControllerAnimated:YES];
    
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end