zjf
2023-03-10 abac8765bf6a1f400c2377b9999ce7495ba34a3f
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
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
    //
//  PBLoginViewController.m
//  IphoneBIMe
//
//  Created by zjf on 2018/7/16.
//  Copyright © 2018年 ProBIM. All rights reserved.
//
 
#import "PBLoginViewController.h"
#import "PBNavigationController.h"
#import "PBAgreementViewController.h"
#import "PBNetworkModel.h"
#import <JPUSHService.h>
#import "PGGCryptoDES.h"
#import "PBEnterpriseCodeController.h"
#import "PBSitePerViewController.h"
#import "PBProjectModel.h"
#define bim365Code @"300012"
@interface PBLoginViewController ()<UITextFieldDelegate>
@property (nonatomic, weak) UILabel *codeL;
@property (nonatomic, weak) UITextField *userNameTF;
@property (nonatomic, weak) UITextField *passwordTF;
@property (nonatomic, weak) UILabel *titleL;
@property (nonatomic, weak) UIButton *loginBtn;
@property (nonatomic, assign) BOOL keyBoardIsShow;
@property (nonatomic, strong) NSDictionary *bim365Data;
@property (nonatomic, strong) NSDictionary *customData;
@property (nonatomic, assign) int logoImageVTop;
@property (nonatomic, assign) int bgViewTop;
@end
 
@implementation PBLoginViewController
 
- (void)viewDidLoad {
    [super viewDidLoad];
//    [PBNoteCenter addObserver:self selector:@selector(keyboardWillShow:) name:UIKeyboardWillShowNotification object:nil];
//    [PBNoteCenter addObserver:self selector:@selector(keyboardWillHidden:) name:UIKeyboardWillHideNotification object:nil];
    NSDictionary *dict = [NSString getApiData];
    if (dict) {
        self.customData = dict;
    }else {
        self.customData = self.bim365Data;
        [self storedLocallyApiWithData:self.customData];
        NSArray *arr = @[self.customData];
        [self saveApiArr:arr];
    }
    [self setupUI];
    [self setApi];
}
- (void)keyboardWillShow:(NSNotification *)notification {
    if (self.keyBoardIsShow) {
        return;
    }
    self.keyBoardIsShow = YES;
    [UIView animateWithDuration:1 animations:^{
        CGFloat titleTop;
        if (IS_IPHONE_X) {
            titleTop = 12;
        }else {
            titleTop = 12 + 24;
        }
        [self.titleL mas_updateConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(self.view).offset(titleTop);
        }];
        [self.loginBtn mas_updateConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(self.passwordTF.mas_bottom).offset(20);
        }];
        [self.view layoutIfNeeded];
    }];
- (void)keyboardWillHidden:(NSNotification *)notification{
    if (!self.keyBoardIsShow) {
        return;
    }
    self.keyBoardIsShow = NO;
    [UIView animateWithDuration:1 animations:^{
        CGFloat titleTop;
        if (IS_IPHONE_X) {
            titleTop = 50;
        }else {
            titleTop = 50 + 24;
        }
        [self.titleL mas_updateConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(self.view).offset(titleTop);
        }];
        [self.loginBtn mas_updateConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(self.passwordTF.mas_bottom).offset(80);
        }];
        [self.view layoutIfNeeded];
    }];
}
 
