单军华
2017-07-12 20d1260d26b028897f3c0935c12fc35aa37b2e93
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
//
//  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