informReportViewController.m 7.29 KB
//
//  informReportViewController.m
//  IVTMeLiveTwo
//
//  Created by xrg on 16/9/8.
//  Copyright © 2016年 QLQ. All rights reserved.
//

#import "informReportViewController.h"
#import "Masonry.h"
#import "UIFont+IVTMeFont.h"
#import "UIColor+IVTMeColor.h"
#import "SVProgressHUD.h"
#import "AFNetworking.h"
#import "AFURLSessionManager.h"
@interface informReportViewController ()
{
    NSArray *juBaoContentArray;
    NSInteger currentSelectedRow;
}

@property (nonatomic, strong) UITableView *informTabelView;
@property (nonatomic, retain) NSIndexPath *selectedIndexPath;
@end

@implementation informReportViewController

- (void)viewDidLoad {
    
    [super viewDidLoad];
    
    juBaoContentArray = [NSArray arrayWithObjects:@"色情低俗",@"政治敏感",@"谣言",@"欺诈骗钱",@"违法(暴力恐怖、违禁品等)",@"未成年",@"其他", nil];
    currentSelectedRow = 0;

    
    [self creatTableView];
    
    [self setNavigationBar];
    
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}
-(void)initNavView{
    self.navigationItem.title = @"举报";
    
//    __unsafe_unretained typeof (self) wself = self;
//    //整体背景nav view
//    UIView* navBgView = [[UIView alloc] init];
//    [self.view addSubview:navBgView];
//    navBgView.backgroundColor = [UIColor IVTLightRedColor];
//    [navBgView mas_makeConstraints:^(MASConstraintMaker* make) {
//        make.left.equalTo(wself.view.mas_left);
//        make.right.equalTo(wself.view.mas_right);
//        make.top.equalTo(@0);
//        make.height.equalTo(@58);
//    }];
//    
//    
//    UILabel *message = [[UILabel alloc]init];
//    [navBgView addSubview:message];
//    message.text =@"举报";
//    message.textColor = [UIColor IVTTitleColor];
//    message.font = [UIFont YXFontOfSize:19];
//    [message mas_makeConstraints:^(MASConstraintMaker *make) {
//        make.centerX.equalTo(navBgView.mas_centerX);
//        make.top.equalTo(wself.view.mas_top).with.offset(29);
//        make.size.mas_equalTo(CGSizeMake(50.0f, 19.0f));
//    }];
//    
//    
//    //背景nav 返回上级页面按钮
//    UIButton* backButton = [UIButton buttonWithType:UIButtonTypeCustom];
//    [navBgView addSubview:backButton];
//    UIImage* navImage = [UIImage imageNamed:@"返回键"];
//    [backButton mas_makeConstraints:^(MASConstraintMaker* make) {
//        make.left.equalTo(wself.view);
//        make.top.equalTo(wself.view.mas_top).with.offset(18);
//        make.size.mas_equalTo(CGSizeMake(40, 40));
//        
//    }];
//    [backButton setImage:navImage forState:UIControlStateNormal];
//    backButton.imageEdgeInsets = UIEdgeInsetsMake(5,5,5,5);
//    [backButton addTarget:self action:@selector(backToTopPage:) forControlEvents:UIControlEventTouchUpInside];
//    
//    
//    
//    
//    UIButton *okBtn = [UIButton buttonWithType:UIButtonTypeCustom];
//    [navBgView addSubview:okBtn];
//    [okBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
//    [okBtn setTitle:@"确定" forState:UIControlStateNormal];
//    [okBtn addTarget:self action:@selector(sendInform:) forControlEvents:UIControlEventTouchUpInside];
//    okBtn.titleLabel.font = [UIFont YXFontOfSize:15];
//    [okBtn mas_makeConstraints:^(MASConstraintMaker *make) {
//        
//        make.size.mas_equalTo(CGSizeMake(40, 15.0f));
//        make.top.equalTo(navBgView.mas_top).with.offset(32);
//        make.trailing.equalTo(navBgView.mas_trailing).with.offset(-10);
//    }];
    
}

- (void)setNavigationBar{
    self.navigationItem.title = @"昵称";
    UIBarButtonItem *rightBarButton = [[UIBarButtonItem alloc]initWithTitle:@"保存" style:UIBarButtonItemStylePlain target:self action:@selector(sendInform:)];
    rightBarButton.tintColor = [UIColor whiteColor];
    self.navigationItem.rightBarButtonItem = rightBarButton;
}

- (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
{
    
//    NSDictionary *dict1 = @{@"userId":@([[IVTAccountTool getUserId] intValue]),@"liveId":@([self.liveId intValue]),@"reason":juBaoContentArray[currentSelectedRow]};
    
    UIImage *imagePicker = [UIImage imageNamed:@"用户详情--用户--占位头像"];
    NSData *imageData = UIImageJPEGRepresentation(imagePicker, 1);
    //    UIImage *image = [UIImage imageWithData:imageData];
    NSDictionary *dict1 = @{@"userId":@([[IVTAccountTool getUserId] intValue]),@"liveId":@([self.liveId intValue]),@"reason":juBaoContentArray[currentSelectedRow]};
    

    
    [[IVTNetworkAPIClient sharedClient] sendReprot:imageData paramDict:dict1 success:^(NSDictionary *successData) {
        LRLog(@"success");
        [SVProgressHUD setMinimumDismissTimeInterval:2];
        [SVProgressHUD showSuccessWithStatus:@"举报成功!"];
        [self.navigationController popViewControllerAnimated:YES];
    } error:^(NSDictionary *successData) {
        
    } failure:^(NSError *failureError) {
        LRLog(@"failure:%@",failureError);
    }];

}



//取消按钮点击
-(void)backToTopPage:(id)sender{
    
    [self.navigationController popViewControllerAnimated:YES];
    
}
/*
 #pragma mark - Navigation
 
 // In a storyboard-based application, you will often want to do a little preparation before navigation
 - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
 // Get the new view controller using [segue destinationViewController].
 // Pass the selected object to the new view controller.
 }
 */

@end