From a67450d72c47f400e56525125318ff1d6ca0a2e8 Mon Sep 17 00:00:00 2001
From: Davin <591807572@qq.com>
Date: 星期三, 18 十二月 2024 10:39:33 +0800
Subject: [PATCH] feature 萤石活动检测&画面翻转调整

---
 EZSDK/EZSDK/EZ/TempPassword/Controllers/HDLEZDetectionTypeViewController.m |   54 +++++++++++++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 53 insertions(+), 1 deletions(-)

diff --git a/EZSDK/EZSDK/EZ/TempPassword/Controllers/HDLEZDetectionTypeViewController.m b/EZSDK/EZSDK/EZ/TempPassword/Controllers/HDLEZDetectionTypeViewController.m
index 37b2a3a..5b5c5ea 100644
--- a/EZSDK/EZSDK/EZ/TempPassword/Controllers/HDLEZDetectionTypeViewController.m
+++ b/EZSDK/EZSDK/EZ/TempPassword/Controllers/HDLEZDetectionTypeViewController.m
@@ -6,10 +6,13 @@
 //
 
 #import "HDLEZDetectionTypeViewController.h"
+#import "HDLESDetectionTypeHeaderView.h"
 #import "HDLEZDetectionTypeView.h"
 #import "MJRefreshNormalHeader.h"
 
 @interface HDLEZDetectionTypeViewController ()
+
+@property (nonatomic, strong) HDLESDetectionTypeHeaderView *detectionTypeHeaderView;
 
 @property (nonatomic, strong) HDLEZDetectionTypeView *detectionTypeView;
 
@@ -43,11 +46,18 @@
     self.view.backgroundColor = HDLEZHEXCOLOR(0xF2F3F7, 1.);
     
     self.selectedCode = @"";
+    [self.view addSubview:self.detectionTypeHeaderView];
     [self.view addSubview:self.detectionTypeView];
     [self.view addSubview:self.sureButton];
     
-    [self.detectionTypeView mas_makeConstraints:^(MASConstraintMaker *make) {
+    [self.detectionTypeHeaderView mas_makeConstraints:^(MASConstraintMaker *make) {
         make.top.equalTo(self.view).offset(HDLEZ_APP_TOP_BAR_HEIGHT);
+        make.left.right.equalTo(self.view);
+        make.height.mas_equalTo(60);
+    }];
+    
+    [self.detectionTypeView mas_makeConstraints:^(MASConstraintMaker *make) {
+        make.top.equalTo(self.view).offset(HDLEZ_APP_TOP_BAR_HEIGHT + 70);
         make.left.right.equalTo(self.view);
     }];
     
@@ -89,6 +99,32 @@
 //    self.detectionTypeView.detectionTypeList = mArray;
     
     __weak __typeof(self)weakSelf = self;
+    BOOL isDefence = (self.deviceInfo.defence != 0);
+    [self updateDetectionView:isDefence];
+    
+    [self.detectionTypeHeaderView configSelected:isDefence switchResult:^(BOOL isSelected) {
+        __weak MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:self.view animated:YES];
+        hud.labelText = NSLocalizedString(@"setting_switching", @"姝e湪鍒囨崲锛岃绋嶅��...");
+        /**
+         *  娉ㄦ剰锛涜demo鍙鐞嗕簡IPC璁惧鐨勫竷鎾ら槻锛屾墍鏈夊彧鏈塝ES/NO锛屽叧浜嶢绯诲垪璁惧璇峰垽鏂澶囧悗淇敼鏋氫妇鍊煎啀澶勭悊
+         */
+        [EZOPENSDK setDefence:isSelected
+                 deviceSerial:weakSelf.deviceInfo.deviceSerial
+                   completion:^(NSError *error) {
+            
+            [hud hide:YES];
+            if (error) {
+                [weakSelf.view makeToast:NSLocalizedString(@"setting_opration_fail", @"鎿嶄綔澶辫触") duration:2.0 position:@"center"];
+                [weakSelf.detectionTypeHeaderView configSelected:!isSelected];
+            }
+            else{
+                weakSelf.deviceInfo.defence = isSelected;
+            }
+            BOOL isDefence = (weakSelf.deviceInfo.defence != 0);
+            [weakSelf updateDetectionView:isDefence];
+        }];
+    }];
+    
     [self.detectionTypeView didSelectedDetectionType:^(NSString * _Nonnull code) {
         weakSelf.selectedCode = code;
     }];
@@ -108,6 +144,11 @@
     [_header beginRefreshing];
     
     [self.sureButton addTarget:self action:@selector(sureAction) forControlEvents:UIControlEventTouchUpInside];
+}
+
+- (void)updateDetectionView:(BOOL)isDefence {
+    self.detectionTypeView.hidden = !isDefence;
+    self.sureButton.hidden = !isDefence;
 }
 
 
@@ -150,7 +191,10 @@
 - (void)sureAction {
     if (self.selectedCode && self.selectedCode.length > 0) {
         __weak __typeof(self)weakSelf = self;
+        __weak MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:self.view animated:YES];
+        hud.labelText = NSLocalizedString(@"setting_switching", @"姝e湪鍒囨崲锛岃绋嶅��...");
         [[EZHttpUtil sharedManager] setAiSupportDetection:self.deviceInfo.deviceSerial code:self.selectedCode completion:^(ResponseData * _Nonnull responseData) {
+            [hud hide:YES];
             if (responseData.success) {
                 [weakSelf.view makeToast:HDLEZLocallizedString(@"setting_opration_success")
                                 duration:1.5
@@ -166,6 +210,14 @@
 }
 
 #pragma mark - Getter
+- (HDLESDetectionTypeHeaderView *)detectionTypeHeaderView {
+    if (!_detectionTypeHeaderView) {
+        _detectionTypeHeaderView = [[HDLESDetectionTypeHeaderView alloc] init];
+        _detectionTypeHeaderView.backgroundColor = [UIColor whiteColor];
+    }
+    return _detectionTypeHeaderView;
+}
+
 - (HDLEZDetectionTypeView *)detectionTypeView {
     if (!_detectionTypeView) {
         _detectionTypeView = [[HDLEZDetectionTypeView alloc] init];

--
Gitblit v1.8.0