Commit 1fd29804 cgx

注销按钮添加倒计时

1 个父辈 f3865b43
......@@ -123,14 +123,14 @@
[self startOpen];
// 注入js代码用于强制刷新小梦睡眠
// NSString *jsCallBack = @"window.parent.location.reload()";
// [self.aiWebView evaluateJavaScript:jsCallBack completionHandler:^(id _Nullable result, NSError * _Nullable error) {
// [self.aiWebView loadRequest:self.request];
// DSLog(@"注入成功...");
// if (error) {
// DSLog(@"err is %@", error.domain);
// }
// }];
// NSString *jsCallBack = @"window.parent.location.reload()";
// [self.aiWebView evaluateJavaScript:jsCallBack completionHandler:^(id _Nullable result, NSError * _Nullable error) {
// [self.aiWebView loadRequest:self.request];
// DSLog(@"注入成功...");
// if (error) {
// DSLog(@"err is %@", error.domain);
// }
// }];
}
}
}
......
......@@ -13,6 +13,9 @@
@property (nonatomic, strong) UIImageView *cryIV;
@property (nonatomic, strong) UILabel *redLab;
@property (nonatomic, strong) UIView *dealView;
@property (nonatomic, strong) UIButton *closeBtn;
@property (nonatomic, strong) NSTimer *closeTimer;
@property (nonatomic, assign) int totalSecond;
@end
@implementation CloseAlertView
......@@ -20,6 +23,8 @@
- (instancetype)initWithDelegate:(id<CloseAlertViewDelegate>)delegate {
if (self = [super initWithFrame:[UIScreen mainScreen].bounds]) {
_delegate = delegate;
_totalSecond = 10;
self.dk_backgroundColorPicker = DKColorPickerWithColors(ColorFromHex(0x6F7587), DSClearColor, DSWhite);
self.backgroundColor = [self.backgroundColor colorWithAlphaComponent:0.6];
......@@ -36,13 +41,21 @@
return self;
}
- (void)dealloc {
[_closeTimer invalidate];
_closeTimer = nil;
}
#pragma mark - public
- (void)showCloseUserAlertView {
[DSKeyWindow addSubview:self];
[self.closeTimer setFireDate:[NSDate date]];
}
- (void)dismissCloseUserAlertView {
[self removeFromSuperview];
[self.closeTimer setFireDate:[NSDate distantFuture]];
self.totalSecond = 10;
}
#pragma mark - actions
......@@ -129,7 +142,9 @@
UIButton *closeBtn = [UIButton btnWithTitle:@"注销" titleColor:BrandColor font:BoldFont(15) bgColor:DSClearColor];
[closeBtn addTarget:self action:@selector(closeAction) forControlEvents:UIControlEventTouchUpInside];
closeBtn.enabled = NO;
[_dealView addSubview:closeBtn];
self.closeBtn = closeBtn;
UIButton *cancelBtn = [UIButton btnWithTitle:@"取消" font:BoldFont(15)];
[cancelBtn dk_setTitleColorPicker:DKColorPickerWithKey(TEXT) forState:UIControlStateNormal];
......@@ -160,4 +175,25 @@
return _dealView;
}
- (NSTimer *)closeTimer {
if (!_closeTimer) {
WS(weakSelf);
_closeTimer = [NSTimer timerWithTimeInterval:1.0 repeats:YES block:^(NSTimer * _Nonnull timer) {
if (weakSelf.totalSecond == 0) {
[weakSelf.closeTimer setFireDate:[NSDate distantFuture]];
[weakSelf.closeBtn setTitle:@"注销" font:BoldFont(15)];
[weakSelf.closeBtn setTitleColor:BrandColor forState:UIControlStateNormal];
weakSelf.closeBtn.enabled = YES;
return;
}
weakSelf.closeBtn.enabled = NO;
[weakSelf.closeBtn setTitle:[NSString stringWithFormat:@"注销(%d)", weakSelf.totalSecond] font:BoldFont(15)];
[weakSelf.closeBtn dk_setTitleColorPicker:DKColorPickerWithColors(SubTitleColor, ColorFromHexA(0xFFFFFF, .5), DSWhite) forState:UIControlStateNormal];
weakSelf.totalSecond--;
}];
[[NSRunLoop currentRunLoop] addTimer:_closeTimer forMode:NSRunLoopCommonModes];
}
return _closeTimer;
}
@end
......@@ -88,7 +88,6 @@
+ (NSURLSessionDataTask *)revokeTokensRequestWithParams:(NSDictionary *)params completion:(void (^)(UserRequestModel *requestModel))completion
{
UserRequestModel * requestModel = [[UserRequestModel alloc] init];
return [self httpVendorPostRequestWithHost:@"https://appleid.apple.com/auth/revoke" params:params view:nil hasNetActivity:YES loadingInfo:nil hasFailInfo:YES success:^(NSDictionary *responseObj) {
} failure:^(id failureInfo) {
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!