Initial commit
This commit is contained in:
@@ -0,0 +1,589 @@
|
||||
//
|
||||
// KanHuBaoGaoView.m
|
||||
// Ifish
|
||||
//
|
||||
// Created by imac on 16/8/29.
|
||||
// Copyright © 2016年 lianxiang. All rights reserved.
|
||||
//
|
||||
|
||||
#import "KanHuBaoGaoView.h"
|
||||
#import "BaoGaoViewFirstCell.h"
|
||||
#import "BaoGaoViewSecondCell.h"
|
||||
#import "BaoGaoViewThirdCell.h"
|
||||
|
||||
//btn tag
|
||||
#define SHUIZHICELL 100010
|
||||
#define WEISHICELL 100020
|
||||
#define JIANAKANGCELL 100030
|
||||
|
||||
//cell tag
|
||||
#define JIANYICELL 100040
|
||||
|
||||
#define SHUIZHICELL_TAG 1110010
|
||||
#define WEISHICELL_TAG 1110020
|
||||
#define JIANAKANGCELL_TAG 1110030
|
||||
|
||||
#define BAOGOCELL_H (viewFrame.size.height - 120 - 50 )/3
|
||||
#import "PingfenModel.h"
|
||||
|
||||
@implementation KanHuBaoGaoView
|
||||
|
||||
-(id)initWithFrame:(CGRect)frame
|
||||
{
|
||||
self=[super initWithFrame:frame];
|
||||
|
||||
if (self) {
|
||||
|
||||
viewFrame = frame;
|
||||
[self setDatas];
|
||||
[self creatTabWithFrame:frame];
|
||||
//self.backgroundColor = COLOR_BACK_;
|
||||
self.backgroundColor = COLOR_BACK_;
|
||||
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(wifiviewkeyboradWillShow:) name:UIKeyboardWillChangeFrameNotification object:nil];
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
return self;
|
||||
|
||||
}
|
||||
|
||||
-(void)setDatas{
|
||||
|
||||
self.cateArr = @[@"水质观察:",@"喂食提醒:",@"将康状况:"];
|
||||
|
||||
[self setshuiZhiArr];
|
||||
[self setweiShiArr];
|
||||
[self setjianKangArr];
|
||||
[self setholdPingfenArr];
|
||||
[self setfenArr1];
|
||||
[self setfenArr2];
|
||||
}
|
||||
|
||||
-(NSArray *)setfenArr1{
|
||||
|
||||
if (!_fenArr1) {
|
||||
_fenArr1 = @[@"0",@"10",@"20",@"30"];
|
||||
}
|
||||
|
||||
return _fenArr1;
|
||||
|
||||
}
|
||||
|
||||
-(NSArray *)setfenArr2{
|
||||
|
||||
if (!_fenArr2) {
|
||||
_fenArr2 = @[@"0",@"15",@"25",@"40"];
|
||||
}
|
||||
|
||||
return _fenArr2;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
-(NSArray *)setholdPingfenArr{
|
||||
|
||||
if (!_holdPingfenArr) {
|
||||
|
||||
_holdPingfenArr = @[@"简直是鱼儿的地狱啊",@"这是有多久没喂了",@"病怏怏的,快不行了"];
|
||||
}
|
||||
|
||||
return _holdPingfenArr;
|
||||
}
|
||||
|
||||
-(NSArray *)setshuiZhiArr{
|
||||
|
||||
if (!_shuiZhiArr) {
|
||||
|
||||
_shuiZhiArr = @[@"简直是鱼儿的地狱啊",@"鱼儿能继续活下去也是个奇迹",@"还凑合~",@"良好,棒棒哒"];
|
||||
}
|
||||
|
||||
return _shuiZhiArr;
|
||||
|
||||
}
|
||||
|
||||
-(NSArray *)setweiShiArr{
|
||||
|
||||
if (!_weiShiArr) {
|
||||
|
||||
_weiShiArr = @[@"这是有多久没喂了",@"喂太少了,鱼儿快饿死啦",@"喂太多了,以后少喂点",@"饱食度刚好,赞一个"];
|
||||
}
|
||||
|
||||
return _weiShiArr;
|
||||
|
||||
}
|
||||
|
||||
-(NSArray *)setjianKangArr{
|
||||
|
||||
if (!_jianKangArr) {
|
||||
|
||||
_jianKangArr = @[@"病怏怏的,快不行了",@"需要赶紧上药了哦",@"还好.多观察几天",@"活蹦乱跳,好着呢"];
|
||||
}
|
||||
|
||||
return _jianKangArr;
|
||||
|
||||
}
|
||||
|
||||
-(void)creatTabWithFrame:(CGRect)frame{
|
||||
|
||||
self.tableView = [[UITableView alloc] init ];
|
||||
self.tableView.frame = CGRectMake(0, 0, frame.size.width, frame.size.height);
|
||||
|
||||
self.tableView.delegate =self;
|
||||
self.tableView.dataSource = self;
|
||||
self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
|
||||
self.tableView.scrollEnabled = YES;
|
||||
self.tableView.backgroundColor = TABLE_BACKGROUD_COLOR;
|
||||
|
||||
[self addSubview:self.tableView];
|
||||
|
||||
|
||||
}
|
||||
|
||||
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
|
||||
|
||||
|
||||
return 6;
|
||||
|
||||
}
|
||||
|
||||
-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
|
||||
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
|
||||
|
||||
if (indexPath.row == 0) {
|
||||
|
||||
|
||||
BaoGaoViewFirstCell *cell = [tableView dequeueReusableCellWithIdentifier:@"BaoGaoViewFirstCell"];
|
||||
if (!cell) {
|
||||
cell = [[[NSBundle mainBundle]loadNibNamed:@"BaoGaoViewFirstCell" owner:self options:nil]lastObject];
|
||||
|
||||
}
|
||||
cell.selectionStyle = UITableViewCellSelectionStyleNone;
|
||||
|
||||
[cell.shengChengBtn addTarget:self action:@selector(shengchengBtnClick) forControlEvents:UIControlEventTouchUpInside];
|
||||
|
||||
|
||||
|
||||
return cell;
|
||||
|
||||
|
||||
|
||||
}else if (indexPath.row >= 1 && indexPath.row <=3){
|
||||
BaoGaoViewSecondCell *cell = [tableView dequeueReusableCellWithIdentifier:@"BaoGaoViewSecondCell"];
|
||||
if (!cell) {
|
||||
cell = [[[NSBundle mainBundle]loadNibNamed:@"BaoGaoViewSecondCell" owner:self options:nil]lastObject];
|
||||
|
||||
}
|
||||
|
||||
cell.cateNameLabel.text = self.cateArr[indexPath.row -1];
|
||||
cell.pingFenLabel.text =self.holdPingfenArr[indexPath.row - 1];
|
||||
|
||||
if (indexPath.row == 1) {
|
||||
|
||||
|
||||
if (self.selectShuiZhiIndex) {
|
||||
|
||||
cell.pingFenLabel.text = self.shuiZhiArr[self.selectShuiZhiIndex.row];
|
||||
cell.fenLabel.text = [NSString stringWithFormat:@"%@分",self.fenArr1[self.selectShuiZhiIndex.row]];
|
||||
}
|
||||
|
||||
|
||||
}else if (indexPath.row == 2){
|
||||
|
||||
if (self.selectWeiShiIndex) {
|
||||
cell.pingFenLabel.text = self.weiShiArr[self.selectWeiShiIndex.row];
|
||||
cell.fenLabel.text = [NSString stringWithFormat:@"%@分",self.fenArr1[self.selectWeiShiIndex.row]];
|
||||
|
||||
}
|
||||
|
||||
}else if (indexPath.row == 3){
|
||||
|
||||
if (self.selectJianKangIndex) {
|
||||
|
||||
cell.pingFenLabel.text = self.jianKangArr[self.selectJianKangIndex.row];
|
||||
cell.fenLabel.text = [NSString stringWithFormat:@"%@分",self.fenArr2[self.selectJianKangIndex.row]];
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
cell.tag = indexPath.row * 10 + 1110000;
|
||||
|
||||
cell.pingFenBtn.tag = indexPath.row * 10 + 100000;
|
||||
|
||||
// [cell.pingFenBtn addTarget:self action:@selector(pingfenActionSheet:) forControlEvents:UIControlEventTouchUpInside];
|
||||
cell.selectionStyle = UITableViewCellSelectionStyleNone;
|
||||
|
||||
return cell;
|
||||
|
||||
}else if (indexPath.row == 4){
|
||||
BaoGaoViewThirdCell *cell = [tableView dequeueReusableCellWithIdentifier:@"BaoGaoViewThirdCell"];
|
||||
if (!cell) {
|
||||
cell = [[[NSBundle mainBundle]loadNibNamed:@"BaoGaoViewThirdCell" owner:self options:nil]lastObject];
|
||||
|
||||
}
|
||||
cell.jianYIField.delegate = self;
|
||||
cell.tag = indexPath.row * 10 + 100000;
|
||||
|
||||
cell.selectionStyle = UITableViewCellSelectionStyleNone;
|
||||
|
||||
return cell;
|
||||
|
||||
|
||||
}else if (indexPath.row == 5){
|
||||
|
||||
static NSString *nllCell=@"nilCell";
|
||||
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:nllCell];
|
||||
if (!cell) {
|
||||
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:nllCell];
|
||||
|
||||
}
|
||||
|
||||
cell.backgroundColor = TABLE_BACKGROUD_COLOR;
|
||||
cell.userInteractionEnabled = NO;
|
||||
return cell;
|
||||
|
||||
}
|
||||
|
||||
return nil;
|
||||
|
||||
}
|
||||
|
||||
-(void)pingfenActionSheet:(UIButton*)btn{
|
||||
|
||||
BaoGaoDownView *pop=[[BaoGaoDownView alloc] init];
|
||||
pop.frame = CGRectMake(0,0,CGRectGetWidth(btn.superview.frame), 160);
|
||||
//pop.backgroundImage =image
|
||||
pop.delegate = self;
|
||||
|
||||
int btnIndex = 0;
|
||||
|
||||
switch (btn.tag) {
|
||||
|
||||
case SHUIZHICELL:
|
||||
{
|
||||
|
||||
//水质
|
||||
pop.titles = self.shuiZhiArr;
|
||||
pop.fenArr = self.fenArr1;
|
||||
self.pingFenStyle = PingfenStyleWater;
|
||||
btnIndex = 0;
|
||||
|
||||
}
|
||||
break;
|
||||
|
||||
case WEISHICELL:
|
||||
{
|
||||
pop.titles = self.weiShiArr;
|
||||
pop.fenArr = self.fenArr1;
|
||||
self.pingFenStyle = PingfenStyleFeed;
|
||||
btnIndex = 1;
|
||||
}
|
||||
break;
|
||||
|
||||
case JIANAKANGCELL:
|
||||
{
|
||||
pop.titles = self.jianKangArr;
|
||||
self.pingFenStyle = PingfenStyleHealth;
|
||||
pop.fenArr = self.fenArr2;
|
||||
btnIndex = 2;
|
||||
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
DXPopover *popover = [DXPopover popover];
|
||||
self.popover = popover;
|
||||
|
||||
popover.arrowSize = CGSizeMake(0.0,0.0);
|
||||
|
||||
|
||||
[popover showAtVIew:btn.superview withNoArrowContentView:pop inView:self.tableView atBtnIndex: btnIndex addCellH:70];
|
||||
|
||||
}
|
||||
|
||||
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
|
||||
|
||||
|
||||
if (indexPath.row ==0) {
|
||||
|
||||
return 50;
|
||||
|
||||
}else if (indexPath.row ==4){
|
||||
|
||||
return 120;
|
||||
|
||||
}else if (indexPath.row ==5){
|
||||
|
||||
return 50;
|
||||
|
||||
}else{
|
||||
|
||||
// return (viewFrame.size.height - 120 - 50 -64)/3 ;
|
||||
|
||||
return 70 ;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
|
||||
|
||||
[tableView deselectRowAtIndexPath:indexPath animated:YES];
|
||||
|
||||
if ( indexPath.row ==4 ) {
|
||||
BaoGaoViewThirdCell *cell =[self viewWithTag:JIANYICELL];
|
||||
[cell.jianYIField resignFirstResponder];
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
if (indexPath.row == 5 || indexPath.row ==0) {
|
||||
// 点击时kongcell return
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
BaoGaoViewSecondCell *cell = [tableView cellForRowAtIndexPath:indexPath];
|
||||
|
||||
// for (BaoGaoViewSecondCell *cell in tableView.subviews) {
|
||||
|
||||
// NSIndexPath *index=[tableView indexPathForCell:cell];
|
||||
|
||||
// if (indexPath == index) {
|
||||
|
||||
BaoGaoDownView *pop=[[BaoGaoDownView alloc] init];
|
||||
pop.frame = CGRectMake(0,0,CGRectGetWidth(cell.baoGaoBackView.frame), 160);
|
||||
//pop.backgroundImage =image
|
||||
pop.delegate = self;
|
||||
|
||||
|
||||
switch (indexPath.row) {
|
||||
|
||||
case 1:
|
||||
{
|
||||
|
||||
//水质
|
||||
pop.titles = self.shuiZhiArr;
|
||||
pop.fenArr = self.fenArr1;
|
||||
self.pingFenStyle = PingfenStyleWater;
|
||||
|
||||
|
||||
}
|
||||
break;
|
||||
|
||||
case 2:
|
||||
{
|
||||
pop.titles = self.weiShiArr;
|
||||
pop.fenArr = self.fenArr1;
|
||||
self.pingFenStyle = PingfenStyleFeed;
|
||||
|
||||
}
|
||||
break;
|
||||
|
||||
case 3:
|
||||
{
|
||||
pop.titles = self.jianKangArr;
|
||||
self.pingFenStyle = PingfenStyleHealth;
|
||||
pop.fenArr = self.fenArr2;
|
||||
|
||||
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
DXPopover *popover = [DXPopover popover];
|
||||
self.popover = popover;
|
||||
|
||||
popover.arrowSize = CGSizeMake(0.0,0.0);
|
||||
|
||||
//[popover showAtVIew:btn.superview withNoArrowContentView:pop inView:self.tableView atBtnIndex: btnIndex addCellH:70];
|
||||
[popover showAtVIew:cell.baoGaoBackView withNoArrowContentView:pop
|
||||
inView:tableView atIndex:indexPath addCellH:70];
|
||||
|
||||
// }
|
||||
|
||||
|
||||
// }
|
||||
|
||||
}
|
||||
|
||||
#pragma mark - BaoGaoDownView delegate
|
||||
|
||||
|
||||
-(void)didBaoGaoViewIndex:(NSIndexPath *)indexPath{
|
||||
|
||||
switch (self.pingFenStyle) {
|
||||
|
||||
case PingfenStyleWater:
|
||||
{
|
||||
self.selectShuiZhiIndex = indexPath;
|
||||
|
||||
}
|
||||
break;
|
||||
case PingfenStyleFeed:
|
||||
{
|
||||
self.selectWeiShiIndex = indexPath;
|
||||
}
|
||||
break;
|
||||
case PingfenStyleHealth:
|
||||
{
|
||||
self.selectJianKangIndex = indexPath;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
[self.popover dismiss];
|
||||
[self.tableView reloadData];
|
||||
}
|
||||
|
||||
#pragma mark - 生成按钮事件
|
||||
|
||||
-(void)shengchengBtnClick{
|
||||
|
||||
|
||||
|
||||
BaoGaoViewSecondCell *cell1=[self viewWithTag:SHUIZHICELL_TAG];
|
||||
BaoGaoViewSecondCell *cell2=[self viewWithTag:WEISHICELL_TAG];
|
||||
BaoGaoViewSecondCell *cell3=[self viewWithTag:JIANAKANGCELL_TAG];
|
||||
BaoGaoViewThirdCell *cell =[self viewWithTag:JIANYICELL];
|
||||
|
||||
if (cell.jianYIField.text.length >70) {
|
||||
|
||||
[self makeToast:@"喂养建议不能超过70字"];
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if ([cell.jianYIField.text isEqualToString:@"给顾客一些建议,让他们感受到您的专业和关怀。"] || cell.jianYIField.text.length ==0) {
|
||||
|
||||
[self makeToast:@"喂养建议不能为空"];
|
||||
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
// if (!self.selectShuiZhiIndex) {
|
||||
//
|
||||
// [self makeToast:@"请给水质评个分"];
|
||||
// return ;
|
||||
// }
|
||||
//
|
||||
// if (!self.selectWeiShiIndex) {
|
||||
// [self makeToast:@"请给鱼儿喂食评分"];
|
||||
// return;
|
||||
// }
|
||||
//
|
||||
// if (!self.selectJianKangIndex) {
|
||||
//
|
||||
// [self makeToast:@"请给鱼儿健康状况评分"];
|
||||
// return;
|
||||
// }
|
||||
|
||||
NSString *index1= [cell1.fenLabel.text substringWithRange:NSMakeRange(0, cell1.fenLabel.text.length - 1)];
|
||||
NSString *index2= [cell2.fenLabel.text substringWithRange:NSMakeRange(0, cell2.fenLabel.text.length - 1)];
|
||||
NSString *index3= [cell3.fenLabel.text substringWithRange:NSMakeRange(0, cell3.fenLabel.text.length - 1)];
|
||||
|
||||
NSLog(@"%@%@%@",index1,index2,index3);
|
||||
|
||||
PingfenModel *PFMode1=[[PingfenModel alloc] init];
|
||||
PFMode1.pingFenDesc = cell1.pingFenLabel.text;
|
||||
PFMode1.pingFenNumber = index1;
|
||||
PingfenModel *PFMode2=[[PingfenModel alloc] init];
|
||||
PFMode2.pingFenDesc = cell2.pingFenLabel.text;
|
||||
PFMode2.pingFenNumber = index2;
|
||||
PingfenModel *PFMode3=[[PingfenModel alloc] init];
|
||||
PFMode3.pingFenDesc = cell3.pingFenLabel.text;
|
||||
PFMode3.pingFenNumber = index3;
|
||||
NSArray *pingfenArr=@[PFMode1,PFMode2,PFMode3];
|
||||
|
||||
[self.baoGaoViewDelegate shengChengBaoGaoWith:index1 index2:index2 index3:index3 addSuggesture:cell.jianYIField.text addPingFenArr:pingfenArr];
|
||||
|
||||
}
|
||||
|
||||
#pragma mark--处理键盘
|
||||
-(void)textViewDidBeginEditing:(UITextView *)textView{
|
||||
//textView.text = @"";
|
||||
}
|
||||
-(void)textViewDidEndEditing:(UITextView *)textView{
|
||||
BaoGaoViewThirdCell *cell =[self viewWithTag:JIANYICELL];
|
||||
[cell.jianYIField resignFirstResponder];
|
||||
|
||||
}
|
||||
|
||||
-(BOOL)textViewShouldEndEditing:(UITextView *)textView{
|
||||
BaoGaoViewThirdCell *cell =[self viewWithTag:JIANYICELL];
|
||||
[cell.jianYIField resignFirstResponder];
|
||||
return YES;
|
||||
}
|
||||
|
||||
//
|
||||
//-(void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event{
|
||||
// [self hiddenKeybord];
|
||||
//}
|
||||
//-(void)hiddenKeybord{
|
||||
// BaoGaoViewThirdCell *cell =[self viewWithTag:JIANYICELL];
|
||||
// [cell.jianYIField resignFirstResponder];
|
||||
//
|
||||
//}
|
||||
|
||||
|
||||
|
||||
-(void)wifiviewkeyboardWillHide:(NSNotification *)notify{
|
||||
|
||||
// 键盘动画时间
|
||||
double duration = [[notify.userInfo objectForKey:UIKeyboardAnimationDurationUserInfoKey] doubleValue];
|
||||
|
||||
//视图下沉恢复原状
|
||||
[UIView animateWithDuration:duration animations:^{
|
||||
self.frame = CGRectMake(0, 0, self.frame.size.width, self.frame.size.height);
|
||||
}];
|
||||
|
||||
}
|
||||
-(void)wifiviewkeyboradWillShow:(NSNotification*)notification{
|
||||
|
||||
// BaoGaoViewThirdCell *cell =[self viewWithTag:JIANYICELL];
|
||||
|
||||
CGRect keyboardFrame = [notification.userInfo[UIKeyboardFrameEndUserInfoKey] CGRectValue];
|
||||
|
||||
//CGRect fieldRect = [self convertRect:cell.jianYIField.bounds toView:self];
|
||||
|
||||
// CGFloat buttonMargin =(fieldRect.origin.y + field.size.height + 10);
|
||||
|
||||
CGFloat transformY = keyboardFrame.size.height;
|
||||
// 取得键盘的动画时间,这样可以在视图上移的时候更连贯
|
||||
double duration = [[notification.userInfo objectForKey:UIKeyboardAnimationDurationUserInfoKey] doubleValue];
|
||||
[UIView animateWithDuration:duration animations:^{
|
||||
|
||||
if (keyboardFrame.origin.y < self.frame.size.height) {
|
||||
self.transform = CGAffineTransformMakeTranslation(0,- transformY);
|
||||
}else{
|
||||
self.transform = CGAffineTransformMakeTranslation(0, 0);
|
||||
}
|
||||
}];
|
||||
}
|
||||
|
||||
-(void)dealloc{
|
||||
|
||||
[[NSNotificationCenter defaultCenter] removeObserver:self name:UIKeyboardWillShowNotification object:nil];
|
||||
[[NSNotificationCenter defaultCenter] removeObserver:self name:UIKeyboardWillHideNotification object:nil];
|
||||
|
||||
}
|
||||
|
||||
@end
|
||||
Reference in New Issue
Block a user