萤石云 iOSSDK,移植跨平台相关工程
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
//
//  HDLEZTempDetailViewController.m
//  EZSDK
//
//  Created by 陈启扬 on 2023/3/14.
//
 
#import "HDLEZTempDetailViewController.h"
#import "HDLEZTempDetailView.h"
#import "HDLEZVisitorRecordViewController.h"
@interface HDLEZTempDetailViewController ()
@property(nonatomic,strong)HDLEZTempDetailView *tempDetailView; //临时密码详情view
 
@end
 
@implementation HDLEZTempDetailViewController
 
- (void)viewDidLoad {
    [super viewDidLoad];
    [self setTopBarViewWithTitle:HDLEZLocallizedString(@"device_temp_pass")];
    [self.topBarView.bottomLine setHidden:YES];
    // Do any additional setup after loading the view.
}
 
-(void)addSubViews{
    
    //临时密码详情view
    _tempDetailView=[[HDLEZTempDetailView alloc] init];
    [self.view addSubview:_tempDetailView];
    [_tempDetailView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.view).offset(HDLEZ_APP_TOP_BAR_HEIGHT);
        make.left.right.equalTo(self.view);
        make.bottom.equalTo(self.view);
    }];
    _tempDetailView.temPdetailModel=self.temPdetailModel;
    __weak __typeof(self)weakSelf = self;
    _tempDetailView.longTapPassWordBlock = ^(NSString * _Nonnull content) {//长按密码
        UIPasteboard *pasteboard = [UIPasteboard generalPasteboard];
        pasteboard.string = content;
        [weakSelf.view makeToast:HDLEZLocallizedString(@"device_temp_copied")
                        duration:1.5
                        position:@"center"];
    };
    _tempDetailView.deletePassWordBlock = ^(NSString * _Nonnull content) {//点击删除
        [weakSelf deletePass];
    };
 
    
}
 
/*点击返回
 */
-(void)goBack{
    NSArray *viewControllers = self.navigationController.viewControllers;
    for (UIViewController *vc in viewControllers)
    {
        if ([vc isKindOfClass:[HDLEZVisitorRecordViewController class]])
        {//跳转到临时密码列表页
            [self.navigationController popToViewController:vc animated:YES];
            break;
        }
        
    }
}
 
/*删除密码
 */
-(void)deletePass{
    UIAlertController *alert=[UIAlertController alertControllerWithTitle:HDLEZLocallizedString(@"alert_title") message:HDLEZLocallizedString(@"device_temp_sure_to_delete") preferredStyle:UIAlertControllerStyleAlert];
    UIAlertAction *cancle=[UIAlertAction actionWithTitle:HDLEZLocallizedString(@"device_temp_cancle") style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {
        
    }];
    __weak __typeof(self)weakSelf = self;
    UIAlertAction *sure=[UIAlertAction actionWithTitle:HDLEZLocallizedString(@"device_temp_sure") style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
        [weakSelf sureToDelete];
    }];
    [alert addAction:cancle];
    [alert addAction:sure];
    [self presentViewController:alert animated:YES completion:nil];
 
}
 
/*确认删除
 */
-(void)sureToDelete{
    [MBProgressHUD showHUDAddedTo:self.view animated:YES];
    __weak __typeof(self)weakSelf = self;
    [[EZHttpUtil sharedManager] deleteTempByHDL:_temPdetailModel.extVisitorId deviceId:self.deviceId completion:^(ResponseData * _Nonnull responseData) {
        HDLEZLog(@"删除临时密码结果:%@",responseData.data);
        [MBProgressHUD hideHUDForView:weakSelf.view animated:YES];
        if (responseData.success) {
            [[NSNotificationCenter defaultCenter] postNotificationName:HDLEZNotificationChangeTemP object:nil];
            [weakSelf goBack];
        }else{
            [weakSelf.view makeToast:responseData.message
                            duration:1.5
                            position:@"center"];
        }
    }];
}
@end