- (void)setupUI {
    self.view.backgroundColor = PBColor(244, 245, 246);
    UILabel *titleL = [UILabel z_labelWithText:@"欢迎登录" Color:PBColor(40, 58, 79) isBold:YES Font:26];
    [self.view addSubview:titleL];
    CGFloat titleTop;
    if (IS_IPHONE_X) {
        titleTop = 50;
    }else {
        titleTop = 50 + 24;
    }
    [titleL mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.view).offset(titleTop);
        make.left.equalTo(self.view).offset(30);
        make.size.mas_equalTo(CGSizeMake(108, 40));
    }];
    
    UIView *codeBg = [[UIView alloc] init];
    codeBg.backgroundColor = [UIColor whiteColor];
    [self.view addSubview:codeBg];
    [codeBg mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(titleL.mas_bottom).offset(30);
        make.left.equalTo(self.view).offset(30);
        make.right.equalTo(self.view).offset(-30);
        make.height.equalTo(@60);
    }];
    codeBg.layer.cornerRadius = 6;
    codeBg.userInteractionEnabled = YES;
    UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(codeBtnAction)];
    [codeBg addGestureRecognizer:tap];
  
    UIView *userBg = [[UIView alloc] init];
    userBg.backgroundColor = [UIColor whiteColor];
    [self.view addSubview:userBg];
    [userBg mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(codeBg.mas_bottom).offset(20);
        make.left.equalTo(self.view).offset(30);
        make.right.equalTo(self.view).offset(-30);
        make.height.equalTo(@60);
    }];
    userBg.layer.cornerRadius = 6;
    
    UIView *passwordBg = [[UIView alloc] init];
    passwordBg.backgroundColor = [UIColor whiteColor];
    [self.view addSubview:passwordBg];
    [passwordBg mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(userBg.mas_bottom).offset(20);
        make.left.equalTo(self.view).offset(30);
        make.right.equalTo(self.view).offset(-30);
        make.height.equalTo(@60);
    }];
    passwordBg.layer.cornerRadius = 6;
    
    UIImageView *codeImageV = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"coding"]];
    [self.view addSubview:codeImageV];
    [codeImageV mas_makeConstraints:^(MASConstraintMaker *make) {
        make.size.mas_equalTo(CGSizeMake(24, 24));
        make.left.equalTo(codeBg).offset(20);
        make.centerY.equalTo(codeBg);
    }];
    UILabel *codeL = [UILabel z_labelWithText:@"BIMe协作平台" Color:PBColor(40, 58, 79) isBold:YES Font:16];
    [self.view addSubview:codeL];
    [codeL mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(codeBg).offset(64);
        make.top.bottom.equalTo(codeBg);
        make.right.equalTo(codeBg).offset(-50);
    }];
    UIImageView *arrow_right = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"arrow_right"]];
    [self.view addSubview:arrow_right];
    [arrow_right mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(codeBg);
        make.size.mas_equalTo(CGSizeMake(24, 24));
        make.right.equalTo(codeBg).offset(-20);
    }];
    UIImageView *userImageV = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"account"]];
    [self.view addSubview:userImageV];
    [userImageV mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(userBg);
        make.size.mas_equalTo(CGSizeMake(24, 24));
        make.left.equalTo(userBg).offset(20);
    }];
    UITextField *userTF = [[UITextField alloc] init];
    [self.view addSubview:userTF];
    userTF.placeholder = @"请输入邮箱/手机号/账号";
    userTF.textColor = PBColor(40, 58, 79);
    userTF.keyboardType = UIKeyboardTypeNumbersAndPunctuation;
    userTF.clearButtonMode = UITextFieldViewModeAlways;
    userTF.delegate = self;
    userTF.returnKeyType = UIReturnKeyNext;
    userTF.font = [UIFont fontWithName:Coarse size:16];
    [userTF mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(userBg).offset(64);
        make.top.bottom.equalTo(userBg);
        make.right.equalTo(userBg).offset(-20);
    }];
    UIImageView *passwordImageV = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"password"]];
    [self.view addSubview:passwordImageV];
    [passwordImageV mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(passwordBg);
        make.size.mas_equalTo(CGSizeMake(24, 24));
        make.left.equalTo(passwordBg).offset(20);
    }];
    UITextField *passwordTF = [[UITextField alloc] init];
    [self.view addSubview:passwordTF];
    passwordTF.placeholder = @"请输入密码";
    passwordTF.textColor = PBColor(40, 58, 79);
    passwordTF.keyboardType = UIKeyboardTypeASCIICapable;
    passwordTF.secureTextEntry = YES;
