// // RQProfileLogoutCell.m // SDJK // // Created by 张嵘 on 2021/8/2. // #import "RQProfileLogoutCell.h" @interface RQProfileLogoutCell () @property (nonatomic, readwrite, strong) RQProfileLogouItemViewModel *viewModel; @property (weak, nonatomic) IBOutlet UIButton *logoutBtn; @end @implementation RQProfileLogoutCell #pragma mark - PublicMethods + (instancetype)cellWithTableView:(UITableView *)tableView { static NSString *ID = @"RQProfileLogoutCell"; RQProfileLogoutCell *cell = [tableView dequeueReusableCellWithIdentifier:ID]; if (!cell) { cell = [self rq_viewFromXib]; cell.selectionStyle = UITableViewCellSelectionStyleNone; } return cell; } - (void)bindViewModel:(RQProfileLogouItemViewModel *)viewModel { _viewModel = viewModel; [_logoutBtn setTitleNormal:viewModel.title]; } #pragma mark - SystemMethods - (void)awakeFromNib { [super awakeFromNib]; _logoutBtn.layer.cornerRadius = RQ_FIT_HORIZONTAL(44.f) / 2.f; } - (void)setSelected:(BOOL)selected animated:(BOOL)animated { [super setSelected:selected animated:animated]; // Configure the view for the selected state } - (IBAction)logoutAction:(id)sender { if ([_viewModel.title isEqualToString:@"退出登录"]) { [_viewModel.logoutCommand execute:nil]; } else if ([_viewModel.title isEqualToString:@"注销账号"]) { [RQ_ALERT_MANAGER showAlertWithAlertType:RQAlertType_SignOut title:@"注销账号" message:@"注销账号将会永久删除当前用户所有数据,VIP用户的VIP权益也将失效,请谨慎操作!" confirmTitle:@"确认" cancelTitle:@"取消" confirmAction:^(__kindof QMUIDialogViewController * _Nonnull dialogViewController) { [MBProgressHUD rq_showTips:@"注销中..."]; [[RQ_HTTP_Service postDeletion] subscribeNext:^(id _Nullable x) { [MBProgressHUD rq_hideHUD]; [_viewModel.signoutCommand execute:nil]; } error:^(NSError * _Nullable error) { [MBProgressHUD rq_hideHUD]; [MBProgressHUD rq_showErrorTips:error]; }]; }]; } } @end