// // 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