DeleteAccountPopupView.m 3.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. //
  2. // DeleteAccountPopupView.m
  3. // kneet
  4. //
  5. // Created by Jason Lee on 5/12/15.
  6. // Copyright (c) 2015 ntels. All rights reserved.
  7. //
  8. #import "JDObject.h"
  9. #import "RequestHandler.h"
  10. #import "JDJSONModel.h"
  11. #import "CustomLabel.h"
  12. #import "DeleteAccountPopupView.h"
  13. @interface DeleteAccountPopupView () {
  14. }
  15. @end
  16. @implementation DeleteAccountPopupView
  17. - (id)initFromNib {
  18. for (UIView *view in [CommonUtil nibViews:@"DeleteAccountPopupView"]) {
  19. if ([view isKindOfClass:[DeleteAccountPopupView class]]) {
  20. self = (DeleteAccountPopupView *)view;
  21. //XIB의 경우, 현재 화면 사이즈로 맞춰줘야 함.
  22. self.frame = [UIScreen mainScreen].bounds;
  23. self.lblTitle.text = NSLocalizedString(@"계정 삭제",nil);
  24. //Localization
  25. [self.imgTitleBar setImage:[UIImage imageNamed:@"img_popup_bg_head"]inset:UIEdgeInsetsMake(kfTopInset,kfRightInset,kfBottomInset,kfLeftInset)];
  26. [self.btnConfirm setBackgroundImage:[UIImage imageNamed:@"img_popup_btn_right"] forState:UIControlStateNormal capInsets:UIEdgeInsetsMake(kfTopInset,kfRightInset,kfBottomInset,kfLeftInset)];
  27. [self.btnConfirm setBackgroundImage:[UIImage imageNamed:@"img_popup_btn_right_press"] forState:UIControlStateHighlighted capInsets:UIEdgeInsetsMake(kfTopInset,kfRightInset,kfBottomInset,kfLeftInset)];
  28. [self.btnCancel setBackgroundImage:[UIImage imageNamed:@"img_popup_btn_left"] forState:UIControlStateNormal capInsets:UIEdgeInsetsMake(kfTopInset,kfRightInset,kfBottomInset,kfLeftInset)];
  29. [self.btnCancel setBackgroundImage:[UIImage imageNamed:@"img_popup_btn_left_press"] forState:UIControlStateHighlighted capInsets:UIEdgeInsetsMake(kfTopInset,kfRightInset,kfBottomInset,kfLeftInset)];
  30. //Localization
  31. [self.btnConfirm setTitle:NSLocalizedString(@"예", @"예") forState:UIControlStateNormal];
  32. [self.btnCancel setTitle:NSLocalizedString(@"아니오", @"아니오") forState:UIControlStateNormal];
  33. }
  34. }
  35. return self;
  36. }
  37. - (void)didMoveToSuperview {
  38. }
  39. //계정 삭제
  40. - (void)requestDeleteAccount {
  41. // NSString *path = [NSString stringWithFormat:API_DELETE_ACCOUNT, [JDFacade facade].loginUser.memberId];
  42. NSString *path = [[JDFacade facade] getUrlWithCustGroupIDAndMemberID:API_DELETE_ACCOUNT];
  43. [[RequestHandler handler] sendAsyncRequestAPIPath:path method:ksHTTPRequestDELETE parameters:nil modelClass:[JDJSONModel class] showLoadingView:YES completion:^(id responseObject) {
  44. //자동 로그인 설정 - 취소
  45. [[JDFacade facade] storeObjectToUserDefaults:@(NO) forKey:USDEF_APP_AUTO_LOGIN];
  46. [[JDFacade facade] removeObjectAtKeychain:USDEF_SESSION_AUTOTOKEN];
  47. [JDFacade facade].loginUser = nil;
  48. UIViewController *vc = [CommonUtil instantiateViewControllerWithIdentifier:@"LoginViewController" storyboardName:@"Main"];
  49. [[JDFacade facade] presentViewControllerByPush:vc];
  50. [super btnConfirmTouched:nil];
  51. } failure:^(id errorObject) {
  52. JDErrorModel *error = (JDErrorModel *)errorObject;
  53. [[JDFacade facade] alert:error.errorMessage];
  54. }];
  55. }
  56. - (void)btnConfirmTouched:(id)sender {
  57. [self requestDeleteAccount];
  58. }
  59. @end