| | |
| | | #import "EZWifiConfigViewController.h" |
| | | #import "EZWifiTipsViewController.h" |
| | | #import "MBProgressHUD.h" |
| | | |
| | | #import "EZSDK.h" |
| | | |
| | | |
| | | @interface EZDeviceResultViewController ()<UIAlertViewDelegate> |
| | |
| | | [GlobalKit shareKit].deviceVerifyCode = [alertView textFieldAtIndex:0].text; |
| | | __weak MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:self.view animated:YES]; |
| | | hud.labelText = NSLocalizedString(@"ad_adding_msg", @"正在添加,请稍候..."); |
| | | [EZOPENSDK addDevice:[GlobalKit shareKit].deviceSerialNo |
| | | verifyCode:[GlobalKit shareKit].deviceVerifyCode |
| | | completion:^(NSError *error) { |
| | | [hud hide:YES]; |
| | | [self handleTheError:error]; |
| | | }]; |
| | | |
| | | // [EZOPENSDK addDevice:[GlobalKit shareKit].deviceSerialNo |
| | | // verifyCode:[GlobalKit shareKit].deviceVerifyCode |
| | | // completion:^(NSError *error) { |
| | | // [hud hide:YES]; |
| | | // [self handleTheError:error]; |
| | | // }]; |
| | | |
| | | [EZHttpUtil.sharedManager addDeviceByHDL:[GlobalKit shareKit].deviceSerialNo |
| | | verifyCode:[GlobalKit shareKit].deviceVerifyCode |
| | | completion:^(ResponseData *responseData) { |
| | | [hud hide:YES]; |
| | | [self handleTheError:responseData]; |
| | | }]; |
| | | |
| | | } |
| | | else if (alertView.tag == 0xbb && buttonIndex == 1) |
| | | { |
| | |
| | | { |
| | | __weak MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:self.view animated:YES]; |
| | | hud.labelText = NSLocalizedString(@"ad_adding_msg", @"正在添加,请稍候..."); |
| | | [EZOPENSDK addDevice:[GlobalKit shareKit].deviceSerialNo |
| | | verifyCode:[GlobalKit shareKit].deviceVerifyCode |
| | | completion:^(NSError *error) { |
| | | [hud hide:YES]; |
| | | [self handleTheError:error]; |
| | | }]; |
| | | // [EZOPENSDK addDevice:[GlobalKit shareKit].deviceSerialNo |
| | | // verifyCode:[GlobalKit shareKit].deviceVerifyCode |
| | | // completion:^(NSError *error) { |
| | | // [hud hide:YES]; |
| | | // [self handleTheError:error]; |
| | | // }]; |
| | | if ([GlobalKit shareKit].deviceType==HDLEZDeviceType_Door) {//为门禁设备(需要验证门锁) |
| | | [EZHttpUtil.sharedManager verifyLocalLockByHDL:[GlobalKit shareKit].deviceSerialNo completion:^(ResponseData * _Nonnull responseData) { |
| | | [hud hide:YES]; |
| | | if (responseData.success) { |
| | | self.resultLabel.numberOfLines=2; |
| | | self.resultLabel.adjustsFontSizeToFitWidth=YES; |
| | | self.resultLabel.text = NSLocalizedString(@"ad_result_verify_local_lock",@"请在2分钟之内校验已添加的主用户指纹、密钥或感应卡,校验完成请点击已校验按钮"); |
| | | |
| | | [self.actionButton setTitle:NSLocalizedString(@"ad_verified", @"已校验") forState:UIControlStateNormal]; |
| | | }else{ |
| | | [self handleTheError:responseData]; |
| | | } |
| | | |
| | | NSLog(@"调用验证接口返回:%@",responseData.data); |
| | | }]; |
| | | }else{ |
| | | [EZHttpUtil.sharedManager addDeviceByHDL:[GlobalKit shareKit].deviceSerialNo |
| | | verifyCode:[GlobalKit shareKit].deviceVerifyCode |
| | | completion:^(ResponseData *responseData) { |
| | | [hud hide:YES]; |
| | | [self handleTheError:responseData]; |
| | | }]; |
| | | } |
| | | |
| | | } |
| | | else |
| | | { |
| | |
| | | alertView.tag = 0xaa; |
| | | [alertView show]; |
| | | } |
| | | } |
| | | else if([self.actionButton.titleLabel.text isEqualToString:NSLocalizedString(@"ad_verified",@"已校验")]) |
| | | { |
| | | __weak MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:self.view animated:YES]; |
| | | hud.labelText = NSLocalizedString(@"ad_adding_msg", @"正在添加,请稍候..."); |
| | | [EZHttpUtil.sharedManager addDeviceByHDL:[GlobalKit shareKit].deviceSerialNo |
| | | verifyCode:[GlobalKit shareKit].deviceVerifyCode |
| | | completion:^(ResponseData *responseData) { |
| | | [hud hide:YES]; |
| | | if (!responseData.success){ |
| | | [self.view makeToast:NSLocalizedString(@"wifi_add_fail", @"添加失败") duration:2.0 position:@"center"]; |
| | | }else{ |
| | | [self handleTheError:responseData]; |
| | | } |
| | | |
| | | }]; |
| | | } |
| | | else |
| | | { |
| | |
| | | if (error.code == EZ_HTTPS_DEVICE_ADDED_MYSELF || error.code == EZ_HTTPS_DEVICE_ONLINE_ADDED) |
| | | { |
| | | self.statusLabel.textColor = [UIColor blackColor]; |
| | | self.statusLabel.text = NSLocalizedString(@"ad_already_added",@"您已添加过此设备"); |
| | | self.statusLabel.text = NSLocalizedString(@"ad_already_added",@"此设备已被添加"); |
| | | self.statusLabel.hidden = NO; |
| | | } |
| | | else if (error.code == EZ_HTTPS_DEVICE_ONLINE_IS_ADDED || error.code == EZ_HTTPS_DEVICE_OFFLINE_IS_ADDED) |
| | |
| | | |
| | | } |
| | | |
| | | - (void)handleTheError:(NSError *)error |
| | | - (void)handleTheError:(ResponseData *)responseData |
| | | { |
| | | if (!error) |
| | | if (responseData.success) |
| | | { |
| | | [self performSegueWithIdentifier:@"go2WifiResult" sender:nil]; |
| | | return; |
| | | } |
| | | if (error.code == 105002) |
| | | if ([responseData.code isEqual: @"20010"]) |
| | | { |
| | | UIAlertView *retryAlertView = [[UIAlertView alloc] initWithTitle:NSLocalizedString(@"device_verify_code_wrong", @"验证码错误") message:nil delegate:self cancelButtonTitle:NSLocalizedString(@"cancel", @"取消") otherButtonTitles:NSLocalizedString(@"retry", @"重试"), nil]; |
| | | retryAlertView.tag = 0xbb; |
| | | [retryAlertView show]; |
| | | } |
| | | else if (error.code == 105000) |
| | | else if ([responseData.code isEqual: @"20017"]) |
| | | { |
| | | [UIView dd_showMessage:NSLocalizedString(@"ad_already_added",@"您已添加过此设备")]; |
| | | } |
| | | else if (error.code == 105001) |
| | | else if ([responseData.code isEqual: @"20013"]) |
| | | { |
| | | [UIView dd_showMessage:NSLocalizedString(@"ad_added_by_others",@"此设备已被别人添加")]; |
| | | } |