//    passwordTF.clearButtonMode = UITextFieldViewModeAlways;
    passwordTF.enablesReturnKeyAutomatically = YES;
    passwordTF.returnKeyType = UIReturnKeyDone;
    passwordTF.delegate = self;
    passwordTF.font = [UIFont fontWithName:Coarse size:16];
    [passwordTF mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(passwordBg).offset(64);
        make.top.bottom.equalTo(passwordBg);
        make.right.equalTo(passwordBg).offset(-50);
    }];
    UIButton *encryptionBtn = [UIButton z_bgNormalImage:[UIImage imageNamed:@"invisible"] bgSelectedImage:[UIImage imageNamed:@"visible"]];
    [encryptionBtn addTarget:self action:@selector(enctyptionAction:) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:encryptionBtn];
    [encryptionBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(passwordBg);
        make.size.mas_equalTo(CGSizeMake(24, 24));
        make.right.equalTo(passwordBg).offset(-20);
    }];
    
    UIButton *loginBtn = [[UIButton alloc] init];
    [loginBtn setImage:[UIImage imageNamed:@"Login_loginBtn_diss"] forState:UIControlStateDisabled];
    [loginBtn setImage:[UIImage imageNamed:@"Login_loginBtn_norm"] forState:UIControlStateNormal];
    loginBtn.enabled = NO;
    [loginBtn addTarget:self action:@selector(loginAction:) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:loginBtn];
    [loginBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(passwordBg.mas_bottom).offset(80);
        make.left.equalTo(self.view).offset(30);
        make.right.equalTo(self.view).offset(-30);
        make.height.equalTo(@60);
    }];
