ifish/Ifish/controllers/IfishTabControllers/探索/lookafterWorkbech/LookAfterReportViewControll...

286 lines
8.5 KiB
Objective-C

//
// LookAfterReportViewController.m
// Ifish
//
// Created by imac on 16/8/30.
// Copyright © 2016年 lianxiang. All rights reserved.
//
#import "LookAfterReportViewController.h"
#import "LookReportViewCell.h"
#import "Report2ViewCell.h"
#import "Report3ViewCell.h"
#import "Reprt4ViewCell.h"
#import "PingfenModel.h"
#import "UIImageView+WebCache.h"
#import "Report5ViewCell.h"
@interface LookAfterReportViewController ()<UITableViewDelegate,UITableViewDataSource,UITextFieldDelegate>
@end
@implementation LookAfterReportViewController
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view.
self.title = @"看护报告";
[self setDatas];
[self setUI];
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
-(void)setDatas{
self.titleDataArr= @[@"水质观察:",@"喂食提醒:",@"健康状况:"];
self.desDataArr = @[self.baGaoMod.timestamp,];
}
-(void)setUI{
self.tableView = [[UITableView alloc] init ];
self.tableView.frame =CGRectMake(0,0, self.view.frame.size.width,self.view.frame.size.height);
self.tableView.delegate = self;
self.tableView.dataSource = self;
self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
self.tableView.showsVerticalScrollIndicator = NO;
self.tableView.backgroundColor = TABLE_BACKGROUD_COLOR;
[self.view addSubview:self.tableView];
}
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
return 8;
}
-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
return 1;
}
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
if (indexPath.row ==0) {
LookReportViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"LookReportViewCell"];
if (!cell) {
cell = [[[NSBundle mainBundle]loadNibNamed:@"LookReportViewCell" owner:self options:nil]lastObject];
}
// UIImage *image=[Utils shopsGetImgeWithCameraId:self.listModel.cameraId];
//
// if (image) {
// cell.lastCameraImg.image = image;
// }else{
//
// cell.lastCameraImg.image =LXImageWithImageName(@"ic_header.png");
// }
NSString *imhUrl = [NSString stringWithFormat:@"%@%@",kGetKanHuUrl,self.baGaoMod.shareImg];
[cell.lastCameraImg sd_setImageWithURL:[NSURL URLWithString:imhUrl] placeholderImage:[UIImage imageNamed:@"ic_header.png"]];
cell.selectionStyle = UITableViewCellSelectionStyleNone;
[cell cellSetBackViewCorner];
return cell;
}else if (indexPath.row >=1 && indexPath.row <=4){
Report2ViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"Report2ViewCell"];
if (!cell) {
cell = [[[NSBundle mainBundle]loadNibNamed:@"Report2ViewCell" owner:self options:nil]lastObject];
}
cell.selectionStyle = UITableViewCellSelectionStyleNone;
if (indexPath.row ==1) {
cell.fenLabel.hidden = YES;
cell.titleCateLabel.text = @"看护时刻:";
cell.descLabel.text = self.baGaoMod.timestamp;
}else{
cell.titleCateLabel.text = self.titleDataArr[indexPath.row -2];
PingfenModel *pfModel = self.pinFenArr[indexPath.row -2];
cell.descLabel.text = pfModel.pingFenDesc;
cell.fenLabel.text =[NSString stringWithFormat:@"+%@",pfModel.pingFenNumber];
}
return cell;
}else if (indexPath.row == 5){
Report3ViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"Report3ViewCell"];
if (!cell) {
cell = [[[NSBundle mainBundle]loadNibNamed:@"Report3ViewCell" owner:self options:nil]lastObject];
}
cell.JianYiLabel.text = self.suggesttrue;
cell.selectionStyle = UITableViewCellSelectionStyleNone;
return cell;
}else if (indexPath.row == 6){
Report5ViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"Report5ViewCell"];
if (!cell) {
cell = [[[NSBundle mainBundle]loadNibNamed:@"Report5ViewCell" owner:self options:nil]lastObject];
}
cell.pingFenLabel.text = [NSString stringWithFormat:@"得分:%@分",self.baGaoMod.totalIndex];
cell.pingFenDescreaption.text =[NSString stringWithFormat:@"您的得分,击败了全国%@%的鱼友",self.baGaoMod.baifenbi];
cell.selectionStyle = UITableViewCellSelectionStyleNone;
return cell;
}else if (indexPath.row == 7){
Reprt4ViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"Reprt4ViewCell"];
if (!cell) {
cell = [[[NSBundle mainBundle]loadNibNamed:@"Reprt4ViewCell" owner:self options:nil]lastObject];
}
cell.selectionStyle = UITableViewCellSelectionStyleNone;
CertificationShopModel *ShopsInfo= [[DataCenter defaultDtacenter] valueForKey:@"ShopsInfo"];
[cell.shangJiaImg sd_setImageWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@%@",kGetIconUrl,ShopsInfo.userImg]] placeholderImage:[UIImage imageNamed:@""]];
cell.shangJiaName.text = ShopsInfo.shopsName;
UserModel*umodel=[[DataCenter defaultDtacenter]valueForKey:@"UserLogIn"];
cell.shangJiadetail.text = umodel.signature;
[cell.faSongBtn addTarget:self action:@selector(faSongBtnClick:) forControlEvents:UIControlEventTouchUpInside];
[cell.faSongBtn setTitleColor:[UIColor lightGrayColor] forState:UIControlStateSelected];
[cell cellSetBackViewCorner];
return cell;
}
return nil;
}
#pragma mark - 发送看护报告
-(void)faSongBtnClick:(UIButton*)btn{
btn.userInteractionEnabled =NO;
[self.view makeToastActivity];
[AFNOHeaderHttpTool sendReportWithUserId:self.listModel.userId baoGaoHtmlName:self.baGaoMod.fileName reportId:self.baGaoMod.reportId success:^(id response) {
NSDictionary*resultDic=[NSJSONSerialization JSONObjectWithData:response options:NSJSONReadingMutableContainers error:nil];
NSLog(@"result:%@",resultDic[@"result"]);
if ([resultDic[@"result"] isEqualToString:@"100"]) {
btn.userInteractionEnabled =YES;
[self.view hideToastActivity];
[self.view makeToast:@"发送成功"];
_getInfTimer = [NSTimer scheduledTimerWithTimeInterval:2 target:self selector:@selector(viewDelayDissMiss) userInfo:nil repeats:NO];
;
}else{
[self.view makeToast:@"发送失败"];
[self.view hideToastActivity];
btn.userInteractionEnabled =YES;
}
} failure:^(NSError *err) {
[self.view hideToastActivity];
btn.userInteractionEnabled =YES;
[self.view makeToast:@"请检查网络"];
}];
}
//tost 结束返回
-(void)viewDelayDissMiss{
[self.navigationController popToViewController:[self.navigationController.viewControllers objectAtIndex:1] animated:YES];
[_getInfTimer invalidate];
}
-(void)dealloc{
[_getInfTimer invalidate];
}
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
CGFloat ROW1H= (self.view.frame.size.width - 16)*0.56 + 54;
if (indexPath.row ==0) {
//return 286;
return ROW1H;
}else if (indexPath.row >=1 && indexPath.row <=4){
return 30;
}else if (indexPath.row ==5){
return 100;
}else if (indexPath.row ==6){
return 80;
}else if (indexPath.row ==7){
return 250;
}
return 0;
//return self.view.frame.size.height - 64;
}
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
[tableView deselectRowAtIndexPath:indexPath animated:YES];
}
@end