//
|
// HotelAccountCell.m
|
// istanbul
|
//
|
// Created by WindShan on 2017/6/16.
|
// Copyright © 2017年 WindShan. All rights reserved.
|
//
|
|
#import "HotelDeviceCell.h"
|
#import "GloriaLabel.h"
|
#import "UpdateHotelAccountPage.h"
|
|
@interface HotelDeviceCell()
|
{
|
UIWebView *callWebview;
|
}
|
|
@property (nonatomic, strong) GloriaLabel * devicenameLabel;
|
@property (nonatomic, strong) GloriaLabel * statusLabel;
|
@property (nonatomic, strong) UIButton * nicknameChangeBtn;
|
@property (nonatomic, strong) UIButton * deleteBtn;
|
@property (nonatomic, strong) UIImageView * imageTag;
|
@end
|
|
@implementation HotelDeviceCell
|
|
/*
|
// Only override drawRect: if you perform custom drawing.
|
// An empty implementation adversely affects performance during animation.
|
- (void)drawRect:(CGRect)rect {
|
// Drawing code
|
}
|
*/
|
|
- (void)layoutSubviews
|
{
|
[super layoutSubviews];
|
|
self.devicenameLabel.frame = CGRectMake(20, 20, SCREEN_WIDTH/2, 40);
|
self.statusLabel.frame = CGRectMake(20+SCREEN_WIDTH/2, 20, SCREEN_WIDTH/3, 40);
|
|
self.imageTag.frame = CGRectMake(20+SCREEN_WIDTH/2-30, 28, 24, 24);
|
self.nicknameChangeBtn.frame = CGRectMake(SCREEN_WIDTH-30-20, 5, 30, 30);
|
self.deleteBtn.frame = CGRectMake(SCREEN_WIDTH-30-20, 45, 30, 30);
|
}
|
|
- (UIImageView *)imageTag
|
{
|
if (!_imageTag)
|
{
|
_imageTag = [[UIImageView alloc] initWithFrame:CGRectMake(10, 0, SCREEN_WIDTH-20, 60)];
|
[self.contentView addSubview:_imageTag];
|
}
|
|
return _imageTag;
|
}
|
|
-(UIButton*)deleteBtn
|
{
|
if(!_deleteBtn)
|
{
|
_deleteBtn = [UIButton buttonWithType:UIButtonTypeCustom];
|
_deleteBtn.frame = CGRectMake(0, SCREEN_HEIGHT-100, 118, 30);
|
[_deleteBtn setBackgroundImage:[UIImage imageNamed:@"icon_shanchu" ] forState:UIControlStateNormal];
|
[_deleteBtn addTarget:self action:@selector(deleteAction) forControlEvents:UIControlEventTouchUpInside];
|
[self.contentView addSubview:_deleteBtn];
|
}
|
|
return _deleteBtn;
|
}
|
|
-(void)deleteAction
|
{
|
if ( _delegate && [_delegate respondsToSelector:@selector(updateDeviceSection:)])
|
{
|
self.model.cmd = 2;
|
[_delegate updateDeviceSection:self.model];
|
}
|
}
|
|
-(UIButton*)nicknameChangeBtn
|
{
|
if(!_nicknameChangeBtn)
|
{
|
_nicknameChangeBtn = [UIButton buttonWithType:UIButtonTypeCustom];
|
_nicknameChangeBtn.frame = CGRectMake(0, SCREEN_HEIGHT-100, 118, 30);
|
[_nicknameChangeBtn setBackgroundImage:[UIImage imageNamed:@"icon_bianji" ] forState:UIControlStateNormal];
|
[_nicknameChangeBtn addTarget:self action:@selector(changeAction) forControlEvents:UIControlEventTouchUpInside];
|
[self.contentView addSubview:_nicknameChangeBtn];
|
}
|
|
return _nicknameChangeBtn;
|
}
|
|
-(void)changeAction
|
{
|
if ( _delegate && [_delegate respondsToSelector:@selector(updateDeviceSection:)])
|
{
|
self.model.cmd = 1;
|
[_delegate updateDeviceSection:self.model];
|
}
|
}
|
|
- (GloriaLabel *) devicenameLabel
|
{
|
if(!_devicenameLabel)
|
{
|
_devicenameLabel = [[GloriaLabel alloc] initWithFrame:CGRectMake(10+50+10+80, 28,150, 14)];
|
_devicenameLabel.font = [UIFont systemFontOfSize:16];
|
_devicenameLabel.textAlignment = UITextAlignmentLeft;
|
_devicenameLabel.textColor = kUIColorFromRGB(0x5a5a5a);
|
[self.contentView addSubview:_devicenameLabel];
|
}
|
|
return _devicenameLabel;
|
}
|
|
- (GloriaLabel *) statusLabel
|
{
|
if(!_statusLabel)
|
{
|
_statusLabel = [[GloriaLabel alloc] initWithFrame:CGRectMake(10+50+10+80, 28,150, 14)];
|
_statusLabel.font = [UIFont systemFontOfSize:16];
|
_statusLabel.textAlignment = UITextAlignmentLeft;
|
_statusLabel.textColor = kUIColorFromRGB(0x5a5a5a);
|
[self.contentView addSubview:_statusLabel];
|
}
|
|
return _statusLabel;
|
}
|
|
- (void)setItemView:(DeviceSpareModel*)model
|
{
|
self.model = model;
|
|
[self.devicenameLabel setText:model.name];
|
self.imageTag.image = [UIImage imageNamed:model.status == 0?@"spare1":@"spare2"];
|
[self.statusLabel setText:model.status == 0?@"闲置":@"使用"];
|
}
|
|
@end
|