单军华
2018-03-28 f99cf1d5cc50407394501853be06cb39f38a092c
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
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
//
//  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