单军华
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
//
//  DeviceDetailsPage.m
//  airtree
//
//  Created by if on 2016/11/18.
//  Copyright © 2016年 Gloria. All rights reserved.
//
 
#import "DeviceDetailsPage.h"
#import "ChangeDeviceNamePage.h"
#import "DateTimePicker.h"
#import "MyDeviceStatus.h"
#import "CommonReqModel.h"
#import "NetworkSingleton.h"
 
@interface DeviceDetailsPage ()<UITableViewDataSource,UITableViewDelegate,UIAlertViewDelegate>
{
    UITableView *_tableView;
    //NSTimer *timer;
    NSString *checkStatus;
 
}
 
@end
 
@implementation DeviceDetailsPage
 
- (void)viewDidLoad
{
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.navigationItem.title = @"设备详情";
    [self setNavigationLeft:@"返回" sel:@selector(backAction)];
    
    self.view.backgroundColor = [UIColor whiteColor];
    
//    UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, 80)];
//    view.userInteractionEnabled = YES;
//    UIButton *quitLoginBtn = [UIButton buttonWithType:UIButtonTypeCustom];
//    quitLoginBtn.frame =CGRectMake(20, 50, SCREEN_WIDTH-40, 40);
//    [quitLoginBtn.layer setMasksToBounds:YES];
//    [quitLoginBtn.layer setCornerRadius:5.0]; //设置矩形四个圆角半径
//    quitLoginBtn.backgroundColor = BLUE_BUTTON_COLOR;
//    [quitLoginBtn setTitle:@"解绑该设备" forState:UIControlStateNormal];
//    [quitLoginBtn addTarget:self action:@selector(unBindDevice) forControlEvents:UIControlEventTouchUpInside];
//    [view addSubview:quitLoginBtn];
    
    
    _tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT-40) style:UITableViewStyleGrouped];
    _tableView.dataSource = self;
    _tableView.delegate = self;
    //_tableView.tableFooterView = view;
    [self.view addSubview:_tableView];
    
    
//    if([device[@"type"] integerValue] == 1)
//    {
//        [self loadDeviceInfoList];
//    }
    
//    //此处调用加载数据的接口
//    [self loadDeviceInfoList];
    
}
 
-(void) viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:YES];
    
    [_tableView reloadData];
}
 
- (void)viewDidDisappear:(BOOL)animated {
    [super viewDidDisappear:YES];
    
}
 
 
-(void)backAction
{
    [self dismissViewControllerAnimated:YES completion:nil];
}
 
 
-(void)unBindDevice
{
    [Global alertMessageEx:@"确定要解除绑定吗" title:@"提示信息" okTtitle:@"确认" cancelTitle:@"取消" delegate:self];
}
 
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{
   // buttonIndex 0 取消 1 确定
    switch (buttonIndex) {
        case 0:
        {
            
        }
            break;
        case 1:
        {
            NSString *path = [NSString stringWithFormat:Moral_Unbind_Url];
            
            CommonReqModel * model = [[CommonReqModel alloc] init];
            model.userID = _loginUser[@"_id"];
            model.deviceID = self._id;
            model.name   = _curDeviceName;
            
            MPWeakSelf(self);
            [NetworkSingleton networkingPostMethod:model.toDic urlName:path success:^(id responseBody)
             {
                 BaseResModel * resModel = [Global toBaseModel:responseBody];
                 if(resModel.code == 0)
                 {
                     [Global alertMessageEx:@"解绑成功!" title:@"提示信息" okTtitle:nil cancelTitle:@"OK" delegate:self];
                      [weakself dismissViewControllerAnimated:YES completion:nil];
                 }
                 else
                 {
                     [Global alertMessageEx:resModel.desc title:@"提示信息" okTtitle:nil cancelTitle:@"OK" delegate:self];
                 }
             }
              failure:^(NSString *error)
             {
                 [Global alertMessageEx:error title:@"提示信息" okTtitle:nil cancelTitle:@"OK" delegate:self];
             }];
        }
            break;
        default:
            break;
    }
}
 
-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    return 1;
}
 
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return 3;
}
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return 60;
}
-(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
    return 1;
}
 
//此处上面和下面 是设置 footerview
- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section
{
    return 80;
}
 
-(UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section
{
    UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, 80)];
    
    UIButton *quitLoginBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    quitLoginBtn.frame =CGRectMake(20, 50, SCREEN_WIDTH-40, 40);
    [quitLoginBtn.layer setMasksToBounds:YES];
    [quitLoginBtn.layer setCornerRadius:5.0]; //设置矩形四个圆角半径
    quitLoginBtn.backgroundColor = RgbColor(85, 81, 168);
    [quitLoginBtn setTitle:@"解绑该设备" forState:UIControlStateNormal];
    [quitLoginBtn addTarget:self action:@selector(unBindDevice) forControlEvents:UIControlEventTouchUpInside];
    [view addSubview:quitLoginBtn];
    
    
    return view;
}
 
 
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    NSString * identifier = @"deviceManage";
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:identifier];
    if (nil == cell) {
        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:identifier];
        
    }
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
    switch (indexPath.row)
    {
        case 0:
        {
            cell.textLabel.text = @"设备编号";
            cell.textLabel.font = FONT16;
            cell.textLabel.textColor = BLACKTEXTCOLOR_TITLE;
            
            cell.detailTextLabel.text = self._id;
            cell.detailTextLabel.font = FONT14;
            cell.detailTextLabel.textColor = BLACKTEXTCOLOR_SUB;
            
        }
            break;
        case 1:
        {
            cell.textLabel.text = @"MAC地址";
            cell.textLabel.font = FONT16;
            cell.textLabel.textColor = BLACKTEXTCOLOR_TITLE;
            
            cell.detailTextLabel.text = self.mac;
            cell.detailTextLabel.font = FONT14;
            cell.detailTextLabel.textColor = BLACKTEXTCOLOR_SUB;
            
        }
            break;
        case 2:
        {
            cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
            
            cell.textLabel.text = @"设备名称";
            cell.textLabel.font = FONT16;
            cell.textLabel.textColor = BLACKTEXTCOLOR_TITLE;
            cell.userInteractionEnabled = YES;
            cell.detailTextLabel.text = _curDeviceName;
            cell.detailTextLabel.font = FONT14;
            cell.detailTextLabel.textColor = BLACKTEXTCOLOR_SUB;
            
        }
            break;
        default:
            break;
    }
    
    return cell;
}
 
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    [tableView deselectRowAtIndexPath:indexPath animated:YES];
    switch (indexPath.row) {
        case 0:
        {
            
            
        }
            break;
        case 1:
        {
            
            
        }
            break;
        case 2:
        {
            
            ChangeDeviceNamePage *page = [[ChangeDeviceNamePage alloc] initIsFirstPage:NO];
            //page.currentPage = self.currentPage;
            [self.navigationController pushViewController:page animated:YES];
        }
            break;
        default:
            break;
    }
 
}
 
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}
 
/*
 #pragma mark - Navigation
 
 // In a storyboard-based application, you will often want to do a little preparation before navigation
 - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
 // Get the new view controller using [segue destinationViewController].
 // Pass the selected object to the new view controller.
 }
 */
 
@end