From 4c1abca185a5727da6fb314a0cb4cd44bfe1b3bf Mon Sep 17 00:00:00 2001
From: Davin <591807572@qq.com>
Date: 星期五, 07 六月 2024 17:48:47 +0800
Subject: [PATCH] feature appkey修改
---
EZSDK/EZSDK/EZ/UIViewControllers/EZDeviceResultViewController.m | 268 +++++++++++++++++++++++++++++++++++++++++++++++++----
1 files changed, 246 insertions(+), 22 deletions(-)
diff --git a/EZSDK/EZSDK/EZ/UIViewControllers/EZDeviceResultViewController.m b/EZSDK/EZSDK/EZ/UIViewControllers/EZDeviceResultViewController.m
index 0c32699..aaa61ed 100644
--- a/EZSDK/EZSDK/EZ/UIViewControllers/EZDeviceResultViewController.m
+++ b/EZSDK/EZSDK/EZ/UIViewControllers/EZDeviceResultViewController.m
@@ -9,12 +9,12 @@
#import "EZDeviceResultViewController.h"
#import "UIImage+GIF.h"
-#import "EZProbeDeviceInfo.h"
+#import <EZOpenSDKFramework/EZProbeDeviceInfo.h>
#import "DDKit.h"
#import "EZWifiConfigViewController.h"
#import "EZWifiTipsViewController.h"
#import "MBProgressHUD.h"
-
+#import "EZSDK.h"
@interface EZDeviceResultViewController ()<UIAlertViewDelegate>
@@ -29,6 +29,21 @@
@property (nonatomic,assign) BOOL supportApMode;
@property (nonatomic,assign) BOOL supportSmartMode;
@property (nonatomic,assign) BOOL supportSoundMode;
+
+@property (nonatomic,strong) UIView *tipView ;//閰嶇綉鎻愮ずview
+
+@property (nonatomic,strong) UIImageView *step1TipImgV ;//姝ラ1鎻愮ず鍥緑iew
+@property (nonatomic,strong) UIImageView *step1ImgV ;//姝ラ1鍥緑iew
+@property (nonatomic,strong) UILabel *step1DescribeL ;//姝ラ1鎻忚堪lable
+
+@property (nonatomic,strong) UIImageView *step2TipImgV ;//姝ラ2鎻愮ず鍥緑iew
+@property (nonatomic,strong) UIImageView *step2ImgV ;//姝ラ2鍥緑iew
+@property (nonatomic,strong) UILabel *step2DescribeL ;//姝ラ2鎻忚堪lable
+
+
+@property (nonatomic,strong) UIView *btnBackView ;//鎸夐挳鑳屾櫙view
+@property (nonatomic,strong) UIButton *connectedBtn;//宸茶繛鎺ユ寜閽�
+
@end
@implementation EZDeviceResultViewController
@@ -48,6 +63,9 @@
self.actionButton.hidden = YES;
[self doSearchDevice];
+
+ //闅愯棌鐘舵�佸浘
+ self.resultImageView.hidden=YES;
}
- (void)didReceiveMemoryWarning {
@@ -82,12 +100,21 @@
[GlobalKit shareKit].deviceVerifyCode = [alertView textFieldAtIndex:0].text;
__weak MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:self.view animated:YES];
hud.labelText = NSLocalizedString(@"ad_adding_msg", @"姝e湪娣诲姞锛岃绋嶅��...");
- [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)
{
@@ -112,12 +139,36 @@
{
__weak MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:self.view animated:YES];
hud.labelText = NSLocalizedString(@"ad_adding_msg", @"姝e湪娣诲姞锛岃绋嶅��...");
- [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
{
@@ -126,6 +177,22 @@
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", @"姝e湪娣诲姞锛岃绋嶅��...");
+ [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
{
@@ -152,7 +219,7 @@
deviceType:[GlobalKit shareKit].deviceModel
completion:^(EZProbeDeviceInfo *deviceInfo, NSError *error) {
NSLog(@"deviceInfo = %@, error = %@", deviceInfo, error);
- self.resultBackgroudImageView.hidden = NO;
+// self.resultBackgroudImageView.hidden = NO;
self.resultImageView.image = [UIImage imageNamed:@"device_default"];
self.resultLabel.text = [GlobalKit shareKit].deviceSerialNo;
@@ -161,7 +228,7 @@
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)
@@ -174,6 +241,10 @@
error.code == EZ_HTTPS_DEVICE_NOT_EXISTS ||
error.code == EZ_HTTPS_DEVICE_OFFLINE_IS_ADDED_MYSELF)
{
+ if ([[EZSDK sharedInstance].connectTipModels containsObject:deviceInfo.model]||[self checkIfShouldTipWithDeviceModel:deviceInfo.model]) {//涓洪渶瑕佹彁绀洪厤缃戠殑绫诲瀷
+ [self showConnectWifiTipView];
+ return;
+ }
self.statusLabel.hidden = NO;
self.actionButton.hidden = NO;
if (deviceInfo)
@@ -189,6 +260,9 @@
self.supportSmartMode = YES;
self.supportSoundMode = YES;
}
+
+ self.statusLabel.text =HDLEZLocallizedString(@"wifi_config_not_connected");
+
[self.actionButton setTitle:NSLocalizedString(@"ad_connect_net", @"杩炴帴缃戠粶") forState:UIControlStateNormal];
}
else
@@ -212,30 +286,180 @@
}
-- (void)handleTheError:(NSError *)error
+/*妫�娴媘odel鏄惁鍖呭惈闇�瑕佹彁绀虹殑绫诲瀷
+ */
+-(BOOL)checkIfShouldTipWithDeviceModel:(NSString*)deviceModel{
+ for (NSString *model in [EZSDK sharedInstance].connectTipModels) {
+ if ([deviceModel containsString:[NSString stringWithFormat:@"-%@-",model]]) {
+ return YES;
+ break;
+ }
+ }
+ return NO;
+}
+
+/*鎻愮ずview
+ */
+-(UIView*)tipView{
+ if (!_tipView) {
+ //鎻愮ずview
+ _tipView=[[UIView alloc] init];
+ [self.view addSubview:_tipView];
+ [_tipView mas_makeConstraints:^(MASConstraintMaker *make) {
+ make.top.equalTo(self.view).offset(HDLEZ_APP_TOP_BAR_HEIGHT);
+ make.left.bottom.right.equalTo(self.view);
+ }];
+ _tipView.backgroundColor=HDLEZ_COLOR_VIEW_BACKGROUND;
+
+ //姝ラ1鎸囩ず鍥�
+ _step1TipImgV=[[UIImageView alloc] init];
+ [_tipView addSubview:_step1TipImgV];
+ [_step1TipImgV mas_makeConstraints:^(MASConstraintMaker *make) {
+ make.top.equalTo(_tipView).offset(33);
+ make.left.equalTo(_tipView).offset(HDLEZGetRealWidth(33));
+ make.width.mas_equalTo(130);
+ make.height.mas_equalTo(120);
+ }];
+ _step1TipImgV.image=[UIImage imageNamed:@"hdl_ez_wifi_connect_step1"];
+
+ //姝ラ1鍥�
+ _step1ImgV=[[UIImageView alloc] init];
+ [_tipView addSubview:_step1ImgV];
+ [_step1ImgV mas_makeConstraints:^(MASConstraintMaker *make) {
+ make.top.equalTo(_step1TipImgV.mas_bottom).offset(13);
+ make.left.equalTo(_step1TipImgV).offset(7);
+ make.width.mas_equalTo(19);
+ make.height.mas_equalTo(22);
+ }];
+ _step1ImgV.image=[UIImage imageNamed:@"hdl_ez_wifi_connect_step_one"];
+
+ //姝ラ1鎻忚堪lable
+ _step1DescribeL=[[UILabel alloc] init];
+ [_tipView addSubview:_step1DescribeL];
+ [_step1DescribeL mas_makeConstraints:^(MASConstraintMaker *make) {
+ make.top.equalTo(_step1ImgV.mas_bottom).offset(7);
+ make.left.equalTo(_step1ImgV);
+ make.right.equalTo(_step1TipImgV);
+ make.height.mas_equalTo(22);
+ }];
+ _step1DescribeL.font=HDLEZ_Get_FontBoldWithSize(HDLEZ_FontSize_16);
+ _step1DescribeL.textColor=HDLEZ_COLOR_TEXT_TITLE_GRAY;
+ _step1DescribeL.numberOfLines=2;
+ _step1DescribeL.adjustsFontSizeToFitWidth=YES;
+ _step1DescribeL.text=HDLEZLocallizedString(@"wifi_config_select_set_param");
+
+ //姝ラ2鎸囩ず鍥�
+ _step2TipImgV=[[UIImageView alloc] init];
+ [_tipView addSubview:_step2TipImgV];
+ [_step2TipImgV mas_makeConstraints:^(MASConstraintMaker *make) {
+ make.top.equalTo(_tipView).offset(33);
+ make.right.equalTo(_tipView).offset(HDLEZGetRealWidth(-33));
+ make.width.mas_equalTo(130);
+ make.height.mas_equalTo(120);
+ }];
+ _step2TipImgV.image=[UIImage imageNamed:@"hdl_ez_wifi_connect_step2"];
+
+ //姝ラ2鍥�
+ _step2ImgV=[[UIImageView alloc] init];
+ [_tipView addSubview:_step2ImgV];
+ [_step2ImgV mas_makeConstraints:^(MASConstraintMaker *make) {
+ make.top.equalTo(_step2TipImgV.mas_bottom).offset(13);
+ make.left.equalTo(_step2TipImgV).offset(7);
+ make.width.mas_equalTo(19);
+ make.height.mas_equalTo(22);
+ }];
+ _step2ImgV.image=[UIImage imageNamed:@"hdl_ez_wifi_connect_step_two"];
+
+ //姝ラ2鎻忚堪lable
+ _step2DescribeL=[[UILabel alloc] init];
+ [_tipView addSubview:_step2DescribeL];
+ [_step2DescribeL mas_makeConstraints:^(MASConstraintMaker *make) {
+ make.top.equalTo(_step2ImgV.mas_bottom).offset(7);
+ make.left.equalTo(_step2ImgV);
+ make.right.equalTo(_step2TipImgV);
+ make.height.mas_equalTo(22);
+ }];
+ _step2DescribeL.font=HDLEZ_Get_FontBoldWithSize(HDLEZ_FontSize_16);
+ _step2DescribeL.textColor=HDLEZ_COLOR_TEXT_TITLE_GRAY;
+ _step2DescribeL.numberOfLines=2;
+ _step2DescribeL.adjustsFontSizeToFitWidth=YES;
+ _step2DescribeL.text=HDLEZLocallizedString(@"wifi_config_select_wifi");
+
+ //宸茶繛鎺ユ寜閽儗鏅痸iew
+ _btnBackView=[[UIView alloc] init];
+ [_tipView addSubview:_btnBackView];
+ [_btnBackView mas_makeConstraints:^(MASConstraintMaker *make) {
+ make.left.bottom.right.equalTo(_tipView);
+ make.height.mas_equalTo(76);
+ }];
+ _btnBackView.backgroundColor=HDLEZ_COLOR_VIEW_FOREGROUND;
+ _btnBackView.layer.cornerRadius = 16;
+ _btnBackView.layer.maskedCorners = kCALayerMinXMinYCorner | kCALayerMaxXMinYCorner;
+
+
+ //宸茶繛鎺ユ寜閽�
+ _connectedBtn=[[UIButton alloc] init];
+ [_btnBackView addSubview:_connectedBtn];
+ [_connectedBtn mas_makeConstraints:^(MASConstraintMaker *make) {
+ make.left.equalTo(_tipView).offset(78);
+ make.right.equalTo(_tipView).offset(-78);
+ make.top.equalTo(_btnBackView).offset(12);
+ make.height.mas_equalTo(44);
+ }];
+ _connectedBtn.layer.cornerRadius = 22;
+ [_connectedBtn setBackgroundColor:HDLEZ_COLOR_BACKGROUND_BUTTON];
+ [_connectedBtn setTitle:HDLEZLocallizedString(@"wifi_config_connected") forState:UIControlStateNormal];
+ _connectedBtn.titleLabel.font=HDLEZ_Get_FontBoldWithSize(HDLEZ_FontSize_16);
+ [_connectedBtn setTitleColor:HDLEZ_COLOR_TEXT_WHITE forState:UIControlStateNormal];
+ [_connectedBtn addTarget:self action:@selector(Connected) forControlEvents:UIControlEventTouchUpInside];
+ }
+ return _tipView;
+}
+
+/*灞曠ず寮曞view锛堣悿鐭抽儴鍒嗚澶囦笉鑳介�氳繃璇ユ祦绋嬭繘琛岄厤缃戯級
+ */
+-(void)showConnectWifiTipView{
+ self.title = HDLEZLocallizedString(@"wifi_config_net_work");
+ [self.tipView setHidden:NO];
+
+}
+
+/*宸茶繛鎺�
+ */
+-(void)Connected{
+ self.title = HDLEZLocallizedString(@"ad_result_title");
+
+ //闅愯棌鎸囩ずview
+ [self.tipView setHidden:YES];
+
+ [self doSearchDevice];
+}
+
+- (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",@"姝よ澶囧凡琚埆浜烘坊鍔�")];
}
else
{
- [UIView dd_showMessage:NSLocalizedString(@"wifi_add_fail",@"娣诲姞澶辫触")];
+// [UIView dd_showMessage:NSLocalizedString(@"wifi_add_fail",@"娣诲姞澶辫触")];
+ [UIView dd_showMessage:responseData.message];
}
}
--
Gitblit v1.8.0