From 48c5a2c66c549d26fecadc6d2dad1924fdd1cc8b Mon Sep 17 00:00:00 2001
From: Davin <591807572@qq.com>
Date: 星期四, 27 七月 2023 13:52:08 +0800
Subject: [PATCH] bugfix 猫眼呼叫问题修复
---
EZSDK/EZSDK/EZ/UIViewControllers/EZWifiConfigViewController.m | 283 ++++++++++++++++++++++++++++++++++++--------------------
1 files changed, 181 insertions(+), 102 deletions(-)
diff --git a/EZSDK/EZSDK/EZ/UIViewControllers/EZWifiConfigViewController.m b/EZSDK/EZSDK/EZ/UIViewControllers/EZWifiConfigViewController.m
index 19adcb3..99162d9 100644
--- a/EZSDK/EZSDK/EZ/UIViewControllers/EZWifiConfigViewController.m
+++ b/EZSDK/EZSDK/EZ/UIViewControllers/EZWifiConfigViewController.m
@@ -11,6 +11,7 @@
#import "DDKit.h"
#import "EZDeviceTableViewController.h"
#import "EZDdnsDeviceTableViewController.h"
+#import "EZAddByQRCodeViewController.h"
// 璁惧bonjour鎼滅储鍒扮殑鐘舵�佹爣绀�
typedef enum _DEVICE_STATE
@@ -89,14 +90,14 @@
}
/*
-#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.
-}
-*/
+ #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.
+ }
+ */
#pragma mark - UIAlertViewDelgate Methods
@@ -107,11 +108,18 @@
self.enState = STATE_PLAT;
[self createTimerWithTimeOut:30];
[GlobalKit shareKit].deviceVerifyCode = [alertView textFieldAtIndex:0].text;
- [EZOPENSDK addDevice:[GlobalKit shareKit].deviceSerialNo
- verifyCode:[GlobalKit shareKit].deviceVerifyCode
- completion:^(NSError *error) {
- [self handleTheError:error];
- }];
+ // [EZOPENSDK addDevice:[GlobalKit shareKit].deviceSerialNo
+ // verifyCode:[GlobalKit shareKit].deviceVerifyCode
+ // completion:^(NSError *error) {
+ // [self handleTheError:error];
+ // }];
+ //2021-03-03 娣诲姞璁惧鐨勬柟娉曢兘淇敼鎴愭渤涓滅殑鎺ュ彛鏂规硶
+ [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)
{
@@ -133,58 +141,63 @@
NSInteger mode = 0;
mode |= self.supportSmartMode?EZWiFiConfigSmart:0;
mode |= self.supportSoundMode?EZWiFiConfigWave:0;
-
+
__weak typeof(self) weakSelf = self;
[EZOPENSDK startConfigWifi:weakSelf.ssid
password:weakSelf.password
deviceSerial:[GlobalKit shareKit].deviceSerialNo
mode:mode
deviceStatus:^(EZWifiConfigStatus status, NSString *deviceSerial) {
- if (status == DEVICE_WIFI_CONNECTING)
- {
- weakSelf.enState = STATE_NONE;
- [weakSelf createTimerWithTimeOut:60];
- }
- else if (status == DEVICE_WIFI_CONNECTED)
- {
- if(weakSelf.enState != STATE_WIFI){
- weakSelf.enState = STATE_WIFI;
- [weakSelf createTimerWithTimeOut:60];
- }
- }
- else if (status == DEVICE_PLATFORM_REGISTED)
- {
- weakSelf.enState = STATE_PLAT;
- [weakSelf createTimerWithTimeOut:30];
- if([GlobalKit shareKit].deviceVerifyCode != nil)
- {
- [EZOPENSDK addDevice:[GlobalKit shareKit].deviceSerialNo
- verifyCode:[GlobalKit shareKit].deviceVerifyCode
- completion:^(NSError *error) {
- [weakSelf handleTheError:error];
- }];
- }
- else
- {
- UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:NSLocalizedString(@"device_input_vierify_code", @"璇疯緭鍏ヨ澶囬獙璇佺爜") message:@"" delegate:weakSelf cancelButtonTitle:NSLocalizedString(@"cancel",@"鍙栨秷") otherButtonTitles:NSLocalizedString(@"done",@"纭畾"), nil];
- alertView.alertViewStyle = UIAlertViewStyleSecureTextInput;
- alertView.tag = 0xaa;
- [alertView show];
- dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(2.0f * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
- if ([_countTimer isValid])
- {
- [_countTimer invalidate];
- _countTimer = nil;
- }
- });
- }
- }
- }];
+ if (status == DEVICE_WIFI_CONNECTING)
+ {
+ weakSelf.enState = STATE_NONE;
+ [weakSelf createTimerWithTimeOut:60];
+ }
+ else if (status == DEVICE_WIFI_CONNECTED)
+ {
+ if(weakSelf.enState != STATE_WIFI){
+ weakSelf.enState = STATE_WIFI;
+ [weakSelf createTimerWithTimeOut:60];
+ }
+ }
+ else if (status == DEVICE_PLATFORM_REGISTED)
+ {
+ weakSelf.enState = STATE_PLAT;
+ [weakSelf createTimerWithTimeOut:30];
+ if([GlobalKit shareKit].deviceVerifyCode != nil)
+ {
+ // [EZOPENSDK addDevice:[GlobalKit shareKit].deviceSerialNo
+ // verifyCode:[GlobalKit shareKit].deviceVerifyCode
+ // completion:^(NSError *error) {
+ // [weakSelf handleTheError:error];
+ // }];
+ [EZHttpUtil.sharedManager addDeviceByHDL:[GlobalKit shareKit].deviceSerialNo
+ verifyCode:[GlobalKit shareKit].deviceVerifyCode
+ completion:^(ResponseData *responseData) {
+ [weakSelf handleTheError:responseData];
+ }];
+ }
+ else
+ {
+ UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:NSLocalizedString(@"device_input_vierify_code", @"璇疯緭鍏ヨ澶囬獙璇佺爜") message:@"" delegate:weakSelf cancelButtonTitle:NSLocalizedString(@"cancel",@"鍙栨秷") otherButtonTitles:NSLocalizedString(@"done",@"纭畾"), nil];
+ alertView.alertViewStyle = UIAlertViewStyleSecureTextInput;
+ alertView.tag = 0xaa;
+ [alertView show];
+ dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(2.0f * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
+ if ([_countTimer isValid])
+ {
+ [_countTimer invalidate];
+ _countTimer = nil;
+ }
+ });
+ }
+ }
+ }];
}
else
{
[self createAddDeviceInitView];
-
+
_enState = STATE_SUCC;
[self showTipsView];
}
@@ -232,37 +245,52 @@
[EZOPENSDK probeDeviceInfo:[GlobalKit shareKit].deviceSerialNo
deviceType:[GlobalKit shareKit].deviceModel
completion:^(EZProbeDeviceInfo *deviceInfo, NSError *error) {
- if (error)
- {
- //鏈夐敊璇洿鎺ユ樉绀洪敊璇殑UI
- [self showFailedView];
- }
- else
- {
- if ([GlobalKit shareKit].deviceVerifyCode != nil)
- {
- [EZOPENSDK addDevice:[GlobalKit shareKit].deviceSerialNo
- verifyCode:[GlobalKit shareKit].deviceVerifyCode
- completion:^(NSError *error) {
- if (!error)
- {
- [self handleTheError:error];
- }
- else
- {
- [self showFailedView];
- }
- }];
- }
- else
- {
- UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:NSLocalizedString(@"device_input_vierify_code", @"璇疯緭鍏ヨ澶囬獙璇佺爜") message:@"" delegate:self cancelButtonTitle:NSLocalizedString(@"cancel",@"鍙栨秷") otherButtonTitles:NSLocalizedString(@"done",@"纭畾"), nil];
- alertView.alertViewStyle = UIAlertViewStyleSecureTextInput;
- alertView.tag = 0xaa;
- [alertView show];
- }
- }
- }];
+ if (error)
+ {
+ //鏈夐敊璇洿鎺ユ樉绀洪敊璇殑UI
+ [self showFailedView];
+ }
+ else
+ {
+ if ([GlobalKit shareKit].deviceVerifyCode != nil)
+ {
+ // [EZOPENSDK addDevice:[GlobalKit shareKit].deviceSerialNo
+ // verifyCode:[GlobalKit shareKit].deviceVerifyCode
+ // completion:^(NSError *error) {
+ // if (!error)
+ // {
+ // [self handleTheError:error];
+ // }
+ // else
+ // {
+ // [self showFailedView];
+ // }
+ // }];
+
+ [EZHttpUtil.sharedManager addDeviceByHDL:[GlobalKit shareKit].deviceSerialNo
+ verifyCode:[GlobalKit shareKit].deviceVerifyCode
+ completion:^(ResponseData *responseData) {
+ if (responseData.success)
+ {
+ [self handleTheError:responseData];
+ }
+ else
+ {
+ [self showFailedView];
+ }
+ }];
+
+
+ }
+ else
+ {
+ UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:NSLocalizedString(@"device_input_vierify_code", @"璇疯緭鍏ヨ澶囬獙璇佺爜") message:@"" delegate:self cancelButtonTitle:NSLocalizedString(@"cancel",@"鍙栨秷") otherButtonTitles:NSLocalizedString(@"done",@"纭畾"), nil];
+ alertView.alertViewStyle = UIAlertViewStyleSecureTextInput;
+ alertView.tag = 0xaa;
+ [alertView show];
+ }
+ }
+ }];
}
UILabel *timeLabel = (UILabel *)[self.timerImageView viewWithTag:0x11c];
@@ -417,10 +445,10 @@
self.registerLabel.font = [UIFont systemFontOfSize:15.0f];
self.registerLabel.textColor = [UIColor dd_hexStringToColor:@"0x666666"];
-
+
self.bindLabel.font = [UIFont systemFontOfSize:15.0f];
self.bindLabel.textColor = [UIColor dd_hexStringToColor:@"0x666666"];
-
+
self.wifiLabel.text = NSLocalizedString(@"wifi_connecting_net", @"钀ゅ皬鐭虫鍦ㄥ姫鍔涜繛鎺i-Fi缃戠粶");
self.registerLabel.text = NSLocalizedString(@"wifi_register_server", @"娉ㄥ唽骞冲彴鏈嶅姟鍣�");
self.bindLabel.text = NSLocalizedString(@"wifi_bind_account", @"缁戝畾浣犵殑璐﹀彿");
@@ -563,13 +591,20 @@
self.animationImageView.animationImages = nil;
//璋冩暣鍥剧墖楂樺害
- self.animationImageView.image = [UIImage imageNamed:@"addDevice_success"];//鎴愬姛鏍囩ず鍥剧墖
-
- [self.animationImageView mas_remakeConstraints:^(MASConstraintMaker *make) {
- make.top.mas_equalTo(@90);
- make.leading.trailing.mas_equalTo(@0);
- make.height.mas_equalTo(@(185 * [UIScreen mainScreen].bounds.size.width/320.0f));
+// self.animationImageView.image = [UIImage imageNamed:@"addDevice_success"];//鎴愬姛鏍囩ず鍥剧墖
+ self.animationImageView.image = [UIImage imageNamed:@"hdl_ez_add_device_success"];//鎴愬姛鏍囩ず鍥剧墖
+ [self.animationImageView mas_updateConstraints:^(MASConstraintMaker *make) {
+ make.top.mas_equalTo(@100);
+ make.leading.mas_equalTo(([UIScreen mainScreen].bounds.size.width-80)/2);
+ make.trailing.mas_equalTo(-([UIScreen mainScreen].bounds.size.width-80)/2);
+ make.height.mas_equalTo(80);
}];
+
+// [self.animationImageView mas_remakeConstraints:^(MASConstraintMaker *make) {
+// make.top.mas_equalTo(@90);
+// make.leading.trailing.mas_equalTo(@0);
+// make.height.mas_equalTo(@(185 * [UIScreen mainScreen].bounds.size.width/320.0f));
+// }];
[self.view addSubview:self.completionLabel];
@@ -672,7 +707,7 @@
case STATE_PLAT:
{
failedLab.text = NSLocalizedString(@"wifi_bind_fail", @"Wi-Fi閰嶇疆鎴愬姛,缁戝畾璐﹀彿澶辫触,璇烽噸璇�");
-
+
self.animationImageView.image = [UIImage imageNamed:@"failure_account"];//璁惧缁戝畾澶辫触
}
break;
@@ -683,11 +718,50 @@
self.failedTipsView.hidden = NO;
}
-- (void)handleTheError:(NSError *)error
+//- (void)handleTheError:(NSError *)error
+//{
+// [EZOPENSDK stopConfigWifi];
+//
+// if (!error)
+// {
+// if ([_countTimer isValid])
+// {
+// [_countTimer invalidate];
+// _countTimer = nil;
+// }
+// _enState = STATE_SUCC;
+// [self showTipsView];
+// return;
+// }
+//
+// if (error.code == 120010)
+// {
+// 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 == 120020)
+// {
+// [UIView dd_showMessage:NSLocalizedString(@"ad_already_added", @"鎮ㄥ凡娣诲姞杩囨璁惧")];
+// }
+// else if (error.code == 120022)
+// {
+// [UIView dd_showMessage:NSLocalizedString(@"ad_added_by_others", @"姝よ澶囧凡琚埆浜烘坊鍔�")];
+// }
+// else
+// {
+// [UIView dd_showMessage:NSLocalizedString(@"wifi_add_fail", @"娣诲姞澶辫触")];
+// }
+//}
+
+- (void)handleTheError:(ResponseData *)responseData
{
[EZOPENSDK stopConfigWifi];
- if (!error)
+ if (responseData.success)
{
if ([_countTimer isValid])
{
@@ -699,7 +773,7 @@
return;
}
- if (error.code == 120010)
+ if ([responseData.code isEqual: @"20010"])
{
UIAlertView *retryAlertView = [[UIAlertView alloc] initWithTitle:NSLocalizedString(@"device_verify_code_wrong", @"楠岃瘉鐮侀敊璇�")
message:nil delegate:self
@@ -708,11 +782,11 @@
retryAlertView.tag = 0xbb;
[retryAlertView show];
}
- else if (error.code == 120020)
+ else if ([responseData.code isEqual: @"20017"])
{
[UIView dd_showMessage:NSLocalizedString(@"ad_already_added", @"鎮ㄥ凡娣诲姞杩囨璁惧")];
}
- else if (error.code == 120022)
+ else if ([responseData.code isEqual: @"20013"])
{
[UIView dd_showMessage:NSLocalizedString(@"ad_added_by_others", @"姝よ澶囧凡琚埆浜烘坊鍔�")];
}
@@ -721,9 +795,7 @@
[UIView dd_showMessage:NSLocalizedString(@"wifi_add_fail", @"娣诲姞澶辫触")];
}
}
-
#pragma mark - Action Methods
-
- (void)completionButtonClicked:(id)sender
{
NSArray *viewControllers = self.navigationController.viewControllers;
@@ -742,6 +814,13 @@
[self.navigationController popToViewController:vc animated:YES];
break;
}
+
+ if ([vc isKindOfClass:[EZAddByQRCodeViewController class]])
+ {//璺宠浆鍒版壂鐮侀〉
+// ((EZAddByQRCodeViewController *)vc).shouldPop = YES;
+ [self.navigationController popToViewController:((EZAddByQRCodeViewController *)vc).prevController animated:YES];
+ break;
+ }
}
}
--
Gitblit v1.8.0