// // MyDeviceStatusCell.m // terminalMgr // // Created by WindShan on 2017/3/16. // Copyright © 2017年 WindShan. All rights reserved. // #import "MyDeviceStatusCell.h" #import "GloriaLabel.h" #import "UIImageView+WebCache.h" #import "commenProgressView.h" @interface MyDeviceStatusCell() { } @property (nonatomic, strong) UIImageView * bkImage; @property (nonatomic, strong) UIImageView * file_name_tag; @property (nonatomic, strong) UIImageView * file_name_line; @property (nonatomic, strong) UIImageView * file_cmd_line; @property (nonatomic, strong) UIImageView * file_cmd_line2; @property (nonatomic, strong) GloriaLabel * fileName; @property (nonatomic, strong) UIButton * startBtn; @property (nonatomic, strong) UIButton * stopBtn; @property (nonatomic, strong) UIButton * deleteBtn; @property (nonatomic, strong) GloriaLabel * useStatus; @property (nonatomic, strong) GloriaLabel * room_No; @property (nonatomic, strong) UIImageView * lw_status; @property (nonatomic, strong) GloriaLabel * lw_change_status; @end @implementation MyDeviceStatusCell /* // Only override drawRect: if you perform custom drawing. // An empty implementation adversely affects performance during animation. - (void)drawRect:(CGRect)rect { // Drawing code } */ - (GloriaLabel *) lw_change_status { if(!_lw_change_status) { _lw_change_status = [[GloriaLabel alloc] initWithFrame:CGRectMake(8+10+45, 5,50, 50)]; _lw_change_status.font = [UIFont systemFontOfSize:8]; _lw_change_status.textAlignment = UITextAlignmentLeft; _lw_change_status.textColor = kUIColorFromRGB(0x5a5a5a); [self.contentView addSubview:_lw_change_status]; } return _lw_change_status; } - (UIImageView *)lw_status { if (!_lw_status) { _lw_status = [[UIImageView alloc] initWithFrame:CGRectMake(8, 5, 2, 100)]; [self.contentView addSubview:_lw_status]; } return _lw_status; } - (GloriaLabel *) useStatus { if(!_useStatus) { _useStatus = [[GloriaLabel alloc] initWithFrame:CGRectMake(8+10+45, 5,SCREEN_WIDTH/2, 30)]; _useStatus.font = [UIFont systemFontOfSize:12]; _useStatus.textAlignment = UITextAlignmentLeft; _useStatus.textColor = kUIColorFromRGB(0x5a5a5a); [self.contentView addSubview:_useStatus]; } return _useStatus; } - (GloriaLabel *) room_No { if(!_room_No) { _room_No = [[GloriaLabel alloc] initWithFrame:CGRectMake(8+10+45, 5,SCREEN_WIDTH/2, 30)]; _room_No.font = [UIFont systemFontOfSize:12]; _room_No.textAlignment = UITextAlignmentLeft; _room_No.textColor = kUIColorFromRGB(0x5a5a5a); [self.contentView addSubview:_room_No]; } return _room_No; } //NSString * btncmd; // 按钮命令 0 发布广告 1 关闭广告&开启广告 2 更换设备 -(void)startAction { if ( _delegate && [_delegate respondsToSelector:@selector(didCellDetailSection:)]) { self.model.btncmd = @"0"; [_delegate didCellDetailSection:self.model]; } } -(void)stopAction { if ( _delegate && [_delegate respondsToSelector:@selector(didCellDetailSection:)]) { self.model.btncmd = @"2"; [_delegate didCellDetailSection:self.model]; } } -(void)deleteAction { if ( _delegate && [_delegate respondsToSelector:@selector(didCellDetailSection:)]) { self.model.btncmd = @"1"; [_delegate didCellDetailSection:self.model]; } } -(UIButton*)deleteBtn { if(!_deleteBtn) { _deleteBtn = [UIButton buttonWithType:UIButtonTypeRoundedRect]; _deleteBtn.frame = CGRectMake(0, SCREEN_HEIGHT-100, 118, 30); [_deleteBtn setImage:[UIImage imageNamed:@"ic_open_gg_tag"] forState:UIControlStateNormal]; [_deleteBtn setTitle:@"开启广告" forState:UIControlStateNormal]; [_deleteBtn setTitleColor:kUIColorFromRGB(0x5a5a5a) forState:UIControlStateNormal]; //_deleteBtn.backgroundColor = [UIColor redColor]; //上左下右 _deleteBtn.titleLabel.font = [UIFont systemFontOfSize: 12.0]; [_deleteBtn addTarget:self action:@selector(deleteAction) forControlEvents:UIControlEventTouchUpInside]; [_deleteBtn setTintColor:RgbColor(253,137,8)]; [_startBtn setTag:2]; [self.contentView addSubview:_deleteBtn]; } return _deleteBtn; } -(UIButton*)stopBtn { if(!_stopBtn) { _stopBtn = [UIButton buttonWithType:UIButtonTypeRoundedRect]; _stopBtn.frame = CGRectMake(0, SCREEN_HEIGHT-100, 118, 30); [_stopBtn setImage:[UIImage imageNamed:@"ic_change_device_tag"] forState:UIControlStateNormal]; [_stopBtn setTitle:@"更换设备" forState:UIControlStateNormal]; [_stopBtn setTitleColor:kUIColorFromRGB(0x5a5a5a) forState:UIControlStateNormal]; //_stopBtn.backgroundColor = [UIColor redColor]; //上左下右 _stopBtn.titleLabel.font = [UIFont systemFontOfSize: 12.0]; [_stopBtn addTarget:self action:@selector(stopAction) forControlEvents:UIControlEventTouchUpInside]; [_startBtn setTag:1]; [_stopBtn setTintColor:RgbColor(253,137,8)]; [self.contentView addSubview:_stopBtn]; } return _stopBtn; } -(UIButton*)startBtn { if(!_startBtn) { _startBtn = [UIButton buttonWithType:UIButtonTypeRoundedRect]; _startBtn.frame = CGRectMake(0, SCREEN_HEIGHT-100, 118, 30); [_startBtn setImage:[UIImage imageNamed:@"ic_fabu_gg_tag"] forState:UIControlStateNormal]; [_startBtn setTitle:@"发布广告" forState:UIControlStateNormal]; [_startBtn setTitleColor:kUIColorFromRGB(0x5a5a5a) forState:UIControlStateNormal]; //_startBtn.backgroundColor = [UIColor redColor]; //上左下右 _startBtn.titleLabel.font = [UIFont systemFontOfSize: 12.0]; [_startBtn addTarget:self action:@selector(startAction) forControlEvents:UIControlEventTouchUpInside]; [_startBtn setTintColor:RgbColor(253,137,8)]; [_startBtn setTag:0]; [self.contentView addSubview:_startBtn]; } return _startBtn; } - (GloriaLabel *) fileName { if(!_fileName) { _fileName = [[GloriaLabel alloc] initWithFrame:CGRectMake(8+10+45, 5,SCREEN_WIDTH/2, 30)]; _fileName.font = [UIFont systemFontOfSize:12]; _fileName.textAlignment = UITextAlignmentLeft; _fileName.textColor = kUIColorFromRGB(0x6e6e6e); [self.contentView addSubview:_fileName]; } return _fileName; } - (UIImageView *)file_name_tag { if (!_file_name_tag) { _file_name_tag = [[UIImageView alloc] initWithFrame:CGRectMake(8, 5, 2, 100)]; [self.contentView addSubview:_file_name_tag]; } return _file_name_tag; } - (UIImageView *)bkImage { if (!_bkImage) { CGFloat bkImageW = 708; if(IsiPhone4 || IsiPhone5) { bkImageW = 620; } _bkImage = [[UIImageView alloc] initWithFrame:CGRectMake((SCREEN_WIDTH-bkImageW)/2-10, 0, bkImageW-20, 80)]; [self.contentView addSubview:_bkImage]; } return _bkImage; } - (UIImageView *)file_name_line { if (!_file_name_line) { _file_name_line = [[UIImageView alloc] initWithFrame:CGRectMake(8, 5, SCREEN_WIDTH-16, 70)]; _file_name_line.image = [UIImage imageNamed:@"ic_device_line"]; [self.contentView addSubview:_file_name_line]; } return _file_name_line; } - (UIImageView *)file_cmd_line { if (!_file_cmd_line) { _file_cmd_line = [[UIImageView alloc] initWithFrame:CGRectMake(8, 5, SCREEN_WIDTH-16, 70)]; _file_cmd_line.image = [UIImage imageNamed:@"file_cmd_line"]; [self.contentView addSubview:_file_cmd_line]; } return _file_cmd_line; } - (UIImageView *)file_cmd_line2 { if (!_file_cmd_line2) { _file_cmd_line2 = [[UIImageView alloc] initWithFrame:CGRectMake(8, 5, SCREEN_WIDTH-16, 70)]; _file_cmd_line2.image = [UIImage imageNamed:@"file_cmd_line"]; [self.contentView addSubview:_file_cmd_line2]; } return _file_cmd_line2; } //@property (nonatomic, strong) UIImageView * bkImage; //@property (nonatomic, strong) UIImageView * iconImage; //@property (nonatomic, strong) UIImageView * nameCircleImage; //@property (nonatomic, strong) UIImageView * statusCircleImage; //@property (nonatomic, strong) GloriaLabel * deviceName; //@property (nonatomic, strong) GloriaLabel * FileStatus; - (void)layoutSubviews { [super layoutSubviews]; CGFloat bkImageW = 356; CGFloat btnW = 118; CGFloat leftOffX = 10; CGFloat lineOffX = 0; if(IsiPhone4 || IsiPhone5) { bkImageW = 300; btnW = 105; leftOffX = 0; lineOffX = 10; } self.lw_status.frame = CGRectMake(SCREEN_WIDTH-20-55, 15, 57, 57); self.bkImage.frame = CGRectMake((SCREEN_WIDTH-bkImageW)/2, 10, bkImageW, 98); self.file_name_tag.frame = CGRectMake((SCREEN_WIDTH-bkImageW)/2+10, 17, 2, 16); self.file_name_line.frame = CGRectMake((SCREEN_WIDTH-bkImageW+20)/2, 40, bkImageW-self.lw_status.frame.size.width-30, 1); self.fileName.frame = CGRectMake((SCREEN_WIDTH-bkImageW)/2+10+10, 10, SCREEN_WIDTH/2, 30); self.startBtn.frame = CGRectMake((SCREEN_WIDTH-bkImageW)/2+2, 75, btnW, 30); self.startBtn.titleEdgeInsets = UIEdgeInsetsMake(0, leftOffX+16+5, 0, 20); //UIEdgeInsetsMake(CGFloat top, CGFloat left, CGFloat bottom, CGFloat right) self.startBtn.imageEdgeInsets = UIEdgeInsetsMake(0, leftOffX, 0, 20); self.file_cmd_line.frame = CGRectMake((SCREEN_WIDTH-bkImageW)/2+2+btnW-lineOffX, 80, 1, 20); self.stopBtn.frame = CGRectMake((SCREEN_WIDTH-bkImageW)/2+2+btnW*2-lineOffX, 75, btnW, 30); self.stopBtn.titleEdgeInsets = UIEdgeInsetsMake(0, leftOffX+16+5, 0, 20); //UIEdgeInsetsMake(CGFloat top, CGFloat left, CGFloat bottom, CGFloat right) self.stopBtn.imageEdgeInsets = UIEdgeInsetsMake(0, leftOffX, 0, 20); self.file_cmd_line2.frame = CGRectMake((SCREEN_WIDTH-bkImageW)/2+2+btnW*2-lineOffX, 80, 1, 20); self.deleteBtn.frame = CGRectMake((SCREEN_WIDTH-bkImageW)/2+2+btnW-lineOffX, 75, btnW, 30); self.deleteBtn.titleEdgeInsets = UIEdgeInsetsMake(0, leftOffX+16+5, 0, 20); //UIEdgeInsetsMake(CGFloat top, CGFloat left, CGFloat bottom, CGFloat right) self.deleteBtn.imageEdgeInsets = UIEdgeInsetsMake(0, leftOffX, 0, 20); //CGRectMake((SCREEN_WIDTH-bkImageW+20)/2, 50, bkImageW-20, 16); self.useStatus.frame = CGRectMake((SCREEN_WIDTH-bkImageW+20)/2, 50, (bkImageW-20)/2, 20); self.room_No.frame = CGRectMake((SCREEN_WIDTH)/2, 50, (bkImageW-20)/2, 20); // 滤网正常 滤网需更换 self.lw_change_status.frame = CGRectMake(SCREEN_WIDTH-20-55, 15, 56, 56); self.lw_change_status.font = [UIFont systemFontOfSize:10]; self.lw_change_status.numberOfLines = 0;//上面两行设置多行显示 self.lw_change_status.textAlignment = UITextAlignmentCenter; } /** 设置数据*/ - (void)setItemView:(MyDeviceStatus*)model { self.model = model; self.contentView.backgroundColor = [UIColor clearColor]; self.bkImage.image = [UIImage imageNamed:@"file_download_item_bk"]; self.file_name_tag.image = [UIImage imageNamed:@"ic_devicename_tag"]; self.lw_status.image = [UIImage imageNamed:@"lw_chaneg_bk"]; [self.fileName setText:[NSString stringWithFormat:@"设备名称:%@",model.name]]; [self.fileName setTextColor:kUIColorFromRGB(0x00b742)]; //int status; 1 正常 2 备品使用中 [self.useStatus setText:[NSString stringWithFormat:@"使用状态:%@",model.status == 1?@"正常":@"备品使用中"]]; [self.room_No setText:[NSString stringWithFormat:@"已保养次数:%d",model.fs_count]]; [self.stopBtn setTitle:model.status == 1?@"更换设备":@"换回设备" forState:UIControlStateNormal]; //[self.lw_change_status setText:@"滤网\n需更换"]; //[self.lw_change_status setTextColor:kUIColorFromRGB(0xfc7411)]; // fs_status;//0不更换,1更换 self.lw_status.image = [UIImage imageNamed:model.fs_status == 0 ? @"lw_normal_bk":@"lw_chaneg_bk"]; [self.lw_change_status setText:model.fs_status == 0 ?@"滤网\n正常":@"滤网\n需保养"]; [self.lw_change_status setTextColor:model.fs_status == 0 ?kUIColorFromRGB(0x00b742):kUIColorFromRGB(0xfc7411)]; //int ad_mode;//": 1 广告已开 0 广告已关 [_deleteBtn setImage:[UIImage imageNamed:model.ad_mode == 0?@"ic_open_gg_tag":@"ic_close_gg_tag"] forState:UIControlStateNormal]; [_deleteBtn setTitle:model.ad_mode == 0?@"开启广告":@"关闭广告" forState:UIControlStateNormal]; } @end