//    [loginBtn circleViewWithRadius:6];
    
    UIButton *clockBtn = [UIButton z_textButton:@"打卡" boldFontSize:16 normalColor:PBColor(40, 58, 79)];
    [clockBtn addTarget:self action:@selector(clockAction) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:clockBtn];
    [clockBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(loginBtn.mas_bottom).offset(20);
        make.right.equalTo(loginBtn);
    }];
    
    UILabel *agreeL = [UILabel z_labelWithText:@"登录代表同意" Color:DescColor isBold:YES Font:12];
    [self.view addSubview:agreeL];
    [agreeL mas_makeConstraints:^(MASConstraintMaker *make) {
        make.bottom.equalTo(self.view).offset(-20);
        make.left.equalTo(self.view).offset(47);
        make.size.mas_equalTo(CGSizeMake(78, 16));
    }];
    UIButton *agreeBtn = [UIButton z_textButton:@"《管理平台用户协议》和《隐私政策》" boldFontSize:12 normalColor:PBColor(0, 122, 255)];
    [agreeBtn addTarget:self action:@selector(agreementAction) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:agreeBtn];
    [agreeBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.bottom.equalTo(self.view).offset(-20);
        make.left.equalTo(agreeL.mas_right);
        make.height.equalTo(@16);
    }];
    self.codeL = codeL;
    self.userNameTF = userTF;
    self.passwordTF = passwordTF;
    self.titleL = titleL;
    self.loginBtn = loginBtn;
}
- (void)enctyptionAction:(UIButton *)button {
    button.selected = !button.selected;
    if (button.selected) {
        self.passwordTF.secureTextEntry = NO;
    }else {
        self.passwordTF.secureTextEntry = YES;
    }
}
- (void)clockAction {
    PBSitePerViewController *moduleVC = [[PBSitePerViewController alloc] init];
    moduleVC.isFromLogin = YES;
    PBProjectModel *projectModel = [[PBProjectModel alloc] init];
    projectModel.organizeid = @"726970e7-005a-42d7-8ab4-0703d9d02957";
    moduleVC.projectModel = projectModel;
    UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:moduleVC];
    nav.modalPresentationStyle = UIModalPresentationFullScreen;
    [self presentViewController:nav animated:YES completion:nil];
}
#pragma mark -查看协议
- (void)agreementAction {
    PBAgreementViewController *agreementVC = [[PBAgreementViewController alloc] init];
    PBNavigationController *nav = [[PBNavigationController alloc] initWithRootViewController:agreementVC];
    nav.modalPresentationStyle = UIModalPresentationFullScreen;
    [self presentViewController:nav animated:YES completion:nil];
}
#pragma mark - 编辑企业码
- (void)codeBtnAction {
    PBEnterpriseCodeController *codeVC = [[PBEnterpriseCodeController alloc] init];
    codeVC.SetCodeBlock = ^(NSString * _Nonnull code, NSDictionary * _Nonnull obj) {
        self.customData = obj;
        NSMutableArray *arrM = [[NSMutableArray alloc] init];
        NSArray *arr = [NSString getApiArrData];
        BOOL isHave = false;
        for (NSDictionary *dict in arr) {
            NSString *haveCode = [dict valueForKey:@"Code"];
            if ([code isEqualToString:haveCode]) {
                [arrM addObject:obj];
                isHave = true;
            } else {
                [dict setValue:@"0" forKey:@"Check"];
                [arrM addObject:dict];
            }
        }
        if (!isHave) {
            [arrM addObject:self.customData];
        }
        [self saveApiArr:arrM.copy];
        [self storedLocallyApiWithData:self.customData];
        [self setApi];
    };
    codeVC.UpdataCodeBlock = ^(NSInteger index) {
        NSMutableArray *arrM = [[NSMutableArray alloc] init];
        NSArray *arr = [NSString getApiArrData];
        for (NSInteger i = 0; i < arr.count; i++) {
            NSDictionary *dict = arr[i];
            if (i == index) {
                [dict setValue:@"1" forKey:@"Check"];
            }else {
                [dict setValue:@"0" forKey:@"Check"];
            }
            [arrM addObject:dict];
        }
        self.customData = arrM[index];
        [self saveApiArr:arrM.copy];
        [self storedLocallyApiWithData:self.customData];
        [self setApi];
    };
    codeVC.DeleteCodeBlock = ^(NSInteger index) {
        NSMutableArray *arrM = [[NSString getApiArrData] mutableCopy];
        [arrM removeObjectAtIndex:index];
        [self saveApiArr:arrM.copy];
    };
    PBNavigationController *nav = [[PBNavigationController alloc] initWithRootViewController:codeVC];
    [self presentViewController:nav animated:YES completion:nil];
    
   
//    UIAlertController *alertVC = [UIAlertController alertControllerWithTitle:@"请输入企业编码" message:@"为空即设为BIMe数据协作平台服务" preferredStyle:UIAlertControllerStyleAlert];
//    UIAlertAction *cancelAction  = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:nil];
//    UIAlertAction *determineAction  = [UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
//        //        [[NSNotificationCenter defaultCenter] removeObserver:self name:UITextFieldTextDidChangeNotification object:nil];
//        [self getEnterpriseWithCode:alertVC.textFields.firstObject.text];
//    }];
//    //    determineAction.enabled = NO;
//    [alertVC addTextFieldWithConfigurationHandler:^(UITextField * _Nonnull textField) {
//        //        [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(alertTextFieldDidChange:) name:UITextFieldTextDidChangeNotification object:textField];
//        textField.keyboardType = UIKeyboardTypeNumberPad;
//        textField.placeholder = @"请输入企业编码";
//    }];
//    [alertVC addAction:cancelAction];
//    [alertVC addAction:determineAction];
//    [self presentViewController:alertVC animated:YES completion:nil];
}
 
//- (void)alertTextFieldDidChange:(NSNotification *)notification{
//    UIAlertController *alertController = (UIAlertController *)self.presentedViewController;
//    if (alertController) {
//        UITextField *codeTF = alertController.textFields.firstObject;
//        UIAlertAction *determineAction = alertController.actions.lastObject;
//        determineAction.enabled = codeTF.text.length > 0;
//    }
//}
 
