萤石云 iOSSDK,移植跨平台相关工程
EZSDK/EZSDK/EZ/UIViewControllers/EZAPConfigResultViewController.m
@@ -13,6 +13,7 @@
#import "Toast+UIView.h"
#import "EZDeviceTableViewController.h"
#import "EZAddByQRCodeViewController.h"
#define MAX_COUNT (20)
@@ -24,6 +25,8 @@
@property (weak, nonatomic) IBOutlet UILabel *msgLabel;
@property (nonatomic,strong) NSTimer *timer;
@property (nonatomic,assign) NSInteger addCount;
@property (nonatomic,strong) UIButton *verifiedBtn;//已校验按钮
@end
@implementation EZAPConfigResultViewController
@@ -33,6 +36,9 @@
    [super viewDidLoad];
    
    self.title = NSLocalizedString(@"wifi_ap_add_device_title", @"添加设备");
    self.msgLabel.numberOfLines=2;
    self.msgLabel.adjustsFontSizeToFitWidth=YES;
    
    [self initSubviews];
    
@@ -52,6 +58,18 @@
- (void) initSubviews
{
    [self.loadingIndicator startAnimating];
    //添加已验证按钮
    CGFloat screenHeight = self.view.frame.size.height;
    CGFloat screenWidth = self.view.frame.size.width;
    self.verifiedBtn=[[UIButton alloc] initWithFrame:CGRectMake((screenWidth-120)/2, screenHeight-150, 120, 30)];
    self.verifiedBtn.titleLabel.textColor=[UIColor whiteColor];
    [self.verifiedBtn setBackgroundColor:[UIColor orangeColor]];
    [self.verifiedBtn setTitle:NSLocalizedString(@"ad_verified", @"已校验") forState:UIControlStateNormal];
    [self.verifiedBtn addTarget:self action:@selector(verified) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:self.verifiedBtn];
    [self.verifiedBtn setHidden:YES];
}
#pragma mark - actions
@@ -67,6 +85,14 @@
            [self.navigationController popToViewController:vc animated:YES];
            break;
        }
        if ([vc isKindOfClass:[EZAddByQRCodeViewController class]])
        {//跳转到扫码页
            ((EZAddByQRCodeViewController *)vc).shouldPop = YES;
            [self.navigationController popToViewController:vc animated:YES];
            break;
        }
    }
}
@@ -78,6 +104,27 @@
    self.retryBtn.hidden = YES;
    
    [self startTimer];
}
/*已校验
 */
-(void)verified{
    self.loadingIndicator.hidden = NO;
    [self.loadingIndicator startAnimating];
    [EZHttpUtil.sharedManager addDeviceByHDL:[GlobalKit shareKit].deviceSerialNo
                    verifyCode:[GlobalKit shareKit].deviceVerifyCode
                    completion:^(ResponseData *responseData) {
        if (!responseData.success){
            [self.view makeToast:NSLocalizedString(@"wifi_add_fail", @"添加失败") duration:2.0 position:@"center"];
        }
        else
        {
            [self.verifiedBtn setHidden:YES];
            [self successProcess];
        }
    }];
}
#pragma mark - callback
@@ -148,20 +195,35 @@
            //                                              [self successProcess];
            //                                          }
            //                                      }];
            [EZHttpUtil.sharedManager addDeviceByHDL:[GlobalKit shareKit].deviceSerialNo
                            verifyCode:[GlobalKit shareKit].deviceVerifyCode
                            completion:^(ResponseData *responseData) {
                if (!responseData.success)
                {
                    [self addErrorProcessWithError:responseData];
                }
                else
                {
                    [self successProcess];
                }
            }];
            if ([GlobalKit shareKit].deviceType==HDLEZDeviceType_Door) {//为门锁
                [EZHttpUtil.sharedManager verifyLocalLockByHDL:[GlobalKit shareKit].deviceSerialNo completion:^(ResponseData * _Nonnull responseData) {
                    if (responseData.success) {
                        self.loadingIndicator.hidden = YES;
                        [self.loadingIndicator stopAnimating];
                        self.msgLabel.text = NSLocalizedString(@"ad_result_verify_local_lock",@"请在2分钟之内校验已添加的主用户指纹、密钥或感应卡,校验完成请点击已校验按钮");
                        [self.verifiedBtn setHidden:NO];
                    }else{
                        [self addErrorProcessWithError:responseData];
                    }
                }];
            }else{
                [EZHttpUtil.sharedManager addDeviceByHDL:[GlobalKit shareKit].deviceSerialNo
                                verifyCode:[GlobalKit shareKit].deviceVerifyCode
                                completion:^(ResponseData *responseData) {
                    if (!responseData.success)
                    {
                        [self addErrorProcessWithError:responseData];
                    }
                    else
                    {
                        [self successProcess];
                    }
                }];
            }
            
        }
    }];