From 3698c13aba988cd3e41b91b255e1c682c057e565 Mon Sep 17 00:00:00 2001
From: chenqiyang <1406175257@qq.com>
Date: 星期四, 23 三月 2023 11:49:58 +0800
Subject: [PATCH] 1.新增历史记录相关页面及功能 2.修改配网为热点配网 3.设备列表增加过滤门锁功能 4.增加添加设备通知功能

---
 EZSDK/EZSDK/EZ/UIViewControllers/EZAPConfigResultViewController.m |  153 ++++++++++++++++++++++++++++++++++++++++++--------
 1 files changed, 127 insertions(+), 26 deletions(-)

diff --git a/EZSDK/EZSDK/EZ/UIViewControllers/EZAPConfigResultViewController.m b/EZSDK/EZSDK/EZ/UIViewControllers/EZAPConfigResultViewController.m
index d199690..1645fb3 100644
--- a/EZSDK/EZSDK/EZ/UIViewControllers/EZAPConfigResultViewController.m
+++ b/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
@@ -31,8 +34,11 @@
 - (void)viewDidLoad
 {
     [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
@@ -102,7 +149,7 @@
     [self stopTimer];
     
     self.addCount = 0;
-
+    
     self.timer = [NSTimer scheduledTimerWithTimeInterval:5.0
                                                   target:self
                                                 selector:@selector(timerCallback)
@@ -130,26 +177,56 @@
     [EZOPENSDK probeDeviceInfo:[GlobalKit shareKit].deviceSerialNo
                     deviceType:[GlobalKit shareKit].deviceModel
                     completion:^(EZProbeDeviceInfo *deviceInfo, NSError *error) {
-                        if (error)
-                        {
-                            [self probeErrorProcessWithError:error];
-                        }
-                        else
-                        {
-                            [EZOpenSDK addDevice:[GlobalKit shareKit].deviceSerialNo
-                                      verifyCode:[GlobalKit shareKit].deviceVerifyCode
-                                      completion:^(NSError *error) {
-                                          if (error)
-                                          {
-                                              [self addErrorProcessWithError:error];
-                                          }
-                                          else
-                                          {
-                                              [self successProcess];
-                                          }
-                                      }];
-                        }
-                    }];
+        if (error)
+        {
+            [self probeErrorProcessWithError:error];
+        }
+        else
+        {
+            //                            [EZOpenSDK addDevice:[GlobalKit shareKit].deviceSerialNo
+            //                                      verifyCode:[GlobalKit shareKit].deviceVerifyCode
+            //                                      completion:^(NSError *error) {
+            //                                          if (error)
+            //                                          {
+            //                                              [self addErrorProcessWithError:error];
+            //                                          }
+            //                                          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];
+                    }
+                    
+                }];
+            }
+
+            
+        }
+    }];
 }
 
 - (void) probeErrorProcessWithError:(NSError *) error
@@ -181,18 +258,42 @@
     [self.view makeToast:msg duration:2.0 position:@"center"];
 }
 
-- (void) addErrorProcessWithError:(NSError *) error
+//- (void) addErrorProcessWithError:(NSError *) error
+//{
+//    NSString *msg = nil;
+//    if (error.code == 120010)
+//    {
+//        msg = NSLocalizedString(@"device_verify_code_wrong", @"楠岃瘉鐮侀敊璇�");
+//    }
+//    else if (error.code == 120020)
+//    {
+//        msg = NSLocalizedString(@"ad_already_added", @"鎮ㄥ凡娣诲姞杩囨璁惧");
+//    }
+//    else if (error.code == 120022)
+//    {
+//        msg = NSLocalizedString(@"ad_added_by_others", @"姝よ澶囧凡琚埆浜烘坊鍔�");
+//    }
+//    else
+//    {
+//        msg = NSLocalizedString(@"wifi_add_fail", @"娣诲姞澶辫触");
+//    }
+//
+//    [self.view makeToast:msg duration:2.0 position:@"center"];
+//    self.msgLabel.hidden = YES;
+//}
+
+- (void) addErrorProcessWithError:(ResponseData *)responseData
 {
     NSString *msg = nil;
-    if (error.code == 120010)
+    if ([responseData.code isEqual: @"20010"])
     {
         msg = NSLocalizedString(@"device_verify_code_wrong", @"楠岃瘉鐮侀敊璇�");
     }
-    else if (error.code == 120020)
+    else if ([responseData.code isEqual: @"20017"])
     {
         msg = NSLocalizedString(@"ad_already_added", @"鎮ㄥ凡娣诲姞杩囨璁惧");
     }
-    else if (error.code == 120022)
+    else if ([responseData.code isEqual: @"20013"])
     {
         msg = NSLocalizedString(@"ad_added_by_others", @"姝よ澶囧凡琚埆浜烘坊鍔�");
     }

--
Gitblit v1.8.0