//#pragma mark - 更改密码
//- (void)forgotPasswordAction {
//    NSLog(@"更改密码");
//    
//}
#pragma mark - 登录
- (void)loginAction:(UIButton *)button {
    [YJProgressHUD showProgress:@"正在登录" inView:self.view];
    [[PBNetworkTools sharedTools] loginWithUserName:self.userNameTF.text andPassword:self.passwordTF.text andCallBack:^(NSURLSessionDataTask *task, id response, NSError *error) {
        if (error) {
            [YJProgressHUD showMessage:@"登录失败" inView:self.view];
            return ;
        }
        NSString *str = [[NSString alloc] initWithData:response encoding:NSUTF8StringEncoding];
        PBNetworkModel *networkModel = [PBNetworkModel yy_modelWithJSON:str];
        if (networkModel.Ret == 1) {
//            [YJProgressHUD hide];
            //存储本地
            [self saveTokenToLocalWith:[networkModel.Data valueForKey:@"token"]];
            [self savePasswordWith:self.userNameTF.text andPassword:self.passwordTF.text];
            [JPUSHService setAlias:[networkModel.Data valueForKey:@"alpha"] completion:^(NSInteger iResCode, NSString *iAlias, NSInteger seq) {
                NSLog(@"=============设置别名:%@",iAlias);
                NSLog(@"%zd",seq);
            } seq:1];
            [self loadToken];
        }else {
            [YJProgressHUD showMessage:networkModel.Msg inView:self.view];
        }
    }];
}
- (void)loadToken {
    [[PBNetworkTools sharedTools] getOnlyTestTokenAndCallBack:^(NSURLSessionDataTask *task, id response, NSError *error) {
        if (error) {
            NSLog(@"%@",error);
            [YJProgressHUD showMessage:@"加载登录人信息失败" inView:self.view];
            return;
        }
        NSString *str = [[NSString alloc] initWithData:response encoding:NSUTF8StringEncoding];
        PBNetworkModel *networkModel = [PBNetworkModel yy_modelWithJSON:str];
        if (networkModel.Ret == 1) {
            NSArray *array = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
            NSString *documents = [array lastObject];
            NSString *documentPath = [documents stringByAppendingPathComponent:@"login.plist"];
            NSDictionary *dict = @{
                                   @"RealName":[networkModel.Data valueForKey:@"RealName"],
                                   @"Account":[networkModel.Data valueForKey:@"Account"],
                                   @"UserId":[networkModel.Data valueForKey:@"apisession_userid"]
                                   };
            [dict writeToFile:documentPath atomically:YES];
            if (self.LoginSuccessfulBlock) {
                self.LoginSuccessfulBlock();
            }
            [self dismissViewControllerAnimated:YES completion:nil];
        }else {
            [YJProgressHUD showMessage:@"加载登录人信息失败" inView:self.view];
        }
    }];
}
 
- (void)saveTokenToLocalWith:(NSString *)token {
    NSArray *array = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
    NSString *documents = [array lastObject];
    NSString *documentPath = [documents stringByAppendingPathComponent:@"token.plist"];
    NSDictionary *dict = @{
                           @"token":token
                           };
    [dict writeToFile:documentPath atomically:YES];
}
- (void)savePasswordWith:(NSString *)name andPassword:(NSString *)pass {
    NSArray *array = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
    NSString *documents = [array lastObject];
    NSString *documentPath = [documents stringByAppendingPathComponent:@"info.plist"];
    NSDictionary *dict = @{
                           @"username":name,
                           @"pass":pass
                           };
    [dict writeToFile:documentPath atomically:YES];
}
- (void)setApi {
    self.codeL.text = [self.customData valueForKey:@"CompanyName"];
}
 
