143 lines
5.1 KiB
Mathematica
143 lines
5.1 KiB
Mathematica
|
|
//
|
|||
|
|
// KBCancelAccountVC.m
|
|||
|
|
// keyBoard
|
|||
|
|
//
|
|||
|
|
// 注销账户页面:顶部标题 + 中间 HTML 协议展示 + 底部注销按钮
|
|||
|
|
//
|
|||
|
|
|
|||
|
|
#import "KBCancelAccountVC.h"
|
|||
|
|
#import <WebKit/WebKit.h>
|
|||
|
|
#import <Masonry/Masonry.h>
|
|||
|
|
#import "KBMyVM.h"
|
|||
|
|
#import "KBAlert.h"
|
|||
|
|
|
|||
|
|
@interface KBCancelAccountVC ()
|
|||
|
|
|
|||
|
|
@property (nonatomic, strong) UILabel *titleLabel;
|
|||
|
|
@property (nonatomic, strong) WKWebView *webView;
|
|||
|
|
@property (nonatomic, strong) UIButton *cancelAccountBtn;
|
|||
|
|
@property (nonatomic, strong) KBMyVM *myVM;
|
|||
|
|
|
|||
|
|
@end
|
|||
|
|
|
|||
|
|
@implementation KBCancelAccountVC
|
|||
|
|
|
|||
|
|
- (void)viewDidLoad {
|
|||
|
|
[super viewDidLoad];
|
|||
|
|
self.kb_titleLabel.text = KBLocalized(@"Cancel Account");
|
|||
|
|
self.view.backgroundColor = [UIColor colorWithHex:0xFFFFFF];
|
|||
|
|
|
|||
|
|
[self.view addSubview:self.titleLabel];
|
|||
|
|
[self.view addSubview:self.webView];
|
|||
|
|
[self.view addSubview:self.cancelAccountBtn];
|
|||
|
|
|
|||
|
|
[self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
|||
|
|
make.top.equalTo(self.view).offset(KB_NAV_TOTAL_HEIGHT + 20);
|
|||
|
|
make.left.equalTo(self.view).offset(16);
|
|||
|
|
make.right.equalTo(self.view).offset(-16);
|
|||
|
|
}];
|
|||
|
|
|
|||
|
|
[self.cancelAccountBtn mas_makeConstraints:^(MASConstraintMaker *make) {
|
|||
|
|
make.left.equalTo(self.view).offset(16);
|
|||
|
|
make.right.equalTo(self.view).offset(-16);
|
|||
|
|
make.bottom.equalTo(self.view.mas_safeAreaLayoutGuideBottom).offset(-12);
|
|||
|
|
make.height.mas_equalTo(56);
|
|||
|
|
}];
|
|||
|
|
|
|||
|
|
[self.webView mas_makeConstraints:^(MASConstraintMaker *make) {
|
|||
|
|
make.top.equalTo(self.titleLabel.mas_bottom).offset(16);
|
|||
|
|
make.left.equalTo(self.view).offset(16);
|
|||
|
|
make.right.equalTo(self.view).offset(-16);
|
|||
|
|
make.bottom.equalTo(self.cancelAccountBtn.mas_top).offset(-16);
|
|||
|
|
}];
|
|||
|
|
|
|||
|
|
[self fetchAgreement];
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
- (void)fetchAgreement {
|
|||
|
|
__weak typeof(self) weakSelf = self;
|
|||
|
|
[self.myVM fetchCancelAccountWarningWithCompletion:^(NSString * _Nullable html, NSError * _Nullable error) {
|
|||
|
|
if (html.length > 0) {
|
|||
|
|
weakSelf.htmlContent = html;
|
|||
|
|
}
|
|||
|
|
[weakSelf loadHTMLContent];
|
|||
|
|
}];
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
- (void)loadHTMLContent {
|
|||
|
|
NSString *html = self.htmlContent ?: @"";
|
|||
|
|
// 包裹一层基本样式,适配移动端
|
|||
|
|
NSString *wrappedHTML = [NSString stringWithFormat:
|
|||
|
|
@"<html><head>"
|
|||
|
|
"<meta name='viewport' content='width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no'>"
|
|||
|
|
"<style>"
|
|||
|
|
"body { font-family: -apple-system, sans-serif; font-size: 15px; color: #333; "
|
|||
|
|
"line-height: 1.6; padding: 0; margin: 0; word-wrap: break-word; }"
|
|||
|
|
"</style></head><body>%@</body></html>", html];
|
|||
|
|
[self.webView loadHTMLString:wrappedHTML baseURL:nil];
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
#pragma mark - Actions
|
|||
|
|
|
|||
|
|
- (void)onTapCancelAccount {
|
|||
|
|
[[KBMaiPointReporter sharedReporter] reportClickWithEventName:@"click_cancel_account_confirm_btn"
|
|||
|
|
pageId:@"cancel_account"
|
|||
|
|
elementId:@"cancel_account_confirm_btn"
|
|||
|
|
extra:nil
|
|||
|
|
completion:nil];
|
|||
|
|
KBWeakSelf;
|
|||
|
|
|
|||
|
|
[KBAlert confirmTitle:KBLocalized(@"Cancel Account") message:KBLocalized(@"After cancellation, your account will be deactivated and local login data will be cleared. Continue?") ok:KBLocalized(@"Confirm") cancel:KBLocalized(@"Cancel") completion:^(BOOL ok) {
|
|||
|
|
if (!ok) { return; }
|
|||
|
|
[weakSelf.myVM cancelAccountWithCompletion:nil];
|
|||
|
|
}];
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
#pragma mark - Lazy
|
|||
|
|
|
|||
|
|
- (UILabel *)titleLabel {
|
|||
|
|
if (!_titleLabel) {
|
|||
|
|
_titleLabel = [UILabel new];
|
|||
|
|
_titleLabel.text = KBLocalized(@"Cancel Account Notice");
|
|||
|
|
_titleLabel.textColor = [UIColor colorWithHex:KBBlackValue];
|
|||
|
|
_titleLabel.font = [KBFont bold:20];
|
|||
|
|
_titleLabel.numberOfLines = 0;
|
|||
|
|
}
|
|||
|
|
return _titleLabel;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
- (WKWebView *)webView {
|
|||
|
|
if (!_webView) {
|
|||
|
|
WKWebViewConfiguration *config = [[WKWebViewConfiguration alloc] init];
|
|||
|
|
_webView = [[WKWebView alloc] initWithFrame:CGRectZero configuration:config];
|
|||
|
|
_webView.backgroundColor = UIColor.whiteColor;
|
|||
|
|
_webView.scrollView.showsVerticalScrollIndicator = YES;
|
|||
|
|
_webView.layer.cornerRadius = 12;
|
|||
|
|
_webView.layer.masksToBounds = YES;
|
|||
|
|
}
|
|||
|
|
return _webView;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
- (UIButton *)cancelAccountBtn {
|
|||
|
|
if (!_cancelAccountBtn) {
|
|||
|
|
_cancelAccountBtn = [UIButton buttonWithType:UIButtonTypeSystem];
|
|||
|
|
[_cancelAccountBtn setTitle:KBLocalized(@"Confirm Cancel Account") forState:UIControlStateNormal];
|
|||
|
|
[_cancelAccountBtn setTitleColor:UIColor.whiteColor forState:UIControlStateNormal];
|
|||
|
|
_cancelAccountBtn.titleLabel.font = [KBFont medium:16];
|
|||
|
|
_cancelAccountBtn.backgroundColor = [UIColor colorWithHex:0xFF0000];
|
|||
|
|
_cancelAccountBtn.layer.cornerRadius = 12;
|
|||
|
|
_cancelAccountBtn.layer.masksToBounds = YES;
|
|||
|
|
[_cancelAccountBtn addTarget:self action:@selector(onTapCancelAccount) forControlEvents:UIControlEventTouchUpInside];
|
|||
|
|
}
|
|||
|
|
return _cancelAccountBtn;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
- (KBMyVM *)myVM {
|
|||
|
|
if (!_myVM) {
|
|||
|
|
_myVM = [[KBMyVM alloc] init];
|
|||
|
|
}
|
|||
|
|
return _myVM;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
@end
|