//
|
// HotelAccountCell.m
|
// istanbul
|
//
|
// Created by WindShan on 2017/6/16.
|
// Copyright © 2017年 WindShan. All rights reserved.
|
//
|
|
#import "HotelAccountCell.h"
|
#import "GloriaLabel.h"
|
#import "UpdateHotelAccountPage.h"
|
|
@interface HotelAccountCell()
|
{
|
UIWebView *callWebview;
|
}
|
|
@property (nonatomic, strong) GloriaLabel * nicknameLabel;
|
@property (nonatomic, strong) GloriaLabel * usernameLabel;
|
@property (nonatomic, strong) GloriaLabel * hotelnameLabel;
|
@property (nonatomic, strong) UIButton * nicknameChangeBtn;
|
@property (nonatomic, strong) UIButton * telBtn;
|
@property (nonatomic, strong) UIButton * deleteBtn;
|
@end
|
|
@implementation HotelAccountCell
|
|
/*
|
// 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.nicknameLabel.frame = CGRectMake(20, 0, SCREEN_WIDTH/2, 40);
|
self.usernameLabel.frame = CGRectMake(20, 40, SCREEN_WIDTH/2, 40);
|
self.hotelnameLabel.frame = CGRectMake(20, 80, SCREEN_WIDTH/2, 40);
|
|
self.nicknameChangeBtn.frame = CGRectMake(SCREEN_WIDTH-30-20, 5, 30, 30);
|
self.telBtn.frame = CGRectMake(SCREEN_WIDTH-30-20, 45, 30, 30);
|
self.deleteBtn.frame = CGRectMake(SCREEN_WIDTH-30-20, 85, 30, 30);
|
}
|
|
-(UIButton*)telBtn
|
{
|
if(!_telBtn)
|
{
|
_telBtn = [UIButton buttonWithType:UIButtonTypeCustom];
|
_telBtn.frame = CGRectMake(0, SCREEN_HEIGHT-100, 118, 30);
|
[_telBtn setBackgroundImage:[UIImage imageNamed:@"icon_dianhua" ] forState:UIControlStateNormal];
|
[_telBtn addTarget:self action:@selector(telAction) forControlEvents:UIControlEventTouchUpInside];
|
[self.contentView addSubview:_telBtn];
|
}
|
|
return _telBtn;
|
}
|
|
-(void)telAction
|
{
|
NSMutableString *str = [[NSMutableString alloc] initWithFormat:@"tel:%@",self.usernameLabel.text];
|
if(callWebview==nil)
|
{
|
callWebview = [[UIWebView alloc] init];
|
[self addSubview:callWebview];
|
}
|
|
[callWebview loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:str]]];
|
}
|
|
-(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(updateAccountSection:)])
|
{
|
self.model.cmd = 2;
|
[_delegate updateAccountSection: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(updateAccountSection:)])
|
{
|
self.model.cmd = 1;
|
[_delegate updateAccountSection:self.model];
|
}
|
}
|
|
- (GloriaLabel *) hotelnameLabel
|
{
|
if(!_hotelnameLabel)
|
{
|
_hotelnameLabel = [[GloriaLabel alloc] initWithFrame:CGRectMake(10+50+10+80, 28,150, 14)];
|
_hotelnameLabel.font = [UIFont systemFontOfSize:16];
|
_hotelnameLabel.textAlignment = UITextAlignmentLeft;
|
_hotelnameLabel.textColor = kUIColorFromRGB(0x5a5a5a);
|
[self.contentView addSubview:_hotelnameLabel];
|
}
|
|
return _hotelnameLabel;
|
}
|
|
- (GloriaLabel *) nicknameLabel
|
{
|
if(!_nicknameLabel)
|
{
|
_nicknameLabel = [[GloriaLabel alloc] initWithFrame:CGRectMake(10+50+10+80, 28,150, 14)];
|
_nicknameLabel.font = [UIFont systemFontOfSize:16];
|
_nicknameLabel.textAlignment = UITextAlignmentLeft;
|
_nicknameLabel.textColor = kUIColorFromRGB(0x5a5a5a);
|
[self.contentView addSubview:_nicknameLabel];
|
}
|
|
return _nicknameLabel;
|
}
|
|
- (GloriaLabel *) usernameLabel
|
{
|
if(!_usernameLabel)
|
{
|
_usernameLabel = [[GloriaLabel alloc] initWithFrame:CGRectMake(10+50+10+80, 28,150, 14)];
|
_usernameLabel.font = [UIFont systemFontOfSize:16];
|
_usernameLabel.textAlignment = UITextAlignmentLeft;
|
_usernameLabel.textColor = kUIColorFromRGB(0x5a5a5a);
|
[self.contentView addSubview:_usernameLabel];
|
}
|
|
return _usernameLabel;
|
}
|
|
- (void)setItemView:(HotelAccount*)model
|
{
|
self.model = model;
|
[self.hotelnameLabel setText:model.hotel_id.name];
|
[self.usernameLabel setText:model.username];
|
[self.nicknameLabel setText:model.nickname];
|
}
|
|
@end
|