- (void)storedLocallyApiWithData:(NSDictionary *)data {
    NSArray *array = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
    NSString *documents = [array lastObject];
    NSString *documentPath = [documents stringByAppendingPathComponent:@"api.plist"];
    [data writeToFile:documentPath atomically:YES];
}
- (void)saveApiArr:(NSArray *)arr {
    NSArray *array = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
    NSString *documents = [array lastObject];
    NSString *documentPath = [documents stringByAppendingPathComponent:@"apiArr.plist"];
    [arr writeToFile:documentPath atomically:YES];
}
#pragma mark - UITextFieldDelegate
- (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string {
    NSInteger textlength = textField.text.length;
    if ([string isEqualToString:@""]) {
        textlength -= range.length;
    }else {
        textlength += string.length;
    }
    if (textlength == 0){
        self.loginBtn.enabled = NO;
        return YES;
    }
    if (textField == self.userNameTF) {
        if (self.passwordTF.text.length == 0) {
            self.loginBtn.enabled = NO;
        }else {
            self.loginBtn.enabled = YES;
        }
    }else {
        if (self.userNameTF.text.length == 0) {
            self.loginBtn.enabled = NO;
        }else {
            self.loginBtn.enabled = YES;
        }
    }
    return YES;
}
- (BOOL)textFieldShouldClear:(UITextField *)textField {
    self.loginBtn.enabled = NO;
    return YES;
}
- (BOOL)textFieldShouldReturn:(UITextField *)textField {
    if (textField == _userNameTF) {
        [_passwordTF becomeFirstResponder];
    }else {
        [self.view endEditing:NO];
    }
    return YES;
}
 
- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event {
    [self.view endEditing:NO];
}
 
- (NSDictionary *)bim365Data {
    if (_bim365Data == nil) {
//        _bim365Data = @{
//                        @"ModelApi" : @"https://bimcomposer.bim365.com.cn:443",
//                        @"NewApi" : @"https://newapi.bim365.com.cn:443",
//                        @"AppApi" : @"https://api.bim365.com.cn:443",
//                        @"Web" : @"https://www.bim365.com.cn:443",
//                        @"NewWeb" : @"https://www.bim365.com.cn",
//                        @"LogoUrl" : @"https://www.bim365.com.cn:443/Content/function/Login/images/Simple_logo.png",
//                        @"CompanyName" : @"BIMe数据协作平台",
//                        @"Code" : bim365Code,
//                        @"StarName" : @"STAR_bim365_com_cn",
//                        @"Check" : @"1"
//                        };
        _bim365Data = @{
                        @"ModelApi" : @"https://bime.shinewing.com:6081",
                        @"Panorama": @"errurl",
                        @"NewApi" : @"https://bime.shinewing.com:6082",
                        @"AppApi" : @"errurl",
                        @"Web" : @"https://bime.shinewing.com:6080",
                        @"NewWeb" : @"https://bime.shinewing.com:6080",
                        @"LogoUrl" : @"https://bime.shinewing.com:6080/Content/function/Login/images/Simple_logo.png",
                        @"CompanyName" : @"管理平台",
                        @"Code" : bim365Code,
                        @"StarName" : @"",
                        @"Check" : @"1"
                        };
        /**
         ModelApi : "https://bimcomposer.bim365.com.cn:443"
         NewApi : "https://newapi.bim365.com.cn:443"
         AppApi : "https://api.bim365.com.cn:443"
         Web : "https://www.bim365.com.cn:443"
         NewWeb : "https://www.bim365.com.cn"
         LogoUrl : "https://www.bim365.com.cn:443/Content/function/Login/images/Simple_logo.png"
         CompanyName : "BIMe数据协作平台"
         StarName : "STAR_bim365_com_cn"
         
         @"ModelApi" : @"http://119.3.217.232:81",
         @"NewApi" : @"https://www.probim.cn:8080",
         @"AppApi" : @"http://119.3.217.232:82",
         @"Web" : @"https://www.probim.cn:8076",
         @"NewWeb" : @"http://www.probim.cn:8888",
         @"LogoUrl" : @"http://119.3.217.232:8075/Content/function/Login/images/Simple_logosl.png",
         @"CompanyName" : @"BIMe数据协作平台",
         @"Code" : bim365Code,
         @"StarName" : @"STAR_bim365_com_cn",
         @"Check" : @"1"
         */
    }
    return _bim365Data;
}
 
- (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