RQProfileLogoutCell.m 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. //
  2. // RQProfileLogoutCell.m
  3. // SDJK
  4. //
  5. // Created by 张嵘 on 2021/8/2.
  6. //
  7. #import "RQProfileLogoutCell.h"
  8. @interface RQProfileLogoutCell ()
  9. @property (nonatomic, readwrite, strong) RQProfileLogouItemViewModel *viewModel;
  10. @property (weak, nonatomic) IBOutlet UIButton *logoutBtn;
  11. @end
  12. @implementation RQProfileLogoutCell
  13. #pragma mark - PublicMethods
  14. + (instancetype)cellWithTableView:(UITableView *)tableView {
  15. static NSString *ID = @"RQProfileLogoutCell";
  16. RQProfileLogoutCell *cell = [tableView dequeueReusableCellWithIdentifier:ID];
  17. if (!cell) {
  18. cell = [self rq_viewFromXib];
  19. cell.selectionStyle = UITableViewCellSelectionStyleNone;
  20. }
  21. return cell;
  22. }
  23. - (void)bindViewModel:(RQProfileLogouItemViewModel *)viewModel {
  24. _viewModel = viewModel;
  25. [_logoutBtn setTitleNormal:viewModel.title];
  26. }
  27. #pragma mark - SystemMethods
  28. - (void)awakeFromNib {
  29. [super awakeFromNib];
  30. _logoutBtn.layer.cornerRadius = RQ_FIT_HORIZONTAL(44.f) / 2.f;
  31. }
  32. - (void)setSelected:(BOOL)selected animated:(BOOL)animated {
  33. [super setSelected:selected animated:animated];
  34. // Configure the view for the selected state
  35. }
  36. - (IBAction)logoutAction:(id)sender {
  37. if ([_viewModel.title isEqualToString:@"退出登录"]) {
  38. [_viewModel.logoutCommand execute:nil];
  39. } else if ([_viewModel.title isEqualToString:@"注销账号"]) {
  40. [RQ_ALERT_MANAGER showAlertWithAlertType:RQAlertType_SignOut title:@"注销账号" message:@"注销账号将会永久删除当前用户所有数据,VIP用户的VIP权益也将失效,请谨慎操作!" confirmTitle:@"确认" cancelTitle:@"取消" confirmAction:^(__kindof QMUIDialogViewController * _Nonnull dialogViewController) {
  41. [MBProgressHUD rq_showTips:@"注销中..."];
  42. [[RQ_HTTP_Service postDeletion] subscribeNext:^(id _Nullable x) {
  43. [MBProgressHUD rq_hideHUD];
  44. [_viewModel.signoutCommand execute:nil];
  45. } error:^(NSError * _Nullable error) {
  46. [MBProgressHUD rq_hideHUD];
  47. [MBProgressHUD rq_showErrorTips:error];
  48. }];
  49. }];
  50. }
  51. }
  52. @end