| | |
| | | #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 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]; |
| | | // }]; |
| | | [EZHttpUtil addDeviceByHDL:[GlobalKit shareKit].deviceSerialNo |
| | | verifyCode:[GlobalKit shareKit].deviceVerifyCode |
| | | completion:^(ResponseData *responseData) { |
| | | [hud hide:YES]; |
| | | [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",@"此设备已被别人添加")]; |
| | | } |