123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193 |
- //
- // AccountDeleteViewController.m
- // KulexiuForTeacher
- //
- // Created by 王智 on 2022/7/12.
- //
- #import "AccountDeleteViewController.h"
- #import "DeleteAccountBodyView.h"
- #import "VeriCheckView.h"
- #import "LoginViewController.h"
- #import "AppDelegate.h"
- #import "CustomNavViewController.h"
- #import "JPUSHService.h"
- #import "UserInfoManager.h"
- #import "GroupQuitAlert.h"
- #import "KSDeleteFailedAlertView.h"
- @interface AccountDeleteViewController ()
- {
- NSTimer *_time;
- int _count;
- }
- @property (nonatomic, strong) DeleteAccountBodyView *bodyView;
- @property (nonatomic, strong) GroupQuitAlert *alertView;
- @property (nonatomic, strong) KSDeleteFailedAlertView *failAlert;
- @end
- @implementation AccountDeleteViewController
- - (void)viewDidLoad {
- [super viewDidLoad];
- // Do any additional setup after loading the view.
- [self allocTitle:@"注销账号"];
- [self configUI];
- }
- - (void)configUI {
-
- self.bodyView = [DeleteAccountBodyView shareInstance];
- [self.scrollView addSubview:_bodyView];
- [_bodyView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.right.mas_equalTo(self.view);
- make.top.mas_equalTo(self.scrollView.mas_top);
- make.bottom.mas_equalTo(self.scrollView.mas_bottom);
- make.height.mas_equalTo(KPortraitHeight - kNaviBarHeight);
- }];
- MJWeakSelf;
- [_bodyView deleteAccountCallback:^(DELETEACCOUNT action, NSDictionary * _Nonnull parm) {
- [weakSelf operationWithAction:action parm:parm];
- }];
- self.bodyView.lineView.backgroundColor = CLIENT_THEMECOLOR;
- [self.bodyView.codeButton setTitleColor:CLIENT_THEMECOLOR forState:UIControlStateNormal];
-
- if ([UserDefault(TENANT_ID) integerValue] > 0) {
- CAGradientLayer *colorLayer = [UIView createGradientLayerFromColor:HexRGB(0xFF204B) startPoint:CGPointMake(1, 0.5) endColor:HexRGB(0xFE5B71) endPoint:CGPointMake(0, 0.5) bounds:CGRectMake(0, 0, KPortraitWidth - 25 *2, 44)];
- [self.bodyView.sureButton.layer addSublayer:colorLayer];
- }
- }
- - (void)operationWithAction:(DELETEACCOUNT)action parm:(NSDictionary *)parm {
-
- if (action == DELETEACCOUNT_CODE) {
- // 图形化验证
- [self veriCheckWithParm:parm];
- }
- else if (action == DELETEACCOUNT_SURE) {
- MJWeakSelf;
- self.alertView = [GroupQuitAlert shareInstance];
- [self.alertView configTitle:@"提示" desc:@"注销账号后您所有的留存信息将被清空且无法恢复,请谨慎操作" callback:^(BOOL isSure) {
- if (isSure) {
- [weakSelf deleteAccount:[parm ks_stringValueForKey:@"code"]];
- }
- }];
- [self.alertView showAlert];
- }
- }
- #pragma mark ----- 删除账号
- - (void)deleteAccount:(NSString *)code {
- [LOADING_MANAGER showHUD];
- [KSNetworkingManager logoffRequest:KS_GET smsCode:code success:^(NSDictionary * _Nonnull dic) {
- [LOADING_MANAGER removeHUD];
- if ([dic ks_integerValueForKey:@"code"] == 200 && [dic ks_boolValueForKey:@"status"]) {
- [LOADING_MANAGER KSShowMsg:@"注销成功,感谢您的使用" promptCompletion:^{
- [self successDeleteBack];
- }];
- }
- else if ([dic ks_integerValueForKey:@"code"] == 5201) {
- [self showFailAlert:@[]];
- }
- else {
- [LOADING_MANAGER MBShowAUTOHidingInWindow:MESSAGEKEY];
- }
- } faliure:^(NSError * _Nonnull error) {
- [LOADING_MANAGER removeHUD];
- }];
- }
- - (void)showFailAlert:(NSArray *)messageList {
- self.failAlert = [KSDeleteFailedAlertView shareIntance];
- [self.failAlert configWithSource:messageList];
- [self.failAlert showAlert];
- }
- - (void)successDeleteBack {
- [APPLOGIN_MANAGER logoutActionWithMsg:@""];
- }
- #pragma mark --- 验证码
- - (void)veriCheckWithParm:(NSDictionary *)parm {
- NSString *phoneNo = [parm ks_stringValueForKey:@"phone"];
- // 图形化验证
- VeriCheckView *view = [VeriCheckView shareInstanceShowInView:self.scrollView];
- __weak typeof(view) weakView = view;
- [view showViewCallback:^(NSDictionary * _Nonnull parm) {
- [self veriImageCodeWithParm:parm checkView:weakView];
- }];
- [view disPlayImageWithPhone:phoneNo];
- }
- // 发送短信 校验图形验证码
- - (void)veriImageCodeWithParm:(NSDictionary *)parm checkView:(VeriCheckView *)checkView {
- [LOADING_MANAGER showHUD];
- [KSNetworkingManager sendSmsRequest:KS_POST mobile:[parm ks_stringValueForKey:@"phone"] type:@"LOGOFF" code:[parm ks_stringValueForKey:@"code"] success:^(NSDictionary * _Nonnull dic) {
- [LOADING_MANAGER removeHUD];
- if ([dic ks_integerValueForKey:@"code"] == 200 && [dic ks_boolValueForKey:@"status"]) {
- [checkView hiddView];
- [LOADING_MANAGER MBShowAUTOHidingInWindow:@"验证码已发送"];
- [self codeButtonCountDown];
- }
- else {
- [LOADING_MANAGER MBShowAUTOHidingInWindow:MESSAGEKEY];
- }
- } faliure:^(NSError * _Nonnull error) {
- [LOADING_MANAGER removeHUD];
- }];
- }
- - (void)codeButtonCountDown {
- _bodyView.codeButton.userInteractionEnabled = NO;
- [_bodyView.codeButton setTitleColor:HexRGB(0xe5e5e5) forState:UIControlStateNormal];
- __weak typeof(self) weakSelf = self;
- _time = [NSTimer scheduledTimerWithTimeInterval:1 target:weakSelf selector:@selector(buttonChangeAction) userInfo:nil repeats:YES];
- [[NSRunLoop mainRunLoop] addTimer:_time forMode:NSRunLoopCommonModes];
- _count = 59;
- }
- - (void)clearButtonState {
- [_time invalidate];
- _time = nil;
- _count = 0;
- [_bodyView.codeButton setTitle:@"获取验证码" forState:UIControlStateNormal];
- [_bodyView.codeButton setTitleColor:CLIENT_THEMECOLOR forState:UIControlStateNormal];
- _bodyView.codeButton.userInteractionEnabled = YES;
- }
- #pragma mark ---- 验证码按钮状态
- - (void)buttonChangeAction {
- _bodyView.codeButton.userInteractionEnabled = NO;
- NSString *title = [NSString stringWithFormat:@"%ds",_count];
- [_bodyView.codeButton setTitle:title forState:UIControlStateNormal];
- _count--;
- if(_count == -1){
- [_time invalidate];
- _time = nil;
- [_bodyView.codeButton setTitle:@"获取验证码" forState:UIControlStateNormal];
- [_bodyView.codeButton setTitleColor:CLIENT_THEMECOLOR forState:UIControlStateNormal];
- _bodyView.codeButton.userInteractionEnabled = YES;
- }
- }
- - (void)dealloc {
- [_time invalidate];
- _time = nil;
- }
- /*
- #pragma mark - Navigation
- // In a storyboard-based application, you will often want to do a little preparation before navigation
- - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
- // Get the new view controller using [segue destinationViewController].
- // Pass the selected object to the new view controller.
- }
- */
- @end
|